:root {
  color-scheme: light;
  --paper: #f2ebdc;
  --paper-deep: #e6ddc7;
  --card: #faf6ec;
  --ink: #1a1712;
  --ink-soft: #6f6a5b;
  --ink-faint: #a49c87;
  --rule: #d3c8ae;
  --accent: #c1451f;
  --accent-tint: #f0d9c9;
  --moss: #5f7a3c;
  --moss-tint: #dfe6cd;
  --play: #3c6ea5;
  --play-tint: #d9e5f2;
  --shadow-sm: 0 1px 3px rgba(40, 32, 20, 0.10), 0 1px 2px rgba(40, 32, 20, 0.06);
  --shadow-accent: 0 10px 22px rgba(193, 69, 31, 0.32);
  --answer-font-size: 19px; /* 学生が字号を選べる（js/app.jsが変更する）。既定値は元の固定値と同じ */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1812;
    --paper-deep: #242019;
    --card: #211d16;
    --ink: #ece4d3;
    --ink-soft: #b3a891;
    --ink-faint: #766c58;
    --rule: #39332470;
    --accent: #e2794f;
    --accent-tint: #3a2318;
    --moss: #93b56a;
    --moss-tint: #22281a;
    --play: #7fa8d6;
    --play-tint: #24344a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-accent: 0 10px 24px rgba(226, 121, 79, 0.28);
  }
}
:root[data-theme="dark"] {
  --paper: #1b1812;
  --paper-deep: #242019;
  --card: #211d16;
  --ink: #ece4d3;
  --ink-soft: #b3a891;
  --ink-faint: #766c58;
  --rule: #39332470;
  --accent: #e2794f;
  --accent-tint: #3a2318;
  --moss: #93b56a;
  --moss-tint: #22281a;
  --play: #7fa8d6;
  --play-tint: #24344a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-accent: 0 10px 24px rgba(226, 121, 79, 0.28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans SC", "Hiragino Sans", "Yu Gothic", sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.phone {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 24px 32px;
}

/* 練習画面（lesson.html）: 質問カードも回答文もページとして普通にスクロールさせ、
   回答の表示エリアを人為的に圧縮しない（以前は上下を画面に固定して中央だけスクロールさせて
   いたが、固定表示分に食われて回答文の表示エリアが小さくなりすぎ、選択操作がしづらい
   というフィードバックがあったため撤回）。操作ボタン群（語速・聞く/録音/対比・回数）だけを
   `.bottom-bar`で画面下端に貼り付け、スクロールしても常に手が届く場所に残す。
   `position: sticky`ではなく`position: fixed`にしている理由: stickyは「このページの
   コンテナの下端」に貼り付くだけで、スマホの実際に見えている画面（ビューポート）の
   下端とは違う——ブラウザのアドレスバー/ツールバーが出たり引っ込んだりすると、
   stickyのボタンがブラウザ自身のUIに隠れて押せなくなることがある、という指摘を受けて
   修正した。fixedならブラウザの可視ビューポートに対して常に固定されるので、
   スクロール位置やツールバーの開閉に関係なく常に画面の一番下に見える。
   `.phone`は`max-width:440px`で中央寄せなので、`.bottom-bar`も同じ幅で中央に
   揃える（`left:50%; transform:translateX(-50%)`）。中身の高さぶんは`.phone`側に
   `padding-bottom`を足して、最後の行がボタンの下に隠れないようにする
   （実際の高さをJSで測って`app.js`の`syncBottomBarHeight()`が設定する）。 */
.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  background: var(--paper);
  padding: 10px 24px max(14px, env(safe-area-inset-bottom));
  box-shadow: 0 -12px 16px -8px var(--paper);
  z-index: 10;
}
.bottom-bar::before {
  content: "";
  display: block;
  height: 1px;
  background: var(--rule);
  margin-bottom: 12px;
}

.eyebrow {
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 22px;
}

/* ---- the interviewer's question ---- */
.question-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 16px 14px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.question-body { flex: 1; min-width: 0; }
.q-badge {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-badge svg { width: 16px; height: 16px; }
.question-body .who {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.question-body .jp-q {
  font-family: "Noto Serif JP", serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 2.1;
}
.jp-q rt, .answer rt {
  font-size: 0.5em;
  font-weight: 400;
  color: var(--ink-faint);
  user-select: none;
}
.jp-q ruby, .answer ruby { ruby-align: center; }
.jp-q span.current {
  background: var(--play);
  color: var(--paper);
  border-radius: 4px;
  padding: 1px 3px;
  transition: background 0.15s, color 0.15s;
}
.jp-q span.current rt { color: var(--paper); opacity: 0.85; }
.question-body .zh-q {
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 4px;
}

.q-listen-btn {
  flex-shrink: 0;
  align-self: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--paper-deep);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, transform 0.12s;
}
.q-listen-btn:active { transform: scale(0.92); }
.q-listen-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.q-listen-btn svg { width: 16px; height: 16px; }
.q-listen-btn.busy { background: var(--ink); color: var(--paper); }
.q-listen-btn .eq { height: 16px; }

.answer-label {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin-bottom: 10px;
}

.controlled-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--play-tint);
  color: var(--play);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.4;
}
.controlled-link svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ---- collapsible 中文表达逻辑 hint on the main practice screen ---- */
.logic-hint { margin-bottom: 14px; }
.logic-hint.hidden { display: none; }
.logic-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: var(--play-tint);
  color: var(--play);
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.logic-toggle svg { width: 15px; height: 15px; flex-shrink: 0; transition: transform 0.2s; }
.logic-toggle.open svg { transform: rotate(90deg); }
.logic-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease, margin-top 0.25s ease;
}
.logic-body.open { max-height: 300px; margin-top: 8px; }

.answer-card {
  flex: 1;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.answer-wrap { flex: 1; min-height: 0; overflow-y: auto; }

.answer {
  font-family: "Noto Serif JP", serif;
  font-weight: 600;
  font-size: var(--answer-font-size);
  line-height: 2.7;
}
.tok {
  cursor: pointer;
  border-radius: 6px;
  padding: 7px 3px;
  margin: 0 -3px;
  display: inline-block;
  transition: background 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.tok.selected { background: var(--accent-tint); color: var(--ink); }
.tok.anchor { box-shadow: inset 0 0 0 1.5px var(--accent); }
/* 「今読まれている」箇所のハイライト。以前はトークン（読点区切りの1文節、長いと
   数秒かかる）をまるごと塗りつぶしていたが、「文字を隠す・長すぎて不正確に見える」
   というフィードバックを受けて撤回。今はスパン単位（漢字熟語1つ、または平仮名/
   カタカナ1文字——tools/build-lesson.jsが分解し、tools/generate-audio.jsが実測秒数を
   割り当てる）で、塗りつぶさずに色+下線だけで示す。文字が隠れず、より細かく・
   実際の発話に近いタイミングで動く。 */
.sp.current {
  color: var(--play);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--play);
  text-decoration-thickness: 2.5px;
  text-underline-offset: 3px;
  transition: color 0.08s;
}
.sp.current rt { color: var(--play); }

.select-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--rule);
  font-size: 12px;
  color: var(--ink-faint);
  min-height: 18px;
}
.select-status b { color: var(--ink); font-weight: 600; }

.edit-link {
  background: none; border: none; padding: 0;
  font-size: 12px; color: var(--play);
  cursor: pointer; font-family: inherit;
}
.edit-panel { margin-top: 14px; }
.edit-panel.hidden { display: none; }
.edit-textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: "Noto Serif JP", serif;
  font-size: 16px;
  line-height: 1.9;
  color: var(--ink);
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 12px 14px;
  resize: vertical;
}
.edit-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.edit-hint.busy { color: var(--play); }
.edit-spinner {
  display: none;
  width: 12px; height: 12px; flex-shrink: 0;
  border: 2px solid var(--rule);
  border-top-color: var(--play);
  border-radius: 50%;
  animation: edit-spin 0.7s linear infinite;
}
.edit-hint.busy .edit-spinner { display: inline-block; }
@keyframes edit-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .edit-spinner { animation: none; border-top-color: var(--rule); }
}
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.edit-btn {
  border: none; border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.edit-btn.primary { background: var(--accent); color: var(--paper); }
.edit-btn.primary:disabled { opacity: 0.5; cursor: wait; }
.edit-btn.ghost { background: none; color: var(--ink-faint); }

.speed-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.speed-label {
  font-size: 12px;
  color: var(--ink-faint);
  margin-right: 2px;
}
.speed-btn {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  font-variant-numeric: tabular-nums;
}
.speed-btn:active { transform: scale(0.96); }
.speed-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--card);
  font-weight: 600;
}

.caption {
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  min-height: 18px;
  margin: 18px 0 14px;
}

/* ---- transport row: two quiet secondary actions flank one dominant primary action ---- */
.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.t-btn {
  background: none;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  color: var(--ink);
}
.t-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.t-btn .t-label { font-size: 12.5px; font-weight: 500; color: var(--ink-soft); }

.t-circle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--card);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  transition: background 0.25s, color 0.25s, transform 0.15s;
}
.t-btn:active .t-circle { transform: scale(0.94); }

.t-btn.secondary .t-circle { width: 54px; height: 54px; }
.t-btn.secondary .t-circle svg { width: 21px; height: 21px; }
.t-btn.secondary.busy .t-circle { background: var(--ink); color: var(--paper); }
.t-btn.compare.busy .t-circle { background: var(--moss); color: var(--paper); }

.t-btn.primary { padding-top: 4px; }
.t-btn.primary .t-circle {
  width: 84px; height: 84px;
  background: var(--accent);
  color: var(--paper);
  box-shadow: var(--shadow-accent);
}
.t-btn.primary .t-circle svg { width: 30px; height: 30px; }
.t-btn.primary .t-label { font-weight: 600; color: var(--ink); }

.t-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
}
.t-btn.primary.active .t-ring {
  opacity: 0.9;
  animation: ringPulse 1.5s ease-out infinite;
}
@keyframes ringPulse {
  0% { transform: scale(0.94); opacity: 0.85; }
  100% { transform: scale(1.32); opacity: 0; }
}

.rec-timer { display: block; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--ink-faint); margin-top: 2px; }

.tally {
  text-align: center;
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 18px;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .t-btn.primary.active .t-ring { animation: none; }
}

/* ==================================================================
   ホーム / コースロードマップ画面（lesson.html以外の共通ページ）
   ================================================================== */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--ink-faint);
  text-decoration: none;
  margin-bottom: 14px;
}
.back-link svg { width: 14px; height: 14px; }

/* ---- brand bar ---- */
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.logout-link {
  margin-left: auto;
  background: none; border: none; padding: 0;
  font-size: 12px; color: var(--ink-faint);
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer; font-family: inherit;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-family: "Noto Serif JP", serif; font-weight: 700; font-size: 16px;
}
.brand-name { font-family: "Noto Serif JP", serif; font-weight: 700; font-size: 17px; }
.brand-name .kun { color: var(--accent); }

/* ---- 管理者用: 見る/編集する学生を選ぶフォーム（?student=を付けずに来た時だけ出る） ---- */
.admin-picker {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-sm);
  padding: 16px; margin-bottom: 28px;
}
.admin-picker.hidden { display: none; }
.admin-picker-label { font-size: 12.5px; color: var(--ink-faint); margin-bottom: 10px; }
.admin-picker-row { display: flex; gap: 8px; }
.admin-picker-row input {
  flex: 1; min-width: 0;
  font-family: inherit; font-size: 14px;
  padding: 9px 12px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--paper-deep); color: var(--ink);
}
.admin-picker-row button {
  border: none; border-radius: 10px; padding: 9px 16px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  background: var(--accent); color: var(--paper); cursor: pointer;
}
.admin-student-list { display: flex; flex-direction: column; gap: 6px; }
.admin-student-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--paper-deep); text-decoration: none;
}
.admin-student-name { font-size: 13.5px; color: var(--ink); font-weight: 600; }
.admin-student-slug { font-size: 11.5px; color: var(--ink-faint); }
.admin-manage-link {
  flex-shrink: 0; margin-left: auto;
  font-size: 12px; font-weight: 600; color: var(--play);
  background: var(--play-tint); border-radius: 10px; padding: 8px 12px;
  text-decoration: none; white-space: nowrap;
}
.admin-manage-link.hidden { display: none; }

/* ---- 常駐の身分バッジ（.phoneの先頭に流し込む、固定表示ではない） ---- */
.identity-badge {
  font-size: 11px; color: var(--ink-faint);
  background: var(--paper-deep); border-radius: 8px;
  padding: 5px 10px; margin-bottom: 10px;
  display: inline-flex; align-items: center; gap: 10px;
}
.identity-badge.admin { background: var(--play-tint); color: var(--play); font-weight: 600; }
.identity-badge-switch {
  color: inherit; text-decoration: underline; font-weight: 600;
  opacity: .75; white-space: nowrap;
}
.identity-badge-switch:hover { opacity: 1; }

/* ---- 「有新版本」バナー（画面上端に固定、更新を検知した時だけ出る） ---- */
.version-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--accent); color: var(--paper);
  font-size: 12.5px; padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.version-banner button {
  border: none; border-radius: 8px; padding: 4px 12px;
  background: var(--paper); color: var(--accent);
  font-size: 12px; font-weight: 700; font-family: inherit; cursor: pointer;
}

/* ---- admin.html: 文字稿管理の一覧行 ---- */
.admin-lesson-row { background: var(--card); border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden; }
.admin-lesson-toggle {
  width: 100%; text-align: left;
  background: none; border: none; cursor: pointer; font-family: inherit;
  padding: 14px 16px; position: relative;
}
.admin-lesson-toggle .lesson-jp { padding-right: 24px; }
.admin-lesson-chevron {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-faint);
  transition: transform 0.2s;
}
.admin-lesson-toggle.open .admin-lesson-chevron { transform: translateY(-50%) rotate(90deg); }
.admin-lesson-row .edit-panel { padding: 0 16px 16px; }
.admin-lesson-row .edit-panel.hidden { display: none; }

/* ---- profile HP ---- */
.profile {
  display: flex; align-items: center; gap: 16px;
  padding: 20px; margin-bottom: 28px;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow-sm);
}
.profile.hidden { display: none; }
.avatar {
  flex-shrink: 0; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: "Noto Serif JP", serif; font-weight: 700; font-size: 22px;
}
.profile-body { min-width: 0; flex: 1; }
.profile-name { font-family: "Noto Serif JP", serif; font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.profile-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11.5px; color: var(--ink-soft); background: var(--paper-deep); padding: 3px 9px; border-radius: 999px; }

/* ---- section label ---- */
.section-label { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; color: var(--ink-faint); margin-bottom: 12px; }
.section-label.hidden { display: none; }

/* ---- course cards (home) ---- */
.courses { display: flex; flex-direction: column; gap: 12px; margin-bottom: 30px; }
.course-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border-radius: 16px;
  background: var(--card); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: transform .12s ease;
  text-decoration: none; color: inherit;
}
.course-card:active { transform: scale(0.98); }
.course-card.active { box-shadow: var(--shadow-accent); }
.course-card.soon { opacity: 0.55; cursor: default; box-shadow: none; }
.course-card.soon:active { transform: none; }
.course-icon {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--paper);
}
.course-card.soon .course-icon { background: var(--paper-deep); color: var(--ink-faint); }
.course-icon svg { width: 20px; height: 20px; }
.course-body { flex: 1; min-width: 0; }
.course-title { font-family: "Noto Serif JP", serif; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.course-title .zh { font-family: "Noto Sans SC", sans-serif; font-weight: 600; font-size: 15px; }
.course-desc { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; line-height: 1.5; }
.course-progress { font-size: 11.5px; color: var(--moss); margin-top: 6px; font-weight: 500; }
.soon-badge { flex-shrink: 0; font-size: 11px; color: var(--ink-faint); background: var(--paper-deep); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chevron { flex-shrink: 0; color: var(--ink-faint); }
.chevron svg { width: 16px; height: 16px; }

/* ---- course header (roadmap page) ---- */
.course-header { padding-bottom: 22px; margin-bottom: 26px; border-bottom: 1px solid var(--rule); }
.course-page-title { font-family: "Noto Serif JP", serif; font-weight: 700; font-size: 25px; line-height: 1.4; text-wrap: balance; margin-bottom: 6px; }
.course-sub { font-size: 13px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 18px; }
.progress-row { display: flex; align-items: center; gap: 12px; }
.progress-track { flex: 1; height: 6px; border-radius: 3px; background: var(--paper-deep); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--moss); }
.progress-label { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress-label b { color: var(--ink); font-weight: 600; }

/* ---- the path (roadmap page) ---- */
.path { position: relative; }
.stage { position: relative; display: flex; gap: 16px; padding-bottom: 22px; }
.stage:last-child { padding-bottom: 0; }
.stage-rail { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; width: 40px; }
.node {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--card); box-shadow: var(--shadow-sm); color: var(--ink-faint); z-index: 1;
}
.node svg { width: 18px; height: 18px; }
.connector { width: 2px; flex: 1; margin-top: 4px; background: var(--rule); border-radius: 1px; min-height: 24px; }
.stage.available .node { background: var(--accent); color: var(--paper); box-shadow: var(--shadow-accent); }
.stage.practiced .node { background: var(--moss); color: var(--paper); box-shadow: none; }
.stage.practiced .connector { background: var(--moss); }

.stage-card {
  flex: 1; background: var(--card); border-radius: 14px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .12s ease, box-shadow .2s ease;
  min-width: 0; text-decoration: none; color: inherit; display: block;
}
.stage-card:active { transform: scale(0.98); }
.stage.available .stage-card { box-shadow: var(--shadow-accent); }
.stage.practiced .stage-card { box-shadow: var(--shadow-sm); }
.stage.soon .stage-card { box-shadow: none; background: transparent; cursor: default; }
.stage.soon .stage-card:active { transform: none; }

.stage-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.stage-title { font-family: "Noto Serif JP", serif; font-weight: 700; font-size: 17px; }
.stage.soon .stage-title { color: var(--ink-soft); font-weight: 600; }
.stage-badge { flex-shrink: 0; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.stage-badge.available { background: var(--accent-tint); color: var(--accent); }
.stage-badge.practiced { background: var(--moss-tint); color: var(--moss); }
.stage-badge.soon { background: var(--paper-deep); color: var(--ink-faint); }
.stage-zh { font-size: 12px; color: var(--ink-faint); margin-bottom: 6px; }
.stage-desc { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; }
.stage.soon .stage-desc { color: var(--ink-faint); }
.enter-cue { margin-top: 10px; display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--accent); font-weight: 600; }
.enter-cue.practiced { color: var(--moss); }
.enter-cue svg { width: 13px; height: 13px; }

/* ---- 章節内の質問一覧（stage-lessons.html） ---- */
.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-card {
  background: var(--card); border-radius: 14px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; display: block;
  transition: transform .12s ease;
}
.lesson-card:active { transform: scale(0.98); }
.lesson-card.practiced { box-shadow: var(--shadow-sm); }
.lesson-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.lesson-jp { font-family: "Noto Serif JP", serif; font-weight: 600; font-size: 15px; line-height: 1.5; }
.lesson-badge { flex-shrink: 0; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.lesson-badge.available { background: var(--accent-tint); color: var(--accent); }
.lesson-badge.practiced { background: var(--moss-tint); color: var(--moss); }
.lesson-zh { font-size: 12px; color: var(--ink-faint); }

/* ---- 受控影子跟读（controlled.html）----
   lesson.htmlの.tok/.answerとは別の画面・別のクラス名にして、練習画面の
   スタイルに影響しないようにしている（.jp-text配下にだけ.spのスタイルを効かせる）。 */
.steps { display: flex; align-items: center; gap: 4px; margin-bottom: 18px; }
.step-dot { flex: 1; height: 4px; border-radius: 2px; background: var(--rule); }
.step-dot.done { background: var(--moss); }
.step-dot.active { background: var(--accent); }

.stage-label { font-size: 12px; letter-spacing: .06em; color: var(--ink-faint); text-align: center; margin-bottom: 4px; }
.stage-title { font-family: "Noto Serif JP", serif; font-weight: 700; font-size: 20px; text-align: center; margin-bottom: 18px; }

.q-card {
  display: flex; align-items: center; gap: 12px; padding: 14px 15px;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.q-badge {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.q-badge svg { width: 15px; height: 15px; }
.q-jp { font-family: "Noto Serif JP", serif; font-weight: 600; font-size: 15px; line-height: 1.6; }
.q-jp rt { font-size: .55em; font-weight: 400; color: var(--ink-faint); }

.card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow-sm); padding: 18px; margin-bottom: 14px; }
.card-label { font-size: 12px; color: var(--ink-faint); margin-bottom: 8px; }

.jp-text { font-family: "Noto Serif JP", serif; font-weight: 600; font-size: 18px; line-height: 2.6; }
.jp-text rt { font-size: .5em; font-weight: 400; color: var(--ink-faint); user-select: none; }
.jp-text .sp { cursor: default; border-radius: 6px; padding: 5px 2px; margin: 0 -2px; display: inline-block; transition: background .15s, color .15s, visibility 0s; }
.jp-text .sp[data-i] { cursor: pointer; }
.jp-text .sp.anchor { background: var(--accent); color: var(--paper); font-weight: 700; box-shadow: 0 2px 6px rgba(193, 69, 31, .35); }
.jp-text .sp.anchor rt { color: var(--paper); }
.jp-text .sp.sp-hidden { visibility: hidden; }

.logic-card { background: var(--play-tint); border-radius: 14px; padding: 14px 16px; font-size: 13.5px; line-height: 1.75; color: var(--ink); }
.logic-card b { color: var(--play); }

.anchor-count { font-size: 12.5px; color: var(--ink-soft); text-align: center; margin: 10px 0 4px; }
.anchor-count b { color: var(--accent); }

.toggle-row { display: flex; justify-content: center; margin: 14px 0 4px; }
.toggle-btn {
  display: flex; align-items: center; gap: 8px; background: var(--card);
  border: 1.5px solid var(--rule); border-radius: 999px; padding: 9px 18px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.toggle-btn.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.toggle-btn svg { width: 15px; height: 15px; }

.center-empty { text-align: center; color: var(--ink-faint); font-size: 13px; padding: 10px 10px 4px; }

.next-bar { margin-top: 18px; }
.next-btn {
  width: 100%; background: var(--accent); color: var(--paper); border: none; border-radius: 14px;
  padding: 15px; font-size: 15px; font-weight: 700; box-shadow: var(--shadow-accent); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.next-btn.ghost { background: var(--moss); box-shadow: none; }
.next-btn:disabled { background: var(--rule); color: var(--ink-faint); box-shadow: none; cursor: not-allowed; }
.next-btn svg { width: 16px; height: 16px; }
.back-mini { text-align: center; font-size: 12px; color: var(--ink-faint); margin-top: 10px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.done-card { text-align: center; padding: 22px 10px 8px; }
.done-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--moss-tint); color: var(--moss); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.done-icon svg { width: 26px; height: 26px; }
.done-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.done-sub { font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
