:root {
  color-scheme: light;
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-border: #d9dee8;
  --color-text: #202632;
  --color-text-muted: #5b6472;
  --color-primary: #2f5fd6;
  --color-primary-hover: #24439e;
  --color-danger: #c0392b;
  --color-success: #1e8e58;
  --color-chart-accent: #c9601f;
  --color-primary-soft: #e7edfc;
  --color-chart-accent-soft: #f7e7d8;
  --color-chart-accent-ink: #5a3312;
  font-family: 'Hiragino Sans', 'Yu Gothic', 'Segoe UI', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-header__title {
  font-weight: 700;
}

.app-header__user {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.app-main {
  flex: 1;
  padding: 0;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}

.app-main--flush-left {
  max-width: none;
  margin: 0;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
}

/* ホーム画面のシナリオ一覧(9.1章) */
.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 720px) {
  .scenario-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- 受講者セクション共通レイアウト(演習サイドバー) ---- */

.exercise-sidebar__toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: transparent;
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.exercise-sidebar__toggle:hover {
  background: var(--color-bg);
}

.exercise-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.exercise-menu-modal {
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 10px;
  padding: 1rem;
  width: 100%;
  max-width: 320px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

/* 「他のシナリオ」を2×2カードで見せるため、通常のナビゲーションメニューより
   目一杯まで横幅を使う特別レイアウト。ヘッダーは固定し、左のシナリオ内メニューだけを
   独立したスクロール領域にする(右のカードは1ページ4枚のカルーセルなのでスクロール不要)。 */
.exercise-menu-modal--wide {
  max-width: 96vw;
  width: 96vw;
  height: calc(100vh - 3rem);
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.exercise-menu-modal--wide .exercise-menu-modal__header {
  flex: none;
}

.exercise-menu-modal__body {
  display: flex;
  align-items: stretch;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
}

.exercise-menu-modal__primary {
  flex: none;
  width: 320px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.exercise-menu-modal__secondary {
  flex: 1;
  min-width: 0;
  padding-left: 1.5rem;
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.exercise-menu-modal__card-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 1.25rem;
}

.exercise-menu-modal__card-grid .exercise-menu-modal__scenario-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.85rem;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.exercise-menu-modal__card-grid a.exercise-menu-modal__scenario-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
  border-color: var(--color-primary);
}

.exercise-menu-modal__scenario-card--disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.exercise-menu-modal__scenario-card__id {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.exercise-menu-modal__scenario-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  flex: 1;
}

.exercise-menu-modal__scenario-card__badge {
  align-self: flex-start;
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--color-border);
  color: var(--color-text-muted);
}

.exercise-menu-modal__scenario-card__badge--ready {
  background: var(--color-primary);
  color: #fff;
}

.exercise-menu-modal__carousel-nav {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.exercise-menu-modal__carousel-dots {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.exercise-menu-modal__carousel-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-border);
  cursor: pointer;
}

.exercise-menu-modal__carousel-dot.is-active {
  background: var(--color-primary);
}

@media (max-width: 900px) {
  .exercise-menu-modal--wide {
    width: 100%;
    max-width: none;
  }

  .exercise-menu-modal__body {
    flex-direction: column;
    overflow-y: auto;
  }

  .exercise-menu-modal__primary {
    width: 100%;
    flex: none;
    max-height: 240px;
  }

  .exercise-menu-modal__secondary {
    padding-left: 0;
    border-left: none;
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
  }

  .exercise-menu-modal__card-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
}

.exercise-menu-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.exercise-menu-modal__header h2 {
  margin: 0;
  font-size: 1rem;
}

.exercise-menu-modal ul {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.exercise-menu-modal__group {
  margin-top: 1rem;
}

.exercise-menu-modal__group-title {
  margin: 0 0 0.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
}

.exercise-menu-modal__group ul {
  margin-top: 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--color-border);
}

.exercise-menu-modal a {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9rem;
}

.exercise-menu-modal a:hover {
  background: var(--color-bg);
}

.exercise-menu-modal a.is-active {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
}

@media (max-width: 720px) {
  .exercise-menu-modal {
    max-width: none;
  }
}

.btn {
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
}

.btn:hover {
  background: var(--color-primary-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn--small {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.btn--outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn--danger-outline {
  background: transparent;
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

/* ---- 汎用フォームモーダル(運営者/テナント管理画面の編集ダイアログ等) ---- */

.op-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.op-modal {
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 10px;
  padding: 1.25rem;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.op-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.op-modal__header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.op-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* テナント編集モーダルの読み取り専用サマリー(発行日・コード・管理者ID・プラン等)。
   一覧に表示されている項目を、編集不可のものも含めてすべてここで参照できるようにする。 */
.op-modal__summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem 1rem;
  margin: 0 0 1rem;
  padding: 0.75rem;
  background: var(--color-bg);
  border-radius: 8px;
  font-size: 0.85rem;
}

.op-modal__summary dt {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.op-modal__summary dd {
  margin: 0.1rem 0 0;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.form-field label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.form-field input {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
}

.alert {
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert--error {
  background: #fdecea;
  color: var(--color-danger);
}

.alert--success {
  background: #e8f6ef;
  color: var(--color-success);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.swot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.swot-quadrant {
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  padding: 0.75rem;
  min-height: 140px;
}

.swot-quadrant h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.swot-quadrant.is-dragover {
  border-color: var(--color-primary);
  background: #eef2fd;
}

/* PEST・3C分析(SWOTと同じカード分類型)で使う汎用版 */
.card-sort-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.card-sort-grid--cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.card-sort-quadrant {
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  padding: 0.75rem;
  min-height: 140px;
}

.card-sort-quadrant h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

@media (max-width: 720px) {
  .card-sort-grid--cols-3 {
    grid-template-columns: 1fr;
  }
}

.exercise-card-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.exercise-card {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  background: #fff;
  cursor: grab;
  font-size: 0.85rem;
  max-width: 220px;
}

.exercise-card.is-correct {
  border-color: var(--color-success);
  background: #e8f6ef;
}

.exercise-card.is-incorrect {
  border-color: var(--color-danger);
  background: #fdecea;
}

/* ---- ビジネスモデルキャンバス(BMC, キャンバス型演習) ---- */

.bmc-canvas {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: auto auto auto;
  grid-template-areas:
    'kp ka vp cr cs'
    'kp kr vp ch cs'
    'cost cost cost rev rev';
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.bmc-block {
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  padding: 0.6rem;
  min-height: 110px;
}

.bmc-block h3 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.bmc-block--key_partners { grid-area: kp; }
.bmc-block--key_activities { grid-area: ka; }
.bmc-block--key_resources { grid-area: kr; }
.bmc-block--value_propositions { grid-area: vp; background: #f6f8fe; }
.bmc-block--customer_relationships { grid-area: cr; }
.bmc-block--channels { grid-area: ch; }
.bmc-block--customer_segments { grid-area: cs; }
.bmc-block--cost_structure { grid-area: cost; }
.bmc-block--revenue_streams { grid-area: rev; }

/* 友情ジャーニーマップ(AioExerciseView.js, case_tomodachi)用のシンプルな5段階グリッド。
   BMCと違い名前付きgrid-template-areasは使わず、exercise.blocksの並び順(接触前→…→
   継続的な関係)のまま左から右に自動配置する。ブロック自体の見た目は.bmc-blockを共用する。 */
.journey-canvas {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 720px) {
  .journey-canvas {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .bmc-canvas {
    grid-template-columns: 1fr;
    grid-template-areas:
      'kp'
      'ka'
      'kr'
      'vp'
      'cr'
      'ch'
      'cs'
      'cost'
      'rev';
  }
}

/* ---- 4P/4C(パネル型演習) ---- */

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.panel-block {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.9rem;
  background: #fff;
}

.panel-block h3 {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- 経営シミュレーション(F-03) ---- */

.sim-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.sim-kpi-grid dt {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.15rem;
}

.sim-kpi-grid dd {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

/* ---- 経営シミュレーション振り返り(フェーズ5): KPI推移グラフ ---- */

.review-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 5px;
  margin-bottom: 5px;
}

.review-chart-card {
  min-width: 0;
}

.review-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.review-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.review-legend__swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.review-legend__swatch--dashed {
  width: 14px;
  height: 0;
  border-radius: 0;
  border-top: 2px dashed var(--color-text-muted);
}

.review-chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.review-chart__gridline {
  stroke: var(--color-border);
  stroke-width: 1;
}

.review-chart__target-line {
  stroke: var(--color-text-muted);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.review-chart__line {
  fill: none;
  stroke-width: 2;
}

.review-chart__axis-label {
  fill: var(--color-text-muted);
  font-size: 10px;
}

/* ---- 演習画面の左右分割(左1/3: ヒント・前回の演習内容 / 右2/3: 演習本体) ---- */

.exercise-split {
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

.exercise-hint-panel {
  flex: 0 0 calc(33% + 15px);
  margin-left: 5px;
  margin-top: 5px;
  height: calc(100vh - 4.5rem - 5px);
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  padding-bottom: 4.5rem;
  position: sticky;
  top: 1.5rem;
}

/* マスコット「マーケン」がヒント/Tipsパネルの左下からサポートしてくれる装飾(クリック操作の邪魔はしない) */
.exercise-hint-panel::after {
  content: '';
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  width: 64px;
  height: 64px;
  background-image: url('/images/マー犬-正面.jpeg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: left bottom;
  pointer-events: none;
}

.exercise-hint-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.exercise-hint-panel h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.exercise-hint-panel p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--color-text);
  margin: 0 0 0.5rem;
}

.exercise-hint-panel__summary-block {
  margin-bottom: 0.75rem;
}

.exercise-hint-panel__summary-block strong {
  display: block;
  font-size: 0.8rem;
  color: var(--color-primary);
  margin-bottom: 0.2rem;
}

.exercise-hint-panel__summary-block ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.exercise-main-panel {
  flex: 1;
  min-width: 0;
  height: calc(100vh - 4.5rem);
  overflow-y: auto;
  padding-top: 5px;
  padding-right: 5px;
}

.exercise-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.exercise-panel-header h1 {
  margin: 0;
}

.exercise-panel-header__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .exercise-split {
    flex-direction: column;
  }

  .exercise-hint-panel {
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    margin-left: 0;
    /* sticky解除が目的で、::after(マーケン)の配置基準としては position: relative で維持する */
    position: relative;
  }

  .exercise-main-panel {
    height: auto;
    padding-right: 0;
  }
}

/* ---- 会話パート(ビジュアルノベルUI, F-13) ---- */

.story-layout {
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

.story-tips-panel {
  flex: 1 1 0%;
  min-width: 240px;
  margin-left: 5px;
  margin-top: 5px;
  height: calc(100vh - 4.5rem - 5px);
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  position: sticky;
  top: 1.5rem;
}

.story-tips-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.story-tips-panel dl {
  margin: 0;
}

.story-tips-panel dt {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary);
}

.story-tips-panel dd {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.story-tips-panel dt:not(:first-child) {
  margin-top: 0.9rem;
}

.story-stage-panel {
  flex: 0 0 auto;
  width: min(100%, calc((100vh - 4.5rem) * 16 / 9));
  display: flex;
  justify-content: flex-end;
  padding-top: 5px;
  padding-right: 5px;
}

@media (max-width: 900px) {
  .story-layout {
    flex-direction: column;
  }

  .story-tips-panel {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: auto;
    max-height: none;
    margin-left: 0;
    position: static;
  }

  .story-stage-panel {
    width: 100%;
    justify-content: center;
  }
}

.vn-stage {
  position: relative;
  width: min(100%, calc((100vh - 4.5rem) * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background-color: #1c2331;
  background-size: cover;
  background-position: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.vn-characters {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.vn-character {
  position: absolute;
  bottom: 0;
  height: 88%;
  display: flex;
  align-items: flex-end;
}

.vn-character img {
  height: 100%;
  width: auto;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25));
}

.vn-character--left {
  left: 4%;
}

.vn-character--center {
  left: 50%;
  transform: translateX(-50%);
}

.vn-character--right {
  right: 4%;
}

/* 複数人が描かれた場面絵(会議・商談・指摘)。個別の立ち絵と違い画像ごとに縦横比が異なるため、
   幅92%・高さ85%の枠を用意し、枠内に収まるよう縮小して(はみ出し・見切れを防ぐ)下端中央に置く。 */
.vn-character--group {
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  height: 85%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.vn-character--group img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.vn-window {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 30%;
  padding: 0.75rem 1.25rem 1.1rem;
  background: linear-gradient(to top, rgba(10, 14, 24, 0.92), rgba(10, 14, 24, 0.78));
  color: #f2f4f8;
  cursor: pointer;
}

.vn-window__toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.vn-icon-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #f2f4f8;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}

.vn-window__speaker {
  display: inline-block;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.15rem 0.75rem;
  margin-bottom: 0.4rem;
  background: var(--color-primary);
  border-radius: 4px;
}

.vn-window__body {
  font-size: 1rem;
  line-height: 1.6;
  min-height: 3.2em;
  white-space: pre-wrap;
}

.vn-caret {
  animation: vn-blink 0.9s steps(1) infinite;
}

@keyframes vn-blink {
  50% {
    opacity: 0;
  }
}

.vn-window__next-hint {
  margin-top: 0.5rem;
  text-align: right;
  font-size: 0.8rem;
  color: rgba(242, 244, 248, 0.7);
}

.vn-choices {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.vn-choice-btn {
  background: rgba(255, 255, 255, 0.95);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.vn-choice-btn:hover {
  background: #fff;
  border-color: var(--color-primary);
}

.vn-backlog-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.vn-backlog {
  background: #fff;
  color: var(--color-text);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  max-height: 85%;
  width: 100%;
  max-width: 480px;
  overflow-y: auto;
}

.vn-backlog__entry {
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.vn-backlog__entry strong {
  display: block;
  color: var(--color-primary);
  margin-bottom: 0.15rem;
}

/* ---- 単元ごとに練習モーダル(ホーム画面) ---- */

.unit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.unit-modal {
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 960px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.unit-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.unit-modal__header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.unit-modal__list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.unit-modal__list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

/* ---- ヘッダーの「教材」ボタンから開く参考資料モーダル ----
   横幅を1:5(サイドバー:本文)で分割する。各カラムは
   flex-basis 0 + flex-growの比率で残り幅を配分し、独立してスクロールする。
   モーダル自体は画面いっぱいに表示する(position:fixed; inset:0で
   .exercise-menu-modal--wideの余白付きサイズを上書き)。 */

.materials-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

.materials-modal__body {
  display: flex;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.materials-modal__sidebar {
  flex: 1 1 0;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-right: 1rem;
}

.materials-modal__sidebar-item {
  text-align: left;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text);
  padding: 0.55rem 0.65rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.materials-modal__sidebar-item:hover {
  background: var(--color-bg);
}

.materials-modal__sidebar-item.is-active {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
}

.materials-modal__sidebar-group {
  display: flex;
  flex-direction: column;
}

.materials-modal__sidebar-subitems {
  list-style: none;
  margin: 0.15rem 0 0.5rem;
  padding: 0 0 0 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.materials-modal__sidebar-subitem {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 4px;
  background: transparent;
  padding: 0.1rem 0.35rem;
  margin: 0 -0.35rem;
  font-size: 0.64rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

button.materials-modal__sidebar-subitem {
  cursor: pointer;
}

button.materials-modal__sidebar-subitem:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

button.materials-modal__sidebar-subitem.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 700;
}

.materials-modal__sidebar-subitem--disabled {
  color: var(--color-text-muted);
  opacity: 0.6;
  cursor: default;
}

.materials-modal__back {
  display: inline-block;
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-size: 0.85rem;
  padding: 0;
  margin-bottom: 1rem;
  cursor: pointer;
}

.materials-modal__back:hover {
  text-decoration: underline;
}

.materials-modal__text {
  flex: 5 1 0;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 0 1.25rem;
  border-left: 1px solid var(--color-border);
  font-size: 0.92rem;
  line-height: 1.7;
}

.materials-modal__text h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.35rem;
}

.materials-modal__text h3:first-child {
  margin-top: 0;
}

.materials-modal__text h4 {
  margin: 1.25rem 0 0.4rem;
  font-size: 0.95rem;
  color: var(--color-primary);
}

.materials-modal__text h5 {
  margin: 1rem 0 0.35rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.materials-modal__text p {
  margin: 0.5rem 0;
}

.materials-modal__text p.material-note {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.materials-modal__text ul {
  list-style: disc;
  margin: 0.5rem 0;
  padding-left: 1.4rem;
  display: block;
}

.materials-modal__text li {
  margin: 0.3rem 0;
}

.materials-modal__text hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.5rem 0;
}

.materials-modal__text strong {
  font-weight: 700;
}

.materials-modal__visuals {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.material-visual {
  margin: 0;
}

.material-diagram {
  margin: 1.25rem 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.25rem 1rem;
  overflow-x: auto;
}

.material-diagram figcaption {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.material-diagram svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 50vh;
  min-width: 560px;
}

.material-visual figcaption {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.material-table-wrap {
  overflow-x: auto;
}

.material-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

.material-table th,
.material-table td {
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.material-table th {
  background: var(--color-bg);
}

@media (max-width: 900px) {
  .materials-modal__body {
    flex-direction: column;
    overflow-y: auto;
  }

  .materials-modal__sidebar {
    flex: none;
    flex-direction: row;
    flex-wrap: wrap;
    overflow-y: visible;
    padding-right: 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
  }

  .materials-modal__sidebar-item {
    border: 1px solid var(--color-border);
    border-radius: 999px;
  }

  .materials-modal__text {
    flex: none;
    border-left: none;
    padding: 1rem 0;
    overflow-y: visible;
  }
}
