:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e6edf3;
  --muted: #8b9cb3;
  --accent: #58a6ff;
  --accent2: #3fb950;
  --code-bg: #0d1117;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", "Yu Gothic UI", Meiryo, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.65;
}
.layout { display: flex; min-height: 100vh; }
nav.sidebar {
  width: 280px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); padding: 1.25rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
nav.sidebar h2 { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.75rem; text-transform: uppercase; letter-spacing: .05em; }
nav.sidebar a {
  display: block; padding: 0.35rem 0.5rem; color: var(--text);
  text-decoration: none; border-radius: 4px; font-size: 0.9rem;
}
nav.sidebar a:hover { background: var(--border); color: var(--accent); }
nav.sidebar a.active { background: #1f3a5f; color: var(--accent); font-weight: 600; }
nav.sidebar .ext {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}
nav.sidebar .ext a { color: var(--muted); font-size: 0.82rem; }
main.content { flex: 1; padding: 2rem 3rem 4rem; max-width: 1100px; }
h1 { font-size: 2rem; border-bottom: 2px solid var(--accent); padding-bottom: .5rem; }
h2 { font-size: 1.5rem; margin-top: 2.5rem; color: var(--accent2); border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
h3 { font-size: 1.2rem; margin-top: 1.75rem; color: var(--accent); }
h3 .count { font-size: 0.85rem; color: var(--muted); font-weight: normal; }
h4 { font-size: 1.05rem; margin-top: 1.25rem; }
p, li { color: #c9d1d9; }
a { color: var(--accent); }
table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-size: 0.88rem; }
th, td { border: 1px solid var(--border); padding: 0.45rem 0.65rem; text-align: left; }
th { background: #243044; color: var(--accent); }
tr:nth-child(even) { background: rgba(255,255,255,.02); }
pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem; overflow-x: auto; font-size: 0.85rem;
}
code { font-family: Consolas, "Courier New", monospace; font-size: 0.88em; }
:not(pre) > code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 3px; }
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.api-toc { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 1rem 0 1.5rem; }
.api-toc a {
  background: var(--surface); border: 1px solid var(--border);
  padding: 0.2rem 0.55rem; border-radius: 4px; font-size: 0.8rem; text-decoration: none;
}
.cmd-table code { color: #79c0ff; }
.cmd-table-wide td:nth-child(1) { width: 3rem; text-align: center; color: var(--muted); }
.footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted); }

/* スクリーンショット（後から images/ に PNG を置いて差し替え） */
.figure {
  margin: 1rem 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.figure__frame {
  position: relative;
  min-height: 0;
  background: #0d1117;
}
.figure img {
  display: none;
  width: 100%;
  max-width: 100%;
  height: auto;
  vertical-align: top;
}
.figure.is-loaded img { display: block; }
.figure.is-loaded .figure__frame { min-height: 0; }
.figure__placeholder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem 0.75rem;
  min-height: 0;
  padding: 0.55rem 0.85rem;
  border: none;
  margin: 0;
  border-radius: 0;
  color: var(--muted);
  text-align: left;
  font-size: 0.82rem;
  background: rgba(255,255,255,0.02);
}
.figure__placeholder p { display: none; }
.figure.is-loaded .figure__placeholder { display: none; }
/* 画像がまだ無い図は出さない（「画像予定」の枠を読者に見せない）。
   画像を images/ に置けば、各ページの小さなスクリプトが is-loaded を付けて表示される。 */
.figure:not(.is-loaded) { display: none; }
.figure__label {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: none;
  color: #6e7f96;
}
.figure__label::before { content: "画像予定 · "; }
.figure figcaption {
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
}
.figure figcaption code { display: none; }
.note {
  margin: 1rem 0 1.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: rgba(88, 166, 255, 0.08);
  color: #c9d1d9;
}
.note strong { color: var(--accent); }
.tip {
  margin: 1.25rem 0;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent2);
  background: rgba(63, 185, 80, 0.08);
  border-radius: 0 6px 6px 0;
}
.page-toc {
  margin: 0.75rem 0 1.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
}
.page-toc__title {
  font-size: 0.78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.page-toc ol {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.25rem;
}
.page-toc a {
  font-size: 0.88rem;
  text-decoration: none;
}
.page-toc a:hover { text-decoration: underline; }
h2, h3 { scroll-margin-top: 4.5rem; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  nav.sidebar { width: 100%; height: auto; position: relative; }
  main.content { padding: 1.25rem; }
}

/* リファレンス詳細（命令ごと） */
.ref-item {
  margin: 1rem 0 1.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
}
.ref-item h4 { margin: 0 0 0.5rem; color: var(--accent); }
.ref-item h4 code { color: #79c0ff; }
.ref-label { margin: 0.5rem 0 0.2rem; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ref-syntax { margin: 0.25rem 0 0.75rem; padding-left: 1.2rem; }
.ref-syntax code { color: #e6edf3; }
.ref-args, .ref-desc, .ref-meta { margin: 0.35rem 0; font-size: 0.92rem; }
.ref-item pre {
  margin: 0.35rem 0 0;
  padding: 0.65rem 0.85rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* =========================================================
   ナビゲーション強化（manual.js が生成）
   ========================================================= */
/* 前後の章ナビ */
.doc-nav {
  display: flex; align-items: stretch; gap: 0.75rem;
  margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
}
.doc-nav__link {
  flex: 1; display: flex; flex-direction: column; gap: 0.2rem;
  padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); text-decoration: none; color: var(--text);
  transition: border-color .15s, background .15s;
}
.doc-nav__link:hover { border-color: var(--accent); background: var(--code-bg); }
.doc-nav__next { text-align: right; }
.doc-nav__dir { font-size: 0.72rem; color: var(--muted); }
.doc-nav__title { font-size: 0.92rem; color: var(--accent); }
.doc-nav__link.is-empty { visibility: hidden; }
.doc-nav__home {
  align-self: center; padding: 0.5rem 0.9rem; border-radius: 8px;
  border: 1px solid var(--border); color: var(--muted); text-decoration: none;
  font-size: 0.85rem; white-space: nowrap;
}
.doc-nav__home:hover { color: var(--accent); border-color: var(--accent); }

/* ページ先頭へ戻る */
.to-top {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 40;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--accent);
  font-size: 1.15rem; cursor: pointer; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.to-top.is-visible { opacity: 1; pointer-events: auto; }
.to-top:hover { border-color: var(--accent); transform: translateY(-2px); }

/* API 検索バー（大きな章のみ） */
.api-subbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin: 0 0 1.25rem; padding: 0.6rem 0;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.api-search {
  flex: 1; min-width: 220px; padding: 0.5rem 0.7rem;
  background: var(--code-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem;
}
.api-search:focus { outline: none; border-color: var(--accent); }
.api-count { font-size: 0.82rem; color: var(--muted); }
.api-top { font-size: 0.82rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.api-top:hover { color: var(--accent); }

/* ハンバーガー / モバイルドロワー */
body.nav-open { overflow: hidden; }
.nav-toggle, .nav-backdrop { display: none; }
@media (max-width: 900px) {
  .nav-toggle {
    display: block; position: fixed; top: 0.6rem; left: 0.6rem; z-index: 60;
    padding: 0.5rem 0.8rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--accent); font-size: 0.9rem; cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,.4);
  }
  nav.sidebar {
    position: fixed; top: 0; left: 0; width: 82%; max-width: 320px; height: 100vh;
    z-index: 55; transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.55); padding-top: 3.5rem; overflow-y: auto;
  }
  body.nav-open nav.sidebar { transform: translateX(0); }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  main.content { padding-top: 3.5rem; }
  .to-top { right: 0.9rem; bottom: 0.9rem; }
}

/* スマホ幅: 広い表はその場で横に流し、ページ全体を横にずらさない（2026-10-06） */
@media (max-width: 900px) {
  main.content { min-width: 0; overflow-wrap: break-word; }
  main.content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  main.content pre { max-width: 100%; overflow-x: auto; }
  main.content img { max-width: 100%; height: auto; }
}