/*
 * トップページの見た目。
 *
 * 配色と書体は最初の検証画面のものに戻してある。薄い灰の地（--bg）の上に
 * 白いパネル（--panel）を細い罫線で置き、角は 10px、文字はシステムのゴシック。
 * アクセントは青（--accent）で、リンク・押すボタン・カーソルなど「操作する側」に使う。
 * 判定の 4 値だけは意味のある色を持ち、正解＝緑・もう一度＝黄土・誤答＝赤・審判へ＝藤。
 * 目立たせるのは出題盤と押すボタンだけで、ほかは罫線だけの静かな面にしてある。
 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #5d6673;
  --line: #d9dde3;
  --accent: #2f6db5;
  --accent-ink: #ffffff;
  --correct: #1e7a45;
  --close: #b06f0d;
  --incorrect: #b3261e;
  --review: #5b4bb5;
  --warn-bg: #fff6e0;
  --warn-ink: #7a5300;
  --radius: 10px;

  /*
   * --close は面や大きな文字には十分だが、小さな注記に地色との差が足りない
   * （白地で 4.1:1）。小さい文字だけはこの濃い黄土を使って 4.5:1 を満たす。
   */
  --close-ink: #8a5600;

  --gothic: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --panel: #1d2127;
    --ink: #e8eaed;
    --muted: #a3acb9;
    --line: #333942;
    --accent: #6ea8e8;
    --accent-ink: #10131a;
    --correct: #66c68b;
    --close: #e0a94b;
    --incorrect: #ef8378;
    --review: #a89bf0;
    --warn-bg: #3a2f14;
    --warn-ink: #f0d79a;

    /* 暗い面では --close のままで 7.6:1 あるので、濃くする必要はない。 */
    --close-ink: #e0a94b;
  }
}

* {
  box-sizing: border-box;
}

/*
 * `hidden` 属性を必ず効かせる。
 *
 * ブラウザの既定は `[hidden] { display: none }` でしかないので、`.next-row { display: flex }`
 * のようにクラス側で display を書くと勝ってしまい、隠したい要素（録音中の印・案内）が
 * 出しっぱなしになる。画面の出し入れは全部 `hidden` で行うので、ここで一度だけ強くしておく。
 */
[hidden] {
  display: none !important;
}

/*
 * スクロールバーの幅を最初から取っておく。決着して判定が出るとページが伸びてスクロールバーが
 * 現れ、中身が左へずれて「次の問題へ」が「押す」の位置からずれるのを防ぐ。
 */
html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  padding: 0 0 4rem;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--gothic);
  font-size: 16px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

main,
.masthead,
footer {
  max-width: 62rem;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 見出し ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding-top: 1.6rem;
  padding-bottom: 0.9rem;
}

/* 製品名。正式名が決まるまでの仮の名前なので、英字ロゴではなく日本語の見出しとして置く。 */
.product-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

/* 「（仮）」は名前の一部だが、読ませたいのは本体なので小さく添える。 */
.product-name .provisional {
  font-size: 0.78em;
  font-weight: normal;
  color: var(--muted);
}

.tagline {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  flex: 1 1 16rem;
}

/* リンクは 2 つで 1 組。個別に折り返すと片方だけ前の行に残って離れて見えるので、
   まとめて 1 つの箱にし、入りきらないときは箱ごと次の行へ落として右に寄せる。 */
.masthead-links {
  display: flex;
  gap: 0.9rem;
  white-space: nowrap;
  margin-left: auto;
}

.to-game {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}

.to-game:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- 出題盤 ---------- */

.stage {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem 1.6rem;
}

.stage-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--muted);
  padding-bottom: 0.8rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.bar-set {
  color: var(--ink);
}

/*
 * 「読み上げ中」「解答受付中」「判定」で幅が変わると、狭い画面で行の折り返しが変わって
 * 下の出題盤ごと上下する（「押す」と「次の問題へ」の位置がずれる）。いちばん長い文言の幅を取っておく。
 */
.bar-state {
  margin-left: auto;
  min-width: 5em;
  text-align: right;
}

.bar-score {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.bar-quit {
  font: inherit;
  font-size: 0.76rem;
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.stage-lead {
  margin: 0 0 1.4rem;
  font-size: 0.95rem;
  color: var(--ink);
  max-width: 44rem;
}

.stage-note {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.stage-note:empty {
  display: none;
}

/*
 * 出題文。1 文字ずつ流れるので、大きめに取って行間をゆったりさせる。
 * 見えない全文（.q-ghost）と読み上げ中の文字（.q-shown）を同じセルに重ねる。
 * 高さはゴーストが決めるので、出題の最初からその問題の全文が収まる高さになり、
 * 1 文字ずつ流れても、決着のあと全文を出しても、下の「押す」ボタンが動かない。
 * 両方とも同じ幅・同じ字で折り返すので、改行の位置もそろう。
 * min-height は短い問題でも欄が小さくなりすぎないためのもの。
 */
.question {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  font-size: clamp(1.15rem, 0.95rem + 1.2vw, 1.7rem);
  line-height: 1.85;
  letter-spacing: 0.01em;
  margin: 0 0 1.5rem;
  min-height: 5.6em;
}

.q-ghost,
.q-shown {
  grid-area: 1 / 1;
  min-width: 0;
}

.q-ghost {
  visibility: hidden;
  pointer-events: none;
}

.caret {
  display: inline-block;
  width: 0.08em;
  height: 1.05em;
  margin-left: 0.06em;
  background: var(--accent);
  vertical-align: -0.16em;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* 読み進みのレール。押した位置に青い線が入る。 */
.rail {
  position: relative;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
}

.rail-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--muted);
  border-radius: 2px;
}

.rail-mark {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 2px;
  background: var(--accent);
}

.rail-note {
  margin: 0.5rem 0 1.2rem;
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-height: 1.3em;
}

/* ---------- 押すボタン ---------- */

.buzz-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.buzzer {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 0.85rem 2.6rem;
  cursor: pointer;
}

.buzzer:hover:not(:disabled) {
  filter: brightness(1.07);
}

.buzzer:active:not(:disabled) {
  transform: translateY(1px);
}

.buzzer:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.buzzer-small {
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  padding: 0.55rem 1.5rem;
}

.buzz-key {
  font-size: 0.76rem;
  color: var(--muted);
}

.ghost {
  font: inherit;
  font-size: 0.86rem;
  background: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
}

.ghost:hover {
  color: var(--ink);
  border-color: var(--muted);
}

.ghost-small {
  font-size: 0.8rem;
  border: none;
  text-decoration: underline;
  padding: 0.3rem 0.2rem;
}

.ghost-small:hover {
  border-color: transparent;
}

/* ---------- 解答欄 ---------- */

.answer {
  margin: 0;
}

.answer-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  max-width: 34rem;
}

.answer-row input {
  flex: 1;
  font: inherit;
  font-size: 1.15rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
}

.answer-row input::placeholder {
  color: var(--muted);
}

.clock {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 2ch;
  text-align: right;
}

.clock.urgent {
  color: var(--incorrect);
}

/* 解答欄の案内（#answer-notes）。操作の行の下に出し、行の高さは変えない。 */
.answer-hint {
  margin: 0.6rem 0 0;
  font-size: 0.86rem;
  color: var(--close-ink);
}

/*
 * 解答欄の横のマイク。押すと「発声で答える」のオン・オフで、オンなら色が付く。
 * 聞いているあいだは点滅する。
 */
.mic-toggle {
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  width: 2.6rem;
  height: 2.4rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  flex: none;
}

.mic-toggle.on {
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.mic-toggle.listening {
  background: var(--incorrect);
  border-color: var(--incorrect);
  animation: mic-pulse 1.1s ease-in-out infinite;
}

.mic-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@keyframes mic-pulse {
  50% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mic-toggle.listening {
    animation: none;
  }
}

/* ---------- 判定（出題盤の中） ---------- */

/*
 * 判定の枠（#outcome。中に #verdict と #judge-panel）。操作の行（押す／解答欄／次の問題へ）の
 * 下に置くので、判定・別解・注記・くわしい判定情報で何行になっても、ボタンの位置は変わらない。
 * 読み上げ中は中身が hidden なので高さ 0（余白も出さない）。
 */
.outcome {
  display: flow-root;
}

.verdict {
  /* 判定語の字の大きさ。 */
  --v-word-size: clamp(1.8rem, 1.3rem + 2.2vw, 2.6rem);
  /* 操作の行との間隔。 */
  margin-top: 1.1rem;
}

/* 判定語の行の高さを、周りの行間に左右されず字の大きさ × 1.2 ちょうどにする。 */
.v-head {
  display: flex;
  align-items: baseline;
}

.v-word {
  font-size: var(--v-word-size);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.06em;
  display: inline-block;
  animation: stamp 260ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes stamp {
  from {
    opacity: 0;
    transform: scale(1.14);
  }
}

.verdict.correct .v-word {
  color: var(--correct);
}
.verdict.close .v-word {
  color: var(--close);
}
.verdict.incorrect .v-word {
  color: var(--incorrect);
}
.verdict.review .v-word {
  color: var(--review);
}
.verdict.none .v-word {
  color: var(--muted);
  font-size: 1.4rem;
}

.v-detail {
  margin: 0.2rem 0 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.v-matched {
  margin: 0.1rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.v-given {
  font-size: 1.1rem;
  font-weight: 600;
}

.v-source,
.v-note,
.v-human {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.v-note {
  color: var(--close-ink);
}

/* 決着した問題の答え合わせ（問題文は全文に差し替え、ここに想定正解を出す）。 */
.v-reveal {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--line);
  /* 長い正解でも画面からはみ出さない。 */
  overflow-wrap: anywhere;
}

.v-reveal p {
  margin: 0;
}

.v-answer {
  font-size: 1rem;
  color: var(--ink);
}

.v-answer b {
  margin-right: 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.v-reveal .v-alt {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.v-probe {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
  font-size: 0.74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.v-prob i {
  display: inline-block;
  width: 3.4rem;
  height: 3px;
  background: var(--line);
  margin-right: 0.4rem;
  vertical-align: 0.2em;
}

.v-prob i span {
  display: block;
  height: 100%;
  background: var(--muted);
}

.v-prob.correct i span {
  background: var(--correct);
}
.v-prob.close i span {
  background: var(--close);
}
.v-prob.incorrect i span {
  background: var(--incorrect);
}

/* ---------- 審判に聞く ---------- */

.judge-call {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.judge-lead {
  margin: 0 0 0.7rem;
  font-size: 0.9rem;
  color: var(--ink);
}

/* 審判が決めるあいだだけ出す想定正解。決まったら答え合わせに引き継ぐ。 */
.judge-answer {
  margin: 0 0 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.judge-answer:empty {
  display: none;
}

.judge-buttons {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.judge {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--panel);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.45rem 1.4rem;
  cursor: pointer;
}

.judge.correct {
  color: var(--correct);
}
.judge.close {
  color: var(--close-ink);
}
.judge.incorrect {
  color: var(--incorrect);
}

.judge:hover {
  background: var(--bg);
}

.next-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

/*
 * 狭い画面でも「次の問題へ」の行が操作の行（「押す」の高さ）を超えないよう、ボタンとリンクは
 * 折り返さず、キーの案内だけを詰めた行間で折り返す。
 */
.next-row > #next,
.next-row > .report-link {
  flex: none;
  white-space: nowrap;
}

.next-row > .buzz-key {
  min-width: 0;
  line-height: 1.3;
}

/*
 * 「次の問題へ」は「押す」と同じ場所に出るので、箱の大きさを「押す」にそろえる。文字の大きさ・
 * 太さ・字間・パディングは .buzzer と同じにし（枠線 1px の分だけパディングを詰める）、文字数が
 * 違っても幅がそろうよう、両方に「次の問題へ」の自然な幅と同じ最小幅を与える。色は枠線だけの
 * .ghost のまま。
 */
.buzz-row > #buzz,
.next-row > #next {
  min-width: 11rem;
}

.next-row > #next {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: calc(0.85rem - 1px) calc(2.6rem - 1px);
}

/*
 * 操作の行（#action-row）。「押す」（#buzz-row）・解答欄（#answer-form）・「次の問題へ」
 * （#next-row）のうち見えている 1 つだけが入る。高さはいちばん大きい「押す」ボタン
 * （.buzzer: 1.05rem × 行間 1.75 + 上下パディング 0.85rem × 2）に固定し、中身を縦の中央に
 * そろえる。高さが変わる判定の欄はこの行の下に置く。これで「押す」と「次の問題へ」の中心が
 * 同じ高さ・同じ左端に来て、
 * カーソルを動かさずに 押す → 答える → 次の問題へ → 押す … と回せる。
 */
.action-row {
  display: flex;
  align-items: center;
  min-height: calc(1.05rem * 1.75 + 1.7rem);
}

.action-row > * {
  flex: 1;
  min-width: 0;
}

/* ---------- 「この判定はおかしい」 ---------- */

/* 「次の問題へ」と同じ行の右端に置く小さなリンク。行の高さは変えない。 */
.report-link {
  margin-left: auto;
  font: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0.2rem 0;
  text-decoration: underline;
  cursor: pointer;
}

.report-link:hover {
  color: var(--ink);
}

.report-link:disabled {
  cursor: default;
  text-decoration: none;
}

/* 判定の枠の下に開く。上の要素（「次の問題へ」・判定）は動かさない。 */
.report-form {
  max-width: 34rem;
  margin-top: 0.9rem;
  padding: 0.8rem 1rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.report-lead {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.report-field {
  display: block;
  margin-bottom: 0.6rem;
}

.report-field > span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.report-status {
  margin: 0.5rem 0 0;
  font-size: 0.86rem;
}

.report-status:empty {
  display: none;
}

/* ボットよけの隠し欄。画面の外に出し、人には見せない（display: none だと埋めないボットがいる）。 */
.report-trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- 成績 ---------- */

.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 1rem;
  margin: 0 0 1.4rem;
}

.scoreboard dt {
  font-size: 0.74rem;
  color: var(--muted);
}

.scoreboard dd {
  margin: 0.1rem 0 0;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.scoreboard .unit {
  font-size: 0.74rem;
  font-weight: normal;
  color: var(--muted);
  margin-left: 0.3rem;
}

.breakdown {
  list-style: none;
  margin: 0 0 1.4rem;
  padding: 0;
  font-size: 0.8rem;
}

.breakdown li {
  display: grid;
  grid-template-columns: 8rem 1fr 2.5rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.15rem 0;
}

.breakdown b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.meter {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--muted);
  border-radius: 2px;
}

.breakdown .correct .meter span {
  background: var(--correct);
}
.breakdown .close .meter span {
  background: var(--close);
}
.breakdown .incorrect .meter span {
  background: var(--incorrect);
}
.breakdown .review .meter span {
  background: var(--review);
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 1.4rem;
}

.records {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
}

.records th,
.records td {
  text-align: left;
  padding: 0.3rem 0.6rem 0.3rem 0;
  border-bottom: 1px solid var(--line);
}

.records th {
  color: var(--muted);
  font-weight: 600;
}

.records .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.verdict-cell.correct {
  color: var(--correct);
}
.verdict-cell.close {
  color: var(--close-ink);
}
.verdict-cell.incorrect {
  color: var(--incorrect);
}
.verdict-cell.review {
  color: var(--review);
}

.by-judge {
  color: var(--muted);
  font-size: 0.7rem;
  margin-left: 0.2rem;
}

.result-actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- 折りたたみ ---------- */

.fold {
  border-top: 1px solid var(--line);
}

.fold > summary {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 1rem 0.2rem;
  cursor: pointer;
  list-style: none;
}

.fold > summary::-webkit-details-marker {
  display: none;
}

.fold > summary::before {
  content: "＋";
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1;
}

.fold[open] > summary::before {
  content: "−";
}

.fold-name {
  font-weight: 700;
  font-size: 1rem;
}

.fold-meta {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: normal;
}

/* いまの設定など、開かなくてもわかる状態は見出しの右端に小さく出す。 */
.fold-state {
  margin-left: auto;
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: normal;
  font-variant-numeric: tabular-nums;
}

.fold-body {
  padding: 0.2rem 0 2rem 1.7rem;
}

.fold-note {
  margin: 1.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.fold-inner {
  border-top: 1px dashed var(--line);
  margin-top: 1.4rem;
}

.fold-inner > summary {
  padding: 0.8rem 0.2rem;
}

.fold-inner .fold-name {
  font-size: 0.9rem;
}

.fold-inner .fold-body {
  padding-bottom: 0.5rem;
}

@media (max-width: 40rem) {
  .fold-body {
    padding-left: 0;
  }
}

/* ---------- 設定 ---------- */

/* 「早押しの設定」「判定の設定」のグループ見出し。 */
.group-head {
  margin: 0.4rem 0 0.2rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.group-note {
  margin: 0 0 1.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.3rem 1.8rem;
  margin-bottom: 1.4rem;
}

.controls-tight {
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

/* 見出しになるラベルだけ。中に入るスイッチや単位のラベルは除く。 */
.control > label:not(.switch):not(.sub-label),
.control-name,
.field > label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.l-en {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: normal;
  color: var(--muted);
  margin-left: 0.45rem;
}

.control-note,
.field-note {
  margin: 0.35rem 0 0;
  font-size: 0.76rem;
  line-height: 1.6;
  color: var(--muted);
}

.control-note:empty,
.field-note:empty {
  display: none;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.with-unit {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.with-unit input {
  width: 5rem;
}

.unit {
  font-size: 0.8rem;
  color: var(--muted);
}

.sub-label {
  font-size: 0.76rem;
  font-weight: normal;
  color: var(--muted);
  margin: 0 0.2rem 0 0;
  white-space: nowrap;
}

.switch {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: normal;
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
  cursor: pointer;
}

.switch input {
  width: auto;
  accent-color: var(--accent);
}

.radios {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.radio {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: normal;
  cursor: pointer;
}

.radio input {
  width: auto;
  accent-color: var(--accent);
}

/* ---------- 判定を試す ---------- */

.try {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

@media (max-width: 52rem) {
  .try {
    grid-template-columns: 1fr;
  }
}

.try-note {
  margin: 0 0 1.2rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.try-head {
  font-size: 0.86rem;
  font-weight: 700;
  margin: 1.6rem 0 0.8rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}

.try-form .try-head:first-of-type {
  margin-top: 0;
}

.field {
  margin-bottom: 1.1rem;
}

.given-row {
  display: flex;
  gap: 0.5rem;
}

.given-row input {
  flex: 1;
}

.mic {
  font: inherit;
  width: 2.6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.mic.listening {
  background: var(--incorrect);
  border-color: var(--incorrect);
}

.switch input:disabled {
  cursor: not-allowed;
}

.switch:has(input:disabled) {
  color: var(--muted);
  cursor: not-allowed;
}

.previous ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: inline;
}

.previous li {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.7rem;
  margin: 0 0.3rem 0.3rem 0;
  font-size: 0.82rem;
  background: var(--bg);
}

.try-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.try-actions select {
  width: auto;
  max-width: 100%;
  margin-left: auto;
  font-size: 0.8rem;
}

.try-panel + .try-panel {
  margin-top: 2rem;
}

/* ---------- 判定結果のカード ---------- */

.result.empty {
  color: var(--muted);
  font-size: 0.86rem;
}

.r-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.r-word {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

.result.correct .r-word {
  color: var(--correct);
}
.result.close .r-word {
  color: var(--close);
}
.result.incorrect .r-word {
  color: var(--incorrect);
}
.result.review .r-word {
  color: var(--review);
}

.r-why {
  margin: 0.1rem 0 0.8rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.badge {
  font-size: 0.74rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.65rem;
  color: var(--muted);
}

.badge.strong {
  border-color: var(--review);
  color: var(--review);
}

.badge.warn {
  background: var(--warn-bg);
  border-color: var(--warn-ink);
  color: var(--warn-ink);
}

.block-name {
  margin: 0 0 0.35rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}

.bars {
  margin-bottom: 0.9rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 3.2rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  margin-bottom: 0.25rem;
}

.bar {
  height: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.bar-row.correct .bar span {
  background: var(--correct);
}
.bar-row.close .bar span {
  background: var(--close);
}
.bar-row.incorrect .bar span {
  background: var(--incorrect);
}
.bar-row.uncertain .bar span {
  background: var(--muted);
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.4rem 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.meta .block-name {
  grid-column: 1 / -1;
  margin: 0;
}

.m-name {
  margin-right: 0.35rem;
}

.meta b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.error-box {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.86rem;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
}

.history li {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.history li:last-child {
  border-bottom: none;
}

.history .empty {
  color: var(--muted);
  border-bottom: none;
}

.h-verdict {
  flex: none;
  width: 4.5rem;
  font-weight: 700;
}

.h-verdict.correct {
  color: var(--correct);
}
.h-verdict.close {
  color: var(--close-ink);
}
.h-verdict.incorrect {
  color: var(--incorrect);
}
.h-verdict.review {
  color: var(--review);
}

.h-given {
  font-weight: 700;
}

.h-question {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.h-time {
  margin-left: auto;
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 開発者向け ---------- */

.dev {
  max-width: 46rem;
}

.dev-head {
  font-size: 0.9rem;
  margin: 1.8rem 0 0.5rem;
}

.dev .dev-head:first-child {
  margin-top: 0;
}

/* 工事中の断り。ほかの説明文と同じ普通の段落にし（線で囲むと引用に見える）、
   見出しより先に置くぶん、最初の見出しとの間だけ少し空ける。 */
.dev-notice {
  margin-bottom: 1.2rem;
}

.dev-note {
  margin: 0 0 0.8rem;
  font-size: 0.86rem;
  color: var(--muted);
}

/* 開発者向けの箇条書き。.dev-note と同じ字の大きさ・色で、行を分けて読ませる。 */
.dev-list {
  margin: 0 0 0.8rem;
  padding-left: 1.3rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.dev-list li {
  margin: 0.3rem 0;
}

.dev-term {
  color: var(--ink);
  font-weight: 700;
}

.code {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.7;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
}

.dev-note code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  color: var(--ink);
}

.code code {
  background: none;
  border: none;
  padding: 0;
}

/* ---------- 足元 ---------- */

footer {
  padding-top: 1.6rem;
  font-size: 0.76rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .caret {
    animation: none;
  }

  .v-word {
    animation: none;
  }
}
