:root {
  --bg: #ffffff; --panel: #f7f7f5; --txt: #37352f; --muted: #787774; --line: #e9e9e7;
  --acc: #2383e2; --acc-soft: #e7f3fe; --ok: #2f9e6b; --warn: #c2410c;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191919; --panel: #202020; --txt: #e6e6e4; --muted: #9b9a97; --line: #2f2f2f;
    --acc: #529cca; --acc-soft: #1f2d3a; --ok: #4dab9a; --warn: #e08a5a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #191919; --panel: #202020; --txt: #e6e6e4; --muted: #9b9a97; --line: #2f2f2f;
  --acc: #529cca; --acc-soft: #1f2d3a; --ok: #4dab9a; --warn: #e08a5a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
.muted { color: var(--muted); font-size: .92rem; }

/* Cabecera y navegación */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line); }
@media (min-width: 760px) { .topbar { background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); } }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .95rem; }
.brand svg { color: var(--acc); }
.sync { display: flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync i.ok { background: var(--ok); } .sync i.err { background: var(--warn); } .sync i.wait { background: var(--acc); }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 16px; border-radius: 8px; color: var(--muted); font-size: .72rem; min-width: 80px; }
.nav a.on { color: var(--acc); }
.nav a b { font-weight: 600; }

main { max-width: 680px; margin: 0 auto; padding: 20px 16px 8px; outline: none; }
.cab { margin-bottom: 18px; display: grid; gap: 2px; }
.sub { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 10px; }
.volver { display: inline-block; margin-bottom: 12px; color: var(--muted); font-size: .92rem; }
.vacio { padding: 12px 0; }

/* Barras de progreso: un solo color */
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--acc); transition: width .3s ease; }

/* Bloques de estudio */
.bloque { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; background: var(--bg); }
.bloque-cab { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: .85rem; }
.hora { font-weight: 600; font-variant-numeric: tabular-nums; }
.estado { color: var(--muted); }
.bloque.fin .estado { color: var(--ok); font-weight: 600; }

.fila { border-top: 1px solid var(--line); }
.bloque-cab + .fila, .unidades .fila:first-child { border-top: 0; }
.fila-cab { display: flex; align-items: center; gap: 12px; padding: 12px 10px 12px 14px; }
.check { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--muted); display: grid; place-items: center; color: transparent; transition: all .12s; }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.check:focus-visible, .chev:focus-visible, .fila-txt:focus-visible, .btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.fila-txt { flex: 1; min-width: 0; display: grid; gap: 1px; text-align: left; }
.fila-sup { font-size: .78rem; color: var(--muted); }
.fila-tit { font-weight: 600; }
.fila-nota { font-size: .78rem; color: var(--acc); }
.fila.fin .fila-tit { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.fila-cnt { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chev { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.chev:hover { background: var(--panel); }
.fila.abierta .chev svg { transform: rotate(180deg); }
.fila-recursos { padding: 2px 10px 10px 54px; display: grid; }

.tarea { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-radius: 8px; cursor: pointer; min-height: 40px; }
.tarea:hover { background: var(--panel); }
.tarea input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chk { flex: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--muted); display: grid; place-items: center; color: transparent; }
.chk svg { width: 13px; height: 13px; }
.tarea input:checked + .chk { background: var(--acc); border-color: var(--acc); color: #fff; }
.tarea input:focus-visible + .chk { outline: 2px solid var(--acc); outline-offset: 2px; }
.tarea.ok .txt { color: var(--muted); text-decoration: line-through; }
.ico { width: 20px; text-align: center; flex: none; font-size: .9rem; opacity: .85; }
.txt { font-size: .95rem; }

/* Descanso, pendiente, progreso */
.descanso { padding: 22px 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--panel); text-align: center; }
.d-tit { font-size: 1.1rem; font-weight: 600; margin-bottom: 2px; }
.pendiente { margin-top: 6px; border: 1px solid var(--line); border-radius: var(--radius); }
.pendiente > summary { cursor: pointer; padding: 11px 14px; color: var(--muted); font-size: .9rem; list-style: none; }
.pendiente > summary::-webkit-details-marker { display: none; }
.pendiente > summary::before { content: "›"; display: inline-block; margin-right: 8px; transition: transform .15s; }
.pendiente[open] > summary::before { transform: rotate(90deg); }
.pendiente .bloque { margin: 0 10px 10px; }
.progreso { margin-top: 8px; }
.p-fila { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.p-fila span { color: var(--muted); }
.p-fila b { font-weight: 600; text-align: right; }
.progreso .bar { margin: 4px 0 8px; }

/* Asignaturas */
.lista { display: grid; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 14px; padding: 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item:hover { background: var(--panel); }
.i-emoji { font-size: 1.4rem; width: 32px; text-align: center; }
.i-info { flex: 1; min-width: 0; display: grid; gap: 8px; }
.i-nom { font-weight: 600; font-size: .95rem; }
.i-der { display: grid; text-align: right; font-size: .85rem; } .i-der b { font-weight: 600; }
.unidades { border: 1px solid var(--line); border-radius: var(--radius); margin-top: 12px; overflow: hidden; }
.cab + .bar { margin-bottom: 4px; }

/* Calendario */
.cal { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.cal-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-cab h2 { font-size: 1rem; text-transform: capitalize; }
.cal-sem, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-sem span { text-align: center; font-size: .72rem; font-weight: 600; color: var(--muted); padding: 4px 0; }
.dia { aspect-ratio: 1 / 1; min-height: 42px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); }
.dia.vacio { pointer-events: none; }
.dia.plan { color: var(--txt); }
.dia.plan:hover, .dia:hover { background: var(--panel); }
.dia.hoy .d-n { background: var(--acc); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; }
.dia.sel { background: var(--acc-soft); }
.dia.hito { box-shadow: inset 0 -2px 0 var(--warn); }
.d-n { font-size: .85rem; font-variant-numeric: tabular-nums; }
.pt { display: inline-block; width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--muted); }
.pt.mid { background: linear-gradient(90deg, var(--ok) 50%, transparent 50%); border-color: var(--ok); }
.pt.full { background: var(--ok); border-color: var(--ok); }
.leyenda { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 10px; font-size: .78rem; color: var(--muted); }
.panel-dia { margin-top: 6px; }
.aviso-fecha { padding: 8px 12px; margin-bottom: 10px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); font-weight: 600; font-size: .9rem; }

/* Botones, diálogo, aviso */
.btn { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; font-size: .9rem; }
.btn:hover { background: var(--panel); }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.danger { color: var(--warn); }
.btn.mini { padding: 4px 12px; }
.btn.file { display: inline-block; }
dialog { width: min(420px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 14px; padding: 20px; background: var(--bg); color: var(--txt); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h2 { margin-bottom: 6px; font-size: 1.15rem; }
dialog label { display: grid; gap: 4px; margin: 12px 0; font-weight: 600; font-size: .88rem; }
dialog input[type=email], dialog input[type=password] { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: inherit; font: inherit; }
dialog hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
dialog summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; } .row.end { justify-content: flex-end; margin-top: 14px; }
.error { color: var(--warn); font-size: .9rem; margin: 6px 0; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0; pointer-events: none; z-index: 50;
  padding: 10px 18px; border-radius: 999px; background: var(--txt); color: var(--bg); font-weight: 600; font-size: .9rem; transition: all .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Escritorio: navegación arriba */
@media (min-width: 760px) {
  body { padding-bottom: 32px; }
  .topbar { display: grid; grid-template-columns: 1fr auto 1fr; }
  .sync { justify-self: end; }
  .nav { position: static; display: flex; padding: 0; border: 0; background: none; gap: 4px; }
  .nav a { flex-direction: row; gap: 8px; font-size: .9rem; padding: 6px 14px; min-width: 0; }
  .nav a.on { background: var(--acc-soft); }
  .toast { bottom: 28px; }
}
@media (max-width: 559px) {
  main { padding: 16px 12px 8px; }
  h1 { font-size: 1.5rem; }
  .fila-recursos { padding-left: 14px; }
  .fila-cab { gap: 10px; padding-left: 12px; }
  .cal { padding: 8px; }
  .dia { min-height: 40px; }
}
/* Base táctil (iPhone, iPad, Android) */
html { -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; min-height: 100dvh; }
button, a, label, summary { touch-action: manipulation; }
.topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.nav { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
.cols, .cal-cols { display: grid; gap: 0; }

/* Pantallas táctiles: objetivos de al menos 44 px */
@media (pointer: coarse) {
  .tarea { min-height: 46px; }
  .chev { width: 44px; height: 44px; }
  .check { width: 32px; height: 32px; border-radius: 9px; }
  .chk { width: 24px; height: 24px; }
  .btn { min-height: 44px; }
  .btn.mini { min-width: 44px; }
  .dia { min-height: 46px; }
  .nav a { min-height: 48px; justify-content: center; }
}
/* Solo hay "hover" con ratón */
@media (hover: none) {
  .tarea:hover, .chev:hover, .item:hover, .btn:hover, .dia:hover { background: none; }
  .dia.sel { background: var(--acc-soft); }
}

/* iPad vertical y portátiles pequeños */
@media (min-width: 760px) {
  main { max-width: 920px; padding-top: 28px; padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
  h1 { font-size: 2rem; }
  .lista { grid-template-columns: 1fr 1fr; gap: 12px; border: 0; overflow: visible; }
  .lista .item { border: 1px solid var(--line); border-radius: var(--radius); }
  .lista .item:first-child { border-top: 1px solid var(--line); }
  .unidades { margin-top: 16px; }
}

/* iPad horizontal, portátil y escritorio: dos columnas */
@media (min-width: 960px) {
  main { max-width: 1120px; }
  .cols { grid-template-columns: minmax(0, 1fr) 320px; gap: 36px; align-items: start; }
  .cols .col-side { position: sticky; top: 76px; margin-top: 0; }
  .cols .col-side .sub { margin-top: 0; }
  .cal-cols { grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; align-items: start;
    grid-template-areas: "cal panel" "fechas panel"; }
  .cal-cols .cal { grid-area: cal; }
  .cal-cols .panel-dia { grid-area: panel; margin-top: 0; position: sticky; top: 76px; }
  .cal-cols .fechas { grid-area: fechas; }
  .cal-cols .panel-dia .sub:first-child { margin-top: 0; }
  .dia { min-height: 56px; }
  .unidades, .cab + .bar { max-width: 760px; }
}
@media (min-width: 1400px) {
  main { max-width: 1240px; }
}

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

/* Tira de semanas y días */
.cab-fila { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.volver-hoy { background: var(--acc-soft); border-color: transparent; color: var(--acc); font-weight: 600; }
.racha-chip { font-weight: 700; font-size: .95rem; padding: 4px 10px; border-radius: 999px; background: #fff1e6; color: #c2410c; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .racha-chip { background: #3a2a1f; color: #f0a06c; } }
.frase { margin-top: 8px; font-size: 1rem; font-weight: 500; }

.tira { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 10px 10px 12px; margin-bottom: 18px; }
.sems { position: relative; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 8px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.sems::-webkit-scrollbar { display: none; }
.sem { position: relative; flex: 0 0 auto; display: grid; justify-items: center; gap: 0; min-width: 62px; padding: 6px 8px 9px; border-radius: 10px; border: 1px solid transparent; color: var(--muted); overflow: hidden; scroll-snap-align: center; line-height: 1.25; }
.sem b { font-size: .9rem; color: var(--txt); }
.sem span { font-size: .72rem; }
.sem i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--ok); border-radius: 0 2px 2px 0; }
.sem.act b::after { content: ''; display: inline-block; width: 5px; height: 5px; margin-left: 4px; border-radius: 50%; background: var(--acc); vertical-align: middle; }
.sem.on { background: var(--bg); border-color: var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.sem.on b { color: var(--acc); }
.sem.full b { color: var(--ok); }

.tira-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0 8px; }
.tira-tit { display: grid; justify-items: center; line-height: 1.3; }
.tira-tit b { font-size: 1rem; }
.tira-tit span { font-size: .8rem; color: var(--muted); }
.flecha { width: 36px; height: 36px; border-radius: 50%; font-size: 1.4rem; line-height: 1; display: grid; place-items: center; color: var(--muted); }
.flecha:hover { background: var(--bg); color: var(--txt); }

.dchips { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dchip { position: relative; display: grid; justify-items: center; gap: 1px; padding: 7px 0 6px; border-radius: 12px; border: 1px solid transparent; min-height: 74px; }
.dchip .dl { font-size: .7rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.dchip .dn { font-size: 1.1rem; font-weight: 700; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; }
.dchip .de { font-size: .72rem; line-height: 1.2; min-height: 1.1em; white-space: nowrap; color: var(--muted); }
.dchip.libre { opacity: .55; }
.dchip.hoy .dn { box-shadow: inset 0 0 0 2px var(--acc); }
.dchip.mid .dn { background: linear-gradient(90deg, color-mix(in srgb, var(--ok) 35%, transparent) 50%, transparent 50%); }
.dchip.full .dn { background: var(--ok); color: #fff; }
.dchip.full .dn { font-size: 0; }
.dchip em { position: absolute; top: 25px; left: 50%; transform: translateX(-50%); width: 30px; height: 30px; display: grid; place-items: center; color: #fff; font-style: normal; }
.dchip.on { background: var(--bg); border-color: var(--acc); box-shadow: 0 1px 4px rgba(35,131,226,.18); }
.dchip.on.libre { opacity: 1; }
.dchip:hover:not(.on) { background: var(--bg); }

.tira-pie { margin-top: 10px; display: grid; gap: 6px; }
.tira-pie span { font-size: .8rem; color: var(--muted); }
.tira-pie .bar { margin: 0; }
.descanso .btn { margin-top: 12px; }

@media (max-width: 559px) {
  .tira { margin-left: -4px; margin-right: -4px; padding: 8px 6px 10px; }
  .dchip { min-height: 70px; }
  .dchip .de { font-size: .62rem; }
}
@media (hover: none) { .dchip:hover:not(.on), .flecha:hover { background: none; } }

/* ===== Color y animación ===== */
:root { --grad: linear-gradient(135deg, #2383e2, #8b5cf6 55%, #ec4899); }

/* Cabecera de Hoy */
.hero { padding: 18px 18px 16px; border-radius: 18px; background: var(--grad); color: #fff; position: relative; overflow: hidden; box-shadow: 0 8px 24px -10px rgba(139,92,246,.55); gap: 0; }
.hero::after { content: ''; position: absolute; right: -40px; top: -50px; width: 170px; height: 170px; border-radius: 50%; background: rgba(255,255,255,.14); }
.hero h1, .hero .fecha, .hero .frase, .hero .cita, .hero .cab-fila { position: relative; z-index: 1; }
.hero .fecha { color: rgba(255,255,255,.85); font-size: .92rem; }
.hero .frase { color: #fff; font-weight: 600; margin-top: 10px; }
.hero .cita { margin-top: 4px; font-size: .85rem; font-style: italic; color: rgba(255,255,255,.8); }
.hero .racha-chip { background: rgba(255,255,255,.22); color: #fff; backdrop-filter: none; }
.hero .volver-hoy { background: rgba(255,255,255,.22); color: #fff; }
.hero + .tira { margin-top: 14px; }

/* Barras con degradado */
.bar i { background: var(--c, var(--acc)); background-image: linear-gradient(90deg, transparent, rgba(255,255,255,.25)); }
.progreso .bar i, .tira-pie .bar i { background: var(--grad); }
.bar { height: 8px; }

/* Filas con color de asignatura */
.fila { position: relative; }
.fila::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c, var(--acc)); }
.badge { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 1.15rem; background: color-mix(in srgb, var(--c, var(--acc)) 16%, transparent); }
.fila-sup { color: color-mix(in srgb, var(--c, var(--muted)) 75%, var(--txt)); font-weight: 600; }
.check.on { background: var(--c, var(--ok)); border-color: var(--c, var(--ok)); }
.fila.fin .badge { filter: saturate(.5); opacity: .75; }
.bloque { box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 16px -12px rgba(0,0,0,.25); transition: box-shadow .2s, transform .2s; }
.bloque.slotA .bloque-cab { background: linear-gradient(90deg, color-mix(in srgb, #2383e2 14%, var(--panel)), var(--panel)); }
.bloque.slotB .bloque-cab { background: linear-gradient(90deg, color-mix(in srgb, #f97316 14%, var(--panel)), var(--panel)); }
.bloque.fin { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.fila-cab { transition: background .15s; }
@media (hover: hover) { .bloque:hover { box-shadow: 0 10px 24px -14px rgba(0,0,0,.35); transform: translateY(-1px); } }

/* Asignaturas coloridas */
.i-emoji { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--acc)) 16%, transparent); }
.item { transition: background .15s, transform .15s; }
@media (hover: hover) { .item:hover { transform: translateX(2px); } }
.item .bar i { background: var(--c); }

/* Días de la tira más vivos */
.dchip.full .dn { background: linear-gradient(135deg, #10b981, #06b6d4); }
.dchip.on { background: var(--bg); border-color: transparent; box-shadow: 0 0 0 2px #8b5cf6, 0 6px 14px -6px rgba(139,92,246,.6); }
.dchip { transition: transform .15s, background .15s, box-shadow .2s; }
.dchip:active { transform: scale(.92); }
.dchip.hoy .dn { box-shadow: inset 0 0 0 2px #2383e2; }
.nav a.on { color: var(--acc); }
.flecha { transition: transform .12s, background .15s; }
.flecha:active { transform: scale(.85); }

/* Entrada de vistas */
@keyframes entra { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes bajar { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
.anim .hero, .anim .tira, .anim .descanso, .anim .cal, .anim .panel-dia, .anim .fechas, .anim .progreso, .anim .bloque, .anim .item, .anim .fila, .anim .cab, .anim .volver { animation: entra .5s cubic-bezier(.22,1,.36,1) both; }
.anim .hero { animation-name: bajar; }
.anim .tira { animation-delay: .06s; }
.anim .col-main > :nth-child(1), .anim .lista > :nth-child(1), .anim .unidades > :nth-child(1) { animation-delay: .12s; }
.anim .col-main > :nth-child(2), .anim .lista > :nth-child(2), .anim .unidades > :nth-child(2) { animation-delay: .19s; }
.anim .col-main > :nth-child(3), .anim .lista > :nth-child(3), .anim .unidades > :nth-child(3) { animation-delay: .26s; }
.anim .lista > :nth-child(n+4), .anim .unidades > :nth-child(n+4) { animation-delay: .32s; }
.anim .progreso, .anim .panel-dia, .anim .fechas { animation-delay: .2s; }
.anim .bloque .fila, .anim .item .fila { animation: none; }

/* Check con rebote y tick que se dibuja */
@keyframes rebote { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 70% { transform: scale(.9); } 100% { transform: scale(1); } }
@keyframes dibuja { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
.check.pop.on { animation: rebote .4s cubic-bezier(.3,1.6,.5,1); }
.check.pop.on svg path, .tarea.pop input:checked + .chk svg path { stroke-dasharray: 24; animation: dibuja .35s .05s ease-out both; }
.tarea.pop input:checked + .chk { animation: rebote .4s cubic-bezier(.3,1.6,.5,1); }
.tarea input:checked + .chk { background: var(--ok); border-color: var(--ok); }
.fila-recursos { animation: entra .25s ease both; }

/* Confeti */
.confeti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confeti i { position: absolute; width: 9px; height: 13px; border-radius: 2px; opacity: 0; animation: vuela 1.5s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes vuela {
  0% { opacity: 1; transform: translate(0,0) rotate(0); }
  60% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), calc(var(--dy) + 340px)) rotate(var(--r)); }
}

/* Saludo inicial */
#splash { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; text-align: center; padding: 24px; background: var(--grad); color: #fff; transition: opacity .5s, transform .5s; cursor: pointer; }
#splash.fuera { opacity: 0; transform: scale(1.04); pointer-events: none; }
.sp-in { display: grid; gap: 10px; justify-items: center; max-width: 440px; animation: entra .7s cubic-bezier(.22,1,.36,1) both; }
.sp-emoji { font-size: 4.2rem; line-height: 1; animation: flota 2.4s ease-in-out infinite; }
#splash h2 { font-size: 1.9rem; letter-spacing: -.01em; }
#splash p { font-size: 1.05rem; opacity: .95; }
#splash .sp-cita { font-style: italic; font-size: .95rem; opacity: .8; margin-top: 8px; }
@keyframes flota { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }

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

/* ===== Progreso, cuenta atrás, ajustes, vista compacta ===== */
.dchip.on { box-shadow: 0 0 0 2px var(--acc2, #8b5cf6), 0 6px 14px -6px var(--acc2, #8b5cf6); }
:root[data-theme="dark"] .racha-chip { background: #3a2a1f; color: #f0a06c; }
:root[data-theme="light"] .racha-chip { background: #fff1e6; color: #c2410c; }
.hero .racha-chip { background: rgba(255,255,255,.22) !important; color: #fff !important; }
@media (max-width: 559px) { .nav a { min-width: 0; flex: 1; padding: 6px 4px; } }

.ritmo { display: flex; gap: 14px; align-items: center; padding: 18px; border-radius: 16px; background: color-mix(in srgb, var(--ok) 13%, var(--bg)); border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line)); }
.ritmo.warn { background: color-mix(in srgb, var(--warn) 11%, var(--bg)); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.ri-emo { font-size: 2.4rem; line-height: 1; }
.ritmo h2 { font-size: 1.15rem; }
.ritmo p { color: var(--muted); font-size: .92rem; margin-top: 2px; }
.ri-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.ri-stats div { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); display: grid; }
.ri-stats b { font-size: 1.5rem; font-variant-numeric: tabular-nums; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ri-stats span { color: var(--muted); font-size: .8rem; }
@media (min-width: 760px) { .ri-stats { grid-template-columns: repeat(4, 1fr); } }

.graf-card { padding: 14px 10px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.grafica { width: 100%; height: auto; display: block; overflow: visible; }
.g-l { stroke: var(--line); stroke-width: 1; }
.g-t { fill: var(--muted); font-size: 9px; }
.g-hoy { stroke: var(--acc); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.g-ideal { fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-dasharray: 4 4; opacity: .7; }
.g-real { fill: none; stroke: url(#gl); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; animation: traza 1.2s ease-out both; }
.g-area { animation: aparece 1.2s ease-out both; }
.g-punto { fill: var(--bg); stroke: var(--acc); stroke-width: 3; animation: aparece 1.4s ease-out both; }
@keyframes traza { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes aparece { from { opacity: 0; } to { opacity: 1; } }
.leyenda .lg { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--acc); border-radius: 2px; vertical-align: middle; margin: 0 4px 0 10px; }
.leyenda .lg-ideal { border-top: 2px dashed var(--muted); }

.cuentas { display: grid; gap: 10px; }
@media (min-width: 560px) { .cuentas.grande { grid-template-columns: repeat(3, 1fr); } }
.cuenta { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line)); background: linear-gradient(135deg, color-mix(in srgb, var(--c) 14%, var(--bg)), var(--bg)); }
.cu-n { display: grid; justify-items: center; min-width: 64px; line-height: 1; }
.cu-n span { font-size: 2rem; font-weight: 800; color: var(--c); font-variant-numeric: tabular-nums; }
.cu-n small { font-size: .68rem; color: var(--muted); margin-top: 3px; text-align: center; }
.cu-t { display: grid; }
.cu-t b { font-size: .95rem; }
.cu-t span { font-size: .8rem; color: var(--muted); }
.progreso > .cuentas { margin-bottom: 4px; }
.cuentas + .sub { margin-top: 20px; }
.progreso .cuenta { margin-top: 0; }

/* Ajustes en el diálogo */
.ap-tit { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 8px; }
.ap-fila { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; }
.ap-fila .btn[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: #fff; }
.sw { width: 34px; height: 34px; border-radius: 50%; background: var(--s); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--line); }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--txt); }
a.btn { display: inline-block; text-align: center; }

/* Vista compacta */
.compacto .topbar { display: none; }
.compacto body, body.compacto { padding-bottom: 24px; }
.compacto-in { max-width: 520px; margin: 0 auto; display: grid; gap: 4px; }
.cp-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; padding-top: env(safe-area-inset-top); }
.cp-hito { font-size: .85rem; color: var(--muted); } .cp-hito b { color: var(--acc); }
.anillo { position: relative; width: 132px; height: 132px; margin: 6px auto 8px; }
.an-fondo { fill: none; stroke: var(--line); stroke-width: 9; }
.an-val { fill: none; stroke: var(--acc); stroke-width: 9; stroke-linecap: round; animation: anillo 1.1s cubic-bezier(.22,1,.36,1) both; }
@keyframes anillo { from { stroke-dashoffset: var(--full); } }
.an-txt { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.an-txt b { font-size: 1.7rem; } .an-txt span { font-size: .75rem; color: var(--muted); }
.cp-tit { text-align: center; font-size: 1.25rem; margin-bottom: 12px; }
.graf-card { max-width: 640px; }
.graf-card .grafica { max-height: 300px; }
.graf-card .leyenda { margin: 6px 0 2px 30px; font-size: .78rem; color: var(--muted); }

/* ===== Calendario con etiquetas ===== */
.pasos { margin: 0; padding: 4px 16px 12px 62px; display: grid; gap: 6px; font-size: .92rem; color: var(--txt); animation: entra .25s ease both; }
.cal { padding: 14px; border-radius: 16px; background: var(--panel); }
.cal-cab h2 { font-size: 1.15rem; }
.cal-sem, .cal-grid { gap: 4px; }
.cal-grid .dia { aspect-ratio: auto; min-height: 84px; align-items: stretch; justify-content: flex-start; gap: 3px; padding: 4px 3px; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.cal-grid .dia.vacio { background: none; border: 0; }
.cal-grid .dia:not(.plan) { color: var(--muted); }
.cal-grid .dia:hover { background: var(--bg); box-shadow: 0 6px 14px -8px rgba(0,0,0,.4); transform: translateY(-1px); }
.dia.sel { box-shadow: 0 0 0 2px var(--acc2, var(--acc)); }
.dia.hito { background: linear-gradient(180deg, color-mix(in srgb, var(--h) 16%, var(--bg)), var(--bg)); box-shadow: inset 0 3px 0 var(--h); }
.dia.sel.hito { box-shadow: inset 0 3px 0 var(--h), 0 0 0 2px var(--acc2, var(--acc)); }
.dia.full { background: linear-gradient(180deg, color-mix(in srgb, var(--ok) 14%, var(--bg)), var(--bg)); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.dia.late { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.d-cab { display: flex; justify-content: space-between; align-items: center; padding: 0 2px; }
.cal-grid .dia .d-n { font-size: .78rem; font-weight: 700; width: 22px; height: 22px; display: grid; place-items: center; }
.cal-grid .dia.hoy .d-n { width: 22px; height: 22px; background: var(--grad); }
.d-st { font-size: .7rem; font-weight: 800; color: #fff; background: var(--ok); width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; }
.hito-lb { font-size: .6rem; font-weight: 700; line-height: 1.15; padding: 1px 3px; border-radius: 4px; background: var(--h); color: #fff; white-space: normal; }
.d-tags { display: grid; gap: 3px; min-width: 0; }
.blk { display: grid; gap: 2px; min-width: 0; }
.t-h { font-style: normal; font-size: .62rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-left: 2px; }
.tag { display: flex; align-items: center; gap: 3px; min-width: 0; padding: 2px 4px; border-radius: 5px; font-size: .68rem; line-height: 1.2; background: color-mix(in srgb, var(--c) 17%, var(--bg)); color: color-mix(in srgb, var(--c) 70%, var(--txt)); border-left: 3px solid var(--c); }
.tag b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag .t-e { font-style: normal; font-size: .7rem; }
.tag .t-s { display: none; }
.tag s { margin-left: auto; text-decoration: none; font-weight: 800; color: var(--ok); }
.tag.ok { opacity: .62; }
.tag.ok b { text-decoration: line-through; }
.tag.late { background: color-mix(in srgb, var(--warn) 16%, var(--bg)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 55%, transparent); }
.clave { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.lg-a { font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--c) 17%, var(--bg)); color: color-mix(in srgb, var(--c) 70%, var(--txt)); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.leyenda .lg-e { display: inline-flex; align-items: center; gap: 4px; }
.leyenda s { text-decoration: none; width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .65rem; font-weight: 800; color: #fff; }
.leyenda s.ok { background: var(--ok); }
.leyenda s.late { background: var(--warn); }
.lg-b { width: 14px; height: 10px; border-radius: 3px; border-left: 3px solid var(--acc); background: var(--acc-soft); }

@media (max-width: 759px) {
  .cal { padding: 8px 6px; }
  .cal-sem, .cal-grid { gap: 2px; }
  .cal-grid .dia { min-height: 76px; padding: 3px 1px; border-radius: 8px; }
  .t-h, .tag .t-e, .tag .t-l { display: none; }
  .tag .t-s { display: block; }
  .blk { display: contents; }
  .d-tags { gap: 2px; }
  .tag { padding: 1px 2px 1px 3px; font-size: .56rem; border-left-width: 2px; border-radius: 3px; }
  .tag s { display: none; }
  .tag.ok::after { content: '✓'; margin-left: auto; font-weight: 800; color: var(--ok); }
  .d-st { width: 12px; height: 12px; font-size: .55rem; }
  .hito-lb { font-size: .5rem; }
}
@media (min-width: 760px) { .cal-grid .dia { min-height: 118px; padding: 5px 4px; } }
@media (min-width: 960px) {
  .cal-cols { grid-template-columns: minmax(0, 1fr); grid-template-areas: "cal" "panel" "fechas"; gap: 18px; }
  .cal-cols .panel-dia { position: static; }
  .cal-cols .panel-dia .bloque { max-width: 640px; }
}
@media (min-width: 1500px) {
  main { max-width: 1320px; }
  .cal-cols { grid-template-columns: minmax(0, 1fr) 380px; grid-template-areas: "cal panel" "fechas panel"; gap: 28px; }
  .cal-cols .panel-dia { position: sticky; }
}

@media (max-width: 759px) { .hito-lb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } }
