/* Pulso 2 · «Cuaderno de días»
   Mismo HTML y mismas clases que v0.5. Base original + capa de rediseño al final. */

/* ---------- Tokens · «Cuaderno de días» ---------- */
:root {
  --bg: #F3F0E8;          /* papel */
  --surface: #FFFFFF;     /* solo lo que pide acción */
  --paper: #EAE6DC;       /* informativo / hecho */
  --ink: #1A1915;
  --muted: #5E5A50;
  --line: #D6D1C3;
  --accent: #3A34D2;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7E5FA;
  --accent-strong: #3A34D2;

  --ok: #1F9D68;
  --partial: #E2AA27;
  --miss: #D24D4A;
  --off: #E4E0D5;
  --none: #ECE8DF;
  --dot: #B3AC9B;
  --cell-ink: #1A1915;
  --partial-ink: #1A1915;
  --ok-ink: #157A50;
  --late: #B3302D;
  --soon: #8A6100;

  --shadow: 0 1px 2px rgba(40,30,10,.06), 0 4px 14px rgba(40,30,10,.05);
  --font-d: 'Schibsted Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-b: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;

  --r-s: 12px;
  --r-m: 22px;
  --tabbar-h: 62px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1F1E1B;
    --paper: #1A1917;
    --ink: #F0EDE4;
    --muted: #A8A396;
    --line: #36352F;
    --accent: #ABA8FF;
    --accent-ink: #15133A;
    --accent-soft: #27254A;
    --accent-strong: #BDBAFF;
    --ok: #1E8A5A;
    --partial: #E2AA27;
    --miss: #C4443F;
    --off: #2D2C28;
    --none: #1C1B19;
    --dot: #5A5850;
    --cell-ink: #FFFFFF;
    --partial-ink: #1A1915;
    --ok-ink: #5FD19E;
    --late: #F08480;
    --soon: #E9B946;
    --shadow: none;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.5 var(--font-b);
  min-height: 100dvh;
}
body.app { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); }

a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

h1, h2, h3 { font-family: var(--font-d); line-height: 1.1; margin: 0; }

.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 max(18px, env(safe-area-inset-left)) 0 max(18px, env(safe-area-inset-right));
}

/* ---------- Barra superior ---------- */
.topbar {
  max-width: 46rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  font: 800 1.15rem/1 var(--font-d); letter-spacing: -0.01em;
}
.brand.big { font-size: 1.6rem; margin-bottom: 28px; }
.mark { width: 26px; height: 26px; }
.brand.big .mark { width: 34px; height: 34px; }
.m-ok { fill: var(--ok); } .m-partial { fill: var(--partial); }
.m-miss { fill: var(--miss); } .m-off { fill: var(--off); }

.link-btn {
  background: none; border: 0; padding: 8px 4px; cursor: pointer;
  color: var(--muted); font: inherit; font-size: .95rem;
}
.link-btn:hover { color: var(--ink); }

/* ---------- Cabeceras de página ---------- */
.page-head { padding: 18px 0 22px; }
.page-head h1 {
  font-size: clamp(2.1rem, 8vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}
.lede { margin: 8px 0 0; color: var(--muted); max-width: 38em; }
.lede [data-summary] { color: var(--ink); font-weight: 700; }

.flash {
  margin: 8px 0 0; padding: 10px 14px;
  background: color-mix(in srgb, var(--ok) 14%, var(--surface));
  border-left: 4px solid var(--ok);
  border-radius: var(--r-s);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 20px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: 700 1rem/1 var(--font-b); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--miss); }
.btn.danger:hover { border-color: var(--miss); }

/* ---------- Hoy ---------- */
.tasks { display: grid; gap: 12px; }

.task {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 16px 16px 20px;
  background: var(--surface);
  border-radius: var(--r-m);
  box-shadow: inset 5px 0 0 var(--st, var(--off));
}
.task[data-status="ok"] { --st: var(--ok); }
.task[data-status="partial"] { --st: var(--partial); }
.task[data-status="pending"] { --st: var(--line); }

.task-info { flex: 1; min-width: 0; }
.task h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.task h2 a { color: inherit; text-decoration: none; }
.task h2 a:hover { text-decoration: underline; }
.meta { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }

.check {
  flex: none; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 2px solid var(--line); color: var(--line);
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
.check svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.check:hover { border-color: var(--ok); color: var(--ok); }
.check:active { transform: scale(.94); }
.check[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.check:disabled { opacity: .6; }

.amount {
  flex: none; display: grid;
  grid-template-columns: 40px 64px 40px; grid-template-rows: auto auto;
  gap: 6px; align-items: center; justify-items: center;
}
.amount input {
  width: 64px; height: 44px; text-align: center;
  font: 700 1.2rem/1 var(--font-d);
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--bg); color: var(--ink);
  -moz-appearance: textfield; appearance: textfield;
}
.amount input::-webkit-outer-spin-button,
.amount input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 700 1.25rem/1 var(--font-b); cursor: pointer;
}
.fill {
  grid-column: 1 / -1; background: none; border: 0; cursor: pointer;
  color: var(--accent); font: 700 .85rem/1 var(--font-b); padding: 4px;
}

/* Tira de días */
.strip { display: flex; gap: 4px; margin-top: 10px; }
.strip .d { width: 14px; height: 14px; border-radius: 3px; }

/* ---------- Estados (comunes a tiras, calendario y leyenda) ---------- */
.d { display: block; background: var(--none); }
.st-ok { background: var(--ok); }
.st-partial { background: var(--partial); }
.st-miss { background: var(--miss); }
.st-off { background: var(--off); }
.st-pending { background: var(--off); box-shadow: inset 0 0 0 2px var(--accent); }
.st-none { background: var(--none); }
.d.today { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.d.st-pending.today { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }

/* ---------- Estadísticas ---------- */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--line); border-radius: var(--r-m); overflow: hidden;
  margin-bottom: 28px;
}
.stat { background: var(--surface); padding: 14px 16px; }
.stat strong { display: block; font: 800 1.6rem/1 var(--font-d); letter-spacing: -0.02em; }
.stat > span { display: block; margin-top: 4px; color: var(--muted); font-size: .85rem; line-height: 1.25; }
.stat.main { grid-column: 1 / -1; padding: 20px 18px; }
.stat.main strong { font-size: clamp(3.2rem, 14vw, 4.6rem); color: var(--ok); }
.stat.main > span { font-size: 1rem; }

/* ---------- Calendario anual ---------- */
.year-nav { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.year-nav h2 { font-size: 1.6rem; font-weight: 800; }
.year-nav a, .year-nav .disabled {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 1.4rem; line-height: 1;
}
.year-nav .disabled { opacity: .3; }

.months {
  display: grid; gap: 22px 18px;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
}
.month h3 {
  font: 600 .95rem/1 var(--font-d); color: var(--muted);
  margin-bottom: 8px; text-transform: capitalize;
}
.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.mgrid .wd { font-size: .62rem; color: var(--muted); text-align: center; opacity: .7; }
.mgrid .d, .mgrid .pad { aspect-ratio: 1; width: 100%; }
.mgrid .pad { visibility: hidden; }
.mgrid .d { border-radius: 3px; border: 0; padding: 0; }
.mgrid button.d { cursor: pointer; }
.mgrid button.d:hover { filter: brightness(.9); }
.mgrid button.d:disabled { opacity: .5; }
.months.dots .mgrid .d { border-radius: 50%; }
.months.dots .mgrid .st-off,
.months.dots .mgrid .st-none { transform: scale(.55); }

.legend {
  list-style: none; margin: 20px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .9rem; color: var(--muted);
}
.legend li { display: flex; align-items: center; gap: 7px; }
.legend .d { width: 12px; height: 12px; border-radius: 3px; }
.hint { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }

/* ---------- Lista de seguimientos ---------- */
.list { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 10px; }
.list a {
  display: block; padding: 14px 16px; border-radius: var(--r-m);
  background: var(--surface); color: var(--ink); text-decoration: none;
}
.list a:hover { box-shadow: inset 0 0 0 1px var(--line); }
.list-name { display: block; font: 600 1.15rem/1.2 var(--font-d); }
.list.compact a { padding: 10px 14px; }

/* ---------- Paneles y formularios ---------- */
.panel {
  background: var(--surface); border-radius: var(--r-m);
  margin: 0 0 16px; padding: 0 18px;
}
.panel > summary {
  cursor: pointer; padding: 16px 0; list-style: none;
  font: 600 1.1rem/1.2 var(--font-d);
  display: flex; justify-content: space-between; align-items: center;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: '+'; font-size: 1.4rem; color: var(--muted); }
.panel[open] > summary::after { content: '−'; }
.panel[open] { padding-bottom: 18px; }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 700; font-size: .95rem; padding: 0; margin-bottom: 6px; }
fieldset.field > legend { margin-bottom: 8px; }
.field input:not([type=radio]):not([type=checkbox]), .field select {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--bg); color: var(--ink); font: inherit;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row > * { min-width: 0; }
.row.end { display: flex; gap: 10px; justify-content: flex-end; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.chip:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip input { accent-color: var(--accent); margin: 0; }

.days { display: flex; gap: 6px; }
.day-chip { position: relative; flex: 1; max-width: 48px; }
.day-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.day-chip span {
  display: grid; place-items: center; aspect-ratio: 1;
  border: 1px solid var(--line); border-radius: 50%; font-weight: 700;
}
.day-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.day-chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Mostrar solo lo que aplica, sin JavaScript */
.tracker-form:has(input[name=kind][value=check]:checked) .qty { display: none; }
.tracker-form:has(.days input:checked) .weekly { display: none; }
.tracker-form .sched-cada, .tracker-form .sched-mes { display: none; }
.tracker-form:has(input[name=sched_type][value=cada]:checked) .sched-cada,
.tracker-form:has(input[name=sched_type][value=mes]:checked) .sched-mes { display: grid; }
.tracker-form:has(input[name=sched_type][value=cada]:checked) .sched-dias,
.tracker-form:has(input[name=sched_type][value=mes]:checked) .sched-dias { display: none; }
.sched-dias { display: grid; gap: 10px; }
.field > .hint { font-weight: 400; margin: 0; }

.errors {
  margin: 0; padding: 10px 14px 10px 32px;
  background: color-mix(in srgb, var(--miss) 12%, var(--surface));
  border-left: 4px solid var(--miss); border-radius: var(--r-s);
}
p.errors { padding-left: 14px; }

.danger-zone { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 24px; }

.empty {
  padding: 28px 20px; text-align: center;
  background: var(--surface); border-radius: var(--r-m);
}
.empty p { margin: 0 0 16px; color: var(--muted); }

/* ---------- Acceso ---------- */
body.bare { display: grid; place-items: center; padding: 24px 0; }
.auth { width: min(100%, 26rem); padding: 0 18px; }
.auth h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 20px; }
.auth .btn.primary { width: 100%; }
.alt { color: var(--muted); margin-top: 20px; }

/* ---------- Diálogo ---------- */
dialog {
  border: 0; border-radius: var(--r-m); padding: 22px;
  width: min(92vw, 24rem); background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgb(10 14 22 / .45); }
dialog h2 { font-size: 1.4rem; font-weight: 800; }

/* ---------- Navegación inferior ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; gap: 4px; padding: 6px;
  background: var(--surface); border-radius: 999px;
  box-shadow: 0 6px 24px rgb(15 22 35 / .16), 0 0 0 1px var(--line);
  z-index: 10;
}
.tabbar a {
  display: flex; align-items: center; gap: 8px;
  height: calc(var(--tabbar-h) - 14px); padding: 0 16px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 700; font-size: .92rem;
}
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { background: var(--ink); color: var(--bg); }
@media (max-width: 560px) {
  .tabbar { gap: 2px; }
  .tabbar a { padding: 0 13px; }
  .tabbar a span { display: none; }  /* 6 secciones: en el móvil solo iconos */
}

/* ---------- Aviso flotante ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 30px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px;
  max-width: 90vw; transition: opacity .2s, transform .2s; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .task { padding: 14px 14px 14px 18px; }
  .amount { grid-template-columns: 36px 56px 36px; }
  .amount input { width: 56px; }
  .step { width: 36px; height: 36px; }
  .months { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* =========================================================
   Lectura
   ========================================================= */
.section { margin: 0 0 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2, .section-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.section-title { margin-bottom: 14px; }
.btn.small { min-height: 40px; padding: 0 16px; font-size: .92rem; }

/* Portadas */
.cover { display: block; flex: none; object-fit: cover; background: var(--off); border-radius: 4px 7px 7px 4px; box-shadow: inset 3px 0 0 rgb(0 0 0 / .12), 0 1px 3px rgb(0 0 0 / .18); }
.cover-s { width: 56px; height: 84px; }
.cover-m { width: 100%; aspect-ratio: 2 / 3; height: auto; }
.cover-l { width: 120px; height: 180px; }
.cover-ph {
  display: grid; place-items: center; color: var(--muted);
  font: 800 1.1rem/1 var(--font-d); letter-spacing: .02em;
  background: linear-gradient(160deg, var(--off), var(--none));
}
.cover-l.cover-ph { font-size: 2rem; }

/* Fila de libro en curso */
.books { display: grid; gap: 10px; }
.book-row {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px; background: var(--surface); border-radius: var(--r-m);
}
.task-reading .books { margin-top: 14px; }
.task-reading .book-row { padding: 12px 0 0; border-top: 1px solid var(--line); border-radius: 0; background: none; }
.book-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.book-title { font: 600 1.15rem/1.2 var(--font-d); color: var(--ink); text-decoration: none; }
.book-title:hover { text-decoration: underline; }
.book-author { color: var(--muted); font-size: .92rem; }
.book-meta { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.35; }
.book-plan { margin: 2px 0 0; font-size: .98rem; }
.book-plan.done { color: var(--ok); font-weight: 700; }
.book-plan.late strong { color: var(--miss); }

progress {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; margin: 6px 0 2px; border: 0; border-radius: 99px;
  background: var(--off); color: var(--ok); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--off); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--ok); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--ok); border-radius: 99px; }
progress.wide { height: 10px; margin: 0 0 6px; }

.book-log { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 8px; }
.book-log label { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); font-weight: 700; }
.book-log input {
  width: 96px; height: 40px; padding: 0 10px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--bg); color: var(--ink); font: 700 1.05rem/1 var(--font-d);
}

/* Ficha */
.book-hero { display: flex; gap: 20px; align-items: flex-end; padding: 18px 0 22px; }
.book-hero h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; }
.book-hero .lede { margin-top: 4px; }
.book-hero .book-meta { margin-top: 8px; }
.book-status { margin: 0 0 6px; font-weight: 700; font-size: .9rem; color: var(--muted); }
.book-status.status-leyendo { color: var(--accent); }
.book-status.status-terminado { color: var(--ok); }
.books.single { margin-bottom: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 20px; }
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.log li span { color: var(--muted); }

/* Estantería de leídos */
.shelf-year { font: 700 1rem/1 var(--font-d); color: var(--muted); margin: 18px 0 10px; }
.shelf-year span { font-weight: 400; }
.shelf {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 16px 12px;
}
.shelf a { display: grid; gap: 6px; color: var(--ink); text-decoration: none; }
.shelf-title { font-size: .8rem; line-height: 1.25; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shelf .cover-ph { font-size: 1.4rem; }

/* Pendientes */
.pending { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pending li { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; background: var(--surface); border-radius: var(--r-m); }
.pending .cover-s { width: 40px; height: 60px; }
.pending a { flex: 1; min-width: 0; display: grid; color: var(--ink); text-decoration: none; }
.pending a span { color: var(--muted); font-size: .88rem; }

/* Búsqueda */
.book-search { display: flex; gap: 8px; margin-bottom: 16px; }
.book-search input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit;
}
.results { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.results a { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--surface); border-radius: var(--r-m); color: var(--ink); text-decoration: none; }
.results a:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.results .cover-s { width: 44px; height: 66px; }
.r-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.r-body span { color: var(--muted); font-size: .88rem; }
.r-pick { color: var(--accent); font-weight: 700; font-size: .9rem; }
.empty-inline { color: var(--muted); margin: 0 0 20px; }

.panel-static { padding: 4px 18px 18px; }
.panel-title { font: 600 1.1rem/1.2 var(--font-d); padding: 14px 0; }
.book-form-head { display: flex; gap: 16px; align-items: flex-start; }
.book-form-head .cover-m { width: 84px; flex: none; }
.book-form-head .form { flex: 1; min-width: 0; }
.book-form:has(input[name=plan][value=fecha]:checked) .plan-ritmo,
.book-form:has(input[name=plan][value=ritmo]:checked) .plan-fecha { display: none; }
.more > summary { cursor: pointer; color: var(--accent); font-weight: 700; padding: 4px 0; }
.more[open] > summary { margin-bottom: 10px; }

@media (max-width: 520px) {
  .book-hero { gap: 14px; }
  .cover-l { width: 96px; height: 144px; }
  .book-row { gap: 12px; }
  .cover-s { width: 48px; height: 72px; }
}

/* Ajustes */
.task.task-reading { display: block; }
.books.single .book-cover-link,
.books.single .book-title,
.books.single .book-author { display: none; }
.book-log input { -moz-appearance: textfield; appearance: textfield; }
.book-log input::-webkit-outer-spin-button,
.book-log input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* =========================================================
   Ajustes y avisos
   ========================================================= */
[hidden] { display: none !important; }
a.link-btn { text-decoration: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 8px; }
.push-state { margin: 0; }
.sub-title { font: 600 1rem/1.2 var(--font-d); margin: 22px 0 8px; }
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.devices small { display: block; color: var(--muted); }
.panel-static + .panel-static, .panel-static + .panel, .panel + .panel-static { margin-top: 16px; }

/* =========================================================
   Finanzas
   ========================================================= */
:root {
  --c0: #2F6FDB; --c1: #E07B39; --c2: #2BA59A; --c3: #9B59D0;
  --c4: #D6456B; --c5: #C29A1F; --c6: #5B8C3A; --c7: #6B7A90;
}
@media (prefers-color-scheme: dark) {
  :root {
    --c0: #6C9BF0; --c1: #F0995E; --c2: #4CC4B8; --c3: #B889E6;
    --c4: #EC6E8F; --c5: #E2BE4A; --c6: #82B45F; --c7: #97A5B8;
  }
}
.cat-0 { background: var(--c0); } .cat-1 { background: var(--c1); }
.cat-2 { background: var(--c2); } .cat-3 { background: var(--c3); }
.cat-4 { background: var(--c4); } .cat-5 { background: var(--c5); }
.cat-6 { background: var(--c6); } .cat-7 { background: var(--c7); }
.cat-none { background: var(--off); }
.cat-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: 1px; flex: none; }

.neg { color: var(--miss); }
.pos { color: var(--ok); }
.muted { color: var(--muted); }

/* Subnavegación */
.subnav {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: -8px -18px 22px; padding: 2px 18px 4px;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  flex: none; padding: 9px 15px; border-radius: 999px;
  background: var(--surface); color: var(--muted); text-decoration: none; font-weight: 700; font-size: .95rem;
}
.subnav a.on { background: var(--ink); color: var(--bg); }
.month-nav { margin: 0 0 12px; }
.month-nav h2 { font-size: 1.35rem; }
.crumb { margin: 0 0 6px; font-weight: 700; }
.crumb a { text-decoration: none; }
.crumb a::before { content: '‹ '; }

.status-line { margin: 0 0 16px; color: var(--muted); }
.status-line.ok { color: var(--ok); font-weight: 700; }

/* Filas genéricas: nombre a la izquierda, importe a la derecha */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.rows > li:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row-main strong { font-weight: 700; overflow-wrap: anywhere; }
.row-main .meta { margin: 0; }
.amount-cell { font: 700 1.05rem/1.2 var(--font-d); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.amount-cell small { display: block; font: 400 .8rem/1.2 var(--font-b); color: var(--muted); }
.row-edit { flex-basis: 100%; }
.row-edit > summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: .9rem; width: max-content; }
.row-edit[open] > summary { margin-bottom: 10px; }
.row-edit form + form { margin-top: 10px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 1.3rem; line-height: 1;
}
.icon-btn:hover { background: var(--bg); color: var(--miss); }
.compact-rows > li { padding: 8px 0; }

.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-total { font: 700 1.05rem/1 var(--font-d); color: var(--muted); font-variant-numeric: tabular-nums; }
.panel .more, .panel-static .more { margin-top: 10px; }
.panel-static > .more > summary { padding: 6px 0; }

/* Campo de dinero con € */
.money { position: relative; display: block; }
.money input { padding-right: 34px !important; font-variant-numeric: tabular-nums; }
.money > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money.small { width: 120px; flex: none; }
.money.small input {
  width: 100%; min-height: 42px; padding: 8px 30px 8px 10px; text-align: right;
  border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); color: var(--ink);
  font: 700 1rem/1 var(--font-d);
}
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.inline-form .field { flex: 1; min-width: 180px; }

/* Presupuesto del día a día */
.budget-card { background: var(--surface); border-radius: var(--r-m); padding: 18px; margin-bottom: 26px; }
.card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.budget-left { margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.budget-left strong { font: 800 clamp(2.2rem, 10vw, 3rem)/1 var(--font-d); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.budget-left span { color: var(--muted); }
.budget-left.neg strong { color: var(--miss); }
.bar { height: 10px; border-radius: 99px; background: var(--off); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--ok); }
.bar.near > span { background: var(--partial); }
.bar.over > span { background: var(--miss); }
.budget-card .meta { margin-top: 10px; }
.quick-expense { margin: 14px 0 4px; }
.quick-expense > summary {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink); list-style: none;
}
.quick-expense > summary::-webkit-details-marker { display: none; }
.quick-expense[open] > summary { background: var(--bg); color: var(--ink); }
.see-all { display: inline-block; margin-top: 8px; font-weight: 700; text-decoration: none; }
.section-total { font: 700 1.1rem/1 var(--font-d); color: var(--muted); }

/* Por categoría */
.cat-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cat-bars li { display: grid; grid-template-columns: minmax(0, 9rem) 1fr auto; align-items: center; gap: 10px; }
.cat-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-track { height: 12px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.cat-fill { display: block; height: 100%; border-radius: 99px; }
.cat-amount { font: 700 .98rem/1.1 var(--font-d); text-align: right; font-variant-numeric: tabular-nums; min-width: 5.5rem; }
.cat-amount small { display: block; font: 400 .78rem/1.2 var(--font-b); color: var(--muted); }

.day-title { font: 600 .95rem/1.2 var(--font-d); color: var(--muted); margin: 18px 0 2px; display: flex; justify-content: space-between; }
.day-title span { font-variant-numeric: tabular-nums; }
.expenses { background: var(--surface); border-radius: var(--r-m); padding: 0 14px; }

/* Últimos meses */
.month-bars { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.month-bars a { display: grid; gap: 4px; justify-items: center; text-decoration: none; color: var(--muted); }
.mb-track { height: 90px; width: 100%; max-width: 44px; display: flex; align-items: flex-end; background: var(--surface); border-radius: 8px; overflow: hidden; }
.mb-fill { display: block; width: 100%; background: var(--c7); border-radius: 8px 8px 0 0; }
.mb-fill.on { background: var(--accent); }
.mb-label { font-weight: 700; font-size: .85rem; text-transform: capitalize; }
.mb-value { font-size: .75rem; font-variant-numeric: tabular-nums; min-height: 1em; }

/* Huchas */
.goals { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px; }
.goals a { display: grid; gap: 6px; padding: 14px 16px; background: var(--surface); border-radius: var(--r-m); color: var(--ink); text-decoration: none; }
.goals a:hover { box-shadow: inset 0 0 0 1px var(--line); }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.goal-head strong { font: 600 1.12rem/1.2 var(--font-d); }
.goal-balance { font: 800 1.15rem/1 var(--font-d); font-variant-numeric: tabular-nums; white-space: nowrap; }
.goals .meta { margin: 0; }
.goals progress { margin: 0; }
.stat.main progress { margin-top: 12px; }
.stat strong { font-variant-numeric: tabular-nums; }

.moves { list-style: none; margin: 0; padding: 0; }
.moves li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.moves li > span { flex: 1; min-width: 0; display: grid; }
.moves strong { font-variant-numeric: tabular-nums; white-space: nowrap; }

.goal-form .alloc-fijo, .goal-form .alloc-porcentaje, .goal-form .alloc-meta, .goal-form .alloc-resto { display: none; }
.goal-form:has(input[name=alloc_type][value=fijo]:checked) .alloc-fijo,
.goal-form:has(input[name=alloc_type][value=porcentaje]:checked) .alloc-porcentaje,
.goal-form:has(input[name=alloc_type][value=meta]:checked) .alloc-meta,
.goal-form:has(input[name=alloc_type][value=resto]:checked) .alloc-resto { display: grid; }
.fixed-form:has(select[name=months] option[value="1"]:checked) .when-other { display: none; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span:not(.sr) { display: block; width: 32px; height: 32px; border-radius: 50%; }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.swatch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 4px; }

/* Mes y reparto */
.sum { margin: 0 0 14px; }
.sum > div { display: flex; justify-content: space-between; padding: 6px 0; }
.sum dt { color: var(--muted); }
.sum dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; }
.sum .total { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 10px; }
.sum .total dt { color: var(--ink); font-weight: 700; }
.sum .total dd { font: 800 1.3rem/1 var(--font-d); }
.alloc-rows { margin-bottom: 12px; }
.alloc-rows .unassigned .row-main strong { color: var(--muted); }
.note {
  margin: 10px 0 0; padding: 10px 14px; border-radius: var(--r-s);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.note.warn { background: color-mix(in srgb, var(--partial) 18%, var(--surface)); }
.income-form .chips { margin-bottom: 2px; }

.callout {
  display: grid; gap: 2px; margin: 0 0 18px; padding: 14px 16px;
  border-radius: var(--r-m); text-decoration: none; color: var(--ink);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  box-shadow: inset 4px 0 0 var(--accent);
}
.callout span { color: var(--muted); }
.setup-steps { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.setup-steps a { font-weight: 700; }

/* Pagos */
.payments { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px; }
.payment { padding: 14px 16px; background: var(--surface); border-radius: var(--r-m); box-shadow: inset 5px 0 0 var(--line); }
.payment.soon { box-shadow: inset 5px 0 0 var(--partial); }
.payment.late { box-shadow: inset 5px 0 0 var(--miss); }
.pay-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pay-head strong { font: 600 1.1rem/1.2 var(--font-d); }
.pay-due { margin: 4px 0 0; font-weight: 700; color: var(--muted); font-size: .95rem; }
.payment.soon .pay-due { color: color-mix(in srgb, var(--partial) 70%, var(--ink)); }
.payment.late .pay-due { color: var(--miss); }
.pay-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.pay-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pay-form select {
  min-height: 40px; max-width: 13rem; padding: 0 10px; border: 1px solid var(--line);
  border-radius: var(--r-s); background: var(--bg); color: var(--ink); font: inherit; font-size: .92rem;
}
.payments.compact .payment { padding: 12px 14px; }

@media (max-width: 520px) {
  .money.small { width: 108px; }
}

.pay-callout { margin-bottom: 14px; }
.pay-callout .late { color: var(--miss); font-weight: 700; }
.row-main { line-height: 1.3; gap: 2px; }
.rows > li { padding: 10px 0; }
.month-nav h2 { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.25rem; }

.stat.main.neutral strong { color: var(--ink); }
.cat-bars li { grid-template-columns: 1fr auto; grid-template-areas: "name amount" "track track"; gap: 4px 10px; }
.cat-name { grid-area: name; }
.cat-amount { grid-area: amount; display: flex; gap: 8px; align-items: baseline; justify-content: flex-end; }
.cat-amount small { display: inline; }
.cat-track { grid-area: track; height: 10px; }
.pay-form label { flex: 1; min-width: 11rem; }
.pay-form select { width: 100%; max-width: none; }

/* =========================================================
   Agenda
   ========================================================= */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 8px; }
.cal-wd { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1 / 1.05; display: grid; grid-template-rows: 1fr auto; justify-items: center; align-items: center;
  padding: 4px 0 6px; border-radius: 10px; background: var(--surface); color: var(--ink); text-decoration: none;
}
.cal-day.past { color: var(--muted); background: transparent; }
.cal-day:hover { box-shadow: inset 0 0 0 1px var(--line); }
.cal-n { font: 700 1rem/1 var(--font-d); font-variant-numeric: tabular-nums; }
.cal-day.today .cal-n { background: var(--accent); color: var(--accent-ink); width: 1.9em; height: 1.9em; border-radius: 50%; display: grid; place-items: center; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-dots { display: flex; gap: 3px; height: 6px; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; }
.cal-today { margin: 4px 0 18px; font-weight: 700; }
.cal-today a { text-decoration: none; }

.events { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.event-row {
  display: grid; grid-template-columns: 4px 5.6rem 1fr; gap: 12px; align-items: center;
  padding: 12px 14px 12px 12px; background: var(--surface); border-radius: var(--r-m); color: var(--ink); text-decoration: none;
}
.event-row:hover { box-shadow: inset 0 0 0 1px var(--line); }
.ev-bar { align-self: stretch; border-radius: 4px; }
.ev-time { font: 700 .92rem/1.2 var(--font-d); font-variant-numeric: tabular-nums; color: var(--muted); }
.ev-body { display: grid; gap: 2px; min-width: 0; }
.ev-body strong { font-weight: 700; overflow-wrap: anywhere; }
.ev-body .meta { margin: 0; }
.ev-title { display: flex; align-items: center; gap: 12px; }
.ev-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.ev-note { margin: 12px 0 0; white-space: normal; }
.ev-detail .sum > div { gap: 16px; }
.ev-detail .sum dd { text-align: right; }
.today-events { margin-bottom: 18px; }
.today-events .card-title a { color: inherit; text-decoration: none; }
.event-form:has(input[name=all_day]:checked) .times { display: none; }
.event-form:has(select[name=repeat_every] option[value=no]:checked) .repeat-until { display: none; }
.check-line { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check-line input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); color: var(--ink); font: inherit; resize: vertical; }
@media (max-width: 400px) {
  .event-row { grid-template-columns: 4px 4.6rem 1fr; gap: 10px; }
  .cal { gap: 3px; }
}
.row { align-items: end; }


/* =====================================================================
   CAPA DE REDISEÑO (Pulso 2). Solo cambia el aspecto; no toca clases
   ni atributos que usa app.js.
   ===================================================================== */
body { font-family: var(--font-b); }
h1, h2, h3, .brand { font-family: var(--font-d); }
.page-head h1 { font-weight: 800; letter-spacing: -0.025em; }
.page-head h1.date { font-size: clamp(2.25rem, 10vw, 3.25rem); }
.meta, .lede, .hint { color: var(--muted); }
.stat strong, .budget-left strong, .amount-cell, .money input, .sum dd, .ev-time,
.cat-amount, .goal-balance, .mb-value, .panel-total, .section-total { font-family: var(--font-d); font-variant-numeric: tabular-nums; }
.neg { color: var(--late); }

/* Botones */
.btn { min-height: 48px; border: 1.5px solid var(--line); background: transparent; }
.btn.primary { border-color: transparent; }
.btn.danger { color: var(--late); }
.btn.small { min-height: 44px; }
.link-btn { min-height: 44px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Superficies: blanco = acción, papel = información */
.task, .panel, .budget-card, .book-hero + .books, .quick-expense { background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow); border: 0; }
.panel-static, .callout, .today-events .event-row, .note { background: var(--paper); box-shadow: none; border: 0; border-radius: 16px; }
.callout, .flash, .note, .note.warn { border-left: 0; }
.flash { background: var(--paper); color: var(--ok-ink); font-weight: 700; border-radius: 14px; }
.callout .late, .pay-callout .late { color: var(--late); }

/* Tarjeta de hábito: sin borde lateral; al hacerse baja al papel */
.task { border-left: 0 !important; padding: 18px; transition: background .3s, box-shadow .3s; }
.task[data-status="ok"] { background: var(--paper); box-shadow: none; }
.task h2 { font-size: 1.25rem; font-weight: 800; }

/* Botón de check */
.check { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--line); background: transparent; color: var(--muted); transition: background .25s, border-color .25s, color .25s; }
.check svg { stroke-width: 2.6; }
.check[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: var(--cell-ink); animation: pulso-pop .45s cubic-bezier(.3,1.6,.5,1); }

/* Cantidad */
.step { width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; color: var(--ink); }
.amount input { height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); font: 800 1.25rem var(--font-d); }
.fill { min-height: 48px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }

/* Celdas de día (tira, año, calendario). Colores completos. */
.d { border-radius: 6px; }
.st-ok { background: var(--ok); }
.st-partial { background: var(--partial); }
.st-miss { background: var(--miss); }
.st-off, .st-none { background: var(--off); }
.st-pending { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); }
.d.today { outline: 2px solid var(--ink); outline-offset: 2px; }
.mgrid .d { border-radius: 4px; }
.mgrid button.d[aria-pressed="true"], .mgrid button.d.st-ok { color: var(--cell-ink); }
/* Gym: cuadros en lugar de puntos, igual que el resto */
.months.dots .mgrid .d { width: auto; height: auto; aspect-ratio: 1; border-radius: 4px; transform: none; }
.months.dots .mgrid .st-off, .months.dots .mgrid .st-none { background: var(--off); }

/* Estadísticas en banda */
.stats { background: none; box-shadow: none; border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--line); border-radius: 0; }
.stat { border: 0 !important; background: none; }
.stat.main strong { font-weight: 900; letter-spacing: -0.03em; color: var(--ink); }

/* Barras y progreso */
progress { accent-color: var(--ok); }
progress::-webkit-progress-bar { background: var(--off); }
progress::-webkit-progress-value { background: var(--ok); }
progress::-moz-progress-bar { background: var(--ok); }
.bar { background: var(--off); }
.bar > span { background: var(--ok); }
.bar.near > span { background: var(--partial); }
.bar.over > span { background: var(--miss); }

/* Libro */
.book-plan { background: var(--accent-soft); padding: 10px 12px; border-radius: 12px; }
.book-log input { height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); font: 700 1.1rem var(--font-d); }
.shelf img, .shelf .cover { box-shadow: 0 4px 10px rgba(0,0,0,.2); }
.shelf { border-bottom: 8px solid var(--line); padding-bottom: 0; }

/* Pagos: sin borde lateral; la urgencia va en el texto */
.payment, .payment.soon, .payment.late { border-left: 0 !important; }
.payment.late .pay-due { color: var(--late); }
.payment.soon .pay-due { color: var(--soon); }

/* Subnavegación de Finanzas: pestañas subrayadas */
.subnav { gap: 4px; border-bottom: 1px solid var(--line); }
.subnav a { background: none; border: 0; border-radius: 0; min-height: 44px; color: var(--muted); }
.subnav a.on { background: none; color: var(--ink); box-shadow: inset 0 -3px 0 var(--accent); }

/* Campos */
.field input:not([type=radio]):not([type=checkbox]), .field select, textarea { min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); }
.field input:focus-visible, .field select:focus-visible, textarea:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field [aria-invalid="true"] { border-color: var(--late); border-width: 2px; }
.chip:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.day-chip input:checked + span { background: var(--ink); color: var(--bg); }

/* Toast */
.toast { background: var(--ink); color: var(--bg); border-radius: 16px; font-weight: 700; }

/* Navegación: píldora flotante con texto (5 secciones) */
.tabbar { left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 14px); transform: none; width: auto; max-width: 30rem; margin: 0 auto;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); padding: 6px; border-radius: 30px; border: 0;
  background: var(--ink); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
@media (prefers-color-scheme: dark) { .tabbar { background: #2A2925; } .tabbar a { color: #B5B0A3; } .tabbar a.on { background: #F0EDE4; color: #141412; } }
.tabbar a { flex-direction: column; gap: 2px; height: 50px; min-width: 0; padding: 0; border-radius: 24px; color: #C9C4B8; font-size: 11px; }
.tabbar a span { display: block !important; font-size: 11px; }
.tabbar svg { width: 20px; height: 20px; }
.tabbar a.on { background: var(--bg); color: var(--ink); font-weight: 700; }

/* Escritorio: barra lateral y dos columnas */
@media (min-width: 1024px) {
  body.app { padding: 0 0 40px 248px; }
  .tabbar { top: 0; bottom: 0; left: 0; right: auto; width: 232px; max-width: none; margin: 0; border-radius: 0; grid-auto-flow: row; grid-auto-rows: 44px; align-content: start;
    padding: 88px 16px 24px; gap: 6px; background: var(--paper); border-right: 1px solid var(--line); box-shadow: none; }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: 12px; height: 44px; padding: 0 12px; border-radius: 12px; color: var(--muted); font-size: 1rem; }
  .tabbar a span { font-size: 1rem; }
  .tabbar a.on, .tabbar a.on:is(*) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
  @media (prefers-color-scheme: dark) { .tabbar a { color: var(--muted); } .tabbar a.on { background: var(--surface); color: var(--ink); } }
  .topbar { position: fixed; top: 0; left: 0; width: 232px; z-index: 11; padding: 24px 26px; }
  .topbar .link-btn { display: none; }
  .wrap { max-width: 72rem; padding: 40px 48px 0; }
  .tasks { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; align-items: start; }
  .tasks .task-reading { grid-column: 1 / -1; }
}

@keyframes pulso-pop { 0% { transform: scale(.7); } 55% { transform: scale(1.14); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* =====================================================================
   Integración en Pulso 0.6 (añadido tras la entrega de diseño)
   ===================================================================== */
/* Estados que no dependen solo del color: «a medias» rellena la mitad y «sin hacer» va tachado */
.st-partial { background: linear-gradient(to top, var(--partial) 50%, color-mix(in srgb, var(--partial) 38%, var(--off)) 50%); }
.st-miss { background: linear-gradient(to top right, var(--miss) calc(50% - 1.2px), var(--cell-ink) calc(50% - 1.2px), var(--cell-ink) calc(50% + 1.2px), var(--miss) calc(50% + 1.2px)); }
@media (prefers-color-scheme: dark) { .st-miss { background: linear-gradient(to top right, var(--miss) calc(50% - 1.2px), rgba(0,0,0,.55) calc(50% - 1.2px), rgba(0,0,0,.55) calc(50% + 1.2px), var(--miss) calc(50% + 1.2px)); } }
.strip .st-miss, .legend .st-miss { background: linear-gradient(to top right, var(--miss) calc(50% - 1px), var(--cell-ink) calc(50% - 1px), var(--cell-ink) calc(50% + 1px), var(--miss) calc(50% + 1px)); }
/* Ajustes: en el móvil está arriba a la derecha; en escritorio, al final de la barra lateral */
.tabbar a.tab-desk { display: none; }
@media (min-width: 1024px) {
  .tabbar a.tab-desk { display: flex; margin-top: 12px; }
}
@media (min-width: 1024px) { .tasks { grid-auto-flow: row dense; } }
.payment, .payment.soon, .payment.late { box-shadow: var(--shadow); }
.payments.compact .payment { box-shadow: none; background: var(--paper); }
details.quick-expense { background: none; box-shadow: none; border-radius: 0; }

/* Apple Pay */
.token-box { display: grid; gap: 10px; padding: 14px; margin: 10px 0 6px; border-radius: 14px; background: var(--accent-soft); }
.token-box p { margin: 0; }
.token-value { width: 100%; min-height: 46px; padding: 10px 12px; border: 1.5px solid var(--accent); border-radius: 12px; background: var(--surface); color: var(--ink); font: 700 .92rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.steps { margin: 10px 0; padding-left: 1.3em; display: grid; gap: 10px; }
.steps code, .hint code { font: .88em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--paper); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }
.review-form { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.review-form label:first-of-type { flex: 1; min-width: 10rem; }
.review-form select { width: 100%; min-height: 44px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; }
.check-line.small { font-weight: 400; font-size: .95rem; }

/* Barra inferior: sección activa visible en oscuro y textos en iPhone pequeños */
@media (prefers-color-scheme: dark) and (max-width: 1023px) {
  .tabbar a.on { background: #F0EDE4; color: #141412; }
}
@media (max-width: 359px) {
  .tabbar { left: 8px; right: 8px; padding: 5px; }
  .tabbar a, .tabbar a span { font-size: 10px; letter-spacing: -0.01em; }
}

/* 0.8 · Barra inferior: iconos y texto centrados dentro de cada botón, y barra más pegada al borde */
@media (max-width: 1023px) {
  .tabbar { bottom: calc(env(safe-area-inset-bottom, 0px) * 0.55 + 10px); align-items: center; }
  .tabbar a { display: flex; flex-direction: column; justify-content: center; align-items: center; line-height: 1; gap: 4px; }
  .tabbar a svg { flex: none; display: block; }
  .tabbar a span { line-height: 1.1; }
}

/* 0.8 · Fechas y horas en iPhone: Safari les da un ancho mínimo propio y se salen del recuadro */
input[type=date], input[type=time], input[type=datetime-local] {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; min-width: 0; max-width: 100%;
  text-align: left;
}
input[type=date]::-webkit-date-and-time-value,
input[type=time]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.5em; }
.field, .row > *, .form > * { min-width: 0; max-width: 100%; }

/* 0.8 · Gym: plan y peso */
.gym-plan .plan-dias { display: none; }
.gym-plan:has(input[name=plan][value=dias]:checked) .plan-dias { display: grid; }
.gym-plan:has(input[name=plan][value=dias]:checked) .plan-semana { display: none; }
.day-chip input[type=radio]:checked + span { background: var(--ink); color: var(--bg); }
.weight-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: 12px; margin: 4px 0 8px; }
.weight-stats strong { display: block; font: 800 1.45rem/1.1 var(--font-d); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.weight-stats span { color: var(--muted); font-size: .9rem; }
.weight-goal-text { margin: 0 0 10px; font-weight: 700; }
.wchart { display: block; width: 100%; height: auto; margin: 6px 0 14px; overflow: visible; }
.wc-grid { stroke: var(--line); stroke-width: 1; }
.wc-lbl { fill: var(--muted); font: 10px var(--font-b); }
.wc-goal { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 5 4; }
.wc-goal-lbl { fill: var(--ok-ink, var(--ok)); font: 700 10px var(--font-b); }
.wc-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.wc-dot { fill: var(--accent); stroke: var(--paper); stroke-width: 2; }
.weight-form { margin-top: 6px; }
