:root {
  --navy: #17324d;
  --blue: #2878b5;
  --red: #bd3b3b;
  --orange: #d97706;
  --green: #2f855a;
  --purple: #7552a6;
  --paper: #f4f3ee;
  --ink: #183042;
  --muted: #5b6d79;
  --line: #ccd9e1;
  --card: #fff;
  --soft-blue: #eaf5fb;
  --soft-red: #fdecec;
  --soft-orange: #fff4df;
  --soft-green: #eaf7ef;
  --soft-purple: #f3edfb;
  --soft-navy: #e8eff4;
  --yellow: #fff7c7;
  --shadow: 0 8px 24px #17324d12;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.75;
}
a { color: inherit; }
button, input, select { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #f1b51c; outline-offset: 3px; }

.version-bar {
  background: #0f2538;
  color: #fff;
  min-height: 38px;
  padding: 7px max(16px, env(safe-area-inset-left));
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .03em;
}
.site-header { background: var(--navy); color: #fff; padding: 24px max(18px, env(safe-area-inset-left)); }
.site-header__inner, .tabs__inner, .page, .site-footer__inner { width: min(760px, 100%); margin: auto; }
.eyebrow { margin: 0; color: #add9f3; font-size: 14px; font-weight: 900; }
.site-title { margin: 5px 0 7px; font-size: clamp(25px, 7vw, 39px); line-height: 1.35; }
.site-lead { margin: 0; color: #e3eef4; font-size: 15px; }

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fffffff5;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.tabs__inner { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 12px; }
.tab, .button {
  display: inline-grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid #9cb0be;
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  text-decoration: none;
  font-weight: 900;
  cursor: pointer;
}
.tab[aria-selected="true"], .button.primary, .button.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.page { padding: 20px 16px 58px; }
.view[hidden], .answer[hidden] { display: none; }
.section-title { margin: 4px 0 14px; font-size: 22px; line-height: 1.45; }
.lead {
  margin: 0 0 17px;
  padding: 14px 16px;
  border: 1px solid #e4cf55;
  border-radius: 14px;
  background: var(--yellow);
  font-weight: 800;
}

.scenario {
  padding: 18px;
  border: 2px solid var(--navy);
  border-radius: 18px;
  background: var(--soft-navy);
  box-shadow: var(--shadow);
}
.scenario h3 { margin: 0 0 10px; font-size: 20px; line-height: 1.5; }
.scenario ul, .content-card ul { margin: 0; padding-left: 1.35em; }
.scenario li, .content-card li { margin: 4px 0; }
.flow-arrow { margin: 10px 0; color: #7895a9; text-align: center; font-size: 28px; line-height: 1; }
.content-list { display: grid; gap: 12px; }
.content-card {
  --accent: var(--blue);
  --soft: var(--soft-blue);
  position: relative;
  padding: 15px 16px;
  border: 2px solid var(--accent);
  border-radius: 16px;
  background: var(--soft);
  box-shadow: var(--shadow);
}
.content-card h3 { margin: 0 0 7px; color: var(--accent); font-size: 19px; line-height: 1.45; }
.tone-red { --accent: var(--red); --soft: var(--soft-red); }
.tone-blue { --accent: var(--blue); --soft: var(--soft-blue); }
.tone-orange { --accent: var(--orange); --soft: var(--soft-orange); }
.tone-green { --accent: var(--green); --soft: var(--soft-green); }
.tone-purple { --accent: var(--purple); --soft: var(--soft-purple); }
.tone-navy { --accent: var(--navy); --soft: var(--soft-navy); }
.level-1 { margin-left: 18px; }
.level-2 { margin-left: 36px; }
.level-1 h3::before, .level-2 h3::before { content: "↳ "; }

.structure-key {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: -3px 0 14px;
  color: var(--navy);
  font-weight: 900;
}
.structure-key span {
  flex: 0 0 auto;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
}
.relation-lanes { display: grid; gap: 9px; margin: 12px 0; }
.relation-lane { padding: 11px 12px; border: 2px solid var(--navy); border-radius: 13px; background: #fff; }
.relation-lane > strong { display: block; margin-bottom: 6px; color: var(--navy); font-size: 14px; }
.relation-lane > div { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.relation-node { padding: 4px 7px; border-radius: 8px; background: var(--soft-blue); font-weight: 800; }
.relation-arrow { color: var(--blue); font-size: 20px; font-weight: 900; }
.map-check-note { margin: 12px 0; padding: 14px; border: 2px solid var(--red); border-radius: 14px; background: var(--soft-red); }
.map-check-note strong { color: var(--red); font-size: 18px; }
.map-check-note p { margin: 4px 0 10px; }
.map-check-note .button { width: 100%; background: #fff; }
.step-number {
  display: grid;
  position: absolute;
  top: 13px;
  left: -17px;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

/* 手順：一本の線上に工程を置く */
.layout-flow { position: relative; gap: 16px; padding-left: 18px; }
.layout-flow::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 17px;
  width: 3px;
  background: #a9becb;
}
.layout-flow .content-card { margin-left: 16px; }

/* 計算：式を一段ずつ積み上げる */
.layout-formula { gap: 10px; padding-left: 18px; counter-reset: formula; }
.layout-formula .content-card { margin-left: 16px; border-radius: 10px; box-shadow: 4px 4px 0 #b8c8d2; }
.layout-formula .content-card:not(:last-child)::after {
  content: "↓ 次の式へ";
  display: block;
  position: absolute;
  right: 8px;
  bottom: -22px;
  z-index: 2;
  padding: 0 7px;
  background: var(--paper);
  color: #6f8797;
  font-size: 13px;
  font-weight: 900;
}
.layout-formula .content-card h3 { padding-right: 4px; }
.layout-formula .content-card li { font-family: "Yu Gothic", sans-serif; font-weight: 700; }

/* 比較：同じ高さの欄を左右に並べる */
.layout-compare { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.layout-compare .content-card { min-width: 0; padding: 13px 11px; box-shadow: none; }
.layout-compare .content-card h3 { font-size: 17px; }
.layout-compare .content-card li { overflow-wrap: anywhere; }
.layout-compare .content-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
.layout-compare .wide-card { grid-column: 1 / -1; }

/* 階層：枝線と字下げで親子関係を残す */
.layout-hierarchy { gap: 9px; }
.layout-hierarchy .content-card { box-shadow: none; }
.layout-hierarchy .level-0 { border-width: 3px; }
.layout-hierarchy .level-1, .layout-hierarchy .level-2 { position: relative; }
.layout-hierarchy .level-1::before, .layout-hierarchy .level-2::before {
  content: "";
  position: absolute;
  top: -11px;
  bottom: 50%;
  left: -20px;
  width: 17px;
  border-bottom: 3px solid #91a8b6;
  border-left: 3px solid #91a8b6;
}

/* システム：部品を盤面に置き、一覧ではなく関係図として読む */
.layout-system {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  border: 2px dashed #8fa8b7;
  border-radius: 18px;
  background: linear-gradient(90deg, transparent 49.5%, #c9d6de 49.5%, #c9d6de 50.5%, transparent 50.5%);
}
.layout-system .content-card { min-width: 0; padding: 13px 11px; box-shadow: 0 4px 12px #17324d18; }
.layout-system .content-card h3 { font-size: 17px; }
.layout-system .content-card li { overflow-wrap: anywhere; }

/* 層：重なりで上位・下位を示す */
.layout-layers { gap: 7px; padding: 0 7px; }
.layout-layers .content-card { border-radius: 8px; text-align: center; box-shadow: 0 5px 0 #c2d0d8; }
.layout-layers .content-card:nth-child(2n) { margin-inline: 10px; }
.layout-layers .content-card:nth-child(3n) { margin-inline: 20px; }
.layout-layers .content-card ul { display: inline-block; text-align: left; }

/* 観点表：見出しと説明を左右のセルとして読む */
.layout-table { gap: 0; overflow: hidden; border: 2px solid var(--navy); border-radius: 15px; background: #fff; }
.layout-table .content-card {
  display: grid;
  grid-template-columns: minmax(92px, 35%) 1fr;
  gap: 10px;
  align-items: start;
  border: 0;
  border-bottom: 1px solid #b9cbd6;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}
.layout-table .content-card:last-child { border-bottom: 0; }
.layout-table .content-card h3 { margin: 0; font-size: 17px; }
.layout-table .content-card ul { padding-left: 1.15em; }

.decision {
  margin-top: 16px;
  padding: 18px;
  border: 3px solid var(--red);
  border-radius: 17px;
  background: var(--soft-red);
  text-align: center;
}
.decision strong { display: block; color: var(--red); font-size: 22px; line-height: 1.5; }
.decision p { margin: 8px 0 0; font-weight: 700; }
.summary { margin-top: 18px; padding: 15px 16px; border-left: 6px solid var(--navy); background: #e8eff3; font-weight: 800; }

.recall-intro, .map-help { margin: 0 0 15px; color: var(--muted); }
.progress { margin-bottom: 16px; font-weight: 900; }
.progress-track { height: 10px; overflow: hidden; border-radius: 999px; background: #dce5ea; }
.progress-bar { width: 0; height: 100%; background: var(--green); transition: width .2s ease; }
.recall-list { display: grid; gap: 13px; }
.recall-card { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow); }
.recall-card h3 { margin: 0 0 8px; font-size: 18px; line-height: 1.55; }
.recall-card p { margin: 0; }
.reveal { width: 100%; margin-top: 13px; background: var(--navy); border-color: var(--navy); color: #fff; }
.answer { margin-top: 12px !important; padding: 12px 13px; border-radius: 10px; background: var(--soft-blue); font-weight: 800; }

.map-mode, .zoom-controls { display: flex; gap: 8px; margin-bottom: 10px; }
.map-mode .button, .zoom-controls .button { flex: 1; padding: 6px; }
.fullscreen-toggle { display: none; }
.map-viewport {
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.map-viewport img { display: block; width: var(--map-width, 100%); max-width: none; height: auto; }
.map-caption { margin: 10px 2px 0; color: var(--muted); font-size: 14px; }

#view-map:fullscreen {
  width: 100%;
  padding: 12px;
  overflow: auto;
  background: var(--paper);
}
#view-map:fullscreen .section-title,
#view-map:fullscreen .map-help,
#view-map:fullscreen .map-caption { display: none; }
#view-map:fullscreen .map-viewport { max-height: calc(100vh - 84px); }

.unit-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 22px; }
.unit-nav .button { padding: 7px 9px; text-align: center; }
.unit-nav .wide { grid-column: 1 / -1; }

.hub-header { background: var(--navy); color: #fff; padding: 44px 18px 38px; }
.hub-header__inner, .hub-main { width: min(980px, 100%); margin: auto; }
.hub-header h1 { margin: 7px 0 12px; font-size: clamp(30px, 9vw, 52px); line-height: 1.25; }
.hub-header p { margin: 0; color: #e3eef4; }
.hub-main { padding: 26px 16px 60px; }
.hub-notice { padding: 15px 16px; border-left: 6px solid var(--green); background: var(--soft-green); font-weight: 800; }
.unit-grid { display: grid; gap: 14px; margin-top: 22px; }
.unit-card { display: flex; flex-direction: column; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { padding: 3px 9px; border-radius: 999px; background: var(--soft-blue); font-size: 13px; font-weight: 900; }
.unit-card h2, .unit-card h3 { margin: 11px 0 6px; font-size: 21px; line-height: 1.45; }
.unit-card p { margin: 0 0 15px; color: var(--muted); flex: 1; }
.hub-actions { display: grid; gap: 9px; }
.domain-jumps { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 22px 0 30px; }
.domain-block { scroll-margin-top: 12px; margin-top: 42px; }
.domain-heading { padding: 17px 18px; border-left: 7px solid var(--blue); border-radius: 12px; background: #fff; }
.domain-heading span { color: var(--blue); font-weight: 900; }
.domain-heading h2 { margin: 3px 0; font-size: 23px; line-height: 1.45; }
.domain-heading p { margin: 0; color: var(--muted); }
.domain-status { margin-top: 28px; padding: 18px; border: 1px dashed #9badb9; border-radius: 14px; background: #fff; }
.domain-status h2 { margin: 0 0 8px; font-size: 20px; }
.domain-status p { margin: 0; color: var(--muted); }
.site-footer { background: #10273b; color: #dce7ee; padding: 26px 18px; }
.site-footer p:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 8px; color: #fff; }

.error { padding: 24px; border-radius: 15px; background: #fff; }

@media (min-width: 640px) {
  .page { padding-top: 28px; }
  .content-list:not(.layout-flow):not(.layout-formula):not(.layout-hierarchy):not(.layout-layers):not(.layout-table) { grid-template-columns: 1fr 1fr; }
  .content-card.level-1, .content-card.level-2 { grid-column: 1 / -1; }
  .unit-grid { grid-template-columns: 1fr 1fr; }
  .hub-actions { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  #view-map {
    position: relative;
    left: 50%;
    width: min(1280px, calc(100vw - 48px));
    transform: translateX(-50%);
  }
  #view-map:fullscreen { left: 0; transform: none; }
  .fullscreen-toggle { display: inline-grid; }
  .map-toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(460px, 2fr);
    gap: 8px;
    margin-bottom: 10px;
  }
  .map-toolbar .map-mode,
  .map-toolbar .zoom-controls { margin-bottom: 0; }
  .map-viewport { max-height: calc(100vh - 190px); }
  .map-viewport[data-zoom="100"] {
    display: grid;
    place-items: center;
  }
  .map-viewport[data-zoom="100"] img {
    width: auto;
    max-width: 100%;
    max-height: calc(100vh - 190px);
    margin: auto;
  }
  #view-map:fullscreen .map-viewport[data-zoom="100"] img {
    max-height: calc(100vh - 84px);
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .progress-bar { transition: none; }
}
