:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #5d6470;
  --line: #dde1e7;
  --accent: #1f5fbf;
  --accent-soft: #e6eefb;
  --ok: #1d7a43;
  --ok-soft: #e5f5eb;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --warn-soft: #fff6dd;
  --radius: 10px;
  --bar-h: 64px;
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
/* tema oscuro: el del sistema, salvo que se elija otro con el botón (data-theme en <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c;
    --card: #1d2128;
    --text: #e6e8eb;
    --muted: #9aa2ad;
    --line: #2f353f;
    --accent: #6ea2ff;
    --accent-soft: #1d2a42;
    --ok: #5fcf8a;
    --ok-soft: #173325;
    --bad: #ff8a80;
    --bad-soft: #3a1c1b;
    --warn-soft: #3a3220;
  }
  /* los esquemas son PNG con fondo transparente y trazo negro */
  :root:not([data-theme="light"]) .q-text img, :root:not([data-theme="light"]) .answers img, :root:not([data-theme="light"]) .review img, :root:not([data-theme="light"]) .theory img { background: #fff; border-radius: 4px; padding: 4px; }
}
:root[data-theme="dark"] {
  --bg: #14171c;
  --card: #1d2128;
  --text: #e6e8eb;
  --muted: #9aa2ad;
  --line: #2f353f;
  --accent: #6ea2ff;
  --accent-soft: #1d2a42;
  --ok: #5fcf8a;
  --ok-soft: #173325;
  --bad: #ff8a80;
  --bad-soft: #3a1c1b;
  --warn-soft: #3a3220;
}
:root[data-theme="dark"] .q-text img, :root[data-theme="dark"] .answers img, :root[data-theme="dark"] .review img, :root[data-theme="dark"] .theory img { background: #fff; border-radius: 4px; padding: 4px; }

* { 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;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); }
h1 { margin: 8px 0 4px; font-size: 1.5rem; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.error { color: var(--bad); }

/* ---------- cabecera ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 16px; height: calc(52px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top); /* app instalada: debajo de la barra de estado / notch */
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
}
.brand { color: var(--text); font-weight: 700; text-decoration: none; white-space: nowrap; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs a {
  display: flex; align-items: center; padding: 0 12px; text-decoration: none; color: var(--muted);
  border-bottom: 3px solid transparent; font-weight: 600;
}
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

main { max-width: 860px; margin: 0 auto; padding: 16px; }

/* ---------- usuario ---------- */
.theme-btn { margin-left: auto; font-size: 1.15rem; padding: 6px; line-height: 1; }
.user-menu { position: relative; margin-left: 4px; }
.user-btn { color: var(--text); font-weight: 600; white-space: nowrap; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 200px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15); padding: 6px; display: grid; gap: 4px;
}
.dropdown button { text-align: left; border: 0; }
.dd-user { padding: 6px 16px 8px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.dropdown button:hover { background: var(--accent-soft); }

.auth-card { max-width: 420px; margin: 24px auto; }
.auth-card h1 { font-size: 1.3rem; }
.auth-tabs { display: flex; gap: 6px; margin: 16px 0; }
.auth-tabs button { flex: 1; }
.auth-tabs button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
form label { display: grid; gap: 4px; margin-bottom: 12px; font-weight: 600; font-size: .92rem; }
form label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; }
form input:not([type=checkbox]):not([type=radio]) {
  font: inherit; padding: 10px 12px; min-height: 44px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%;
}
form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
form .big { margin-top: 8px; }
.small { font-size: .85rem; }
.narrow { max-width: 420px; }
.pill.small { font-size: .7rem; padding: 1px 8px; vertical-align: middle; }

.user-row .row-actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.danger:hover { background: var(--bad-soft); }
#new-user form { margin-top: 12px; }

/* ---------- controles ---------- */
button, select {
  font: inherit; padding: 10px 16px; border-radius: var(--radius); min-height: 44px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.big { margin-top: 24px; padding: 12px 28px; font-size: 1.05rem; width: 100%; min-height: 52px; }
button.link { border: 0; background: none; color: var(--muted); padding: 6px 0; min-height: 0; }
button.small { min-height: 0; padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .45; cursor: default; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- cabecera de inicio: la estación, de día (tema claro) o de noche (tema oscuro) ---------- */
.hero {
  --hs-sky-1: #6fb6ec; --hs-sky-2: #addaf6; --hs-sky-3: #e6f4fb;
  --hs-glow: #ffffff; --hs-glow-a: .55;
  --hs-ink: #36414f; --hs-hill-far: #9fcb7f; --hs-hill: #5b9645;
  --hs-wall: #f4eee2; --hs-roof: #b4553d; --hs-window: #8fc3e6; --hs-window-dim: 1;
  --hs-wave: #ff7a1a; --hs-day: inline; --hs-night: none;
  --hero-text: #0e2340; --hero-sub: #2c4364; --hero-cw: #c25700; --hero-cw-sub: #4c6384;
  --hero-veil: linear-gradient(90deg, rgba(255, 255, 255, .78) 0%, rgba(255, 255, 255, .45) 48%, rgba(255, 255, 255, 0) 72%);
  position: relative; isolation: isolate; overflow: hidden; margin: 4px 0 8px;
  border-radius: var(--radius); background: var(--hs-sky-1); color: var(--hero-text); min-height: 210px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero {
    --hs-sky-1: #081327; --hs-sky-2: #16305a; --hs-sky-3: #3b3f63;
    --hs-glow: #f39a1f; --hs-glow-a: .35;
    --hs-ink: #0a1322; --hs-hill-far: #0f1c31; --hs-hill: #0a1322;
    --hs-wall: #0a1322; --hs-roof: #0a1322; --hs-window: #ffc35a; --hs-window-dim: .55;
    --hs-wave: #ffc35a; --hs-day: none; --hs-night: inline;
    --hero-text: #fff; --hero-sub: #c9d5ea; --hero-cw: #ffc35a; --hero-cw-sub: #8fa3c4;
    --hero-veil: linear-gradient(90deg, rgba(6, 14, 30, .88) 0%, rgba(6, 14, 30, .55) 48%, rgba(6, 14, 30, 0) 72%);
  }
}
:root[data-theme="dark"] .hero {
  --hs-sky-1: #081327; --hs-sky-2: #16305a; --hs-sky-3: #3b3f63;
  --hs-glow: #f39a1f; --hs-glow-a: .35;
  --hs-ink: #0a1322; --hs-hill-far: #0f1c31; --hs-hill: #0a1322;
  --hs-wall: #0a1322; --hs-roof: #0a1322; --hs-window: #ffc35a; --hs-window-dim: .55;
  --hs-wave: #ffc35a; --hs-day: none; --hs-night: inline;
  --hero-text: #fff; --hero-sub: #c9d5ea; --hero-cw: #ffc35a; --hero-cw-sub: #8fa3c4;
  --hero-veil: linear-gradient(90deg, rgba(6, 14, 30, .88) 0%, rgba(6, 14, 30, .55) 48%, rgba(6, 14, 30, 0) 72%);
}
.hero-scene { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
.hs-sky1 { stop-color: var(--hs-sky-1); }
.hs-sky2 { stop-color: var(--hs-sky-2); }
.hs-sky3 { stop-color: var(--hs-sky-3); }
.hs-glow1 { stop-color: var(--hs-glow); stop-opacity: var(--hs-glow-a); }
.hs-glow2 { stop-color: var(--hs-glow); stop-opacity: 0; }
.hs-day { display: var(--hs-day); }
.hs-night { display: var(--hs-night); }
.hs-ink { stroke: var(--hs-ink); }
.hs-hill-far { fill: var(--hs-hill-far); }
.hs-hill { fill: var(--hs-hill); }
.hs-wall { fill: var(--hs-wall); }
.hs-roof { fill: var(--hs-roof); }
.hs-window { fill: var(--hs-window); }
.hs-window-dim { opacity: var(--hs-window-dim); }
.hs-waves { stroke: var(--hs-wave); }
.hero::before { /* el texto se lee sobre el cielo, la torre queda a la vista */
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--hero-veil);
}
.hero-body { padding: 18px 20px 20px; max-width: 62%; }
.hero h1 { margin: 10px 0 6px; font-size: 1.7rem; line-height: 1.2; color: var(--hero-text); }
.hero p { margin: 0; font-size: .95rem; color: var(--hero-sub); }
.hero-lcd {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 9px; border-radius: 4px;
  background: radial-gradient(120% 140% at 50% 0%, #ffc35a 0%, #f39a1f 75%); color: #1d140a;
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .5), 0 0 14px rgba(255, 170, 60, .35);
  font: 700 .95rem/1.2 "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: .06em; font-variant-numeric: tabular-nums;
}
.hero-lcd small { font-size: .65rem; letter-spacing: .1em; }
.hero-rx { font-size: .6rem; padding: 0 3px; border: 1.5px solid currentColor; border-radius: 2px; }
.hero-cw { margin-top: 12px; font-size: .8rem; letter-spacing: .12em; color: var(--hero-cw); opacity: .85; white-space: nowrap; }
.hero-cw span { margin-left: 6px; color: var(--hero-cw-sub); letter-spacing: .08em; }
.hs-waves path { opacity: 0; animation: hs-wave 2.4s ease-out infinite; }
.hs-waves path:nth-child(2) { animation-delay: .3s; }
.hs-waves path:nth-child(3) { animation-delay: .6s; }
@keyframes hs-wave { 0% { opacity: 0; } 15% { opacity: .95; } 60%, 100% { opacity: 0; } }
.hs-beacon { animation: hs-beacon 1.6s steps(1) infinite; }
@keyframes hs-beacon { 50% { opacity: .15; } }
.hs-stars { animation: hs-twinkle 5s ease-in-out infinite alternate; }
.hs-clouds { animation: hs-drift 18s ease-in-out infinite alternate; }
@keyframes hs-drift { to { transform: translateX(-14px); } }
@keyframes hs-twinkle { to { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  .hs-waves path, .hs-beacon, .hs-stars, .hs-clouds { animation: none; }
  .hs-waves path { opacity: .7; }
}

.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.choice {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 12px 44px; position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.choice input { position: absolute; left: 14px; top: 15px; margin: 0; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice span { font-size: .9rem; }

.filters { margin-top: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.filters summary { cursor: pointer; font-weight: 600; }
.filters fieldset { border: 0; padding: 8px 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.filters legend { font-size: .9rem; color: var(--muted); padding: 0; }
.filters label { display: inline-flex; gap: 8px; align-items: center; padding: 4px 0; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.section-head h2 { margin: 0 0 10px; }
.section-head label { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- historial ---------- */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 14px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat h3 { margin: 0 0 8px; font-size: 1rem; }
.stat dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0; text-align: center; }
.stat dt { font-size: .75rem; color: var(--muted); }
.stat dd { margin: 0; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.spark { display: flex; gap: 3px; align-items: flex-end; height: 34px; margin-top: 10px; }
.spark span { flex: 1; max-width: 14px; border-radius: 2px 2px 0 0; background: var(--bad); min-height: 3px; }
.spark span.ok { background: var(--ok); }

.hist-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.hist-filters select { flex: 1; min-width: 150px; }

.attempts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.attempt {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--bad);
  border-radius: var(--radius); padding: 10px 12px; cursor: pointer;
}
.attempt.ok { border-left-color: var(--ok); }
.attempt:hover { border-color: var(--accent); }
.attempt .a-title { font-weight: 600; }
.attempt .a-sub { font-size: .85rem; color: var(--muted); }
.attempt .a-score { grid-row: span 2; text-align: right; font-variant-numeric: tabular-nums; }
.attempt .a-score strong { font-size: 1.3rem; display: block; line-height: 1.1; }
/* vídeos de YouTube en la teoría */
.videos { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.videos-head { font-size: .9rem; margin-bottom: 8px; }
.videos ul { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.video {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0;
}
.video:hover { border-color: var(--accent); }
.v-thumb { position: relative; flex: 0 0 128px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #000; }
.v-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.v-play {
  position: absolute; inset: 0; margin: auto; width: 34px; height: 24px; border-radius: 6px;
  background: rgba(220, 0, 0, .9); color: #fff; font-size: .75rem; display: grid; place-items: center;
}
.v-len { position: absolute; right: 4px; bottom: 4px; background: rgba(0, 0, 0, .8); color: #fff; font-size: .7rem; padding: 0 4px; border-radius: 3px; }
.v-info { display: grid; gap: 2px; min-width: 0; }
.v-title { font-weight: 600; font-size: .9rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.news-row { border-left-color: var(--accent); }
.news-row .a-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news-summary { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0 4px; }
.news-day h3 { font-size: 1rem; margin: 22px 0 8px; }
.news-day h3 span:first-child::first-letter { text-transform: uppercase; }
.news-items { display: grid; gap: 8px; }
.news-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.news-item[open] { border-color: var(--accent); }
.news-item summary { list-style: none; cursor: pointer; padding: 10px 12px; display: grid; gap: 4px; }
.news-item summary::-webkit-details-marker { display: none; }
.news-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.news-meta .src { font-size: .8rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.news-text { font-size: .95rem; }
.news-item[open] .news-text { display: none; }
.news-body { padding: 0 12px 12px; }
#news-more { width: 100%; margin: 16px 0; }
.pending-item { cursor: default; border-left-color: var(--accent); }
.pending-item:hover { border-color: var(--line); border-left-color: var(--accent); }
.pending-item .a-actions { grid-row: span 2; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.pending-item .a-progress { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.pending-item .a-progress span { display: block; height: 100%; background: var(--accent); }
.tag-ok { color: var(--ok); font-weight: 700; }
.tag-bad { color: var(--bad); font-weight: 700; }
.empty { padding: 20px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- test ---------- */
.test-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.test-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.test-tools { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.finish-link { color: var(--muted); font-size: .85rem; padding: 6px 0; min-height: 0; text-decoration: underline; text-underline-offset: 3px; }
.finish-link:hover { color: var(--bad); }
#q-card { touch-action: pan-y; will-change: transform; } /* el navegador hace el scroll vertical; el horizontal es nuestro */
.swipe-hint {
  text-align: center; font-size: .88rem; padding: 8px 12px; margin-bottom: 10px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent); animation: hint-in .3s ease-out;
}
@keyframes hint-in { from { opacity: 0; transform: translateY(-4px); } }
.pill { background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: .85rem; white-space: nowrap; }
.progress { height: 4px; background: var(--line); border-radius: 2px; margin: 10px 0; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin: 0 0 14px; }
.grid button { padding: 0; min-height: 36px; font-size: .85rem; font-variant-numeric: tabular-nums; }
.grid button.answered { background: var(--accent-soft); border-color: var(--accent); }
.grid button.ok { background: var(--ok-soft); border-color: var(--ok); }
.grid button.bad { background: var(--bad-soft); border-color: var(--bad); }
.grid button.current { outline: 2px solid var(--accent); outline-offset: 1px; font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.q-meta { display: flex; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; font-size: .85rem; margin-bottom: 10px; }
.q-num { font-weight: 700; }
.origin { color: var(--muted); }
.origin a { color: var(--muted); }
.origin .src { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); margin-left: 4px; }
.origin .src.apuntes { background: var(--warn-soft); }
.q-text { font-size: 1.08rem; font-weight: 500; margin: 6px 0 14px; overflow-wrap: anywhere; }
.q-text img { display: block; margin: 10px auto 0; }

/* ---------- favoritas, reportes y normativa ---------- */
.q-tools { display: flex; gap: 4px; }
.icon-btn { min-height: 0; padding: 2px 8px; font-size: 1rem; line-height: 1.4; border-color: transparent; background: none; color: var(--muted); }
.icon-btn:hover { border-color: var(--line); }
.icon-btn.on { color: #e0a100; }
.q-origin { font-size: .85rem; margin: -4px 0 10px; }
.normativa { border-left: 4px solid #e0a100; background: var(--warn-soft); border-radius: 6px; padding: 8px 12px; margin: 0 0 12px; font-size: .92rem; }
.normativa.derogada { border-left-color: var(--bad); background: var(--bad-soft); }
.normativa div { margin-top: 4px; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .72rem; text-align: center; }
.v-votes { display: flex; gap: 2px; justify-content: flex-end; margin-top: 2px; }
.v-votes .icon-btn { font-size: .85rem; padding: 0 6px; }
.v-votes .icon-btn.on { color: inherit; background: var(--ok-soft); border-color: var(--ok); }

.theory { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: .95rem; }
.theory summary { cursor: pointer; font-weight: 600; }
.theory p { margin: 8px 0; }
.theory .ref { font-size: .8rem; color: var(--muted); }
.theory .pending { color: var(--muted); font-style: italic; }

.answers { padding-left: 0; list-style: none; margin: 0; display: grid; gap: 8px; }
.answers li button {
  width: 100%; text-align: left; display: flex; gap: 10px; align-items: flex-start; padding: 12px;
  overflow-wrap: anywhere;
}
.answers .letter { font-weight: 700; min-width: 1.4em; }
.answers li button.selected { border-color: var(--accent); background: var(--accent-soft); }
.answers li button.correct { border-color: var(--ok); background: var(--ok-soft); opacity: 1; }
.answers li button.wrong { border-color: var(--bad); background: var(--bad-soft); opacity: 1; }
.answers li button:disabled:not(.correct):not(.wrong) { opacity: .6; }
.answers img { max-height: 160px; }

.feedback { margin-top: 14px; padding: 10px 14px; border-radius: var(--radius); }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }

.bottom-bar { display: flex; gap: 10px; margin: 16px 0; }
.bottom-bar button { flex: 1; min-height: 48px; font-weight: 600; }

.nav-buttons { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }

/* ---------- reloj del examen: pantalla LCD de emisora ---------- */
.install-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; padding: 12px 14px; }
.install-banner p { margin: 2px 0 0; }
.install-actions { display: flex; gap: 8px; align-items: center; }

.radio-clock {
  --lcd-bg-1: #ffc35a; --lcd-bg-2: #f39a1f; --lcd-on: #1d140a; --lcd-off: rgba(40, 24, 6, .10); --lcd-ink: #3a2408;
  position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 5; margin: 0 0 14px;
  padding: 10px 14px; border-radius: 14px;
  background: linear-gradient(180deg, #3a3e45 0%, #24272c 45%, #1a1c20 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), inset 0 -2px 4px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .35);
}
/* tornillos de la carcasa */
.radio-clock::before, .radio-clock::after {
  content: ""; position: absolute; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #9aa0a8, #3b3f45 70%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5);
}
.radio-clock::before { left: 4px; }
.radio-clock::after { right: 4px; }
.rc-lcd {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; align-items: center; gap: 2px 10px;
  padding: 8px 12px 6px; border-radius: 6px;
  background: radial-gradient(120% 140% at 50% 0%, var(--lcd-bg-1) 0%, var(--lcd-bg-2) 75%);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .55), inset 0 3px 10px rgba(0, 0, 0, .35), 0 0 18px rgba(255, 170, 50, .35);
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  color: var(--lcd-ink); transition: background .4s, box-shadow .4s;
}
.rc-side { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.rc-right { align-items: flex-end; }
.rc-tag {
  font-size: .62rem; font-weight: 700; letter-spacing: .06em; line-height: 1;
  padding: 2px 4px; border: 1.5px solid var(--lcd-on); border-radius: 2px; color: var(--lcd-on);
}
.rc-tx { opacity: .15; }
.rc-label { font-size: .62rem; font-weight: 700; letter-spacing: .12em; color: var(--lcd-ink); opacity: .85; }
.rc-digits { justify-self: center; width: 100%; max-width: 230px; }
.rc-digits svg { display: block; width: 100%; height: auto; }
.rc-digits rect.on { fill: var(--lcd-on); }
.rc-digits rect.off { fill: var(--lcd-off); }
.rc-meter { grid-column: 1 / -1; }
.rc-scale { display: flex; justify-content: space-between; font-size: .55rem; font-weight: 700; letter-spacing: .04em; opacity: .8; padding: 0 1px; }
.rc-bars { display: flex; align-items: flex-end; gap: 2px; height: 12px; margin-top: 1px; }
.rc-bars span { flex: 1; background: var(--lcd-off); border-radius: 1px; }
.rc-bars span.on { background: var(--lcd-on); }
/* últimos 5 minutos: retroiluminación roja, como al transmitir */
.radio-clock.warn { --lcd-bg-1: #ff8a6b; --lcd-bg-2: #e2402b; --lcd-ink: #2a0703; --lcd-on: #200402; --lcd-off: rgba(60, 6, 0, .12); }
.radio-clock.warn .rc-lcd { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .55), inset 0 3px 10px rgba(0, 0, 0, .35), 0 0 20px rgba(255, 70, 40, .45); }
.radio-clock.warn .rc-tx { opacity: 1; }
.radio-clock.crit .rc-digits { animation: lcd-blink 1s steps(2, start) infinite; }
@keyframes lcd-blink { to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .radio-clock.crit .rc-digits { animation: none; } }
.time-up { margin-top: 10px; font-weight: 700; }

/* ---------- resultado ---------- */
.result-box { text-align: center; padding: 24px 16px; border-radius: var(--radius); margin-top: 10px; }
.result-box.ok { background: var(--ok-soft); }
.result-box.bad { background: var(--bad-soft); }
.result-box .score { font-size: 3rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }

.review .card { margin-bottom: 12px; }
.review .answers li, .news-body .answers li { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); display: flex; gap: 10px; overflow-wrap: anywhere; }
.review .answers li.correct, .news-body .answers li.correct { border-color: var(--ok); background: var(--ok-soft); }
.review .answers li.wrong, .news-body .answers li.wrong { border-color: var(--bad); background: var(--bad-soft); }
.review .yours { font-size: .8rem; font-weight: 700; margin-left: auto; white-space: nowrap; padding-left: 6px; }
.review .theory { margin: 12px 0 0; }

/* ---------- móvil ---------- */
@media (max-width: 640px) {
  main { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.3rem; }
  .brand span { display: none; }
  /* en el móvil la estación va en una franja debajo del texto, que no la tape */
  .hero-scene { top: auto; height: 170px; }
  .hero::before { display: none; }
  .hero-body { max-width: none; padding: 16px 16px 150px; }
  .hero h1 { font-size: 1.45rem; }
  .hero-cw span { display: none; }
  .top { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .tabs a { padding: 0 8px; }
  #user-name { display: none; }
  .card { padding: 14px; }
  .q-text { font-size: 1.02rem; }

  /* la cuadrícula de 30 se despliega desde la cabecera para no ocupar media pantalla */
  .grid { display: none; grid-template-columns: repeat(6, 1fr); }
  .grid.open { display: grid; }

  /* botones de navegación siempre a mano, pegados abajo */
  #screen-test { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); }
  .bottom-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; margin: 0;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .hide-sm { display: none; }

  .nav-buttons button { flex: 1; }
  .radio-clock { top: calc(56px + env(safe-area-inset-top)); padding: 8px 12px; }
  .rc-lcd { padding: 6px 8px 5px; gap: 2px 6px; }
  .rc-digits { max-width: 190px; }
  .hist-filters select { flex: 1 1 100%; }
  .stat dd { font-size: 1.15rem; }
}
@media (min-width: 641px) {
  #grid-toggle { pointer-events: none; }
  #grid-toggle .caret { display: none; }
}

/* ---------- tu preparación ---------- */
.dash { margin-top: 18px; }
.dash-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dash-head h2 { margin-bottom: 6px; }
.streak { font-size: .9rem; padding: 3px 10px; border-radius: 999px; background: var(--warn-soft); color: var(--text); }
.streak.cold { background: var(--line); color: var(--muted); }
.dash-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.dash-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; }
.dash-card h3 { margin: 0; font-size: 1rem; }
.ready { display: flex; gap: 10px; align-items: center; line-height: 1.3; }
.ready > span:last-child { display: grid; gap: 2px; }
.ready-num { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
.ready.ok .ready-num { color: var(--ok); }
.ready.mid .ready-num { color: #c27c00; }
.ready.bad .ready-num { color: var(--bad); }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--muted); }
.meter.ok span { background: var(--ok); }
.meter.mid span { background: #e0a100; }
.meter.bad span { background: var(--bad); }
.dash-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dash-actions button { flex: 1 1 auto; min-height: 40px; padding: 6px 10px; font-size: .9rem; }
.dash-actions button:disabled { opacity: .5; cursor: default; }
.sim-btn { width: 100%; margin-top: 10px; min-height: 48px; text-align: left; font-weight: 600; }
.topic-pick { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.topic-pick select { flex: 1; min-width: 0; }

/* ---------- temas ---------- */
.topic-block h3 { font-size: .95rem; margin: 14px 0 6px; }
.topics { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.topic-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px;
}
.topic-row.weak { border-left: 4px solid var(--bad); }
.topic-row .t-name { font-weight: 600; font-size: .92rem; }
.topic-row .meter { grid-column: 1; }
.topic-row .t-num { grid-column: 1; }
.topic-row button { grid-column: 2; grid-row: 1 / span 3; }

/* ---------- simulacro ---------- */
.sim-card { text-align: center; margin-top: 20px; }
.sim-parts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.sim-part { display: grid; gap: 2px; padding: 10px 18px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--bad); min-width: 140px; }
.sim-part.ok { border-color: var(--ok); }
.sim-part strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.review h3 { margin: 20px 0 8px; }

/* ---------- sin conexión, administrador y recordatorio ---------- */
.offline-box { margin-top: 24px; }
.offline-actions { display: grid; gap: 6px; margin-top: 8px; }
#screen-offline .offline-actions button { min-height: 52px; }
.admin-item { margin-bottom: 10px; }
.admin-item summary { cursor: pointer; }
.admin-item .row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.report-msg { margin-bottom: 8px; font-weight: 600; }
.admin-item .answers li { padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); display: flex; gap: 10px; margin-bottom: 4px; }
.admin-item .answers li.correct { border-color: var(--ok); background: var(--ok-soft); }
.reminder { margin-bottom: 20px; }
.reminder h2 { margin-top: 0; }
