/* style.css — build.py により生成（手編集しない） */
/* 紙基調のウォーム配色 + ダークモード。外部フォント・CDN不使用。 */

:root {
  --bg: #FAF9F5;
  --bg-alt: #F1EEE6;
  --bg-raise: #FFFFFF;
  --fg: #33302B;
  --fg-muted: #77705F;
  --accent: #D97757;
  --accent-strong: #B85C3C;
  --accent-soft: #F6E3DB;
  --border: #E4DFD2;
  --code-bg: #F3F0E8;
  --link: #B85C3C;
  --mark: #F7E9A0;
  --warn-bg: #FBF3DC;
  --node-none: #D8D2C4;
  --node-part: #E9B44C;
  --node-done: #7BA05B;
  --shadow: 0 1px 3px rgba(60, 50, 30, 0.12);
}
html[data-theme="dark"] {
  --bg: #1a1815;
  --bg-alt: #232019;
  --bg-raise: #26221C;
  --fg: #E8E2D4;
  --fg-muted: #A39B88;
  --accent: #E08A66;
  --accent-strong: #E8956F;
  --accent-soft: #3A2C24;
  --border: #3A352B;
  --code-bg: #24211A;
  --link: #E8956F;
  --mark: #6b5c1e;
  --warn-bg: #322A17;
  --node-none: #464136;
  --node-part: #A97F1F;
  --node-done: #4F7038;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "BIZ UDPGothic", "Yu Gothic Medium", "Noto Sans CJK JP", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.9;
}
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
code, pre, kbd {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}
code { background: var(--code-bg); padding: 0.15em 0.4em; border-radius: 4px; }
pre { line-height: 1.6; }
pre code { background: none; padding: 0; }

/* ---------- レイアウト ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px;
  background: var(--bg-raise);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--fg); white-space: nowrap; }
#nav-toggle, #theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg); font-size: 16px; padding: 4px 10px; cursor: pointer;
}
#nav-toggle { display: none; }
#theme-toggle:hover, #nav-toggle:hover { border-color: var(--accent); }

.layout { display: flex; padding-top: 52px; min-height: 100vh; }

.sidebar {
  width: 270px; flex: 0 0 270px;
  position: sticky; top: 52px; height: calc(100vh - 52px);
  overflow-y: auto; padding: 16px 10px 40px;
  border-right: 1px solid var(--border);
  background: var(--bg-alt);
}
.side-group {
  font-size: 12px; font-weight: 700; color: var(--fg-muted);
  margin: 18px 8px 6px; letter-spacing: 0.08em;
}
.side-link {
  display: block; padding: 5px 10px; margin: 1px 0;
  border-radius: 8px; text-decoration: none; color: var(--fg);
  font-size: 14px; line-height: 1.5;
}
.side-link:hover { background: var(--accent-soft); color: var(--fg); }
.side-link.active { background: var(--accent); color: #fff; }
.side-link.active .side-lv { background: rgba(255,255,255,0.25); color: #fff; }
.side-lv {
  display: inline-block; min-width: 34px; text-align: center;
  font-size: 11px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent-strong);
  border-radius: 6px; padding: 0 4px; margin-right: 6px;
}
.side-note { font-size: 11px; color: var(--fg-muted); }
.side-link.active .side-note { color: rgba(255,255,255,0.8); }
.mini-progress {
  display: block; height: 4px; margin: 3px 2px 2px 40px;
  background: var(--border); border-radius: 2px; overflow: hidden;
}
.mini-progress .fill { display: block; height: 100%; width: 0; background: var(--node-done); }
.side-link.active .mini-progress { background: rgba(255,255,255,0.35); }

.content {
  flex: 1 1 auto; min-width: 0;
  padding: 28px 40px 80px;
}
.content > *:not(.graph-wrap):not(.level-grid) { max-width: 46em; }
.content h1 { font-size: 1.7em; line-height: 1.5; margin: 0.4em 0 0.8em; }
.content h2 {
  font-size: 1.32em; line-height: 1.5; margin-top: 2.2em;
  padding-bottom: 0.25em; border-bottom: 2px solid var(--border);
}
.content h3 { font-size: 1.12em; margin-top: 1.8em; }
.content h4 { font-size: 1em; margin-top: 1.5em; }
.content img { max-width: 100%; }

/* ---------- 図解（インラインSVG） ---------- */
figure.diagram {
  margin: 1.8em 0; padding: 20px 16px 12px;
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: 12px; text-align: center;
}
figure.diagram > svg { max-width: 100%; height: auto; }
figure.diagram > figcaption {
  margin-top: 10px; font-size: 0.88em; color: var(--fg-muted);
  text-align: center; line-height: 1.6;
}

/* ---------- 動画（インライン埋め込み） ---------- */
figure.video-embed {
  margin: 1.8em 0; padding: 14px 14px 10px;
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: 12px;
}
figure.video-embed > video {
  display: block; width: 100%; border-radius: 8px; background: #000;
}
figure.video-embed > figcaption {
  margin-top: 10px; font-size: 0.9em; color: var(--fg-muted); line-height: 1.6;
}

/* ---------- ウォームアップ予想テスト（事前テスト効果） ---------- */
.pretest {
  margin: 1.6em 0 2em; padding: 14px 18px 12px;
  background: var(--bg-alt); border: 1px dashed var(--border); border-radius: 12px;
}
.pretest .pretest-title {
  font-size: 1.02em; margin: 0 0 0.3em; border-bottom: none; padding-bottom: 0;
}
.pretest .pretest-note { font-size: 0.88em; color: var(--fg-muted); margin: 0.2em 0 0.8em; }
.pretest-item { margin: 0.5em 0; }
.pretest-item > summary { color: var(--fg); font-weight: 600; }
.pretest-item > summary:hover { color: var(--accent-strong); }
.pretest-a {
  margin: 0.5em 0 0.8em; padding: 10px 14px;
  background: var(--bg-raise); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
}

/* ---------- 間隔反復（ダッシュボード・ドリル） ---------- */
.srs-nums { display: flex; gap: 14px; flex-wrap: wrap; margin: 0.6em 0; }
.srs-num {
  min-width: 110px; padding: 10px 14px; text-align: center;
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: 10px;
}
.srs-num strong { display: block; font-size: 1.6em; line-height: 1.3; }
.srs-num span { font-size: 0.8em; color: var(--fg-muted); line-height: 1.4; display: inline-block; }
.srs-num.srs-due { border-color: var(--accent); }
.srs-num.srs-due strong { color: var(--accent-strong); }
.drill-calib {
  padding: 10px 14px; border-radius: 8px;
  background: var(--warn-bg); border: 1px solid var(--border);
}
.drill-conf .btn { margin-top: 4px; }

/* ---------- prefers-reduced-motion（全体共通） ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------- 対話ウィジェット（動画の代替） ---------- */
.dialogue {
  margin: 1.6em 0; padding: 16px 16px 12px;
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: 12px;
}
.dlg-turns { list-style: none; margin: 0; padding: 0; }
.dlg-turn {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 14px;
}
.dlg-turn.dlg-in { animation: dlgIn 0.25s ease-out; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.dlg-role-b { flex-direction: row-reverse; }
.dlg-avatar {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font: 600 13px -apple-system, sans-serif; color: var(--bg-raise);
  background: var(--accent);
}
.dlg-role-b .dlg-avatar { background: var(--fg-muted); }
.dlg-bubble {
  max-width: calc(100% - 50px); padding: 8px 12px;
  background: var(--bg-alt); border-radius: 12px; line-height: 1.7;
}
.dlg-role-a .dlg-bubble { border-top-left-radius: 2px; }
.dlg-role-b .dlg-bubble { border-top-right-radius: 2px; text-align: right; }
.dlg-bubble > p:first-child { margin-top: 0; }
.dlg-bubble > p:last-child { margin-bottom: 0; }
.dlg-speaker {
  display: block; font-size: 0.78em; font-weight: 600; color: var(--fg-muted); margin-bottom: 2px;
}
.dlg-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.dlg-progress { font-size: 0.82em; color: var(--fg-muted); margin-left: auto; }

/* ---------- 疑似ターミナル（Predict → Play） ---------- */
.terminal { margin: 1.6em 0; }
.term-predict {
  margin: 0 0 10px; padding: 10px 14px;
  background: var(--warn-bg); border: 1px solid var(--border); border-radius: 8px;
}
.term-predict > summary { cursor: pointer; font-weight: 600; }
.term-predict > p { margin: 0.6em 0 0; }
.term-frame {
  background: #1e1c18; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border);
}
.term-title {
  padding: 8px 14px; font-size: 0.82em; color: #cfc9ba;
  background: #26221c; border-bottom: 1px solid #3a352b;
}
.term-body {
  margin: 0; padding: 14px; min-height: 3.6em; max-height: 360px; overflow-y: auto;
  color: #e8e2d4; font-size: 0.86em; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}
.term-output { color: inherit; background: none; padding: 0; }
.term-cursor { display: inline-block; color: #7BA05B; animation: termBlink 1s step-end infinite; }
@keyframes termBlink { 50% { opacity: 0; } }
.term-controls { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- 達成演出（習得バッジ・控えめ・初回のみ） ---------- */
.confetti-burst {
  position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden;
}
.confetti-burst > span {
  position: absolute; top: -10px; width: 7px; height: 10px; opacity: 0.9;
  animation: confettiFall 1.6s ease-in forwards;
}
@keyframes confettiFall {
  to { transform: translate(calc(var(--dx) * 60px), 108vh) rotate(540deg); opacity: 0; }
}
.content hr { border: none; border-top: 1px solid var(--border); margin: 2.4em 0; }
.content blockquote {
  margin: 1em 0; padding: 0.2em 1.2em;
  border-left: 4px solid var(--border);
  color: var(--fg-muted); background: var(--bg-alt); border-radius: 0 8px 8px 0;
}
.content table {
  border-collapse: collapse; display: block; overflow-x: auto;
  font-size: 0.92em; line-height: 1.7;
}
.content th, .content td { border: 1px solid var(--border); padding: 6px 12px; }
.content th { background: var(--bg-alt); }
.content details { margin: 0.8em 0; }
.content summary { cursor: pointer; color: var(--accent-strong); }
.site-footer {
  margin-top: 60px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--fg-muted);
}
.muted { color: var(--fg-muted); font-size: 0.92em; }
.lead { font-size: 1.02em; }

/* ---------- ページ内TOC ---------- */
.toc {
  width: 240px; flex: 0 0 240px;
  position: sticky; top: 52px; height: calc(100vh - 52px);
  overflow-y: auto; padding: 20px 14px 40px;
  font-size: 12.5px;
}
.toc-title { font-weight: 700; color: var(--fg-muted); margin-bottom: 8px; }
.toc-nav ul { list-style: none; margin: 0; padding: 0; }
.toc-nav li { margin: 0; line-height: 1.5; }
.toc-nav a {
  display: block; padding: 3px 8px; border-left: 2px solid var(--border);
  color: var(--fg-muted); text-decoration: none;
}
.toc-nav .toc-l3 a { padding-left: 22px; }
.toc-nav a:hover { color: var(--accent-strong); }
.toc-nav a.active { color: var(--accent-strong); border-left-color: var(--accent); font-weight: 600; }

/* ---------- 検索 ---------- */
.searchbox { position: relative; flex: 1 1 auto; max-width: 560px; margin-left: auto; }
#search-input {
  width: 100%; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--fg); font-size: 14px;
}
#search-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
#search-results {
  position: absolute; top: 40px; left: 0; right: 0; z-index: 60;
  max-height: 70vh; overflow-y: auto;
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
}
.sr-count { padding: 6px 14px; font-size: 11px; color: var(--fg-muted); border-bottom: 1px solid var(--border); }
.sr-empty { padding: 14px; font-size: 13px; color: var(--fg-muted); }
.sr-item {
  display: block; padding: 8px 14px; text-decoration: none;
  border-bottom: 1px solid var(--border); color: var(--fg);
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover, .sr-item:focus { background: var(--accent-soft); }
.sr-page { display: block; font-size: 12px; font-weight: 600; color: var(--accent-strong); }
.sr-snip { display: block; font-size: 12px; color: var(--fg-muted); line-height: 1.6; }
.sr-snip mark, .quiz-q mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ---------- チップ・バッジ ---------- */
.page-chip {
  display: inline-block; font-size: 12px; font-weight: 700;
  color: var(--accent-strong); background: var(--accent-soft);
  border-radius: 999px; padding: 2px 12px; margin-bottom: 4px;
}
.callout-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  background: #6B4FBB; color: #fff; border-radius: 999px;
  padding: 1px 10px; margin: 4px 0;
}

/* ---------- callout ---------- */
.callout {
  margin: 1.2em 0; padding: 0.6em 1.2em;
  border-radius: 10px; border: 1px solid;
}
.callout blockquote, .callout p { background: none; border: none; margin: 0.5em 0; padding: 0; color: var(--fg); }
.callout-warn { background: var(--warn-bg, #FBF3DC); border-color: #DDBE5B; }
html[data-theme="dark"] .callout-warn { background: #322A17; border-color: #8A7434; }
.callout-api { background: #EFEAF8; border-color: #A98FE0; }
html[data-theme="dark"] .callout-api { background: #292239; border-color: #7A62B8; }
.callout-li { list-style: none; margin: 0.8em 0 0.8em -1.2em; padding: 0.5em 1em; border-radius: 10px; border: 1px solid; }
.callout-warn-li { background: var(--warn-bg, #FBF3DC); border-color: #DDBE5B; }
html[data-theme="dark"] .callout-warn-li { background: #322A17; border-color: #8A7434; }
.callout-api-li { background: #EFEAF8; border-color: #A98FE0; }
html[data-theme="dark"] .callout-api-li { background: #292239; border-color: #7A62B8; }
.warn-ico { margin-right: 2px; }

/* ---------- モジュール見出し・進捗 ---------- */
.module-heading { position: relative; padding-right: 7em; }
.mod-toggle {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  font-size: 12px; font-weight: 600; line-height: 1.6;
  padding: 3px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-raise); color: var(--fg-muted);
}
.mod-toggle:hover { border-color: var(--accent); color: var(--accent-strong); }
.mod-toggle.on { background: var(--node-done); border-color: var(--node-done); color: #fff; }
.module-heading.mod-done { color: var(--fg-muted); }

.progressbar {
  display: block; height: 8px; border-radius: 4px;
  background: var(--border); overflow: hidden;
}
.progressbar .fill {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--node-done));
  transition: width 0.3s;
}
.page-progress-wrap { margin: 10px 0 20px; max-width: 46em; }
.page-progress { display: flex; align-items: center; gap: 12px; margin: 4px 0; }
.page-progress .pp-label { font-size: 12.5px; font-weight: 600; color: var(--fg-muted); white-space: nowrap; }
.page-progress .progressbar { flex: 1 1 auto; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-block; font-size: 14px; font-weight: 600;
  padding: 6px 18px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-raise); color: var(--fg);
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn.danger { color: #A33; }
.btn.danger:hover { border-color: #A33; }

/* ---------- クイズカード ---------- */
.quiz-card {
  margin: 1.4em 0; padding: 14px 18px;
  background: var(--bg-raise); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 10px;
  box-shadow: var(--shadow);
}
.quiz-card.marked-c { border-left-color: var(--node-done); }
.quiz-card.marked-w { border-left-color: #C55; }
.quiz-q > p:first-child { margin-top: 0; }
.quiz-actions { display: flex; align-items: center; gap: 12px; margin: 8px 0 2px; }
.quiz-status { font-size: 12px; color: var(--fg-muted); }
.quiz-a {
  margin-top: 10px; padding: 10px 14px;
  background: var(--bg-alt); border-radius: 8px;
}
.quiz-a > p:first-child { margin-top: 0; }
.quiz-self { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--fg-muted); }

/* ---------- ドリル ---------- */
.drill-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0; }
#drill-mode { font-size: 14px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-raise); color: var(--fg); }
.drill-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--fg-muted); margin-bottom: 8px; }
.drill-empty, .drill-summary { margin: 20px 0; }

/* ---------- 診断 ---------- */
.diag-stage { margin: 24px 0; }
.diag-card {
  padding: 22px 26px; background: var(--bg-raise);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.diag-progress { font-size: 12.5px; color: var(--fg-muted); display: flex; align-items: center; gap: 14px; }
.diag-progress .progressbar { flex: 1 1 auto; }
.diag-q { font-size: 1.08em; font-weight: 600; line-height: 1.9; }
.diag-btns { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.btn-yes { background: var(--node-done); border-color: var(--node-done); color: #fff; }
.btn-no { background: var(--accent); border-color: var(--accent); color: #fff; }
.diag-table { width: 100%; }
.diag-start li, .diag-later li { margin-bottom: 8px; }
.diag-cta, .diag-result-mini {
  padding: 16px 22px; background: var(--bg-raise);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px;
}
.diag-result-mini h3 { margin: 0 0 6px; font-size: 1em; }

/* ---------- ダッシュボード ---------- */
.dash-section { margin-top: 8px; }
.level-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px; max-width: 62em;
}
.level-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px; text-decoration: none; color: var(--fg);
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.level-card:hover { border-color: var(--accent); color: var(--fg); }
.lv-head { display: flex; align-items: center; gap: 8px; }
.lv-badge {
  font-size: 12px; font-weight: 700; color: #fff;
  background: var(--accent); border-radius: 6px; padding: 1px 8px;
}
.lv-title { font-weight: 700; }
.lv-desc { font-size: 12.5px; color: var(--fg-muted); line-height: 1.7; }
.lv-meta { font-size: 11.5px; color: var(--fg-muted); }
.lv-count { font-size: 11.5px; color: var(--fg-muted); text-align: right; }
.guide-list li { margin-bottom: 6px; }

/* ---------- 前提グラフ（SVG） ---------- */
.graph-wrap { max-width: 820px; overflow-x: auto; }
.prereq-graph { width: 100%; min-width: 640px; height: auto; }
.prereq-graph a { cursor: pointer; }
.g-edge { stroke: var(--fg-muted); stroke-width: 1.6; }
.g-edge.dashed { stroke-dasharray: 5 4; }
.g-arrow { fill: var(--fg-muted); }
.prereq-graph rect { stroke: var(--border); stroke-width: 1; transition: fill 0.3s; }
.prereq-graph rect.g-none { fill: var(--node-none); }
.prereq-graph rect.g-part { fill: var(--node-part); }
.prereq-graph rect.g-done { fill: var(--node-done); }
.prereq-graph a:hover rect { stroke: var(--accent-strong); stroke-width: 2; }
.g-id { font-size: 13px; font-weight: 700; fill: var(--fg); }
.g-name { font-size: 10px; fill: var(--fg); }
.g-pct { font-size: 8.5px; fill: var(--fg); opacity: 0.75; }
.legend { font-size: 12.5px; color: var(--fg-muted); }

/* ---------- コードコピー ---------- */
.codewrap { position: relative; }
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  font-size: 11px; padding: 2px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-raise);
  color: var(--fg-muted); cursor: pointer; opacity: 0;
  transition: opacity 0.15s;
}
.codewrap:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn:hover { color: var(--accent-strong); border-color: var(--accent); }
.codehilite { border-radius: 10px; overflow-x: auto; }
.codehilite pre { margin: 0; padding: 14px 16px; }

/* ---------- ガイド章ナビ ---------- */
.part-nav {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 1.6em 0; padding: 10px 16px;
  background: var(--bg-alt); border-radius: 10px; font-size: 14px;
}
.chapter-list > li { margin-bottom: 10px; }
.lesson-list { font-size: 13px; color: var(--fg-muted); }

/* ---------- エクスポート/インポート ---------- */
#io-area {
  width: 100%; max-width: 46em; font-size: 12px;
  font-family: ui-monospace, Menlo, monospace;
  background: var(--bg-raise); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.io-btns { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
#io-msg.ok { color: var(--node-done); font-size: 13px; }
#io-msg.ng { color: #C55; font-size: 13px; }

/* ---------- モバイル ---------- */
@media (max-width: 1120px) {
  .toc { display: none; }
}
@media (max-width: 860px) {
  #nav-toggle { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 52px; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform 0.2s;
    width: 280px; height: auto;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .content { padding: 20px 18px 60px; }
  .brand { display: none; }
  .module-heading { padding-right: 0; padding-bottom: 1.6em; }
  .mod-toggle { top: auto; bottom: 0; transform: none; }
}

/* ===== pygments (light: default) ===== */
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.codehilite .hll { background-color: #ffffcc }
.codehilite { background: #f8f8f8; }
.codehilite .c { color: #3D7B7B; font-style: italic } /* Comment */
.codehilite .err { border: 1px solid #F00 } /* Error */
.codehilite .k { color: #008000; font-weight: bold } /* Keyword */
.codehilite .o { color: #666 } /* Operator */
.codehilite .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
.codehilite .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
.codehilite .cp { color: #9C6500 } /* Comment.Preproc */
.codehilite .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
.codehilite .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
.codehilite .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
.codehilite .gd { color: #A00000 } /* Generic.Deleted */
.codehilite .ge { font-style: italic } /* Generic.Emph */
.codehilite .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.codehilite .gr { color: #E40000 } /* Generic.Error */
.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.codehilite .gi { color: #008400 } /* Generic.Inserted */
.codehilite .go { color: #717171 } /* Generic.Output */
.codehilite .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.codehilite .gs { font-weight: bold } /* Generic.Strong */
.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.codehilite .gt { color: #04D } /* Generic.Traceback */
.codehilite .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.codehilite .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.codehilite .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.codehilite .kp { color: #008000 } /* Keyword.Pseudo */
.codehilite .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.codehilite .kt { color: #B00040 } /* Keyword.Type */
.codehilite .m { color: #666 } /* Literal.Number */
.codehilite .s { color: #BA2121 } /* Literal.String */
.codehilite .na { color: #687822 } /* Name.Attribute */
.codehilite .nb { color: #008000 } /* Name.Builtin */
.codehilite .nc { color: #00F; font-weight: bold } /* Name.Class */
.codehilite .no { color: #800 } /* Name.Constant */
.codehilite .nd { color: #A2F } /* Name.Decorator */
.codehilite .ni { color: #717171; font-weight: bold } /* Name.Entity */
.codehilite .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
.codehilite .nf { color: #00F } /* Name.Function */
.codehilite .nl { color: #767600 } /* Name.Label */
.codehilite .nn { color: #00F; font-weight: bold } /* Name.Namespace */
.codehilite .nt { color: #008000; font-weight: bold } /* Name.Tag */
.codehilite .nv { color: #19177C } /* Name.Variable */
.codehilite .ow { color: #A2F; font-weight: bold } /* Operator.Word */
.codehilite .w { color: #BBB } /* Text.Whitespace */
.codehilite .mb { color: #666 } /* Literal.Number.Bin */
.codehilite .mf { color: #666 } /* Literal.Number.Float */
.codehilite .mh { color: #666 } /* Literal.Number.Hex */
.codehilite .mi { color: #666 } /* Literal.Number.Integer */
.codehilite .mo { color: #666 } /* Literal.Number.Oct */
.codehilite .sa { color: #BA2121 } /* Literal.String.Affix */
.codehilite .sb { color: #BA2121 } /* Literal.String.Backtick */
.codehilite .sc { color: #BA2121 } /* Literal.String.Char */
.codehilite .dl { color: #BA2121 } /* Literal.String.Delimiter */
.codehilite .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.codehilite .s2 { color: #BA2121 } /* Literal.String.Double */
.codehilite .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
.codehilite .sh { color: #BA2121 } /* Literal.String.Heredoc */
.codehilite .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
.codehilite .sx { color: #008000 } /* Literal.String.Other */
.codehilite .sr { color: #A45A77 } /* Literal.String.Regex */
.codehilite .s1 { color: #BA2121 } /* Literal.String.Single */
.codehilite .ss { color: #19177C } /* Literal.String.Symbol */
.codehilite .bp { color: #008000 } /* Name.Builtin.Pseudo */
.codehilite .fm { color: #00F } /* Name.Function.Magic */
.codehilite .vc { color: #19177C } /* Name.Variable.Class */
.codehilite .vg { color: #19177C } /* Name.Variable.Global */
.codehilite .vi { color: #19177C } /* Name.Variable.Instance */
.codehilite .vm { color: #19177C } /* Name.Variable.Magic */
.codehilite .il { color: #666 } /* Literal.Number.Integer.Long */
/* ===== pygments (dark: monokai) ===== */
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }

html[data-theme="dark"] .codehilite .hll { background-color: #49483e }

html[data-theme="dark"] .codehilite { background: #272822; color: #F8F8F2 }

html[data-theme="dark"] .codehilite .c { color: #959077 } /* Comment */

html[data-theme="dark"] .codehilite .err { color: #ED007E; background-color: #1E0010 } /* Error */

html[data-theme="dark"] .codehilite .esc { color: #F8F8F2 } /* Escape */

html[data-theme="dark"] .codehilite .g { color: #F8F8F2 } /* Generic */

html[data-theme="dark"] .codehilite .k { color: #66D9EF } /* Keyword */

html[data-theme="dark"] .codehilite .l { color: #AE81FF } /* Literal */

html[data-theme="dark"] .codehilite .n { color: #F8F8F2 } /* Name */

html[data-theme="dark"] .codehilite .o { color: #FF4689 } /* Operator */

html[data-theme="dark"] .codehilite .x { color: #F8F8F2 } /* Other */

html[data-theme="dark"] .codehilite .p { color: #F8F8F2 } /* Punctuation */

html[data-theme="dark"] .codehilite .ch { color: #959077 } /* Comment.Hashbang */

html[data-theme="dark"] .codehilite .cm { color: #959077 } /* Comment.Multiline */

html[data-theme="dark"] .codehilite .cp { color: #959077 } /* Comment.Preproc */

html[data-theme="dark"] .codehilite .cpf { color: #959077 } /* Comment.PreprocFile */

html[data-theme="dark"] .codehilite .c1 { color: #959077 } /* Comment.Single */

html[data-theme="dark"] .codehilite .cs { color: #959077 } /* Comment.Special */

html[data-theme="dark"] .codehilite .gd { color: #FF4689 } /* Generic.Deleted */

html[data-theme="dark"] .codehilite .ge { color: #F8F8F2; font-style: italic } /* Generic.Emph */

html[data-theme="dark"] .codehilite .ges { color: #F8F8F2; font-weight: bold; font-style: italic } /* Generic.EmphStrong */

html[data-theme="dark"] .codehilite .gr { color: #F8F8F2 } /* Generic.Error */

html[data-theme="dark"] .codehilite .gh { color: #F8F8F2 } /* Generic.Heading */

html[data-theme="dark"] .codehilite .gi { color: #A6E22E } /* Generic.Inserted */

html[data-theme="dark"] .codehilite .go { color: #66D9EF } /* Generic.Output */

html[data-theme="dark"] .codehilite .gp { color: #FF4689; font-weight: bold } /* Generic.Prompt */

html[data-theme="dark"] .codehilite .gs { color: #F8F8F2; font-weight: bold } /* Generic.Strong */

html[data-theme="dark"] .codehilite .gu { color: #959077 } /* Generic.Subheading */

html[data-theme="dark"] .codehilite .gt { color: #F8F8F2 } /* Generic.Traceback */

html[data-theme="dark"] .codehilite .kc { color: #66D9EF } /* Keyword.Constant */

html[data-theme="dark"] .codehilite .kd { color: #66D9EF } /* Keyword.Declaration */

html[data-theme="dark"] .codehilite .kn { color: #FF4689 } /* Keyword.Namespace */

html[data-theme="dark"] .codehilite .kp { color: #66D9EF } /* Keyword.Pseudo */

html[data-theme="dark"] .codehilite .kr { color: #66D9EF } /* Keyword.Reserved */

html[data-theme="dark"] .codehilite .kt { color: #66D9EF } /* Keyword.Type */

html[data-theme="dark"] .codehilite .ld { color: #E6DB74 } /* Literal.Date */

html[data-theme="dark"] .codehilite .m { color: #AE81FF } /* Literal.Number */

html[data-theme="dark"] .codehilite .s { color: #E6DB74 } /* Literal.String */

html[data-theme="dark"] .codehilite .na { color: #A6E22E } /* Name.Attribute */

html[data-theme="dark"] .codehilite .nb { color: #F8F8F2 } /* Name.Builtin */

html[data-theme="dark"] .codehilite .nc { color: #A6E22E } /* Name.Class */

html[data-theme="dark"] .codehilite .no { color: #66D9EF } /* Name.Constant */

html[data-theme="dark"] .codehilite .nd { color: #A6E22E } /* Name.Decorator */

html[data-theme="dark"] .codehilite .ni { color: #F8F8F2 } /* Name.Entity */

html[data-theme="dark"] .codehilite .ne { color: #A6E22E } /* Name.Exception */

html[data-theme="dark"] .codehilite .nf { color: #A6E22E } /* Name.Function */

html[data-theme="dark"] .codehilite .nl { color: #F8F8F2 } /* Name.Label */

html[data-theme="dark"] .codehilite .nn { color: #F8F8F2 } /* Name.Namespace */

html[data-theme="dark"] .codehilite .nx { color: #A6E22E } /* Name.Other */

html[data-theme="dark"] .codehilite .py { color: #F8F8F2 } /* Name.Property */

html[data-theme="dark"] .codehilite .nt { color: #FF4689 } /* Name.Tag */

html[data-theme="dark"] .codehilite .nv { color: #F8F8F2 } /* Name.Variable */

html[data-theme="dark"] .codehilite .ow { color: #FF4689 } /* Operator.Word */

html[data-theme="dark"] .codehilite .pm { color: #F8F8F2 } /* Punctuation.Marker */

html[data-theme="dark"] .codehilite .w { color: #F8F8F2 } /* Text.Whitespace */

html[data-theme="dark"] .codehilite .mb { color: #AE81FF } /* Literal.Number.Bin */

html[data-theme="dark"] .codehilite .mf { color: #AE81FF } /* Literal.Number.Float */

html[data-theme="dark"] .codehilite .mh { color: #AE81FF } /* Literal.Number.Hex */

html[data-theme="dark"] .codehilite .mi { color: #AE81FF } /* Literal.Number.Integer */

html[data-theme="dark"] .codehilite .mo { color: #AE81FF } /* Literal.Number.Oct */

html[data-theme="dark"] .codehilite .sa { color: #E6DB74 } /* Literal.String.Affix */

html[data-theme="dark"] .codehilite .sb { color: #E6DB74 } /* Literal.String.Backtick */

html[data-theme="dark"] .codehilite .sc { color: #E6DB74 } /* Literal.String.Char */

html[data-theme="dark"] .codehilite .dl { color: #E6DB74 } /* Literal.String.Delimiter */

html[data-theme="dark"] .codehilite .sd { color: #E6DB74 } /* Literal.String.Doc */

html[data-theme="dark"] .codehilite .s2 { color: #E6DB74 } /* Literal.String.Double */

html[data-theme="dark"] .codehilite .se { color: #AE81FF } /* Literal.String.Escape */

html[data-theme="dark"] .codehilite .sh { color: #E6DB74 } /* Literal.String.Heredoc */

html[data-theme="dark"] .codehilite .si { color: #E6DB74 } /* Literal.String.Interpol */

html[data-theme="dark"] .codehilite .sx { color: #E6DB74 } /* Literal.String.Other */

html[data-theme="dark"] .codehilite .sr { color: #E6DB74 } /* Literal.String.Regex */

html[data-theme="dark"] .codehilite .s1 { color: #E6DB74 } /* Literal.String.Single */

html[data-theme="dark"] .codehilite .ss { color: #E6DB74 } /* Literal.String.Symbol */

html[data-theme="dark"] .codehilite .bp { color: #F8F8F2 } /* Name.Builtin.Pseudo */

html[data-theme="dark"] .codehilite .fm { color: #A6E22E } /* Name.Function.Magic */

html[data-theme="dark"] .codehilite .vc { color: #F8F8F2 } /* Name.Variable.Class */

html[data-theme="dark"] .codehilite .vg { color: #F8F8F2 } /* Name.Variable.Global */

html[data-theme="dark"] .codehilite .vi { color: #F8F8F2 } /* Name.Variable.Instance */

html[data-theme="dark"] .codehilite .vm { color: #F8F8F2 } /* Name.Variable.Magic */

html[data-theme="dark"] .codehilite .il { color: #AE81FF } /* Literal.Number.Integer.Long */
/* pygments 背景を紙基調に合わせる */
.codehilite { background: var(--code-bg) !important; }
html[data-theme="dark"] .codehilite { background: var(--code-bg) !important; }
