/* Tokens -------------------------------------------------------------------- */

:root {
  --paper: #f7f2e8;
  --surface: #fffdf8;
  --sunken: #efe8da;
  --ink: #1b2330;
  --muted: #5d6573;
  --line: #d9cfbd;
  --line-strong: #1b2330;
  --accent: #0a4fa3;
  --accent-ink: #ffffff;
  --accent-soft: #dfe8f6;
  --gold: #f2b705;
  --gold-soft: #fff1c2;
  --right: #1b7a4b;
  --right-soft: #dcf1e5;
  --wrong: #b3261e;
  --wrong-soft: #fbe2df;
  --shadow: 0 2px 0 var(--line-strong);
  --yellow: #8a6500;
  --blue: #0a4fa3;
  --red: #b3261e;
  --orange: #b04f00;
  --green: #1b7a4b;
  --purple: #6b3fb0;
  --gray: #5d6573;
  --brown: #7a4a22;
  --pink: #b0185b;
  --font-scale: 1.0625;
  --leading: 1.55;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14181f;
    --surface: #1d232d;
    --sunken: #262d39;
    --ink: #f1ece2;
    --muted: #a9b0bc;
    --line: #353e4c;
    --line-strong: #8b94a5;
    --accent: #7fb0ff;
    --accent-ink: #0d1320;
    --accent-soft: #23324d;
    --gold: #f2c53d;
    --gold-soft: #3b3215;
    --right: #63d297;
    --right-soft: #183528;
    --wrong: #ff8a80;
    --wrong-soft: #3d1d1b;
    --yellow: #f2c53d;
    --blue: #7fb0ff;
    --red: #ff8a80;
    --orange: #ffab5c;
    --green: #63d297;
    --purple: #c4a2ff;
    --gray: #a9b0bc;
    --brown: #d9a679;
    --pink: #ff8ab8;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #14181f;
  --surface: #1d232d;
  --sunken: #262d39;
  --ink: #f1ece2;
  --muted: #a9b0bc;
  --line: #353e4c;
  --line-strong: #8b94a5;
  --accent: #7fb0ff;
  --accent-ink: #0d1320;
  --accent-soft: #23324d;
  --gold: #f2c53d;
  --gold-soft: #3b3215;
  --right: #63d297;
  --right-soft: #183528;
  --wrong: #ff8a80;
  --wrong-soft: #3d1d1b;
  --yellow: #f2c53d;
  --blue: #7fb0ff;
  --red: #ff8a80;
  --orange: #ffab5c;
  --green: #63d297;
  --purple: #c4a2ff;
  --gray: #a9b0bc;
  --brown: #d9a679;
  --pink: #ff8ab8;
  color-scheme: dark;
}

/* Accessibility settings, set as data attributes on <html> by app.js. */

:root[data-font-size="s"] { --font-scale: .9375; }
:root[data-font-size="l"] { --font-scale: 1.25; }
:root[data-font-size="xl"] { --font-scale: 1.4375; }
:root[data-font-size="xxl"] { --font-scale: 1.6875; }
:root[data-spacing="wide"] { --leading: 1.9; letter-spacing: .02em; word-spacing: .08em; }

:root[data-contrast="high"] {
  --paper: #ffffff;
  --surface: #ffffff;
  --sunken: #ffffff;
  --ink: #000000;
  --muted: #000000;
  --line: #000000;
  --accent: #002f87;
  --accent-soft: #ffffff;
  --gold-soft: #ffe36b;
  --right: #00552b;
  --wrong: #8f0000;
}
:root[data-contrast="high"][data-theme="dark"] {
  --paper: #000000;
  --surface: #000000;
  --sunken: #000000;
  --ink: #ffffff;
  --muted: #ffffff;
  --line: #ffffff;
  --line-strong: #ffffff;
  --accent: #ffe600;
  --accent-ink: #000000;
  --accent-soft: #000000;
  --gold-soft: #4a3f00;
  --right: #7dff9b;
  --wrong: #ff9e9e;
}

:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before {
  transition: none !important;
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Base ---------------------------------------------------------------------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: calc(100% * var(--font-scale)); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", system-ui, sans-serif;
  line-height: var(--leading);
  overflow-wrap: break-word;
}

h1, h2, .score, .brand strong {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 800;
  line-height: 1.15;
}

a { color: var(--accent); text-underline-offset: .2em; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: .5rem 1rem;
  background: var(--ink);
  color: var(--paper);
  z-index: 10;
}
.skip-link:focus { top: 1rem; }

main {
  flex: 1;
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}
main:focus { outline: none; }

.loading { color: var(--muted); text-align: center; }

/* Buttons ------------------------------------------------------------------- */

button, select {
  font: inherit;
  color: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.1rem;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 3px 0 var(--line-strong); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
button:disabled { opacity: .55; cursor: not-allowed; }

button.primary { background: var(--accent); color: var(--accent-ink); }
button.danger { background: var(--wrong); color: #fff; }
button.ghost { background: transparent; box-shadow: none; border-color: var(--line); }
button.ghost:hover { border-color: var(--ink); box-shadow: none; }
button.big { width: 100%; padding: .9rem 1.4rem; font-size: 1.1rem; }

button.link {
  padding: .2rem .4rem;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: .2em;
  font-weight: 400;
}

kbd {
  padding: 0 .4rem;
  border: 1px solid currentColor;
  border-radius: 6px;
  font: .75rem/1.5 ui-monospace, monospace;
  opacity: .75;
}

/* Header & footer ----------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  padding: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.05rem;
}
.brand strong { font-size: 1.15rem; }

/* The real flag with the coat of arms: plain stripes would read as Colombia's. */
.flag {
  flex: none;
  width: 2.4rem;
  height: 1.6rem;
  border: 2px solid var(--line-strong);
  border-radius: 4px;
  object-fit: cover;
}

.footer {
  border-top: 2px dashed var(--line);
  padding: 1.25rem 1rem 2rem;
  text-align: center;
  font-size: .875rem;
  color: var(--muted);
}
.footer p { max-width: 46rem; margin: 0 auto .5rem; }
.footer-links { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: .5rem 1.25rem; }
/* The share button looks like the links beside it. */
.footer-links button.link { padding: 0; font-size: inherit; line-height: inherit; }

/* Home ---------------------------------------------------------------------- */

.hero { padding: 1.5rem 0 1rem; }
.eyebrow {
  margin: 0 0 .5rem;
  color: var(--accent);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.9rem); margin: 0 0 1rem; max-width: 22ch; }
.lead { margin: 0; color: var(--muted); font-size: 1.1rem; max-width: 44rem; }
.features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  max-width: 46rem;
  margin: 0 auto 1.25rem;
  padding: 0;
  list-style: none;
}
.features li {
  padding: .25rem .8rem;
  border: 2px solid var(--line-strong);
  /* Not a full pill: with very large text a label may wrap to two lines. */
  border-radius: 1rem;
  background: var(--gold-soft);
  color: var(--ink);
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.search { margin-top: 2rem; }
.search-box {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .2rem 1rem;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}
.search-box:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.search-box input {
  flex: 1;
  min-width: 0;
  padding: .6rem 0;
  border: none;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  text-overflow: ellipsis;
  outline: none;
}
.search-status { margin: .75rem 0 0; color: var(--muted); }
.search-status:empty { display: none; }
/* The example lives under the box, not in the placeholder, which phones cut short. */
.search-hint { margin: .5rem 0 0; color: var(--muted); font-size: .9rem; }
.search:has(.search-status:not(:empty)) .search-hint { display: none; }
.search-results {
  display: grid;
  gap: .75rem;
  margin: .75rem 0 0;
  padding: 0;
  list-style: none;
}
.search-results:empty { display: none; }
.search-results li {
  padding: .9rem 1.1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  white-space: pre-wrap;
}
.search-results p { margin: 0; }
.result-crumbs { color: var(--muted); font-size: .8rem; font-weight: 700; white-space: normal; }
.result-question { margin-top: .3rem !important; }
.result-answer { margin-top: .4rem !important; color: var(--accent); font-weight: 700; }
.search-results .occlusion { margin-top: .5rem; max-width: 28rem; }
.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  white-space: normal;
}
.result-head .result-crumbs { flex: 1; min-width: 0; margin-top: .4rem; }
.result-head button { flex: none; padding: .3rem .8rem; font-size: .9rem; }

/* Toggle buttons: mark a question, add it to an exam. */
.mark[aria-pressed="true"] { border-color: var(--line-strong); background: var(--gold-soft); }
.mark[aria-pressed="true"] svg { fill: var(--gold); }
.add[aria-pressed="true"] { border-color: var(--right); background: var(--right-soft); color: var(--right); }

.practice h2 { margin: 2rem 0 .75rem; font-size: 1.5rem; }
.practice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
}
.practice-card {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 1rem 1.1rem 1.1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.practice-card h3 { margin: 0; font-family: "Fraunces", Georgia, serif; font-size: 1.25rem; }
.practice-card p { flex: 1; margin: 0; color: var(--muted); }.practice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }

.my-exams .toolbar { align-items: center; margin: 2rem 0 .75rem; }
.my-exams .toolbar h2 { margin: 0; }
.exams-empty { margin: 0; color: var(--muted); }
.exam-list { display: grid; gap: .75rem; margin: 0; padding: 0; list-style: none; }
.exam-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem .75rem;
  padding: .9rem 1.1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.exam-info { display: grid; flex: 1 1 14rem; min-width: 0; }
.exam-info strong { font-size: 1.1rem; }
.exam-info small { color: var(--muted); font-size: .9rem; }
.exam-tag {
  justify-self: start;
  margin-bottom: .2rem;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.shared-about { margin: -.5rem 0 1rem; color: var(--muted); }

.topics-intro { padding-top: .5rem; }
.topics-intro h1 { margin: 0 0 .75rem; font-size: clamp(1.8rem, 5vw, 2.5rem); }
.topics-intro + .toolbar { margin-top: 1.25rem; }
.topics-status { margin: -.25rem 0 .75rem; color: var(--right); font-weight: 700; }
.topics-status:empty { display: none; }

.save-exam { max-width: 32rem; margin: 0 auto 2.5rem; text-align: left; }
.save-done { margin: 0 auto 2.5rem; color: var(--right); font-weight: 700; }

.install {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.25rem;
  margin-top: 1.5rem;
  padding: 1rem 1.2rem;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.install-text { flex: 1 1 18rem; }
.install-text p { margin: .2rem 0 0; color: var(--muted); }
.install-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }

.toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 2rem 0 .75rem;
}
.toolbar h2 { margin: 0; font-size: 1.5rem; }

.categories { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }

.category {
  padding: 1rem 1.1rem 1.1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .15s ease;
}
.category.is-selected { border-color: var(--line-strong); box-shadow: 4px 4px 0 var(--gold); }

.category header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
}
.category-title {
  display: flex;
  align-items: center;
  gap: .7rem;
  cursor: pointer;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 800;
}
.category .index { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.category .count { color: var(--muted); font-size: .9rem; white-space: nowrap; }

input[type="checkbox"], input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}

/* Our own checkbox, so it matches the dark borders of buttons and fields in
   every theme instead of the browser's light gray box. */
input[type="checkbox"] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  border: 2px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
}
input[type="checkbox"]::before {
  content: "";
  width: .65rem;
  height: .65rem;
  background: var(--accent-ink);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  transform: scale(0);
}
input[type="checkbox"]:checked,
input[type="checkbox"]:indeterminate { border-color: var(--accent); background: var(--accent); }
input[type="checkbox"]:checked::before { transform: scale(1); }
input[type="checkbox"]:indeterminate::before { height: .18rem; clip-path: none; transform: scale(1); }
@media (forced-colors: active) {
  input[type="checkbox"] { appearance: auto; }
}

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: .45rem;
  padding: .35rem .75rem .35rem .55rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: .95rem;
  cursor: pointer;
}
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chip:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 2px; }
.chip span { min-width: 0; overflow-wrap: break-word; }
.chip small { color: var(--muted); font-variant-numeric: tabular-nums; }

.start-panel, .builder-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.25rem;
  margin: 1.5rem -1rem 0;
  padding: 1rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-top: 2px solid var(--line);
}
.field, .check { display: flex; align-items: center; gap: .5rem; }
.start-panel #start { flex: 1 1 16rem; }
select {
  padding: .45rem .6rem;
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
}

/* Exam ---------------------------------------------------------------------- */

.exam-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}
.counter { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
#open-settings, .exit { flex: none; }

.meter {
  height: .5rem;
  margin-bottom: 1.25rem;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}
.meter > div { height: 100%; background: var(--gold); transition: width .3s ease; }

.question {
  position: relative;
  padding: 1.4rem 1.5rem 1.6rem;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 6px 6px 0 var(--accent);
  min-height: 14rem;
}
.question:not(.is-revealed) { cursor: pointer; }

.question-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}
.listen { flex: none; padding: .3rem .8rem; font-size: .9rem; }
.listen[aria-pressed="true"] { border-color: var(--line-strong); background: var(--accent-soft); color: var(--accent); }

.crumbs {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.front { font-size: clamp(1.2rem, 3vw, 1.45rem); white-space: pre-wrap; }
.front p { margin: 0 0 1rem; }
.front p:last-child { margin-bottom: 0; }

.answer {
  margin-top: 1.25rem;
  padding: .9rem 1.1rem;
  border-left: 5px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: var(--gold-soft);
}
.answer-label {
  margin: 0 0 .2rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.back { font-size: clamp(1.1rem, 2.6vw, 1.3rem); font-weight: 700; white-space: pre-wrap; }

.photo { margin: 1rem 0 0; }
.photo img {
  display: block;
  /* Keep the whole photo visible: tall photos get narrower, never cropped. */
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 24rem;
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  background: var(--sunken);
}
.photo figcaption {
  margin-top: .4rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 400;
  white-space: normal;
}
.missed .photo img { max-height: 14rem; }

.cloze {
  display: inline-block;
  min-width: 3.5em;
  padding: 0 .5rem;
  border-bottom: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  text-align: center;
  font-weight: 700;
}
.cloze.revealed {
  min-width: 0;
  border-bottom-color: var(--gold);
  background: var(--gold-soft);
  color: var(--ink);
}

.color-yellow { color: var(--yellow); }
.color-blue { color: var(--blue); }
.color-red { color: var(--red); }
.color-orange { color: var(--orange); }
.color-green { color: var(--green); }
.color-purple { color: var(--purple); }
.color-gray { color: var(--gray); }
.color-brown { color: var(--brown); }
.color-pink { color: var(--pink); }

.occlusion {
  position: relative;
  container-type: inline-size;
  margin: 0;
  max-width: 40rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.occlusion img { display: block; width: 100%; height: 100%; }

.mask {
  position: absolute;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: repeating-linear-gradient(-45deg, #d8d2c4 0 8px, #cbc4b4 8px 16px);
}
.mask.active {
  border: 2px solid #1b2330;
  background: repeating-linear-gradient(-45deg, #f2b705 0 10px, #e6a800 10px 20px);
  color: #1b2330;
  /* Size the "?" from the mask itself so it fits thin labels too. */
  container-type: size;
}
.mask.active span {
  font: 800 min(70cqh, 40cqw, 2rem)/1 "Fraunces", Georgia, serif;
}

.options {
  display: grid;
  gap: .6rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  white-space: normal;
}
.options button {
  justify-content: flex-start;
  width: 100%;
  padding: .75rem 1rem;
  border-radius: 12px;
  box-shadow: none;
  text-align: left;
  font-size: 1.05rem;
  font-weight: 400;
}
.options button:hover:not(:disabled) { border-color: var(--accent); box-shadow: none; transform: none; }
.options button:disabled { opacity: 1; cursor: default; }
.options button.is-correct { border-color: var(--right); background: var(--right-soft); color: var(--right); font-weight: 700; }
.options button.is-wrong { border-color: var(--wrong); background: var(--wrong-soft); color: var(--wrong); font-weight: 700; }
.options kbd { flex: none; }
.options button.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.options button.is-missed { border-style: dashed; }

/* One answer: round marks, like radio buttons. Several: square marks, like
   checkboxes, and a highlighted hint above the options. */
.option-mark {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.15em;
  height: 1.15em;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.is-multi .option-mark { border-radius: 4px; }
.options button:is(.is-selected, .was-picked) .option-mark::after {
  content: "";
  width: .5em;
  height: .5em;
  border-radius: 50%;
  background: currentColor;
}
.options.is-multi button:is(.is-selected, .was-picked) .option-mark { background: currentColor; }
.options.is-multi button:is(.is-selected, .was-picked) .option-mark::after {
  width: .28em;
  height: .55em;
  margin-top: -.12em;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  border-radius: 0;
  background: none;
  transform: rotate(45deg);
}
.choice-hint {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: .5rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 700;
  white-space: normal;
}
.choice-hint .option-mark { width: 1em; height: 1em; }
.choice-hint.is-multi {
  padding: .3rem .75rem;
  border: 2px solid var(--gold);
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--ink);
}

.explanation {
  margin: .5rem 0 0;
  padding: .7rem .9rem;
  border-left: 4px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: var(--gold-soft);
  white-space: normal;
}
.missed .explanation { font-size: .95rem; }

.feedback { margin: 1rem 0 0; font-weight: 700; white-space: normal; }
/* Leaves room below the result so the start of the explanation shows too. */
.feedback, .grade { scroll-margin: 1rem 0 20vh; }
.feedback.is-right { color: var(--right); }
.feedback.is-wrong { color: var(--wrong); }

.actions { display: grid; gap: .75rem; margin-top: 1.5rem; }

.grade {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.grade-label { grid-column: 1 / -1; margin: 0; font-weight: 700; text-align: center; }
.grade button { padding: .85rem; font-size: 1.1rem; }
.grade .wrong { background: var(--wrong-soft); color: var(--wrong); }
.grade .right { background: var(--right-soft); color: var(--right); }

.report { justify-self: center; font-size: .85rem; color: var(--muted); }

/* Result -------------------------------------------------------------------- */

.result { text-align: center; padding-top: 1.5rem; }
.score { margin: 0; font-size: clamp(4rem, 14vw, 6rem); }
.summary { margin: .25rem 0 1.5rem; color: var(--muted); font-size: 1.1rem; }

.breakdown {
  display: grid;
  gap: .5rem;
  max-width: 30rem;
  margin: 0 auto 2rem;
  padding: 0;
  list-style: none;
  text-align: left;
}
.breakdown li {
  display: grid;
  grid-template-columns: 9rem 1fr auto;
  align-items: center;
  gap: .75rem;
}
.breakdown i {
  height: .6rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--right) calc(var(--ratio) * 100%), var(--sunken) 0);
}

.verdict { margin: -.75rem auto 1.5rem; font-size: 1.2rem; font-weight: 700; }
.verdict.is-right { color: var(--right); }
.verdict.is-wrong { color: var(--wrong); }

.result-actions { display: grid; gap: .75rem; max-width: 26rem; margin: 0 auto 2.5rem; }
.missed-title { text-align: left; font-size: 1.5rem; }

.missed {
  display: grid;
  gap: 1rem;
  padding-left: 1.5rem;
  text-align: left;
}
.missed li {
  padding: .75rem 1rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  white-space: pre-wrap;
}
.missed p { margin: 0; }
.missed-answer { margin-top: .4rem !important; font-weight: 700; color: var(--accent); }
.missed-answer.is-right { color: var(--right); }
.picked-answer { margin-top: .4rem !important; font-weight: 700; color: var(--wrong); }
.right-title { margin-top: 2rem; }
.missed .occlusion { margin-top: .5rem; }

/* Exam builder and shared exams --------------------------------------------- */

.builder h1, .shared h1 { margin: 0 0 .75rem; font-size: clamp(1.8rem, 5vw, 2.5rem); }
.builder h2 { margin: 2rem 0 .75rem; font-size: 1.4rem; }
.text-field { display: grid; gap: .35rem; margin-top: 1.5rem; font-weight: 700; }
.text-field input, .share-link {
  min-width: 0;
  padding: .6rem .9rem;
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}
.builder-source { margin-top: .75rem; }
.source-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 .75rem; }
.draft-empty { color: var(--muted); }
.clear-draft { margin-top: .75rem; }
.builder-count { flex: 1 1 9rem; font-weight: 700; }
.builder-bar #builder-done { flex: 1 0 auto; max-width: 16rem; padding: .8rem 1.4rem; }

.shared { padding-top: .5rem; }
.shared-warning {
  margin: 1rem 0 0;
  padding: .6rem .9rem;
  border-left: 4px solid var(--wrong);
  border-radius: 0 8px 8px 0;
  background: var(--wrong-soft);
}
.shared-start { display: grid; gap: .75rem; max-width: 26rem; margin: 1.5rem 0 2rem; }
.share-box {
  padding: 1rem 1.2rem 1.2rem;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.share-box h2 { margin: 0 0 .3rem; font-size: 1.3rem; }
.share-box p { margin: 0 0 .75rem; }
.share-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.share-link { flex: 1 1 14rem; }
.share-status { margin: .5rem 0 0 !important; color: var(--right); font-weight: 700; }
.share-status:empty { display: none; }
.shared-more { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-top: 1.5rem; }

/* Progress ------------------------------------------------------------------ */

.progress-summary .toolbar { align-items: center; }
.progress-summary .stat-tiles { grid-template-columns: repeat(auto-fit, minmax(min(100%, 5.5rem), 1fr)); }
.progress-summary .stat-tiles > div { padding: .6rem .7rem; }
.progress-summary .stat-tiles dt { font-size: .8rem; }
.progress-summary .stat-tiles dd strong { display: block; font-size: 1.6rem; }
.stat-tiles dt { overflow-wrap: normal; hyphens: none; }
.stat-tiles dd { overflow-wrap: normal; hyphens: none; }
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr));
  gap: .75rem;
  margin: 0;
}
.stat-tiles > div {
  padding: .8rem 1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat-tiles dt { color: var(--muted); font-size: .85rem; font-weight: 700; }
.stat-tiles dd { margin: 0; color: var(--muted); }
.stat-tiles dd strong { color: var(--ink); font-family: "Fraunces", Georgia, serif; font-size: 2rem; line-height: 1.2; }
.stat-tiles .stat-note { font-size: .85rem; }

.progress-page { padding-top: .5rem; }
.progress-page h1 { margin: 0 0 1rem; font-size: clamp(1.8rem, 5vw, 2.5rem); }
.progress-page h2 { margin: 2rem 0 .75rem; font-size: 1.4rem; }
.achievements-count { color: var(--muted); font-family: "Atkinson Hyperlegible", system-ui, sans-serif; font-size: 1rem; font-weight: 400; }
.progress-hint { margin: .75rem 0 0; color: var(--muted); font-size: .9rem; }

.activity-summary { margin: 0 0 .75rem; }
.activity-scroll {
  overflow-x: auto;
  padding: .75rem 0;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.activity-scroll:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.activity-calendar {
  /* Capped so the largest text sizes still show several months at once. */
  --cell: min(.75rem, 15px);
  display: grid;
  grid-template-columns: auto;
  grid-auto-columns: var(--cell);
  grid-template-rows: auto;
  grid-auto-rows: var(--cell);
  gap: 3px;
  width: max-content;
  margin-inline: auto;
  padding-right: .75rem;
}
.activity-month, .activity-days { color: var(--muted); font-size: .75rem; line-height: 1; white-space: nowrap; }
.activity-month { padding-bottom: .3rem; }
.activity-days {
  position: sticky;
  left: 0;
  z-index: 1;
  display: grid;
  grid-template-rows: repeat(7, var(--cell));
  gap: 3px;
  padding: 0 .4rem 0 .75rem;
  background: var(--surface);
}
.activity-days span { display: flex; align-items: center; }
.activity-corner { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.activity-cell {
  display: block;
  width: var(--cell, min(.75rem, 15px));
  height: var(--cell, min(.75rem, 15px));
  border-radius: 3px;
  background: var(--sunken);
  box-shadow: inset 0 0 0 1px var(--line);
}
.activity-cell[data-level="1"] { background: color-mix(in srgb, var(--right) 30%, var(--surface)); box-shadow: none; }
.activity-cell[data-level="2"] { background: color-mix(in srgb, var(--right) 55%, var(--surface)); box-shadow: none; }
.activity-cell[data-level="3"] { background: color-mix(in srgb, var(--right) 80%, var(--surface)); box-shadow: none; }
.activity-cell[data-level="4"] { background: var(--right); box-shadow: none; }
/* Games --------------------------------------------------------------------- */

.game-board { margin-top: 1rem; }
.game-board .practice-actions { margin-top: 1.25rem; }
.order-result { margin-top: 1.5rem; }
.order-result h2 { margin: 0 0 .5rem; font-size: 1.5rem; }
.order-result p { margin: 0 0 .5rem; }

/* Ordena la historia: numbered slots on top, the events to place below. */
.order-slots, .order-answer { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.order-slot {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 3.25rem;
  padding-left: .75rem;
  border: 2px dashed var(--line);
  border-radius: 12px;
}
.order-slot:has(button), .order-slot.is-checked { border-style: solid; border-color: var(--line-strong); }
.order-slot.is-checked { padding: .6rem .75rem; }
.order-position {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--sunken);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.order-slot .order-item { flex: 1; min-height: 3rem; border: 0; border-radius: 10px; box-shadow: none; justify-content: flex-start; text-align: left; }
.order-empty { color: var(--muted); font-size: .9rem; }
.order-slot.is-right { border-color: var(--right); background: var(--right-soft); }
.order-slot.is-wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.order-year { min-width: 3.5rem; font-variant-numeric: tabular-nums; }
.order-pool { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.order-pool .order-item { border-radius: 12px; text-align: left; font-weight: 700; }

/* Parejas: two columns of buttons; a matched pair shares a number. */
.pairs-topic { max-width: 22rem; margin-top: 0; }
.pairs-topic select {
  padding: .55rem .8rem;
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.pairs-title { margin: 1.5rem 0 .25rem; font-size: 1.4rem; }
.pairs-counter { margin: 0 0 1rem; color: var(--muted); font-weight: 700; }
/* The pieces: the body holds the shape (a tab on the left pieces, a notch
   on the right ones) and the outline is a drop shadow around it, so it
   follows the shape. Every row has the height of the tallest piece. */
.puzzle {
  --gap: 1.4rem;
  --tab: .7rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: .7rem var(--gap);
}
.piece {
  --piece-line: var(--line-strong);
  --piece-fill: var(--surface);
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 3.5rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  filter: drop-shadow(2px 0 0 var(--piece-line)) drop-shadow(-2px 0 0 var(--piece-line)) drop-shadow(0 2px 0 var(--piece-line)) drop-shadow(0 -2px 0 var(--piece-line));
  transition: translate .3s ease;
}
.piece:hover:not(:disabled) { box-shadow: none; transform: none; --piece-line: var(--accent); }
.piece:active:not(:disabled) { box-shadow: none; }
.piece:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
.piece-body {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  padding: .6rem 1rem;
  border-radius: 12px;
  background: var(--piece-fill);
}
.piece-left .piece-body { padding-right: calc(1rem + var(--tab) / 2); }
.piece-left .piece-body::after {
  content: "";
  position: absolute;
  top: 50%;
  right: calc(var(--tab) * -1);
  width: calc(var(--tab) * 2);
  height: calc(var(--tab) * 2);
  margin-top: calc(var(--tab) * -1);
  border-radius: 50%;
  background: var(--piece-fill);
}
.piece-right .piece-body {
  padding-left: calc(1rem + var(--tab));
  -webkit-mask: radial-gradient(circle at 0 50%, transparent calc(var(--tab) + 2px), #000 calc(var(--tab) + 3px));
  mask: radial-gradient(circle at 0 50%, transparent calc(var(--tab) + 2px), #000 calc(var(--tab) + 3px));
}
.piece.is-selected, .piece.is-target { --piece-line: var(--accent); --piece-fill: var(--accent-soft); color: var(--accent); font-weight: 700; }
.piece.is-selected { translate: 0 -3px; }
.piece.is-wrong { --piece-line: var(--wrong); --piece-fill: var(--wrong-soft); color: var(--wrong); animation: piece-shake .4s; }
.piece.is-matched { --piece-line: var(--right); --piece-fill: var(--right-soft); opacity: 1; color: var(--right); font-weight: 700; cursor: default; }
/* A matched pair closes the gap between the columns, so the tab fits the notch. */
.piece-left.is-matched { translate: calc(var(--gap) / 2) 0; }
.piece-right.is-matched { translate: calc(var(--gap) / -2) 0; }
.piece.is-dragging { z-index: 2; cursor: grabbing; transition: none; }
@keyframes piece-shake {
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
@media (prefers-reduced-motion: reduce) {
  .piece { transition: none; }
  .piece.is-wrong { animation: none; }
}
:root[data-motion="reduce"] .piece { transition: none; }
:root[data-motion="reduce"] .piece.is-wrong { animation: none; }
@media (forced-colors: active) {
  .piece { filter: none; }
  .piece-body { border: 2px solid CanvasText; -webkit-mask: none; mask: none; }
  .piece-left .piece-body::after { display: none; }
  .piece.is-selected .piece-body, .piece.is-matched .piece-body { border-color: Highlight; }
}

/* Verdadero o falso. */
.tf-modes { max-width: 34rem; }
.tf-keys { margin-bottom: 0; }
.tf-counter { margin: 0 0 .4rem; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.tf-card {
  padding: 1.25rem;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 6px 6px 0 var(--accent);
  transition: border-color .15s ease, background .15s ease;
}
.tf-card.is-right { border-color: var(--right); background: var(--right-soft); }
.tf-card.is-wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.tf-question { margin: 0; font-size: 1.15rem; }
.tf-label { margin: 1rem 0 .25rem; color: var(--muted); font-size: .9rem; font-weight: 700; }
.tf-proposal { margin: 0; font-family: "Fraunces", Georgia, serif; font-size: 1.5rem; font-weight: 800; }
.tf-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1.25rem; }
.tf-buttons button { padding: 1rem; font-size: 1.15rem; }
.tf-false { background: var(--wrong-soft); color: var(--wrong); }
.tf-true { background: var(--right-soft); color: var(--right); }
.tf-quit { display: block; margin: 1rem auto 0; }
@media (prefers-reduced-motion: reduce) { .tf-card { transition: none; } }
@media (max-width: 30rem) {
  .puzzle { --gap: 1.1rem; }
  .piece-body { padding: .5rem .6rem; font-size: .95rem; }
  .piece-left .piece-body { padding-right: calc(.6rem + var(--tab) / 2); }
  .piece-right .piece-body { padding-left: calc(.6rem + var(--tab)); }
}

/* Mis simulacros: one line, round marks; a filled mark is a passed exam and
   a hollow one a failed exam, so the state does not rely on color alone. */
.mocks-section { margin-top: 2rem; }
.mocks-summary { margin: 0 0 .75rem; }
.mock-chart { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); margin: .5rem 0; }
.mock-chart svg { display: block; }
.mock-scroll { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.mock-grid { stroke: var(--line); stroke-width: 1; }
.mock-axis { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.mock-pass { stroke: var(--right); stroke-width: 1.5; stroke-dasharray: 5 4; }
.mock-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mock-point { cursor: pointer; }
.mock-hit { fill: transparent; }
.mock-mark {
  fill: var(--surface);
  stroke: var(--wrong);
  stroke-width: 2.5;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .12s ease;
}
.mock-point.is-passed .mock-mark { fill: var(--right); stroke: var(--surface); stroke-width: 2; }
.mock-point:hover .mock-mark { transform: scale(1.35); }
.mock-tip {
  position: absolute;
  z-index: 1;
  margin: 0;
  padding: .35rem .6rem;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: .85rem;
  white-space: pre;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
}
.mock-tip[data-side="left"] { transform: translate(-1rem, calc(-100% - 12px)); }
.mock-tip[data-side="right"] { transform: translate(calc(-100% + 1rem), calc(-100% - 12px)); }
.mock-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; color: var(--muted); font-size: .85rem; }
.mock-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.mock-dot { width: .7rem; height: .7rem; border: 2.5px solid var(--wrong); border-radius: 50%; background: var(--surface); }
.mock-dot.is-passed { border-color: var(--right); background: var(--right); }
.mock-pass-line { width: 1.2rem; border-top: 2px dashed var(--right); }
.mock-history-toggle { margin-top: 1rem; }
.mock-list { display: grid; gap: .5rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.mock-list[hidden] { display: none; }
.mock-list button {
  display: grid;
  grid-template-columns: 1fr auto auto;
  width: 100%;
  gap: .25rem 1rem;
  padding: .6rem 1rem;
  border-radius: 12px;
  text-align: left;
  font-weight: 400;
}
.mock-list strong { font-variant-numeric: tabular-nums; }
.mock-status { min-width: 8.5rem; color: var(--wrong); font-weight: 700; }
.mock-status.is-passed { color: var(--right); }
.mock-date { margin: 0 0 .5rem; color: var(--muted); }
@media (max-width: 30rem) {
  .mock-list button { grid-template-columns: 1fr auto; }
  .mock-list button > span:first-child { grid-column: 1 / -1; }
  .mock-status { min-width: 0; text-align: right; }
}
@media (forced-colors: active) {
  .mock-line { stroke: CanvasText; }
  .mock-mark { stroke: CanvasText; }
  .mock-point.is-passed .mock-mark, .mock-dot.is-passed { fill: Highlight; background: Highlight; }
}

.activity-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: .5rem;
  color: var(--muted);
  font-size: .8rem;
}
.activity-legend span { margin: 0 .3rem; }
@media (forced-colors: active) {
  .activity-cell { forced-color-adjust: none; background: Canvas; box-shadow: inset 0 0 0 1px CanvasText; }
  .activity-cell:not([data-level="0"]) { background: Highlight; }
  .activity-cell[data-level="4"] { background: CanvasText; }
}

.mastery-list { display: grid; gap: .6rem; margin: 0; padding: 0; list-style: none; }
.mastery-list li {
  display: grid;
  grid-template-columns: 10rem 1fr auto;
  align-items: center;
  gap: .25rem .75rem;
}
.mastery-list i {
  height: .7rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--right) calc(var(--ratio) * 100%), var(--sunken) 0);
}
.mastery-list strong { font-variant-numeric: tabular-nums; }
.mastery-list small { grid-column: 2 / -1; color: var(--muted); }
.mastery-list small:empty { display: none; }

.achievement-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.achievement-list li {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}
.achievement-list li > div { display: grid; }
.achievement-list small { color: var(--muted); }
.achievement-icon { flex: none; color: var(--muted); }
.achievement-list .is-unlocked { border-color: var(--line-strong); background: var(--gold-soft); }
.achievement-list .is-unlocked .achievement-icon { color: var(--ink); }
.achievement-list .is-locked { opacity: .7; border-style: dashed; }
.reset-progress { margin-top: 2rem; }

.new-achievements { max-width: 32rem; margin: 0 auto 2rem; }
.new-achievements h2 { margin: 0 0 .75rem; font-size: 1.4rem; }
.new-achievements .achievement-list { grid-template-columns: 1fr; }

.goal { margin-top: .75rem; }
.goal-text { margin: 0 0 .35rem; font-weight: 700; }
.goal-bar {
  display: block;
  height: .7rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold) calc(var(--ratio) * 100%), var(--sunken) 0);
}
.goal-bar.is-met { background: var(--right); }
.goal-options { max-width: 30rem; margin-bottom: .9rem; }
.goal-days { margin: .4rem 0 0; color: var(--muted); font-size: .9rem; }

.combo {
  margin: -.75rem 0 .75rem;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}
:root[data-combo="off"] .combo { display: none; }
.result-combo, .result-goal { margin: -.75rem auto 1.25rem; font-weight: 700; }
.result-goal { color: var(--right); }

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

.smart-summary { color: var(--ink) !important; font-weight: 700; }
.data-section p { color: var(--muted); }
.data-status { color: var(--right) !important; font-weight: 700; }
.data-status:empty { display: none; }

.faq { margin-top: 2.5rem; }
.faq h2 { margin: 0 0 .5rem; font-size: 1.5rem; }
.faq-group { margin: 1.25rem 0 .6rem; font-size: 1.1rem; }
.faq details {
  margin-bottom: .5rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.faq details[open] { border-color: var(--line-strong); }
.faq summary {
  padding: .75rem 1rem;
  cursor: pointer;
  font-weight: 700;
}
.faq summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: var(--radius); }
.faq details > :not(summary) { margin: 0 1rem .9rem; }
.faq details ul, .faq details ol { padding-left: 1.25rem; }
.faq details li + li { margin-top: .25rem; }
.faq-note {
  margin: .75rem 0 0;
  padding: .7rem .9rem;
  border-left: 4px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: var(--gold-soft);
  font-size: .95rem;
}

/* Study mode ---------------------------------------------------------------- */

.study { cursor: default; }
.study-options li {
  padding: .7rem 1rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  font-size: 1.05rem;
}
.study-options li.is-correct { border-color: var(--right); background: var(--right-soft); color: var(--right); font-weight: 700; }
.study-actions { grid-template-columns: auto 1fr; }
.study-actions .previous { width: auto; }

/* Dialogs ------------------------------------------------------------------- */

dialog {
  width: min(32rem, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: 1.5rem;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 6px 6px 0 var(--accent);
}
dialog::backdrop { background: rgb(10 14 20 / .55); }
dialog h2 { margin: 0 0 1rem; font-size: 1.5rem; }

fieldset { margin: 0 0 1.1rem; padding: 0; border: none; }
legend { margin-bottom: .45rem; font-weight: 700; }

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: var(--line-strong);
  overflow: hidden;
}
.segmented label {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  min-height: 2.75rem;
  padding: .3rem .7rem;
  background: var(--surface);
  cursor: pointer;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.goal-label { margin: 0 0 .4rem; color: var(--muted); font-weight: 700; }
.goal-options { display: grid; grid-template-columns: repeat(3, 1fr); font-variant-numeric: tabular-nums; }
.segmented label:has(input:checked) { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: -3px; }

.switch { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; cursor: pointer; }

.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }

/* Learning pages: symbols, timeline and map ---------------------------------- */

.learn-page { padding-top: .5rem; }
.learn-page h1 { margin: 0 0 .75rem; font-size: clamp(1.8rem, 5vw, 2.5rem); }
.learn-page .lead { margin-bottom: 1.5rem; }

.symbol {
  margin-top: 1.5rem;
  padding: 1.1rem 1.25rem 1.25rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.symbol h2 { margin: 0 0 .75rem; font-size: 1.6rem; }
.symbol h3 { margin: 1.25rem 0 .5rem; font-size: 1.15rem; }
.symbol-body {
  display: grid;
  grid-template-columns: minmax(0, 18rem) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.symbol-body h3 { margin-top: 0; }
.symbol-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}
.symbol-flag { box-shadow: 0 0 0 1px var(--line); }
.symbol-coat { max-width: 14rem; margin-inline: auto; }
.symbol-facts { margin: 0; padding-left: 1.2rem; }
.symbol-facts li + li { margin-top: .35rem; }
.symbol-day {
  display: inline-block;
  margin: 1rem 0 0;
  padding: .3rem .8rem;
  border-radius: 999px;
  background: var(--gold-soft);
}
.symbol-history { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.symbol-history li { display: grid; grid-template-columns: 3.5rem 1fr; gap: .75rem; }
.symbol-history strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.symbol-actions { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: 1.25rem; }

.anthem-player { margin: 1rem 0 0; }
.anthem-player audio { display: block; width: 100%; max-width: 32rem; }
.anthem-player figcaption { margin-top: .4rem; color: var(--muted); font-size: .8rem; }
.lyrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1rem 1.5rem;
}
.lyrics h4 {
  margin: 0 0 .3rem;
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.lyrics p { margin: 0; line-height: 1.6; }
.lyrics-full { margin-top: 1.25rem; }
.lyrics-full summary { cursor: pointer; color: var(--accent); font-weight: 700; }
.lyrics-full .lyrics { margin-top: 1rem; }

.era-nav { display: flex; flex-wrap: wrap; gap: .5rem; }
.era-nav button.chip { box-shadow: none; font-weight: 700; }
.timeline-tools { display: flex; justify-content: flex-end; margin: .75rem 0 .25rem; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline-era { scroll-margin-top: 1rem; }
.timeline-era h2 { margin: 1.5rem 0 .5rem; font-size: 1.3rem; }
.timeline-event {
  position: relative;
  padding: 0 0 .75rem 1.75rem;
  scroll-margin-top: 1rem;
}
/* The line and the dot of each event. */
.timeline-event::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: .45rem;
  width: 3px;
  background: color-mix(in srgb, var(--accent) 35%, var(--paper));
}
.timeline-event::after {
  content: "";
  position: absolute;
  top: 1.05rem;
  left: 0;
  width: 1rem;
  height: 1rem;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--paper);
  box-sizing: border-box;
}
.timeline-event:has(details[open])::after { background: var(--accent); }
.timeline-event details {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.timeline-event details[open] { border-color: var(--accent); }
/* The year and the + sign share the first line; the title gets the whole
   width below, so long words never run into the sign at large text sizes. */
.timeline-event summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .1rem .75rem;
  padding: .7rem 1rem;
  cursor: pointer;
}
.timeline-event summary::after { grid-column: 2; grid-row: 1; }
.timeline-title { grid-column: 1 / -1; }
.timeline-year[hidden] + .timeline-title { grid-column: 1; grid-row: 1; }
.timeline-event summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: var(--radius); }
.timeline-year {
  color: var(--accent);
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.timeline-title { font-weight: 700; overflow-wrap: break-word; }
.timeline-event summary::-webkit-details-marker { display: none; }
.timeline-event summary::after {
  content: "+";
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}
.timeline-event details[open] summary::after { content: "−"; }
.timeline-body { padding: 0 1rem 1rem; }
.timeline-summary { margin: 0 0 1rem; }
.timeline-extra h2 { margin: 2rem 0 .75rem; font-size: 1.3rem; }

.map-modes { max-width: 20rem; margin-bottom: 1rem; }
.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.map-frame {
  padding: .5rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--blue) 10%, var(--surface));
}
.map-loading { margin: 2rem 1rem; color: var(--muted); text-align: center; }
.province-map { display: block; width: 100%; height: auto; }
.province-map .sea, .province-map .inset-sea { fill: color-mix(in srgb, var(--blue) 14%, var(--surface)); }
.province-map .inset-sea { stroke: var(--line-strong); stroke-width: 2px; }
.province-map .abroad { fill: var(--sunken); }
.province-map .land { fill: var(--surface); }
.province-map .border { fill: none; stroke: var(--muted); stroke-width: 1px; stroke-linejoin: round; pointer-events: none; }
.province-map .border-outer { stroke: var(--ink); stroke-width: 1.5px; }
.province-map .coast { fill: none; stroke: color-mix(in srgb, var(--blue) 60%, var(--surface)); stroke-width: 1px; pointer-events: none; }
.province-map [data-province] { cursor: pointer; outline: none; }
.province-map path.province, .province-map .island { fill: var(--surface); transition: fill .15s ease; }
.province-map [data-region="Costa"] path, .province-map path[data-region="Costa"] { fill: color-mix(in srgb, var(--blue) 30%, var(--surface)); }
.province-map [data-region="Sierra"] path, .province-map path[data-region="Sierra"] { fill: color-mix(in srgb, var(--orange) 30%, var(--surface)); }
.province-map [data-region="Amazonía"] path, .province-map path[data-region="Amazonía"] { fill: color-mix(in srgb, var(--green) 30%, var(--surface)); }
.province-map [data-region="Insular"] .island { fill: color-mix(in srgb, var(--purple) 40%, var(--surface)); }
.province-map [data-region="Insular"] .inset-sea { fill: color-mix(in srgb, var(--blue) 14%, var(--surface)); }
.province-map.is-game path.province, .province-map.is-game .island { fill: var(--surface); }
/* Hover, selection and game states: a province is a path, except Galápagos,
   a group of islands. */
.province-map path[data-province]:is(:hover, :focus-visible),
.province-map g[data-province]:is(:hover, :focus-visible) .island { fill: var(--gold-soft); }
.province-map path[data-province]:is(.is-selected, .is-target),
.province-map g[data-province]:is(.is-selected, .is-target) .island { fill: var(--gold); }
.province-map path[data-province].is-right,
.province-map g[data-province].is-right .island { fill: var(--right); }
.province-map path[data-province].is-wrong,
.province-map g[data-province].is-wrong .island { fill: var(--wrong); }
.province-map g[data-province]:hover .inset-sea, .province-map g[data-province]:focus-visible .inset-sea { stroke: var(--accent); stroke-width: 3px; }

.map-side { display: grid; gap: 1rem; }
.map-panel {
  padding: 1rem 1.1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  scroll-margin: 1rem 0;
}
.map-panel h2 { margin: 0 0 .5rem; font-size: 1.5rem; }
.map-panel .practice-actions { margin-top: 1rem; }
.map-hint { margin: 0; color: var(--muted); }
.map-counter { margin: 0 0 .25rem; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.map-panel .feedback { margin: .5rem 0 1rem; }
.map-panel .feedback.is-wrong { color: var(--wrong); }
.map-facts { display: grid; gap: .4rem; margin: 0; }
.map-facts div { display: flex; flex-wrap: wrap; gap: .1rem .5rem; }
.map-facts dt { color: var(--muted); font-weight: 700; }
.map-facts dt::after { content: ":"; }
.map-facts dd { margin: 0; font-weight: 700; }
.map-legend { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; font-size: .95rem; }
.map-legend li { display: flex; align-items: center; gap: .5rem; }
.map-legend i { flex: none; width: 1.1rem; height: 1.1rem; border: 1px solid var(--muted); border-radius: 4px; }
.map-legend [data-region="Costa"] i { background: color-mix(in srgb, var(--blue) 30%, var(--surface)); }
.map-legend [data-region="Sierra"] i { background: color-mix(in srgb, var(--orange) 30%, var(--surface)); }
.map-legend [data-region="Amazonía"] i { background: color-mix(in srgb, var(--green) 30%, var(--surface)); }
.map-legend [data-region="Insular"] i { background: color-mix(in srgb, var(--purple) 40%, var(--surface)); }
.map-credit { margin: 1rem 0 0; color: var(--muted); font-size: .8rem; }
.map-practice { margin-top: 1rem; }

@media (forced-colors: active) {
  .province-map path.province, .province-map .island { fill: Canvas; stroke: CanvasText; }
  .province-map path[data-province]:is(.is-selected, .is-target, .is-right, .is-wrong),
  .province-map g[data-province]:is(.is-selected, .is-target, .is-right, .is-wrong) .island { fill: Highlight; }
}

@media (max-width: 48rem) {
  .symbol-body { grid-template-columns: 1fr; }
  .symbol-flag { max-width: 22rem; }
  .map-layout { grid-template-columns: 1fr; }
  /* The question or the province info goes above the map. */
  .map-side { order: -1; }
}

/* Small screens ------------------------------------------------------------- */

@media (max-width: 40rem) {
  #open-settings { padding: .5rem .7rem; }
  #open-settings span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .brand { font-size: .95rem; }
  .brand strong { font-size: min(1.15rem, 4.8vw); hyphens: none; }
  .topbar, main { padding-left: 1rem; padding-right: 1rem; }
  .question { padding: 1.1rem; box-shadow: 4px 4px 0 var(--accent); }
  .exam-bar { flex-wrap: wrap; gap: .5rem; }
  .listen span,
  .exam-bar .mark span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .breakdown li { grid-template-columns: 7rem 1fr auto; }
  .mastery-list li { grid-template-columns: 1fr auto; }
  .mastery-list i { grid-column: 1 / -1; grid-row: 2; }
  .mastery-list small { grid-column: 1 / -1; }
  kbd { display: none; }
  /* Whole words, no hyphens: titles shrink with the screen so long words
     such as "Nacionalización" still fit with the largest text. */
  .hero h1, .topics-intro h1, .builder h1, .shared h1, .progress-page h1 { font-size: min(1.9rem, 8.5vw); }
  .start-panel { display: contents; }
  .start-panel .field, .start-panel .check { margin-top: 1rem; }
  .start-panel #start {
    position: sticky;
    bottom: .75rem;
    display: flex;
    width: 100%;
    margin-top: 1rem;
    box-shadow: 0 0 0 .5rem var(--paper);
  }
}

/* Print ---------------------------------------------------------------------- */

.print-summary { margin-top: 0; }
.print-hint { color: var(--muted); font-size: .9rem; }

@media screen {
  #print-area { display: none; }
}

@media print {
  @page { margin: 1.5cm; }

  body {
    display: block;
    min-height: 0;
    background: #fff;
    color: #000;
    font-size: 11pt;
    line-height: 1.4;
  }
  body > :not(#print-area) { display: none !important; }
  #print-area { display: block; }

  .print-header { margin-bottom: 1rem; padding-bottom: .5rem; border-bottom: 2px solid #000; }
  .print-header h1 { margin: 0 0 .2rem; font-size: 18pt; }
  .print-header p { margin: 0; }
  .print-disclaimer { font-size: 9pt; color: #444; }

  .print-lyrics .lyrics { display: block; columns: 2; column-gap: 1.5cm; }
  .print-lyrics .lyrics section { break-inside: avoid; margin-bottom: .6rem; }
  .print-lyrics h4 { margin: 0 0 .2rem; font-size: 11pt; }
  .print-lyrics p { margin: 0; line-height: 1.3; }

  #print-area h2 {
    margin: 1.2rem 0 .4rem;
    font-size: 13pt;
    break-after: avoid;
  }

  .print-list { margin: 0; padding-left: 1.6rem; }
  .print-card {
    margin-bottom: .7rem;
    break-inside: avoid;
    white-space: pre-wrap;
  }
  .print-card p { margin: 0; }
  .print-answer { margin-top: .15rem !important; font-weight: 700; }
  .print-answer::before { content: "R: "; }
  .print-blank {
    height: 1.6rem;
    border-bottom: 1px solid #999;
  }
  .print-note { margin-top: .15rem !important; font-size: 9pt; font-style: italic; }
  .print-options { margin: .2rem 0 0; padding-left: 1.4rem; list-style: upper-alpha; }
  .print-options .is-correct { font-weight: 700; }
  .print-options .is-correct::after { content: " ✓"; }

  #print-area .cloze, #print-area .cloze.revealed {
    padding: 0;
    border: none;
    background: none;
    color: #000;
    font-weight: 700;
    text-decoration: underline;
  }
  #print-area [class^="color-"] { color: #000; }
  #print-area .explanation {
    margin-top: .2rem;
    padding: .2rem .5rem;
    border-left: 3px solid #999;
    background: none;
    font-size: 9.5pt;
  }
  #print-area .occlusion { max-width: 9cm; margin-top: .3rem; border: 1px solid #999; }
  #print-area .mask {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  #print-area .mask.active { font-size: 10pt; }
  #print-area .print-photo { margin-top: .3rem; }
  #print-area .print-photo img { max-height: 5cm; border: 1px solid #999; }
  #print-area .print-photo figcaption { font-size: 8pt; color: #444; }
}
