/* Olimpia — warm paper, navy ink, medal orange. Light and dark follow the system. */
:root {
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-2: #efe9db;
  --ink: #14213d;
  --muted: #5d6781;
  --line: #ddd5c3;
  --accent: #e4690b;
  --accent-ink: #ffffff;
  --accent-soft: #fde6d0;
  --good: #1f8a52;
  --good-soft: #dcf2e4;
  --bad: #c62a3a;
  --bad-soft: #fbe0e2;
  --warn-soft: #fff1c9;
  --gold: #d99a00;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 33, 61, 0.06), 0 8px 24px rgba(20, 33, 61, 0.06);
  --nav-width: 216px;
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-math: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1524;
    --surface: #172037;
    --surface-2: #1f2a46;
    --ink: #eef1f8;
    --muted: #9ea9c4;
    --line: #2c3857;
    --accent: #ff8f3a;
    --accent-ink: #1a1206;
    --accent-soft: #3a2a1a;
    --good: #4ccb86;
    --good-soft: #163526;
    --bad: #ff6f7d;
    --bad-soft: #3d1b21;
    --warn-soft: #3a3115;
    --gold: #f2c14e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 750; }
h3 { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
h4 { font-size: 1rem; }
p { margin: 0 0 0.8em; }
a { color: var(--accent); text-underline-offset: 3px; }
small { font-size: 0.82em; }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.75rem; font-weight: 700; color: var(--accent); margin-bottom: 0.3em; }
.center { text-align: center; justify-content: center; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); min-height: 100vh; }
.nav {
  position: sticky; top: 0; align-self: start; height: 100vh;
  padding: 22px 14px; display: flex; flex-direction: column; gap: 18px;
  background: var(--ink); color: #f5f1e8;
}
@media (prefers-color-scheme: dark) { .nav { background: #0a0f1b; border-right: 1px solid var(--line); } }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 0 8px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 1.25rem;
}
.brand-name { font-weight: 800; font-size: 1.3rem; letter-spacing: -0.02em; }
.nav-items { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: #c9d0e2; text-decoration: none; font-weight: 600; font-size: 0.95rem;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { width: 20px; text-align: center; }
.view { padding: 30px clamp(16px, 4vw, 48px) 80px; outline: none; }
.page { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.page-head h1 { margin-bottom: 0.15em; }
.page-head p { margin: 0; }

@media (max-width: 820px) {
  .shell { display: block; }
  .nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .brand { display: none; }
  .nav-items { flex-direction: row; gap: 2px; }
  .nav-item { flex-direction: column; gap: 0; padding: 6px 12px; font-size: 0.68rem; min-width: 62px; }
  .nav-icon { font-size: 1.1rem; }
  .view { padding: 20px 16px 110px; }
}

/* ---------- surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(16px, 3vw, 26px); box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
}
.tile b { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 0.85rem; }

/* ---------- buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  padding: 11px 18px; border-radius: 999px; border: 2px solid var(--line);
  background: var(--surface); color: var(--ink); min-height: 44px;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 6px 14px; min-height: 36px; font-size: 0.88rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .choice {
  font: inherit; font-weight: 600; cursor: pointer; padding: 9px 14px; min-height: 42px;
  border-radius: 999px; border: 2px solid var(--line); background: var(--surface); color: var(--ink);
}
.chip[aria-pressed="true"], .choice[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip:disabled, .choice:disabled { cursor: default; opacity: 0.8; }

/* ---------- bars, dots, status ---------- */
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; min-width: 60px; flex: 1; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s ease; }
.bar.gold span { background: var(--gold); }
.dots { display: inline-flex; gap: 4px; align-items: center; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.status { font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.status-learning { background: var(--accent-soft); color: var(--accent); }
.status-solid { background: var(--good-soft); color: var(--good); }
.status-mastered { background: var(--gold); color: #241800; }

/* ---------- home ---------- */
.hero {
  display: flex; gap: 24px; align-items: center; justify-content: space-between;
  background: var(--ink); color: #f5f1e8; border-radius: calc(var(--radius) + 6px); padding: clamp(20px, 4vw, 34px);
}
@media (prefers-color-scheme: dark) { .hero { background: var(--surface-2); color: var(--ink); } }
.hero h1 { margin-bottom: 0.2em; }
.hero .eyebrow { color: #ffb679; }
.countdown { font-size: 1.05rem; margin-bottom: 0.6em; }
.countdown b { font-size: 1.5rem; color: #ffb679; font-weight: 800; }
.phase { font-size: 0.93rem; opacity: 0.88; max-width: 52ch; margin: 0; }
.ring-wrap { flex: 0 0 auto; width: clamp(110px, 22vw, 150px); }
.ring { width: 100%; height: auto; display: block; }
.ring-track { fill: none; stroke: rgba(255, 255, 255, 0.16); stroke-width: 10; }
.ring-value { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.ring-number { font-size: 26px; font-weight: 800; fill: currentColor; font-family: var(--font); }
.ring-label { font-size: 10px; fill: currentColor; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--font); }
@media (max-width: 520px) { .hero { flex-direction: column; align-items: flex-start; } .ring-wrap { align-self: center; } }

.mission { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mission-step {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
}
.mission-step.done { opacity: 0.72; }
.check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 800; color: #fff; }
.mission-step.done .check { background: var(--good); border-color: var(--good); }
.mission-text { display: flex; flex-direction: column; min-width: 0; }
.mission-text span { font-size: 0.88rem; }

/* ---------- lists ---------- */
.plain-list { margin: 0 0 0.6em; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.skill-list, .history, .error-list, .kind-list, .method-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.skill-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto 110px; gap: 12px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; border-radius: 8px;
}
.skill-list li:last-child .skill-row { border-bottom: 0; }
.skill-row:hover { background: var(--surface-2); }
.skill-title { font-weight: 650; }
@media (max-width: 600px) { .skill-row { grid-template-columns: minmax(0, 1fr) auto; } .skill-row .dots { display: none; } .skill-row .bar { grid-column: 1 / -1; } }
.unit-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; margin-right: 10px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.unit-average { float: right; font-weight: 600; font-size: 0.95rem; }
.history li { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(60px, 1fr) auto auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.error-list li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.error-list li:last-child, .kind-list li:last-child { border-bottom: 0; }
.kind-list li { display: flex; flex-direction: column; padding: 9px 0; border-bottom: 1px solid var(--line); }
.method-list { gap: 12px; padding: 0; }
.method-list li { display: flex; flex-direction: column; gap: 2px; padding-left: 14px; border-left: 3px solid var(--accent); }
.set-title { margin: 14px 0 10px; }
.format-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

/* ---------- problem ---------- */
.problem-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.tag { font-size: 0.74rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag-nuevo { background: var(--accent-soft); color: var(--accent); }
.tag-error, .tag-refuerzo { background: var(--bad-soft); color: var(--bad); }
.tag-reto { background: var(--gold); color: #241800; }
.tag-repaso { background: var(--good-soft); color: var(--good); }
.skill-name { font-weight: 650; font-size: 0.92rem; color: var(--muted); }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); font-size: 0.95rem; }
.timer.big { font-size: 1.5rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
.timer.low { color: var(--bad); border-color: var(--bad); }
.statement { font-family: var(--font-math); font-size: 1.14rem; line-height: 1.65; }
.statement ul, .statement ol { padding-left: 1.3em; margin: 0 0 0.8em; }
.statement .math { text-align: center; font-size: 1.35rem; margin: 0.6em 0; }
.statement .quote { margin: 0.3em 0 0.3em 0.6em; padding-left: 12px; border-left: 3px solid var(--line); }
.figure { margin: 6px 0 14px; overflow-x: auto; }
.fig { max-width: 100%; height: auto; color: var(--ink); display: block; }
.answer-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.answer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.answer-row.select { align-items: flex-start; }
.answer-label { font-weight: 700; min-width: 2ch; }
.answer-input {
  font: inherit; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center;
  width: 9ch; padding: 9px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink);
}
.answer-input:focus { border-color: var(--accent); outline: none; }
.answer-unit { color: var(--muted); font-weight: 600; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.is-right .answer-input { border-color: var(--good); background: var(--good-soft); }
.is-wrong .answer-input { border-color: var(--bad); background: var(--bad-soft); }
.is-right .choice[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #fff; }
.is-wrong .choice[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.hints { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.hint { margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); }
.note { margin: 12px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.note.good { background: var(--good-soft); }
.note.bad { background: var(--bad-soft); }
.note.warn { background: var(--warn-soft); }
.solution, .classify { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.steps { padding-left: 1.3em; margin: 0 0 0.8em; display: flex; flex-direction: column; gap: 6px; }
.steps li::marker { font-weight: 800; color: var(--accent); }
.answer-final { font-size: 1.05rem; }
.key-idea, .advice:not(:empty) { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); margin: 10px 0 0; }
.session-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; }

/* ---------- lesson ---------- */
.lesson .idea { font-size: 1.12rem; font-weight: 600; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin: 18px 0; }
.traps { padding-left: 1.2em; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.traps li::marker { color: var(--bad); }
.example { padding: 16px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); }

/* ---------- exam ---------- */
.exam { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.exam-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.exam-head h1 { margin-bottom: 0.1em; }
.exam-head p { margin: 0; }
.exam-dots { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.exam-dot {
  font: inherit; font-weight: 800; width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
}
.exam-dot.answered { background: var(--good-soft); border-color: var(--good); }
.exam-dot.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.exam-dots .btn { margin-left: auto; }
.review { display: flex; flex-direction: column; gap: 10px; }
.review-item { padding: 0; }
.review-item summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 14px 18px; list-style: none; }
.review-item summary::-webkit-details-marker { display: none; }
.review-item[open] summary { border-bottom: 1px solid var(--line); }
.review-item > :not(summary) { margin: 16px 18px; }
.review-item .official-body > .card { border: 0; box-shadow: none; padding: 0; background: transparent; }
.review-title { font-weight: 700; }
.mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface-2); color: var(--muted); }
.review-item.ok .mark { background: var(--good); color: #fff; }
.review-item.ko .mark { background: var(--bad); color: #fff; }

/* ---------- progress ---------- */
.activity { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; height: 120px; align-items: end; }
.activity-day { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.activity-bar { width: 100%; min-height: 3px; border-radius: 6px 6px 2px 2px; background: var(--accent); opacity: 0.85; }
.activity-day small { color: var(--muted); }
.activity-day.today small { color: var(--accent); font-weight: 800; }

/* ---------- sprint ---------- */
.sprint-question { font-family: var(--font-math); font-size: clamp(2.2rem, 9vw, 3.6rem); font-weight: 700; margin: 0.2em 0 0.4em; }
.sprint-input { width: 8ch; font-size: 1.8rem; }
.sprint-score b { font-size: 3rem; font-weight: 800; color: var(--accent); }
.flash-good { animation: flash-good 0.35s ease; }
.flash-bad { animation: flash-bad 0.35s ease; }
@keyframes flash-good { from { color: var(--good); } to { color: inherit; } }
@keyframes flash-bad { from { color: var(--bad); } to { color: inherit; } }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 700; }
.field { font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); max-width: 320px; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media print { .nav, .actions, .exam-dots { display: none !important; } .shell { display: block; } .card { box-shadow: none; break-inside: avoid; } }

/* ---------- tricks ---------- */
.stars { display: inline-flex; gap: 2px; font-size: 1.15rem; line-height: 1; }
.stars i { font-style: normal; color: var(--line); }
.stars i.on { color: var(--gold); }
.trick-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; border-radius: 8px;
}
.skill-list li:last-child .trick-row { border-bottom: 0; }
.trick-row:hover { background: var(--surface-2); }
.trick-line { margin: 8px 0 0; }
.legend { margin-top: 12px; }
.choices.column { flex-direction: column; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.choice.wide { border-radius: 14px; text-align: left; width: 100%; }
.choice.right { background: var(--good-soft); border-color: var(--good); color: var(--ink); }
.choice.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--ink); }
