/* Curso Inglés — estilos.
   Idea visual: el mapa de temas es un plano de metro (cada rama gramatical es una línea y
   cada tema una estación). El resto de la interfaz se mantiene sobria para que destaque eso
   y los propios ejercicios, que imitan una hoja de respuestas de examen. */

:root {
  --bg: #edf0f4;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --ink: #1d2a44;
  --muted: #5b6680;
  --line: #cbd2de;
  --accent: #2b4fd8;
  --accent-ink: #ffffff;
  --accent-soft: #e3e9ff;
  --coin: #b97f00;
  --coin-bg: #fff3d1;
  --ok: #23794a;
  --ok-bg: #e3f2e8;
  --bad: #b3261e;
  --bad-bg: #fbe7e5;

  --l-presente: #2b4fd8;
  --l-pasado: #7c3aed;
  --l-condicionales: #0e8a7a;
  --l-pasiva: #c26a00;
  --l-indirecto: #c0267a;
  --l-modales: #4d7c0f;
  --l-sueltos: #64748b;

  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible', system-ui, sans-serif;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --maxw: 760px;
  --tabbar-h: 64px;
}

body[data-theme='theme-ocean'] { --bg: #e4f1f3; --surface-2: #f2f9fa; --ink: #0f2f3a; --muted: #4c6670; --line: #bcd6dc; --accent: #0e7490; --accent-soft: #d5eef3; }
body[data-theme='theme-forest'] { --bg: #edf1e5; --surface-2: #f6f8f1; --ink: #1f2a14; --muted: #5a654b; --line: #cdd6bd; --accent: #3f6212; --accent-soft: #e4eed2; }
body[data-theme='theme-sunset'] { --bg: #f6ebe4; --surface-2: #fbf5f1; --ink: #3a1f14; --muted: #6f5245; --line: #e2cbbf; --accent: #c2410c; --accent-soft: #fde3d4; }
body[data-theme='theme-night'] {
  --bg: #121829; --surface: #1c2438; --surface-2: #222c44; --ink: #e7ebf5; --muted: #9aa5bf; --line: #34405e;
  --accent: #8ea2ff; --accent-ink: #121829; --accent-soft: #28325a; --coin: #f2c14e; --coin-bg: #3a3120;
  --ok: #6fd39a; --ok-bg: #173826; --bad: #ff8a80; --bad-bg: #3b1a1a;
  --l-presente: #8ea2ff; --l-pasado: #b794ff; --l-condicionales: #4fd1c0; --l-pasiva: #f4a340; --l-indirecto: #f472b6; --l-modales: #a3d65c; --l-sueltos: #94a3b8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
@media (min-width: 900px) { body { padding-bottom: 32px; } }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* ---------- barra superior y navegación ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-family: var(--font-display); font-weight: 800; font-size: 14px;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.nav { display: none; gap: 4px; margin-left: 12px; }
.nav a, .tabbar a { text-decoration: none; color: var(--muted); font-weight: 700; }
.nav a { padding: 8px 12px; border-radius: 999px; }
.nav a[aria-current='page'] { background: var(--surface); color: var(--ink); }
.wallet { margin-left: auto; display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: .95rem; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.pill.coins { background: var(--coin-bg); border-color: transparent; color: var(--coin); }
.avatar { font-size: 1.4rem; line-height: 1; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .78rem; }
.tabbar a span { font-size: 1.25rem; line-height: 1; }
.tabbar a[aria-current='page'] { color: var(--accent); }
@media (min-width: 900px) { .nav { display: flex; } .tabbar { display: none; } }

main { max-width: var(--maxw); margin: 0 auto; padding: 24px 16px 40px; outline: none; }
main:focus, main:focus-visible { outline: none; }
.loading { color: var(--muted); }

/* ---------- piezas comunes ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: 12px; }
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); padding-inline: 8px; }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .92rem; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-weight: 700; }

/* ---------- inicio ---------- */
.hello { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.hello .avatar { font-size: 2.6rem; }
.hello p { margin: 0; }
.today { background: var(--ink); color: var(--bg); border: 0; }
.today h2 { font-size: 1.7rem; margin-bottom: .2em; }
.today .muted { color: color-mix(in srgb, var(--bg) 72%, transparent); }
.today .btn { background: var(--bg); color: var(--ink); margin-top: 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.6rem; line-height: 1.1; }
.stat span { font-size: .82rem; line-height: 1.3; display: block; color: var(--muted); }

/* ---------- mapa (plano de metro) ---------- */
.lines { display: grid; gap: 14px; }
@media (min-width: 700px) { .lines { grid-template-columns: 1fr 1fr; } }
.line { --c: var(--l-sueltos); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 16px 8px; }
.line-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.line-badge { width: 28px; height: 10px; border-radius: 5px; background: var(--c); }
.line-head h2 { margin: 0; font-size: 1.15rem; }
.stations { list-style: none; margin: 0; padding: 0; position: relative; }
.stations::before { content: ''; position: absolute; left: 13px; top: 18px; bottom: 18px; width: 6px; border-radius: 3px; background: var(--c); }
.line.loose .stations::before { display: none; }
.station a, .station div { position: relative; display: flex; align-items: center; gap: 14px; padding: 9px 4px; text-decoration: none; color: var(--ink); border-radius: var(--r-sm); }
.station a:hover { background: var(--surface-2); }
.dot { position: relative; z-index: 1; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--surface); border: 5px solid var(--c); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.station.done .dot { background: var(--c); color: var(--surface); }
.station.locked .dot, .station.soon .dot { border-color: var(--line); }
.station.locked .name, .station.soon .name { color: var(--muted); }
.station.skipped .dot { border-style: dashed; }
.station .name { font-weight: 700; line-height: 1.25; }
.station .why { display: block; font-weight: 400; font-size: .85rem; color: var(--muted); }

/* ---------- tema ---------- */
.status { display: inline-block; font-weight: 700; font-size: .9rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.status.done { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

/* ---------- lección ---------- */
.lesson h2 { margin-top: 1.2em; }
.lesson ul { padding-left: 1.2em; margin: 0 0 1em; }
.lesson li { margin-bottom: .35em; }
.form-block { background: var(--surface-2); border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 10px; }
.form-block h3 { margin-bottom: .3em; }
.form-block ul { margin: 0; }
.example { padding: 10px 0; border-bottom: 1px solid var(--line); }
.example:last-child { border-bottom: 0; }
.example .en { font-size: 1.12rem; font-weight: 700; }
.example .es { color: var(--muted); font-size: .95rem; }
.err { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.err:last-child { border-bottom: 0; }
.err .wrong { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 2px; }
.err .right { color: var(--ok); font-weight: 700; }
.err .why { color: var(--muted); font-size: .92rem; }
.tip { border-left: 6px solid var(--accent); padding: 8px 14px; background: var(--accent-soft); border-radius: 0 var(--r-md) var(--r-md) 0; }

/* ---------- sesión ---------- */
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 18px; list-style: none; padding: 0; counter-reset: s; }
.steps li { font-size: .74rem; color: var(--muted); text-align: center; }
.steps li::before { counter-increment: s; content: counter(s); display: block; margin: 0 auto 4px; width: 100%; height: 6px; border-radius: 3px; background: var(--line); font-size: 0; }
.steps li.on::before, .steps li.past::before { background: var(--accent); }
.steps li.on { color: var(--ink); font-weight: 700; }
.counter { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }

/* ---------- ejercicio: hoja de respuestas ---------- */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 20px; }
.sheet .kind { display: inline-block; font-size: .82rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 3px 10px; border-radius: 999px; margin-bottom: 12px; }
.sheet .kind.ai { color: var(--coin); background: var(--coin-bg); }
.sheet .ask { color: var(--muted); margin-bottom: 8px; }
.sentence { font-size: 1.22rem; line-height: 1.9; margin-bottom: 16px; }
.blank {
  font: inherit; color: var(--ink); background: transparent;
  border: 0; border-bottom: 2px dashed var(--accent); border-radius: 0;
  padding: 0 4px; min-width: 8ch; width: 12ch; max-width: 100%;
}
.blank:focus { outline: none; border-bottom-style: solid; background: var(--accent-soft); }
textarea.free {
  width: 100%; font: inherit; font-size: 1.1rem; color: var(--ink); background: var(--surface-2);
  border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; min-height: 92px; resize: vertical;
}
textarea.free:focus { outline: none; border-color: var(--accent); }
.wrongline { font-size: 1.15rem; padding: 10px 14px; background: var(--bad-bg); border-radius: var(--r-md); margin-bottom: 12px; }
.es-line { font-size: 1.15rem; font-weight: 700; margin-bottom: 12px; }
.keyword {
  display: inline-block; font-family: var(--font-display); font-weight: 800; letter-spacing: .04em;
  border: 2.5px solid var(--ink); padding: 2px 12px; border-radius: 6px; margin: 4px 0 12px; transform: rotate(-1.5deg);
}
.options { display: grid; gap: 10px; margin-bottom: 8px; }
.option {
  appearance: none; font: inherit; text-align: left; cursor: pointer; color: var(--ink);
  display: flex; gap: 12px; align-items: center; min-height: 52px; padding: 10px 14px;
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: var(--r-md);
}
.option .letter { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line); font-weight: 700; font-size: .9rem; }
.option:hover:not(:disabled) { border-color: var(--accent); }
.option.correct { background: var(--ok-bg); border-color: var(--ok); }
.option.wrong { background: var(--bad-bg); border-color: var(--bad); }
.option:disabled { cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; min-height: 48px; }
.chip { appearance: none; font: inherit; font-weight: 700; cursor: pointer; padding: 8px 14px; border-radius: var(--r-sm); background: var(--surface-2); border: 1.5px solid var(--line); color: var(--ink); }
.chip:disabled { opacity: .3; }
.built { border-bottom: 2px dashed var(--accent); padding: 8px 0; }
.built:empty::before { content: 'Toca las palabras en orden'; color: var(--muted); font-weight: 400; }
.feedback { margin-top: 16px; border-radius: var(--r-md); padding: 14px 16px; }
.feedback.ok { background: var(--ok-bg); }
.feedback.no { background: var(--bad-bg); }
.feedback .verdict { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.no .verdict { color: var(--bad); }
.feedback .model { font-weight: 700; margin: 4px 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- resumen ---------- */
.big-score { font-family: var(--font-display); font-weight: 800; font-size: 3.4rem; line-height: 1; }

/* ---------- tienda ---------- */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.item .look { font-size: 2.2rem; line-height: 1; height: 44px; display: flex; align-items: center; }
.swatch { width: 44px; height: 44px; border-radius: 50%; }
.item .price { color: var(--coin); font-weight: 700; }
.item .fact { font-size: .88rem; color: var(--muted); }
.item.postcard { border-style: dashed; }

/* ---------- aviso flotante ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); font-weight: 700; padding: 10px 18px; border-radius: 999px;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ---------- inicio de sesión ---------- */
[hidden] { display: none !important; }
.login label { display: block; font-weight: 700; }
.login input {
  display: block; width: 100%; font: inherit; font-size: 1.1rem; color: var(--ink); background: var(--surface-2);
  border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 12px 14px;
}
.login input:focus { outline: none; border-color: var(--accent); }
.login [role='alert']:not(:empty) { color: var(--bad); font-weight: 700; margin: 0; }
