: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;
  --top-h: 58px;  /* barra superior: 52 px de botones + 6 px de escala de dial */
  /* cabecera: aluminio cepillado de día, panel anodizado de noche */
  --panel-1: #f6f8fa; --panel-2: #d8dde4; --panel-ink: #1f2933; --panel-dim: #5c6878; --panel-on: #0f141a;
  --panel-led-off: #c2c8d0; --panel-brush: rgba(255, 255, 255, .35); --panel-edge: rgba(0, 0, 0, .12);
  --dial-bg: #c7cdd5; --dial-tick: rgba(31, 41, 51, .55); --dial-major: #b06d00;
  --knob-1: #ffffff; --knob-2: #c3c9d1; --knob-edge: #9aa3ae;
  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"]) {
    --panel-1: #2c313a; --panel-2: #171a20; --panel-ink: #d5dce6; --panel-dim: #8d97a6; --panel-on: #ffffff;
    --panel-led-off: #3a404a; --panel-brush: rgba(255, 255, 255, .03); --panel-edge: rgba(255, 255, 255, .08);
    --dial-bg: #0d0f13; --dial-tick: rgba(255, 181, 71, .45); --dial-major: rgba(255, 181, 71, .85);
    --knob-1: #59616e; --knob-2: #1d2128; --knob-edge: #0b0d10;
    --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"] {
  --panel-1: #2c313a; --panel-2: #171a20; --panel-ink: #d5dce6; --panel-dim: #8d97a6; --panel-on: #ffffff;
  --panel-led-off: #3a404a; --panel-brush: rgba(255, 255, 255, .03); --panel-edge: rgba(255, 255, 255, .08);
  --dial-bg: #0d0f13; --dial-tick: rgba(255, 181, 71, .45); --dial-major: rgba(255, 181, 71, .85);
  --knob-1: #59616e; --knob-2: #1d2128; --knob-edge: #0b0d10;
  --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: frontal de emisora ----------
   Panel oscuro en los dos temas, visor LCD ámbar como logo, pestañas como botones de banda con su LED
   y, abajo, la escala del dial con la aguja en la pestaña activa. */
.top {
  --amber: #ffb547;
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  /* vetas horizontales finas sobre el degradado: metal cepillado */
  background:
    repeating-linear-gradient(0deg, var(--panel-brush) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--panel-1) 0%, var(--panel-2) 100%);
  box-shadow: inset 0 1px 0 var(--panel-edge), 0 2px 8px rgba(0, 0, 0, .18);
  padding: 0 16px 6px; height: calc(var(--top-h) + 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));
}
/* escala del dial: marcas pequeñas cada 10 px y grandes cada 50 px */
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, var(--dial-major) 0 1.5px, transparent 1.5px 50px) left bottom / 100% 6px no-repeat,
    repeating-linear-gradient(90deg, var(--dial-tick) 0 1px, transparent 1px 10px) left bottom / 100% 3px no-repeat,
    var(--dial-bg);
}
.brand { text-decoration: none; white-space: nowrap; display: flex; align-items: center; }
.brand-lcd {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 6px; 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, .55), inset 0 2px 5px rgba(0, 0, 0, .25), 0 0 12px rgba(255, 170, 60, .25);
  font: 800 .8rem/1.2 "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif; letter-spacing: .08em;
}
.brand-lcd svg { width: 16px; height: 16px; flex: none; }
.brand-short { display: none; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs a {
  position: relative; display: flex; align-items: center; padding: 6px 12px 0; text-decoration: none;
  color: var(--panel-dim); font-weight: 600; transition: color .15s;
}
.tabs a:hover { color: var(--panel-ink); }
/* LED del botón: apagado en gris, encendido en ámbar en la pestaña activa */
.tabs a::before {
  content: ""; position: absolute; top: 9px; left: 50%; width: 16px; height: 3px; margin-left: -8px;
  border-radius: 2px; background: var(--panel-led-off); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .35);
}
.tabs a.active { color: var(--panel-on); }
.tabs a.active::before { background: var(--amber); box-shadow: 0 0 6px var(--amber), 0 0 2px #fff; }
/* aguja del dial sobre la escala, debajo de la pestaña activa */
.tabs a.active::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; width: 2px; height: 12px; margin-left: -1px;
  background: #ff5a3c; box-shadow: 0 0 5px rgba(255, 90, 60, .8); border-radius: 1px; z-index: 1;
}

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

/* ---------- usuario ---------- */
/* botón de tema como un mando giratorio */
.theme-btn {
  margin-left: auto; font-size: 1rem; line-height: 1; width: 34px; height: 34px; padding: 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--knob-1), var(--knob-2) 70%); border: 1px solid var(--knob-edge);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .25), 0 2px 4px rgba(0, 0, 0, .35);
}
.user-menu { position: relative; margin-left: 4px; }
.user-btn { color: var(--panel-ink, 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 */
/* la tarjeta sale y entra por los lados al cambiar de pregunta: lo que asoma se recorta, o el móvil
   ensancharía la página (y con ella los botones de abajo) */
#screen-test { overflow-x: clip; }
/* sin zoom por doble toque al pulsar seguido Anterior/Siguiente o las respuestas */
button, a, .choice { touch-action: manipulation; }
.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; padding: 0 3px; } /* el padding deja sitio al contorno de la actual (#screen-test recorta en horizontal) */
.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); }
#q-card .normativa, #q-card .theory { margin-top: 14px; }
#q-card .theory { margin-bottom: 0; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .why { margin-top: 6px; color: var(--text); font-size: .92rem; }
.review .answers li:has(.why) { flex-wrap: wrap; }
.review li .why { display: block; flex-basis: 100%; margin-top: 4px; color: var(--text); font-size: .88rem; }

.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; }
#retry-btn { flex-basis: 100%; }

/* ---------- 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(var(--top-h) + 8px + 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; }
/* estudio y práctica: la emisora en recepción, con luz verde; no se queda fija arriba */
.radio-clock.rx { position: relative; top: auto; --lcd-bg-1: #c6f3a8; --lcd-bg-2: #74c66e; --lcd-on: #0c2408; --lcd-off: rgba(10, 40, 6, .10); --lcd-ink: #163a10; }
.radio-clock.rx .rc-lcd { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .55), inset 0 3px 10px rgba(0, 0, 0, .3), 0 0 18px rgba(120, 220, 90, .35); }
.radio-clock.rx .rc-tx { opacity: 1; }
.rc-digits text { fill: var(--lcd-ink); font: 700 13px "Arial Narrow", "Roboto Condensed", Arial, sans-serif; letter-spacing: .14em; }
#rc-right-label.pass { font-size: .7rem; padding: 1px 4px; border: 1.5px solid var(--lcd-on); border-radius: 2px; opacity: 1; }
/* al contestar, un destello: verde si aciertas, rojo si fallas */
.radio-clock.hit .rc-lcd { --lcd-bg-1: #e4ffcf; --lcd-bg-2: #8fe07f; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .55), 0 0 26px rgba(130, 255, 100, .75); }
.radio-clock.miss { --lcd-bg-1: #ff8a6b; --lcd-bg-2: #e2402b; --lcd-ink: #2a0703; --lcd-on: #200402; --lcd-off: rgba(60, 6, 0, .12); }
.radio-clock.miss .rc-lcd { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .55), 0 0 26px rgba(255, 70, 40, .6); }

/* ---------- 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-long { display: none; }
  .brand-short { display: inline; }
  /* 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: 6px 8px 0; }
  #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(var(--top-h) + 4px + 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 .tp-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; }

/* ---------- chuleta ---------- */
.ch-bar { position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top)); z-index: 2; background: var(--bg); padding: 8px 0; display: grid; gap: 8px; }
.ch-tabs { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.ch-tabs button { border: 0; min-height: 38px; padding: 4px 2px; border-radius: 7px; font-size: .9rem; font-weight: 600; color: var(--muted); background: none; }
.ch-tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
@media (max-width: 420px) { .ch-tabs button { font-size: .78rem; } }
.ch-search { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; }
.ch-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ch-empty { margin: 0; }
.ch-sec h2:first-child { margin-top: 14px; }
.ch-sec h2 { margin: 26px 0 10px; }
.f-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.f { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.f-name { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.f-eq { font: 600 1.05rem/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; margin: 4px 0; overflow-wrap: anywhere; }
.f-note { font-size: .88rem; color: var(--muted); }
.ch-table { width: 100%; border-collapse: collapse; margin: 10px 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .92rem; }
.ch-table th, .ch-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ch-table thead th { background: var(--accent-soft); font-size: .82rem; }
.ch-table tr:last-child td { border-bottom: 0; }
.ch-table.colors i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 8px; vertical-align: -2px; }
.ch-tip { font-size: .92rem; background: var(--accent-soft); border-radius: var(--radius); padding: 8px 12px; margin: 10px 0; }
.q-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; margin: 10px 0; }
.q-list div { display: flex; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.q-list dt { font: 700 .95rem ui-monospace, Menlo, monospace; min-width: 44px; color: var(--accent); }
.q-list dd { margin: 0; font-size: .9rem; }
.abc { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.abc span { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: .95rem; }
.abc b { display: inline-block; width: 1.4em; color: var(--accent); }
.map-box { background: #f3f5f8; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; }
.map-box img { display: block; width: 100%; height: auto; }
.districts td:first-child { width: 36px; }
.d { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: #fff; font-weight: 800; }
.d1 { background: #5b8def; } .d2 { background: #e5534b; } .d3 { background: #e8a33d; } .d4 { background: #57ab5a; } .d5 { background: #b083f0; }
.d6 { background: #39c5cf; } .d7 { background: #f0883e; } .d8 { background: #d16fc1; } .d9 { background: #8b949e; }
.chuleta-btn { font-weight: 600; color: var(--accent); }

/* panel de la chuleta en el modo estudio: hoja inferior en el móvil, panel lateral en pantallas anchas */
.sheet {
  padding: 0; border: 0; background: var(--bg); color: var(--text); display: none; flex-direction: column;
  width: 100%; max-width: 100%; height: 88vh; max-height: 88vh; margin: auto 0 0; border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .3);
}
.sheet[open] { display: flex; animation: sheet-up .22s ease-out; }
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--card); border-radius: 16px 16px 0 0; }
.sheet-head .icon-btn { font-size: 1.2rem; }
.sheet-body { overflow-y: auto; padding: 0 14px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.sheet-body .ch-bar { top: 0; }
@media (min-width: 900px) {
  .sheet { width: 520px; height: 100vh; max-height: 100vh; margin: 0 0 0 auto; border-radius: 0; }
  .sheet[open] { animation-name: sheet-left; }
  .sheet-head { border-radius: 0; }
  @keyframes sheet-left { from { transform: translateX(40px); opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }

/* móviles estrechos: con cuatro pestañas (administrador) la barra no debe desbordar */
@media (max-width: 430px) {
  .top { gap: 2px; }
  .tabs { gap: 0; }
  .tabs a { padding: 6px 6px 0; font-size: .92rem; }
  .theme-btn { width: 30px; height: 30px; font-size: .9rem; }
}

/* chuleta: «¿Qué es?» y términos que se despliegan */
.f-what { margin-top: 6px; font-size: .88rem; }
.f-what summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .82rem; list-style: none; }
.f-what summary::-webkit-details-marker { display: none; }
.f-what summary::before { content: "▸ "; }
.f-what[open] summary::before { content: "▾ "; }
.f-what[open] { background: var(--accent-soft); border-radius: 8px; padding: 6px 10px; margin: 6px -4px 0; }
.f-what[open] summary { margin-bottom: 4px; }
.chuleta dfn { font-style: normal; border-bottom: 1.5px dotted var(--accent); cursor: pointer; }
.chuleta dfn[aria-expanded="true"] { color: var(--accent); }
.gloss { margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); font-size: .88rem; font-weight: 400; animation: hint-in .2s ease-out; }
@media (max-width: 380px) {
  .brand-short { display: none; }
  .brand-lcd { padding: 3px 5px; }
  .tabs a { padding: 6px 5px 0; font-size: .87rem; }
  .top { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
}

/* ---------- teoría ---------- */
.t-bar { position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top)); z-index: 2; background: var(--bg); padding: 8px 0; }
.sheet-body .t-bar { top: 0; }
.t-intro { margin: 4px 0 0; }
.t-part { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 22px 0 8px; }
.t-list, .t-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.t-item {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; min-height: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.t-item:hover { border-color: var(--accent); }
.t-item.read { border-left: 4px solid var(--ok); }
.t-num { flex: none; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; background: var(--accent-soft); color: var(--accent); }
.t-text { display: grid; gap: 2px; min-width: 0; }
.t-list li { position: relative; }
.t-list .t-item { padding-right: 52px; }
/* casilla de leído en el índice, encima de la tarjeta del tema */
.t-check {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; min-height: 0; padding: 0;
  border-radius: 50%; border: 2px solid var(--line); background: var(--card); color: #fff; font-weight: 800;
}
.t-check.on { background: var(--ok); border-color: var(--ok); }
.t-read { display: block; margin: 10px 0; min-height: 40px; font-weight: 600; }
.t-read.small { display: inline-block; margin: 4px 0 6px; min-height: 0; padding: 4px 12px; font-size: .85rem; }
.t-read.on { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.t-end .t-read { width: 100%; margin-top: 24px; }
.t-snip { color: var(--muted); }
.t-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.t-jump { max-width: 60%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; font-size: .88rem; }
.t-kicker { margin: 12px 0 0; text-transform: uppercase; letter-spacing: .05em; }
.t-title { margin: 2px 0 6px; }
.t-nav { display: flex; justify-content: space-between; gap: 10px; margin: 16px 0 28px; }
.t-nav button { flex: 1; font-size: .88rem; min-height: 44px; }
.t-nav button:last-child { text-align: right; }
.t-practice { margin-top: 18px; }
.t-link { display: block; margin: 8px 0 0; font-weight: 600; color: var(--accent); }

.lesson { font-size: 1rem; line-height: 1.65; }
.lesson section { scroll-margin-top: calc(var(--top-h) + 70px); border-radius: 8px; }
.sheet-body .lesson section { scroll-margin-top: 70px; }
.lesson section.flash { animation: t-flash 1.6s ease-out; }
@keyframes t-flash { from { background: var(--warn-soft); } to { background: transparent; } }
.lesson h3 { font-size: 1.15rem; margin: 30px 0 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.lesson section:first-child h3 { border-top: 0; margin-top: 10px; }
.lesson h4 { font-size: 1rem; margin: 18px 0 6px; color: var(--accent); }
.lesson p { margin: 8px 0; }
.lesson ul, .lesson ol { padding-left: 22px; margin: 8px 0; }
.lesson li { margin: 4px 0; }
.lesson .formula { font: 600 1.02rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 12px; margin: 10px 0; overflow-x: auto; }
.lesson .key { background: var(--warn-soft); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; }
.lesson .t-table { width: 100%; border-collapse: collapse; margin: 10px 0; background: var(--card); border: 1px solid var(--line); font-size: .92rem; }
.lesson .t-table th, .lesson .t-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.lesson .t-table thead th { background: var(--accent-soft); }
.lesson .table-wrap { overflow-x: auto; }

/* fichas: concepto → relación → ejemplo */
.cc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 18px 0; scroll-margin-top: calc(var(--top-h) + 70px); }
.sheet-body .cc { scroll-margin-top: 70px; }
.cc.flash { animation: t-flash 1.6s ease-out; }
.lesson .cc-title { margin: 0 0 6px; color: var(--text); font-size: 1.02rem; }
.cc-tag { display: inline-block; vertical-align: 2px; margin-right: 4px; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; }
.cc-step { border-left: 3px solid var(--line); padding: 0 0 0 12px; margin: 10px 0 0; }
.cc-c { border-color: var(--accent); }
.cc-r { border-color: #d98a00; }
.cc-e { border-color: var(--ok); }
.lesson .cc-step p { margin: 4px 0; }
.lesson .cc-lbl { margin: 0; font-size: .8rem; font-weight: 700; color: var(--muted); }
.lesson .cc .formula { background: var(--bg); font-size: .95rem; margin: 6px 0; }
@media (max-width: 600px) {
  .formula .fp { display: block; }
  .formula .fsep { display: none; }
  /* las tablas anchas se desplazan dentro de su recuadro, no ensanchan la página */
  .lesson .t-table { display: block; overflow-x: auto; }
}
.cc-sol { margin: 8px 0 2px; }
.cc-sol summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .92rem; }
.lesson .cc-sol ol { margin: 6px 0; }
.lesson .cc-res { margin: 6px 0 0; padding: 6px 10px; border-radius: 8px; background: var(--ok-soft); }
.t-method { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0 4px; }
.t-method h2 { font-size: 1rem; margin: 0 0 6px; }
.t-method ol { margin: 6px 0 10px; padding-left: 22px; }
.t-method li { margin: 3px 0; }
.t-method .t-fichas { width: 100%; }
.cc-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
.cc-list .t-item { padding: 8px 12px; }
.t-links { display: flex; flex-wrap: wrap; gap: 4px 18px; }
/* pregunta rápida */
.quick-btn { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; margin: 14px 0 4px; padding: 12px 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--accent); }
.quick-btn > span:last-child { display: grid; gap: 2px; }
.quick-ico { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; background: var(--accent-soft); }
.quick-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.quick-head h1 { margin: 10px 0 2px; }
.quick-reason { margin: 0 0 10px; }
.quick-actions { display: flex; gap: 10px; margin: 14px 0 8px; }
.quick-actions button { flex: 1; min-height: 48px; }
.quick-actions .primary { flex: 2; }
.q-concepts { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 12px; }
.q-concepts[hidden] { display: none; }
.concept-chip { min-height: 0; padding: 5px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; background: var(--accent-soft); border-color: transparent; color: var(--accent); text-align: left; }
.ficha-go { width: 100%; margin: 4px 0 20px; }

/* esquemas: trazos y textos toman los colores del tema */
.dg { margin: 14px 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.dg svg { display: block; width: 100%; height: auto; max-height: 340px; color: var(--text); overflow: visible; }
.dg figcaption { font-size: .85rem; color: var(--muted); margin-top: 6px; text-align: center; }
.dg .s { stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dg .a { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dg .w { stroke: #d98a00; stroke-width: 2.2; fill: none; stroke-linecap: round; }
.dg .ok { stroke: var(--ok); stroke-width: 2.5; fill: none; }
.dg .bad { stroke: var(--bad); stroke-width: 2.5; fill: none; }
.dg .thin { stroke-width: 1.2; }
.dg .thick { stroke-width: 3.5; }
.dg .dash { stroke-dasharray: 5 4; stroke-width: 1.2; }
.dg .fa { fill: var(--accent-soft); }
.dg .fw { fill: var(--warn-soft); }
.dg .fc { fill: var(--card); }
.dg .dot { fill: currentColor; stroke: none; }
.dg .tx { fill: currentColor; font: 12px system-ui, -apple-system, sans-serif; stroke: none; }
.dg .tx.big { font-size: 22px; font-weight: 800; }
.dg .tx.b, .dg .b { font-weight: 700; }
.dg .tx.m { fill: var(--muted); font-size: 11px; }
.dg .tx.acc { fill: var(--accent); font-weight: 600; }
.dg .tx.warn { fill: #c27c00; font-weight: 600; }
.dg .sub { font-size: 9px; baseline-shift: sub; }

/* gesto de atrás / adelante desde el borde (iPhone con la app instalada) */
.edge-arrow {
  position: fixed; z-index: 50; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); color: var(--muted); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  font-size: 1.3rem; font-weight: 700; pointer-events: none; transition: background .12s, color .12s;
}
.edge-arrow.ready { background: var(--accent); color: #fff; border-color: var(--accent); }
.ch-tip code { font: 600 .86rem ui-monospace, Menlo, Consolas, monospace; background: var(--card); border-radius: 4px; padding: 0 4px; }

/* pie con la versión de la web */
.foot { max-width: 860px; margin: 0 auto; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); text-align: center; font-size: .78rem; color: var(--muted); }
.foot-version { font-variant-numeric: tabular-nums; }
body[data-screen="test"] .foot { display: none; }

/* trampa anti-bots del formulario de alta: fuera de la vista y del lector de pantalla */
.hp-field { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
