:root {
  --bg: #081119;
  --bg-soft: #0d1822;
  --panel: #111f2b;
  --panel-2: #162735;
  --line: rgba(255,255,255,.10);
  --text: #f2f7fa;
  --muted: #9fb0bc;
  --accent: #27d3e2;
  --accent-2: #64eef5;
  --accent-soft: rgba(39,211,226,.12);
  --ok: #3ddc97;
  --bad: #ff6b78;
  --warn: #ffc857;
  --radius: 18px;
  --shadow: 0 22px 60px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(39,211,226,.08), transparent 34rem),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
}

button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(39,211,226,.45);
  outline-offset: 3px;
}

a { color: inherit; }

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(39,211,226,.34);
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
}

.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: 12px; margin-top: 1px; }

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { color: var(--accent-2); }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 70px;
}

.hidden { display: none !important; }

.hero-v2 {
  position: relative;
  overflow: hidden;
  min-height: 520px;
  display: grid;
  grid-template-columns:
    minmax(0, 1.35fr)
    minmax(330px, .65fr);
  align-items: center;
  gap: 70px;
  padding: clamp(40px, 6vw, 80px);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 28px;
  background:
    linear-gradient(
      110deg,
      #0c1822 0%,
      #09131c 55%,
      #061017 100%
    );
  box-shadow:
    0 30px 80px rgba(0,0,0,.35);
}

/* GRID TECNOLÓGICO */
.hero-v2::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .23;
  background-image:
    linear-gradient(
      rgba(39,211,226,.12) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(39,211,226,.12) 1px,
      transparent 1px
    );
  background-size: 48px 48px;
  mask-image:
    linear-gradient(
      90deg,
      transparent,
      black 55%,
      black
    );
}

.hero-v2::after {
  content: "";
  position: absolute;
  width: 500px;
  height: 500px;
  right: -230px;
  top: -230px;
  border-radius: 50%;
  background: rgba(39,211,226,.10);
  filter: blur(80px);
}

/* IZQUIERDA */
.hero-main {
  position: relative;
  z-index: 2;
}

.hero-path {
  margin-bottom: 32px;
  color: #718491;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
}

.hero-path span {
  margin: 0 8px;
  color: var(--accent);
}

.hero-version {
  display: inline-block;
  padding: 6px 11px;
  margin-bottom: 20px;
  border: 1px solid rgba(39,211,226,.35);
  border-radius: 999px;
  color: var(--accent-2);
  background: rgba(39,211,226,.07);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
}

.hero-v2 h1 {
  margin: 0 0 25px;
  max-width: 750px;
  font-size: clamp(44px, 6vw, 78px);
  line-height: .98;
  letter-spacing: -.055em;
}

.hero-v2 h1 span {
  color: var(--accent);
}

.hero-v2 p {
  max-width: 630px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.hero-cta,
.hero-practice {
  min-width: 170px;
}

/* PANEL DERECHO */
.exam-panel {
  position: relative;
  z-index: 2;
  padding: 26px;
  border: 1px solid rgba(39,211,226,.22);
  border-radius: 22px;
  background: rgba(5,13,19,.78);
  backdrop-filter: blur(12px);
  box-shadow:
    inset 0 1px rgba(255,255,255,.04),
    0 20px 50px rgba(0,0,0,.30);
}

.exam-panel-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.exam-panel-top span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .15em;
}

.exam-panel-top strong {
  display: block;
  margin-top: 4px;
  color: white;
  font-size: 28px;
}

.exam-live {
  padding: 5px 9px;
  border: 1px solid rgba(61,220,151,.35);
  border-radius: 999px;
  color: var(--ok);
  font-size: 9px;
  letter-spacing: .1em;
}

/* CÍRCULO */
.exam-score {
  display: flex;
  justify-content: center;
  padding: 32px 0;
}

.exam-circle {
  width: 180px;
  height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  background:
    radial-gradient(
      circle closest-side,
      #081119 76%,
      transparent 78%
    ),
    conic-gradient(
      var(--accent) 80%,
      rgba(255,255,255,.07) 0
    );
}

.exam-circle span {
  color: white;
  font-size: 38px;
  font-weight: 850;
}

.exam-circle small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .12em;
}

/* ESTADÍSTICAS */
.exam-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(255,255,255,.07);
  padding-top: 20px;
}

.exam-stats div {
  text-align: center;
}

.exam-stats div + div {
  border-left: 1px solid rgba(255,255,255,.08);
}

.exam-stats strong {
  display: block;
  color: var(--accent-2);
  font-size: 23px;
}

.exam-stats span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

/* Mantener estilos del resto de la app */
.eyebrow {
  display: inline-block;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.results-hero h1 {
  margin: 12px auto 16px;
  line-height: 1.02;
  letter-spacing: -.04em;
  max-width: 780px;
}

.notice {
  margin: 18px 0 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  background: rgba(255,255,255,.025);
  border-radius: 0 10px 10px 0;
  font-size: 13px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 26px;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 360px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.mode-card.featured {
  border-color: rgba(39,211,226,.35);
  background:
    linear-gradient(180deg, rgba(39,211,226,.08), transparent 50%),
    var(--panel);
}
.mode-card h2 { margin: 14px 0 8px; font-size: 24px; }
.mode-card p { color: var(--muted); margin: 0; }
.mode-card ul {
  margin: 20px 0 26px;
  padding-left: 20px;
  color: #cad6dd;
}
.mode-card li + li { margin-top: 8px; }
.mode-card button { margin-top: auto; width: 100%; }

.mode-tag {
  align-self: flex-start;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.mode-tag.muted { background: rgba(255,255,255,.05); color: var(--muted); }

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn, .text-btn, .flag-btn {
  border: 0;
  border-radius: 12px;
  min-height: 46px;
  padding: 0 18px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}

.primary-btn {
  background: var(--accent);
  color: #031217;
  font-weight: 850;
}
.secondary-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  color: var(--text);
  font-weight: 750;
}
.ghost-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}
.danger-btn {
  background: var(--bad);
  color: #220409;
  font-weight: 850;
}
.text-btn {
  min-height: auto;
  padding: 6px 0;
  background: transparent;
  color: var(--muted);
}
.flag-btn {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.flag-btn.active {
  color: var(--warn);
  border-color: rgba(255,200,87,.45);
  background: rgba(255,200,87,.08);
}

.primary-btn:hover, .secondary-btn:hover, .ghost-btn:hover, .danger-btn:hover, .flag-btn:hover {
  transform: translateY(-1px);
}
button:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

.history-panel { margin-top: 56px; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.section-heading h2 { margin: 5px 0 0; font-size: 28px; }
.section-heading.compact h2 { font-size: 22px; }

.history-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.history-item, .history-empty {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}
.history-item strong { display: block; font-size: 22px; }
.history-item span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.history-empty { grid-column: 1 / -1; color: var(--muted); }

.quiz-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}
.quiz-toolbar strong { display: block; margin-top: 5px; font-size: 20px; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }

.timer {
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
  background: var(--panel);
}
.timer span { display: block; color: var(--muted); font-size: 11px; }
.timer strong { margin: 0; font-variant-numeric: tabular-nums; }
.timer.urgent { border-color: rgba(255,107,120,.55); color: var(--bad); }

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255,255,255,.08);
  margin-bottom: 20px;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .25s ease;
}

.quiz-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.question-nav, .question-card, .result-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.question-nav {
  position: sticky;
  top: 16px;
  padding: 17px;
}
.nav-header strong { display: block; margin-bottom: 12px; }
.nav-header span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 8px;
  color: var(--muted);
  font-size: 10px;
}
.legend {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  border: 1px solid var(--line);
}
.legend.answered { background: var(--accent); }
.legend.flagged { background: var(--warn); }

.question-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}
.qnav-btn {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255,255,255,.025);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.qnav-btn.current {
  color: #031217;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 850;
}
.qnav-btn.answered:not(.current) { color: var(--text); border-color: rgba(39,211,226,.42); }
.qnav-btn.flagged::after {
  content: "";
  position: absolute;
  right: 3px; top: 3px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.question-card { padding: clamp(22px, 4vw, 38px); }
.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.category-badge {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}
.question-card h2 {
  margin: 18px 0 26px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.25;
  letter-spacing: -.02em;
}

.answers { display: grid; gap: 12px; }
.answer-option {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  background: rgba(255,255,255,.022);
}
.answer-option:hover { border-color: rgba(39,211,226,.32); }
.answer-option.selected {
  border-color: rgba(39,211,226,.55);
  background: var(--accent-soft);
}
.answer-option.correct {
  border-color: rgba(61,220,151,.55);
  background: rgba(61,220,151,.08);
}
.answer-option.wrong {
  border-color: rgba(255,107,120,.55);
  background: rgba(255,107,120,.08);
}
.answer-option input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.answer-letter {
  color: var(--accent-2);
  font-weight: 850;
  margin-right: 7px;
}
.answer-text { color: #dbe6eb; }

.feedback {
  margin-top: 18px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
}
.feedback.good { border-color: rgba(61,220,151,.4); }
.feedback.bad { border-color: rgba(255,107,120,.4); }
.feedback strong { display: block; margin-bottom: 5px; }
.feedback p { margin: 0; color: var(--muted); }

.question-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.right-actions { display: flex; gap: 10px; }

.results-hero {
  text-align: center;
  padding: 40px 20px 20px;
}
.results-hero h1 {
  margin-left: auto; margin-right: auto;
  font-size: clamp(32px, 5vw, 50px);
}
.score-ring {
  --score: 0;
  width: 180px;
  height: 180px;
  margin: 22px auto;
  display: grid;
  place-content: center;
  border-radius: 50%;
  background:
    radial-gradient(circle closest-side, var(--bg) 78%, transparent 80% 99%, transparent),
    conic-gradient(var(--accent) calc(var(--score) * 1%), rgba(255,255,255,.08) 0);
}
.score-ring strong { font-size: 40px; line-height: 1; }
.score-ring span { margin-top: 7px; color: var(--muted); }
#resultMessage { color: var(--muted); margin: 0 auto; max-width: 700px; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 24px; }

.results-grid {
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: 20px;
  margin-top: 34px;
}
.result-panel { padding: 22px; }

.category-results { display: grid; gap: 14px; }
.category-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: center;
}
.category-row strong { font-size: 14px; }
.category-row span { color: var(--muted); font-size: 13px; }
.category-track {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 99px;
  background: rgba(255,255,255,.07);
  overflow: hidden;
}
.category-fill { height: 100%; background: var(--accent); }

#reviewFilter {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
}
.review-list { display: grid; gap: 12px; }
.review-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.02);
}
.review-item h3 { margin: 5px 0 12px; font-size: 16px; }
.review-item p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.review-item .ok { color: var(--ok); }
.review-item .bad { color: var(--bad); }
.review-item .flag { color: var(--warn); }
.review-empty { color: var(--muted); padding: 18px 0; }

.footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
}
.footer p { margin: 0; }
.footer a { color: var(--accent-2); text-decoration: none; }

@media (max-width: 900px) {
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: auto; }
  .history-list { grid-template-columns: repeat(2, 1fr); }
  .quiz-layout { grid-template-columns: 1fr; }
  .question-nav { position: static; }
  .question-grid { grid-template-columns: repeat(10, 1fr); }
  .results-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { padding-top: 14px; }
  .back-link { display: none; }
  .app-shell { width: min(100% - 20px, 1180px); margin-top: 8px; }
.history-list { grid-template-columns: 1fr; }
  .quiz-toolbar { align-items: flex-start; }
  .toolbar-actions { align-items: stretch; }
  .question-grid { grid-template-columns: repeat(8, 1fr); }
  .question-card { padding: 20px 16px; }
  .question-meta { align-items: flex-start; flex-direction: column; }
  .question-actions { align-items: stretch; flex-direction: column-reverse; }
  .question-actions > button, .right-actions, .right-actions button { width: 100%; }
  .right-actions { flex-direction: column; }
  .result-actions { flex-direction: column; }
  .result-actions button { width: 100%; }
  .section-heading { align-items: flex-start; }
  .section-heading.compact { flex-direction: column; }
  .footer { flex-direction: column; }
}


@media (max-width: 850px) {
  .hero-v2 {
    grid-template-columns: 1fr;
    gap: 45px;
  }

  .exam-panel {
    max-width: 500px;
    width: 100%;
  }
}

@media (max-width: 520px) {
  .hero-v2 {
    padding: 30px 20px;
    border-radius: 20px;
  }

  .hero-v2 h1 {
    font-size: 43px;
  }

  .hero-v2 p {
    font-size: 16px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions button {
    width: 100%;
  }

  .exam-circle {
    width: 150px;
    height: 150px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
