:root {
  --navy: #4e1f85;
  --navy-dark: #3a1763;
  --blue: #4e1f85;
  --blue-hover: #3a1763;
  --gold: #fdc101;
  --gold-ink: #4e1f85;
  --ink: #1c2833;
  --muted: #5d6d7e;
  --line: #d5d8dc;
  --paper: #ffffff;
  --wash: #f7f4fb;
  --warn-bg: #fef9e7;
  --warn-ink: #7d6608;
  --error-bg: #fdecea;
  --error-ink: #922b21;
  --ok-bg: #e8f8f5;
  --ok-ink: #0e6655;
  --fail-bg: #fdecea;
  --fail-ink: #922b21;
  --shadow: 0 8px 24px rgba(12, 32, 64, 0.08);
  --radius: 8px;
  --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--wash);
  line-height: 1.55;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--navy);
  color: #fff;
  padding: 0.5rem 0.75rem;
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand__logo {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #00000000;
  display: block;
}

.brand__kicker,
.brand__name {
  margin: 0;
}

.brand__kicker {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand__name {
  font-size: 1rem;
  font-weight: 700;
}

.topbar__hello {
  margin: 0;
  color: var(--navy);
  font-weight: 600;
}

.nav {
  background: #efe6f8;
  border-top: 1px solid #e0d2f0;
}

.nav__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.35rem 1.25rem;
}

.nav__link,
.nav__hint {
  display: inline-block;
  border: 0;
  background: none;
  font: inherit;
  color: var(--navy);
  font-weight: 600;
  padding: 0.4rem 0;
}

.nav__link {
  cursor: pointer;
  text-decoration: underline;
}

.disclaimer {
  margin: 0;
  padding: 0.45rem 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  background: #fff6cc;
  color: var(--navy-dark);
  border-bottom: 1px solid #f0d66a;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem 1.75rem;
  margin-bottom: 1.25rem;
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  line-height: 1.3;
  text-align: center;
  color: var(--navy-dark);
}

.section-title {
  margin: 1.5rem 0 0.85rem;
  font-size: 1.05rem;
  color: var(--ink);
}

.prose p {
  margin: 0 0 0.85rem;
  text-align: justify;
}

.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.cat {
  appearance: none;
  border: 0;
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0.7rem 1rem;
  min-width: 9.5rem;
  cursor: pointer;
}

.cat:hover,
.cat:focus-visible {
  background: var(--blue-hover);
}

.cat:disabled {
  background: #aab7c4;
  cursor: not-allowed;
}

.alert {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  font-size: 0.95rem;
}

.alert--error {
  background: var(--error-bg);
  color: var(--error-ink);
}

.alert--warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 4px;
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1.15rem;
  cursor: pointer;
}

.btn--primary {
  background: var(--navy);
  color: #fff;
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background: var(--navy-dark);
}

.btn--secondary {
  background: var(--gold);
  color: var(--gold-ink);
  text-decoration: none;
  display: inline-block;
}

.btn--secondary:hover,
.btn--secondary:focus-visible {
  background: #e5ae00;
}

.btn--ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  background: var(--wash);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 40, 0.55);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  background: var(--paper);
  border-radius: 6px;
  padding: 1.35rem 1.5rem 1.25rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.modal__x {
  position: absolute;
  top: 0.4rem;
  right: 0.55rem;
  border: 0;
  background: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.modal__aviso {
  margin: 0 0 0.35rem;
  color: #c0392b;
  font-size: 1.1rem;
}

.modal__dialog h3 {
  margin: 0.75rem 0 0.5rem;
  font-size: 1.05rem;
}

.modal__list {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
}

.modal__note {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.modal__confirm {
  text-align: center;
  color: var(--navy-dark);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.exam-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.exam-toolbar__cat {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.exam-toolbar__title {
  margin: 0;
  text-align: left;
  font-size: 1.2rem;
}

.timer {
  min-width: 7.5rem;
  text-align: right;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
}

.timer__label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.timer__value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.timer--low .timer__value {
  color: #c0392b;
}

.exam-q {
  margin: 0 0 1rem;
  font-size: 1.08rem;
  font-weight: 600;
}

.exam-fig {
  margin: 0 0 1rem;
}

.exam-fig img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.options {
  display: grid;
  gap: 0.55rem;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0.7rem 0.85rem;
  font: inherit;
  cursor: pointer;
}

.option:hover,
.option:focus-visible {
  border-color: var(--blue);
}

.option.is-selected {
  border-color: var(--navy);
  background: #f3eafc;
}

.option__letter {
  flex: 0 0 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.exam-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.palette button {
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 4px;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.palette button.is-current {
  border-color: var(--navy);
  font-weight: 700;
}

.palette button.is-answered {
  background: #fff1b0;
}

.result-hero {
  text-align: center;
}

.result-hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 0.25rem;
}

.result-hero__cat,
.result-hero__meta {
  color: var(--muted);
}

.result-hero__score {
  margin: 0.25rem 0;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--navy);
}

.result-hero__badge {
  display: inline-block;
  margin: 0.4rem 0 1rem;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.result-hero--ok .result-hero__badge {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.result-hero--fail .result-hero__badge {
  background: var(--fail-bg);
  color: var(--fail-ink);
}

.section-title--serif {
  font-family: Georgia, "Times New Roman", serif;
}

.wrap-title {
  margin: 0 0 0.85rem;
}

.donut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.25rem 0.75rem;
  justify-items: center;
  padding: 0.5rem 0 0.25rem;
}

.donut {
  --p: 0;
  --c: #27ae60;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #ececec 0);
  display: grid;
  place-items: center;
}

.donut__hole {
  width: 94px;
  height: 94px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.2rem;
}

.donut__pct {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.1;
}

.donut__code {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.donut--detail {
  --c: #c0392b;
  flex: 0 0 auto;
}

.donut--detail .donut__pct {
  color: #c0392b;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.tema-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.15rem;
}

.tema-card h3 {
  margin: 0 0 0.15rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
}

.tema-card__name {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.tema-card__body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tema-card__stats {
  font-size: 0.92rem;
}

.tema-card__stats p {
  margin: 0.2rem 0;
}

.potenciar-card {
  text-align: center;
}

.potenciar {
  display: grid;
  place-items: center;
  min-height: 160px;
}

.potenciar__empty {
  color: var(--ok-ink);
  font-weight: 600;
}

.potenciar__hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.leyenda {
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.leyenda div {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.6rem;
  align-items: start;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}

.leyenda dt {
  margin: 0;
  font-weight: 700;
  color: var(--navy);
}

.leyenda dd {
  margin: 0;
}

.focus-warn {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 30, 40, 0.6);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.focus-warn__box {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 1.4rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.focus-warn__box h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

@media (max-width: 640px) {
  h1 {
    font-size: 1.15rem;
  }

  .card {
    padding: 1.15rem;
  }

  .cat {
    min-width: calc(50% - 0.35rem);
  }

  .exam-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .timer {
    text-align: left;
  }

  .modal__actions,
  .exam-nav {
    flex-direction: column-reverse;
  }

  .btn {
    width: 100%;
  }

  .leyenda div {
    grid-template-columns: 1fr;
  }
}
