.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  inline-size: 44px;
  block-size: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--pale);
}

.theme-toggle:empty::before {
  content: "☾";
}

.theme-toggle[aria-pressed="true"]:empty::before {
  content: "☀";
}

@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1827;
    --paper: #17253a;
    --ink: #edf4fe;
    --muted: #acbfd9;
    --line: #415671;
    --green: #9cccff;
    --lime: #71e6ca;
    --purple: #2b3151;
    --navy: #f0f5ff;
    --blue: #8ac2ff;
    --blue-hover: #b6d8ff;
    --mint: #71e6ca;
    --pale: #223653;
    --shade: #111f32;
    --focus: #a7d6ff;
    --control-border: #6a86a5;
    --shadow: 0 2px 0 #0a1320;
    --positive-surface: #1b3b36;
    --positive-ink: #9cf0d3;
    --positive-border: #66bdac;
    --warning-surface: #392a22;
    --warning-ink: #ffd0ad;
  }

  [data-theme="dark"] :is(.bar, .skip, .path-step, .module, .option, .quiet, .country-control, dialog) {
    background: var(--paper);
  }

  [data-theme="dark"] :is(.brand strong b, .eyebrow, .principle .eyebrow) {
    color: var(--blue-hover);
  }

  [data-theme="dark"] .brand small {
    color: var(--muted);
  }

  [data-theme="dark"] .brand-icon {
    background: var(--pale);
    border-color: var(--line);
  }

  [data-theme="dark"] .brand-icon i {
    background: var(--blue);
  }

  [data-theme="dark"] .brand-icon i:nth-child(3) {
    background: var(--mint);
  }

  [data-theme="dark"] .stat {
    border-color: var(--line);
  }

  [data-theme="dark"] :is(.stat.streak b, .review-due) {
    color: var(--warning-ink);
  }

  [data-theme="dark"] :is(.nav-link:hover, .nav-link[aria-current="page"], .quiet:hover, .module.active) {
    background: var(--pale);
    color: var(--ink);
    border-color: var(--control-border);
  }

  [data-theme="dark"] :is(.theme-toggle, .icon-button, .country-control, .quiet, .option) {
    border-color: var(--control-border);
  }

  [data-theme="dark"] :is(.quiet, .country-control, .day b) {
    color: var(--ink);
  }

  [data-theme="dark"] :is(.exam-jump.answered, .exam-attempt [data-action="exam-flag"][aria-pressed="true"]) {
    background: var(--positive-surface);
    color: var(--positive-ink);
    border-color: var(--positive-border);
  }

  [data-theme="dark"] .exam-jump[aria-current="step"] {
    border-color: var(--focus);
    box-shadow: inset 0 0 0 1px var(--focus);
  }

  [data-theme="dark"] :is(.theme-toggle, .icon-button):hover {
    background: var(--pale);
  }

  [data-theme="dark"] .cta {
    background: #1c528b;
    border-color: var(--control-border);
    color: var(--ink);
    box-shadow: 0 3px 0 #0a192d;
  }

  [data-theme="dark"] .cta:hover:enabled {
    background: #2a629d;
  }

  [data-theme="dark"] .cta:active:enabled {
    box-shadow: 0 1px 0 #0a192d;
  }

  [data-theme="dark"] .cta:disabled {
    background: var(--pale);
    border-color: var(--line);
    color: var(--muted);
    box-shadow: none;
  }

  [data-theme="dark"] .hero {
    box-shadow: 0 5px 0 #0a1320;
    border-color: var(--line);
  }

  [data-theme="dark"] .hero .eyebrow {
    color: var(--mint);
  }

  [data-theme="dark"] .hero .cta:enabled {
    background: var(--mint);
    color: #102e48;
    border-color: var(--positive-border);
  }

  [data-theme="dark"] .hero .cta:hover:enabled {
    background: #a0efd9;
  }

  [data-theme="dark"] .hero .quiet {
    background: #152941;
    color: var(--ink);
  }

  [data-theme="dark"] .hero .quiet:hover {
    background: #23415f;
  }

  [data-theme="dark"] :is(select, textarea, input[type="text"], input[type="number"], input[type="email"], input[type="password"]) {
    background: var(--shade);
    border-color: var(--control-border);
    color: var(--ink);
  }

  [data-theme="dark"] :is(input, textarea)::placeholder {
    color: var(--muted);
    opacity: 1;
  }

  [data-theme="dark"] :is(input[type="range"], input[type="checkbox"], input[type="radio"]) {
    accent-color: var(--blue);
  }

  [data-theme="dark"] .option:has(input:checked) {
    background: var(--pale);
    border-color: var(--blue);
  }

  [data-theme="dark"] :is(a, button, input, select, textarea, summary):focus-visible,
  [data-theme="dark"] .option:has(input:focus-visible) {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
  }

  [data-theme="dark"] .day b {
    background: var(--pale);
    border-color: var(--line);
  }

  [data-theme="dark"] .day.today b {
    border-color: var(--blue);
  }

  [data-theme="dark"] :is(.day.done b, .feedback.correct, .coverage-status[data-status="targeted"], .biology-practice-feedback[data-correct="true"]) {
    background: var(--positive-surface);
    color: var(--positive-ink);
    border-color: var(--positive-border);
  }

  [data-theme="dark"] .day.today.done b {
    border-color: var(--mint);
  }

  [data-theme="dark"] .feedback.correct h3 {
    color: var(--positive-ink);
  }

  [data-theme="dark"] :is(.feedback.incorrect, .coverage-status[data-status="gap"], .biology-practice-feedback[data-correct="false"], .exam-confirm) {
    background: var(--warning-surface);
    color: var(--warning-ink);
  }

  [data-theme="dark"] .feedback.incorrect h3 {
    color: var(--warning-ink);
  }

  [data-theme="dark"] :is(.step-icon:nth-child(2), .path-step:nth-child(3) .step-icon) {
    background: var(--positive-surface);
    color: var(--positive-ink);
  }

  [data-theme="dark"] .finish-icon {
    color: #10362f;
  }

  [data-theme="dark"] .study-tools .panel {
    border-block-start-color: var(--blue);
  }

  [data-theme="dark"] progress {
    background: #324760;
  }

  [data-theme="dark"] progress::-webkit-progress-bar {
    background: #324760;
  }

  [data-theme="dark"] progress::-webkit-progress-value {
    background: var(--blue);
  }

  [data-theme="dark"] progress::-moz-progress-bar {
    background: var(--blue);
  }

  [data-theme="dark"] .explain {
    background: var(--positive-surface);
    color: var(--positive-ink);
    border-color: var(--positive-border);
    box-shadow: 0 3px 0 #0b201d;
  }

  [data-theme="dark"] .explain:hover {
    background: #244d46;
  }

  [data-theme="dark"] dialog {
    box-shadow: 0 1rem 4rem #060c17bf;
  }

  [data-theme="dark"] dialog::backdrop {
    background: #040812b8;
  }

  [data-theme="dark"] .dialog-body .practice-result {
    background: var(--pale);
  }

  [data-theme="dark"] .biology-practice-score {
    color: var(--positive-ink);
  }

  /* Recolour the graph and its background together to preserve its dark ink and dashed/solid series. */
  [data-theme="dark"] .biology-practice-figure canvas {
    filter: invert(.9) hue-rotate(180deg);
    border-color: #c7d1de;
    forced-color-adjust: none;
  }

  [data-theme="dark"] .biology-practice-legend span::before {
    border-color: #6fabf1;
  }

  [data-theme="dark"] .biology-practice-legend span + span::before {
    border-color: #e3947c;
  }
}
