:root {
  color-scheme: light;
  --font:
    "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI",
    sans-serif;
  --bg: oklch(97.4% 0.006 265);
  --sheet: oklch(100% 0 0);
  --track: oklch(93.5% 0.01 265);
  --seg-on: var(--sheet);
  --ink: oklch(23% 0.025 265);
  --ink-2: oklch(47% 0.02 265);
  --line: oklch(91% 0.01 265);
  --line-2: oklch(62% 0.015 265);
  --accent: oklch(50% 0.2 270);
  --accent-hover: oklch(44% 0.2 270);
  --on-accent: oklch(100% 0 0);
  --accent-soft: oklch(95% 0.03 270);
  --ok: oklch(50% 0.12 155);
  --ok-soft: oklch(95.5% 0.04 155);
  --bad: oklch(52% 0.18 25);
  --bad-soft: oklch(95.5% 0.03 25);
  --lift: oklch(23% 0.03 265 / 0.14);
  --r: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: oklch(17% 0.012 265);
    --sheet: oklch(21.5% 0.014 265);
    --track: oklch(26.5% 0.015 265);
    --seg-on: oklch(35% 0.018 265);
    --ink: oklch(94% 0.006 265);
    --ink-2: oklch(73% 0.015 265);
    --line: oklch(29% 0.015 265);
    --line-2: oklch(54% 0.018 265);
    --accent: oklch(74% 0.14 270);
    --accent-hover: oklch(80% 0.12 270);
    --on-accent: oklch(19% 0.04 270);
    --accent-soft: oklch(30% 0.07 270);
    --ok: oklch(79% 0.14 155);
    --ok-soft: oklch(28% 0.05 155);
    --bad: oklch(75% 0.15 25);
    --bad-soft: oklch(28% 0.045 25);
    --lift: oklch(0% 0 0 / 0.45);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scrollbar-color: var(--line-2) var(--bg);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
::selection {
  background: var(--accent-soft);
  color: var(--ink);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}
h1,
h2 {
  text-wrap: balance;
}
code {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--track);
  padding: 0.05em 0.35em;
  border-radius: 5px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.wrap {
  width: min(100% - 32px, 42rem);
  margin-inline: auto;
}
.i {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Header */
.head {
  padding: 16px 0 20px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
  margin-left: -8px;
  padding: 0 10px 0 4px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.18s;
}
.back:hover {
  background: var(--accent-soft);
}
h1 {
  margin: 12px 0 6px;
  font-size: 1.75rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.lead {
  margin: 0 0 20px;
  max-width: 62ch;
  color: var(--ink-2);
}

.rules {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.rules summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 16px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  border-radius: var(--r);
}
.rules summary::-webkit-details-marker {
  display: none;
}
.rules summary .i {
  color: var(--ink-2);
  transition: transform 0.18s var(--ease);
}
.rules[open] summary .i {
  transform: rotate(180deg);
}
.rules dl {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 14px 16px 0;
  border-top: 1px solid var(--line);
}
.rules dt {
  font-weight: 600;
}
.rules dd {
  margin: 2px 0 0;
  color: var(--ink-2);
}
.rules > p {
  margin: 16px 0 0;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}
@media (min-width: 640px) {
  .rules dl {
    grid-template-columns: 1fr 1fr;
    gap: 16px 28px;
  }
}

/* Block tabs */
.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 0;
  background: var(--bg);
  box-shadow: 0 1px 0 var(--line);
}
.seg {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--track);
  border-radius: var(--r);
}
.seg a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  padding: 6px 8px;
  border-radius: 9px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition:
    background 0.18s,
    color 0.18s,
    box-shadow 0.18s;
}
.seg a:hover {
  color: var(--ink);
}
.seg a[aria-current="true"] {
  background: var(--seg-on);
  color: var(--ink);
  box-shadow:
    0 1px 2px var(--lift),
    0 4px 12px -6px var(--lift);
}
.seg small {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.seg small .i {
  width: 1em;
  height: 1em;
  stroke-width: 2.5;
}
.seg a.pass small {
  color: var(--ok);
  font-weight: 600;
}

/* Exercises */
main {
  padding-bottom: 32px;
}
.block h2 {
  margin: 28px 0 4px;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.intro {
  margin: 0 0 14px;
  color: var(--ink-2);
}
.hist {
  margin: -8px 0 14px;
  color: var(--ink-2);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
.items {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 12px;
  padding: 18px 16px;
  border-top: 1px solid var(--line);
}
.item:first-child {
  border-top: 0;
}

.num {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--track);
  color: var(--ink-2);
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition:
    background 0.18s,
    color 0.18s;
}
.num .i {
  display: none;
  width: 1rem;
  height: 1rem;
  stroke-width: 3;
}
[data-state] .num b {
  display: none;
}
[data-state="ok"] .num {
  background: var(--ok);
  color: var(--sheet);
}
[data-state="bad"] .num {
  background: var(--bad);
  color: var(--sheet);
}
[data-state="ok"] .num .i-check,
[data-state="bad"] .num .i-x {
  display: block;
  animation: mark-in 0.18s var(--ease);
}
@keyframes mark-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

.en {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.75;
  text-wrap: pretty;
}
.es {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.blank {
  width: var(--w);
  min-width: 5ch;
  max-width: 100%;
  margin: 0 0.05em;
  padding: 0.1em 0.4em;
  font: inherit;
  font-weight: 600;
  line-height: 1.35;
  color: var(--accent);
  caret-color: var(--accent);
  background: var(--bg);
  border: 0;
  border-bottom: 2px solid var(--line-2);
  border-radius: 6px 6px 2px 2px;
  appearance: none;
  transition:
    border-color 0.18s,
    background 0.18s,
    color 0.18s;
}
.blank:hover {
  border-bottom-color: var(--ink-2);
}
.blank:focus {
  outline: none;
  background: var(--accent-soft);
  border-bottom-color: var(--accent);
}
[data-state="ok"] .blank {
  color: var(--ok);
  background: var(--ok-soft);
  border-bottom-color: var(--ok);
}
[data-state="bad"] .blank {
  color: var(--bad);
  background: var(--bad-soft);
  border-bottom-color: var(--bad);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
legend {
  padding: 0;
}
.opts {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--sheet);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  font-size: 1.0625rem;
  line-height: 1.4;
  cursor: pointer;
  transition:
    border-color 0.18s,
    background 0.18s,
    box-shadow 0.18s;
}
.opt:hover {
  border-color: var(--ink-2);
}
.opt input {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--accent);
}
.opt:has(:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.opt.is-right {
  background: var(--ok-soft);
  border-color: var(--ok);
  box-shadow: inset 0 0 0 1px var(--ok);
}
.opt.is-right input {
  accent-color: var(--ok);
}
.opt.is-wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
  box-shadow: inset 0 0 0 1px var(--bad);
}
.opt.is-wrong input {
  accent-color: var(--bad);
}
.opt.is-wrong span {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

/* Feedback */
.fb:empty {
  display: none;
}
.fb {
  margin-top: 12px;
  font-size: 0.9375rem;
  line-height: 1.55;
  animation: fb-in 0.18s var(--ease);
}
.fb p {
  margin: 0;
}
[data-state="bad"] .fb {
  padding: 12px 14px;
  background: var(--bad-soft);
  border-radius: 10px;
}
.fb-head .i {
  margin-top: 0.15em;
}
.fb-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px !important;
  color: var(--bad);
  font-weight: 600;
}
.fb-head strong {
  color: var(--ink);
}
[data-state="bad"] .fb code {
  background: color-mix(in oklch, var(--bad) 14%, var(--bad-soft));
}
.fb details code {
  background: color-mix(in oklch, var(--ok) 14%, var(--ok-soft));
}
.fb summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: var(--ok);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  border-radius: 6px;
}
.fb summary::-webkit-details-marker {
  display: none;
}
.fb .why {
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.fb details[open] .why {
  display: none;
}
.fb details p {
  margin-top: 6px;
  padding: 10px 14px;
  background: var(--ok-soft);
  border-radius: 10px;
}
@keyframes fb-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* Bottom bar */
.bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: var(--sheet);
  box-shadow:
    0 -1px 0 var(--line),
    0 -12px 32px -20px var(--lift);
}
.bar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.status {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.3;
}
.status strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.meter {
  display: block;
  width: min(10rem, 38vw);
  height: 4px;
  overflow: hidden;
  background: var(--track);
  border-radius: 99px;
}
.meter i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transform: scaleX(var(--p));
  transform-origin: left;
  transition: transform 0.18s var(--ease);
}
.status .score {
  color: var(--bad);
  font-size: 1.375rem;
  line-height: 1.1;
  font-weight: 700;
}
.status .score.pass {
  color: var(--ok);
}
.status .score,
.status .score + span {
  animation: fb-in 0.18s var(--ease) both;
}
.status .score + span {
  animation-delay: 40ms;
}
.acts {
  display: flex;
  flex: none;
  gap: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 20px;
  font: inherit;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  transition:
    background 0.18s,
    color 0.18s,
    transform 0.1s;
}
.btn:active {
  transform: scale(0.97);
}
.btn[hidden] {
  display: none;
}
.primary {
  background: var(--accent);
  color: var(--on-accent);
}
.primary:hover {
  background: var(--accent-hover);
}
.primary:disabled {
  background: var(--track);
  color: var(--ink-2);
  cursor: not-allowed;
  transform: none;
}
.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.ghost:hover {
  background: var(--bg);
}
@media (max-width: 420px) {
  .ghost {
    padding: 0 13px;
  }
  .ghost span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Topic index */
.topics {
  list-style: none;
  margin: 0 0 40px;
  padding: 0;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.topics > li + li {
  border-top: 1px solid var(--line);
}
.topic {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 18px 16px;
  color: inherit;
  text-decoration: none;
  transition: background 0.18s;
}
.topic:hover {
  background: var(--bg);
}
.topic h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.topic p {
  margin: 2px 0 12px;
  color: var(--ink-2);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--track);
  color: var(--ink-2);
  border-radius: 99px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip .i {
  width: 1em;
  height: 1em;
  stroke-width: 2.5;
}
.chip.pass {
  background: var(--ok-soft);
  color: var(--ok);
}
.go {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--accent);
  font-weight: 700;
}
.note {
  margin: 0 0 32px;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

/* Phone: lists run edge to edge for wider sentences. */
@media (max-width: 639px) {
  .items,
  .topics {
    margin-inline: -16px;
    border-inline: 0;
    border-radius: 0;
  }
  .topic {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .topic p {
    margin-bottom: 0;
  }
  .chips {
    margin-top: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation: none !important;
  }
}
