@font-face {
  font-family: 'Geist';
  src: url('fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('fonts/GeistMono-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fff;
  --ink: #000;
  --ink-2: #111;
  --grey: #666;
  --grey-2: #999;
  --rule: #e5e5e5;
  --accent: #ff4f00;
  --gutter: 16px;
  --col-gap: 16px;
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

[hidden] { display: none !important; }

.mono { font-family: var(--mono); }
.muted { color: var(--grey-2); }

.wrap {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
}

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--rule);
  padding-top: max(20px, env(safe-area-inset-top));
}
.masthead .grid {
  align-items: baseline;
  padding-bottom: 20px;
  row-gap: 4px;
}
.wordmark {
  grid-column: 1 / 11;
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}
.version {
  grid-column: 11 / 13;
  grid-row: 1;
  justify-self: end;
  font-size: 11px;
  color: var(--grey-2);
  letter-spacing: 0.04em;
}
.tagline {
  grid-column: 1 / 13;
  margin: 0;
  color: var(--grey);
  font-size: 15px;
}

/* ---------- labels / buttons ---------- */

.label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--grey);
}

.btn {
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:hover { background: #f5f5f5; }
.btn:focus-visible,
.seg button:focus-visible,
.input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--ink-2); }
.btn-big { min-height: 64px; width: 100%; font-size: 14px; letter-spacing: 0.12em; }
.btn-small { min-height: 44px; padding: 0 12px; font-size: 11px; }

/* ---------- layout ---------- */

main.grid {
  padding-top: 24px;
  padding-bottom: 32px;
  row-gap: 32px;
}

.drill { grid-column: 1 / 13; min-width: 0; }
.controls { grid-column: 1 / 13; min-width: 0; border-top: 1px solid var(--ink); }

@media (min-width: 900px) {
  :root { --gutter: 40px; --col-gap: 24px; }
  .masthead { padding-top: 40px; }
  .masthead .grid { padding-bottom: 28px; }
  .wordmark { grid-column: 1 / 5; font-size: 40px; }
  .tagline { grid-column: 5 / 11; grid-row: 1; font-size: 16px; }
  main.grid { padding-top: 40px; padding-bottom: 64px; }
  .controls { grid-column: 1 / 5; grid-row: 1; }
  .drill { grid-column: 5 / 13; grid-row: 1; }
}

/* ---------- controls ---------- */

.row {
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--rule);
  display: grid;
  gap: 10px;
}
.row-last { border-bottom: 0; }

.seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
  border-radius: 2px;
}
.seg-cat { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg-wide { grid-column: 1 / -1; }

.seg button {
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
  min-width: 0;
  padding: 0 6px;
  border: 0;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg button:hover { background: #f5f5f5; }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--bg); }
.seg .count { color: var(--grey-2); margin-left: 4px; }
.seg button[aria-pressed='true'] .count { color: var(--grey-2); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
}
.check input {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--bg);
  display: grid;
  place-content: center;
  flex: none;
}
.check input:checked { background: var(--ink); }
.check input:checked::after {
  content: '';
  width: 10px;
  height: 5px;
  border-left: 2px solid var(--bg);
  border-bottom: 2px solid var(--bg);
  transform: translateY(-1px) rotate(-45deg);
}
.check.is-disabled { color: var(--grey-2); cursor: not-allowed; }
.check.is-disabled input { border-color: var(--grey-2); }

.voice {
  margin: 0;
  font-size: 12px;
  color: var(--grey-2);
  overflow-wrap: anywhere;
}
.notice {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  font-size: 14px;
  color: var(--ink-2);
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.stat {
  display: grid;
  gap: 4px;
  padding: 12px 0 14px;
  min-width: 0;
}
.stat + .stat { border-left: 1px solid var(--rule); padding-left: 12px; }
.num {
  font-family: var(--mono);
  font-size: clamp(28px, 8vw, 48px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.num.is-hot { color: var(--accent); }

/* ---------- stage ---------- */

.stage { padding-top: 16px; }
.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.prompt {
  font-family: var(--mono);
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  padding: 28px 0 32px;
  white-space: nowrap;
  overflow: hidden;
  min-height: 1em;
}
.prompt:empty { display: none; }
.prompt.size-xl { font-size: clamp(72px, 24vw, 168px); }
.prompt.size-l { font-size: clamp(40px, 13vw, 112px); }
.prompt.size-m { font-size: clamp(30px, 10.5vw, 88px); letter-spacing: -0.06em; }

.start { padding: 28px 0 24px; display: grid; gap: 12px; }
.hint { margin: 0; color: var(--grey); font-size: 14px; }

.listen {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0 24px;
}
.listen-mark { font-size: 40px; color: var(--grey-2); letter-spacing: 0.1em; line-height: 1; }

.empty { margin: 28px 0; color: var(--grey); }

.answer { display: grid; gap: 8px; padding-top: 4px; scroll-margin-bottom: 24px; }
.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  font-family: var(--mono);
}
.input:disabled { border-color: var(--rule); background: #fafafa; }
.answer-row .btn { min-height: 52px; }

/* ---------- feedback ---------- */

.feedback {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 8px;
  justify-items: start;
}
.feedback p { margin: 0; max-width: 100%; overflow-wrap: anywhere; }
.verdict {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink);
}
.verdict.is-wrong { color: var(--accent); }
.fb-digits { font-size: clamp(28px, 8vw, 44px); line-height: 1.1; letter-spacing: -0.04em; color: var(--ink); }
.fb-words { font-size: 18px; line-height: 1.5; color: var(--ink); }
.fb-typed { font-size: 13px; color: var(--grey); }
.fb-note { font-size: 14px; color: var(--grey); }
.fb-note:empty, .fb-typed:empty, .fb-digits:empty { display: none; }

.d-wrong, .d-missing {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.d-missing { text-decoration-style: dotted; }
.d-extra {
  color: var(--accent);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* ---------- footer ---------- */

.foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-top: 16px;
  padding-bottom: 24px;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  color: var(--grey-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.foot .mono { font-size: 11px; }
