:root {
  --bg: #101816;
  --card: #1a2623;
  --header: #14211e;
  --ink: #e8f3ef;
  --muted: #b7cbc4;
  --line: #314843;
  --teal: #1f6f6b;
  --teal-dark: #185853;
  --teal-soft: #1d3834;
  --on-teal: #ffffff;
  --ok-bg: #12352a;
  --ok: #9be0bc;
  --ok-line: #2f7a58;
  --bad-bg: #3a1c24;
  --bad: #ffb4be;
  --bad-line: #8a4450;
  --caution-bg: #3a3016;
  --caution: #f3d48a;
  --urgent-bg: #3d221c;
  --urgent: #ffb5a8;
  --focus: #9ee8e0;
  --track: #2a403c;
  --disabled: #4d6663;
  --max: 46rem;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f6f5;
  --card: #ffffff;
  --header: #ffffff;
  --ink: #10243f;
  --muted: #3d5168;
  --line: #d3dfdb;
  --teal: #0f4c4a;
  --teal-dark: #0b3b39;
  --teal-soft: #e6f3f1;
  --on-teal: #ffffff;
  --ok-bg: #e7f6ee;
  --ok: #085c38;
  --ok-line: #b7dfc9;
  --bad-bg: #fdecee;
  --bad: #8f1d2c;
  --bad-line: #f0c2c7;
  --caution-bg: #fff6e0;
  --caution: #6b4300;
  --urgent-bg: #fde8e4;
  --urgent: #7a1b14;
  --focus: #0f4c4a;
  --track: #d7e3df;
  --disabled: #8aa4a3;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { font-size: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.5rem 0.75rem;
  z-index: 5;
}

.skip:focus { top: 0.75rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--header);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 1rem 0.6rem;
}

.header-inner,
.header-meta,
#main,
.site-footer {
  width: min(100%, var(--max));
  margin-inline: auto;
}

.header-inner,
.header-tools,
.header-meta,
.dialog-actions,
.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.brand-title,
.brand-subtitle,
.timer,
.header-meta p {
  margin: 0;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-subtitle,
.timer-label,
.kicker,
.header-meta,
.meta {
  color: var(--muted);
}

.brand-subtitle { font-size: 0.92rem; }

.timer { text-align: right; }

.timer-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: 0.03em;
}

.timer-value.caution { color: var(--caution); }
.timer-value.urgent,
.timer-value.expired { color: var(--urgent); }

.header-meta {
  margin-top: 0.55rem;
  font-size: 0.92rem;
}

progress {
  display: block;
  width: min(100%, var(--max));
  height: 0.5rem;
  margin: 0.55rem auto 0;
  border: 0;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}

progress::-webkit-progress-bar { background: var(--track); }
progress::-webkit-progress-value { background: var(--teal); }
progress::-moz-progress-bar { background: var(--teal); }

.timer-alert,
.resume-note {
  width: min(100%, var(--max));
  margin: 0.55rem auto 0;
  border-radius: 0.4rem;
  padding: 0.45rem 0.7rem;
}

.timer-alert:empty,
.resume-note:empty { display: none; }

.timer-alert.caution,
.resume-note {
  background: var(--caution-bg);
  color: var(--caution);
}

.timer-alert.urgent,
.timer-alert.expired {
  background: var(--urgent-bg);
  color: var(--urgent);
  font-weight: 700;
}

#main { padding: 1rem 1rem 2.5rem; }

.card,
.review-item,
.summary {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(16, 36, 63, 0.04);
}

.card + .card,
.review-item + .review-item,
.summary + .card,
.summary + .review-list,
.card + .review-list { margin-top: 0.9rem; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6rem; scroll-margin-top: 12rem; }

h1 { font-size: 1.55rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

.kicker {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.stem { font-size: 1.06rem; margin: 0 0 1rem; overflow-wrap: anywhere; }

.instructions { padding-left: 1.15rem; margin: 0.4rem 0 1rem; }
.instructions li { margin: 0.35rem 0; }

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend { font-weight: 700; margin-bottom: 0.45rem; }

.option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-height: 2.75rem;
  margin: 0.45rem 0;
  padding: 0.7rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 0.65rem;
  background: var(--card);
  cursor: pointer;
}

.option input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.15rem 0 0;
  flex: none;
  accent-color: var(--teal);
}

.option-letter {
  flex: none;
  width: 1.6rem;
  font-weight: 700;
}

.option-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.option:focus-within,
button:focus-visible,
.skip:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.option:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.option.is-correct {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.option.is-incorrect {
  border-color: var(--bad);
  background: var(--bad-bg);
}

.option-tag {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

button,
.option { font: inherit; color: inherit; }

.actions { margin-top: 1rem; }

button {
  min-height: 2.75rem;
  min-width: 2.75rem;
  border-radius: 0.6rem;
  border: 2px solid transparent;
  padding: 0.55rem 1rem;
  cursor: pointer;
}

.primary {
  background: var(--teal);
  color: var(--on-teal);
  width: 100%;
}

.primary:hover,
.primary:focus-visible { background: var(--teal-dark); }

.primary:disabled {
  background: var(--disabled);
  cursor: not-allowed;
}

.secondary,
.ghost,
.danger {
  background: var(--card);
  border-color: var(--line);
}

.danger { border-color: var(--bad); color: var(--bad); }

.feedback {
  border-radius: 0.65rem;
  padding: 0.85rem 0.9rem;
  margin: 0.9rem 0;
}

.feedback.correct { background: var(--ok-bg); color: var(--ok); }
.feedback.incorrect { background: var(--bad-bg); color: var(--bad); }
.feedback p { margin: 0.3rem 0; }
.rationale { color: var(--ink); }

.review-list { display: grid; gap: 0.75rem; margin-top: 0.9rem; }
.review-item p { margin: 0.3rem 0; }
.review-item.correct { border-color: var(--ok-line); }
.review-item.incorrect { border-color: var(--bad-line); }

.rounds { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.rounds li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}

@media (min-width: 768px) {
  .rounds li {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
  }
}

.note, .loading, .error { color: var(--muted); }
.error { color: var(--bad); }

dialog {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem;
  width: min(100% - 2rem, 28rem);
  background: var(--card);
  color: var(--ink);
}

dialog::backdrop { background: rgba(16, 36, 63, 0.45); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (min-width: 768px) {
  .site-header { padding-inline: 1.5rem; }
  #main { padding-inline: 1.5rem; }
  .primary { width: auto; min-width: 13rem; }
  .actions { display: flex; }
}

@media (max-width: 22rem) {
  .timer { text-align: left; }
  .header-tools { width: 100%; }
}

.quiet-link {
  color: var(--muted);
  font-size: 0.92rem;
}

a.ghost {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.field { display: grid; gap: 0.3rem; margin: 0.7rem 0; }
.field span, .check-row { color: var(--muted); }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  min-height: 2.75rem;
  background: var(--bg);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.5rem 0.7rem;
  font: inherit;
}

textarea { min-height: 6rem; resize: vertical; }

.check-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  min-height: 2.75rem;
}

.admin-nav, .stack { display: grid; gap: 0.75rem; }
.admin-nav { grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); }

.row-list { display: grid; gap: 0.45rem; margin: 0.6rem 0; }
.row-list article, .row-list div.line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0;
}

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

.spelling-clue { margin: 0.35rem 0; }
.spelling-label { display: block; color: var(--muted); font-size: 0.85rem; }
.spelling .actions, .review-item .actions { margin-top: 0.75rem; }
