/* App v2 · sistema de diseño (diseno.md §2–§4): «cálido y sereno». Claro siempre por defecto; Noche solo
   si se elige en Ajustes (html[data-theme="noche"]). Nunca prefers-color-scheme. Cada carril tiene su CSS
   (styles/<carril>.css) y usa estos tokens y componentes; lo que sea de todos, aquí. */

@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url("../fonts/nunito-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #FBF6EE;
  --surface: #FFFDF9;
  --sunk: #F5EEE2;
  --line: #EEE5D7;
  --line-2: #E2D6C4;
  --ink: #2E3833;
  --ink-2: #5F6B64;
  --ink-3: #6E7972;
  --sage: #7E9C85;            /* decorativo (ilustraciones, foco) */
  --sage-ink: #3F5E48;
  --sage-strong: #6A8C72;
  --sage-soft: #E4ECE3;
  --sage-wash: #EFF3EC;
  --peach: #F3B79E;
  --peach-strong: #E59E80;
  --peach-ink: #A3522F;
  --peach-soft: #FBE6DB;
  --peach-wash: #FDF3EC;
  --late-ink: #9A4A30; --late-bg: #F7E4DB;
  --now-ink: #80540F;  --now-bg: #F7EAD3; --now-dot: #D39A45;
  --sos: #B23A2A;      --sos-bg: #FBE3DE;
  --on-sage: #FFFFFF;          /* texto sobre --sage-ink */
  --on-sos: #FFFFFF;           /* texto sobre --sos */
  --sage-ink-hover: #355140;
  --focus: #7E9C85;
  --glass: rgba(251, 246, 238, .86);
  --glass-2: rgba(255, 253, 249, .94);
  --backdrop: rgba(46, 56, 51, .36);
  --toast-bg: #2E3833; --toast-ink: #FBF6EE; --toast-action: #F6C7B2; --toast-error: #7A3A26;
  --shadow-1: 0 1px 2px rgba(46, 56, 51, .04), 0 6px 20px rgba(46, 56, 51, .045);
  --shadow-2: 0 18px 50px rgba(46, 56, 51, .18), 0 2px 8px rgba(46, 56, 51, .06);
  --shadow-bar: 0 6px 24px rgba(46, 56, 51, .12), 0 1px 3px rgba(46, 56, 51, .08);
  --gate-glow: #FFFDF9;
  /* Colores de persona (settings.personas.*.color) */
  --av-salvia-bg: #E4ECE3;    --av-salvia-ink: #3F5E48;
  --av-melocoton-bg: #FBE6DB; --av-melocoton-ink: #A3522F;
  --av-arena-bg: #F1E6CF;     --av-arena-ink: #6B5220;
  --av-cielo-bg: #DFEAF2;     --av-cielo-ink: #2F5670;
  --av-lavanda-bg: #ECE6F3;   --av-lavanda-ink: #5A4A7A;
  /* Forma, tipo, espacio, movimiento */
  --radius: 20px; --radius-sm: 14px; --radius-xs: 10px;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.5, 0, .75, 0);
  --spring: cubic-bezier(.34, 1.36, .5, 1);
  --gutter: 16px;
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --side-w: 0px;
  --panel-w: 0px;
  --content-max: 760px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --bottom-clear: calc(var(--tabbar-h) + var(--safe-b) + 24px);
  --toast-bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
}

/* Noche: cálido oscuro (no negro puro); sombras casi nulas y bordes --line. */
html[data-theme="noche"] {
  color-scheme: dark;
  --bg: #1C1A17;
  --surface: #252220;
  --sunk: #2D2925;
  --line: #38332D;
  --line-2: #4A433B;
  --ink: #F1EADF;
  --ink-2: #C9BFB1;
  --ink-3: #A99F92;
  --sage: #7FA487;
  --sage-ink: #A9C9B0;
  --sage-strong: #7FA487;
  --sage-soft: #2C3A30;
  --sage-wash: #263129;
  --peach: #C98A6E;
  --peach-strong: #D79478;
  --peach-ink: #F2B79C;
  --peach-soft: #4A2F24;
  --peach-wash: #35261F;
  --late-ink: #F4A88C; --late-bg: #4A2A20;
  --now-ink: #E8C07A;  --now-bg: #3F3220; --now-dot: #C99A4E;
  --sos: #FF9C8A;      --sos-bg: #4C2420;
  --on-sage: #1C1A17;
  --on-sos: #1C1A17;
  --sage-ink-hover: #BCD7C2;
  --focus: #A9C9B0;
  --glass: rgba(28, 26, 23, .86);
  --glass-2: rgba(37, 34, 32, .94);
  --backdrop: rgba(0, 0, 0, .55);
  --toast-bg: #F1EADF; --toast-ink: #1C1A17; --toast-action: #A3522F; --toast-error: #F4A88C;
  --shadow-1: 0 0 0 transparent;
  --shadow-2: 0 18px 50px rgba(0, 0, 0, .45);
  --shadow-bar: 0 4px 18px rgba(0, 0, 0, .35);
  --gate-glow: #25221F;
  --av-salvia-bg: #2C3A30;    --av-salvia-ink: #A9C9B0;
  --av-melocoton-bg: #4A2F24; --av-melocoton-ink: #F2B79C;
  --av-arena-bg: #3D3424;     --av-arena-ink: #E3CB98;
  --av-cielo-bg: #23323D;     --av-cielo-ink: #A9C8DE;
  --av-lavanda-bg: #332B3E;   --av-lavanda-ink: #CDBDE8;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); scroll-padding-top: calc(var(--topbar-h) + var(--safe-t) + 12px); scroll-padding-bottom: var(--bottom-clear); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.5; font-weight: 600;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  /* clip (no hidden): no convierte body en contenedor de scroll, así la barra superior sigue fija con una hoja abierta */
  overflow-x: hidden; overflow-x: clip;
}
html.sheet-open { overflow: hidden; }
h1, h2, h3, h4, p, dl, dd, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .5; }
a { color: var(--sage-ink); text-underline-offset: 3px; -webkit-tap-highlight-color: transparent; }
mark { background: var(--peach-soft); color: inherit; border-radius: 4px; padding: 0 2px; box-shadow: inset 0 -2px 0 var(--peach); }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 12px; }
.input:focus-visible { outline: none; }
[tabindex="-1"]:focus, main:focus { outline: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ico { flex: none; display: block; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.fineprint { font-size: 13px; color: var(--ink-2); font-weight: 600; text-align: center; }
.plain-list { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.plain-list li { display: flex; flex-direction: column; gap: 2px; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.noscript { padding: 24px; text-align: center; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--sage-ink); color: var(--on-sage); padding: 10px 14px; border-radius: 12px; font-weight: 800; text-decoration: none; }
.skip:focus { top: calc(var(--safe-t) + 8px); }
.tel-link { color: var(--sage-ink); font-weight: 800; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; white-space: nowrap; }
.link-btn { color: var(--sage-ink); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Ilustraciones lineales ---------- */
.illus { display: block; stroke-width: 1.5; overflow: visible; }
.illus path { vector-effect: non-scaling-stroke; fill: none; }
.illus .t-s { stroke: var(--sage); }
.illus .t-d { stroke: var(--sage-ink); }
.illus .t-p { stroke: var(--peach-strong); }
.illus .t-q { stroke: var(--peach); }
.illus.draw path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 140ms + 80ms); }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Entrada: carga, acceso, «¿Quién eres?» ---------- */
.splash { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--sage-ink); }
.splash-art { width: 76px; height: 76px; }
.splash-name { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.splash-text { color: var(--ink-2); font-weight: 600; }
.gate { position: relative; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: calc(72px + var(--safe-t)) 20px calc(28px + var(--safe-b));
  background: radial-gradient(120% 70% at 50% 0%, var(--gate-glow) 0%, var(--bg) 60%), var(--bg); }
.gate-card { width: 100%; max-width: 400px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.gate-card.wide { max-width: 560px; }
.gate-art { width: 172px; height: auto; margin-bottom: 18px; }
.gate-art.small { width: 84px; }
.gate-title { font-size: 40px; font-weight: 800; letter-spacing: -.02em; color: var(--sage-ink); line-height: 1.1; }
.gate-sub { margin-top: 6px; font-size: 18px; font-weight: 800; color: var(--peach-ink); }
.gate-text { margin-top: 10px; color: var(--ink-2); font-size: 15px; max-width: 420px; }
.gate .btn { margin-top: 22px; }
.login-form { width: 100%; margin-top: 32px; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.pw-wrap { position: relative; }
.login-input { min-height: 56px; font-size: 18px; padding-right: 56px; border-radius: 16px; }
.eye-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.login-msg { min-height: 1.5em; font-size: 14px; font-weight: 700; color: var(--late-ink); }
.login-msg.info { color: var(--ink-2); font-weight: 600; }
.login-form .btn { min-height: 56px; border-radius: 16px; font-size: 17px; margin-top: 4px; }
.who-grid { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 28px; }
.who-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 12px 22px; border-radius: 24px; background: var(--surface); border: 1.5px solid var(--line); box-shadow: var(--shadow-1); transition: transform .18s var(--ease), border-color .2s, box-shadow .2s; }
.who-card:hover { border-color: var(--sage); }
.who-card:active { transform: scale(.98); }
.who-name { font-size: 22px; font-weight: 800; color: var(--ink); }

/* ---------- Marco ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.main-col { min-width: 0; padding-bottom: var(--bottom-clear); }
.topbar { position: sticky; top: 0; z-index: 20; padding-top: var(--safe-t); background: var(--bg); border-bottom: 1px solid transparent; transition: border-color .25s, background-color .25s; }
.topbar.scrolled { background: var(--glass); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); border-bottom-color: var(--line); }
.topbar-inner { height: var(--topbar-h); max-width: calc(var(--content-max) + 2 * var(--gutter)); margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 0 calc(8px + var(--safe-r)) 0 calc(8px + var(--safe-l)); }
.tb-me { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; }
.tb-count { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; min-height: 44px; padding: 0 6px; border-radius: 12px; text-decoration: none; color: var(--ink); white-space: nowrap; overflow: hidden; align-items: center; }
.tb-count:hover { background: var(--sunk); }
.tb-week { font-size: 16px; font-weight: 800; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; }
.tb-days { font-size: 14px; font-weight: 700; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.tb-dot { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.tb-count.no-days .tb-dot { display: none; }
.tb-search { color: var(--ink-2); }
.tb-ask { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 44px; min-width: 44px; padding: 0 12px 0 10px; border-radius: 999px; background: var(--peach-wash); color: var(--peach-ink); box-shadow: inset 0 0 0 1px var(--peach-soft); font-size: 14px; font-weight: 800; white-space: nowrap; }
.tb-ask:hover { background: var(--peach-soft); }
.me-av { position: relative; display: inline-grid; place-items: center; flex: none; }
.me-gear { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); color: var(--ink-2); box-shadow: 0 0 0 1px var(--line-2); }
.me-gear .ico { width: 11px; height: 11px; }

.offline-band { position: sticky; top: calc(var(--topbar-h) + var(--safe-t)); z-index: 19; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px; padding: 6px var(--gutter); background: var(--now-bg); color: var(--now-ink); font-size: 13px; font-weight: 800; text-align: center; line-height: 1.3; }
.offline-band[hidden] { display: none; }
.offline-band .ico { width: 16px; height: 16px; }
.offline-band > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.offline-band.sending { background: var(--sage-wash); color: var(--sage-ink); }

.view { max-width: calc(var(--content-max) + 2 * var(--gutter)); margin: 0 auto; padding: 8px calc(var(--gutter) + var(--safe-r)) 0 calc(var(--gutter) + var(--safe-l)); outline: none; }
.view.enter { animation: viewIn .26s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.as-compose-row > .comer-btn { color: var(--peach-ink); }
.as-composer.is-recording .comer-btn { display: none; }
/* Panel de escritorio (views/asistente.js): con el botón de comer, botones de 44 y menos hueco para que el campo respire */
.as-compose-row:has(> .comer-btn) { gap: 4px; }
.as-compose-row:has(> .comer-btn) > .icon-btn { width: 44px; height: 44px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); padding: 0 var(--safe-r) var(--safe-b) var(--safe-l); background: var(--glass-2); -webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2); border-top: 1px solid var(--line); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tabbar-h); min-width: 0; text-decoration: none; color: var(--ink-2); font-size: 13px; font-weight: 700; -webkit-tap-highlight-color: transparent; }
.tab-ico { width: 56px; height: 30px; border-radius: 999px; display: grid; place-items: center; transition: background .3s var(--ease), color .2s; }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.tab[aria-current="page"] { color: var(--sage-ink); font-weight: 800; }
.tab[aria-current="page"] .tab-ico { background: var(--sage-soft); }
.tab:focus-visible { outline-offset: -4px; }
.tab.is-accent .tab-ico { width: 52px; height: 36px; margin-top: -4px; background: var(--sage-ink); color: var(--on-sage); box-shadow: 0 4px 12px rgba(63, 94, 72, .22); }
.tab.is-accent[aria-current="page"] .tab-ico { background: var(--sage-ink-hover); }

/* Barra lateral (tableta y escritorio) y panel del asistente (escritorio) */
.side, .apanel { display: none; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; text-decoration: none; color: inherit; }
.side-logo { width: 40px; height: 40px; flex: none; }
.side-name { font-size: 21px; font-weight: 800; color: var(--sage-ink); letter-spacing: -.015em; line-height: 1.1; }
.side-count { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.side-me { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 8px; border-radius: 14px; font-weight: 800; text-align: left; width: 100%; }
.side-me:hover { background: var(--sunk); }
.side-search, .side-ask { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 14px; background: var(--sunk); color: var(--ink-2); font-weight: 700; text-decoration: none; width: 100%; }
.side-ask .ico { color: var(--peach-ink); }
.side-search:hover, .side-ask:hover { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 14px; text-decoration: none; color: var(--ink-2); font-weight: 700; font-size: 15px; transition: background .2s, color .2s; }
.side-link:hover { background: var(--sunk); color: var(--ink); }
.side-link[aria-current="page"] { background: var(--sage-soft); color: var(--sage-ink); font-weight: 800; }

/* ---------- Cabeceras, secciones y tarjetas ---------- */
.screen-head { display: flex; align-items: center; gap: 8px; margin: 6px 0 16px; min-height: 44px; }
.screen-head.has-back { margin-left: -10px; }
.screen-head-text { flex: 1; min-width: 0; }
.screen-title { font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; color: var(--ink); overflow-wrap: anywhere; }
.screen-sub { margin-top: 2px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.screen-actions { flex: none; display: flex; align-items: center; gap: 4px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 6px; min-height: 32px; }
.sec-title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.sec-count { font-size: 13px; font-weight: 800; color: var(--ink-2); background: var(--sunk); border-radius: 999px; padding: 2px 9px; font-variant-numeric: tabular-nums; }
.sec-action { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 2px 0 8px; font-size: 14px; font-weight: 800; color: var(--sage-ink); text-decoration: none; border-radius: 10px; }
.sec-action:hover { text-decoration: underline; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); box-shadow: var(--shadow-1); }
.card + .card { margin-top: var(--s3); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-title { font-size: 17px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.card-action { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin: -8px -6px -8px 0; padding: 0 4px 0 8px; font-size: 14px; font-weight: 800; color: var(--sage-ink); text-decoration: none; border-radius: 10px; white-space: nowrap; }
.card-action:hover { background: var(--sage-wash); }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: var(--radius-sm); font-weight: 800; font-size: 15px; line-height: 1.2; text-align: center; text-decoration: none; transition: transform .14s var(--ease), background .2s, box-shadow .2s, color .2s; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-primary { background: var(--sage-ink); color: var(--on-sage); box-shadow: 0 6px 16px rgba(63, 94, 72, .2); }
.btn-primary:hover:not(:disabled) { background: var(--sage-ink-hover); }
.btn-soft { background: var(--sage-soft); color: var(--sage-ink); }
.btn-soft:hover:not(:disabled) { box-shadow: inset 0 0 0 1.5px var(--sage); }
.btn-ghost { background: transparent; color: var(--sage-ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn-ghost:hover:not(:disabled) { background: var(--sage-wash); }
.btn-danger { background: var(--late-ink); color: var(--surface); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
.btn-text { background: transparent; color: var(--sage-ink); padding: 0 10px; }
.btn-text:hover:not(:disabled) { background: var(--sage-wash); }
.btn-sos { background: var(--sos); color: var(--on-sos); }
.btn-peach { background: var(--peach-soft); color: var(--peach-ink); }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: 14px; }
.btn-wide { flex: 1; width: 100%; }
.btn[data-busy] { opacity: .75; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center; border-radius: 12px; color: var(--ink-2); text-decoration: none; transition: background .2s, color .2s; }
.icon-btn:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.icon-btn[hidden] { display: none; }
html.offline [data-needs-net] { opacity: .45; cursor: not-allowed; }

/* ---------- Chips ---------- */
.chip-s { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; font-size: 13px; font-weight: 700; line-height: 1.15; padding: 4px 9px; border-radius: 999px; background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.chip-s > span { overflow: hidden; text-overflow: ellipsis; }
.chip-s .ico { width: 14px; height: 14px; }
.chip-s.tone-neutral { background: var(--sunk); color: var(--ink-2); }
.chip-s.tone-late { background: var(--late-bg); color: var(--late-ink); }
.chip-s.tone-now { background: var(--now-bg); color: var(--now-ink); }
.chip-s.tone-future { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.chip-s.tone-done, .chip-s.tone-sage { background: var(--sage-soft); color: var(--sage-ink); }
.chip-s.tone-peach { background: var(--peach-soft); color: var(--peach-ink); }
.chip-s.tone-sos { background: var(--sos-bg); color: var(--sos); }
.chip-cat { background: var(--sage-wash); color: var(--sage-ink); padding-left: 7px; }
.chip-cat.cat-salud, .chip-cat.cat-posparto, .chip-cat.cat-clases { background: var(--peach-wash); color: var(--peach-ink); }
.chip-cat.cat-tramites, .chip-cat.cat-ayudas, .chip-cat.cat-trabajo { background: var(--now-bg); color: var(--now-ink); }
.chip-confirm { white-space: normal; text-align: left; }
.confirm-dot { display: inline-block; width: 8px; height: 8px; margin: 0 4px; border-radius: 50%; background: var(--now-dot); box-shadow: 0 0 0 3px var(--now-bg); vertical-align: middle; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Avatares ---------- */
.avatar { flex: none; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 800; line-height: 1; background: var(--av-salvia-bg); color: var(--av-salvia-ink); }
.avatar-sm { width: 24px; height: 24px; font-size: 12px; }
.avatar-md { width: 32px; height: 32px; font-size: 14px; }
.avatar-lg { width: 44px; height: 44px; font-size: 18px; }
.avatar-xl { width: 72px; height: 72px; font-size: 30px; }
.av-salvia { background: var(--av-salvia-bg); color: var(--av-salvia-ink); }
.av-melocoton { background: var(--av-melocoton-bg); color: var(--av-melocoton-ink); }
.av-arena { background: var(--av-arena-bg); color: var(--av-arena-ink); }
.av-cielo { background: var(--av-cielo-bg); color: var(--av-cielo-ink); }
.av-lavanda { background: var(--av-lavanda-bg); color: var(--av-lavanda-ink); }
.avatars { display: inline-flex; flex: none; width: auto; height: auto; }
.avatars .avatar + .avatar { margin-left: -7px; box-shadow: 0 0 0 2px var(--surface); }

/* ---------- Casilla ---------- */
.check { position: relative; z-index: 1; flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; }
.check-sm { width: 44px; height: 44px; }
.check-svg { width: 28px; height: 28px; overflow: visible; }
.check-sm .check-svg { width: 24px; height: 24px; }
.check-box { fill: var(--surface); stroke: var(--sage-strong); stroke-width: 1.8; transition: fill .22s var(--ease), stroke .22s; }
.check-mark { fill: none; stroke: var(--on-sage); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .3s var(--ease) .05s; }
.check:hover .check-box { stroke: var(--sage-ink); fill: var(--sage-wash); }
.check[aria-checked="true"] .check-box { fill: var(--sage-ink); stroke: var(--sage-ink); }
.check[aria-checked="true"] .check-mark { stroke-dashoffset: 0; }
.check.just-on .check-svg { animation: pop .4s var(--spring); }
.check.just-off .check-mark { transition-duration: .15s; transition-delay: 0s; }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(.84); } 100% { transform: scale(1); } }

/* ---------- Filas (rows.js) ---------- */
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.row { position: relative; display: flex; align-items: center; gap: 4px; min-height: 64px; padding: 4px 4px 4px 0; border-radius: var(--radius-sm); transition: background .2s, opacity .3s var(--ease), height .36s var(--ease); }
.rows > .row + .row::before { content: ""; position: absolute; left: 52px; right: 8px; top: 0; height: 1px; background: var(--line); }
.row:hover { background: color-mix(in srgb, var(--sunk) 55%, transparent); }
.row.leaving { opacity: 0; overflow: hidden; pointer-events: none; }
.row-lead { position: relative; z-index: 1; flex: none; width: 48px; display: grid; place-items: center; align-self: stretch; }
.row-lead-ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--sage-wash); color: var(--sage-ink); }
.row-main { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 9px 8px 9px 2px; text-align: left; border-radius: 12px; color: inherit; }
.row-line { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.row-line-2 { align-items: center; }
.row-line > :first-child { flex: 1; min-width: 0; }
.row-end { flex: none; display: inline-flex; align-items: center; gap: 6px; max-width: 60%; }
.row-line:first-child > .row-end { min-height: 21px; }
.row-end .chip-s { max-width: 100%; }
.row-main::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-sm); }
.row-main:focus-visible { outline: none; }
.row-main:focus-visible::after { outline: 3px solid var(--focus); outline-offset: -2px; }
.row-title { font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; transition: color .3s; }
.row-sub { font-size: 14px; font-weight: 600; color: var(--ink-2); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.is-done .row-title { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: color-mix(in srgb, var(--ink-2) 55%, transparent); }
.row.is-out .row-title { color: var(--ink-2); }
.row-price { font-size: 15px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-price.est { color: var(--ink-2); font-weight: 700; }
.row-price.state { font-size: 13px; font-weight: 800; color: var(--sage-ink); }
.row-units { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.date-tile { width: 40px; height: 44px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--peach-wash); color: var(--peach-ink); line-height: 1; }
.date-tile b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.date-tile small { font-size: 13px; font-weight: 800; margin-top: 2px; }
.date-tile.past { background: var(--sunk); color: var(--ink-2); }

/* ---------- Segmentado ---------- */
.seg { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; background: var(--sunk); border-radius: 15px; padding: 4px; gap: 2px; }
.seg::-webkit-scrollbar { display: none; }
.seg-btn { flex: 1 0 auto; min-height: 44px; padding: 0 14px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; font-size: 14px; color: var(--ink-2); white-space: nowrap; transition: background .22s var(--ease), color .2s, box-shadow .22s; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.on { background: var(--surface); color: var(--sage-ink); font-weight: 800; box-shadow: 0 1px 2px rgba(46, 56, 51, .08), 0 3px 10px rgba(46, 56, 51, .07); }
html[data-theme="noche"] .seg-btn.on { background: var(--line-2); color: var(--ink); box-shadow: none; }
.seg.seg-wide, .field .seg { display: flex; width: 100%; }

/* ---------- Plegable ---------- */
.fold { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.fold + .fold { margin-top: var(--s3); }
.fold-head { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 14px 0 16px; cursor: pointer; border-radius: var(--radius); }
.fold-head::-webkit-details-marker { display: none; }
.fold-label { flex: 1; min-width: 0; font-size: 16px; font-weight: 800; color: var(--ink); }
.fold-count { color: var(--ink-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.fold-sum { font-size: 14px; color: var(--ink-2); font-weight: 700; white-space: nowrap; }
.fold-chev { color: var(--ink-2); transition: transform .25s var(--ease); }
.fold[open] > .fold-head .fold-chev { transform: rotate(180deg); }
.fold-head:hover { background: color-mix(in srgb, var(--sunk) 50%, transparent); }
.fold-body { padding: 0 8px 10px; }
.fold.flat { background: transparent; border: 0; box-shadow: none; }
.fold.flat > .fold-head { padding: 0 6px; }
.fold.flat > .fold-body { padding: 0; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field[hidden] { display: none; } /* `display: flex` le ganaba al atributo hidden: los campos que se ocultan (el precio mensual, «¿Quién os lo ha regalado?»…) seguían a la vista */
.field-label { font-size: 14px; font-weight: 800; color: var(--ink); }
.field-hint { font-size: 14px; color: var(--ink-2); line-height: 1.45; font-weight: 600; }
.field-error { font-size: 14px; color: var(--late-ink); font-weight: 700; }
.input { display: block; width: 100%; min-width: 0; min-height: 48px; padding: 11px 14px; border-radius: 13px; border: 1.5px solid var(--line-2); background: var(--surface); font-size: 16px; font-weight: 600; line-height: 1.35; color: var(--ink); transition: border-color .2s, box-shadow .2s; -webkit-appearance: none; appearance: none; }
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:focus { border-color: var(--sage-strong); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sage) 25%, transparent); }
.input:disabled { opacity: .6; }
.input[aria-invalid="true"] { border-color: var(--late-ink); }
input[type="date"].input { text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="search"]::-webkit-search-cancel-button { display: none; }
.textarea { resize: vertical; line-height: 1.5; min-height: 88px; }
.select { padding-right: 42px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: right 20px center, right 14px center; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input-affix { display: flex; align-items: center; gap: 8px; }
.input-affix .input { width: 140px; }
.affix { font-weight: 800; color: var(--ink-2); }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; font-size: 15px; color: var(--ink); }
.switch-track { position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--line-2); transition: background .25s var(--ease); flex: none; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(46, 56, 51, .25); transition: transform .28s var(--spring); }
.switch[aria-checked="true"] .switch-track { background: var(--sage-ink); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(18px); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, currentColor 25%, transparent); transition: transform .15s var(--ease), box-shadow .2s; }
.swatch .ico { opacity: 0; transition: opacity .2s; }
.swatch.on { box-shadow: inset 0 0 0 2.5px currentColor; }
.swatch.on .ico { opacity: 1; }
.swatch:active { transform: scale(.94); }

/* ---------- Hojas (móvil: inferior; ≥760: diálogo; lateral) ---------- */
.sheet-layer { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--backdrop); opacity: 0; transition: opacity .28s var(--ease); }
.sheet-layer.open .sheet-backdrop { opacity: 1; }
.sheet-layer.closing .sheet-backdrop { opacity: 0; transition-duration: .22s; }
.sheet { position: absolute; display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-2); outline: none; will-change: transform; }
.sheet-grip { display: none; justify-content: center; padding: 10px 0 2px; touch-action: none; cursor: grab; }
.sheet-grip span { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); }
.sheet-head { display: flex; align-items: center; gap: 2px; min-height: 56px; padding: 4px 6px 4px 20px; touch-action: none; }
.sheet.has-back .sheet-head { padding-left: 6px; }
.sheet-title { flex: 1; min-width: 0; padding: 8px 0; font-size: 20px; line-height: 1.25; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.sheet-title:empty { visibility: hidden; }
.sheet-head-extra { display: flex; align-items: center; gap: 2px; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 20px 24px; }
.sheet:not(.has-foot) .sheet-body { padding-bottom: calc(24px + var(--safe-b)); }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface); }
.sheet-foot[hidden] { display: none; }
.sheet-foot .btn-wide { flex: 1; }

/* Inferior (móvil) */
.sheet-layer[data-mode="bottom"] .sheet { left: 0; right: 0; bottom: 0; max-height: calc(100vh - var(--topbar-h) - var(--safe-t)); max-height: calc(100dvh - var(--topbar-h) - var(--safe-t)); border-radius: 26px 26px 0 0; transform: translateY(105%); transition: transform .42s cubic-bezier(.22, 1.12, .36, 1), height .32s var(--ease); }
.sheet-layer[data-mode="bottom"] .sheet::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 60px; background: var(--surface); }
.sheet-layer[data-mode="bottom"] .sheet-grip { display: flex; }
.sheet-layer[data-mode="bottom"] .sheet-head { min-height: 48px; }
.sheet-layer[data-mode="bottom"][data-size="media"] .sheet { height: 55vh; height: 55dvh; }
.sheet-layer[data-mode="bottom"][data-size="completa"] .sheet { height: calc(100vh - var(--topbar-h) - var(--safe-t)); height: calc(100dvh - var(--topbar-h) - var(--safe-t)); }
.sheet-layer[data-mode="bottom"].open .sheet { transform: translateY(0); }
.sheet-layer[data-mode="bottom"].closing .sheet { transform: translateY(105%); transition: transform .26s var(--ease-in); }
.sheet.dragging { transition: none !important; }

/* Diálogo centrado (≥760 px, y confirmaciones en todas partes) */
.sheet-layer[data-mode="dialog"] { display: grid; place-items: center; padding: 24px 16px; }
.sheet-layer[data-mode="dialog"] .sheet { position: relative; width: 100%; max-width: 560px; max-height: min(86vh, 860px); max-height: min(86dvh, 860px); border-radius: 24px; opacity: 0; transform: translateY(14px) scale(.98); transition: opacity .22s var(--ease), transform .3s var(--ease); }
.sheet-layer[data-mode="dialog"][data-size="completa"] .sheet { height: min(86vh, 860px); height: min(86dvh, 860px); }
.sheet-layer[data-mode="dialog"][data-size="media"] .sheet { min-height: min(55vh, 560px); }
.sheet-layer[data-mode="dialog"].open .sheet { opacity: 1; transform: none; }
.sheet-layer[data-mode="dialog"].closing .sheet { opacity: 0; transform: translateY(8px) scale(.98); }
.sheet-layer[data-mode="dialog"] .sheet-head { padding: 12px 10px 4px 24px; }
.sheet-layer[data-mode="dialog"] .sheet-body { padding: 4px 24px 24px; }
.sheet-layer[data-mode="dialog"] .sheet-foot { padding: 14px 24px; border-radius: 0 0 24px 24px; }

/* Lateral derecho (asistente en tableta) */
.sheet-layer[data-mode="side"] .sheet { top: 0; right: 0; bottom: 0; width: min(440px, 92vw); border-radius: 26px 0 0 26px; transform: translateX(105%); transition: transform .38s cubic-bezier(.22, 1.08, .36, 1); }
.sheet-layer[data-mode="side"].open .sheet { transform: none; }
.sheet-layer[data-mode="side"].closing .sheet { transform: translateX(105%); }
.sheet-layer[data-mode="side"] .sheet-head { padding: calc(12px + var(--safe-t)) 10px 4px 24px; }

/* Confirmación */
.sheet-confirm { max-width: 400px !important; }
.sheet-confirm .sheet-head { padding: 18px 16px 0 22px !important; }
.sheet-confirm .sheet-title { font-size: 19px; }
.sheet-confirm .sheet-body { padding: 0 22px 8px !important; }
.sheet-confirm .sheet-foot { border-top: 0; justify-content: flex-end; padding: 10px 16px 16px !important; }
.sheet-confirm .sheet-close { display: none; }
.confirm-text { color: var(--ink-2); font-size: 15px; }

/* Menú «⋯»: hoja de acciones (móvil) y menú flotante (escritorio) */
.action-list { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }
.action-item { display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 12px; border-radius: 14px; text-align: left; font-size: 16px; font-weight: 700; color: var(--ink); }
.action-item:hover:not(:disabled) { background: var(--sunk); }
.action-item .ico { color: var(--ink-2); }
.action-item.danger, .action-item.danger .ico, .menu-item.danger, .menu-item.danger .ico { color: var(--late-ink); }
.action-pad { width: 22px; }
.action-text { display: flex; flex-direction: column; }
.action-hint { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.menu { position: fixed; z-index: 80; min-width: 220px; max-width: 320px; padding: 6px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2); opacity: 0; transform: translateY(-4px); transition: opacity .16s var(--ease), transform .2s var(--ease); }
.menu.open { opacity: 1; transform: none; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 11px; font-size: 15px; font-weight: 700; color: var(--ink); text-align: left; }
.menu-item .ico { color: var(--ink-2); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--sunk); outline: none; }

/* ---------- Aviso con Deshacer ---------- */
.toast { position: fixed; left: 50%; bottom: var(--toast-bottom); z-index: 90; display: flex; align-items: center; gap: 8px; width: max-content; max-width: min(calc(100vw - 24px), 520px); min-height: 50px; padding: 5px 6px 5px 18px; border-radius: 16px; background: var(--toast-bg); color: var(--toast-ink); font-weight: 700; font-size: 15px; line-height: 1.35; box-shadow: var(--shadow-2); opacity: 0; transform: translate(-50%, 16px) scale(.98); pointer-events: none; transition: opacity .2s var(--ease), transform .3s var(--spring); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { background: var(--toast-error); color: #FFF8F2; }
html[data-theme="noche"] .toast.error { color: #1C1A17; }
.toast:not(.has-action) { padding-right: 18px; }
.toast-text { padding: 8px 0; }
.toast-btn { flex: none; min-height: 44px; padding: 0 14px; border-radius: 12px; color: var(--toast-action); font-weight: 800; }
.toast-btn:hover { background: color-mix(in srgb, var(--toast-ink) 10%, transparent); }
.toast-btn[hidden] { display: none; }
html.sheet-open .toast { bottom: calc(var(--safe-b) + 86px); }

/* ---------- Recibos, propuestas, preguntas ---------- */
.receipt { padding: 12px 14px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); }
.receipt + .receipt { margin-top: 8px; }
.receipt-head { display: flex; align-items: flex-start; gap: 8px; }
.receipt-ico { color: var(--sage-strong); margin-top: 1px; }
.receipt.undone .receipt-ico { color: var(--ink-3); }
.receipt-title { font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.4; overflow-wrap: anywhere; }
.receipt.undone .receipt-title { color: var(--ink-2); text-decoration: line-through; }
.receipt-changes { margin: 8px 0 0 28px; display: flex; flex-direction: column; gap: 4px; }
.receipt-row { display: grid; grid-template-columns: minmax(84px, auto) 1fr; gap: 10px; font-size: 14px; }
.receipt-row dt { color: var(--ink-2); font-weight: 700; }
.receipt-row dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.receipt-before { color: var(--ink-2); font-weight: 600; text-decoration-color: color-mix(in srgb, var(--ink-2) 55%, transparent); }
.receipt-before.none { text-decoration: none; }
.receipt-arrow { color: var(--ink-3); }
.receipt-after { color: var(--ink); font-weight: 800; }
.receipt > .btn { margin: 6px 0 -4px 18px; }
.receipt-note { margin: 6px 0 0 28px; font-size: 13px; font-weight: 800; color: var(--ink-2); }
.proposal { padding: 14px; border-radius: 18px; background: var(--surface); border: 1.5px solid var(--sage-soft); }
.proposal-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; color: var(--sage-ink); margin-bottom: 10px; }
.proposal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.proposal-status { margin-top: 10px; font-size: 14px; font-weight: 800; color: var(--ink-2); }
.ask-q { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.ask-options { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-opt { min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--sage-soft); color: var(--sage-ink); font-weight: 800; font-size: 14px; }
.ask-opt:hover { box-shadow: inset 0 0 0 1.5px var(--sage); }

/* ---------- Estados: vacío, error, esqueleto ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px 16px 28px; }
.empty-art { width: 104px; height: 80px; margin-bottom: 12px; }
.empty-title { font-size: 17px; font-weight: 800; color: var(--sage-ink); }
.empty-text { margin-top: 4px; color: var(--ink-2); font-size: 15px; max-width: 340px; }
.empty-action { margin-top: 14px; }
.skel { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.skel-rows { gap: 0; }
.skel-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 0 8px 0 10px; }
.skel-box, .skel-dot, .skel-line { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--sunk) 0%, var(--line) 50%, var(--sunk) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel-box { width: 28px; height: 28px; border-radius: 8px; flex: none; }
.skel-dot { width: 24px; height: 24px; border-radius: 50%; flex: none; }
.skel-text { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skel-line { height: 12px; }
.skel-line.w40 { width: 40%; } .skel-line.w50 { width: 50%; } .skel-line.w60 { width: 60%; } .skel-line.w70 { width: 70%; } .skel-line.w80 { width: 80%; } .skel-line.w90 { width: 90%; }
.skel-card { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Anillos y barras ---------- */
.ring { position: relative; width: var(--ring-size); height: var(--ring-size); flex: none; }
.ring-svg { display: block; }
.ring-track { fill: none; stroke: var(--sunk); }
.ring-fill { fill: none; stroke: var(--sage-strong); stroke-linecap: round; transition: stroke-dashoffset 1.1s var(--ease); }
.ring.tone-peach .ring-fill { stroke: var(--peach-strong); }
.ring-center { position: absolute; inset: 0; display: grid; place-items: center; }
.bar { height: 10px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.bar.thin { height: 6px; }
.bar-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--sage-strong); transition: width 1s var(--ease); }
.bar.tone-peach .bar-fill { background: var(--peach-strong); }
.bar.tone-now .bar-fill { background: var(--now-dot); }

/* ---------- Texto largo (fichas, guía, píldoras) ---------- */
.prose { font-size: 15px; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
.prose p + p, .prose p + ul, .prose ul + p, .prose p + ol, .prose ol + p { margin-top: 10px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li + li { margin-top: 4px; }
.prose .md-h { margin-top: 14px; }
.md-host { color: var(--ink-2); font-size: .92em; font-weight: 600; overflow-wrap: anywhere; }


/* ---------- Ajustes ---------- */
.aj { display: flex; flex-direction: column; }
.aj-sec { padding: 18px 0 6px; border-top: 1px solid var(--line); }
.aj-sec:first-child { border-top: 0; padding-top: 4px; }
.aj-sec > h3 { font-size: 17px; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.aj-sec > .aj-hint { font-size: 14px; color: var(--ink-2); font-weight: 600; margin-bottom: 12px; }
.aj-person { display: grid; grid-template-columns: 52px 1fr; gap: 6px 12px; align-items: start; padding: 14px; margin-bottom: 12px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); }
.aj-person > .avatar { margin-top: 26px; }
.aj-person .field { margin-bottom: 10px; }
.aj-person .swatches { grid-column: 1 / -1; }
.aj-person-row { display: grid; grid-template-columns: 1fr 76px; gap: 10px; }
.aj-person-row .input { text-transform: none; }
.aj-cal { padding: 14px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); }
.aj-cal-url { display: block; margin: 8px 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--sunk); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; }
.aj-gcal { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.aj-steps { margin: 8px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.aj-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.aj-row .btn { flex: 1 1 auto; }
.aj-cal .aj-row + .field-hint { margin-top: 12px; }
.aj-cal .field-hint + .field-hint { margin-top: 4px; }
.aj-warn { display: flex; gap: 6px; align-items: flex-start; color: var(--now-ink); }
.aj-warn .ico { flex: none; margin-top: 2px; }
.aj-offline { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 8px; border-radius: 14px; background: var(--now-bg); color: var(--now-ink); font-size: 14px; font-weight: 700; }
.aj-pw { display: flex; gap: 12px; align-items: flex-start; padding: 14px; margin-bottom: 8px; border-radius: 14px; background: var(--sage-wash); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); }
.aj-pw > .ico { flex: none; margin-top: 2px; color: var(--sage-ink); }
.aj-pw h3 { font-size: 15px; font-weight: 800; color: var(--sage-ink); }
.aj-pw p { margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.aj-about { margin-top: 18px; padding-bottom: 6px; }

/* ---------- Pantalla provisional ---------- */
.provisional-note { margin-top: 8px; }

/* ---------- Tableta (760–1099 px): barra lateral estrecha, sin pestañas, asistente como hoja lateral ---------- */
@media (min-width: 760px) {
  :root { --gutter: 24px; --side-w: 96px; --bottom-clear: 32px; --toast-bottom: 24px; }
  .tabbar { display: none; }
  .tb-me, .tb-search, .tb-ask { display: none; }
  .tb-count { padding-left: 10px; }
  .main-col { margin-left: var(--side-w); }
  .side { display: flex; flex-direction: column; align-items: stretch; gap: 10px; position: fixed; z-index: 25; top: 0; left: 0; bottom: 0; width: var(--side-w); padding: calc(14px + var(--safe-t)) 8px 14px; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: thin; }
  .side-brand, .side-count, .side-name { display: none; }
  .side-me { justify-content: center; padding: 0; min-height: 52px; }
  .side-me-name { display: none; }
  .side-search, .side-ask { flex-direction: column; justify-content: center; gap: 2px; min-height: 60px; padding: 6px 4px; background: transparent; font-size: 13px; }
  .side-nav { gap: 4px; }
  .side-link { flex-direction: column; justify-content: center; gap: 2px; min-height: 62px; padding: 6px 4px; font-size: 13px; text-align: center; }
  .toast { left: calc(var(--side-w) + (100% - var(--side-w)) / 2); }
  .screen-title { font-size: 30px; }
}

/* ---------- Escritorio (≥1100 px): barra lateral completa y asistente fijo a la derecha ---------- */
@media (min-width: 1100px) {
  :root { --side-w: 240px; --panel-w: 380px; --bottom-clear: 56px; --toast-bottom: 28px; }
  .main-col { margin-right: var(--panel-w); }
  .side { gap: 14px; padding: calc(22px + var(--safe-t)) 14px 18px; }
  .side-brand, .side-name { display: block; }
  .side-ask { display: none; }
  .side-brand { display: flex; }
  .side-me { justify-content: flex-start; padding: 0 8px; min-height: 48px; }
  .side-me-name { display: inline; }
  .side-search, .side-ask { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 44px; padding: 0 12px; background: var(--sunk); font-size: 15px; }
  .side-link { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 46px; padding: 0 12px; font-size: 15px; text-align: left; }
  .apanel { display: flex; flex-direction: column; position: fixed; z-index: 24; top: 0; right: 0; bottom: 0; width: var(--panel-w); padding-top: var(--safe-t); background: var(--surface); border-left: 1px solid var(--line); }
  .toast { left: calc(var(--side-w) + (100% - var(--side-w) - var(--panel-w)) / 2); }
}

/* Panel provisional del asistente (lo sustituye views/asistente.js) */
.apanel-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 10px; }
.apanel-title { font-size: 20px; font-weight: 800; color: var(--ink); }
.apanel-ctx { margin: 0 20px; }
.apanel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 20px; display: flex; flex-direction: column; justify-content: center; }
.apanel-composer { display: flex; align-items: center; gap: 4px; margin: 12px 16px 16px; padding: 4px 4px 4px 14px; min-height: 52px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line-2); color: var(--ink-2); font-weight: 700; }
.apanel-composer span { flex: 1; }

/* Pantallas estrechas: el contador pasa a dos líneas para que no se corte */
/* Por debajo de 390 el contador sigue en una línea: menos hueco entre piezas, píldora SOS más ceñida y 15/13 px.
   Medido con las métricas de Nunito: «Semana 21+5 · 128 días» ocupa ~158 px y a 360 quedan ~172 px. */
@media (max-width: 429.98px) {
  /* Con «Preguntar» en la cabecera el contador no cabe en una línea en móvil: semana arriba, días debajo (el botón no se acorta). */
  .tb-count:not(.no-days) { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; line-height: 1.15; }
  .tb-count:not(.no-days) .tb-dot { display: none; }
  .tb-count:not(.no-days) .tb-days { font-size: 12px; }
}
@media (max-width: 389.98px) {
  .topbar-inner { gap: 2px; }
  .tb-count { gap: 4px; padding: 0 4px; }
  .tb-week { font-size: 14px; }
  .tb-count.no-days .tb-week { font-size: 14px; }
  .tb-days { font-size: 12px; }
  /* Con «Preguntar» en la cabecera el contador no cabe en una línea a 360: semana arriba, días debajo (el botón no se acorta). */
  .tb-count:not(.no-days) { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; line-height: 1.15; }
  .tb-dot { display: none; }
  .tb-ask { padding: 0 10px 0 8px; font-size: 13px; gap: 4px; }
}
@media (max-width: 380px) {
  :root { --gutter: 14px; }
  .who-grid { gap: 10px; }
  .screen-title { font-size: 26px; }
}

/* Modo parto y pantallas a pantalla completa: sin barras */
html[data-bare] .topbar, html[data-bare] .tabbar, html[data-bare] .side, html[data-bare] .apanel { display: none !important; }
html[data-bare] .main-col { margin: 0; padding-bottom: calc(24px + var(--safe-b)); }
html[data-bare] .offline-band { top: 0; }

/* Imprimir (plan de parto): solo el contenido */
@media print {
  .topbar, .tabbar, .side, .apanel, .offline-band, .toast, .skip { display: none !important; }
  .main-col { margin: 0 !important; padding: 0 !important; }
  body { background: #fff; }
}

/* Sin movimiento: solo fundidos */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .illus.draw path { stroke-dashoffset: 0; animation: none; }
  .sheet-layer .sheet, .sheet-layer .sheet-backdrop { transition: opacity .2s linear !important; }
  .sheet-layer[data-mode] .sheet { transform: none !important; opacity: 0; }
  .sheet-layer.open .sheet { opacity: 1; }
  .skel-box, .skel-dot, .skel-line { animation: none; }
}

/* ---------- Visor 3D del bebé (bebe3d) ---------- */
.bebe3d { position: relative; border-radius: var(--radius); overflow: hidden; background: linear-gradient(165deg, #FBF0E1 0%, #EEF3E9 100%); border: 1px solid var(--line); }
.bebe3d-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.bebe3d-canvas:active { cursor: grabbing; }
.bebe3d-fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.bebe3d-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 28px 12px 10px; align-items: flex-end; background: linear-gradient(transparent, rgba(34, 44, 39, .72) 55%); color: #fff; }
.bebe3d-nota { font-size: 13px; font-weight: 800; line-height: 1.2; text-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.bebe3d-actions { display: flex; gap: 4px; flex: none; }
.bebe3d-nota strong, .bebe3d-nota small { display: block; }
.bebe3d-nota small { margin-top: 2px; font-size: 11.5px; font-weight: 700; opacity: .95; }
.bebe3d-play { white-space: nowrap; position: absolute; left: 50%; top: 36%; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .94); color: var(--ink); font: inherit; font-size: 14px; font-weight: 800; box-shadow: var(--shadow-1); cursor: pointer; }
.bebe3d-act { background: rgba(255, 255, 255, .92); color: var(--ink); border-radius: 10px; box-shadow: var(--shadow-1); }
.bebe3d-act:hover { background: #fff; }
.bebe3d-ruler { position: absolute; left: 12px; right: 12px; bottom: 52px; padding: 8px 10px 10px; border-radius: 10px; background: rgba(255, 255, 255, .95); color: var(--ink); box-shadow: var(--shadow-1); }
.bebe3d-ruler-label { display: block; font-size: 11px; font-weight: 800; color: var(--ink-2); margin-bottom: 5px; }
.bebe3d-ruler-bar { height: 12px; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); background: linear-gradient(180deg, transparent 55%, var(--ink) 55%, var(--ink) 60%, transparent 60%); background-size: 100% 100%; }
.bebe3d-calib { position: fixed; left: 8px; right: 8px; top: 96px; z-index: 120; max-width: 520px; margin: 0 auto; border-radius: 14px; padding: 12px; background: rgba(255, 255, 255, .97); box-shadow: var(--shadow-2); color: var(--ink); }
.bebe3d-calib-hint { font-size: 13px; font-weight: 700; line-height: 1.45; color: var(--ink-2); margin-bottom: 10px; }
.bebe3d-calib-rect { overflow-x: auto; padding: 4px 0 24px; }
.bebe3d-card { height: 24px; margin: 0 auto; background: var(--peach-wash); border: 2px solid var(--peach-strong); border-radius: 4px; position: relative; }
.bebe3d-card-mark { position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; font-size: 10px; font-weight: 800; color: var(--peach-ink); text-align: center; }
.bebe3d-calib-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* Ajuste de tamaño en «{bebe} esta semana» */
.sem-hero-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.sem-eco-nota { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--sage-ink); }
.sem-hero .bebe3d { margin-bottom: 12px; }

/* ---------- Ecografías (#ecos) ---------- */
.ec { display: flex; flex-direction: column; gap: 14px; }
.ec-graph .card-title { margin-bottom: 4px; }
.ec-chart-wrap { margin-top: 4px; }
.ec-chart { display: block; width: 100%; height: auto; }
.ec-ref { stroke: var(--sage-ink); stroke-width: 2; fill: none; }
.ec-grid { stroke: var(--line); stroke-width: 1; }
.ec-axis { stroke: var(--line-2); stroke-width: 1.5; }
.ec-tick { fill: var(--ink-2); font-size: 10px; font-weight: 700; }
.ec-pt circle { fill: var(--peach-strong); stroke: var(--surface); stroke-width: 1.5; }
.ec-legend { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.ec-cita-note { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; padding: 8px 10px; border-radius: 10px; background: var(--sage-wash); color: var(--sage-ink); font-size: 13px; font-weight: 700; }
.ec-form { display: flex; flex-direction: column; gap: 10px; }
.ec-bios { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.ec-bio { display: flex; flex-direction: column; gap: 4px; }
.ec-bios-fold { margin-top: 2px; }
.ec-submit { align-self: flex-end; margin-top: 2px; }
.ec-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ec-row { display: flex; align-items: flex-start; gap: 8px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.ec-row-main { flex: 1; min-width: 0; }
.ec-row-title { font-size: 15px; font-weight: 800; color: var(--ink); }
.ec-row-ga { font-size: 13px; font-weight: 700; color: var(--sage-ink); margin-top: 2px; }
.ec-row-medidas { font-size: 14px; font-weight: 800; color: var(--ink); margin-top: 4px; }
.ec-row-bios { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-top: 2px; }
.ec-row-warn { display: flex; align-items: flex-start; gap: 5px; margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--peach-ink); }
.ec-row-del { flex: none; color: var(--ink-3); }
.ec-row-del:hover { color: var(--sos); background: var(--sos-bg); }
.ec-empty .empty { padding-top: 6px; }
/* Informe de la eco: adjuntar (formulario), lo que lee la IA y los informes del historial */
.ec-adj-wrap { display: flex; flex-direction: column; gap: 6px; }
.ec-adj { display: flex; flex-direction: column; gap: 8px; }
.ec-adj-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.ec-adj-file { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.ec-adj-thumb, .ec-inf-thumb { flex: none; width: 48px; height: 48px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--sage-wash); color: var(--sage-ink); }
.ec-adj-thumb img, .ec-inf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ec-adj-text, .ec-inf-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ec-adj-name, .ec-inf-name { font-size: 14px; font-weight: 800; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-adj-meta, .ec-inf-meta { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.ec-adj-state { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--sage-ink); }
.ec-adj-error p { display: flex; align-items: flex-start; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--peach-ink); }
.ec-prop { padding: 12px; border-radius: var(--radius-sm); background: var(--sage-wash); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.ec-prop.applied { background: var(--surface); }
.ec-prop-t { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; color: var(--sage-ink); }
.ec-prop-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px 12px; }
.ec-prop-list li { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.ec-prop-k { font-weight: 700; color: var(--ink-2); }
.ec-prop-v { font-weight: 800; color: var(--ink); }
.ec-prop-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ec-inf-wrap { margin-top: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.ec-inf-list { list-style: none; display: flex; flex-direction: column; gap: 6px; width: 100%; }
.ec-inf { display: flex; align-items: center; gap: 6px; }
.ec-inf-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; border-radius: 10px; }
.ec-inf-del { flex: none; color: var(--ink-3); }
.ec-inf-del:hover { color: var(--sos); background: var(--sos-bg); }
html[data-theme="noche"] .bebe3d { border-color: var(--line); }
html[data-theme="noche"] .bebe3d-ruler, html[data-theme="noche"] .bebe3d-calib, html[data-theme="noche"] .bebe3d-act { background: rgba(44, 44, 44, .96); color: var(--ink); }

/* Aviso de instalación (shared/instalar.js) */
.inst { text-align: left; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.inst p + *, .inst .inst-pasos { margin-top: 8px; }
.inst-pasos { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.inst-acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.inst-acceso { width: 100%; margin: 0 0 14px; padding: 12px; border-radius: var(--radius); background: var(--sage-wash); border: 1px solid var(--line); }
.inst-linea { margin: 0; }
.inst-hoy-cerrar { margin-top: 6px; }
