/* Plazo — tokens
   Papel #F5F7F4 · Tinta #14261F · Palmeral #1F6F54 · Dátil #B86E12 · Granada #B5362E · Niebla #DCE3DE
   Titulares y cifras en SF Rounded (ui-rounded); texto en la fuente del sistema. */
:root {
  --paper: #F5F7F4; --surface: #FFFFFF; --ink: #14261F; --ink-2: #4C5F57; --ink-3: #7C8C85;
  --line: #DCE3DE; --palm: #1F6F54; --palm-soft: #E2EFE9; --on-palm: #FFFFFF;
  --date: #B86E12; --date-soft: #F8ECD9; --garnet: #B5362E; --garnet-soft: #F9E4E1;
  --c0: #1F6F54; --c1: #2E62C9; --c2: #B86E12; --c3: #8A48B8; --c4: #C2416B;
  --c5: #0E7C8C; --c6: #6B7A12; --c7: #C4502B; --c8: #4F5BC4; --c9: #5E6E66;
  --round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --tab-h: 58px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #0E1714; --surface: #17231F; --ink: #E8EFEB; --ink-2: #A9B8B1; --ink-3: #7B8A83;
  --line: #26352F; --palm: #5CC29D; --palm-soft: #1B3A30; --on-palm: #07231A;
  --date: #E9A94B; --date-soft: #3A2C14; --garnet: #F0847B; --garnet-soft: #3D1D1A;
  --c0: #5CC29D; --c1: #7FA6F5; --c2: #E9A94B; --c3: #C08BE6; --c4: #F083A8;
  --c5: #55C3D3; --c6: #B5C651; --c7: #F08C68; --c8: #98A1F5; --c9: #A9B8B1;
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --paper: #0E1714; --surface: #17231F; --ink: #E8EFEB; --ink-2: #A9B8B1; --ink-3: #7B8A83;
  --line: #26352F; --palm: #5CC29D; --palm-soft: #1B3A30; --on-palm: #07231A;
  --date: #E9A94B; --date-soft: #3A2C14; --garnet: #F0847B; --garnet-soft: #3D1D1A;
  --c0: #5CC29D; --c1: #7FA6F5; --c2: #E9A94B; --c3: #C08BE6; --c4: #F083A8;
  --c5: #55C3D3; --c6: #B5C651; --c7: #F08C68; --c8: #98A1F5; --c9: #A9B8B1;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.4 var(--text); min-height: 100dvh; overscroll-behavior-y: none; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
a { color: var(--palm); }
:focus-visible { outline: 3px solid var(--palm); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }
.noscript { padding: 24px; }

.c0 { --c: var(--c0); } .c1 { --c: var(--c1); } .c2 { --c: var(--c2); } .c3 { --c: var(--c3); } .c4 { --c: var(--c4); }
.c5 { --c: var(--c5); } .c6 { --c: var(--c6); } .c7 { --c: var(--c7); } .c8 { --c: var(--c8); } .c9 { --c: var(--c9); }

/* ── estructura ── */
.screen { max-width: 620px; margin: 0 auto; padding: calc(var(--safe-t) + 14px) 18px calc(var(--tab-h) + var(--safe-b) + 28px); }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.top > div:first-child { flex: 1; min-width: 0; }
.top h1 { font: 800 32px/1.05 var(--round); letter-spacing: -0.01em; }
.top .sub { color: var(--ink-2); font-size: 15px; margin-top: 4px; }
.me { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--palm-soft); color: var(--palm); font: 700 14px/38px var(--round); text-align: center; }
.icon-btn { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn svg, .tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; background: color-mix(in srgb, var(--paper) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs-in { display: flex; width: 100%; max-width: 620px; }
.tab { flex: 1; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-3); font-size: 11px; font-weight: 600; position: relative; }
.tab[aria-current="page"] { color: var(--palm); }
.tab .badge { position: absolute; top: 7px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--garnet); color: #fff; font: 700 11px/17px var(--round); text-align: center; }

.section-title { font: 700 13px/1 var(--text); color: var(--ink-2); margin: 26px 2px 8px; display: flex; justify-content: space-between; align-items: baseline; }
.section-title button { color: var(--palm); font-weight: 600; font-size: 13px; padding: 4px 0; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.empty { padding: 26px 18px; color: var(--ink-2); text-align: center; font-size: 15px; }
.banner { display: flex; gap: 12px; align-items: center; background: var(--garnet-soft); color: var(--ink); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.banner.info { background: var(--date-soft); }
.banner button { margin-left: auto; flex: none; font-weight: 700; color: var(--garnet); padding: 6px 4px; }
.banner.info button { color: var(--date); }

/* ── lo siguiente ── */
.next { display: block; width: 100%; background: var(--palm); color: var(--on-palm); border-radius: 22px; padding: 20px 20px 18px; position: relative; overflow: hidden; }
.next.late { background: var(--garnet); color: #fff; }
.next .lab { font-size: 13px; font-weight: 600; opacity: 0.85; }
.next .count { font: 800 54px/1 var(--round); letter-spacing: -0.02em; margin: 6px 0 10px; font-variant-numeric: tabular-nums; }
.next .count small { font: 700 22px/1 var(--round); margin-left: 6px; letter-spacing: 0; }
.next .what { font: 700 18px/1.25 var(--round); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.next .meta { font-size: 14px; opacity: 0.9; margin-top: 4px; }
.next::after { content: ""; position: absolute; right: -46px; top: -46px; width: 150px; height: 150px; border-radius: 50%; border: 22px solid currentColor; opacity: 0.09; }
.calm { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 22px 20px; }
.calm b { font: 800 24px/1.15 var(--round); display: block; margin-bottom: 4px; }
.calm span { color: var(--ink-2); font-size: 15px; }

/* ── carga de 14 días ── */
.load { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 8px 8px; }
.load button { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0 0 4px; border-radius: 9px; }
.load .bar { width: 100%; height: 44px; display: flex; flex-direction: column-reverse; align-items: center; gap: 3px; }
.load .bar i { display: block; width: 9px; height: 9px; border-radius: 3px; background: var(--c, var(--palm)); }
.load .bar i.done { background: transparent; box-shadow: inset 0 0 0 1.6px var(--c, var(--palm)); opacity: 0.55; }
.load .bar i.exam { background: var(--garnet); border-radius: 50%; }
.load .bar em { font: 700 10px/1 var(--round); color: var(--ink-3); font-style: normal; }
.load .wd { font-size: 10px; font-weight: 600; color: var(--ink-3); }
.load .dn { font: 700 13px/1 var(--round); font-variant-numeric: tabular-nums; }
.load .today .dn { background: var(--ink); color: var(--paper); border-radius: 7px; padding: 3px 4px; margin: -3px 0; }
.load .wknd .wd, .load .wknd .dn { color: var(--ink-3); }

/* ── filas ── */
.row { display: flex; gap: 12px; align-items: center; width: 100%; padding: 11px 14px 11px 12px; border-top: 1px solid var(--line); min-height: 62px; }
.row:first-child { border-top: 0; }
.row .when { flex: none; width: 44px; text-align: center; }
.row .when .wd { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: lowercase; }
.row .when .dn { font: 800 22px/1 var(--round); font-variant-numeric: tabular-nums; }
.row .when .mo { font-size: 10px; font-weight: 600; color: var(--ink-3); }
.row .body { flex: 1; min-width: 0; border-left: 3px solid var(--c, var(--line)); padding-left: 11px; }
.row .t { font-weight: 600; font-size: 15.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .s { color: var(--ink-2); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { flex: none; text-align: right; }
.row.done .t { color: var(--ink-2); }
.row.done .when .dn { color: var(--ink-3); }
.chip { display: inline-block; font: 700 12px/1 var(--round); padding: 5px 8px; border-radius: 8px; background: var(--palm-soft); color: var(--palm); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.soon { background: var(--date-soft); color: var(--date); }
.chip.late, .chip.exam { background: var(--garnet-soft); color: var(--garnet); }
.chip.muted { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line); }
.row .glyph { flex: none; width: 44px; height: 36px; display: grid; place-items: center; color: var(--ink-2); }
.row .glyph svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--garnet); flex: none; }
.row .tm { font: 700 13px/1 var(--round); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ── controles ── */
.seg { display: flex; background: var(--line); border-radius: 11px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; text-align: center; padding: 8px 6px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(20, 38, 31, 0.12); }
.search { width: 100%; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; font-size: 16px; }
.search::placeholder { color: var(--ink-3); }
.btn { display: block; width: 100%; text-align: center; background: var(--palm); color: var(--on-palm); font-weight: 700; border-radius: 14px; padding: 14px 16px; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--palm); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: transparent; color: var(--garnet); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn[disabled] { opacity: 0.55; }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 12px; font-size: 16px; }
.field button { flex: none; padding: 0 14px; border-radius: 12px; font-weight: 700; color: var(--palm); box-shadow: inset 0 0 0 1.5px var(--line); }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--line); width: 100%; }
.switch-row:first-child { border-top: 0; }
.switch-row .lbl { flex: 1; min-width: 0; }
.switch-row .lbl small { display: block; color: var(--ink-2); font-size: 13px; margin-top: 1px; }
.switch { flex: none; width: 48px; height: 29px; border-radius: 15px; background: var(--line); position: relative; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 23px; height: 23px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
[aria-checked="true"] .switch { background: var(--palm); }
[aria-checked="true"] .switch::after { transform: translateX(19px); }
.link-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-top: 1px solid var(--line); width: 100%; color: var(--ink); text-decoration: none; }
.link-row:first-child { border-top: 0; }
.link-row span:last-child { color: var(--ink-3); font-size: 14px; flex: none; }
.link-row.red { color: var(--garnet); }
.note { color: var(--ink-2); font-size: 13.5px; line-height: 1.45; margin: 8px 4px 0; }

/* ── calendario ── */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h2 { font: 800 22px/1 var(--round); text-transform: capitalize; }
.cal-head div { display: flex; gap: 2px; align-items: center; }
.cal-head .today-btn { font-weight: 700; color: var(--palm); font-size: 14px; padding: 8px 10px; }
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 6px 6px; }
.cal .dow, .cal .days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal .dow span { text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-3); padding-bottom: 6px; }
.cal .days button { height: 52px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 6px; border-radius: 11px; }
.cal .days .n { font: 600 15px/22px var(--round); width: 26px; height: 22px; text-align: center; border-radius: 8px; font-variant-numeric: tabular-nums; }
.cal .days .out .n { color: var(--ink-3); opacity: 0.55; }
.cal .days .today .n { background: var(--ink); color: var(--paper); }
.cal .days [aria-pressed="true"] { background: var(--palm-soft); }
.cal .marks { display: flex; gap: 3px; height: 8px; align-items: center; }
.cal .marks i { width: 7px; height: 7px; border-radius: 2.5px; background: var(--c, var(--palm)); }
.cal .marks i.done { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c, var(--palm)); opacity: 0.6; }
.cal .marks i.exam { background: var(--garnet); border-radius: 50%; }
.cal .marks em { font: 700 9px/1 var(--round); color: var(--ink-3); font-style: normal; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-2); font-size: 12.5px; margin: 10px 4px 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 2.5px; background: var(--palm); display: inline-block; }
.legend i.done { background: transparent; box-shadow: inset 0 0 0 1.5px var(--palm); }
.legend i.exam { background: var(--garnet); border-radius: 50%; }

/* ── hoja inferior ── */
.sheet-back { position: fixed; inset: 0; z-index: 20; background: rgba(8, 16, 13, 0.45); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.16s ease-out; }
.sheet { width: 100%; max-width: 620px; max-height: 92dvh; overflow: auto; background: var(--paper); border-radius: 22px 22px 0 0; padding: 10px 18px calc(var(--safe-b) + 22px); animation: rise 0.2s ease-out; overscroll-behavior: contain; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet h2 { font: 800 22px/1.2 var(--round); }
.sheet .kicker { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.sheet .kicker.dot::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--c, transparent); margin-right: 7px; }
.sheet .facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 14px 0; font-size: 15px; }
.sheet .facts dt { color: var(--ink-2); }
.sheet .facts dd { margin: 0; font-weight: 600; }
.sheet .facts s { color: var(--ink-3); font-weight: 400; }
.rich { font-size: 15.5px; line-height: 1.55; overflow-wrap: anywhere; max-width: 68ch; }
.rich p, .rich ul, .rich ol, .rich blockquote, .rich table { margin: 0 0 0.8em; }
.rich h4 { font: 700 16px/1.3 var(--round); margin: 1em 0 0.4em; }
.rich table { border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.rich td, .rich th { border: 1px solid var(--line); padding: 4px 8px; }
.sheet .actions { display: grid; gap: 10px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0.6; } }

/* ── bienvenida ── */
.welcome { max-width: 520px; margin: 0 auto; padding: calc(var(--safe-t) + 34px) 22px calc(var(--safe-b) + 30px); }
.welcome .mark { width: 60px; height: 60px; border-radius: 16px; }
.welcome h1 { font: 800 34px/1.08 var(--round); letter-spacing: -0.01em; margin: 20px 0 10px; }
.welcome .lead { color: var(--ink-2); font-size: 17px; line-height: 1.45; margin-bottom: 26px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: paso; }
.steps li { counter-increment: paso; position: relative; padding: 0 0 22px 44px; }
.steps li::before { content: counter(paso); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--palm-soft); color: var(--palm); font: 800 15px/30px var(--round); text-align: center; }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 14px; top: 34px; bottom: 4px; width: 2px; background: var(--line); }
.steps h2 { font: 700 17px/30px var(--round); }
.steps p { color: var(--ink-2); font-size: 15px; margin: 2px 0 12px; }
.steps q { quotes: "«" "»"; font-weight: 600; color: var(--ink); }
.welcome .foot { color: var(--ink-3); font-size: 13px; line-height: 1.5; margin-top: 8px; }
.welcome .foot button { color: var(--palm); font-weight: 600; }
.error { color: var(--garnet); font-size: 14px; margin-top: 8px; min-height: 1.3em; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); transform: translate(-50%, 12px); z-index: 40; background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 36px); text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) { .top h1 { font-size: 36px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
