/* Sixteen Gate Lattice - MIT (c) 2026 ipusiron. */
:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --paper: #fffffb;
  --ink: #17283a;
  --muted: #4a5a69;
  --line: #b5c3cc;
  --edge: #9aabb8;
  --accent: #1f5f8b;
  --on-accent: #fffffb;
  --shadow: #d8dcd4;
  --warn: #9b2c1f;
  /* 緩い（青）・厳しい（橙）・選んだ印・▼と▲ */
  --up: #cfe3f6;
  --up-line: #1f5f8b;
  --down: #fbd9b5;
  --down-line: #9a4a00;
  --pick: #17283a;
  --diamond: #6b2fa0;
  /* ベン図の塗り */
  --venn-on: #5b7c99;
  --venn-off: #fffffb;
  --venn-edge: #17283a;
  /* 暗号の色分け：1次以下（灰の斜線）と AB の項を含む（紫）、つり合いの帯 */
  --linear: #e6e9ec;
  --hatch: #8a96a1;
  --quad: #e6d8f5;
  --band: #fff3c4;
  --band-line: #b08a00;
  /* 判定の色 */
  --neither: #5b6670;
  --gained-bg: #d9ecfb;
  --lost-bg: #fde3cd;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1a26;
  --paper: #182838;
  --ink: #e8eff5;
  --muted: #bccad6;
  --line: #5d7387;
  --edge: #6d8397;
  --accent: #8cc4ec;
  --on-accent: #10202e;
  --shadow: #08121c;
  --warn: #ffb4a8;
  --up: #1d4466;
  --up-line: #8cc4ec;
  --down: #5a3412;
  --down-line: #f4b06a;
  --pick: #ffffff;
  --diamond: #d7b4ff;
  --venn-on: #8fb3d1;
  --venn-off: #182838;
  --venn-edge: #e8eff5;
  --linear: #263646;
  --hatch: #7c8c9a;
  --quad: #47305f;
  --band: #3b3410;
  --band-line: #e0c24a;
  --neither: #c3ccd4;
  --gained-bg: #1d4466;
  --lost-bg: #5a3412;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.6 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  /* 日本語は語の切れ目（<wbr>）だけで折り返す。英語は空白で折り返す */
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-break: strict;
}
button, select { font: inherit; color: inherit; }
button {
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  padding: .4rem .8rem;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: var(--paper);
}
button:focus-visible, a:focus-visible, select:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
a { color: var(--accent); }
.wrap { width: min(100% - 2rem, 1000px); margin-inline: auto; }
.nowrap { white-space: nowrap; }
.mono, code, .mono-cells td { font-family: ui-monospace, Consolas, "Courier New", monospace; }

/* ===== 見出し：狭い幅は縦に、900px以上は3列（左の空き・題名・ボタン。左右を同じ幅にして題名を中央に置く） ===== */
.site-header { padding: 1.4rem 0 .4rem; }
.header-content { display: flex; flex-direction: column; align-items: center; gap: .7rem; }
.header-title { text-align: center; min-width: 0; }
@media (min-width: 900px) {
  .header-content { display: grid; grid-template-columns: 270px minmax(0, 1fr) 270px; align-items: center; }
  .header-title { grid-column: 2; }
  .header-buttons { grid-column: 3; justify-self: end; }
}
h1 { margin: 0; font-size: clamp(1.5rem, 4.5vw, 2rem); line-height: 1.2; }
h1 span { color: var(--accent); }
.subtitle { margin: .35rem 0 0; color: var(--muted); font-size: .9375rem; }
.header-buttons { display: flex; gap: .4rem; }
.tool-button { border-radius: 999px; font-weight: 700; white-space: nowrap; }
.tool-icon { margin-right: .3rem; }

/* ===== 冒頭：目的の段落・できること（600px未満はたたむ）・T/F の対応 ===== */
.intro { margin: .8rem 0 0; }
.intro p { margin: 0 0 .5rem; }
.intro-list { margin: 0 0 .3rem; padding-left: 1.3rem; }
.intro-list li + li { margin-top: .15rem; }
@media (min-width: 600px) {
  }
.intro-tf { font-size: .9375rem; color: var(--muted); }
noscript { display: block; margin: .8rem 0; padding: .6rem; border: 1px solid var(--warn); color: var(--warn); }

/* ===== タブ ===== */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .15rem;
  margin-top: 1rem;
  padding: .15rem;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 3px 3px 0 var(--shadow);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: .3rem .2rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  line-height: 1.3;
}
.tab-name { font-size: .9375rem; font-weight: 700; }
@media (max-width: 429px) {
  .tab-name { font-size: .8125rem; }
}
.tab-en { font-size: .75rem; color: var(--muted); }
:root[lang="en"] .tab-en { display: none; }
/* 選んだタブは色と下線で示し、文字の太さは変えない（太さで幅が変わり、折り返し方が変わらないように） */
.tab[aria-selected="true"] { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
/* タブを替えても、ページの下端が縮んで表示の位置が飛ばないよう、パネルの領域は画面の高さ以上にする */
.panels { min-height: 100vh; min-height: 100dvh; overflow-anchor: none; }
.panel {
  margin: -1px 0 1rem;
  padding: .9rem;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 3px 3px 0 var(--shadow);
  min-width: 0;
}
.panel h2 { margin: 0 0 .3rem; font-size: 1.15rem; color: var(--accent); }
.lead { margin: 0 0 .6rem; color: var(--muted); font-size: .9375rem; }
h3 { margin: 1.1rem 0 .4rem; font-size: 1rem; color: var(--accent); }
.seg-note { margin: .25rem 0 0; font-size: .8125rem; color: var(--muted); }

/* ===== タブ1：図と詳しい欄（900px以上は左右に並べる） ===== */
.diagram-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 900px) {
  .diagram-layout { grid-template-columns: minmax(0, 1fr) minmax(250px, 290px); align-items: start; }
}
.figure-col, .detail { min-width: 0; }
.rank-note { margin: 0 0 .3rem; font-size: .8125rem; color: var(--muted); }
.figure-box { width: 100%; min-width: 0; }
.figure-box svg { display: block; margin-inline: auto; overflow: visible; }
/* 狭い画面は、図の枠をパネルの内側の余白まで広げる（6個の段の印の隙間を2px以上にする） */
@media (max-width: 599px) {
  .figure-box { width: calc(100% + 1.8rem - 8px); margin-inline: calc(-.9rem + 4px); }
}
.sel-line { margin: .4rem 0 0; font-weight: 700; font-size: .9375rem; min-height: 1.6em; }
.sel-line .to-detail { margin-left: .5em; font-weight: 400; font-size: .875rem; }
.example-note { margin: -.3rem 0 .5rem; }
@media (min-width: 900px) {
  .sel-line { display: none; }
}
.count-line { margin: .2rem 0 0; font-size: .9375rem; }
.legend { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .8125rem; }
.legend li { display: flex; align-items: flex-start; gap: .35rem; }
.legend svg { flex: none; margin-top: .15rem; }
/* 図のすぐ上の道具の行：右端に「選び直す」と「共有」。知らせはボタンの左に出し、ボタンの位置は動かさない */
.figure-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .4rem; align-items: center; margin: 0 0 .4rem; }
.share-status { grid-column: 1; margin: 0; font-size: .8125rem; line-height: 1.3; color: var(--accent); font-weight: 700; text-align: right; }
.small-button { padding: .25rem .7rem; font-size: .875rem; white-space: nowrap; }
.small-button:disabled { cursor: default; opacity: .55; }
.share-box { margin: 0 0 .5rem; }
.share-url {
  width: 100%;
  min-height: 44px;
  padding: .3rem .5rem;
  font: inherit;
  font-size: .8125rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 6px;
}
/* 色分けのスイッチは、すぐ下の説明の1文と組にして図の下に置く */
.crypto-group { margin-top: .7rem; }
.crypto-group .seg-note { margin-top: .2rem; }
.detail { padding: .6rem .8rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.detail h3 { margin-top: 0; }
.detail-name { margin: 0 0 .3rem; font-size: 1.05rem; font-weight: 700; }
.detail-rows { margin: 0 0 .5rem; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .1rem .6rem; font-size: .875rem; }
.detail-rows dt { color: var(--muted); }
.detail-rows dd { margin: 0; }
.venn-wrap { margin: .3rem 0; }
.venn-caption { margin: .2rem 0 .4rem; font-size: .75rem; color: var(--muted); }
.detail-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-bottom: .4rem; }
.detail-pair > div { min-width: 0; padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.pair-name { margin: 0 0 .2rem; font-weight: 700; font-size: .875rem; }
/* 幅400px未満では、2つの演算の名前が語の途中で折れないよう、縦に並べる */
@media (max-width: 399px) {
  .detail-pair { grid-template-columns: minmax(0, 1fr); }
}
.detail-lines p { margin: .25rem 0 0; font-size: .875rem; }
.detail-lines .meet-join { font-weight: 700; }

/* ===== 図の印と線（SVG） ===== */
svg.lattice text { font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif; }
.rank-label { fill: var(--muted); font-weight: 700; }
.edge { stroke: var(--edge); stroke-width: 1.3; }
.edge.up { stroke: var(--up-line); stroke-width: 3; }
.edge.down { stroke: var(--down-line); stroke-width: 3; }
.edge.path { stroke-width: 4.5; }
.edge.path.looser { stroke: var(--up-line); }
.edge.path.stricter { stroke: var(--down-line); }
.node { cursor: default; }
.node[role="button"] { cursor: pointer; }
.node .frame { fill: var(--paper); stroke: var(--muted); stroke-width: 1.2; }
.node .label { fill: var(--ink); font-weight: 700; }
.node .hatch, .node .bar-top, .node .bar-bottom, .node .same-ring, .node .focus-ring { display: none; }
.node .bar-top { fill: var(--up-line); }
.node .bar-bottom { fill: var(--down-line); }
.node.looser .frame { fill: var(--up); stroke: var(--up-line); }
.node.looser .bar-top { display: inline; }
.node.stricter .frame { fill: var(--down); stroke: var(--down-line); }
.node.stricter .bar-bottom { display: inline; }
.node.picked .frame { stroke: var(--pick); stroke-width: 4; }
.node.linear .frame { fill: var(--linear); }
.node.linear .hatch { display: inline; }
.node.quadratic .frame { fill: var(--quad); }
.node .corner-left { fill: var(--pick); font-weight: 700; }
.node .corner-right { fill: var(--diamond); font-weight: 700; }
.node.before .frame, .node.after .frame { stroke: var(--pick); stroke-width: 3; }
.node.via .frame { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; }
.node.same .same-ring { display: inline; fill: none; stroke: var(--pick); stroke-width: 2; }
.node .focus-ring { fill: none; stroke: var(--accent); stroke-width: 3; }
.node:focus { outline: none; }
.node:focus-visible .focus-ring { display: inline; }
.hatch-bg { fill: var(--linear); }
.hatch-line { stroke: var(--hatch); stroke-width: 2; }
.balance-band { display: none; fill: var(--band); stroke: var(--band-line); stroke-width: 1.5; stroke-dasharray: 5 4; }
svg.lattice.show-band .balance-band { display: inline; }
.venn-on { fill: var(--venn-on); }
.venn-off { fill: var(--venn-off); }
.venn-edge { fill: none; stroke: var(--venn-edge); stroke-width: 1; }
.venn-name { fill: var(--ink); font-weight: 700; paint-order: stroke; stroke: var(--paper); stroke-width: 3px; }
.arrow-head.looser { fill: var(--up-line); }
.arrow-head.stricter { fill: var(--down-line); }
.arrow-head.neither { fill: var(--neither); }
.arrow-line { fill: none; stroke-width: 3.5; }
.arrow-line.neither { stroke: var(--neither); stroke-dasharray: 8 5; }
.arrow-halo { fill: none; stroke: var(--paper); stroke-width: 8; }

/* ===== タブ2：場面・選ぶ欄・判定・図と表 ===== */
fieldset.seg { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.seg legend { padding: 0; margin-bottom: .25rem; font-size: .875rem; font-weight: 700; }
.seg-buttons { display: flex; flex-wrap: wrap; gap: .35rem; }
.seg-buttons button { min-height: 44px; }
/* 選んだボタンは色で示し、太さは変えない（太さで幅が変わると、ボタンの折り返しが変わって画面が動く） */
.seg-buttons button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.meaning { margin: .7rem 0 .2rem; font-weight: 700; }
.scene-desc { margin: 0 0 .3rem; font-size: .9375rem; }
.scene-link { margin: 0 0 .3rem; font-size: .875rem; }
.selects { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .4rem .6rem; margin: .6rem 0 .2rem; }
.select-field { display: flex; flex-direction: column; gap: .15rem; font-size: .875rem; font-weight: 700; min-width: 0; }
.select-field select {
  min-height: 44px;
  max-width: 100%;
  padding: .3rem .4rem;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: var(--paper);
  font-size: 1rem;
  font-weight: 400;
}
.select-arrow { font-size: 1.3rem; padding-bottom: .4rem; color: var(--muted); }
@media (max-width: 599px) {
  .select-arrow { display: none; }
  .cases-table th, .cases-table td { padding: .3rem .3rem; }
}
.verdict { margin: .6rem 0 .2rem; padding: .4rem .6rem; border-left: 6px solid var(--line); background: var(--bg); font-weight: 700; }
.verdict.looser { border-left-color: var(--up-line); }
.verdict.stricter { border-left-color: var(--down-line); }
.verdict.neither { border-left-color: var(--neither); }
.say { margin: .2rem 0 .6rem; }
.rules-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem 1rem; }
@media (min-width: 900px) {
  .rules-layout { grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); align-items: start; }
  .rules-table-col h3 { margin-top: 0; }
}
.rules-figure-col, .rules-table-col { min-width: 0; }
.scene-note { margin: .5rem 0 0; padding: .4rem .6rem; border: 1px dashed var(--line); border-radius: 6px; font-size: .875rem; }

/* ===== 表 ===== */
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { padding: .3rem .45rem; border: 1px solid var(--line); text-align: left; vertical-align: middle; overflow-wrap: normal; }
th { background: var(--bg); font-size: .875rem; }
.truth-table td, .truth-table th, .cases-table td, .cases-table th { text-align: center; }
/* 2つ選んだときの6列の真理値表が詳しい欄に収まるよう、欄の左右の余白を詰める */
.detail .truth-table td, .detail .truth-table th { padding-inline: .2rem; }
.truth-table td.yes, .cases-table td.yes { font-weight: 700; }
.cases-table td.change { text-align: left; font-size: .8125rem; }
.cases-table tr.gained td { background: var(--gained-bg); }
.cases-table tr.lost td { background: var(--lost-bg); }
.cases-table tr.focus-row td { box-shadow: inset 0 2px 0 var(--pick), inset 0 -2px 0 var(--pick); }

/* ===== タブ3：座学のカード ===== */
/* 分野ごとのアコーディオン：見出しは押しやすい高さにし、開いた中にカードを並べる */
.genres { display: grid; gap: .6rem; }
.genre { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); min-width: 0; }
.genre-summary {
  display: list-item;
  min-height: 44px;
  padding: .6rem .8rem;
  border-radius: 10px;
  background: var(--bg);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}
.genre[open] > .genre-summary { border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.genre > .study-grid { padding: .7rem; }
/* ルールで読むタブの一番下の「解説」：今選んでいる場面の話を出す */
.notes { margin-top: 1rem; }
.notes-body { padding: .2rem .8rem .6rem; }
.notes-body h3 { margin: .5rem 0 .4rem; font-size: 1rem; color: var(--ink); }
.notes-body p { margin: 0 0 .5rem; font-size: .9375rem; }
@media (max-width: 399px) {
  .genre > .study-grid { padding: .5rem .4rem; }
}
.study-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: .8rem; }
.study-card { padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-width: 0; }
@media (max-width: 399px) {
  .study-card { padding: .7rem .6rem; }
}
/* 「論理学と証明」と「暗号とセキュリティ」のカードは、表と図が広いので横いっぱいに1枚ずつ置く */
.study-card.wide-card { grid-column: 1 / -1; }
.study-card h3 { margin: 0 0 .35rem; font-size: 1rem; color: var(--ink); }
.study-card h3 .no { display: inline-block; min-width: 1.8rem; color: var(--accent); }
.study-card p { margin: 0 0 .5rem; font-size: .9375rem; }
.study-card table { font-size: .8125rem; background: var(--paper); margin: 0 0 .6rem; }
.card-link, .card-action { margin: .3rem 0 0; font-size: .875rem; }
.source-line { font-size: .8125rem; color: var(--muted); }
/* 16個の演算の名前の表：書き方は分野ごとに1行ずつ縦に並べる（表を横にはみ出させない） */
.names-table td { vertical-align: top; }
.names-table .nt { display: block; white-space: nowrap; }
.names-table .nt-k { display: inline-block; min-width: 3.4em; margin-right: .3em; color: var(--muted); font-size: .75rem; }
:root[lang="en"] .names-table .nt-k { min-width: 4.6em; }
.names-table .nt-v code { font-size: .875em; }
.over { text-decoration: overline; }
/* 名前の表は列が多いので、幅900px未満では行ごとの縦の並びにする（ほかの表は600px未満から） */
@media (max-width: 899px) {
  .names-table thead { display: none; }
  .names-table, .names-table tbody, .names-table tr, .names-table td { display: block; width: 100%; }
  .names-table tr { border: 1px solid var(--line); border-bottom: 0; }
  .names-table tr:last-child { border-bottom: 1px solid var(--line); }
  .names-table td { border: 0; border-top: 1px dashed var(--line); }
  .names-table tr td:first-child { border-top: 0; font-weight: 700; background: var(--bg); }
  .names-table td[data-label]::before { content: attr(data-label) "："; display: block; font-size: .75rem; color: var(--muted); font-weight: 400; }
  :root[lang="en"] .names-table td[data-label]::before { content: attr(data-label) ": "; }
}
.steps { margin: 0 0 .6rem; padding-left: 1.5rem; font-size: .9375rem; }
.reduction-box { margin: .4rem 0 .4rem; }
.reduction-box svg { display: block; margin-inline: auto; }
.reduction text { fill: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif; }
.reduction .box { fill: var(--paper); stroke: var(--muted); stroke-width: 1.3; }
.reduction .box-r { fill: none; stroke: var(--ink); stroke-width: 3; }
.reduction .box-f { stroke: var(--ink); stroke-width: 1.5; }
.reduction .box-inner { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.quant .box-a { stroke: var(--ink); stroke-width: 1.5; }
.reduction .box-title { font-weight: 700; }
/* 論理南京錠の線画：扉の縁・錠の本体・ツル・掛け金。拡大しても線の太さは変えない */
.pad-art * { vector-effect: non-scaling-stroke; }
.padlocks .pad-door { fill: var(--paper); stroke: var(--ink); stroke-width: 1.6; }
.padlocks .pad-post { fill: var(--linear); stroke: var(--ink); stroke-width: 1.6; }
.padlocks .pad-body, .padlocks .pad-plate { fill: var(--paper); stroke: var(--ink); stroke-width: 1.6; }
.padlocks .pad-guide, .padlocks .pad-keeper { fill: var(--muted); stroke: var(--ink); stroke-width: 1.2; }
.padlocks .pad-shackle { fill: none; stroke: var(--ink); stroke-width: 3.4; }
.padlocks .pad-chain { fill: none; stroke: var(--ink); stroke-width: 3; stroke-dasharray: 5 3; }
.padlocks .pad-spring { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
.padlocks .pad-staple { fill: none; stroke: var(--ink); stroke-width: 2.4; }
.padlocks .pad-hole { fill: var(--ink); }
.padlocks .pad-bolthole { fill: var(--ink); }
/* 水の流れの図：管と流れは青（--accent）、弁と壁は文字の色 */
.water .water-pipe { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linejoin: round; }
.water .water-valve { fill: var(--paper); stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
.water .water-head { fill: var(--accent); }
.water .water-wall { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.water .water-flow { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.water .water-ctrl-on { stroke: var(--accent); stroke-width: 2.5; }
.reduction .io { font-weight: 700; fill: var(--accent); font-family: ui-monospace, Consolas, "Courier New", monospace; }
.reduction .flow { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.reduction .flow-head { fill: var(--ink); }
/* 幅600px未満では、3列以上の表を行ごとの縦の並びにする（見出しは各欄の前に出す） */
@media (max-width: 599px) {
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
  .stack-table tr { border: 1px solid var(--line); border-bottom: 0; }
  .stack-table tr:last-child { border-bottom: 1px solid var(--line); }
  .stack-table td { border: 0; border-top: 1px dashed var(--line); }
  .stack-table tr td:first-child { border-top: 0; font-weight: 700; background: var(--bg); }
  .stack-table td[data-label]::before { content: attr(data-label) "："; display: block; font-size: .75rem; color: var(--muted); font-weight: 400; }
  :root[lang="en"] .stack-table td[data-label]::before { content: attr(data-label) ": "; }
}

/* ===== フッター・出典 ===== */
.site-footer { padding: .4rem 0 2rem; font-size: .875rem; color: var(--muted); text-align: center; }
.site-footer p { margin: .3rem 0; }
.sources { margin: 0; padding-left: 1.2rem; }
.sources li + li { margin-top: .25rem; }

/* ===== ヘルプ ===== */
html.dialog-open { overflow: hidden; }
.help-dialog {
  width: min(100% - 2rem, 44rem);
  max-height: min(90dvh, 48rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}
.help-dialog::backdrop { background: rgba(8, 18, 28, .6); }
.help-frame { display: flex; flex-direction: column; max-height: min(90dvh, 48rem); }
.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--line);
}
.help-head h2 { margin: 0; font-size: 1.15rem; color: var(--accent); }
.help-body { overflow-y: auto; padding: .4rem .9rem 1rem; scrollbar-gutter: stable; }
.help-body h3 { margin: 1rem 0 .3rem; }
.help-body li { font-size: .9375rem; }
.help-features, .help-list { margin: 0; padding-left: 1.2rem; }
.help-features li + li, .help-list li + li { margin-top: .4rem; }
.help-go { display: block; margin-top: .25rem; min-height: 40px; font-size: .875rem; color: var(--accent); }

/* ===== オン・オフのスイッチ ===== */
.switch { display: inline-flex; align-items: center; gap: .5rem; text-align: left; }
.switch-track {
  position: relative;
  flex: none;
  width: 2.6rem;
  height: 1.5rem;
  border: 2px solid var(--muted);
  border-radius: 999px;
  background: var(--bg);
}
.switch-knob {
  position: absolute;
  top: .125rem;
  left: .125rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--muted);
}
.switch[aria-checked="true"] .switch-track { border-color: var(--accent); background: var(--accent); }
.switch[aria-checked="true"] .switch-knob { left: auto; right: .125rem; background: var(--on-accent); }
.switch-state { font-weight: 700; min-width: 2em; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* ===== 説明の文：最後の行に短い句だけが落ちないようにする（対応しないブラウザーでは、ふつうの折り返しのまま） ===== */
p, li { text-wrap: pretty; }
/* 日本語の短い句（js/i18n.js）は句の中で折り返さない */
.ph { white-space: nowrap; }
/* 座学のカードは、ふつうの折り返し（WebKit で text-wrap: pretty と特定の文の組み合わせでページが落ちるため） */
.study-card p, .study-card li { text-wrap: wrap; }
