:root {
  /* 青みのある淡い地に白いカード、明るい青のアクセント（Zenn の雰囲気を参考にした配色）。 */
  --bg: #edf2f7;
  --surface: #ffffff;
  --text: #24292f;
  --muted: #65717b;
  --border: #d6e3ed;
  --accent: #0c74dd;       /* リンクや文字に使う青 */
  --primary: #0f83fd;      /* ボタンや印の塗りに使う青 */
  --accent-soft: #e0efff;
  --ok: #1a7f37;
  --ok-soft: #e3f5e8;
  --code-bg: #e4ecf4;
  --terminal: #1a2638;
  --card-shadow: 0 2px 4px rgba(33, 37, 58, 0.06);
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --commit: #8a5a00;
  --commit-soft: #fbf0d6;
  /* スクロールバーなどブラウザの部品も、明るい・暗い配色に合わせる。 */
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --card-shadow: none;
    --bg: #0d1420;
    --surface: #17202e;
    --text: #e4e9ef;
    --muted: #96a3b3;
    --border: #2a3648;
    --accent: #6cb8ff;
    --primary: #3ea8ff;
    --accent-soft: #162c47;
    --ok: #56c271;
    --ok-soft: #173021;
    --code-bg: #222e40;
    --bad: #ff938a;
    --bad-soft: #3a1d1b;
    --commit: #e3b341;
    --commit-soft: #33290f;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.8 -apple-system, "system-ui", "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
}
code, pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
}
code { background: var(--code-bg); border-radius: 4px; padding: 0.1em 0.35em; }
h1, h2 { line-height: 1.35; margin: 0; }

.site-header { padding: 14px 24px 6px; background: var(--surface); }
.site-header h1 { font-size: 1.25rem; letter-spacing: 0.01em; }

/* 問題の一覧：番号だけを横に並べた細い帯。スクロールしても上に残る。 */
.quiz-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
/* 狭い画面でも折り返さず1行に保ち、入りきらない分は横にスクロールする。 */
.quiz-nav-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  max-width: 2200px;
  margin: 0 auto;
  padding: 6px 24px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.quiz-nav-inner::-webkit-scrollbar { display: none; }
.quiz-nav-inner > * { flex: none; }
.quiz-nav-label { font-size: 0.85rem; font-weight: 700; }
.progress { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.quiz-list { display: flex; flex-wrap: nowrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.quiz-item {
  position: relative;
  display: block;
  padding: 2px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.quiz-item:disabled { cursor: default; }
body:not(.ready) .quiz-item { opacity: 0.55; cursor: progress; }
body.preparing .quiz-item, body.preparing .onboarding-start { cursor: progress; }
/* 準備中は、まだ前の問題のままの問題文を薄くする */
.panel-body { transition: opacity 0.15s; }
body.preparing .panel-body { opacity: 0.45; }
/* 準備中の問題の番号のまわりを、輪が回る */
.quiz-item.preparing::after {
  content: "";
  position: absolute;
  /* 選択中の番号は青い縁取りがあるので、その外側を回す */
  inset: -3px;
  border: 2px solid transparent;
  border-top-color: var(--primary);
  border-right-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.mark {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.8rem;
  line-height: 26px;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.quiz-item:hover .mark { border-color: var(--accent); color: var(--accent); }
.quiz-item[aria-current="true"] .mark { border-color: var(--primary); background: var(--accent-soft); color: var(--accent); font-weight: 700; box-shadow: 0 0 0 2px var(--primary); }
.cleared .mark, .cleared:hover .mark { background: var(--ok); border-color: var(--ok); color: var(--surface); font-weight: 700; }
.link-button {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}

.main { max-width: 2200px; margin: 0 auto; padding: 20px 24px 48px; }

/* 問題文は枠で囲まず、ページの地にそのまま置く。 */
/* 左右の余白は置かない。会話の枠の左右の端を、下のターミナルの窓とそろえるため。 */
.panel { padding: 8px 0 4px; }
.panel h2 { font-size: 1.45rem; letter-spacing: 0.01em; }
/* 問題のタイトルの右に、チャット通知と状況設定をたたむボタンを置く。読み終えたあと、ターミナルを上に寄せられるようにするため。 */
.panel-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; }
/* 何をするボタンかが分かるよう、記号だけにせず、向きを示す三角と文で書く。 */
.panel-toggle {
  padding: 3px 14px;
  border: 1px solid var(--border);
  border-radius: 99rem;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.panel-toggle:hover { border-color: var(--accent); background: var(--accent-soft); }
.panel:not(.started) .panel-toggle { display: none; }
/* 導入のあいだは見せないが、場所は取っておく。あとから出すと行の高さが変わり、下の会話が動くため。 */
body.intro .panel-toggle { visibility: hidden; }
/* たたんでいるあいだは、症状の1文とヒント、最初に試すコマンドだけを残す。 */
.panel.folded .panel-chat-col, .panel.folded .situation, .panel.folded .situation-heading { display: none; }
.panel-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 40px; }
.panel-heading { margin: 16px 0 0; color: var(--muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; }
.panel:not(.started) .panel-heading { display: none; }
/* 会話の幅は、下のターミナルの窓の幅（--terminal-width。main.js が測って入れる）にそろえる。 */
.panel-chat-col { min-width: 0; max-width: var(--terminal-width, none); }
.panel p { margin: 6px 0 0; }

/* ---- 問題を選ぶ前の画面（使い方） ---- */
.panel.started .onboarding { display: none; }
.panel:not(.started) .panel-body { display: none; }
/* 文の途中で折り返さないよう、区切りごとにまとめて折り返す。 */
.onboarding-lead span { display: inline-block; }
.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}
.onboarding-steps li {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}
.step-mark {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  line-height: 26px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.panel .onboarding-steps p { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
.onboarding-tips { margin: 14px 0 0; padding-left: 20px; color: var(--muted); font-size: 0.9rem; }
.onboarding-tips li { margin: 3px 0; }
.onboarding-tips strong { color: var(--text); }
.onboarding-start {
  margin-top: 14px;
  padding: 9px 28px;
  border: 0;
  border-radius: 99rem;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.onboarding-start:hover:not(:disabled) { filter: brightness(0.93); }
.onboarding-start:disabled { opacity: 0.55; cursor: default; }
.onboarding-start.busy:disabled { opacity: 0.85; cursor: progress; }
/* 読み込み中の印：文の前で回る輪 */
@keyframes spin { to { transform: rotate(360deg); } }
.onboarding-start.busy::before, .status.busy::before {
  content: "";
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  margin-right: 0.6em;
  vertical-align: -0.15em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .onboarding-start.busy::before, .status.busy::before, .quiz-item.preparing::after { animation-duration: 2.4s; }
}
.first { margin-top: 12px; }

/* ---- 問題が起きた場面の会話 ---- */
/* Slack の標準の見た目（白地、太字の名前、灰色の時刻、赤いコード）に寄せる。 */
.chat {
  --chat-bg: #ffffff;
  --chat-text: #1d1c1d;
  --chat-muted: #616061;
  --chat-line: rgba(29, 28, 29, 0.13);
  --chat-hover: #f8f8f8;
  --chat-code: #e01e5a;
  --chat-code-bg: rgba(29, 28, 29, 0.04);
  margin-top: 8px;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  background: var(--chat-bg);
  color: var(--chat-text);
  font-family: Lato, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  .chat {
    --chat-bg: #1a1d21;
    --chat-text: #d1d2d3;
    --chat-muted: #ababad;
    --chat-line: rgba(232, 232, 232, 0.13);
    --chat-hover: #222529;
    --chat-code: #e8912d;
    --chat-code-bg: rgba(232, 232, 232, 0.04);
  }
}
.chat[hidden] { display: none; }
.chat-channel {
  padding: 8px 16px;
  border-bottom: 1px solid var(--chat-line);
  font-size: 0.95rem;
  font-weight: 700;
}
.chat-messages { list-style: none; margin: 0; padding: 8px 0; font-size: 0.9375rem; }
.chat-message { display: flex; gap: 8px; padding: 4px 16px; }
.chat-message:hover { background: var(--chat-hover); }
.chat-avatar {
  flex: none;
  width: 36px;
  height: 36px;
  margin-top: 3px;
  border-radius: 6px;
  background: #2bac76;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 36px;
  text-align: center;
}
.senpai .chat-avatar { background: #1264a3; }
.chat-head { display: flex; align-items: baseline; gap: 8px; line-height: 1.4; }
.chat-head strong { font-weight: 700; }
.chat-time { color: var(--chat-muted); font-size: 0.75rem; }
/* 同じ人の続けての発言は、アイコンと名前を省き、時刻だけを左の余白に出す（マウスを載せたとき）。 */
.chat-message.continued { padding-top: 2px; }
.chat-gutter { flex: none; width: 36px; color: var(--chat-muted); font-size: 0.7rem; line-height: 1.47rem; text-align: right; visibility: hidden; }
.chat-message:hover .chat-gutter { visibility: visible; }
.panel .chat-message p { margin: 0; line-height: 1.47; }
.chat code {
  padding: 2px 3px 1px;
  border: 1px solid var(--chat-line);
  border-radius: 3px;
  background: var(--chat-code-bg);
  color: var(--chat-code);
  font-size: 0.8rem;
}

/* ---- 問題を始めた直後の導入 ---- */
/* VM の準備を待つあいだ（body.intro）は、問題文の会話だけをその場に見せ、ほかは場所を取ったまま隠す。
   準備が済んだら、会話を動かさずに、残りを浮かび上がらせる。 */
.panel-text, .workspace { transition: opacity 0.5s ease-out; }
body.intro .panel-text, body.intro .workspace { opacity: 0; visibility: hidden; transition: none; }
.chat-message[hidden] { display: none; }
/* 通知が届いたことが分かるよう、発言を下から浮かび上がらせる。 */
@keyframes notify-in { from { opacity: 0; transform: translateY(8px); } }
.chat-message.arriving { animation: notify-in 0.3s ease-out; }
/* 見出しの行は高さを決めておき、準備中の印やボタンを出し入れしても、下の会話の位置が動かないようにする。 */
.panel-chat-col .panel-heading { display: flex; align-items: center; height: 1.5rem; }
/* 導入のあいだ、まだ続きがあることを会話の欄の中で示す。
   先輩の返信が届くまでは「入力中」の印を出し、欄の下端の帯が、残りが表示されるまでの時間を左から右へ進む。 */
.chat { position: relative; }
.chat-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  /* 発言の文の左端（余白16 + アイコン36 + 間隔8）にそろえる。 */
  padding: 2px 16px 12px 60px;
  color: var(--chat-muted);
  font-size: 0.8rem;
}
.chat-typing[hidden], body:not(.intro) .chat-typing { display: none; }
.chat-typing-dots { display: inline-flex; gap: 3px; }
.chat-typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: typing 1.2s ease-in-out infinite; }
.chat-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
/* 帯は欄の下端に重ねて置き、出し入れしても欄の高さを変えない。進み具合は main.js が動かす。 */
.chat-progress {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--primary);
  transform-origin: left;
  transform: scaleX(0);
}
body.intro .chat-progress { display: block; }
@media (prefers-reduced-motion: reduce) {
  .chat-typing-dots i { animation: none; opacity: 0.6; }
}
/* 準備中の印は見出しの行の右に出す。出していないあいだも場所は取っておき、行の高さ（会話の位置）を変えない。 */
.chat-loading { display: inline-flex; align-items: center; margin-left: 14px; font-weight: 400; letter-spacing: 0; visibility: hidden; }
body.intro .chat-loading { visibility: visible; }
/* VM の準備が済んだら、準備中の印を、待たずに進むボタンに替える。どちらも同じ行に収め、行の高さを変えない。 */
body.intro.intro-ready .chat-loading { display: none; }
.intro-skip {
  display: none;
  margin-left: 14px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 400;
  letter-spacing: 0;
  line-height: inherit;
  text-decoration: underline;
  cursor: pointer;
}
body.intro.intro-ready .intro-skip { display: inline; }
.chat-loading::before {
  content: "";
  flex: none;
  width: 1em;
  height: 1em;
  margin-right: 0.5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
/* 問題文を先に出しているあいだ（導入と、クリア済みの問題を開いたとき）は、準備中でも問題文を薄くしない。 */
body.preparing.intro .panel-body, body.preparing.panel-early .panel-body { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .panel-text, .workspace { transition: none; }
  .chat-message.arriving { animation: none; }
  .chat-loading::before { animation-duration: 2.4s; }
}

.panel .situation { margin-top: 6px; }
/* 状況設定と会話は文ごとに行を分ける。状況設定は、幅のある画面でも1行が長くなりすぎないよう、行の長さに上限を置く。 */
/* 折り返すときは文節の切れ目で折り、最後の行に数文字だけ残るのを避ける（対応しているブラウザのみ）。 */
.situation span, .chat-message p span { display: block; word-break: auto-phrase; text-wrap: pretty; }
#panel-symptom { word-break: auto-phrase; text-wrap: pretty; }
.situation, #panel-symptom { max-width: 44em; }
.situation[hidden] { display: none; }
.hints { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hints:empty { display: none; }
.hints details {
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
  padding: 5px 14px;
  font-size: 0.9rem;
}
.hints details[open] { flex-basis: 100%; border-radius: 14px; padding: 10px 16px; }
.hints summary { cursor: pointer; color: var(--accent); }
.hints a { color: var(--accent); text-underline-offset: 2px; }
.hints pre {
  margin: 8px 0 4px;
  padding: 8px 10px;
  background: var(--code-bg);
  border-radius: 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- クリア済みの問題で、解説を読み返すボタン ---- */
.explain-open {
  margin-top: 12px;
  padding: 5px 16px;
  border: 1px solid var(--ok);
  border-radius: 99rem;
  background: var(--ok-soft);
  color: var(--ok);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.explain-open[hidden] { display: none; }

/* ---- ゴールしたときのダイアログ（ゴールの知らせ・解説・次の問題へ） ---- */
.goal-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.goal-dialog[open] { display: flex; flex-direction: column; }
.goal-dialog::backdrop { background: rgba(10, 13, 18, 0.6); }
.goal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--ok-soft);
  border-bottom: 1px solid var(--ok);
  color: var(--ok);
}
.goal-head h2 { margin: 0; font-size: 1.15rem; outline: none; }
.goal-badge {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ok);
  color: var(--surface);
  font-weight: 700;
  line-height: 32px;
  text-align: center;
}
.goal-body { flex: 1; min-height: 0; padding: 14px 20px 6px; overflow-y: auto; }
.goal-body h3 {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.goal-body h3:first-child { margin-top: 0; }
.goal-body a { color: var(--accent); text-underline-offset: 2px; }
.goal-body a code { color: inherit; }
/* 要点：原因・直し方・覚えておくこと */
.explain-points {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  line-height: 1.7;
}
.explain-points dt { color: var(--accent); font-weight: 700; white-space: nowrap; }
.explain-points dd { margin: 0; }
/* 図：.git の中のつながりと、原因の場所、直すときに使う関係 */
.explain-map { margin: 0; }
.explain-map-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.recovery-map { display: block; width: 100%; min-width: 600px; height: auto; font-family: inherit; }
.explain-map figcaption { margin-top: 8px; padding-left: 12px; border-left: 4px solid var(--bad); line-height: 1.75; font-size: 0.95rem; }
.map-group { fill: var(--bg); stroke: var(--border); }
.map-g { font-size: 11.5px; font-weight: 700; fill: var(--muted); }
.map-box { fill: var(--surface); stroke: var(--muted); stroke-width: 1.2; }
.map-broken { fill: var(--bad-soft); stroke: var(--bad); stroke-width: 2.4; }
.map-t { font-size: 13px; font-weight: 700; fill: var(--text); }
.map-s { font-size: 11px; fill: var(--muted); }
.map-tag { fill: var(--bad); }
.map-tag-text { font-size: 10.5px; font-weight: 700; fill: var(--surface); }
.map-arrow line { fill: none; }
.map-ref line { stroke: var(--muted); stroke-width: 1.5; }
.map-ref polygon { fill: var(--muted); }
.map-fix line { stroke: var(--accent); stroke-width: 1.8; stroke-dasharray: 6 4; }
.map-fix polygon { fill: var(--accent); }
.map-key line { stroke: var(--bad); stroke-width: 3; }
.map-key polygon { fill: var(--bad); }
.map-dim { opacity: 0.35; }
.map-label { font-size: 11.5px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.map-label-ref { fill: var(--muted); }
.map-label-key { fill: var(--bad); font-weight: 700; }
/* くわしい説明：見出しで何の話かを先に示す */
.explain-details section + section { margin-top: 12px; }
.explain-details h4 { margin: 0; font-size: 0.95rem; }
.explain-details p { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.75; }
.explain-details p code, .explain-details p a { color: var(--text); }
.explain-details p a { color: var(--accent); }
.explain-refs { margin: 0 0 10px; padding-left: 20px; font-size: 0.9rem; line-height: 1.8; }
@media (max-width: 560px) {
  .explain-points { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .explain-points dd + dt { margin-top: 8px; }
}
.goal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}
.goal-actions button {
  padding: 8px 22px;
  border-radius: 99rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.goal-actions button[hidden] { display: none; }
.goal-close { border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.goal-next { border: 1px solid var(--primary); background: var(--primary); color: #fff; }

/* ターミナルと.git エクスプローラー。幅があれば横に並べる。 */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 18px; }
.terminal-col { min-width: 0; }
.terminal-window {
  /* 窓は中身（文字の桁数）の幅にし、右に余白を引き伸ばさない。画面が狭いときは画面の幅まで。 */
  width: fit-content;
  max-width: 100%;
  border: 1px solid #101826;
  border-radius: 14px;
  background: var(--terminal);
  box-shadow: 0 8px 24px rgba(26, 38, 56, 0.2);
  overflow: hidden;
}
.terminal-bar {
  position: relative;
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  background: #26354d;
  border-bottom: 1px solid #142033;
}
.terminal-dots { display: flex; gap: 7px; }
.terminal-dots i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; }
.terminal-dots i:nth-child(2) { background: #febc2e; }
.terminal-dots i:nth-child(3) { background: #28c840; }
.terminal-title {
  position: absolute;
  left: 0;
  right: 0;
  color: #aab2bf;
  font: 0.78rem ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-align: center;
  pointer-events: none;
}
/* Esc キーをブラウザや拡張機能に取られる環境のために、クリックで Esc を送るボタンを置く。 */
.terminal-key {
  position: relative;
  margin-left: auto;
  padding: 1px 10px;
  border: 1px solid #4a5b77;
  border-radius: 5px;
  background: #33435e;
  color: #e4e9ef;
  font: 0.75rem ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  cursor: pointer;
}
.terminal-key:hover { background: #40526f; }
.terminal-key:focus-visible { outline: 2px solid #8fc0ff; outline-offset: 1px; }
.terminal-frame {
  position: relative;
  padding: 8px 10px 10px;
  background: var(--terminal);
  overflow-x: auto;
}
.status {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  /* ターミナルは縦に長く、中央だと画面の外に出やすいので、上寄せで表示する */
  align-items: flex-start;
  justify-content: center;
  padding: 96px 16px 0;
  text-align: center;
  background: var(--terminal);
  color: #c9d1d9;
}
.status[hidden] { display: none; }
/* ターミナルの中身（xterm）はスクリプトの読み込みが済んでから描かれる。それまで窓が潰れて見えないよう、
   同じ大きさ（110桁 × 34行）を先に確保しておく。桁数・行数・フォントは main.js の ROWS、COLS、Terminal の指定と揃えること。 */
#terminal {
  font: 14px ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans Mono CJK JP", "MS Gothic", monospace;
  min-width: 110ch;
  min-height: calc(34 * 16px);
}
.status.error { color: #ff938a; }
.note { margin: 8px 2px 0; color: var(--muted); font-size: 0.85rem; }

/* ---- .git エクスプローラー ---- */
.explorer {
  container-type: inline-size;
  min-width: 0;
  /* ターミナルの下に置くときは、ターミナルの窓と同じ幅にする。 */
  max-width: var(--terminal-width, none);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px 16px;
}
/* たたんでいるあいだは枠を出さず、＋ボタンと見出しだけにする。 */
/* 左の余白は置かず、＋ボタンの左端を、上の状況設定やターミナルの窓の左端にそろえる。 */
.explorer.collapsed { background: none; border-color: transparent; padding: 4px 0; }
.explorer-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.explorer-actions { margin-left: auto; }
.explorer-toggle {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font: 700 1.1rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  cursor: pointer;
}
.explorer-toggle:hover { border-color: var(--accent); background: var(--accent-soft); }
.explorer-head h2 { font-size: 1.05rem; }
.explorer-root { margin-left: 6px; color: var(--muted); font: 0.85rem ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.explorer-actions { display: flex; gap: 8px; }
.explorer-actions button {
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.explorer-actions button:hover:not(:disabled) { background: var(--code-bg); }
.explorer-actions button:disabled { opacity: 0.45; cursor: default; }
.explorer-closed-note { display: none; margin: 6px 0 0; color: var(--muted); font-size: 0.85rem; }
.explorer.collapsed .explorer-closed-note { display: block; }
.explorer.collapsed .explorer-content, .explorer.collapsed .explorer-nav, .explorer.collapsed .explorer-root { display: none; }
.explorer-lead { margin: 4px 0 10px; color: var(--muted); font-size: 0.85rem; }
.explorer-body { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 12px; }
.explorer-tree, .explorer-detail {
  height: 432px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.explorer-tree:empty { display: none; }
.explorer-tree:empty + .explorer-detail { grid-column: 1 / -1; height: auto; }
.explorer-detail { padding: 12px 16px; font-size: 0.9rem; }
/* 参照元に戻るボタン。スクロールしても上端に残る。 */
.explorer-return {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: -12px -16px 10px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
  font-size: 0.85rem;
}
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; }

.tree { list-style: none; margin: 0; padding: 6px 0; }
.tree-item {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 2px 8px;
  border: 0;
  background: none;
  color: inherit;
  font: 0.82rem/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.tree-item:hover { background: var(--code-bg); }
.tree-item.current { background: var(--accent-soft); }
.tree-item.dir { color: var(--muted); }
.twist { flex: none; width: 12px; font-size: 0.7rem; }
.tree-item .name { overflow: hidden; text-overflow: ellipsis; }

.badge {
  flex: none;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--code-bg);
  color: var(--muted);
  font: 0.72rem/1.6 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  white-space: nowrap;
}
.badge.commit { background: var(--commit-soft); color: var(--commit); }
.badge.tree { background: var(--ok-soft); color: var(--ok); }
.badge.blob { background: var(--accent-soft); color: var(--accent); }
.badge.bad { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.badge.new { background: var(--commit-soft); color: var(--commit); }

.x-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.x-link.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; }
.object-link { white-space: nowrap; }

.explorer-detail h3 { margin: 0 0 6px; font-size: 0.98rem; overflow-wrap: anywhere; }
.explorer-detail h3 .badge { margin-left: 0; font-size: 0.78rem; }
.explorer-detail h4 { margin: 16px 0 4px; font-size: 0.9rem; }
.explorer-detail p { margin: 6px 0; }
.explorer-detail .about, .explorer-detail .hint, .explorer-detail .empty { color: var(--muted); }
.explorer-detail .hint { font-size: 0.82rem; }
.explorer-detail .warn { color: var(--bad); font-weight: 600; }
.explorer-detail .command { margin: 2px 0 10px; color: var(--muted); font-size: 0.85rem; }
/* コマンドをコピーするボタン（copy.js）。.git エクスプローラーと「最初に試すコマンド」で使う。
   目立たせないよう、枠のない小さなアイコンにし、マウスを載せたときだけ色を付ける。 */
.copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 4px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  vertical-align: middle;
  cursor: pointer;
}
.copy:hover { background: var(--code-bg); color: var(--accent); }
.copy.done { color: var(--ok); }
.copy.failed { color: var(--bad); }
.explorer-detail pre {
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--code-bg);
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.explorer-detail pre.dump { white-space: pre; overflow-wrap: normal; }
.explorer-detail table { border-collapse: collapse; margin: 8px 0; }
.explorer-detail th, .explorer-detail td { padding: 3px 14px 3px 0; text-align: left; vertical-align: top; }
.explorer-detail th { color: var(--muted); font-size: 0.8rem; font-weight: 600; border-bottom: 1px solid var(--border); }
.explorer-detail dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 10px 0; }
.explorer-detail dt { color: var(--muted); }
.explorer-detail dd { margin: 0; overflow-wrap: anywhere; }
.explorer-detail dd pre { margin: 0; }
.explorer-detail ul.plain { margin: 4px 0; padding-left: 20px; }
.chain, .chain ul { list-style: none; margin: 0; padding: 0; }
.chain ul { margin-left: 8px; padding-left: 14px; border-left: 1px solid var(--border); }
.chain li { padding: 2px 0; }

/* .git エクスプローラーの幅が狭いときは、一覧を上、中身を下に積む。 */
@container (max-width: 580px) {
  .explorer-body { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .explorer-tree { height: 150px; }
  .explorer-detail { height: 272px; }
}

@media (min-width: 1480px) {
  /* 幅があるときは、会話を左、状況設定を右に置く。先に読む会話を、読み始めの位置に置くため。
     左の列はターミナルの窓と同じ幅にして、下のターミナルと左右の端をそろえる。 */
  .panel.started .panel-body { grid-template-columns: var(--terminal-width, minmax(0, 1fr)) minmax(0, 1fr); column-gap: 24px; align-items: start; }
  /* 列の間隔は上の問題文と同じにして、.git エクスプローラーの左端を状況設定の左端にそろえる。 */
  .workspace { grid-template-columns: max-content minmax(0, 1fr); column-gap: 24px; align-items: start; }
  /* 横に並べるときは、.git エクスプローラーの高さをターミナルの窓に合わせる。
     ターミナルの下の注記は2行目に送り、1行目にターミナルの窓とエクスプローラーだけを置く。 */
  .terminal-col { display: contents; }
  .terminal-window { grid-column: 1; grid-row: 1; }
  /* 注記の文の長さで左の列が広がらないよう、列の幅の計算には入れず、決まった列の幅いっぱいに置く。 */
  .terminal-col .note { grid-column: 1; grid-row: 2; margin-top: -8px; width: 0; min-width: 100%; }
  .explorer { grid-column: 2; grid-row: 1; max-width: none; }
  /* contain: size で中身の高さを行の高さに影響させず、ターミナルの高さに引き伸ばす。中身は欄の中でスクロールする。 */
  .explorer:not(.collapsed) { align-self: stretch; contain: size; display: flex; flex-direction: column; }
  .explorer:not(.collapsed) .explorer-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .explorer:not(.collapsed) .explorer-body { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  .explorer:not(.collapsed) .explorer-tree,
  .explorer:not(.collapsed) .explorer-detail { height: auto; min-height: 0; }
  @container (max-width: 580px) {
    .explorer:not(.collapsed) .explorer-body { grid-template-rows: 150px minmax(0, 1fr); }
  }
}
@media (max-width: 700px) {
  .site-header { padding: 12px 16px 4px; }
  .quiz-nav-inner { padding: 6px 16px; }
  .main { padding: 10px 16px 32px; }
}
