.manual-main {
  --guide-body-color: #d3d8de;
  /* カード面はページ背景 (--bg #111316) より一段明るく、枠はさらに明るく取る。
     --panel-soft / --line の組はページ背景との差が 4/16 しかなく面の境界が読めない。 */
  --guide-card-bg: #1c2127;
  --guide-card-line: #414a55;
}

.manual-container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.guide-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.guide-body {
  min-width: 0;
}

/* 左目次（主項目） */
.guide-toc {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  z-index: 20;
}

.guide-toc-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-toc-row {
  position: relative;
}

.guide-toc-item {
  display: grid;
  grid-template-columns: 1.9rem 1fr;
  gap: 6px;
  align-items: baseline;
  padding: 9px 10px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.5;
  text-decoration: none;
}

.guide-toc-num {
  color: var(--accent);
  font-size: .74rem;
  font-weight: 700;
}

.guide-toc-item:hover,
.guide-toc-row[data-open] > .guide-toc-item {
  color: var(--text);
  border-left-color: var(--accent);
  background: #232931;
}

.guide-toc-item[aria-current="true"] {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--guide-card-bg);
  font-weight: 700;
}

.guide-toc-item:focus-visible,
.guide-toc-flyout a:focus-visible,
.panel-pager a:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

/* 副項目フライアウト — 開く操作（ホバー / フォーカス）があってはじめて出す。JS が動いて
   いなければ開く手段が無いので出さない。主項目のリンクだけで12画面すべてへ到達できる。 */
.guide-toc-flyout {
  display: none;
}

.guide-js .guide-toc-row[data-open] > .guide-toc-flyout {
  display: block;
  position: absolute;
  left: 100%;
  top: -8px;
  z-index: 30;
  min-width: 250px;
  max-width: 320px;
  padding: 10px 8px;
  border: 1px solid var(--guide-card-line);
  background: #232931;
  box-shadow: 0 14px 38px rgba(0, 0, 0, .45);
}

.guide-toc-flyout ul {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-toc-flyout a {
  display: block;
  padding: 8px 10px;
  color: var(--accent-hover);
  font-size: .92rem;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
}

.guide-toc-flyout a:hover {
  color: var(--text);
  background: var(--panel-soft);
}

/* JS 有効時のパネル制御 */
.guide-js .window-panel[hidden] {
  display: none;
}

.window-panel {
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.panel-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 2px 2px 16px;
}

.panel-heading h2 {
  margin: 0 0 5px;
  font-size: 1.45rem;
}

.panel-heading p:last-child {
  margin: 0;
  font-size: .95rem;
  color: var(--muted);
}

.panel-number {
  margin: 0;
  color: var(--accent);
  font-size: .95rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.manual-card {
  scroll-margin-top: calc(var(--header-h) + 16px);
  margin-bottom: 22px;
  padding: 28px 30px;
  border: 1px solid var(--guide-card-line);
  background: var(--guide-card-bg);
}

.manual-card + .manual-card {
  padding-top: 28px;
}

.manual-card h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--text);
}

.manual-card > p,
.manual-card li {
  color: var(--guide-body-color);
  font-size: 1.125rem;
  line-height: 1.9;
}

.manual-card > p,
.manual-card > ul {
  max-width: 40em;
}

.manual-card > p:last-child,
.manual-card ul:last-child {
  margin-bottom: 0;
}

.manual-card ul {
  margin: 0;
  padding-left: 1.35rem;
}

.manual-card li + li {
  margin-top: 7px;
}

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0 .38em;
  border: 1px solid #4a515b;
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--text);
  background: #0d0f11;
  font: inherit;
  font-size: .82em;
  line-height: 1.55;
  text-align: center;
}

/* 素の画素数を超えて引き伸ばさない。図の幅は画像が決め、カラム幅に収まらないときだけ
   縮む（help-menu.png 189px 等の小さな図が本文カラム 848px まで 4.5 倍に伸びていた）。 */
.guide-media {
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
  margin: 24px 0 0;
  border: 1px solid #4a515b;
  background: #0b0d0f;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .24);
}

.guide-media img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
}

.manual-main .guide-shot figcaption,
.guide-media figcaption {
  padding: 12px 15px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #2f2a20;
  font-size: .9375rem;
}

/* キャプションは fit-content の幅計算へ max-content として効いてしまい、短い画像でも
   図が文字列の長さまで広がる。min-content で寄与を切り、実幅は 100% で取り戻す。 */
.guide-media figcaption {
  width: min-content;
  min-width: 100%;
}

.manual-main .guide-note {
  background: #14181d;
}

.manual-main .guide-note p {
  font-size: 1rem;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.media-grid .guide-media {
  margin-top: 18px;
}

.panel-pager {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.panel-pager a {
  padding: 10px 14px;
  border: 1px solid var(--line);
  color: var(--accent-hover);
  font-size: .86rem;
  font-weight: 700;
  text-decoration: none;
}

.panel-pager a:hover {
  border-color: var(--accent);
  background: var(--panel);
}

/* 2カラム維持の下限は実測901px（本文カラム582px・スクショ2枚並びのセル252px）。
   900px 以下は積み替えて本文カラムを853pxへ戻す。 */
@media (max-width: 900px) {
  .guide-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .guide-toc {
    position: static;
  }
}

/* ホバー式フライアウトが成立するのは guide.js の HOVER_QUERY と同じ条件だけ。その否定
   （狭幅・hover 不可・粗いポインタ）では開く操作自体が存在しないので、静的な入れ子目次へ
   戻して現在の行の副項目を出す。これが無いと幅901px以上のタッチ端末で副項目34件が
   display:none のまま到達不能になる — 主項目をタップしても focusin 直後に click が
   open(null) を呼ぶため、開いた状態が残らない。 */
@media (max-width: 900px), (hover: none), (pointer: coarse) {
  .guide-js .guide-toc-row[data-open] > .guide-toc-flyout,
  .guide-js .guide-toc-row[data-current] > .guide-toc-flyout {
    display: block;
    position: static;
    min-width: 0;
    max-width: none;
    border: 0;
    border-left: 2px solid var(--line);
    background: transparent;
    box-shadow: none;
    margin: 0 0 4px 12px;
    padding: 2px 0 2px 10px;
  }

  .guide-toc-flyout a {
    white-space: normal;
  }
}

@media (max-width: 760px) {
  .manual-container {
    width: min(100% - 22px, 1180px);
  }

  .panel-heading {
    gap: 10px;
    padding: 0 2px 14px;
  }

  .manual-card {
    padding: 23px 20px;
  }

  .media-grid {
    grid-template-columns: 1fr;
  }

  .panel-pager {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-pager span:empty {
    display: none;
  }

  .panel-pager a {
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
