/*
 * Estilos propios de la app de tests. Los tokens de diseño, botones,
 * cabecera, modal de configuración y el shell (body + sidebar + grid
 * desktop) viven en /shared/*.css.  Aquí solo van reglas específicas
 * de las vistas de tests.
 */

/* Backdrop legado del sidebar antiguo: sigue oculto por si algún atajo
 * lo dispara. El sidebar real está en shared/app-shell.css. */
.sidebar-backdrop { display: none !important; }

/* ─── Main ─── */
.content { padding: 0.75rem 0.85rem; flex: 1; min-width: 0; }
.view { display: none; }
.view.active {
  display: block;
  animation: view-fade-in 0.14s ease both;
}
@keyframes view-fade-in {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}

/* Atenuación suave del listado de tests mientras se recargan filtros:
 * evita el flash de "Cargando…" cuando el fetch tarda unos ms y no
 * despega la lista actual del sitio (así el usuario no ve un salto en
 * blanco al cambiar de chip). */
#tests-list.cargando {
  opacity: 0.55;
  transition: opacity 0.12s ease;
  pointer-events: none;
}
#tests-list { transition: opacity 0.2s ease; }
#tests-tag-chips, #buscar-tag-chips { transition: opacity 0.15s ease; }

/* Estado de arranque síncrono (lo pinta el inline script del <head>):
 *  - data-boot="session" → hay cookie, el usuario probablemente está
 *    logueado; ocultamos el login por defecto y dejamos que app.js
 *    decida qué vista mostrar. Así no se ve el parpadeo del login al
 *    volver desde /teoria/.
 *  - data-boot="anon" → sin cookie, mostramos el login inmediatamente.
 * Cuando app.js confirma la sesión, cambia data-boot="ready" y las
 * reglas normales de .view.active toman el control. */
:root[data-boot="anon"] #view-login { display: block; }
:root[data-boot="anon"] .topbar,
:root[data-boot="anon"] .bottom-nav,
:root[data-boot="anon"] .sidebar { display: none; }
:root[data-boot="session"] #view-login { display: none; }

.view-header {
  display: flex; flex-direction: column;
  align-items: stretch; gap: 0.5rem; margin-bottom: 0.65rem;
}
.view-header h2 { margin: 0; font-size: 1.35rem; color: var(--txt); font-weight: 700; letter-spacing: -0.01em; }

.upload-oposiciones {
  margin: 0.75rem 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
}
.upload-oposiciones-head {
  display: flex; flex-direction: column; gap: 0.15rem;
  margin-bottom: 0.5rem;
}

/* App-first: en modo standalone (PWA instalada) apretamos aún más los
   márgenes verticales para aprovechar la pantalla como una app nativa. */
@media (display-mode: standalone) {
  .content { padding: 0.6rem 0.85rem; }
  .view-header { margin-bottom: 0.5rem; }
}

/* Home más compacto: el saludo no debe ocupar dos filas cuando arriba
   ya tenemos la topbar con el avatar. */
#view-home > h2 {
  margin: 0.1rem 0 0.15rem;
  font-size: 1.3rem;
  font-weight: 700;
}
#view-home > .tagline {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
}
.view-header input[type=search] {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.95rem; background: var(--bg-panel); color: var(--txt);
}
.view-header input[type=search]:focus {
  outline: none; border-color: var(--pri);
  box-shadow: 0 0 0 4px var(--pri-glow);
}
.view-header .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ─── Detalle de un test: cabecera compacta y ergonómica ─────────────
 * Antes: título + timer + Empezar test + Repasar + Oposiciones + 🗑️
 * apilados en columna → ocupaba toda la pantalla. Ahora:
 *  · Fila 1 → "← Volver" y título en línea.
 *  · Fila 2 → CTA principal (timer + Empezar test) a lo ancho.
 *  · Fila 3 → acciones secundarias (Repasar / Oposiciones / 🗑️)
 *    como chips más pequeños.
 */
.test-detail-header { gap: 0.55rem; }
.test-detail-head-row {
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap;
}
.test-detail-head-row h2 {
  flex: 1; min-width: 0;
  font-size: 1.35rem; margin: 0;
  color: var(--txt); font-weight: 700; letter-spacing: -0.01em;
  word-break: break-word;
}
.test-detail-actions {
  display: flex; flex-direction: column;
  gap: 0.5rem;
}
.test-detail-cta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  align-items: stretch;
}
.test-detail-cta .tiempo-input-wrap {
  margin: 0;
  min-height: 42px;
}
.test-detail-cta .btn-cta {
  font-weight: 700;
  padding: 0.7rem 1.1rem;
  font-size: 1rem;
  box-shadow: 0 4px 12px var(--pri-glow);
  min-height: 42px;
}
.test-detail-secondary {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
}
.test-detail-secondary .btn-secondary-action {
  flex: 1 1 auto;
  min-height: 38px;
  padding: 0.4rem 0.7rem;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  background: var(--bg-panel);
}
.test-detail-secondary #btn-delete-test {
  flex: 0 0 auto;
  min-width: 42px;
}

@media (min-width: 600px) {
  .test-detail-head-row { flex-wrap: nowrap; }
  .test-detail-cta {
    grid-template-columns: auto minmax(180px, 260px);
    justify-content: start;
  }
  .test-detail-secondary .btn-secondary-action { flex: 0 0 auto; }
}

/* ─── Auth: los estilos viven en shared/auth.css (los usa <ap-auth-form>). ─── */

/* ─── Stats ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem; margin: 0.6rem 0;
}
.stat-card {
  background: var(--bg-panel); padding: 0.7rem 0.7rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--stat-tint, var(--pri-soft)) 0%, transparent 60%);
  pointer-events: none;
  opacity: 0.9;
}
.stat-card > * { position: relative; }
.stat-card:nth-child(1) { --stat-tint: var(--accent-soft); }
.stat-card:nth-child(2) { --stat-tint: var(--sky-soft); }
.stat-card:nth-child(3) { --stat-tint: var(--coral-soft); }
.stat-card:nth-child(4) { --stat-tint: var(--lavender-soft); }
.stat-card:nth-child(5) { --stat-tint: var(--leaf-soft); }
.stat-card:nth-child(6) { --stat-tint: var(--pri-soft); }
.stat-card .v {
  font-size: 1.55rem; font-weight: 800;
  color: var(--pri-d); line-height: 1.1;
}
.stat-card:nth-child(1) .v { color: var(--accent-d); }
.stat-card:nth-child(2) .v { color: var(--sky-d); }
.stat-card:nth-child(3) .v { color: var(--coral-d); }
.stat-card:nth-child(4) .v { color: var(--lavender-d); }
[data-theme="dark"] .stat-card .v { color: var(--pri); }
[data-theme="dark"] .stat-card:nth-child(1) .v { color: var(--accent); }
[data-theme="dark"] .stat-card:nth-child(2) .v { color: var(--sky); }
[data-theme="dark"] .stat-card:nth-child(3) .v { color: var(--coral); }
[data-theme="dark"] .stat-card:nth-child(4) .v { color: var(--lavender); }
.stat-card .l { color: var(--txt-soft); font-size: 0.85rem; font-weight: 500; }

/* ─── Action cards ─── */
.actions-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem; margin-top: 0.6rem;
}
.action-card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem 0.8rem;
  box-shadow: var(--shadow);
  text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 0.25rem;
  min-height: 92px;
  color: var(--txt);
  font-family: inherit;
  position: relative; overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  --action-tint: var(--pri);
  --action-tint-soft: var(--pri-soft);
}
.action-card::before {
  content: "";
  position: absolute;
  top: -30px; right: -30px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--action-tint-soft) 0%, transparent 70%);
  pointer-events: none;
  transition: transform 0.3s;
}
.action-card > * { position: relative; z-index: 1; }
.action-card:nth-child(1) { --action-tint: var(--accent-d); --action-tint-soft: var(--accent-soft); }
.action-card:nth-child(2) { --action-tint: var(--sky-d);    --action-tint-soft: var(--sky-soft); }
.action-card:nth-child(3) { --action-tint: var(--coral-d);  --action-tint-soft: var(--coral-soft); }
.action-card:nth-child(4) { --action-tint: var(--lavender-d);--action-tint-soft: var(--lavender-soft); }
[data-theme="dark"] .action-card:nth-child(1) { --action-tint: var(--accent); }
[data-theme="dark"] .action-card:nth-child(2) { --action-tint: var(--sky); }
[data-theme="dark"] .action-card:nth-child(3) { --action-tint: var(--coral); }
[data-theme="dark"] .action-card:nth-child(4) { --action-tint: var(--lavender); }
.action-card:hover { border-color: var(--action-tint); box-shadow: var(--shadow-md); }
.action-card:hover::before { transform: scale(1.4); }
.action-card:active { transform: scale(0.98); }
.action-card .ico { width: 24px; height: 24px; color: var(--action-tint); }
.action-card strong { font-size: 1rem; color: var(--action-tint); font-weight: 700; }
.action-card small { color: var(--txt-soft); font-size: 0.82rem; line-height: 1.3; }

/* ─── Listas ─── */
#tests-list { display: flex; flex-direction: column; gap: 0.55rem; }
.test-row {
  background: var(--bg-panel); padding: 0.85rem 1rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: grid;
  /* 4 cols: estrella · título (crece) · meta (numero preg + intentos) · stats.
   * Uso posiciones explícitas para evitar que auto-placement solape el
   * icono de stats con el texto de meta. */
  grid-template-columns: 28px minmax(0, 1fr) auto 40px;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0.4rem 0.6rem;
  cursor: pointer;
  color: var(--txt);
}
.test-row:hover { border-color: var(--pri); }
.test-row .star  { grid-column: 1; grid-row: 1; font-size: 1.2rem; }
.test-row .titulo {
  grid-column: 2; grid-row: 1;
  font-weight: 600; word-break: break-word;
  min-width: 0;
}
.test-row .meta {
  grid-column: 3; grid-row: 1;
  color: var(--txt-soft); font-size: 0.78rem; white-space: nowrap;
  padding-right: 0.3rem;
}
.test-row .stats-btn { grid-column: 4; grid-row: 1; justify-self: end; }
.test-row .tags {
  grid-column: 2 / -1; grid-row: 2;
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  min-width: 0;
}
/* En pantallas estrechas el meta pasa a la segunda fila junto a las
 * etiquetas: el título y el botón de stats se quedan solos arriba. */
@media (max-width: 480px) {
  .test-row { grid-template-columns: 28px minmax(0, 1fr) 40px; }
  .test-row .stats-btn { grid-column: 3; grid-row: 1; }
  .test-row .meta {
    grid-column: 2 / -1; grid-row: 3;
    white-space: normal;
  }
  .test-row .tags { grid-row: 2; }
}

/* Icono 📊 (SVG) por test — abre modal con estadísticas. Sutil, no
 * compite con el título. */
.test-row .stats-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: transparent; border: 0;
  border-radius: 10px;
  color: var(--txt-soft);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.test-row .stats-btn svg { width: 18px; height: 18px; }
.test-row .stats-btn:hover {
  background: var(--pri-soft);
  color: var(--pri-d);
}
.test-row .stats-btn:active { transform: scale(0.9); }
[data-theme="dark"] .test-row .stats-btn:hover { color: var(--pri); }

/* ── Modal de estadísticas por test ───────────────────────────────── */
#modal-stats-test .stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}
@media (min-width: 520px) {
  #modal-stats-test .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-tile {
  position: relative;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 0.65rem 0.85rem;
  text-align: center;
  display: flex; flex-direction: column; gap: 0.2rem;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.stat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-tile-ico {
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0.85;
}
.stat-tile-v {
  font-size: 1.55rem; font-weight: 800;
  color: var(--txt);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-tile-l {
  font-size: 0.7rem; font-weight: 700;
  color: var(--txt-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-tile.ok   { background: linear-gradient(160deg, var(--pri-soft), var(--bg-soft)); border-color: var(--pri); }
.stat-tile.ok .stat-tile-v { color: var(--pri-d); }
[data-theme="dark"] .stat-tile.ok .stat-tile-v { color: var(--pri); }
.stat-tile.warn { background: linear-gradient(160deg, var(--accent-soft), var(--bg-soft)); border-color: var(--accent); }
.stat-tile.warn .stat-tile-v { color: var(--accent-d); }
.stat-tile.hi   { background: linear-gradient(160deg, var(--sky-soft, var(--accent-soft)), var(--bg-soft)); border-color: var(--sky, var(--accent)); }
.stat-tile.hi .stat-tile-v { color: var(--pri-d); }

.stats-highlight {
  margin-top: 0.9rem;
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--pri-soft), transparent 65%);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.7rem 1rem;
}
.stats-highlight.warn {
  background: linear-gradient(135deg, var(--accent-soft), transparent 65%);
  border-color: var(--accent);
}
.stats-highlight-l {
  font-size: 0.72rem; font-weight: 700;
  color: var(--txt-soft);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.stats-highlight-v {
  grid-column: 2 / 3;
  display: flex; align-items: baseline; gap: 0.25rem;
  font-variant-numeric: tabular-nums;
}
.stats-highlight-num {
  font-size: 2.1rem; font-weight: 800; line-height: 1;
  color: var(--pri-d);
}
[data-theme="dark"] .stats-highlight-num { color: var(--pri); }
.stats-highlight.warn .stats-highlight-num { color: var(--accent-d); }
.stats-highlight-slash {
  color: var(--txt-soft); font-size: 1rem; font-weight: 600;
}
.stats-trend {
  grid-column: 3 / 4;
  font-size: 0.78rem; font-weight: 700;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.stats-trend.up   { color: var(--pri-d); border-color: var(--pri); }
[data-theme="dark"] .stats-trend.up { color: var(--pri); }
.stats-trend.down { color: var(--accent-d); border-color: var(--accent); }
.stats-trend.flat { color: var(--txt-soft); }

.stats-sub {
  font-size: 0.82rem; font-weight: 700;
  color: var(--txt-soft);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 1.1rem 0 0.5rem;
}

/* Timeline de intentos ─ sustituye a la sparkline plana */
.attempts-list {
  list-style: none;
  padding: 0.35rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  display: flex; flex-direction: column;
  gap: 0.25rem;
  max-height: 260px;
  overflow-y: auto;
}
.attempt-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.55rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  animation: attempt-in 0.28s ease both;
}
@keyframes attempt-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.attempt-num {
  font-size: 0.78rem; font-weight: 700;
  color: var(--txt-soft);
  font-variant-numeric: tabular-nums;
}
.attempt-bar-wrap {
  position: relative;
  height: 10px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}
.attempt-bar {
  position: absolute; inset: 0 auto 0 0;
  width: var(--pct, 0%);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b));
  transition: width 0.5s ease;
}
.attempt-nota {
  font-size: 0.95rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--txt);
  min-width: 42px; text-align: right;
}
.attempt-row.sobresa { border-color: var(--pri); }
.attempt-row.sobresa .attempt-bar { background: linear-gradient(90deg, var(--pri), var(--sky, var(--pri))); }
.attempt-row.sobresa .attempt-nota { color: var(--pri-d); }
[data-theme="dark"] .attempt-row.sobresa .attempt-nota { color: var(--pri); }
.attempt-row.aprob .attempt-bar { background: linear-gradient(90deg, var(--grad-a), var(--grad-b)); }
.attempt-row.just  .attempt-bar { background: linear-gradient(90deg, var(--accent), var(--accent-d)); }
.attempt-row.just  { border-color: var(--accent); }
.attempt-row.just  .attempt-nota { color: var(--accent-d); }
.attempt-row.susp  .attempt-bar { background: linear-gradient(90deg, #d97575, #b04a4a); }
.attempt-row.susp  { border-color: rgba(217, 117, 117, 0.5); }
.attempt-row.susp  .attempt-nota { color: #b04a4a; }
[data-theme="dark"] .attempt-row.susp .attempt-nota { color: #ff9b9b; }
.stats-hint { margin-top: 0.5rem; }

.question-list {
  list-style: none; padding: 0;
  display: flex; flex-direction: column; gap: 0.55rem;
}
.q-row {
  background: var(--bg-panel); padding: 0.85rem 1rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
  color: var(--txt);
}
.q-row .q-text { font-weight: 500; word-break: break-word; }
.q-row .q-meta { color: var(--txt-soft); font-size: 0.8rem; margin-top: 0.3rem; }
.q-row .q-actions {
  display: flex; gap: 0.3rem; margin-top: 0.5rem;
  justify-content: flex-end;
}

/* .tags y .tag (contenedor + chip semántico) viven en shared/components.css. */
.q-row .tags { margin-top: 0.4rem; }

.quiz-tags-inline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
  margin-top: 0.9rem; padding-top: 0.7rem; border-top: 1px dashed var(--border);
}

.buscar-tematico {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem;
  margin-top: 0.5rem; padding: 0.6rem 0.9rem;
  background: var(--bg-panel); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.buscar-tematico .small { font-size: 0.8rem; }
.buscar-tematico label { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--txt-soft); }
.buscar-tematico input[type=number] {
  padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 0.4rem;
  background: var(--bg-panel); color: var(--txt);
}
.quiz-tags-inline .muted.small { font-size: 0.75rem; }
.quiz-tags-inline #quiz-tag-add {
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.25rem 0.7rem; font-size: 0.75rem;
  background: var(--bg-panel); color: var(--txt); outline: none;
  min-width: 9rem; max-width: 14rem;
}
.quiz-tags-inline #quiz-tag-add:focus { border-color: var(--pri); }

/* ─── Quiz ─── */
.quiz-header {
  background: var(--bg-panel); padding: 0.65rem 0.9rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex; align-items: center;
  flex-wrap: wrap; gap: 0.4rem 0.9rem;
}
.quiz-header #quiz-title { font-weight: 600; flex: 1; min-width: 0; word-break: break-word; }
.quiz-card {
  background: var(--bg-panel); padding: 1.3rem 1.1rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-top: 0.7rem;
  color: var(--txt);
}
.quiz-card #quiz-question { font-size: 1.1rem; line-height: 1.45; margin: 0; word-break: break-word; }
.quiz-timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--pri); }
.options { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1.2rem; }
.option-btn {
  background: var(--bg-alt); border: 1px solid var(--border);
  padding: 0.85rem 1rem; border-radius: var(--radius);
  text-align: left; cursor: pointer;
  font-size: 0.95rem; font-family: inherit;
  color: var(--txt);
  min-height: 50px;
  word-break: break-word;
  transition: background 0.12s, border-color 0.12s;
}
.option-btn:hover { background: var(--pri-soft); border-color: var(--pri); }
.option-btn.correct { background: var(--success-light); border-color: var(--success); color: var(--txt); }
.option-btn.wrong { background: var(--danger-light); border-color: var(--danger); color: var(--txt); }
.option-btn.disabled { pointer-events: none; opacity: 0.9; }
.explanation {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--txt);
  padding: 0.95rem 1.15rem;
  border-radius: var(--radius); margin-top: 1rem;
  word-break: break-word;
  line-height: 1.55;
}
[data-theme="dark"] .explanation { background: rgba(244, 208, 63, 0.10); border-color: rgba(244, 208, 63, 0.45); }
.quiz-actions {
  margin-top: 1.3rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: center;
}
.quiz-actions-tools {
  display: flex; gap: 0.4rem;
  justify-content: center;
}
.quiz-actions .btn-icon {
  padding: 0.5rem 0.75rem;
  min-width: 48px;
  font-size: 1.15rem;
  line-height: 1;
}
.quiz-actions .btn-icon.fav-on { color: var(--accent, #f4d03f); }
.quiz-actions .btn-next {
  padding: 0.7rem 1.4rem;
  min-width: 130px;
  font-weight: 700;
  box-shadow: 0 4px 12px var(--pri-glow);
}

/* En móvil, con enunciados largos o explicaciones extensas, el botón
 * "Siguiente" quedaba fuera del viewport y había que hacer scroll cada
 * vez. Lo dejamos pegado al borde inferior (justo encima de la
 * bottom-nav) mientras se está respondiendo un test. Solo aplica al
 * quiz activo — el resumen y las demás vistas no lo necesitan. */
@media (max-width: 899.98px) {
  #view-quiz.active {
    /* Deja hueco extra para que las opciones nunca queden tapadas por
     * la barra sticky. Usa la altura real medida por el flex a través
     * de un padding-bottom generoso. */
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0));
  }
  #view-quiz .quiz-actions {
    position: sticky;
    /* Encima de la bottom-nav de la app (--bottom-nav-h la define
     * shared/header.css). */
    bottom: calc(var(--bottom-nav-h, 58px) + 0.4rem);
    z-index: 10;
    margin-top: 1rem;
    padding: 0.55rem 0.8rem;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem;
  }
  #view-quiz .quiz-actions .btn { min-height: 42px; }
  #view-quiz .quiz-actions .btn-next { padding: 0.55rem 1.1rem; min-width: 110px; }
}

/* ─── Tiempo per-pregunta input ─── */
.tiempo-input-wrap {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--bg-panel); padding: 0.35rem 0.7rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  min-height: 44px;
  color: var(--txt);
}
.tiempo-input-wrap input {
  width: 64px; border: 0; background: transparent;
  font-size: 0.95rem; font-weight: 600; text-align: right;
  font-family: inherit; outline: none; color: var(--txt);
}

/* ─── Selects estilizados (mismo look que los inputs vistosos) ─── */
.select-styled, .orden-wrap select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0.6rem 2.2rem 0.6rem 1rem;
  border: 1.5px solid var(--border); border-radius: 999px;
  background-color: var(--bg-panel); color: var(--txt);
  font-family: inherit; font-size: 0.95rem; font-weight: 500;
  min-height: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23556B2F' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.select-styled:focus, .orden-wrap select:focus {
  outline: none; border-color: var(--pri);
  box-shadow: 0 0 0 4px var(--pri-glow);
}

/* ─── Etiquetas ─── */
.inline-form {
  display: flex; flex-direction: column;
  gap: 0.6rem; margin-bottom: 1rem;
}
.inline-form input, .inline-form select {
  padding: 0.7rem 0.95rem;
  border: 1.5px solid var(--border); border-radius: 999px;
  font-size: 0.95rem; font-family: inherit; width: 100%;
  background: var(--bg-panel); color: var(--txt);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.inline-form input:focus, .inline-form select:focus {
  outline: none; border-color: var(--pri);
  box-shadow: 0 0 0 4px var(--pri-glow);
}
.inline-form .select-styled { min-height: 46px; }
.etiquetas-list {
  list-style: none; padding: 0;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.etiqueta-row {
  background: var(--bg-panel); padding: 0.85rem 1rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: start;
  gap: 0.5rem;
  color: var(--txt);
  max-width: 100%; overflow: hidden;
}
.etiqueta-row > div { min-width: 0; max-width: 100%; }
.etiqueta-row .nombre { font-weight: 600; word-break: break-word; }
.etiqueta-row .descripcion { color: var(--txt-soft); font-size: 0.85rem; word-break: break-word; }
.etiqueta-row .count {
  background: var(--bg-soft); color: var(--txt);
  padding: 0.2rem 0.55rem;
  border-radius: 999px; font-size: 0.78rem; white-space: nowrap;
}
.etiqueta-row button { padding: 0.3rem 0.55rem; min-height: 36px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); margin-top: 6px; flex: 0 0 auto; }
.dot.ok { background: var(--success); }

/* En móvil, la fila de etiqueta se compacta y las palabras clave envuelven bien */
@media (max-width: 500px) {
  .etiqueta-row {
    grid-template-columns: 12px 1fr;
    grid-template-areas:
      "dot cuerpo"
      "meta meta"
      "acciones acciones";
  }
  .etiqueta-row > .dot { grid-area: dot; }
  .etiqueta-row > div:not(.dot) { grid-area: cuerpo; }
  .etiqueta-row > .count { grid-area: meta; justify-self: start; }
  .etiqueta-row > button { grid-area: acciones; justify-self: end; }
  .etiqueta-row > .count + button { grid-column: 2; }
}

/* ─── Controles de listado de tests ─── */
.tests-controls {
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem;
  align-items: center;
  margin-bottom: 0.6rem;
}
.tests-controls .tag-chips { margin: 0; }
.orden-wrap {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.85rem; color: var(--txt-soft);
}

/* .tag-chips y .tag-chips .chip viven en shared/components.css. */

/* ─── Progreso ─── */
.por-test { list-style: none; padding: 0; }
.por-test li {
  background: var(--bg-panel); padding: 0.75rem 1rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 0.5rem; word-break: break-word;
  color: var(--txt);
}

/* ─── Pagination ─── */
.pagination {
  display: flex; gap: 0.25rem; justify-content: center;
  flex-wrap: wrap; margin-top: 1rem;
}
.pagination .page {
  background: var(--bg-panel); border: 1px solid var(--border);
  padding: 0.4rem 0.65rem; border-radius: 0.5rem;
  cursor: pointer; min-width: 38px; min-height: 38px;
  color: var(--txt);
}
.pagination .page:hover { border-color: var(--pri); }
.pagination .page.active {
  background: var(--pri); color: #fff; border-color: var(--pri);
}
[data-theme="dark"] .pagination .page.active { color: #14241D; }

/* ─── Forms ─── */
textarea {
  width: 100%; min-height: 180px;
  padding: 0.7rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-family: monospace;
  font-size: 0.85rem;
  background: var(--bg-panel); color: var(--txt);
}
textarea:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 4px var(--pri-glow); }
.muted { color: var(--txt-soft); font-size: 0.9rem; }
.actions { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }

/* ─── Modal (cristal esmerilado) ───
 * Base compartida (.modal como overlay, .modal-card como caja,
 * .modal-header / .modal-body / .modal-actions) vive en
 * shared/modal.css. Aquí solo quedan los estilos específicos
 * de los formularios de tests dentro de .modal-card. */
/* El padding lo pone .modal-body; aquí solo el layout del form. */
.modal form { display: flex; flex-direction: column; gap: 0.7rem; }
.modal label { display: block; font-weight: 600; }
.modal input, .modal textarea, .modal select {
  display: block; width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 0.95rem;
  background: var(--bg-panel); color: var(--txt);
}
.modal input:focus, .modal textarea:focus, .modal select:focus {
  outline: none; border-color: var(--pri); box-shadow: 0 0 0 4px var(--pri-glow);
}
.modal textarea { font-family: monospace; font-size: 0.85rem; }

/* Gestión solo a quien tenga permisos */
body:not(.puede-gestionar) .gestion { display: none !important; }
body:not(.es-admin)         .solo-admin { display: none !important; }

/* ─── Usuarios ─── */
.usuarios-list {
  list-style: none; padding: 0;
  display: flex; flex-direction: column; gap: 0.55rem;
}
.usuarios-list .usuario-row {
  background: var(--bg-panel); padding: 0.85rem 1rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 0.7rem; cursor: pointer;
  color: var(--txt);
}
.usuarios-list .avatar-row {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: #fff; font-weight: 700;
  border-radius: 50%; font-size: 1rem;
  user-select: none;
}
[data-theme="dark"] .usuarios-list .avatar-row { color: #14241D; }
.usuarios-list .nombre { font-weight: 600; word-break: break-word; }
.usuarios-list .meta { color: var(--txt-soft); font-size: 0.8rem; }
.usuarios-list .roles-chips {
  display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem;
}
.usuarios-list .role-chip {
  background: var(--pri-soft); color: var(--pri-d);
  padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem;
  font-weight: 600;
}
.usuarios-list .role-chip.admin { background: var(--accent-soft); color: var(--accent-d); }
[data-theme="dark"] .usuarios-list .role-chip.admin { background: rgba(244, 208, 63, 0.20); color: var(--accent); }
.usuarios-list .inactivo { opacity: 0.55; }

.modal-body h4 { margin: 0; font-size: 0.85rem; color: var(--txt-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.modal-body .roles-grid {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.modal-body .role-toggle {
  background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--txt);
  padding: 0.45rem 0.85rem; border-radius: 999px;
  cursor: pointer; font-size: 0.9rem;
  min-height: 36px;
  font-family: inherit;
}
.modal-body .role-toggle.active {
  background: var(--pri); color: #fff; border-color: var(--pri);
}
[data-theme="dark"] .modal-body .role-toggle.active { color: #14241D; }
.modal-body .input-row {
  display: flex; gap: 0.5rem; align-items: stretch; flex-wrap: wrap;
}
.modal-body .input-row input {
  flex: 1; min-width: 160px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 0.95rem;
  background: var(--bg-panel); color: var(--txt);
}


/* ════════════════ TABLET (>= 600 px) ════════════════ */
@media (min-width: 600px) {
  .user-chip .user-name { display: inline; max-width: 140px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .actions-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .view-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
  }
  /* El detalle de un test mantiene su layout en columna incluso en
   * tablet/desktop: título arriba, CTA principal en su fila y las
   * acciones secundarias en la última. Así ni el título ni "Empezar
   * test" se ven aplastados al lado de un timer estrecho. */
  .view-header.test-detail-header { flex-direction: column; align-items: stretch; }
  .view-header h2 { font-size: 1.4rem; flex: 1; min-width: 200px; }
  .inline-form {
    flex-direction: row; flex-wrap: wrap; align-items: stretch;
  }
  .inline-form input, .inline-form select { width: auto; flex: 1; min-width: 200px; }
}


/* ════════════════ DESKTOP (>= 900 px) ════════════════
 * El grid body + sidebar + topbar lo pinta shared/app-shell.css. Aquí
 * solo van las particularidades de tests: tamaño del brand, colocación
 * del contenido en la columna "main" y ajustes de tarjetas. */
@media (min-width: 900px) {
  .brand-name { font-size: 1.05rem; }
  .user-chip {
    margin-left: auto;
    padding-left: 0.4rem;
  }
  .user-chip .user-name { max-width: 180px; }
  .hamburger { display: none; }
  .content { grid-area: main; padding: 1.5rem; max-width: none; overflow-x: hidden; }
  .auth-card { margin-top: 3rem; padding: 2rem; }
}

/* .badge vive en shared/components.css. */


/* ─────────────────────────── Gamificación ───────────────────────────────── */
/* Tarjeta de gamificación (nivel, racha, reto en curso) y .progress-bar
 * viven en shared/gamif.css: se usan iguales en tests y teoría. */

/* Vista completa de retos */
.retos-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}
.retos-tab {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--txt);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
}
.retos-tab:hover { transform: translateY(-1px); background: var(--bg-alt); }
.retos-tab.active {
  background: var(--pri);
  color: var(--bg-panel);
  border-color: var(--pri);
}
[data-theme="dark"] .retos-tab.active { color: var(--bg); }

.retos-grid, .logros-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.reto-card, .logro-card {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .2s ease;
}
.reto-card:hover, .logro-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.reto-card.completado, .logro-card.obtenido {
  background: linear-gradient(135deg, var(--pri-soft), var(--leaf-soft));
  border-color: var(--pri);
}
.reto-card.completado .progress-bar > span,
.logro-card.obtenido .progress-bar > span {
  background: linear-gradient(90deg, var(--leaf), var(--pri));
}

.reto-icono, .logro-icono {
  font-size: 1.9rem;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.08));
}
.reto-body, .logro-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.reto-body strong, .logro-body strong { font-size: 1rem; }
.reto-body p, .logro-body p { margin: 0; }

.logro-card:not(.obtenido) .logro-icono { filter: grayscale(0.8) opacity(0.7); }

/* Sección de notificaciones push en el modal de configuración */
.push-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
#config-push-wrap.push-nosoporte #btn-activar-push { cursor: not-allowed; opacity: 0.7; }
#push-status { margin-top: 0.5rem; }

.push-diagnose {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.push-diag-out {
  margin: 0.55rem 0 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--txt);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-x: auto;
}


/* ── Fase 5: Oposiciones y perfiles ────────────────────────────────────── */
.oposiciones-tabs {
  display: flex; gap: 6px;
  background: var(--bg-soft);
  padding: 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  width: fit-content;
}
.oposiciones-tab {
  padding: 8px 18px; border-radius: 999px;
  font-size: 0.92rem; font-weight: 600;
  color: var(--txt-soft);
  background: transparent; border: 0;
  cursor: pointer;
  font-family: inherit;
}
.oposiciones-tab.active {
  background: var(--pri); color: #fff;
  cursor: default;
}
[data-theme="dark"] .oposiciones-tab.active { color: #14241D; }
.oposiciones-panel.hidden { display: none; }

.oposiciones-list, .perfiles-list {
  list-style: none; padding: 0; margin: 1rem 0 0;
  display: flex; flex-direction: column; gap: 0.55rem;
}
.opos-item, .perf-item {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}
.opos-head, .perf-head {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 0.2rem;
}
.opos-actions {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* .check-list y .check-item viven en shared/components.css. */

/* ── Modal BULK: picker de tests con filtros ─────────────────────────── */
.modal-bulk-card,
ap-modal[data-wide] .modal-card { width: min(720px, 96vw); max-width: none; }
.bulk-body { display: flex; flex-direction: column; gap: 0.6rem; }
.bulk-toolbar {
  display: grid; grid-template-columns: 1fr auto; gap: 0.5rem;
}
.bulk-toolbar input[type=search] {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.95rem; background: var(--bg-panel); color: var(--txt);
}
.bulk-toolbar input[type=search]:focus {
  outline: none; border-color: var(--pri);
}
.bulk-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.bulk-list {
  max-height: min(60vh, 520px);
  overflow-y: auto;
}
.bulk-list .check-item {
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
}
.bulk-list .check-item strong { display: block; }

/* Modal N×M: cada sección (oposiciones destino + tests a asignar)
 * lleva su propio recuadro con contador, filtros y su lista scrolleable. */
.bulk-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem 0.75rem;
  margin: 0.6rem 0;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.bulk-section legend {
  padding: 0 0.35rem;
  font-weight: 600;
  color: var(--txt);
}
.bulk-section .bulk-list {
  max-height: min(32vh, 260px);
}

/* Barra bajo el formulario de "Crear oposición" con el atajo bulk N×M. */
.opos-toolbar {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin: 0.6rem 0 0.8rem;
}

/* ── Cabecera unificada de Home (saludo + selector de oposición) ─────────
 * Vive en shared/user-header.css: la comparten tests y teoría. */


/* ─────────── Resumen del test (vista final tras terminar un quiz) ───────────
 * Sustituye la tarjeta flotante de XP por una vista integrada que ordena
 * en secciones la nota, los aciertos/fallos, las recompensas conseguidas
 * durante el test (línea a línea) y el desglose de XP. */
.quiz-summary {
  display: flex; flex-direction: column;
  gap: 1rem;
  max-width: 640px;
  margin: 0.5rem auto 2rem;
}
.quiz-summary-actions {
  display: flex; justify-content: center;
  margin-top: 0.4rem;
}
.quiz-summary-actions .btn { min-width: 200px; }

/* Cabecera del resumen: medalla con la nota + progreso de acierto. */
.summary-hero {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 1.15rem;
  background: linear-gradient(135deg, var(--pri-soft), var(--sky-soft) 60%, var(--lavender-soft));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.summary-hero::after {
  content: "";
  position: absolute; inset: -40% -20% auto auto;
  width: 220px; height: 220px;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 65%);
  pointer-events: none;
}
.summary-hero-medal {
  --medal-tint: var(--pri);
  --medal-soft: var(--pri-soft);
  flex: 0 0 auto;
  width: 96px; height: 96px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 30%, #fff 0%, var(--medal-soft) 70%);
  color: var(--medal-tint);
  border: 3px solid var(--medal-tint);
  box-shadow: 0 6px 18px var(--medal-soft), inset 0 0 0 6px rgba(255,255,255,0.35);
  font-weight: 800;
  position: relative; z-index: 1;
}
[data-theme="dark"] .summary-hero-medal {
  background: radial-gradient(circle at 30% 30%, var(--bg-panel) 0%, var(--medal-soft) 70%);
  box-shadow: 0 6px 18px var(--medal-soft), inset 0 0 0 6px rgba(255,255,255,0.06);
}
.summary-hero-medal.sobresa { --medal-tint: var(--leaf); --medal-soft: var(--leaf-soft); }
.summary-hero-medal.aprob   { --medal-tint: var(--sky-d); --medal-soft: var(--sky-soft); }
.summary-hero-medal.just    { --medal-tint: var(--accent-d); --medal-soft: var(--accent-soft); }
.summary-hero-medal.susp    { --medal-tint: var(--coral-d); --medal-soft: var(--coral-soft); }
[data-theme="dark"] .summary-hero-medal.aprob { --medal-tint: var(--sky); }
[data-theme="dark"] .summary-hero-medal.just  { --medal-tint: var(--accent); }
[data-theme="dark"] .summary-hero-medal.susp  { --medal-tint: var(--coral); }
.summary-hero-nota { font-size: 1.9rem; line-height: 1; letter-spacing: -0.02em; }
.summary-hero-nota-l { font-size: 0.75rem; opacity: 0.7; margin-top: 2px; font-weight: 600; }
.summary-hero-info {
  flex: 1; min-width: 0;
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.summary-hero-title {
  font-size: 1.15rem; font-weight: 700; color: var(--txt);
  word-break: break-word; line-height: 1.2;
}
.summary-hero-sub { color: var(--txt-soft); font-size: 0.85rem; }
.summary-hero-bar {
  height: 8px; border-radius: 999px;
  background: rgba(0,0,0,0.08); overflow: hidden;
  margin-top: 0.25rem;
}
[data-theme="dark"] .summary-hero-bar { background: rgba(255,255,255,0.1); }
.summary-hero-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--pri), var(--leaf));
  border-radius: inherit;
  transition: width 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

/* Fila de stats compacta: aciertos / fallos / blanco. */
.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.stat-mini {
  display: flex; flex-direction: column; align-items: center;
  padding: 0.75rem 0.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm, var(--shadow));
  --mini-tint: var(--pri);
}
.stat-mini.stat-hit   { --mini-tint: var(--leaf); }
.stat-mini.stat-miss  { --mini-tint: var(--coral-d); }
.stat-mini.stat-blank { --mini-tint: var(--lavender-d); }
[data-theme="dark"] .stat-mini.stat-miss  { --mini-tint: var(--coral); }
[data-theme="dark"] .stat-mini.stat-blank { --mini-tint: var(--lavender); }
.stat-mini-ico { font-size: 1.15rem; line-height: 1; }
.stat-mini-v {
  font-size: 1.55rem; font-weight: 800; line-height: 1.1;
  color: var(--mini-tint); margin-top: 0.1rem;
}
.stat-mini-l { color: var(--txt-soft); font-size: 0.78rem; font-weight: 600; }

/* Secciones (recompensas / XP). */
.summary-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm, var(--shadow));
}
.summary-section-title {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--txt);
  letter-spacing: 0.01em;
}

/* Lista de bonos / logros conseguidos, línea a línea. */
.bonus-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.bonus-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--pri);
  border-radius: 10px;
  background: var(--bg);
  animation: bonus-in 0.32s ease both;
}
.bonus-row.es-reto { border-left-color: var(--coral); background: linear-gradient(90deg, var(--coral-soft), transparent 60%); }
.bonus-row.es-logro { border-left-color: var(--accent-d); background: linear-gradient(90deg, var(--accent-soft), transparent 60%); }
[data-theme="dark"] .bonus-row.es-logro { border-left-color: var(--accent); }
.bonus-ico { font-size: 1.3rem; line-height: 1; }
.bonus-body { display: flex; flex-direction: column; min-width: 0; }
.bonus-body strong { font-size: 0.92rem; color: var(--txt); }
.bonus-desc { font-size: 0.78rem; color: var(--txt-soft); }
.bonus-xp {
  font-weight: 800; font-size: 0.9rem;
  color: var(--pri-d);
  background: var(--pri-soft);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}
[data-theme="dark"] .bonus-xp { color: var(--pri); }
.bonus-row.es-reto  .bonus-xp { color: var(--coral-d); background: var(--coral-soft); }
.bonus-row.es-logro .bonus-xp { color: var(--accent-d); background: var(--accent-soft); }
[data-theme="dark"] .bonus-row.es-reto  .bonus-xp { color: var(--coral); }
[data-theme="dark"] .bonus-row.es-logro .bonus-xp { color: var(--accent); }
@keyframes bonus-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Desglose de XP (base + volumen + nota + racha) — línea a línea. */
.summary-xp-head {
  display: flex; align-items: baseline; gap: 0.6rem;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}
.summary-xp-head .summary-section-title { margin: 0; }
.summary-xp-total {
  font-weight: 800; font-size: 1.15rem;
  color: var(--pri-d);
  background: var(--pri-soft);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
}
[data-theme="dark"] .summary-xp-total { color: var(--pri); }
.xp-breakdown {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column;
}
.xp-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.1rem;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}
.xp-row:last-child { border-bottom: 0; }
.xp-ico { font-size: 1.05rem; line-height: 1; }
.xp-txt { color: var(--txt); }
.xp-val {
  font-weight: 700; color: var(--pri-d);
  white-space: nowrap;
}
[data-theme="dark"] .xp-val { color: var(--pri); }

@media (max-width: 380px) {
  .summary-hero { flex-direction: column; align-items: flex-start; text-align: left; }
  .summary-hero-medal { align-self: center; }
  .summary-stats { grid-template-columns: repeat(3, 1fr); }
  .stat-mini-v { font-size: 1.35rem; }
}
