/* ============================================================
   TAI – AGE  |  Estilos principales
   Paleta VS Code Dark + acentos azul AGE
   ============================================================ */

:root {
  --bg:          #1e1e1e;
  --bg-alt:      #252526;
  --bg-hover:    #2a2d2e;
  --border:      #3c3c3c;
  --text:        #d4d4d4;
  --text-muted:  #858585;
  --accent:      #007acc;
  --accent-2:    #4ec9b0;
  --success:     #6a9955;
  --error:       #f44747;
  --warning:     #d7ba7d;
  --sidebar-w:   290px;
  --topbar-h:    52px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  gap: 1rem;
  z-index: 100;
}

.topbar-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: .02em;
  white-space: nowrap;
}

.topbar-nav { display: flex; gap: .5rem; margin-left: auto; }

.topbar-nav a {
  padding: .35rem .85rem;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  transition: background .15s;
}
.topbar-nav a:hover,
.topbar-nav a.active { background: var(--bg-hover); color: var(--accent-2); text-decoration: none; }

.topbar-progress {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-left: auto;
  white-space: nowrap;
}
.topbar-user .user-email {
  font-size: .8rem;
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-user .btn-logout,
.topbar-user .btn-login {
  padding: .3rem .8rem;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: opacity .15s;
  font-family: inherit;
}
.topbar-user .btn-logout {
  background: var(--bg-hover);
  color: var(--text);
}
.topbar-user .btn-login {
  background: var(--accent);
  color: #fff;
}
.topbar-user .btn-logout:hover,
.topbar-user .btn-login:hover { opacity: .8; }

/* hamburger (solo móvil) */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: .2rem .4rem;
}

/* ============================================================
   HOME – PÁGINA ÍNDICE
   ============================================================ */
.home-hero {
  margin-top: var(--topbar-h);
  padding: 3.5rem 2rem 2.5rem;
  text-align: center;
  background: linear-gradient(135deg, #252526 0%, #1e1e1e 100%);
  border-bottom: 1px solid var(--border);
}

.home-hero h1 {
  font-size: 2.2rem;
  color: var(--accent-2);
  margin-bottom: .5rem;
}
.home-hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 640px;
  margin: 0 auto 1.5rem;
}

.home-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.stat-item { text-align: center; }
.stat-num  { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.stat-lbl  { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }

/* ── Cuenta atrás ──────────────────────────────────────────── */
.countdown-wrap {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
}
.countdown-label {
  font-size: .8rem;
  color: var(--text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.countdown-units {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.cd-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .8rem;
  min-width: 3.5rem;
}
.cd-num {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.cd-lbl {
  font-size: .65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .2rem;
}
.cd-sep {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 1rem;
}

.btn {
  display: inline-block;
  padding: .65rem 1.5rem;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--accent);   color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--accent); color: var(--accent); }
.btn-secondary { background: var(--bg-hover); color: var(--text); }

/* Bloques grid */
.bloques-section {
  max-width: 1100px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}
.bloques-section h2 {
  font-size: 1.2rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 1.2rem;
}

.bloques-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.1rem;
}

.bloque-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  padding: 1.4rem;
  transition: border-color .2s, transform .15s;
  cursor: pointer;
}
.bloque-card:nth-child(2) { border-top-color: #c586c0; }
.bloque-card:nth-child(3) { border-top-color: var(--warning); }
.bloque-card:nth-child(4) { border-top-color: var(--accent-2); }

.bloque-card:hover { transform: translateY(-3px); }

.bloque-num {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent);
  margin-bottom: .4rem;
}
.bloque-card:nth-child(2) .bloque-num { color: #c586c0; }
.bloque-card:nth-child(3) .bloque-num { color: var(--warning); }
.bloque-card:nth-child(4) .bloque-num { color: var(--accent-2); }

.bloque-card h3 { font-size: 1.05rem; color: var(--text); margin-bottom: .5rem; line-height: 1.3; }
.bloque-card p  { font-size: .82rem; color: var(--text-muted); margin-bottom: 1rem; }

.bloque-temas-list {
  list-style: none;
  font-size: .8rem;
  color: var(--text-muted);
}
.bloque-temas-list li { padding: .18rem 0; border-bottom: 1px solid var(--border); }
.bloque-temas-list li:last-child { border-bottom: none; }

/* Cuestionarios card */
.quiz-card {
  max-width: 1100px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
}

.quiz-banner {
  background: linear-gradient(135deg, #1a2a3a 0%, #1e1e1e 100%);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 1.6rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.quiz-banner-icon { font-size: 2.5rem; }
.quiz-banner h3 { font-size: 1.2rem; color: var(--accent-2); margin-bottom: .3rem; }
.quiz-banner p  { color: var(--text-muted); font-size: .9rem; }
.quiz-banner .btn { margin-left: auto; }

/* ============================================================
   PLAYER – CURSO
   ============================================================ */
.player-layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  overflow-y: auto;
  transition: transform .25s ease;
  z-index: 90;
}

.sidebar-header {
  padding: 1rem 1.1rem .6rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

/* Bloque agrupador */
.bloque-group { border-bottom: 1px solid var(--border); }

.bloque-group-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1rem;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  -webkit-user-select: none;
  user-select: none;
  transition: background .12s;
}
.bloque-group-header:hover { background: var(--bg-hover); }
.bloque-group-header .chevron {
  margin-left: auto;
  font-size: .7rem;
  transition: transform .2s;
}
.bloque-group.open .chevron { transform: rotate(90deg); }

.bloque-group-items { display: none; }
.bloque-group.open .bloque-group-items { display: block; }

.sidebar-item {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .55rem 1rem .55rem 1.5rem;
  font-size: .82rem;
  color: var(--text);
  cursor: pointer;
  transition: background .12s;
  border-left: 3px solid transparent;
}
.sidebar-item:hover  { background: var(--bg-hover); }
.sidebar-item.active {
  background: var(--bg-hover);
  border-left-color: var(--accent);
  color: var(--accent-2);
}
.sidebar-item .item-num {
  flex-shrink: 0;
  width: 1.3rem;
  font-size: .7rem;
  color: var(--text-muted);
  padding-top: .1rem;
}

/* ── Content pane ────────────────────────────────────────── */
.content-pane {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2.2rem 2.8rem;
  max-width: 860px;
}

/* Spinner */
.spinner {
  display: flex;
  justify-content: center;
  padding: 4rem;
  font-size: 1.4rem;
  color: var(--text-muted);
}

/* Render Markdown */
.md-body { line-height: 1.75; }

.md-body h1 { font-size: 1.9rem; color: var(--accent-2); margin: 0 0 1.2rem; border-bottom: 2px solid var(--border); padding-bottom: .5rem; }
.md-body h2 { font-size: 1.35rem; color: var(--accent); margin: 1.8rem 0 .7rem; }
.md-body h3 { font-size: 1.1rem; color: var(--warning); margin: 1.4rem 0 .5rem; }
.md-body h4 { font-size: 1rem;   color: var(--text-muted); margin: 1.2rem 0 .4rem; text-transform: uppercase; letter-spacing: .04em; }

.md-body p  { margin-bottom: .9rem; }
.md-body ul, .md-body ol { margin: .5rem 0 .9rem 1.6rem; }
.md-body li { margin-bottom: .3rem; }

.md-body strong { color: #fff; }
.md-body em     { color: var(--warning); }

.md-body code {
  background: #2d2d2d;
  color: #ce9178;
  padding: .1em .35em;
  border-radius: 4px;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: .88em;
}

.md-body pre {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 1rem 0 1.2rem;
}
.md-body pre code { background: none; padding: 0; color: var(--text); font-size: .85rem; }

.md-body blockquote {
  border-left: 4px solid var(--accent-2);
  background: #1a2a2a;
  padding: .7rem 1rem;
  border-radius: 0 6px 6px 0;
  margin: 1rem 0;
  color: var(--text-muted);
}

.md-body table { border-collapse: collapse; width: 100%; margin: 1rem 0 1.2rem; font-size: .88rem; }
.md-body th { background: #2d2d2d; color: var(--accent-2); text-align: left; padding: .55rem .8rem; border: 1px solid var(--border); }
.md-body td { padding: .45rem .8rem; border: 1px solid var(--border); }
.md-body tr:hover td { background: var(--bg-hover); }

.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1.8rem 0; }

.md-body a { color: var(--accent); }

/* Navegación prev/next */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}
.lesson-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.2rem;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.lesson-nav-btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent-2); text-decoration: none; }
.lesson-nav-btn.disabled { opacity: .3; pointer-events: none; }

.lesson-pos { font-size: .8rem; color: var(--text-muted); text-align: center; }

/* Barra de leyes del tema */
.tema-leyes-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem .9rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: 8px;
  padding: .7rem 1rem;
  margin-bottom: .75rem;
}
.tema-leyes-bar > .fa-landmark {
  color: var(--warning);
  font-size: 1rem;
  flex-shrink: 0;
}
.tema-leyes-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-right: .1rem;
}
.tema-ley-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  font-weight: 600;
  padding: .3rem .75rem;
  border-radius: 6px;
  background: rgba(215,186,125,.1);
  border: 1px solid rgba(215,186,125,.3);
  color: var(--warning);
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.tema-ley-btn:hover {
  background: rgba(215,186,125,.2);
  border-color: var(--warning);
  color: #f0d080;
}
.tema-ley-btn .fa-file-pdf { color: var(--error); }


.tema-audio-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: .75rem 1rem;
  margin-bottom: 1.5rem;
}
.tema-audio-bar > .fa-headphones {
  color: var(--accent);
  font-size: 1.05rem;
  flex-shrink: 0;
}
.tema-audio-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-right: .25rem;
}
.tema-audio-item {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.tema-audio-tag {
  font-size: .75rem;
  color: var(--accent-2);
  background: rgba(78,201,176,.12);
  border-radius: 4px;
  padding: .15rem .45rem;
  white-space: nowrap;
}
.tema-audio-bar audio {
  height: 32px;
  accent-color: var(--accent);
}

/* ============================================================
   CUESTIONARIOS
   ============================================================ */

/* ── Supuesto selector ──────────────────────────────────────── */
.sup-sel-header { text-align: center; margin-bottom: 1.5rem; }
.sup-sel-header h2 { font-size: 1.3rem; color: var(--accent); margin-bottom: .4rem; }
.sup-sel-header p  { color: var(--text-muted); font-size: .9rem; }

.sup-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.sup-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}
.sup-card-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .6rem;
  font-size: 1rem;
  color: var(--accent);
}
.sup-card-num {
  margin-left: auto;
  font-size: .8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .15rem .55rem;
  color: var(--text-muted);
}
.sup-card-desc { font-size: .85rem; color: var(--text-muted); margin-bottom: .75rem; line-height: 1.5; }
.sup-material  { margin-bottom: .75rem; }

/* Context hint inside question card */
.supuesto-context {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: .6rem .9rem;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.supuesto-context i { color: var(--accent); margin-right: .35rem; }

/* ── PDF docs bar ───────────────────────────────────────────── */
.exam-pdfs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem 1rem;
  margin-bottom: 1rem;
}
.exam-pdfs-label {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: .25rem;
}
.exam-pdf-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .3rem .65rem;
  color: var(--accent);
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.exam-pdf-link:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); }

/* ── Repaso de fallos ────────────────────────────────────────── */
.repaso-wrap {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}
.repaso-titulo {
  font-size: 1.1rem;
  color: var(--warning);
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.repaso-intro {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
}
.repaso-grupo {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .75rem;
  overflow: hidden;
}
.repaso-grupo > summary {
  list-style: none;
  cursor: pointer;
  padding: .7rem 1rem;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  -webkit-user-select: none;
  user-select: none;
}
.repaso-grupo > summary::-webkit-details-marker { display: none; }
.repaso-grupo[open] > summary { border-bottom: 1px solid var(--border); }
.repaso-tema-name { font-size: .9rem; font-weight: 600; color: var(--fg); display: flex; align-items: center; gap: .45rem; }
.repaso-tema-name i { color: var(--accent); }
.repaso-badge {
  background: color-mix(in srgb, var(--error) 18%, transparent);
  color: var(--error);
  border: 1px solid color-mix(in srgb, var(--error) 35%, transparent);
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  padding: .15rem .6rem;
  white-space: nowrap;
}
.repaso-lista {
  list-style: none;
  margin: 0;
  padding: 0;
}
.repaso-item {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.repaso-item:last-child { border-bottom: none; }
.repaso-q {
  font-size: .85rem;
  color: var(--fg);
  margin-bottom: .45rem;
  line-height: 1.5;
}
.repaso-answers {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.repaso-ans {
  font-size: .8rem;
  padding: .25rem .5rem;
  border-radius: 4px;
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  line-height: 1.4;
}
.repaso-ans.ko {
  background: color-mix(in srgb, var(--error) 12%, transparent);
  color: var(--error);
}
.repaso-ans.ok {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
}
.repaso-link-tema {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--accent);
  text-decoration: none;
  padding: .5rem 1rem;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-top: 1px solid var(--border);
  width: 100%;
  transition: background .15s;
}
.repaso-link-tema:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.repaso-perfecto {
  text-align: center;
  font-size: .95rem;
  color: var(--success);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.repaso-perfecto i { color: var(--warning); font-size: 1.1rem; }

/* ── Layout ─────────────────────────────────────────────────── */
.quiz-layout {
  margin-top: var(--topbar-h);
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  padding: 2rem 1.5rem;
}

.quiz-header { margin-bottom: 2rem; text-align: center; }
.quiz-header h1 { font-size: 1.8rem; color: var(--accent-2); margin-bottom: .4rem; }
.quiz-header p  { color: var(--text-muted); font-size: .95rem; }

.quiz-controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.quiz-select {
  padding: .55rem 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: .95rem;
  cursor: pointer;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}
.quiz-select:focus { outline: none; border-color: var(--accent); }

.quiz-scoreboard {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.8rem;
}
.score-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .7rem 1.4rem;
  min-width: 90px;
}
.score-chip .val { font-size: 1.6rem; font-weight: 700; }
.score-chip .lbl { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.score-chip.aciertos .val { color: var(--success); }
.score-chip.fallos   .val { color: var(--error); }
.score-chip.total    .val { color: var(--accent); }

.question-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.8rem;
  margin-bottom: 1rem;
}

.question-num {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: .6rem;
}
.question-text { 
  font-size: 1.05rem; 
  color: var(--text); 
  margin-bottom: 1.3rem; 
  line-height: 1.6; 
}

.options-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }

.option-label {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: .95rem;
}
.option-label:hover { border-color: var(--accent); background: var(--bg-hover); }
.option-label input { margin-top: .15rem; accent-color: var(--accent); }
.option-label.correct   { border-color: var(--success); background: #1a2a1a; color: #6a9955; }
.option-label.incorrect { border-color: var(--error);   background: #2a1a1a; color: var(--error); }
.option-letter {
  flex-shrink: 0;
  width: 1.4rem;
  font-weight: 700;
  color: var(--accent-2);
  font-size: .88rem;
}

.question-feedback {
  margin-top: 1rem;
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  display: none;
}
.question-feedback.show { display: block; }
.question-feedback.ok   { background: #1a2a1a; border: 1px solid var(--success); color: var(--success); }
.question-feedback.ko   { background: #2a1a1a; border: 1px solid var(--error);   color: var(--error); }

.quiz-nav-row { display: flex; justify-content: flex-end; margin-top: 1rem; }

.final-screen {
  text-align: center;
  padding: 3rem 1rem;
}
.final-screen h2 { font-size: 1.8rem; color: var(--accent-2); margin-bottom: 1rem; }
.final-score-big { font-size: 3rem; font-weight: 700; color: var(--accent); margin-bottom: .3rem; }
.final-score-sub { color: var(--text-muted); margin-bottom: 2rem; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  /* La topbar dobla a 2 filas en móvil → aumentar la variable de offset */
  :root { --topbar-h: 86px; }

  .menu-toggle { display: block; }

  /* Topbar: wrap para 2 filas (iconos/usuario arriba, nav abajo) */
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: .35rem .8rem .2rem;
    row-gap: 0;
  }

  .menu-toggle  { order: 0; }
  .topbar-brand { order: 1; }
  .topbar-user  { order: 2; margin-left: auto; }
  .topbar-progress { display: none; }   /* evita que ocupe espacio en móvil */

  /* Segunda fila: links desplazables horizontalmente */
  .topbar-nav {
    order: 10;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    scrollbar-width: none;          /* Firefox */
    padding: .15rem 0 .3rem;
    gap: .15rem;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-nav a { white-space: nowrap; font-size: .8rem; padding: .28rem .65rem; }

  .sidebar {
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 85vw);
  }
  .sidebar.open { transform: translateX(0); }

  .content-pane { margin-left: 0; padding: 1.2rem 1rem; }

  .home-hero h1 { font-size: 1.5rem; }
  .bloques-grid { grid-template-columns: 1fr; }

  .quiz-layout { padding: 1rem; }
}

/* ═══════════════════════════════════════════════════════════
   NOTICIAS Y CONVOCATORIAS
   ============================================================ */
.noticias-layout {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 1.5rem 3rem;
}
.noticias-header {
  text-align: center;
  margin-bottom: 2.5rem;
}
.noticias-header h1 {
  font-size: 1.8rem;
  color: var(--accent-2);
  margin-bottom: .4rem;
}
.noticias-header p { color: var(--text-muted); font-size: .95rem; }

.noticias-section {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}
.noticias-section-hdr {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .5rem;
  flex-wrap: wrap;
}
.noticias-section-hdr h2 {
  font-size: 1.05rem;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  flex: 1;
}
.noticias-section-hdr h2 i { color: var(--accent); }
.noticias-src-badge {
  font-size: .72rem;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 20px;
  padding: .15rem .6rem;
  white-space: nowrap;
}
.noticias-section-desc {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* ── INAP links ─────────────────────────────────────────────── */
.inap-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .65rem;
  margin-bottom: 1rem;
}
.inap-link-card {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .65rem .85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--fg);
  font-size: .85rem;
  transition: border-color .15s, background .15s;
}
.inap-link-card:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent);
}
.inap-link-card i:first-child { color: var(--accent); width: 1rem; text-align: center; }
.inap-link-card span { flex: 1; }
.inap-ext { font-size: .7rem; color: var(--text-muted); margin-left: auto; }
.inap-link-primary {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.inap-info-box {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: .85rem 1rem;
  background: color-mix(in srgb, var(--warning) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  border-radius: 8px;
  font-size: .85rem;
  line-height: 1.5;
  color: var(--fg);
}
.inap-info-box > i { color: var(--warning); margin-top: .15rem; flex-shrink: 0; }
.inap-info-box a { color: var(--accent); }

/* ── BOE news list ──────────────────────────────────────────── */
.news-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.news-loading, .news-empty, .news-error {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.news-error {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
  border-radius: 8px;
  flex-direction: column;
}
.news-error a { color: var(--accent); }
.news-item {
  display: block;
  padding: .6rem .85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  text-decoration: none;
  color: var(--fg);
  transition: border-color .13s, background .13s;
}
.news-item:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.news-item--tai {
  border-color: color-mix(in srgb, var(--success) 50%, transparent);
  background: color-mix(in srgb, var(--success) 6%, transparent);
}
.news-item--tai:hover {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
}
.news-item-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .25rem;
  flex-wrap: wrap;
}
.news-tag-tai {
  font-size: .68rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--success) 18%, transparent);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
  border-radius: 20px;
  padding: .1rem .5rem;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}
.news-date {
  font-size: .72rem;
  color: var(--text-muted);
  margin-left: auto;
}
.news-title {
  font-size: .85rem;
  line-height: 1.45;
  color: var(--fg);
}

/* ── CCAA grid ──────────────────────────────────────────────── */
.ccaa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .6rem;
}
.ccaa-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  padding: .65rem .5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  text-align: center;
  transition: border-color .13s, background-color .13s;
}
.ccaa-card:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.ccaa-sigla {
  font-size: .75rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .04em;
}
.ccaa-nombre {
  font-size: .8rem;
  color: var(--fg);
}

@media (max-width: 600px) {
  .inap-links-grid { grid-template-columns: 1fr; }
  .ccaa-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Banner de cambios INAP ─────────────────────────────────── */
.inap-cambio-banner {
  position: sticky;
  top: var(--topbar-h);
  z-index: 90;
  background: color-mix(in srgb, var(--warning) 15%, var(--bg));
  border-bottom: 2px solid var(--warning);
  padding: .65rem 1rem;
}
.inap-cambio-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.inap-cambio-banner > .inap-cambio-inner > i:first-child {
  color: var(--warning);
  font-size: 1.2rem;
  flex-shrink: 0;
}
.inap-cambio-txt {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  font-size: .88rem;
}
.inap-cambio-txt strong { color: var(--warning); }
.inap-cambio-txt span  { color: var(--text-muted); font-size: .8rem; }
.inap-banner-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: .25rem .4rem;
  border-radius: 4px;
  transition: color .15s, background-color .15s;
  flex-shrink: 0;
}
.inap-banner-close:hover { color: var(--fg); background: color-mix(in srgb, var(--fg) 10%, transparent); }

/** LOGIN **/
.auth-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 2rem;
}
.auth-card {
    background: var(--bg-alt); border: 1px solid var(--border);
    border-radius: 12px; padding: 2.5rem 2rem; width: 100%; max-width: 400px;
}
.auth-card h2 { color: var(--accent-2); margin-bottom: 1.5rem; font-size: 1.4rem; }
.auth-field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.auth-field label { font-size: .85rem; color: var(--text-muted); }
.auth-field input {
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); padding: .55rem .8rem; font-size: .95rem; outline: none;
    transition: border-color .15s;
}
.auth-field input:focus { border-color: var(--accent); }
.auth-btn {
    width: 100%; padding: .65rem; border-radius: 8px; border: none;
    background: var(--accent); color: #fff; font-size: 1rem;
    font-weight: 600; cursor: pointer; margin-top: .5rem;
    transition: opacity .15s;
}
.auth-btn:hover { opacity: .88; }
.auth-msg { font-size: .85rem; padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
.auth-msg.error { background: rgba(244,71,71,.12); color: var(--error); border: 1px solid var(--error); }
.auth-msg.ok    { background: rgba(106,153,85,.12); color: var(--success); border: 1px solid var(--success); }
.auth-footer { margin-top: 1.2rem; text-align: center; font-size: .85rem; color: var(--text-muted); }
.auth-footer a { color: var(--accent); }