/* ============================================================
   Oracle SQL Quest — estilos
   Tema oscuro corporativo Stemdo. Paleta extraída de los activos
   de marca (logo.png / fondo.png): negro carbón + índigo, teal,
   rojo y violeta. Soporte de layout responsive.
   ============================================================ */

:root {
  --bg: #0c0c10;
  --bg-elevated: #17171d;
  --bg-card: #1b1b22;
  --bg-card-hover: #232330;
  --border: #2c2c38;
  --text: #f1f1f5;
  --text-dim: #a5a5b3;
  --text-faint: #74747f;
  --accent: #4f46e5;
  --accent-strong: #6d64ff;
  --accent-soft: rgba(79, 70, 229, 0.18);
  --teal: #14b8a6;
  --teal-soft: rgba(20, 184, 166, 0.16);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --purple: #8b7ff0;
  --purple-soft: rgba(139, 127, 240, 0.16);
  --blue: #60a5fa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Code", "Consolas", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 800px at 80% -10%, #1c1a3a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

.hidden { display: none !important; }

#app {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3563; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- Sidebar ---------------- */

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-elevated), #0e1428);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 4px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .15s ease;
}
.brand:hover { background: var(--bg-card-hover); }
/* logo.png es un lienzo cuadrado de 400x400 con el wordmark real ocupando solo una
   franja estrecha en el centro; se recorta con background-position/-size en vez de
   escalar el <img> completo, o el logo "grande" seguiría viéndose diminuto. */
.brand-logo {
  width: 147px;
  height: 34px;
  display: block;
  background-image: url('logo.png');
  background-repeat: no-repeat;
  background-size: 174px 174px;
  background-position: -15px -68px;
  filter: drop-shadow(0 0 6px rgba(109,100,255,.35));
}
.brand h1 {
  font-size: 16px;
  margin: 0;
  line-height: 1.2;
}
.brand span {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 400;
}

.xp-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.xp-panel .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.xp-panel .xp-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-strong);
}
.xp-panel .xp-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 6px;
  background: #0d1430;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--accent));
  border-radius: 6px;
  transition: width .4s ease;
}
.xp-sub {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  margin: 4px 4px 0;
}

.level-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
}

.level-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease;
  font-size: 13.5px;
}
.level-item:hover { background: var(--bg-card-hover); }
.level-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.level-item .lv-title {
  flex: 1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.level-item .lv-status { font-size: 13px; }
.level-item.locked { opacity: .45; cursor: not-allowed; }
.level-item.completed .lv-title { color: var(--green); }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  text-align: left;
  transition: all .15s ease;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ---------------- Main content ---------------- */

.main {
  flex: 1;
  min-width: 0;
  padding: 26px 34px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar .badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pill {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.pill.streak { border-color: var(--accent); color: var(--accent-strong); }

.view { display: none; animation: fadeIn .25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px);} to { opacity:1; transform:none; } }

/* dashboard */
.dash-header h2 { margin: 0 0 4px; font-size: 24px; }
.dash-header p { margin: 0 0 22px; color: var(--text-dim); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card .num { font-size: 26px; font-weight: 700; }
.stat-card .lbl { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.level-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  position: relative;
  overflow: hidden;
}
.level-card:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--bg-card-hover); }
.level-card.locked { cursor: not-allowed; opacity: .5; }
.level-card .lc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.level-card .lc-code { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.level-card h3 { font-size: 15px; margin: 8px 0 4px; }
.level-card .lc-progress { margin-top: 12px; }
.level-card .lc-tag {
  position: absolute; top: 12px; right: 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 9px;
  max-width: calc(100% - 24px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- Level view ---------------- */

.level-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}
.level-header h2 { margin: 0; font-size: 22px; }
.level-header p { margin: 2px 0 0; color: var(--text-dim); font-size: 13.5px; }

.tabs {
  display: flex;
  gap: 4px;
  margin: 18px 0 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13.5px;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent-strong); border-color: var(--accent); }

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn .2s ease; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h4 { margin: 0 0 8px; font-size: 15px; }
.card p { margin: 0; color: var(--text-dim); line-height: 1.55; font-size: 14px; }

/* Teoria: guia de estudio unificada, lectura vertical continua (sin tarjetas por bloque) */
.theory-doc {
  max-width: 720px;
  margin: 0 auto;
}
.theory-section {
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.theory-section:last-of-type { border-bottom: none; }
.theory-section h3 {
  font-size: 21px;
  margin: 0 0 12px;
  color: var(--text);
  letter-spacing: -.01em;
}
.theory-section p {
  margin: 0 0 16px;
  color: var(--text-dim);
  line-height: 1.75;
  font-size: 15.5px;
}
.theory-section p:last-child { margin-bottom: 0; }
.theory-syntax, .theory-example { margin: 0 0 6px; }
.theory-output { margin: 0 0 16px; }
.theory-output-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.theory-output-block { color: #8fd6a8; }
.theory-sources {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}
.theory-callout {
  margin: 28px 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--accent);
}
.theory-callout h4 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent-strong);
}
.theory-callout ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.theory-callout li {
  color: var(--text-dim);
  line-height: 1.6;
  font-size: 14.5px;
  padding-left: 16px;
  position: relative;
}
.theory-callout li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.theory-summary { border-left-color: var(--teal); }
.theory-summary h4 { color: var(--teal); }
.theory-summary li::before { background: var(--teal); }
.theory-docs-link {
  text-align: center;
  margin: 32px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.theory-docs-link a {
  color: var(--text-faint);
  text-decoration: none;
  font-size: 13px;
}
.theory-docs-link a:hover { color: var(--accent-strong); text-decoration: underline; }

pre.code-block {
  background: #0a0f22;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  color: #c9e9ff;
  line-height: 1.5;
}
.example-title { font-size: 13.5px; color: var(--text-dim); margin: 0 0 6px; font-weight: 600; }

/* Chuleta de sintaxis (pestaña Ejemplos) */
.cheat-sheet-card { border-left: 3px solid var(--purple); }
.cheat-sheet-card h4 {
  margin: 0 0 14px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--purple);
}
.cheat-sheet-item { margin-bottom: 14px; }
.cheat-sheet-item:last-child { margin-bottom: 0; }
.cheat-sheet-heading {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.cheat-sheet-item pre.code-block { margin: 0; }

.challenges-intro {
  font-size: 13px;
  font-style: italic;
  color: var(--text-faint);
  margin: 0 0 16px;
  line-height: 1.55;
}


.mistake-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mistake-list li {
  background: var(--red-soft);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13.5px;
  color: #ffd7d7;
  display: flex;
  gap: 8px;
}

/* Subconceptos anidados dentro de un concepto de teoría (1.1, 1.2, ...) */
.theory-subsection {
  margin: 18px 0 0 18px;
  padding: 14px 0 14px 16px;
  border-left: 2px solid var(--border);
}
.theory-subsection h4 {
  margin: 0 0 8px;
  font-size: 15.5px;
  color: var(--text);
}
.theory-subsection p {
  margin: 0 0 12px;
  color: var(--text-dim);
  line-height: 1.65;
  font-size: 14.5px;
}
.theory-subsection p:last-child { margin-bottom: 0; }
.theory-common-errors {
  background: var(--red-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 10px;
}
.theory-common-errors ul { margin: 4px 0 0; padding: 0 0 0 16px; }
.theory-common-errors li { color: #ffd7d7; font-size: 13px; line-height: 1.55; margin-bottom: 4px; }

/* Tabla comparativa dentro de Teoria */
.theory-table-wrap { overflow-x: auto; }
.comparison-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.comparison-table th, .comparison-table td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  color: var(--text-dim);
}
.comparison-table th {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.comparison-table tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.theory-table h4 { color: var(--purple); }
.theory-table { border-left-color: var(--purple); }

/* Mapa mental textual */
.theory-mindmap { border-left-color: var(--blue); }
.theory-mindmap h4 { color: var(--blue); }
.mindmap-node { margin-bottom: 4px; }
.mindmap-topic { font-weight: 700; color: var(--text); font-size: 14px; margin-bottom: 8px; }
.mindmap-node ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mindmap-node li {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.55;
  padding-left: 18px;
  position: relative;
}
.mindmap-node li::before {
  content: "→";
  position: absolute;
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  color: var(--blue);
}

/* Errores tipicos de examen (formato profundo: {mistake, why}) */
.mistake-card { border-left: 3px solid var(--red); }
.mistake-card h4 { color: #ffd7d7; font-size: 14.5px; }
.mistake-why { display: flex; flex-direction: column; gap: 6px; }

/* Casos reales */
.real-case-card { border-left: 3px solid var(--teal); }
.real-case-card h4 { color: var(--teal); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }

/* Ejercicios resueltos paso a paso */
.solved-card { border-left: 3px solid var(--purple); }
.solved-problem { font-style: italic; margin-bottom: 12px !important; }
.solved-steps { margin: 0 0 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.solved-steps li { color: var(--text-dim); font-size: 14px; line-height: 1.55; }

/* Insignias de dificultad en ejercicios guiados */
.difficulty-badge {
  display: inline-block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: middle;
  font-weight: 700;
}
.diff-basico { background: var(--teal-soft); color: var(--teal); }
.diff-intermedio { background: var(--accent-soft); color: var(--accent-strong); }
.diff-avanzado { background: var(--red-soft); color: #ff9b9b; }
.diff-otro { background: var(--bg-elevated); color: var(--text-faint); }

/* Flashcards */
.flashcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.flashcard {
  perspective: 1200px;
  height: 160px;
  cursor: pointer;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .5s;
  transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}
.flashcard-front { background: var(--bg-card); color: var(--text); }
.flashcard-back {
  background: linear-gradient(135deg, var(--accent-soft), var(--purple-soft));
  color: var(--text);
  transform: rotateY(180deg);
  font-size: 13.5px;
}
.flashcard-hint { color: var(--text-faint); font-size: 12.5px; text-align: center; margin-top: 14px; }

/* Flashcards: CTA dentro de la pestaña de un módulo */
.flashcard-cta { text-align: left; }
.flashcard-cta .btn { margin-top: 14px; }
.flashcard-progress-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.fc-stat {
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.fc-stat-unknown { border-color: rgba(239,68,68,.4); color: #ff9b9b; }
.fc-stat-doubt { border-color: rgba(245,158,11,.4); color: #fbbf6a; }
.fc-stat-known { border-color: rgba(34,197,94,.4); color: #7de3a4; }

/* Flashcards: vista global (sidebar) */
.flashcard-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.flashcard-select-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 600;
}
.flashcard-select-label select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: var(--font);
  cursor: pointer;
  max-width: 360px;
}
.flashcard-select-label select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.flashcard-solo-wrap { max-width: 620px; margin: 20px auto 0; }
.flashcard-solo {
  height: 280px;
  perspective: 1600px;
}
.flashcard-solo .flashcard-face {
  flex-direction: column;
  gap: 14px;
  padding: 28px 32px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
}
.flashcard-solo .flashcard-back { font-size: 17px; font-weight: 500; }
.flashcard-tag {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
}
.flashcard-text { max-width: 100%; }
.flashcard-status {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 14px;
}
.fc-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin: 0 2px; }
.fc-dot-unknown { background: var(--red); }
.fc-dot-doubt { background: var(--amber); }
.fc-dot-known { background: var(--green); }
.fc-dot-new { background: var(--text-faint); }

.flashcard-rate-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 22px;
}
.flashcard-rate-btn { min-width: 130px; }
.btn.fc-rate-unknown { background: linear-gradient(135deg, var(--red), #fca5a5); color: #2a0a0a; }
.btn.fc-rate-doubt { background: linear-gradient(135deg, var(--amber), #fcd34d); color: #2a1a06; }
.btn.fc-rate-known { background: linear-gradient(135deg, var(--green), #86efac); color: #06280f; }

.flashcard-nav-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* Quiz con explicacion por opcion */
.explain-detailed { border-left-color: var(--accent-strong); }
.explain-verdict { font-weight: 700; margin: 0 0 10px; color: var(--text); }
.option-explain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.option-explain-list li { font-size: 13px; line-height: 1.55; color: var(--text-dim); }
.option-explain-list li.opt-correct { color: #b9f5cf; }
.option-explain-list li.opt-correct strong { color: var(--green); }
.option-explain-list li.opt-selected-wrong strong { color: var(--red); }

/* quiz */
.quiz-progress { color: var(--text-faint); font-size: 12.5px; margin-bottom: 10px; }
.quiz-question { font-size: 16px; margin: 0 0 16px; }
.option-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; }
.option-btn {
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: all .15s ease;
}
.option-btn:hover { border-color: var(--accent); }
.option-btn.correct { background: rgba(74,222,128,.15); border-color: var(--green); }
.option-btn.incorrect { background: var(--red-soft); border-color: var(--red); }
.option-btn:disabled { cursor: default; }

.explain-box {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #1a1206;
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13.5px;
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active { transform: translateY(0) scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn.secondary:hover { border-color: var(--teal); color: var(--teal); }
.btn.danger { background: linear-gradient(135deg, var(--red), #fca5a5); color: #2a0a0a; }

.quiz-result {
  text-align: center;
  padding: 30px 10px;
}
.quiz-result .big-score { font-size: 44px; font-weight: 800; color: var(--accent-strong); }

/* exercises / challenges */
.exercise-card details { margin-top: 10px; }
.exercise-card summary {
  cursor: pointer;
  color: var(--teal);
  font-size: 13px;
  outline: none;
  margin-top: 6px;
}
.exercise-card summary + div { margin-top: 8px; }
.diff-badge {
  display: inline-block;
  font-size: 10.5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  margin-left: 8px;
  vertical-align: middle;
}

/* level complete banner */
.complete-banner {
  background: linear-gradient(135deg, rgba(74,222,128,.15), rgba(45,212,191,.1));
  border: 1px solid rgba(74,222,128,.35);
  color: var(--green);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* error review */
.error-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.error-card .eq { font-size: 14.5px; margin-bottom: 8px; }
.error-card .your-answer { color: var(--red); font-size: 13px; margin-bottom: 4px; }
.error-card .right-answer { color: var(--green); font-size: 13px; margin-bottom: 8px; }
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}
.empty-state .big-icon { font-size: 46px; display: block; margin-bottom: 12px; }

/* exam timer */
.exam-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 20px;
}
.timer {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-strong);
}
.timer.warning { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.5;} }

.exam-nav-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.dot.current { border-color: var(--accent); color: var(--accent-strong); }
.dot.answered { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }

/* badges screen */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px,1fr));
  gap: 14px;
}
.badge-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 10px;
  text-align: center;
  transition: transform .15s ease, border-color .15s ease;
}
.badge-item:not(.locked):hover { transform: translateY(-3px) scale(1.03); border-color: var(--accent); }
.badge-item .b-name { font-size: 11.5px; color: var(--text-dim); }
.badge-item.locked { opacity: .3; }
@keyframes badgePop {
  0% { transform: scale(.4) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.badge-item.just-unlocked { animation: badgePop .5s ease; }

.stat-card, .kpi-card { transition: transform .15s ease, border-color .15s ease; }
.stat-card:hover, .kpi-card:hover { transform: translateY(-2px); border-color: var(--accent); }

/* toast */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  z-index: 999;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
}
#toast.show { transform: translateY(0); opacity: 1; }

/* ============================================================
   LANDING PAGE
   ============================================================ */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 34px;
  flex-wrap: wrap;
  gap: 12px;
}
.landing-brand { display: flex; align-items: center; gap: 14px; }
.landing-logo {
  width: 191px;
  height: 44px;
  display: block;
  background-image: url('logo.png');
  background-repeat: no-repeat;
  background-size: 226px 226px;
  background-position: -19px -88px;
}
.landing-brand-divider { width: 1px; height: 30px; background: var(--border); }
.landing-brand-name { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.landing-nav-pills { display: flex; gap: 8px; flex-wrap: wrap; }

.hero {
  position: relative;
  margin: 0 24px 8px;
  border-radius: 20px;
  overflow: hidden;
  min-height: 380px;
  display: flex;
  align-items: center;
  background-size: cover;
  background-position: center right;
  border: 1px solid var(--border);
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(12,12,16,.97) 20%, rgba(12,12,16,.72) 55%, rgba(12,12,16,.35) 100%);
}
.hero-content {
  position: relative;
  z-index: 1;
  padding: 48px 5% 48px 5%;
  max-width: 640px;
}
.hero-kicker {
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 14px;
}
.hero-content h1 {
  font-size: 42px;
  margin: 0 0 12px;
  line-height: 1.1;
  background: linear-gradient(90deg, var(--text), var(--accent-strong) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  color: var(--text-dim);
  font-size: 16px;
  margin: 0 0 26px;
  line-height: 1.5;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.btn-hero { padding: 13px 24px; font-size: 14.5px; }
.hero-stats { display: flex; gap: 18px; flex-wrap: wrap; }
.hero-stat { font-size: 12.5px; color: var(--text-dim); }
.hero-stat strong { color: var(--text); font-size: 15px; display: block; }

.landing-cards {
  padding: 34px 24px 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.landing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
  position: relative;
}
.landing-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow);
}
.landing-card h3 { margin: 0 0 6px; font-size: 16px; }
.landing-card p { margin: 0 0 14px; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.lcard-status {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.landing-footer {
  margin-top: auto;
  text-align: center;
  padding: 26px 20px;
  color: var(--text-faint);
  font-size: 12px;
}

/* ============================================================
   DASHBOARD — KPIs, indicador circular, mensaje motivacional
   ============================================================ */

.motivational-banner {
  background: linear-gradient(120deg, var(--accent-soft), var(--purple-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 22px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.kpi-card .num { font-size: 24px; font-weight: 700; }
.kpi-card .lbl { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.kpi-card .sub-bar {
  margin-top: 10px;
  display: flex;
  height: 6px;
  border-radius: 6px;
  overflow: hidden;
  background: #0d1430;
}
.kpi-card .sub-bar .seg-correct { background: var(--green); }
.kpi-card .sub-bar .seg-wrong { background: var(--red); }

.progress-ring-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}
.ring-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.ring-card .ring-label { font-size: 13px; color: var(--text-dim); }
.ring-card .ring-value { font-size: 20px; font-weight: 700; color: var(--text); margin-top: 2px; }
.progress-ring circle { transition: stroke-dashoffset .6s ease; }
.progress-ring text { font-size: 8px; font-weight: 700; fill: var(--text); }

/* ============================================================
   CONFETI (vanilla, sin dependencias)
   ============================================================ */

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1200;
}

/* ============================================================
   RANGOS (Fase 4)
   ============================================================ */

.sidebar-rank {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.rank-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 22px;
}
.rank-caption { margin: 14px 0 0; font-size: 13px; color: var(--text-dim); text-align: center; }
.rank-caption strong { color: var(--accent-strong); }

.rank-stepper {
  display: flex;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 4px;
}
.rank-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 92px;
  opacity: .4;
}
.rank-step.reached { opacity: 1; }
.rank-step-name {
  font-size: 10.5px; color: var(--text-dim); text-align: center; white-space: nowrap;
  padding: 8px 4px;
  border-radius: 20px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
}
.rank-step.reached .rank-step-name { border-color: var(--teal); background: var(--teal-soft); }
.rank-step.current .rank-step-name { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); }
.rank-step.current .rank-step-name { color: var(--accent-strong); font-weight: 700; }
.rank-step-connector { flex: 1; min-width: 20px; height: 2px; background: var(--border); margin-bottom: 22px; }

/* ============================================================
   INSIGNIAS — secciones y condiciones (Fase 4)
   ============================================================ */

.badge-section-title { font-size: 13px; color: var(--text-dim); margin: 8px 0 12px; }
.badge-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.b-state { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.b-state.unlocked { color: var(--green); }
.b-desc { font-size: 10.5px; color: var(--text-faint); line-height: 1.4; margin-top: 2px; }

/* ============================================================
   REPASO DE ERRORES — evolución (Fase 5)
   ============================================================ */

.evolution-card { max-width: 360px; margin-bottom: 22px; }

/* ============================================================
   ESTADO DE PREPARACIÓN
   ============================================================ */

.prep-pill {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.prep-pill.prep-green { background: rgba(34,197,94,.16); color: var(--green); }
.prep-pill.prep-yellow { background: rgba(234,179,8,.16); color: #eab308; }
.prep-pill.prep-red { background: var(--red-soft); color: var(--red); }
.motivational-banner { flex-wrap: wrap; }

/* ============================================================
   ANALYTICS — radar, heatmap, distribución, evolución (Fase 5)
   ============================================================ */

.radar-svg { width: 100%; max-width: 420px; height: auto; display: block; margin: 10px auto; }
.radar-ring { fill: none; stroke: var(--border); stroke-width: 1; }
.radar-shape { fill: var(--accent-soft); stroke: var(--accent-strong); stroke-width: 2; }
.radar-dot { fill: var(--accent-strong); }
.radar-label { font-size: 8.5px; fill: var(--text-dim); }

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.heatmap-cell {
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
}
.heatmap-cell .hm-name { font-size: 11px; color: var(--text-dim); }
.heatmap-cell .hm-pct { font-size: 15px; font-weight: 700; }
.heatmap-cell.tier-high { background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.35); }
.heatmap-cell.tier-high .hm-pct { color: var(--green); }
.heatmap-cell.tier-mid { background: rgba(234,179,8,.14); border-color: rgba(234,179,8,.35); }
.heatmap-cell.tier-mid .hm-pct { color: #eab308; }
.heatmap-cell.tier-low { background: var(--red-soft); border-color: rgba(239,68,68,.35); }
.heatmap-cell.tier-low .hm-pct { color: var(--red); }
.heatmap-cell.tier-nodata { background: var(--bg-elevated); opacity: .55; }
.heatmap-cell.tier-nodata .hm-pct { color: var(--text-faint); font-size: 11px; }

.dist-bar {
  display: flex;
  height: 14px;
  border-radius: 8px;
  overflow: hidden;
  background: #0d1430;
  margin-bottom: 12px;
}
.dist-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.dist-legend-item { font-size: 12px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; }
.dist-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.evo-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 140px;
  padding-top: 10px;
}
.evo-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.evo-bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--accent-strong), var(--accent)); border-radius: 6px 6px 0 0; transition: height .4s ease; }
.evo-date { font-size: 10px; color: var(--text-faint); }

/* ============================================================
   SIMULADOR — revisión final (Fase 4 del simulador)
   ============================================================ */

.review-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.review-row:last-child { border-bottom: none; }
.review-row:hover { background: var(--bg-elevated); }
.review-num {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700;
  background: var(--bg-elevated); border: 1px solid var(--border);
}
.review-num.answered { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }
.review-num.unanswered { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.review-q-text { flex: 1; font-size: 13px; color: var(--text-dim); }
.review-status { font-size: 12px; white-space: nowrap; }


/* ============================================================
   CERTIFICADO (Fase 8)
   ============================================================ */

.certificate {
  max-width: 720px;
  margin: 0 auto;
  background: linear-gradient(150deg, var(--bg-card), var(--bg-elevated));
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 60px 50px;
  text-align: center;
  position: relative;
}
.certificate::before {
  content: "";
  position: absolute; inset: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  pointer-events: none;
}
.cert-brand { font-weight: 800; letter-spacing: .1em; color: var(--accent-strong); margin-bottom: 18px; }
.cert-title { font-size: 30px; margin: 0 0 6px; }
.cert-sub { color: var(--text-dim); margin: 0 0 30px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.cert-name { font-size: 26px; font-weight: 800; color: var(--accent-strong); margin: 0 0 18px; }
.cert-body { color: var(--text-dim); line-height: 1.7; max-width: 520px; margin: 0 auto 24px; }
.cert-body strong { color: var(--text); }
.cert-date { color: var(--text-faint); font-size: 12.5px; }

@media print {
  body * { visibility: hidden; }
  .certificate, .certificate * { visibility: visible; }
  .certificate { position: absolute; top: 0; left: 0; width: 100%; border: none; }
  .no-print { display: none !important; }
}

/* ============================================================
   LANDING — sección ¿Por qué existe?
   ============================================================ */

.why-section {
  max-width: 1100px;
  margin: 30px auto;
  padding: 0 24px;
}
.why-section h2 { font-size: 22px; margin-bottom: 14px; }
.why-section p { color: var(--text-dim); max-width: 720px; line-height: 1.6; }
.why-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.why-list li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-dim);
}

/* ============================================================
   LANDING — sección Fuentes de referencia
   ============================================================ */

.sources-section {
  max-width: 1100px;
  margin: 30px auto;
  padding: 0 24px;
}
.sources-section h2 { font-size: 22px; margin-bottom: 10px; }
.sources-intro { color: var(--text-dim); max-width: 720px; line-height: 1.6; margin-bottom: 18px; }
.sources-list {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.sources-list li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sources-list a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
}
.sources-list a:hover { color: var(--accent-strong); text-decoration: underline; }
.sources-list span { color: var(--text-faint); font-size: 12px; line-height: 1.4; }

.disclaimer-box {
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.disclaimer-box p { margin: 0 0 6px; color: var(--text-faint); font-size: 12.5px; line-height: 1.6; }
.disclaimer-box p:first-child { color: var(--text-dim); font-weight: 600; }
.disclaimer-box p:last-child { margin-bottom: 0; }

/* responsive */
@media (max-width: 900px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .level-list { max-height: 260px; }
  .main { padding: 18px; }
  .hero { margin: 0 12px 8px; min-height: 320px; }
  .hero-content { padding: 32px 6%; }
  .hero-content h1 { font-size: 30px; }
  .landing-header { padding: 16px 18px; }
  .landing-cards { padding: 24px 12px 10px; }
}

@media (max-width: 560px) {
  .hero-actions { flex-direction: column; }
  .btn-hero { width: 100%; text-align: center; }
  .hero-content h1 { font-size: 26px; }
}
