/* historia_world — ワンスクリーン・パズルゲーム風ステージUI ＆ 操作フォーカススタイル */

/* ── 1. 完全ワンスクリーン骨格（100vw × 100dvh / ウィンドウ縦横スクロール完全ゼロ） ── */
html,
body {
  height: 100dvh;
  width: 100vw;
  max-width: 100vw;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-attachment: scroll;
}

#app {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  position: relative;
  top: auto;
  z-index: 40;
  flex: 0 0 48px;
  height: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 clamp(10px, 2vw, 22px);
  overflow: hidden;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  border-bottom: 1px solid var(--line-strong);
}

.brand {
  flex: 0 0 auto;
  font-size: 15px;
  gap: 6px;
}

.nav-shoulder-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--line-strong) 60%, transparent);
  transition: border-color 0.12s ease, background-color 0.12s ease, transform 0.08s ease;
}

.nav-shoulder-badge:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-2);
}

.nav-shoulder-badge:active {
  transform: translateY(1px);
}

.topnav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.topnav a {
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1.3;
}

.topbar-tools {
  margin-left: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-search {
  padding: 3px 10px;
}

.quick-search input {
  width: 120px;
  font-size: 12.5px;
}

.icon-btn {
  padding: 4px 10px;
  font-size: 12.5px;
  line-height: 1.3;
}

.footer {
  display: none !important;
}

main,
.stage-viewport,
.earth-main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: auto !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.container.page {
  max-width: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 10px 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── 2. パズルゲーム風 盤面＆カードデッキUI ── */
.stage-shell {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px;
  overflow: hidden;
}

.container.page > .stage-shell {
  padding: 0;
}

.stage-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.stage-tab,
.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.stage-tab:hover,
.stage-chip:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--surface-2);
}

.stage-tab.active,
.stage-chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.stage-split {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: 12px;
  overflow: hidden;
  align-items: stretch;
}

.stage-split.cols-home {
  grid-template-columns: 1.25fr 0.95fr;
}

.stage-split.cols-unit {
  grid-template-columns: 200px minmax(0, 1.15fr) minmax(340px, 0.95fr);
}

.stage-split.cols-unit.no-companion,
.stage-split.cols-unit:has(#companion-panel.is-hidden-pane),
.stage-split.cols-unit:has(#companion-panel[hidden]),
.stage-split.cols-unit:not(:has(#companion-panel)) {
  grid-template-columns: 200px minmax(0, 1fr);
}

.stage-split.cols-master-detail {
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.25fr);
}

.stage-split.cols-single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}

.stage-pane {
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--line-strong) 65%, transparent), var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stage-pane-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  min-height: 40px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 13px;
}

.stage-pane-head h1,
.stage-pane-head h2,
.stage-pane-head h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

.stage-pane-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.stage-pane-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.stage-pane-body::-webkit-scrollbar-track {
  background: transparent;
}

.stage-pane-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--line-strong) 80%, transparent);
  border-radius: 999px;
}

@media (max-width: 900px) {
  .visual-map-stage {
    height: 250px;
  }
}

.stage-pane-body::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.stage-pane-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  min-height: 44px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  font-family: var(--sans);
}

.toc.stage-pane .stage-pane-foot {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px 10px;
}

.toc.stage-pane .stage-pane-foot .step-nav-btn {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  padding: 5px 8px;
  text-decoration: none;
}

/* マスター・ディテール左ペイン内の用語行を狭幅向けに最適化 */
.stage-split.cols-master-detail .term-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding: 9px 10px;
}

.stage-split.cols-master-detail .term-row .tr-term {
  grid-column: 1;
}

.stage-split.cols-master-detail .term-row .tr-cat {
  grid-column: 2;
  justify-self: end;
}

.stage-split.cols-master-detail .term-row .tr-reading {
  grid-column: 1 / -1;
}

.stage-split.cols-master-detail .term-row .tr-summary {
  grid-column: 1 / -1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 講義内の目次・地球儀コンパニオンパネルをペイン高さに適合 */
.stage-split.cols-unit .toc {
  position: static;
  top: auto;
  max-height: none;
  height: 100%;
  min-height: 0;
  border-left: 0;
  padding: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.stage-split.cols-unit .toc a {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 2px;
  font-size: 12.5px;
}

.stage-split.cols-unit .toc a:hover {
  background: var(--surface-2);
}

.stage-split.cols-unit .toc a.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}

.stage-split #companion-panel.companion-panel,
.stage-preview-pane {
  position: static;
  top: auto;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--line-strong) 65%, transparent), var(--shadow);
  overflow: hidden;
}

.stage-split #companion-panel .companion-globe-wrap {
  flex: 1 1 auto;
  min-height: 160px;
}

.stage-pane-body .article {
  max-width: none;
}

.stage-pane-body .article h2:first-child,
.stage-pane-body .article h3:first-child,
.stage-pane-body .theme-head:first-child {
  margin-top: 4px;
}

/* ステップインジケータ（パズルステージ風ドット＆カウンタ） */
.step-pips {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.step-pip {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  transition: width 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.step-pip:hover {
  border-color: var(--accent);
}

.step-pip.active {
  width: 24px;
  background: var(--accent);
  border-color: var(--accent);
}

.step-counter {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.step-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--line-strong) 70%, transparent);
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.12s ease, background-color 0.12s ease;
}

.step-nav-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-2);
}

.step-nav-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--line-strong) 70%, transparent);
}

.step-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* ステージセレクトタイル */
.unit-card,
.battle-card,
.stage-tile {
  position: relative;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--line-strong) 55%, transparent);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}

.stage-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}

.stage-tile:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 40%, transparent), var(--shadow);
}

.stage-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  line-height: 1.3;
}

.badge-read {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
}

.unit-card.is-selected,
.battle-card.is-selected,
.stage-tile.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 45%, transparent);
}

/* ステップ・セクション切替用の表示制御 */
.is-hidden-sec,
.is-hidden-step,
.is-hidden-pane {
  display: none !important;
}

/* ── 3. コントローラー／キーボード用 高視認フォーカスリング ── */
:focus {
  outline: none;
}

:focus-visible,
.is-pad-focused {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

.unit-card.is-pad-focused,
.term-row.is-pad-focused,
.earth-list-item.is-pad-focused,
.quiz-opt.is-pad-focused,
.battle-card.is-pad-focused,
.toc a.is-pad-focused,
.stage-tile.is-pad-focused,
.search-hit.is-pad-focused,
.appearance-list a.is-pad-focused {
  background: color-mix(in srgb, var(--accent-soft) 52%, var(--surface));
  border-color: var(--accent);
}

.unit-card.is-pad-focused,
.battle-card.is-pad-focused,
.stage-tile.is-pad-focused,
.quiz-opt.is-pad-focused {
  transform: translateY(-1px);
}

a.term-link:focus-visible,
a.term-link.is-pad-focused {
  border-radius: 5px;
  padding: 0 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border-bottom-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

[data-nav-zone]:focus-within.stage-pane,
[data-nav-zone]:focus-within .stage-pane,
.stage-pane:has(.is-pad-focused) {
  border-color: color-mix(in srgb, var(--accent) 68%, var(--line-strong));
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 35%, transparent), var(--shadow);
}

/* ── 4. ボトム操作ガイドバー ＆ カスタム<select> ＆ 操作一覧モーダル ── */
#control-bar.control-bar {
  flex: 0 0 36px;
  height: 36px;
  min-height: 36px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  background: #1d1a15;
  color: #ece5d6;
  border-top: 1px solid color-mix(in srgb, var(--line-strong) 80%, #000);
  font-family: var(--sans);
  font-size: 12px;
  overflow: hidden;
  z-index: 45;
  user-select: none;
}

:root[data-theme="dark"] #control-bar.control-bar {
  background: #12100d;
  border-top-color: var(--line-strong);
}

.control-hints,
.control-bar-items {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.ctrl-hint,
.control-bar-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.control-bar-item.is-emphasis .control-bar-label {
  color: #f7f2e7;
  font-weight: 700;
}

.ctrl-key,
.control-bar-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  background: #312c24;
  color: #f7f2e7;
  border: 1px solid #595042;
  border-bottom-width: 2px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}

.ctrl-label,
.control-bar-label {
  color: #d6cebe;
  font-size: 11.5px;
}

.control-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.ctrl-mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #2c271f;
  border: 1px solid #595042;
  color: #e09a94;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.ctrl-help-btn,
.control-bar-help-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 6px;
  background: #2c271f;
  border: 1px solid #595042;
  color: #f7f2e7;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}

.ctrl-help-btn:hover,
.control-bar-help-btn:hover {
  border-color: #e09a94;
  background: #383127;
}

/* カスタム<select>ピッカー */
.pad-select-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 12, 8, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.pad-select-menu {
  width: min(400px, 100%);
  max-height: min(70vh, 460px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.36);
}

.pad-select-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
}

.pad-select-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  gap: 4px;
}

.pad-select-opt,
.pad-select-option {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pad-select-opt:hover,
.pad-select-opt.is-pad-focused,
.pad-select-option:hover,
.pad-select-option.is-pad-focused {
  background: var(--surface-2);
  border-color: var(--accent);
}

.pad-select-opt[aria-selected="true"],
.pad-select-opt.is-selected,
.pad-select-option[aria-selected="true"],
.pad-select-option.is-selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* 操作一覧モーダル */
.controls-help-backdrop {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(15, 12, 8, 0.58);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.controls-help-modal {
  width: min(680px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
}

.controls-help-head,
.controls-help-header {
  position: sticky;
  top: 0;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
}

.controls-help-head h2,
.controls-help-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.controls-help-close {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.controls-help-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.controls-help-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 13px;
}

.controls-help-table th,
.controls-help-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.controls-help-table th {
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.controls-help-table tbody tr:last-child td {
  border-bottom: 0;
}

.controls-help-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
}

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

.controls-help-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 12px 14px;
}

.controls-help-section h3 {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.controls-help-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.controls-help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--sans);
  font-size: 12.5px;
}

.controls-help-row .ctrl-key {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

/* ── 5. レスポンシブ（iPad縦画面・モバイル対応・ウィンドウ縦横スクロール完全ゼロ） ── */
@media (hover: none) and (pointer: coarse) {
  a, button, summary, .stage-tab, .stage-chip, .term-link, .b3d-pill, .nav-shoulder-badge {
    touch-action: manipulation;
  }

  .stage-pane-body,
  .topnav,
  .toc {
    -webkit-overflow-scrolling: touch;
  }

  input, select, textarea {
    font-size: 16px;
  }

  .nav-shoulder-badge,
  #control-bar.control-bar {
    display: none !important;
  }
}

@media (max-width: 960px), (max-width: 1100px) and (orientation: portrait) {
  .topbar {
    flex: 0 0 auto;
    height: auto;
    min-height: calc(48px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    gap: 8px;
    flex-wrap: nowrap;
  }

  .brand small {
    display: none;
  }

  .nav-shoulder-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    font-size: 10px;
  }

  .topnav {
    order: 0;
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    gap: 4px;
  }

  .topnav a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 5px 11px;
    font-size: 13px;
  }

  .stage-tab,
  .stage-chip {
    min-height: 34px;
    padding: 5px 12px;
  }

  .container.page,
  .stage-shell {
    padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    gap: 8px;
  }

  .stage-split {
    gap: 10px;
  }

  .stage-split.cols-home {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.1fr) minmax(0, 0.9fr);
  }

  .stage-split.cols-unit,
  .stage-split.cols-unit.no-companion,
  .stage-split.cols-unit:has(#companion-panel.is-hidden-pane),
  .stage-split.cols-unit:has(#companion-panel[hidden]),
  .stage-split.cols-unit:not(:has(#companion-panel)) {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage-split.cols-unit {
    grid-template-rows: auto minmax(0, 1fr) minmax(220px, 0.72fr);
  }

  .stage-split.cols-unit.no-companion,
  .stage-split.cols-unit:has(#companion-panel.is-hidden-pane),
  .stage-split.cols-unit:has(#companion-panel[hidden]),
  .stage-split.cols-unit:not(:has(#companion-panel)) {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .stage-split.cols-unit .toc.stage-pane .stage-pane-head,
  .stage-split.cols-unit .toc.stage-pane .stage-pane-foot {
    display: none;
  }

  .stage-split.cols-unit .toc,
  .stage-split.cols-unit .toc.stage-pane .stage-pane-body {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    height: auto;
    max-height: 48px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 10px;
    margin: 0;
    border-bottom: 0;
  }

  .stage-split.cols-unit .toc .toc-title,
  .stage-split.cols-unit .toc .toc-sub {
    display: none;
  }

  .stage-split.cols-unit .toc a {
    white-space: nowrap;
    margin-bottom: 0;
    padding: 5px 10px;
  }

  .stage-split.cols-master-detail {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(200px, 0.72fr) minmax(0, 1.28fr);
  }

  .stage-pane-head,
  .stage-pane-foot {
    padding: 8px 12px;
  }

  .stage-pane-body {
    padding: 12px 16px;
  }

  .article {
    max-width: 100%;
  }

  .controls-help-grid {
    grid-template-columns: 1fr;
  }

  #control-bar.control-bar {
    padding: 0 8px;
    gap: 6px;
  }

  .control-hints,
  .control-bar-items {
    gap: 8px;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .ctrl-hint[data-priority="low"],
  .ctrl-hint:nth-child(n+4),
  .control-bar-item:nth-child(n+4) {
    display: none;
  }
}

/* ── 6. 印刷対応（高さ固定解除・全節/全ステップ展開・操作UI非表示） ── */
@media print {
  html,
  body,
  #app,
  main,
  .stage-viewport,
  .container.page,
  .stage-shell,
  .stage-split,
  .stage-pane,
  .stage-pane-body {
    height: auto !important;
    max-height: none !important;
    width: auto !important;
    max-width: none !important;
    overflow: visible !important;
    display: block !important;
    position: static !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .is-hidden-sec,
  .is-hidden-step {
    display: block !important;
  }

  .topbar,
  #control-bar,
  .stage-toolbar,
  .stage-pane-head,
  .stage-pane-foot,
  #companion-panel,
  .stage-preview-pane,
  .toc,
  .pad-select-backdrop,
  .controls-help-backdrop {
    display: none !important;
  }
}
