/* Tokens: DESIGN.md (Tabo Live — Índigo). Si cambias un color aquí, cámbialo allá.
   Siempre en claro; el oscuro solo con el botón de la luna (data-theme="dark"). */
:root {
  --bg: #F1F2F8;
  --tile: #FFFFFF;
  --ink: #12142A;
  --mu: #5A5E78;
  --ln: #E1E3EE;
  --ac: #3B4BD8;
  --onac: #FFFFFF;
  --t1: #3B4BD8;
  --t1i: #FFFFFF;
  --t2: #FFD9BD;
  --t2i: #4A2408;
  --t3: #E3E6FB;
  --t3i: #1E2672;
  --cl: #3B4BD8;
  --cli: #FFFFFF;
  --chip: #FFE3CF;
  --chipi: #6B330C;
  --late: #B42318;
  --late-soft: #FDE8E6;
  --pk: #D6336C;
  --or: #E8590C;
  --shadow: 0 12px 34px rgba(18, 20, 42, .16);
  --fd: "Funnel Display", "Funnel Sans", system-ui, -apple-system, sans-serif;
  --fb: "Funnel Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0D0F17; --tile: #171A26; --ink: #ECEEF7; --mu: #9AA0B8; --ln: #252A3B;
  --ac: #8C9BFF; --onac: #0D0F17; --t1: #2B3474; --t1i: #E3E6FF; --t2: #3B2A1E; --t2i: #FFC9A0;
  --t3: #1E2340; --t3i: #C8CEFF; --cl: #4655D6; --cli: #FFFFFF; --chip: #3B2A1E; --chipi: #FFC9A0;
  --late: #FF8787; --late-soft: #3A1D20; --pk: #F783AC; --or: #FFA94D;
  --shadow: 0 12px 34px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 500 17px/1.3 var(--fb);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(72px + var(--safe-b));
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i, .i svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--ac); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---------- Encabezado + pestañas (fijo arriba) ---------- */
.top { position: sticky; top: 0; z-index: 8; background: var(--bg); padding: calc(var(--safe-t) + 14px) 16px 0; }
.top-in, .tabs, main, .capture-row, .capture-preview { max-width: 560px; margin-left: auto; margin-right: auto; }
.top-in { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.kicker { font: 500 15px/1.2 var(--fb); color: var(--mu); }
.kicker #sync { color: var(--late); font-size: 13px; margin-left: 4px; }
.top h1 { margin: 2px 0 0; font: 700 30px/1.05 var(--fd); letter-spacing: -.02em; transition: font-size .2s ease; }
.top.compact h1 { font-size: 20px; }
.top.compact .kicker { display: none; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--tile); color: var(--ink); display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
.tabs { display: grid; grid-template-columns: 1fr 1fr 1.25fr 1.25fr 1fr; gap: 6px; padding: 12px 0 10px; }
.tabs button { border: 0; min-height: 36px; padding: 0 4px; border-radius: 999px; background: var(--tile); font: 600 13.5px var(--fb); color: var(--mu); white-space: nowrap; transition: background .15s, color .15s; }
.tabs button[aria-current="page"] { background: var(--ac); color: var(--onac); }

main { padding: 4px 16px 16px; outline: none; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Bloques ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { position: relative; background: var(--tile); color: var(--ink); border-radius: 22px; padding: 14px 16px; border: 0; text-align: left; display: block; width: 100%; }
button.tile { font: inherit; }
.tile .tk { display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 600 13px/1.2 var(--fb); color: var(--mu); }
.tile .big { font: 700 26px/1 var(--fd); letter-spacing: -.02em; margin-top: 8px; }
.tile .sm { font: 500 13px/1.25 var(--fb); margin-top: 4px; opacity: .85; }
.tile.c1 { background: var(--t1); color: var(--t1i); }
.tile.c2 { background: var(--t2); color: var(--t2i); }
.tile.c3 { background: var(--t3); color: var(--t3i); }
.tile.c1 .tk, .tile.c2 .tk, .tile.c3 .tk { color: inherit; opacity: .78; }
.mini-ring { position: absolute; right: 14px; bottom: 14px; width: 46px; height: 46px; }
.mini-ring svg { width: 46px; height: 46px; transform: rotate(-90deg); }
.mini-ring circle { fill: none; stroke-width: 6; }

/* ---------- Bloque del día ---------- */
.dayhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.dayhead b { font: 700 18px/1.1 var(--fd); }
.dayhead .cnt { font: 600 13px var(--fb); color: var(--mu); font-variant-numeric: tabular-nums; margin-left: 6px; }
.daynav { display: flex; align-items: center; gap: 6px; }
.daynav.solo { justify-content: flex-end; }
.daynav button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--bg); color: var(--ink); display: grid; place-items: center; }
.daynav button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.daynav .lbl { flex: 1; font: 600 15px var(--fb); color: var(--mu); }
.daynav .today-link { width: auto; height: 32px; border-radius: 999px; padding: 0 12px; font: 600 14px var(--fb); color: var(--ac); }
.bar { height: 6px; border-radius: 9px; background: var(--ln); overflow: hidden; margin: 6px 0 4px; }
.bar i { display: block; height: 100%; background: var(--ac); border-radius: 9px; transition: width .35s cubic-bezier(.3, .7, .2, 1); }

.list { list-style: none; margin: 0; padding: 0; }
.row-wrap { position: relative; overflow: hidden; border-top: 1px solid var(--ln); }
.list > .row-wrap:first-child { border-top: 0; }
/* Deslizar como en el iPhone: a la derecha aparece «Hecho»; a la izquierda, los botones de fecha rápida. */
.row-bg { position: absolute; inset: 0 auto 0 0; width: 60%; display: flex; align-items: center; padding: 0 14px; font: 600 14px var(--fb); color: var(--onac); background: var(--ac); border-radius: 12px; opacity: 0; }
.row-wrap.swipe-r .row-bg { opacity: 1; }
.rapidos { position: absolute; inset: 0 0 0 auto; display: flex; }
.rapidos button { width: 62px; border: 0; display: grid; place-items: center; align-content: center; gap: 1px; font: 600 12.5px/1.1 var(--fb); }
.rapidos button small { font: 500 10.5px var(--fb); opacity: .8; }
.rapidos .r0 { background: var(--ac); color: var(--onac); }
.rapidos .r1 { background: var(--t3); color: var(--t3i); }
.rapidos .r2 { background: var(--t2); color: var(--t2i); }
.rapidos .r3 { background: color-mix(in srgb, var(--ink) 12%, var(--tile)); color: var(--ink); border-radius: 0 12px 12px 0; }
.row-wrap:not(.swipe-l):not(.abierta) .rapidos { visibility: hidden; }
.row { position: relative; display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 4px 0; background: var(--tile); touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.row.animating { transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
.box { width: 22px; height: 22px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--ink) 32%, transparent); display: grid; place-items: center; flex: none; transition: background .18s, border-color .18s, transform .18s; }
.box svg { width: 13px; height: 13px; fill: none; stroke: var(--onac); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .25s .05s ease-out; }
.row.done .box { background: var(--ac); border-color: var(--ac); transform: scale(1.04); }
.row.done .box svg { stroke-dashoffset: 0; }
.row.plain .box { display: none; }
.txt { flex: 1; min-width: 0; }
.txt .t { display: block; font: 500 15px/1.25 var(--fb); overflow-wrap: anywhere; }
.txt .n { display: block; font: 400 12px/1.3 var(--fb); color: var(--mu); margin-top: 1px; }
.row.done .t { color: var(--mu); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--mu) 70%, transparent); }
.late-date { color: var(--late) !important; font-weight: 600 !important; }
.chip { font: 600 11px/1 var(--fb); padding: 5px 8px; border-radius: 999px; background: var(--chip); color: var(--chipi); flex: none; }
.more { width: 34px; height: 34px; border: 0; background: none; color: var(--mu); border-radius: 50%; display: grid; place-items: center; flex: none; margin-right: -8px; }
.more svg { width: 18px; height: 18px; opacity: .7; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 16px; border: 0; background: var(--bg); color: var(--ink); font: 600 15px var(--fb); }
.tile .btn { background: var(--bg); }
.btn.primary { background: var(--ac); color: var(--onac); }
.btn.block { width: 100%; }
.btn.ghost { background: none; color: var(--ac); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.close-day { margin-top: 8px; min-height: 46px; font-size: 15px; }
.empty { color: var(--mu); font: 500 15px/1.4 var(--fb); padding: 8px 0; margin: 0; }
.hint { color: var(--mu); font: 500 13px/1.4 var(--fb); margin: 0; padding: 0 4px; }
.late-tile .dayhead b { color: var(--late); }
.cumples { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.cumple-chip { font: 500 13px/1.2 var(--fb); padding: 7px 10px; border-radius: 12px; background: var(--t3); color: var(--t3i); }
.cumple-chip.aniversario { background: var(--t2); color: var(--t2i); }
.tile .big.nombre { font-size: 20px; line-height: 1.1; }

.closed-card { display: grid; gap: 6px; justify-items: start; background: var(--cl); color: var(--cli); }
.closed-card.fresh { animation: pop .45s cubic-bezier(.2, .9, .25, 1.2); }
.closed-card .mark { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; background: color-mix(in srgb, var(--cli) 16%, transparent); }
.closed-card .mark svg { width: 30px; height: 30px; stroke: var(--cli); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.closed-card.fresh .mark svg { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .5s .15s ease-out forwards; }
.closed-card b { font: 700 28px/1.05 var(--fd); }
.closed-card span { font: 500 15px/1.3 var(--fb); opacity: .9; }
.closed-card button { margin-top: 4px; border: 0; background: color-mix(in srgb, var(--cli) 16%, transparent); color: var(--cli); border-radius: 999px; padding: 9px 14px; font: 600 14px var(--fb); }
@keyframes pop { from { transform: scale(.96); opacity: .4; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Mes ---------- */
.mtop { display: flex; justify-content: space-between; align-items: center; }
.mtop > b { font: 700 24px/1.1 var(--fd); letter-spacing: -.01em; }
.mtop .daynav { gap: 8px; }
.mtop .daynav button { background: var(--tile); }
.cal { touch-action: pan-y; }
.streak { font: 500 14px var(--fb); color: var(--mu); }
.streak b { color: var(--ink); font-weight: 700; }
.wd, .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd span { text-align: center; font: 600 12px var(--fb); color: var(--mu); }
.cal button { border: 0; background: none; height: 48px; border-radius: 15px; display: grid; grid-template-rows: 1fr auto; justify-items: center; align-items: center; padding: 6px 0 7px; font: 600 16px/1 var(--fb); color: var(--ink); position: relative; transition: background .3s, color .3s, transform .15s; font-variant-numeric: tabular-nums; }
.cal button.o { visibility: hidden; }
.cal button.x { background: var(--cl); color: var(--cli); }
.cal button.tdy { box-shadow: inset 0 0 0 2px var(--ac); color: var(--ac); }
.cal button.tdy.x { color: var(--cli); box-shadow: inset 0 0 0 2px var(--cli); }
.cal button.sel:not(.x) { background: var(--tile); }
.cal button.sel { transform: scale(1.06); }
.cal button.fresh { animation: fill .6s ease-out; }
@keyframes fill { 0% { background: transparent; color: var(--ink); } 60% { transform: scale(1.12); } }
.cal button em { display: flex; gap: 3px; height: 5px; }
.cal button em u { width: 5px; height: 5px; border-radius: 9px; background: color-mix(in srgb, var(--ink) 40%, transparent); }
.cal button em u.jwork { background: var(--ac); }
.cal button em u.cumple { background: var(--pk); }
.cal button em u.carrera { background: var(--or); }
.cal button.x em u { background: color-mix(in srgb, var(--cli) 55%, transparent); }
.cal.moving button:not(.o) { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ac) 45%, transparent); }
.cal button.drop { background: var(--t3); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font: 500 12px var(--fb); color: var(--mu); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.legend i.d { width: 8px; height: 8px; border-radius: 9px; }
.moving-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-radius: 16px; background: var(--ac); color: var(--onac); font: 600 15px var(--fb); }
.moving-bar button { background: none; border: 1.5px solid currentColor; color: inherit; border-radius: 999px; padding: 6px 12px; font: 600 13px var(--fb); }

/* ---------- 75 Hard ---------- */
.ringbox { display: flex; align-items: center; gap: 16px; }
.ringbox svg { width: 112px; height: 112px; transform: rotate(-90deg); flex: none; }
.ringbox circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.ringbox b { display: block; font: 700 40px/1 var(--fd); letter-spacing: -.02em; }
.ringbox span { font: 500 14px/1.35 var(--fb); opacity: .9; }
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rule { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 8px 12px; border-radius: 16px; border: 0; background: var(--tile); color: var(--ink); text-align: left; transition: background .2s, color .2s; }
.rule .l { font: 700 18px var(--fd); width: 16px; color: var(--mu); flex: none; }
.rule .n { font: 500 14px/1.2 var(--fb); }
.rule .n small { display: block; font-size: 12px; opacity: .75; }
.rule.dn { background: var(--ac); color: var(--onac); }
.rule.dn .l { color: var(--onac); opacity: .8; }
.g75 { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; margin-top: 10px; }
.g75 i { aspect-ratio: 1; border-radius: 5px; background: color-mix(in srgb, var(--ink) 10%, transparent); }
.g75 i.f { background: var(--ac); }
.g75 i.p { background: color-mix(in srgb, var(--ac) 40%, transparent); }
.g75 i.m { background: var(--late-soft); box-shadow: inset 0 0 0 1.5px var(--late); }
.g75 i.n { box-shadow: 0 0 0 2px var(--ac); background: transparent; }
.start input[type="date"] { min-height: 46px; border-radius: 12px; border: 0; padding: 0 12px; background: color-mix(in srgb, var(--t1i) 16%, transparent); color: var(--t1i); margin: 10px 0; font: 500 16px var(--fb); color-scheme: dark; }
.start .btn { background: var(--t1i); color: var(--t1); }

/* ---------- Bandeja ---------- */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--tile); }
.seg button { border: 0; background: none; padding: 9px 0; border-radius: 11px; font: 600 14px var(--fb); color: var(--mu); }
.seg button small { font-weight: 500; opacity: .7; margin-left: 3px; }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

/* ---------- Listas ---------- */
.lst .big { font-size: 22px; }
.lst .big span { opacity: .5; }
.prog { height: 5px; border-radius: 9px; background: color-mix(in srgb, currentColor 15%, transparent); margin-top: 12px; overflow: hidden; }
.prog i { display: block; height: 100%; background: currentColor; border-radius: 9px; }
.group-title { font: 700 20px/1.1 var(--fd); margin: 8px 2px 0; }
.add-line { display: flex; gap: 8px; margin-top: 10px; }
.add-line input { flex: 1; min-width: 0; min-height: 46px; border-radius: 14px; border: 0; background: var(--bg); padding: 0 14px; font: 500 16px var(--fb); }
.logout { text-align: center; margin-top: 10px; }

/* ---------- Barra para anotar (fija abajo) ---------- */
.capture { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; padding: 8px 16px calc(var(--safe-b) + 10px); background: var(--bg); }
.capture-row { display: flex; gap: 10px; }
.capture input { flex: 1; min-width: 0; min-height: 46px; border-radius: 16px; border: 1.5px solid transparent; background: var(--tile); padding: 0 16px; font: 500 16px var(--fb); }
.capture input::placeholder { color: var(--mu); }
.capture input:focus { border-color: var(--ac); outline: none; }
.send { width: 46px; height: 46px; border-radius: 16px; border: 0; background: var(--ac); color: var(--onac); display: grid; place-items: center; flex: none; }
.send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.atajos { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 8px; scrollbar-width: none; max-width: 560px; margin: 0 auto; }
.atajos::-webkit-scrollbar { display: none; }
.atajos button { flex: none; border: 0; min-height: 34px; padding: 0 12px; border-radius: 999px; background: var(--tile); color: var(--ink); font: 600 13px var(--fb); }
.atajos button.b { background: var(--t3); color: var(--t3i); }
.atajos button.on { background: var(--ac); color: var(--onac); }
.capture-preview { padding: 0 4px 6px; color: var(--mu); font: 500 13px var(--fb); }
.capture-preview:empty { display: none; }
.capture-preview b { color: var(--ac); }

/* ---------- Hoja que sube ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 28, .45); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 560px; margin: 0 auto; background: var(--tile); border-radius: 24px 24px 0 0; padding: 10px 16px calc(16px + var(--safe-b)); box-shadow: var(--shadow); max-height: 88dvh; overflow: auto; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--ln); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 4px; font: 700 24px/1.1 var(--fd); }
.sheet .sub { color: var(--mu); font: 500 14px/1.35 var(--fb); margin: 0 0 12px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.strip button { min-height: 56px; border-radius: 14px; border: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; font: 500 12px var(--fb); color: var(--mu); }
.strip button b { font: 700 18px/1.1 var(--fd); color: var(--ink); }
.strip button.cur { box-shadow: inset 0 0 0 2px var(--ac); }
.sheet-actions { display: grid; gap: 8px; margin-top: 8px; }
.sheet .field { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.sheet .field input { flex: 1; min-width: 0; min-height: 48px; border-radius: 14px; border: 0; background: var(--bg); padding: 0 14px; font: 500 16px var(--fb); }
.danger { color: var(--late) !important; }
.pend { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.pend label { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 12px; border-radius: 14px; background: var(--bg); font: 500 16px var(--fb); }
.pend input { width: 22px; height: 22px; accent-color: var(--ac); }
.pend .to { margin-left: auto; color: var(--mu); font-size: 13px; }

/* ---------- Aviso con Deshacer ---------- */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(76px + var(--safe-b)); z-index: 30; max-width: 528px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 16px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font: 500 15px var(--fb); }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; min-height: 40px; padding: 0 10px; }

/* ---------- Entrar ---------- */
body.sin-sesion .tabs, body.sin-sesion .capture { display: none; }
body.sin-sesion { padding-bottom: 24px; }
.login { max-width: 380px; margin: 24px auto 0; width: 100%; display: grid; gap: 8px; }
.login h2 { margin: 0; font: 700 28px/1.05 var(--fd); }
.login .sub { margin: 0 0 8px; color: var(--mu); font: 500 15px/1.4 var(--fb); }
.login label { font: 600 14px var(--fb); margin-top: 6px; }
.login input { min-height: 50px; border-radius: 14px; border: 1.5px solid var(--ln); background: var(--tile); padding: 0 14px; font: 500 17px var(--fb); }
.login input:focus { border-color: var(--ac); outline: none; }
.login .btn { margin-top: 10px; }
.login .err { color: var(--late); min-height: 1.4em; margin: 4px 0 0; font: 500 15px var(--fb); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .closed-card.fresh .mark svg { stroke-dashoffset: 0; }
}
