:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --ko: #dc2626;
  --ko-soft: #fee2e2;
  --warn-soft: #fef3c7;
  --lv0: #fecaca;
  --lv1: #fde68a;
  --lv2: #d9f99d;
  --lv3: #86efac;
  --lv4: #22c55e;
  --none: #eceef1;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013;
    --surface: #171a1f;
    --text: #eceef1;
    --muted: #9aa1ab;
    --border: #2a2f36;
    --accent: #2dd4bf;
    --accent-soft: #123a36;
    --ok: #4ade80;
    --ok-soft: #12321f;
    --ko: #f87171;
    --ko-soft: #3a1717;
    --warn-soft: #3a2f10;
    --lv0: #5b1f1f;
    --lv1: #5c4a12;
    --lv2: #3f5714;
    --lv3: #1f6b3a;
    --lv4: #22c55e;
    --none: #22262c;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1013; --surface: #171a1f; --text: #eceef1; --muted: #9aa1ab; --border: #2a2f36;
  --accent: #2dd4bf; --accent-soft: #123a36; --ok: #4ade80; --ok-soft: #12321f;
  --ko: #f87171; --ko-soft: #3a1717; --warn-soft: #3a2f10;
  --lv0: #5b1f1f; --lv1: #5c4a12; --lv2: #3f5714; --lv3: #1f6b3a; --lv4: #22c55e; --none: #22262c;
}

:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
input, button { font-size: 16px; max-width: 100%; } /* 16px evita el zoom automático de iOS al escribir */
main { max-width: 560px; margin: 0 auto; padding: 0 16px 24px; }
h1 { font-size: 1.25rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; margin: 18px 0 12px; }
h3 { font-size: 1rem; margin: 22px 0 10px; }

/* Cabecera con una línea fina de lado a lado */
.top {
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--border); background: var(--bg);
  padding-top: env(safe-area-inset-top);
}
.top-inner { max-width: 560px; margin: 0 auto; padding: 14px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); }
.top h1 { color: var(--text); font-weight: 800; }

/* Iconos de línea en blanco y negro */
.ic { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.25em; flex: none; }
.icon-btn {
  background: transparent; border: none; padding: 8px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
}
.icon-btn:hover { color: var(--text); background: var(--none); }

button {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent;
  padding: 10px 14px; color: var(--text); background: var(--surface);
}
button.primary { background: var(--text); color: var(--bg); font-weight: 600; }
button.ghost { background: transparent; border-color: var(--border); }
button.small { padding: 6px 10px; font-size: .875rem; }
button:disabled { opacity: .5; cursor: default; }

.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.card, .cards > li {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
.goal-row { display: flex; align-items: center; gap: 12px; }
.goal-row .txt { flex: 1; min-width: 0; }
.goal-row .txt b { display: block; overflow-wrap: anywhere; }
.goal-row .txt small { color: var(--muted); }
.answer { display: flex; gap: 8px; }
.answer button, .state {
  width: 42px; height: 42px; padding: 0; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.answer .yes { background: var(--text); color: var(--bg); }
.answer .no { background: transparent; color: var(--text); border: 1.5px solid var(--text); }
.state { width: 32px; height: 32px; font-size: .9rem; }
.state.yes { background: var(--text); color: var(--bg); }
.state.no { border: 1.5px solid var(--muted); color: var(--muted); }
.cards > li.due { border-color: var(--text); }
.cards > li.done-yes, .cards > li.done-no { background: transparent; }
.cards > li.done-no .txt b { color: var(--muted); }
.hint { color: var(--muted); margin: -6px 0 14px; font-size: .9rem; }

.form { display: grid; gap: 12px; margin-bottom: 16px; }
.form label { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
.setting { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.setting-txt { flex: 1; display: grid; gap: 2px; }
.setting-txt small { color: var(--muted); }
.setting input[type="time"] { width: auto; flex: none; }
.edit-row input { flex: 1; min-width: 0; }

/* Pie de página (Ajustes) */
.footer { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); text-align: center; color: var(--muted); font-size: .85rem; }
.footer p { margin: 0 0 14px; }
.footer a { color: inherit; }
.footer p a { white-space: nowrap; }
.footer nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 28px; }
.footer nav a { text-decoration: none; }
.footer nav a:hover { color: var(--text); }

input[type="text"], input[type="time"], input[type="email"], input[type="password"] {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus { outline: 1.5px solid var(--text); outline-offset: 1px; }

.empty, .muted { color: var(--muted); }
.banner {
  background: var(--surface); border: 1px solid var(--text); border-radius: var(--radius); padding: 14px; margin-top: 16px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
}

.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-nav h2 { margin: 18px 0 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; text-align: center; display: grid;
}
.stat span { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: .78rem; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 16px; }
.calendar .dow { font-size: .72rem; color: var(--muted); text-align: center; }
.calendar .day {
  aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: .8rem; background: var(--none); color: var(--text); font-variant-numeric: tabular-nums;
}
.calendar .day.today { outline: 1.5px solid var(--text); }
.lv0 { background: var(--lv0) !important; } .lv1 { background: var(--lv1) !important; }
.lv2 { background: var(--lv2) !important; } .lv3 { background: var(--lv3) !important; }
.lv4 { background: var(--lv4) !important; color: #052e14 !important; }
.legend { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--muted); margin-top: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.none { background: var(--none); margin-left: 8px; }

.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.bars li { display: grid; gap: 4px; }
.bars .lbl { display: flex; justify-content: space-between; font-size: .9rem; gap: 8px; }
.bars .lbl span:first-child { overflow-wrap: anywhere; }
.bars .lbl span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bars .track { height: 8px; background: var(--none); border-radius: 999px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--text); border-radius: 999px; }

.ai { margin-top: 22px; }
.ai-head { display: flex; justify-content: space-between; align-items: center; }
.ai-head h3 { margin: 0; display: flex; align-items: center; gap: 6px; }
.ai-out { margin-top: 10px; white-space: pre-wrap; }
.ai-out p { margin: 0 0 10px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  flex: 1; max-width: 140px; background: none; display: grid; justify-items: center; gap: 3px;
  font-size: 1.15rem; color: var(--muted); padding: 6px;
}
.tabs button span:last-child { font-size: .72rem; }
.tabs button.active { color: var(--text); font-weight: 700; }
.tabs .ic { stroke-width: 1.6; }

/* Pantallas estrechas: los ajustes se apilan */
@media (max-width: 360px) {
  .setting { flex-wrap: wrap; }
  .setting input[type="time"] { width: 100%; }
  .stat span { font-size: 1.25rem; }
}

/* Racha, frase del día */
.streak { display: inline-flex; align-items: center; gap: 6px; font-size: .95rem; padding: 6px 12px; border: 1px solid var(--text); border-radius: 999px; margin: -4px 0 10px; }
.quote { color: var(--muted); font-style: italic; text-align: center; margin: 22px 8px 0; }

/* Objetivos: orden, días, edición */
.move { display: flex; flex-direction: column; margin: -6px 0 -6px -6px; }
.icon-btn.tiny { padding: 2px 6px; font-size: .9rem; }
.icon-btn:disabled { opacity: .25; cursor: default; background: transparent; }
.cards > li.paused .txt { opacity: .55; }
.field { display: grid; gap: 6px; }
.field .label, .form .label { font-size: .9rem; color: var(--muted); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.chip {
  width: 100%; max-width: 44px; aspect-ratio: 1; padding: 0; border-radius: 999px; font-weight: 600; font-size: .9rem; justify-self: start;
  background: transparent; color: var(--muted); border: 1.5px solid var(--border);
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.edit-panel { display: grid; gap: 12px; }
.edit-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.edit-actions .ic { width: 1.1em; height: 1.1em; }

/* Nota al marcar "No" */
.note { margin-top: 10px; font-size: 16px; }

/* Ajustes */
.seg { display: inline-flex; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; flex: none; }
.seg button { border-radius: 0; background: transparent; padding: 8px 10px; font-size: .85rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.setting.stack { flex-direction: column; align-items: stretch; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row button, .share { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.share { width: 100%; margin-top: 18px; }
@media (max-width: 360px) { .seg { width: 100%; } .seg button { flex: 1; } }

/* Cuenta */
.account { display: grid; gap: 12px; margin-bottom: 10px; }
.auth-form { display: grid; gap: 10px; }
.msg { margin: 0; padding: 8px 10px; border: 1px solid var(--text); border-radius: 8px; font-size: .9rem; }
.muted small, small.muted { color: var(--muted); }

/* Copias automáticas */
.backup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.backup-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.backup-list .txt { min-width: 0; }
.backup-list .txt b { display: block; }
.backup-list .txt small { color: var(--muted); }

/* Días anteriores sin marcar, agrupados por día */
.day-group { margin-top: 18px; }
.day-group:first-child { margin-top: 0; }
.day-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 0 2px 8px; font-size: .95rem; }
.day-title b { font-weight: 700; }
.day-title span { color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ---------- Gráficos del mes (blanco y negro: tinta = lo importante, gris = el resto) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chart-card { position: relative; margin-top: 18px; }
.seg-wide { display: flex; width: 100%; }
.seg-wide button { flex: 1; }
#chart-body { margin-top: 14px; min-height: 120px; }
.chart-sub { margin: 0 0 4px; font-size: .85rem; color: var(--muted); }
.chart-delta { display: flex; align-items: center; gap: 4px; margin: 0 0 6px; font-size: .9rem; font-weight: 600; }
.chart-note { margin: 12px 0 0; font-size: .9rem; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; width: max-content; max-width: 250px;
  display: grid; gap: 1px; padding: 7px 10px; border-radius: 10px;
  background: var(--text); color: var(--bg); box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.chart-tip strong { font-size: .95rem; }
.chart-tip span { font-size: .75rem; opacity: .85; }

/* Tira de puntos por objetivo */
.strip { display: grid; gap: 12px; margin-top: 10px; }
.strip-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: .9rem; }
.strip-head span { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dots { display: grid; grid-template-columns: repeat(var(--n), 1fr); height: 26px; touch-action: manipulation; cursor: default; }
.dot { display: flex; align-items: center; justify-content: center; }
.dot::before { content: ""; display: block; width: calc(100% - 3px); max-width: 12px; aspect-ratio: 1; border-radius: 50%; transition: transform .1s; }
.dot.done::before { background: var(--text); }
.dot.miss::before { box-shadow: inset 0 0 0 1.6px var(--text); }
.dot.pending::before { width: 36%; background: var(--muted); }
.dot.none::before { display: none; }
.dot.hot::before { transform: scale(1.35); }
.strip-axis { display: grid; grid-template-columns: repeat(var(--n), 1fr); margin-top: -6px; font-size: .7rem; color: var(--muted); }
.strip-axis span { justify-self: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-key { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--muted); }
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.dot.key { display: inline-flex; width: 12px; height: 12px; }
.dot.key::before { width: 10px; max-width: none; }
.dot.key.pending::before { width: 4px; }

/* Columnas de porcentaje */
.bc { margin-top: 6px; }
.bc-plot { position: relative; height: 132px; margin: 22px 0 0 38px; }
.bc-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--border); }
.bc-grid span { position: absolute; left: -38px; top: -.62em; width: 32px; text-align: right; font-size: .7rem; color: var(--muted); }
.bc-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--cols), 1fr); }
.bc-col { position: relative; display: flex; align-items: flex-end; justify-content: center; height: 100%; padding: 0; border: 0; background: transparent; border-radius: 6px; cursor: pointer; }
.bc-col:focus-visible { outline: 1.5px solid var(--text); outline-offset: 2px; }
.bc-bar { display: block; width: min(60%, 24px); background: var(--muted); border-radius: 4px 4px 0 0; transition: background .1s; }
.bc-bar.hot, .bc-col:hover .bc-bar, .bc-col:focus-visible .bc-bar { background: var(--text); }
.bc-val { position: absolute; left: 50%; transform: translateX(-50%); font-size: .75rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.bc-val.hot { color: var(--text); }
.bc-none { margin-bottom: 2px; color: var(--muted); font-size: .8rem; }
.bc-x { display: grid; grid-template-columns: repeat(var(--cols), 1fr); margin: 6px 0 0 38px; font-size: .72rem; color: var(--muted); text-align: center; }
.bc-x span { white-space: pre-line; line-height: 1.2; }

/* Tabla equivalente */
.chart-table { margin-top: 14px; font-size: .85rem; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.chart-table th, .chart-table td { padding: 5px 4px; border-bottom: 1px solid var(--border); text-align: right; font-weight: 400; font-variant-numeric: tabular-nums; }
.chart-table th[scope="row"], .chart-table tbody th { text-align: left; font-weight: 600; }
.chart-table thead th { color: var(--muted); font-size: .75rem; }
