:root {
  --bg: #f6f3ec; --surface: #fffdf8; --surface2: #efeadf; --text: #221d33; --muted: #6c6680;
  --line: #e1dacb; --accent: #8a5a12; --accent-ink: #fff; --accent-soft: #f3e6c9;
  --mental: #6d4bc4; --animico: #2c6fb0; --fisico: #2f8a5b;
  --fuego: #d4512c; --aire: #c9a227; --agua: #2a86a8; --tierra: #7d5a33;
  --danger: #b33a3a; --ok: #2f8a5b; --shadow: 0 1px 2px rgba(30, 20, 50, .06), 0 4px 16px rgba(30, 20, 50, .05);
  --r: 14px; --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #110f22; --surface: #1b1832; --surface2: #25213f; --text: #ece7f7; --muted: #a29cbb;
    --line: #2f2a4d; --accent: #e0b25a; --accent-ink: #1b1530; --accent-soft: #3a2f22;
    --mental: #a58cf0; --animico: #6fb2ec; --fisico: #6fcf9a;
    --fuego: #f07a52; --aire: #e8c95a; --agua: #5ec0e0; --tierra: #c49a6a;
    --danger: #f07a7a; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #110f22; --surface: #1b1832; --surface2: #25213f; --text: #ece7f7; --muted: #a29cbb;
  --line: #2f2a4d; --accent: #e0b25a; --accent-ink: #1b1530; --accent-soft: #3a2f22;
  --mental: #a58cf0; --animico: #6fb2ec; --fisico: #6fcf9a;
  --fuego: #f07a52; --aire: #e8c95a; --agua: #5ec0e0; --tierra: #c49a6a;
  --danger: #f07a7a; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
.view { max-width: 760px; margin: 0 auto; padding: 16px; }
.page-title { font-size: 1.7rem; margin: .2em 0 .4em; }
.sec { font-size: 1.15rem; margin: 1.4em 0 .6em; display: flex; align-items: center; gap: 8px; }
.card .sec:first-child { margin-top: 0; }
.sub { font-size: 1rem; margin: 1em 0 .4em; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; color: var(--muted); margin: 0 0 4px; display: flex; gap: 8px; align-items: center; }
.lead { font-size: 1.05rem; }
.hint { font-size: .85rem; color: var(--muted); }
.warn { background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); padding: 10px 12px; border-radius: 10px; font-size: .9rem; }
.empty { color: var(--muted); padding: 12px; list-style: none; }
.cap { text-transform: capitalize; }
.back { display: inline-block; text-decoration: none; color: var(--muted); margin-bottom: 8px; font-size: .9rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin: 12px 0; }
section > .card { margin: 8px 0; }

/* Barra superior */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 8px 16px 10px; }
.topbar > * { max-width: 728px; margin-left: auto; margin-right: auto; }
.tb-row { display: flex; align-items: center; justify-content: space-between; }
.brand { font-family: var(--serif); font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.sigil { color: var(--accent); }
.tb-progress { display: block; text-decoration: none; margin-top: 4px; }
.tb-lbl { display: flex; justify-content: space-between; font-size: .8rem; margin: 2px 0; }
.tb-lbl.small { font-size: .7rem; color: var(--muted); }
.tb-sug { display: flex; gap: 6px; font-size: .8rem; text-decoration: none; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sug span { color: var(--accent); }

.bar { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin: 6px 0; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--mental))); border-radius: inherit; transition: width .4s; }
.bar.thin { height: 4px; margin: 4px 0; }

/* Barra de pestañas */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; font-size: .72rem; color: var(--muted); padding: 4px 0; border-radius: 10px; }
.tabbar a span { font-size: 1.25rem; line-height: 1; }
.tabbar a.on { color: var(--accent); background: var(--accent-soft); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; font: inherit; font-size: .95rem; cursor: pointer; text-decoration: none; min-height: 40px; background: var(--surface2); color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: 4px 10px; min-height: 32px; font-size: .85rem; }
.btn.big { padding: 12px 22px; font-size: 1.05rem; width: 100%; }
.btn.round { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.rec { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 25%, transparent); } }
.icon-btn { background: none; border: 0; color: inherit; font-size: 1.2rem; cursor: pointer; padding: 6px; text-decoration: none; border-radius: 8px; }
.icon-btn.sm { font-size: .85rem; padding: 2px 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Formularios */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; }
textarea { resize: vertical; line-height: 1.5; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; margin: 8px 0; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; }
label.check input { width: auto; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.voice-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.voice-status { font-size: .85rem; color: var(--muted); flex: 1; min-width: 0; }
.note-form > input { font-family: var(--serif); font-size: 1.15rem; margin-bottom: 8px; }
.note-form textarea { margin-top: 8px; min-height: 240px; }

/* Hoy */
.hero h1 { font-size: 1.45rem; margin: 0 0 4px; }
.hero .eyebrow { text-transform: capitalize; letter-spacing: .02em; }
.stats { display: flex; gap: 10px; margin: 12px 0 6px; flex-wrap: wrap; }
.stats > div { flex: 1; min-width: 80px; background: var(--surface2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.stats b { font-size: 1.2rem; font-family: var(--serif); }
.stats span { font-size: .75rem; color: var(--muted); }
.stats.small b { font-size: 1rem; }
.goals, .sugs, .step-list, .ex-list, .note-list, .art-list, .hist { list-style: none; padding: 0; margin: 0; }
.goal { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin: 8px 0; }
.goal.done { opacity: .65; }
.goal.done b { text-decoration: line-through; }
.chk { width: 28px; height: 28px; flex: none; border-radius: 50%; border: 2px solid var(--accent); background: transparent; color: var(--accent-ink); cursor: pointer; font-weight: 700; }
.goal.done .chk { background: var(--accent); }
.goal-body { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; }
.goal-top { display: flex; gap: 8px; align-items: center; }
.tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; padding: 1px 7px; border-radius: 99px; font-weight: 600; font-family: system-ui, sans-serif; }
.b-mental { color: var(--mental); background: color-mix(in srgb, var(--mental) 14%, transparent); }
.b-animico { color: var(--animico); background: color-mix(in srgb, var(--animico) 14%, transparent); }
.b-fisico { color: var(--fisico); background: color-mix(in srgb, var(--fisico) 14%, transparent); }
.sugs li a { display: flex; gap: 10px; align-items: flex-start; text-decoration: none; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); margin: 6px 0; font-size: .92rem; }
.sug-i { color: var(--accent); font-weight: 700; flex: none; width: 1.2em; text-align: center; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.quick .btn { flex: 1; min-width: 140px; }

/* Pasos */
.step-card { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.step-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.roman { font-family: var(--serif); font-size: 1.5rem; color: var(--accent); width: 52px; text-align: center; flex: none; }
.sc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sc-pct { font-weight: 600; font-size: .9rem; flex: none; }
.ex-card { display: flex; align-items: center; gap: 12px; text-decoration: none; justify-content: space-between; }
.ex-card > span:first-child { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chip { font-size: .72rem; padding: 2px 8px; border-radius: 99px; white-space: nowrap; background: var(--surface2); color: var(--muted); flex: none; }
.s-progress { background: color-mix(in srgb, var(--animico) 16%, transparent); color: var(--animico); }
.s-review { background: color-mix(in srgb, var(--aire) 20%, transparent); color: color-mix(in srgb, var(--aire) 70%, var(--text)); }
.s-mastered { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.ex-status { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rings { display: flex; gap: 12px; justify-content: space-around; margin: 14px 0; flex-wrap: wrap; }
.ring-mini { --c: var(--accent); width: 96px; height: 96px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface2) 0); display: grid; place-items: center; }
.ring-mini > div { width: 76px; height: 76px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-mini b { font-size: 1.05rem; }
.ring-mini small { font-size: .7rem; color: var(--muted); }
.r-mental { --c: var(--mental); } .r-animico { --c: var(--animico); } .r-fisico { --c: var(--fisico); }
.how { padding-left: 1.2em; margin: 0; }
.how li { margin: 4px 0; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 14px 0 0; font-size: .92rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.hist li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.hist li span:first-child { min-width: 90px; color: var(--muted); }
.hist .grow { flex: 1; min-width: 0; }

/* Espejos */
.mirror-add { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 6px; }
.mirror-add input, .mirror-add select { padding: 7px 8px; font-size: .88rem; }
.mirrors-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.mirror-el { border-left: 4px solid var(--c); background: var(--surface2); border-radius: 10px; padding: 8px 10px; }
.mirror-el h3 { margin: 0 0 4px; font-size: 1rem; color: var(--c); }
.mirror-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mirror-cols h4 { margin: 0; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mirror-cols ul { list-style: none; padding: 0; margin: 2px 0; }
.mirror-cols li { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; gap: 4px; }
.mirror-cols li.transmuted span:first-child { text-decoration: line-through; opacity: .6; }
.mi-act { display: flex; flex: none; }

/* Diario */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 6px 14px; border-radius: 99px; text-decoration: none; border: 1px solid var(--line); font-size: .9rem; }
.tabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.filters { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-bottom: 10px; }
.note-item { display: flex; flex-direction: column; text-decoration: none; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin: 8px 0; }
.excerpt { font-size: .88rem; color: var(--muted); margin-top: 4px; white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Biblioteca */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip-link { padding: 5px 12px; border-radius: 99px; text-decoration: none; border: 1px solid var(--line); font-size: .85rem; background: var(--surface); }
.chip-link.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.art-card { display: flex; flex-direction: column; text-decoration: none; gap: 2px; }
.prose p, .prose li { font-size: 1.02rem; }
.prose ul { padding-left: 1.2em; }

/* Tests */
.sticky-progress { position: sticky; top: 112px; z-index: 5; background: var(--bg); padding: 6px 0; font-size: .85rem; }
.titem { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 10px 0; background: var(--surface); }
.titem legend { font-weight: 500; padding: 0 4px; }
.likert, .opts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.likert label, .opts label { flex-direction: row; margin: 0; flex: 1; min-width: 80px; }
.likert input, .opts input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.likert span, .opts span { flex: 1; text-align: center; padding: 7px 6px; border: 1px solid var(--line); border-radius: 9px; font-size: .8rem; cursor: pointer; }
.likert input:checked + span, .opts input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.likert input:focus-visible + span, .opts input:focus-visible + span { outline: 2px solid var(--accent); }
.mchart { margin: 10px 0; }
.mrow { display: grid; grid-template-columns: 60px 1fr 64px; align-items: center; gap: 10px; margin: 6px 0; }
.mname { font-weight: 600; color: var(--c); font-size: .9rem; }
.mval { font-size: .78rem; color: var(--muted); text-align: right; }
.mbar { height: 9px; border-radius: 99px; background: var(--surface2); overflow: hidden; margin: 2px 0; }
.mbar span { display: block; height: 100%; }
.mbar.white span { background: color-mix(in srgb, var(--c) 55%, transparent); }
.mbar.black span { background: var(--c); }

/* Progreso */
.heat { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--surface2); }
.heat .h1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface2)); }
.heat .h2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface2)); }
.heat .h3 { background: color-mix(in srgb, var(--accent) 80%, var(--surface2)); }
.heat .h4 { background: var(--accent); }
.ptable { width: 100%; border-collapse: collapse; font-size: .85rem; }
.ptable th, .ptable td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--line); }
.ptable td:first-child a { font-family: var(--serif); font-weight: 600; color: var(--accent); text-decoration: none; }
.ptable tr.cur { background: var(--accent-soft); }
.ptable td:last-child { text-align: right; white-space: nowrap; }

/* Overlay / cronómetro */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 8, 25, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { position: relative; background: var(--surface); width: 100%; max-width: 560px; max-height: 94vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { margin: 0 0 8px; padding-right: 30px; }
.close { position: absolute; top: 12px; right: 12px; }
.dur-row { display: flex; align-items: center; gap: 10px; }
.dur { font-size: 1.6rem; font-family: var(--serif); min-width: 2ch; text-align: center; }
.ring-wrap { position: relative; width: min(260px, 70vw); margin: 10px auto; }
.ring { width: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface2); stroke-width: 6; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.time { font-size: 2.6rem; font-variant-numeric: tabular-nums; font-family: var(--serif); }
.phase { color: var(--muted); font-size: .85rem; }
.timer-ctrl { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.timer-ctrl .btn { flex: 1; min-width: 120px; }
.quality { border: 0; padding: 0; margin: 8px 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.quality legend { font-size: .9rem; margin-bottom: 4px; }
.q { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font: inherit; cursor: pointer; }
.q.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: .9rem; z-index: 60; transition: .25s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .mirror-add { grid-template-columns: 1fr 1fr; }
  .mirror-add input { grid-column: 1 / -1; }
  .mirrors-grid { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .meta { grid-template-columns: 1fr; gap: 2px; }
  .meta dd { margin-bottom: 8px; }
  .filters { grid-template-columns: 1fr; }
  .likert label { min-width: 56px; }
  .likert span { font-size: .72rem; padding: 7px 2px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
