/* ============================================================
   Motor PWA v2 — sistema de diseño
   Tokens inyectados por build.js: :root (claro) + [data-theme=dark]
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --radius: 22px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --tabbar-h: 66px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow: 0 12px 32px rgba(0,0,0,.13);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.22);
  --ease: cubic-bezier(.22,.9,.3,1);
  --good: #17916B;
  --bad: #D8453B;
  --warn: #C98A18;
}
:root[data-theme="dark"] {
  --shadow-sm: 0 2px 8px rgba(0,0,0,.4);
  --shadow: 0 12px 32px rgba(0,0,0,.5);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.65);
  --good: #45C48D;
  --bad: #FF6B60;
  --warn: #E9B44C;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  transition: background .3s var(--ease), color .3s var(--ease);
}
body.no-chrome { padding-bottom: 0; }

/* ============================================================
   Cabecera
   ============================================================ */
.app-header {
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 20px 8px;
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}
.app-header .logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  color: #fff; font-family: var(--font-display); font-weight: 800;
  font-size: 16px; flex-shrink: 0;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 38%, transparent);
}
.app-header .hgrow { flex: 1; min-width: 0; }
.app-header h1 {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header .tagline {
  font-size: 12px; color: var(--ink-soft); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface);
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; cursor: pointer;
  color: var(--ink-soft); font-size: 16px; padding: 0;
  transition: transform .15s var(--ease), background .2s;
}
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .dot { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transform: translate(12px,-12px); }

/* ============================================================
   Vistas
   ============================================================ */
.view { display: none; padding: 10px 20px 32px; }
.view.active { display: block; animation: rise .38s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { 0% { transform: scale(.85); opacity: 0 } 60% { transform: scale(1.04) } 100% { transform: scale(1); opacity: 1 } }

.stagger > * { animation: rise .4s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .02s }
.stagger > *:nth-child(2) { animation-delay: .06s }
.stagger > *:nth-child(3) { animation-delay: .10s }
.stagger > *:nth-child(4) { animation-delay: .14s }
.stagger > *:nth-child(5) { animation-delay: .18s }
.stagger > *:nth-child(n+6) { animation-delay: .22s }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================
   Tarjeta HOY (elemento firma)
   ============================================================ */
.today-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  padding: 28px 22px 22px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-2) 125%);
  box-shadow: 0 18px 40px color-mix(in srgb, var(--accent) 32%, transparent);
  animation: rise .5s .04s var(--ease) both;
}
.today-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .13;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}
.today-card::before {
  content: ""; position: absolute; width: 240px; height: 240px; border-radius: 50%;
  right: -90px; top: -110px; background: rgba(255,255,255,.16); pointer-events: none;
}
.today-card .eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; opacity: .88; margin: 0 0 12px;
  position: relative; z-index: 1;
}
.today-card h2 {
  font-family: var(--font-display);
  font-size: 27px; line-height: 1.18; font-weight: 800;
  margin: 0 0 12px; letter-spacing: -.025em; position: relative; z-index: 1;
}
.today-card p { margin: 0 0 8px; font-size: 15.5px; opacity: .96; position: relative; z-index: 1; }
.today-card .ref { font-size: 12.5px; opacity: .82; font-style: italic; }
.today-actions { display: flex; gap: 8px; margin-top: 18px; position: relative; z-index: 1; flex-wrap: wrap; }
.btn-ghost {
  appearance: none; border: 1px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.16); color: #fff;
  border-radius: 999px; padding: 9px 16px;
  font: 600 13px var(--font-body); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .18s, transform .12s var(--ease);
  backdrop-filter: blur(4px);
}
.btn-ghost:active { transform: scale(.95); background: rgba(255,255,255,.28); }
.btn-ghost.on { background: #fff; color: var(--accent); border-color: #fff; }

/* ============================================================
   Secciones y tipografía
   ============================================================ */
.section-title {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700; letter-spacing: -.005em;
  margin: 26px 0 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.section-title small { font-family: var(--font-body); font-weight: 500; font-size: 12px; color: var(--ink-soft); flex-shrink: 0; }
.section-title button { appearance: none; background: none; border: none; color: var(--accent); font: 600 12.5px var(--font-body); cursor: pointer; padding: 0; }
.hint { font-size: 13px; color: var(--ink-soft); margin: 0 2px 12px; line-height: 1.5; }

/* ============================================================
   Tarjetas
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 10px;
  position: relative;
  transition: transform .14s var(--ease), border-color .18s, box-shadow .18s;
}
.card h3 { font-family: var(--font-display); font-size: 15.5px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; padding-right: 26px; }
.card p { margin: 0; font-size: 13.5px; color: var(--ink-soft); }
.card .tag {
  display: inline-block; margin-top: 9px; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.card.tappable { cursor: pointer; }
.card.tappable:active { transform: scale(.985); border-color: var(--accent); }
.card.seen::after {
  content: "✓"; position: absolute; right: 14px; bottom: 12px;
  color: var(--accent); font-size: 12px; font-weight: 700; opacity: .75;
}
.fav-btn {
  position: absolute; top: 12px; right: 10px;
  appearance: none; background: none; border: none; cursor: pointer;
  font-size: 17px; line-height: 1; padding: 4px; color: var(--ink-soft); opacity: .45;
  transition: transform .18s var(--ease), opacity .18s;
}
.fav-btn.on { opacity: 1; color: var(--accent); animation: pop .3s var(--ease); }
.fav-btn:active { transform: scale(1.25); }

/* ============================================================
   Pills / segmentos / búsqueda
   ============================================================ */
.pill-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.pill-row::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0; padding: 8px 15px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font: 600 13px var(--font-body); color: var(--ink-soft); cursor: pointer;
  transition: all .18s var(--ease);
}
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 34%, transparent); }
.pill:active { transform: scale(.95); }

.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; margin-bottom: 14px; }
.seg button {
  flex: 1; appearance: none; border: none; background: none; cursor: pointer;
  padding: 8px 4px; border-radius: 999px; font: 600 13px var(--font-body); color: var(--ink-soft);
  transition: all .2s var(--ease);
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap input { padding-left: 40px; }
.search-wrap::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 15px; height: 15px;
  transform: translateY(-50%); opacity: .5; pointer-events: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* ============================================================
   Detalle
   ============================================================ */
.detail { animation: rise .3s var(--ease) both; }
.detail-back {
  appearance: none; background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  font: 600 13.5px var(--font-body); padding: 8px 14px 8px 10px; margin: 2px 0 16px; cursor: pointer;
  border-radius: 999px; display: inline-flex; align-items: center; gap: 4px;
}
.detail-back:active { transform: scale(.96); }
.detail h2 { font-family: var(--font-display); font-size: 23px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.025em; line-height: 1.2; }
.detail .meta { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 16px; }
.detail .body { font-size: 15.5px; white-space: pre-line; line-height: 1.65; }
.detail ul { padding-left: 18px; font-size: 15px; margin: 0 0 16px; }
.detail li { margin-bottom: 8px; }
.detail .block {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 16px; margin: 0 0 12px;
}
.detail .block h4 {
  font-family: var(--font-display); font-size: 12px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--accent); margin: 0 0 8px;
}
.detail .block ul { margin: 0; }
.detail .block ol { margin: 0; padding-left: 20px; font-size: 15px; }
.detail .block ol li { margin-bottom: 9px; }

/* ============================================================
   Plan / checklist
   ============================================================ */
.plan-progress {
  height: 9px; border-radius: 99px; background: var(--surface-2);
  overflow: hidden; margin: 6px 0 6px;
}
.plan-progress > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s var(--ease); }
.check-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 8px; cursor: pointer;
  transition: border-color .2s, transform .12s var(--ease), opacity .2s;
}
.check-item:active { transform: scale(.99); }
.check-item.today-step { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.check-item .box {
  width: 23px; height: 23px; border-radius: 8px; flex-shrink: 0; margin-top: 1px;
  border: 2px solid color-mix(in srgb, var(--ink-soft) 55%, transparent); display: grid; place-items: center;
  color: #fff; font-size: 13px; transition: all .18s var(--ease);
}
.check-item.done .box { background: var(--accent); border-color: var(--accent); animation: check-pop .3s var(--ease); }
@keyframes check-pop { 45% { transform: scale(1.28) rotate(-6deg); } }
.check-item.done .txt b { opacity: .5; text-decoration: line-through; }
.check-item.done .txt span { opacity: .5; }
.check-item .txt { min-width: 0; }
.check-item .txt b { display: block; font-size: 14.5px; font-weight: 700; }
.check-item .txt span { font-size: 13px; color: var(--ink-soft); display: block; }
.check-item .badge-day {
  margin-left: auto; flex-shrink: 0; font-size: 10px; font-weight: 800; letter-spacing: .08em;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 3px 8px; border-radius: 999px; text-transform: uppercase; align-self: center;
}

/* ============================================================
   Rachas / anillo de progreso
   ============================================================ */
.ring-wrap { display: grid; place-items: center; position: relative; padding: 8px 0 2px; }
.ring { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-linecap: round; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: url(#ringGrad); transition: stroke-dashoffset .8s var(--ease); }
.ring-center {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
}
.ring-center .num { font-family: var(--font-display); font-size: 46px; font-weight: 800; line-height: 1; color: var(--ink); letter-spacing: -.03em; }
.ring-center .lbl { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.streak-flame { font-size: 22px; display: block; margin-bottom: -2px; }

.week-dots { display: flex; justify-content: center; gap: 8px; margin: 18px 0 6px; }
.week-dots .d {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid transparent; transition: all .25s var(--ease);
}
.week-dots .d.on { background: var(--accent); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 34%, transparent); }
.week-dots .d.today { border-color: var(--accent); }

/* Mapa de calor anual */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.heat::-webkit-scrollbar { display: none; }
.heat i { width: 11px; height: 11px; border-radius: 3px; background: var(--surface-2); display: block; }
.heat i.l1 { background: color-mix(in srgb, var(--accent) 32%, var(--surface-2)); }
.heat i.l2 { background: color-mix(in srgb, var(--accent) 62%, var(--surface-2)); }
.heat i.l3 { background: var(--accent); }

/* ============================================================
   Formularios
   ============================================================ */
input[type="number"], input[type="text"], input[type="date"], input[type="time"],
input[type="password"], select, textarea {
  width: 100%; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 14px; font: 500 15px var(--font-body);
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.55; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px; }
label.f { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 5px; }
.form-grid { display: grid; gap: 11px; margin-bottom: 6px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  appearance: none; border: none; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font: 700 15px var(--font-body); padding: 13px 18px; cursor: pointer;
  flex-shrink: 0; transition: transform .12s var(--ease), opacity .2s, box-shadow .2s;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 30%, transparent);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn.full { width: 100%; margin-top: 10px; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); box-shadow: none; font-weight: 600; }
.btn.soft { background: var(--surface-2); color: var(--ink); box-shadow: none; }
.btn.outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); box-shadow: none; }
.btn:disabled { opacity: .5; box-shadow: none; cursor: default; }
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-row .btn { flex: 1; margin-top: 0; }

/* ============================================================
   Estadísticas / gráfica
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat-grid.three { grid-template-columns: repeat(3, 1fr); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px;
}
.stat .v { font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: -.025em; line-height: 1.2; }
.stat .k { font-size: 11.5px; color: var(--ink-soft); line-height: 1.35; margin-top: 2px; }
.stat .v.good { color: var(--good); }
.stat .v.bad { color: var(--bad); }
.stat.hero { grid-column: 1 / -1; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 28%, transparent); }
.stat.hero .v { font-size: 30px; color: #fff; }
.stat.hero .k { color: rgba(255,255,255,.85); }

.chart { width: 100%; height: 150px; margin: 6px 0 12px; overflow: visible; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .area { fill: url(#areaGrad); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { fill: var(--accent); }
.chart .lbl { font: 500 10px var(--font-body); fill: var(--ink-soft); }
.bars { display: flex; align-items: flex-end; gap: 5px; height: 110px; margin: 10px 0 6px; }
.bars .b { flex: 1; background: var(--surface-2); border-radius: 6px 6px 3px 3px; position: relative; min-height: 3px; transition: height .5s var(--ease); }
.bars .b.on { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.bars-x { display: flex; gap: 5px; }
.bars-x span { flex: 1; text-align: center; font-size: 9.5px; color: var(--ink-soft); }

/* ============================================================
   Registros
   ============================================================ */
.entry-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
  animation: rise .3s var(--ease) both;
}
.entry-row .l { min-width: 0; flex: 1; }
.entry-row .l b { font-size: 14.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-row .l span { font-size: 12.5px; color: var(--ink-soft); }
.entry-row .r { text-align: right; font-family: var(--font-display); font-weight: 800; font-size: 15px; flex-shrink: 0; }
.entry-row .r small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 11px; color: var(--ink-soft); text-transform: capitalize; }
.entry-row .del { background: none; border: none; color: var(--ink-soft); font-size: 15px; cursor: pointer; padding: 6px; opacity: .55; flex-shrink: 0; }
.entry-row .del:active { opacity: 1; transform: scale(1.15); }
.entry-row .status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.empty {
  text-align: center; color: var(--ink-soft); font-size: 14px;
  padding: 32px 20px; border: 1.5px dashed var(--line); border-radius: var(--radius-sm);
  line-height: 1.5;
}
.empty .ico { font-size: 30px; display: block; margin-bottom: 10px; opacity: .55; }

/* ============================================================
   Respiración
   ============================================================ */
.breathe-stage { display: grid; place-items: center; padding: 26px 0 8px; position: relative; }
.breathe-halo {
  position: absolute; width: 250px; height: 250px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 68%);
  transform: scale(.8); transition: transform 4s ease-in-out, opacity 1s; opacity: .8;
}
.breathe-halo.in { transform: scale(1.18); }
.breathe-circle {
  width: 178px; height: 178px; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, var(--accent-2), var(--accent));
  display: grid; place-items: center; color: #fff; text-align: center;
  font: 700 18px var(--font-display); cursor: pointer; position: relative;
  transform: scale(.72); transition: transform 4s ease-in-out;
  box-shadow: 0 0 70px color-mix(in srgb, var(--accent) 45%, transparent);
}
.breathe-circle.in { transform: scale(1.06); }
.breathe-circle.hold { transition-duration: .3s; }
.breathe-ring { position: absolute; inset: -12px; transform: rotate(-90deg); pointer-events: none; }
.breathe-ring circle { fill: none; stroke: color-mix(in srgb, var(--accent) 30%, transparent); stroke-width: 3; }
.breathe-ring .p { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.breathe-count { text-align: center; font-size: 14px; color: var(--ink-soft); margin-top: 18px; min-height: 22px; }
.breathe-phase-secs { font-size: 34px; font-family: var(--font-display); font-weight: 800; display: block; letter-spacing: -.03em; }

/* ============================================================
   Timer
   ============================================================ */
.timer-display { text-align: center; font-family: var(--font-display); font-size: 68px; font-weight: 800; letter-spacing: -.045em; padding: 10px 0 2px; font-variant-numeric: tabular-nums; }
.timer-phase { text-align: center; font-size: 13px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.timer-phase.rest { color: var(--warn); }
.timer-wrap { position: relative; display: grid; place-items: center; margin: 10px 0 4px; }
.timer-ring { transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-linecap: round; stroke-width: 9; }
.timer-ring .bg { stroke: var(--surface-2); }
.timer-ring .fg { stroke: var(--accent); transition: stroke-dashoffset 1s linear; }
.timer-ring.rest .fg { stroke: var(--warn); }
.timer-inner { position: absolute; inset: 0; display: grid; place-items: center; }

/* ============================================================
   Diario / estado de ánimo
   ============================================================ */
.mood-row { display: flex; gap: 8px; margin-bottom: 12px; }
.mood-row button {
  flex: 1; appearance: none; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--radius-xs); padding: 10px 2px 8px; cursor: pointer;
  font-size: 22px; line-height: 1; transition: all .2s var(--ease);
}
.mood-row button span { display: block; font-size: 9.5px; color: var(--ink-soft); margin-top: 5px; font-family: var(--font-body); }
.mood-row button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); transform: translateY(-2px); }
.journal-entry { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 10px; }
.journal-entry .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.journal-entry .date { font-size: 11.5px; color: var(--ink-soft); font-weight: 600; letter-spacing: .02em; }
.journal-entry .txt { font-size: 14.5px; white-space: pre-line; line-height: 1.6; margin: 0; color: var(--ink); }

/* ============================================================
   Tab bar
   ============================================================ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border-top: 1px solid var(--line);
  display: flex;
}
.tabbar button {
  flex: 1; appearance: none; background: none; border: none; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-soft); font: 600 10px var(--font-body); cursor: pointer; padding: 0 2px;
  transition: color .2s;
}
.tabbar button .ic { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .55; transition: all .22s var(--ease); }
.tabbar button.active { color: var(--accent); }
.tabbar button.active .ic { filter: none; opacity: 1; transform: translateY(-2px) scale(1.08); }
.tabbar button.active::before {
  content: ""; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 0 0 4px 4px;
  background: var(--accent); animation: pop .3s var(--ease);
}
.tabbar button span.lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 22px);
  transform: translateX(-50%) translateY(16px) scale(.95);
  background: var(--ink); color: var(--bg);
  padding: 11px 20px; border-radius: 999px; max-width: 86vw; text-align: center;
  font: 600 13.5px var(--font-body);
  opacity: 0; pointer-events: none; transition: all .28s var(--ease); z-index: 120;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

/* ============================================================
   Hoja modal (sheet)
   ============================================================ */
.sheet-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .3s var(--ease);
  backdrop-filter: blur(3px);
}
.sheet-back.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 201;
  background: var(--bg); border-radius: 26px 26px 0 0;
  max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 20px calc(28px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .36s var(--ease);
  box-shadow: var(--shadow-lg);
}
.sheet.show { transform: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 8px auto 14px; }
.sheet h2 { font-family: var(--font-display); font-size: 20px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.02em; }
.sheet .sub { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 18px; }
@media (min-width: 560px) {
  .sheet { max-width: 480px; left: 50%; transform: translateX(-50%) translateY(100%); border-radius: 26px 26px 0 0; }
  .sheet.show { transform: translateX(-50%); }
}

/* Filas de ajustes */
.set-list { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 16px; background: var(--surface); }
.set-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 15px;
  border-bottom: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left; font-family: var(--font-body); color: var(--ink); appearance: none;
}
.set-row:last-child { border-bottom: none; }
.set-row:active { background: var(--surface-2); }
.set-row .si { font-size: 17px; width: 24px; text-align: center; flex-shrink: 0; }
.set-row .st { flex: 1; min-width: 0; }
.set-row .st b { display: block; font-size: 14.5px; font-weight: 600; }
.set-row .st span { display: block; font-size: 12px; color: var(--ink-soft); }
.set-row .chev { color: var(--ink-soft); opacity: .5; flex-shrink: 0; }
.set-row.danger .st b { color: var(--bad); }

.switch { width: 46px; height: 27px; border-radius: 99px; background: var(--surface-2); position: relative; flex-shrink: 0; transition: background .25s var(--ease); border: 1px solid var(--line); }
.switch::after { content: ""; position: absolute; width: 21px; height: 21px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform .25s var(--ease); box-shadow: var(--shadow-sm); }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on::after { transform: translateX(19px); }

/* ============================================================
   Logros
   ============================================================ */
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ach {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 8px 12px; text-align: center; position: relative; overflow: hidden;
}
.ach .em { font-size: 26px; display: block; filter: grayscale(1); opacity: .3; transition: all .3s var(--ease); }
.ach .nm { font-size: 10.5px; font-weight: 700; margin-top: 7px; line-height: 1.3; color: var(--ink-soft); }
.ach.on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.ach.on .em { filter: none; opacity: 1; }
.ach.on .nm { color: var(--ink); }

.ach-pop {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%) scale(.8);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 26px; text-align: center; z-index: 300; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: all .4s var(--ease); max-width: 84vw;
}
.ach-pop.show { opacity: 1; transform: translateX(-50%) scale(1); }
.ach-pop .em { font-size: 46px; display: block; animation: pop .5s var(--ease); }
.ach-pop .t { font-family: var(--font-display); font-weight: 800; font-size: 16px; margin-top: 8px; }
.ach-pop .d { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }

/* ============================================================
   Onboarding
   ============================================================ */
.onb {
  position: fixed; inset: 0; z-index: 400; background: var(--bg);
  display: flex; flex-direction: column;
  padding: calc(24px + env(safe-area-inset-top)) 26px calc(24px + env(safe-area-inset-bottom));
  animation: fade .4s var(--ease);
}
.onb-body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.onb-hero {
  width: 76px; height: 76px; border-radius: 24px; margin-bottom: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 34px; color: #fff;
  box-shadow: 0 16px 40px color-mix(in srgb, var(--accent) 38%, transparent);
  animation: pop .5s var(--ease);
}
.onb h2 { font-family: var(--font-display); font-size: 29px; font-weight: 800; letter-spacing: -.035em; margin: 0 0 12px; line-height: 1.15; }
.onb p { font-size: 15.5px; color: var(--ink-soft); margin: 0 0 22px; line-height: 1.6; }
.onb .feat { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 16px; }
.onb .feat .e { font-size: 20px; flex-shrink: 0; width: 26px; }
.onb .feat b { display: block; font-size: 14.5px; font-weight: 700; }
.onb .feat span { font-size: 13px; color: var(--ink-soft); }
.onb-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.onb-dots i { width: 7px; height: 7px; border-radius: 99px; background: var(--line); transition: all .3s var(--ease); }
.onb-dots i.on { background: var(--accent); width: 20px; }
.onb-skip { position: absolute; top: calc(20px + env(safe-area-inset-top)); right: 22px; appearance: none; background: none; border: none; color: var(--ink-soft); font: 600 13.5px var(--font-body); cursor: pointer; }

/* ============================================================
   Banner instalar / licencia
   ============================================================ */
.banner {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: var(--radius-sm); padding: 13px 14px;
  animation: rise .4s var(--ease) both;
}
.banner .e { font-size: 22px; flex-shrink: 0; }
.banner .t { flex: 1; min-width: 0; }
.banner .t b { display: block; font-size: 13.5px; font-weight: 700; }
.banner .t span { display: block; font-size: 12px; color: var(--ink-soft); line-height: 1.4; }
.banner .x { appearance: none; background: none; border: none; color: var(--ink-soft); cursor: pointer; font-size: 15px; padding: 4px; opacity: .5; }
.banner button.go { appearance: none; border: none; background: var(--accent); color: #fff; border-radius: 999px; padding: 8px 14px; font: 700 12.5px var(--font-body); cursor: pointer; flex-shrink: 0; }
.banner.warn { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

/* Pantalla de bloqueo por licencia */
.lock {
  position: fixed; inset: 0; z-index: 500; background: var(--bg);
  display: flex; flex-direction: column; justify-content: center;
  padding: 30px 26px calc(30px + env(safe-area-inset-bottom)); text-align: center;
  animation: fade .35s var(--ease);
}
.lock .em { font-size: 46px; margin-bottom: 14px; }
.lock h2 { font-family: var(--font-display); font-size: 24px; font-weight: 800; margin: 0 0 10px; letter-spacing: -.03em; }
.lock p { font-size: 14.5px; color: var(--ink-soft); margin: 0 0 22px; line-height: 1.6; }
.lock input { text-align: center; font-family: var(--font-display); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.lock .lock-foot { font-size: 12px; color: var(--ink-soft); margin-top: 18px; }
.lock a { color: var(--accent); }

.demo-tag {
  display: inline-block; background: var(--warn); color: #fff;
  font: 800 9.5px var(--font-body); letter-spacing: .12em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 5px; vertical-align: middle; margin-left: 6px;
}
.locked-card { position: relative; overflow: hidden; }
.locked-card > * { filter: blur(3.5px); opacity: .5; pointer-events: none; user-select: none; }
.locked-card::after {
  content: "🔒 Disponible en la versión completa";
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font: 700 12.5px var(--font-body); color: var(--ink); padding: 0 16px;
}

/* ============================================================
   Utilidades
   ============================================================ */
.center { text-align: center; }
.mt0 { margin-top: 0 } .mt8 { margin-top: 8px } .mt16 { margin-top: 16px } .mt24 { margin-top: 24px }
.muted { color: var(--ink-soft); }
.fs12 { font-size: 12px } .fs13 { font-size: 13px }
.divider { height: 1px; background: var(--line); margin: 20px 0; border: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.card.tappable:focus-visible, .check-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

@media (min-width: 560px) {
  body { max-width: 480px; margin: 0 auto; box-shadow: 0 0 60px rgba(0,0,0,.14); min-height: 100dvh; }
  .tabbar { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .app-header { max-width: 480px; }
}
