:root {
  --bg: #F2F3F6;
  --surface: #FFFFFF;
  --sunk: #E7E8EE;
  --ink: #1D1E26;
  --muted: #6E7180;
  --line: rgba(29, 30, 38, 0.09);
  --accent: #5B4BE0;
  --accent-soft: #ECEAFD;
  --accent-ink: #3A2DA8;
  --green: #1F9D6B;
  --green-soft: #E2F4EC;
  --font: 'Cabinet Grotesk', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top, 0px);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 20px calc(110px + env(safe-area-inset-bottom, 0px));
}

/* Encabezado */
.top { margin: 8px 0 22px; }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.date { color: var(--muted); font-size: 15px; font-weight: 500; }
h1 {
  font-size: 34px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 4px 0 0;
}
h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  margin: 30px 2px 8px;
  letter-spacing: 0;
}
.lede { color: var(--muted); margin: 6px 0 0; max-width: 40ch; }
.small { font-size: 14px; color: var(--muted); }

/* Tarjeta principal: el único elemento protagonista */
.main {
  background: var(--accent);
  color: #fff;
  border-radius: 26px;
  padding: 22px 20px 20px;
}
.main .label { font-size: 14px; font-weight: 700; opacity: 0.75; }
.main .title {
  font-size: 27px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 6px 0 12px;
  overflow-wrap: anywhere;
}
.main .step {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 15px;
  margin-bottom: 16px;
}
.main .step b { font-weight: 700; }
.main .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.main .meta { font-size: 14px; opacity: 0.8; }
.main .btn-primary { background: #fff; color: var(--accent-ink); }
.main .btn-link { color: #fff; opacity: 0.8; }
.main.empty { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }

/* Bloque suave para formularios y avisos */
.panel {
  background: var(--surface);
  border-radius: 20px;
  padding: 16px;
  border: 1px solid var(--line);
}
.panel + .panel { margin-top: 12px; }
.notice {
  background: var(--green-soft);
  color: #12603F;
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 15px;
}
.notice b { font-weight: 700; }

/* Listas sobre el fondo, sin tarjeta */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 20px; border: 1px solid var(--line); }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.item:last-child { border-bottom: 0; }
.item .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item .sub { display: block; font-size: 13px; color: var(--muted); }
.item.done .txt { color: var(--muted); text-decoration: line-through; }
.empty-line { padding: 16px; color: var(--muted); font-size: 15px; }

.check {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  border: 2px solid #C9CBD5;
  background: transparent;
  display: grid; place-items: center;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.check.on { background: var(--c, var(--green)); border-color: var(--c, var(--green)); }
.check.on::after {
  content: '';
  width: 7px; height: 13px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.check:active { transform: scale(0.9); }

.x {
  border: 0; background: transparent; color: var(--muted);
  width: 36px; height: 36px; border-radius: 50%; font-size: 20px; line-height: 1;
}

.dots { display: flex; gap: 3px; }
.dot { width: 9px; height: 9px; border-radius: 3px; background: var(--sunk); }
.dot.on { background: var(--c, var(--accent)); }
.dot.today { box-shadow: 0 0 0 1.5px var(--ink); }

.chip {
  border: 0; border-radius: 999px; padding: 7px 12px;
  background: var(--sunk); font-size: 14px; font-weight: 700;
}
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); }

/* Botones */
.btn {
  appearance: none; border: 0; border-radius: 999px;
  padding: 13px 20px; min-height: 48px;
  font-weight: 700; font-size: 16px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-soft { background: var(--sunk); color: var(--ink); }
.btn-link { background: transparent; padding: 13px 8px; color: var(--muted); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; }
.stack { display: grid; gap: 10px; }

/* Formularios */
.input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 16px;
}
.panel .input { background: var(--bg); }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 14px; font-weight: 700; color: var(--muted); }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: var(--c);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--c); }

/* Hábitos */
.habit { padding: 16px; }
.habit-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.habit-name { font-weight: 800; font-size: 19px; flex: 1; overflow-wrap: anywhere; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cell {
  aspect-ratio: 1; border-radius: 6px; border: 0; padding: 0;
  background: var(--sunk);
}
.cell.on { background: var(--c); }
.cell.today { box-shadow: 0 0 0 2px var(--ink); }
.cell.future { opacity: 0.35; pointer-events: none; }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-bottom: 6px; }
.weekdays span { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; }
.habit-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--sunk); font-weight: 800; }

/* Cierre */
.progress { display: flex; gap: 6px; margin: 4px 0 18px; }
.progress span { height: 4px; flex: 1; border-radius: 2px; background: var(--sunk); }
.progress span.on { background: var(--accent); }
.win { display: flex; gap: 10px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.win:last-child { border-bottom: 0; }
.win b { font-weight: 800; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Barra inferior */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(242, 243, 246, 0.9);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 10;
}
.tab {
  border: 0; background: transparent; color: var(--muted);
  display: grid; justify-items: center; gap: 2px;
  font-size: 11px; font-weight: 700; padding: 4px 4px; min-width: 56px; flex: 1;
}
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab svg .fill { fill: currentColor; stroke: none; }
.tab[aria-current="page"] { color: var(--accent); }

/* Enfoque */
.focus {
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
}
.focus[hidden] { display: none; }
.focus .what { color: var(--muted); font-weight: 700; font-size: 15px; }
.focus .task { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin: 4px 0 0; overflow-wrap: anywhere; }
.focus .clock {
  flex: 1; display: grid; place-items: center; align-content: center; gap: 10px;
}
.focus .time {
  font-size: clamp(88px, 28vw, 140px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.focus .bar { width: min(320px, 80vw); height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.focus .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; width: 0; transition: width 0.5s linear; }
.focus .hint { color: var(--muted); font-size: 15px; text-align: center; max-width: 30ch; }
.focus .park { margin-bottom: 12px; }

/* Aviso flotante */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px));
  transform: translate(-50%, -150%);
  background: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 700;
  z-index: 30; max-width: 90vw; text-align: center;
  transition: transform 0.25s ease;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }

details summary { cursor: pointer; color: var(--muted); font-weight: 700; padding: 12px 2px; list-style: none; }
details summary::-webkit-details-marker { display: none; }

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

/* ===== v2 ===== */
.tag { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.18); margin-bottom: 4px; }

/* Retomar */
.retomar { background: var(--accent-soft); border-radius: 26px; padding: 20px; margin-bottom: 16px; color: var(--ink); }
.retomar h3 { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 8px; }
.retomar p { margin: 0 0 12px; }
.retomar .goal { background: var(--surface); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; }
.retomar .goal b { display: block; font-size: 22px; font-weight: 800; color: var(--accent-ink); }
.retomar details { margin-top: 10px; }
.retomar details[open] summary { color: var(--accent-ink); }
.retomar ul { margin: 6px 0 10px; padding-left: 20px; }
.retomar li { margin: 4px 0; }

/* Aviso de cierre en la tarde */
.nudge { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; margin-top: 14px; }
.nudge svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 1.8; flex: none; }
.nudge .txt { flex: 1; font-weight: 700; }

/* ENARM */
.hero { padding: 6px 2px 4px; }
.hero .big { font-size: 64px; font-weight: 800; letter-spacing: -0.045em; line-height: 0.95; font-variant-numeric: tabular-nums; }
.hero .big small { font-size: 26px; letter-spacing: -0.02em; margin-left: 4px; }
.hero .cap { color: var(--muted); font-weight: 700; margin-top: 6px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 16px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.fact b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.fact span { font-size: 13px; color: var(--muted); font-weight: 700; }
.countdown { font-weight: 800; color: var(--accent-ink); background: var(--accent-soft); padding: 7px 12px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.picker .chip { padding: 10px 14px; font-size: 15px; background: var(--surface); border: 1px solid var(--line); }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--sunk); display: block; }
.heat i.l1 { background: #CFC9F8; } .heat i.l2 { background: #A397F0; } .heat i.l3 { background: #7A6BE6; } .heat i.l4 { background: var(--accent); }
.heat i.today { box-shadow: 0 0 0 1.5px var(--ink); }
.heat i.future { opacity: 0; }
.legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 8px; font-size: 12px; color: var(--muted); font-weight: 700; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: block; }

.area { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.area:last-child { border-bottom: 0; }
.area-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.area-name { font-weight: 800; font-size: 17px; border: 0; background: none; padding: 0; text-align: left; flex: 1; }
.area-pct { font-weight: 800; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.pbar { height: 8px; background: var(--sunk); border-radius: 4px; overflow: hidden; margin: 8px 0 6px; }
.pbar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }
.area-edit { margin-top: 12px; display: grid; gap: 10px; }

/* Semana */
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-nav button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-weight: 800; font-size: 18px; }
.week-nav button:disabled { opacity: .3; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; }
.metric b { display: block; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.metric span { font-size: 14px; font-weight: 700; color: var(--muted); }
.metric em { display: block; font-style: normal; font-size: 13px; margin-top: 6px; color: var(--green); font-weight: 700; }
.metric em.neutral { color: var(--muted); }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; padding: 16px 16px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.bars .col { display: grid; grid-template-rows: 1fr auto auto; height: 100%; gap: 4px; justify-items: center; }
.bars .col .b { width: 100%; align-self: end; background: #CFC9F8; border-radius: 8px 8px 4px 4px; min-height: 4px; }
.bars .col.best .b { background: var(--accent); }
.bars .col.today span { color: var(--ink); }
.bars .col span { font-size: 12px; font-weight: 700; color: var(--muted); }
.bars .col small { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.insight:last-child { border-bottom: 0; }
.insight .mark { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; }
.insight.calm .mark { background: #C99A12; }
.moods { display: flex; gap: 8px; flex-wrap: wrap; }

/* Enfoque v2 */
.ring-wrap { position: relative; width: min(280px, 72vw); aspect-ratio: 1; display: grid; place-items: center; }
.ring-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-wrap circle { fill: none; stroke-width: 10; }
.ring-wrap .track { stroke: var(--sunk); }
.ring-wrap .prog { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s linear; }
.focus .time { font-size: clamp(64px, 19vw, 96px); }
.focus .sheet { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; max-width: 460px; width: 100%; margin: 0 auto; }
.focus .sheet h3 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin: 0; }
.focus .sheet p { margin: 0; color: var(--muted); }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 12px 6px; font-weight: 700; font-size: 15px; }
.choice[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Momentos satisfactorios */
@keyframes ripple {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c, var(--green)) 55%, transparent); }
  to { box-shadow: 0 0 0 18px color-mix(in srgb, var(--c, var(--green)) 0%, transparent); }
}
@keyframes pop { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.check.pop { animation: pop .35s ease, ripple .6s ease-out; }
.cell.pop { animation: pop .3s ease; }
.celebrate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none; }
.celebrate i { position: absolute; width: 90px; height: 90px; border-radius: 50%; border: 3px solid var(--accent); opacity: 0; animation: bloom 1.3s ease-out forwards; }
.celebrate i:nth-child(2) { animation-delay: .15s; }
.celebrate i:nth-child(3) { animation-delay: .3s; }
.celebrate b { position: relative; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 17px; animation: fadeout 1.6s ease forwards; }
@keyframes bloom { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(5); opacity: 0; } }
@keyframes fadeout { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .check.pop, .cell.pop, .celebrate i { animation: none !important; }
}
.main.empty .btn-primary { background: var(--accent); color: #fff; }
