/* Dirección A · "Línea del día". Beige, crema y blanco cálido; texto carbón; líneas finas. */
:root {
  --bg: #F4EEE3; --surface: #FBF8F2; --raised: #FFFDF8; --ink: #2E2C29; --muted: #6F695F; --faint: #A39B8E;
  --line: #E2D9CA; --line-strong: #CFC4B1; --now: #EADDC6; --now-ink: #574430; --warn: #85561C; --warn-bg: #F6E7CC;
  --ok: #3F3A33; --danger: #8E3B2E; --focus: #2E2C29; --shadow: 0 10px 30px -12px rgba(60, 45, 25, .35);
  --r: 8px; --r-sm: 6px; --pad: 20px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1E1B18; --surface: #26221E; --raised: #2C2823; --ink: #EDE6DA; --muted: #ABA295; --faint: #7D7469;
  --line: #3A332D; --line-strong: #4D453C; --now: #3A3128; --now-ink: #E8D6B8; --warn: #E2B579; --warn-bg: #3B2F20;
  --ok: #EDE6DA; --danger: #E79A8B; --focus: #EDE6DA; --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1E1B18; --surface: #26221E; --raised: #2C2823; --ink: #EDE6DA; --muted: #ABA295; --faint: #7D7469;
    --line: #3A332D; --line-strong: #4D453C; --now: #3A3128; --now-ink: #E8D6B8; --warn: #E2B579; --warn-bg: #3B2F20;
    --ok: #EDE6DA; --danger: #E79A8B; --focus: #EDE6DA; --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
@font-face { font-family: "Instrument Sans"; src: url("/fonts/InstrumentSans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden; min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.xs { font-size: 13px; }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Estructura ---------- */
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; }
.page { padding: 0 0 calc(96px + env(safe-area-inset-bottom)); }
body.kb .page { padding-bottom: 24px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) var(--pad) 0; min-height: 56px; }
.top .ctx { font-size: 14px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .left { display: flex; align-items: center; gap: 2px; min-width: 0; }
.ask { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px 0 11px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 500; flex: none; }
.iconbtn { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; background: none; cursor: pointer; border-radius: 22px; flex: none; }
.iconbtn:hover { background: var(--surface); }
h1.title { font-weight: 500; font-size: 28px; line-height: 1.15; letter-spacing: -.015em; margin: 6px var(--pad) 0; }
.lead { margin: 6px var(--pad) 0; color: var(--muted); font-size: 15px; }
section.sec { padding: 0 var(--pad); margin-top: 30px; }
.sec-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 36px; margin-bottom: 2px; }
.sec-h h2 { font-size: 15px; font-weight: 600; margin: 0; }
.sec-h .link, .linkbtn { font-size: 14px; color: var(--muted); background: none; border: 0; cursor: pointer; min-height: 44px; padding: 0 2px; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.linkbtn.ink { color: var(--ink); font-weight: 500; }
.note { font-size: 14px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.banner { margin: 10px var(--pad) 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--warn-bg); color: var(--ink); font-size: 14px; display: flex; gap: 8px; align-items: flex-start; }
.banner svg { color: var(--warn); margin-top: 1px; }
.banner.neutral { background: var(--surface); border: 1px solid var(--line); }

/* ---------- Barra inferior ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs nav { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tabs a { min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--muted); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabs a[aria-current="page"] svg { stroke-width: 2; }
body.kb .tabs { display: none; }

/* ---------- Ahora ---------- */
.nowline { margin: 22px var(--pad) 0; padding: 14px 16px; background: var(--now); color: var(--now-ink); border-radius: var(--r-sm); }
.nowline .lbl { font-size: 13px; }
.nowline .what { font-size: 21px; font-weight: 500; margin-top: 2px; color: var(--ink); }
.nowline .bar { height: 3px; background: color-mix(in srgb, var(--now-ink) 22%, transparent); margin-top: 12px; border-radius: 2px; }
.nowline .bar i { display: block; height: 100%; background: var(--now-ink); border-radius: 2px; }
.nowline .meta { display: flex; justify-content: space-between; font-size: 13px; margin-top: 6px; gap: 8px; }
.nowline .acts { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.nowline .acts .btn { padding: 0 12px; }
.nowline .btn { background: var(--raised); border-color: transparent; }
.nowline .btn.primary { background: var(--ink); color: var(--bg); }

/* ---------- Listas ---------- */
.tl { list-style: none; margin: 0; padding: 0; }
.tl > li { display: grid; grid-template-columns: 52px 1fr auto; gap: 0 12px; align-items: center; min-height: 54px; border-top: 1px solid var(--line); }
.tl > li:first-child { border-top: 0; }
.tl time, .tl .when { font-size: 15px; color: var(--muted); }
.tl .body { min-width: 0; padding: 8px 0; text-align: left; background: none; border: 0; cursor: pointer; display: block; width: 100%; }
.tl .t { font-size: 16px; overflow-wrap: anywhere; }
.tl .s { font-size: 13px; color: var(--muted); margin-top: 1px; }
.tl li.done .t, .tl li.skipped .t { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.tl li.done time, .tl li.skipped time { color: var(--faint); }
.tl li.cur time, .tl li.cur .t { font-weight: 600; }
.tl .flag { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--warn); margin-top: 2px; }
.chk { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; margin-right: -10px; }
.chk span { width: 22px; height: 22px; border-radius: 50%; border: 1.6px solid var(--faint); display: grid; place-items: center; }
.chk[aria-pressed="true"] span { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chk svg { width: 14px; height: 14px; stroke-width: 2.4; }
.chk.skip span { border-style: dashed; }
.rows { margin: 0; padding: 0; list-style: none; }
.rows > li { display: flex; gap: 12px; align-items: center; min-height: 52px; padding: 6px 0; border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
.rows .k { width: 78px; flex: none; font-size: 14px; color: var(--muted); }
.rows .v { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rows .v small { display: block; font-size: 13px; color: var(--muted); }
.rows .amt { text-align: right; flex: none; }
.rows .amt small { display: block; font-size: 13px; color: var(--muted); }
.rows button.rowbtn { all: unset; display: flex; gap: 12px; align-items: center; flex: 1; min-height: 44px; cursor: pointer; min-width: 0; }
.rows button.rowbtn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.addrow { display: flex; align-items: center; gap: 8px; min-height: 48px; color: var(--muted); background: none; border: 0; border-top: 1px solid var(--line); width: 100%; cursor: pointer; padding: 0; font-size: 15px; }
.empty { padding: 14px 0 4px; color: var(--muted); font-size: 15px; }
.empty p { margin: 0 0 10px; }

/* ---------- Píldoras y botones ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 10px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); cursor: pointer; font-size: 15px; }
.pill .dot { width: 20px; height: 20px; border-radius: 50%; border: 1.6px solid var(--faint); display: grid; place-items: center; }
.pill[aria-pressed="true"] .dot { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.pill .dot svg { width: 12px; height: 12px; stroke-width: 2.6; }
.pill small { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 12px; line-height: 18px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--muted); vertical-align: 1px; white-space: nowrap; }
.badge.dashed { border-style: dashed; }
.badge.warn { border-color: transparent; background: var(--warn-bg); color: var(--warn); }
.btn { min-height: 44px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 500; }
.btn.ghost { background: none; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btnrow.end { justify-content: flex-end; }

/* ---------- Pestañas internas ---------- */
.seg { display: flex; margin: 14px var(--pad) 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg a, .seg button { flex: none; border: 0; background: none; min-height: 44px; padding: 0 9px; font-size: 15px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; display: inline-flex; align-items: center; }
.seg [aria-selected="true"], .seg [aria-current="page"] { color: var(--ink); border-color: var(--ink); font-weight: 600; }
.seg :first-child { padding-left: 0; }

/* ---------- Números ---------- */
.big { margin: 22px var(--pad) 0; }
.big .n { font-size: 34px; font-weight: 500; letter-spacing: -.02em; line-height: 1.1; }
.big p { margin: 6px 0 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.split { display: grid; grid-template-columns: 1fr 1fr; margin: 18px var(--pad) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.split > div { padding: 12px 0; min-width: 0; }
.split > div + div { border-left: 1px solid var(--line); padding-left: 14px; }
.split small { display: block; font-size: 13px; color: var(--muted); }
.split b { font-weight: 500; font-size: 18px; }
.calc { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.calc li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.calc li:first-child { border-top: 0; }
.calc li.total { font-weight: 600; border-top: 1px solid var(--line-strong); }
.calc li span:first-child { color: var(--muted); }
.calc li.total span:first-child { color: var(--ink); }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 6px 4px 6px 0; border-bottom: 1px solid var(--line); }
table.grid td { padding: 9px 4px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid td.r, table.grid th.r { text-align: right; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.dots span { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.dots span.on { background: var(--ink); border-color: var(--ink); }
.dots span.off { border-style: dotted; opacity: .5; }

/* ---------- Hoja inferior ---------- */
.scrim { position: fixed; inset: 0; background: rgba(32, 26, 20, .32); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92dvh; border-radius: 14px 14px 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: up .18s ease-out; }
.sheet.full { height: 100dvh; max-height: 100dvh; border-radius: 0; }
.sheet > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px var(--pad); border-bottom: 1px solid var(--line); flex: none; }
.sheet > header h2 { font-size: 17px; font-weight: 600; margin: 0; }
.sheet > header small { display: block; font-size: 12px; color: var(--muted); }
.sheet .content { overflow-y: auto; padding: 16px var(--pad) 20px; flex: 1; overscroll-behavior: contain; }
.sheet > footer { padding: 10px var(--pad) calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; flex: none; }
.sheet > footer .btn { flex: 1; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Formularios ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span, .fieldset > legend { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; padding: 0; }
.field > small, .fieldset > small { display: block; font-size: 13px; color: var(--muted); margin-top: 5px; }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--raised); font-size: 16px; }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.4; }
textarea.code { font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; min-height: 160px; }
.input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 1px var(--ink); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice { min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 22px; border: 1px solid var(--line-strong); background: var(--raised); cursor: pointer; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.choice[aria-pressed="true"], .choice[aria-checked="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-top: 1px solid var(--line); cursor: pointer; }
.switch:first-of-type { border-top: 0; }
.switch span small { display: block; font-size: 13px; color: var(--muted); }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--line-strong); position: relative; flex: none; cursor: pointer; margin: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--raised); transition: transform .15s; }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(18px); background: var(--bg); }
details.more { border-top: 1px solid var(--line); margin-top: 6px; }
details.more > summary { min-height: 48px; display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-size: 15px; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary svg { transform: rotate(90deg); }
.err { color: var(--danger); font-size: 14px; margin: 0 0 12px; }
.callout { border-left: 2px solid var(--ink); padding: 2px 0 2px 12px; margin: 0 0 16px; font-size: 14px; }
.callout.warn { border-color: var(--warn); }

/* ---------- Avisos de la app ---------- */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 60; max-width: 520px; margin: 0 auto; background: var(--ink); color: var(--bg); padding: 4px 6px 4px 14px; border-radius: var(--r); font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 48px; box-shadow: var(--shadow); }
.toast button { background: none; border: 0; color: inherit; text-decoration: underline; min-height: 44px; padding: 0 8px; cursor: pointer; font-weight: 500; }

/* ---------- Asistente ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; font-size: 15px; line-height: 1.5; }
.msg-me { align-self: flex-end; background: var(--ink); color: var(--bg); padding: 9px 13px; border-radius: 14px 14px 4px 14px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-bot { max-width: 94%; white-space: pre-wrap; overflow-wrap: anywhere; }
.proposal { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 14px; margin-top: 8px; white-space: normal; }
.proposal ul { list-style: none; margin: 6px 0 10px; padding: 0; font-size: 14px; }
.proposal li { padding: 4px 0; border-top: 1px solid var(--line); }
.proposal li:first-child { border-top: 0; }
.proposal li b { font-weight: 600; display: block; }
.compose { display: flex; gap: 8px; align-items: flex-end; }
.compose textarea { flex: 1; min-height: 46px; max-height: 140px; resize: none; border-radius: 22px; padding: 11px 16px; }
.send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; cursor: pointer; flex: none; }
.send:disabled { opacity: .45; }
.suggest { display: flex; flex-direction: column; gap: 6px; }
.suggest button { text-align: left; min-height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 8px 12px; cursor: pointer; font-size: 15px; }

/* ---------- Entrada ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: calc(48px + env(safe-area-inset-top)) var(--pad) 40px; }
.auth h1 { font-size: 30px; font-weight: 500; letter-spacing: -.015em; margin: 0 0 6px; }
.auth .lead { margin: 0 0 26px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.menu { list-style: none; margin: 0; padding: 0; }
.menu a, .menu button { display: flex; align-items: center; gap: 12px; min-height: 56px; border-top: 1px solid var(--line); text-decoration: none; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; padding: 0; cursor: pointer; text-align: left; font-size: 16px; }
.menu li:first-child a, .menu li:first-child button { border-top: 0; }
.menu .grow { flex: 1; min-width: 0; }
.menu small { display: block; color: var(--muted); font-size: 13px; }
.steps { display: flex; gap: 4px; margin: 14px var(--pad) 0; }
.steps span { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.steps span.on { background: var(--ink); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); margin: 12px 14px 0; }
.week button { border: 0; background: none; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; border-radius: var(--r); color: var(--muted); font-size: 12px; }
.week button b { font-size: 16px; font-weight: 600; color: var(--ink); }
.week button[aria-current="date"] { background: var(--ink); color: var(--bg); }
.week button[aria-current="date"] b { color: var(--bg); }
.week button.today b { text-decoration: underline; text-underline-offset: 3px; }
.daynav { display: flex; align-items: center; justify-content: space-between; margin: 10px calc(var(--pad) - 10px) 0; }
.daynav b { font-weight: 600; font-size: 16px; }

/* ---------- Mensajes de acompañamiento: texto secundario, sin caja ni comillas ---------- */
.phrase { padding: 2px 0 10px; }
.phrase-text { all: unset; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1.45; display: block; min-height: 24px; }
.phrase-text:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.phrase-acts { display: flex; gap: 14px; flex-wrap: wrap; }
.tl > li.phrase-li { display: grid; grid-template-columns: 52px 1fr; gap: 0 12px; border-top: 0; min-height: 0; }
.phrase-block { padding: 0 var(--pad); margin-top: 14px; }
