@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;700&family=Inter:wght@400;600;700&family=Zen+Kaku+Gothic+New:wght@400;500;700&display=swap');

:root {
  color-scheme: light;
  
  /* 艦船局 カラーパレット */
  --navy-deep: #06131e;
  --navy: #0b1f30;
  --navy-surface: #102a40;
  --slate: #4f6879;
  --slate-light: #8fa5b4;
  --ink: #1c2b36;
  --ink-sub: #4b6170;
  
  --cyan-core: #00e5ff;
  --cyan-glow: rgba(0, 229, 255, 0.15);
  --blue-accent: #007799;
  
  --bg-wash: #f4f8fa;
  --paper: #ffffff;
  --line-subtle: #dce7ec;
  --line-crisp: #b8cdd6;

  /* フォントスタック */
  --font-sans: "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
  --font-en: "Chakra Petch", "Inter", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
}

body {
  margin: 0;
  background-color: var(--bg-wash);
  /* 艦船局の設計端末を思わせる微細なグリッドパターン */
  background-image: 
    linear-gradient(to right, rgba(0, 119, 153, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 119, 153, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 2.1;
  letter-spacing: 0.04em;
  -webkit-font-smoothing: antialiased;
}

/* リンク */
a {
  color: var(--blue-accent);
  text-underline-offset: 0.35em;
  text-decoration-thickness: 1px;
  transition: all 0.2s ease;
}
a:hover {
  color: var(--navy);
}

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--cyan-core);
  outline-offset: 3px;
}

/* アクセシビリティ用スキップリンク */
.skip {
  position: fixed;
  top: -100px;
  left: 16px;
  background: var(--navy);
  color: #fff;
  padding: 8px 16px;
  z-index: 999;
  font-family: var(--font-en);
}
.skip:focus {
  top: 16px;
}

/* ==========================================================================
   Header (艦船局オペレーションバー) ※めり込み解消版
   ========================================================================== */
.topbar {
  min-height: 76px;
  height: auto;
  background: rgba(6, 19, 30, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 40px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(0, 229, 255, 0.2);
}

.brand {
  font-family: var(--font-en);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  text-decoration: none;
  line-height: 1.1;
  display: block; /* 縦積みにならず横一列で自然に配置 */
  white-space: nowrap;
}

.brand > span {
  color: var(--cyan-core);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
  margin: 0 1px;
}

.brand small {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--slate-light);
  margin-top: 5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 28px;
}

.version {
  font-family: var(--font-en);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--slate-light);
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.sheet-link {
  font-family: var(--font-en);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  border: 1px solid rgba(0, 229, 255, 0.4);
  background: rgba(0, 229, 255, 0.05);
  padding: 8px 16px;
  transition: all 0.2s ease;
  position: relative;
}
.sheet-link span {
  margin-left: 8px;
  color: var(--cyan-core);
}
.sheet-link:hover {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--cyan-core);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.25);
}

/* ==========================================================================
   Layout (サイドバー ＋ メイン領域)
   ========================================================================== */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  max-width: 1560px;
  margin: 0 auto;
}

/* サイドバー */
.sidebar {
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  padding: 44px 24px 28px;
  background: #f8fafb;
  border-right: 1px solid var(--line-subtle);
  display: flex;
  flex-direction: column;
}

.side-label {
  font-family: var(--font-en);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--slate);
  font-weight: 700;
  margin-bottom: 20px;
  text-transform: uppercase;
}

.sidebar nav {
  display: grid;
  gap: 4px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 9px 14px;
  text-decoration: none;
  color: var(--ink-sub);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}
.sidebar nav a > span {
  font-family: var(--font-en);
  font-size: 12px;
  color: var(--slate-light);
  letter-spacing: 0.05em;
}
.sidebar nav a:hover {
  color: var(--navy);
  background: #eef3f6;
  border-left-color: var(--slate-light);
}
.sidebar nav a[aria-current="page"] {
  background: #ffffff;
  border-left-color: var(--blue-accent);
  color: var(--navy);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.sidebar nav a[aria-current="page"] > span {
  color: var(--blue-accent);
  font-weight: 700;
}

.side-bottom {
  font-size: 11.5px;
  color: var(--slate);
  line-height: 1.7;
  margin-top: auto;
  padding: 24px 14px 0;
  border-top: 1px dashed var(--line-subtle);
}
.side-bottom span {
  font-family: var(--font-en);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--slate-light);
}

/* ==========================================================================
   Main Content & Typography (ノベルゲーム風タイポグラフィ)
   ========================================================================== */
main {
  min-width: 0;
  background: var(--paper);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.02);
}

.page-heading {
  padding: 64px 72px 52px;
  border-bottom: 1px solid var(--line-subtle);
  background: #ffffff;
  position: relative;
}

/* 上部の極細サイバーアクセントライン */
.page-heading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan-core) 0%, var(--blue-accent) 40%, transparent 100%);
}

.eyebrow {
  font-family: var(--font-en);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--blue-accent);
  text-transform: uppercase;
  display: inline-block;
}

h1 {
  font-size: clamp(2rem, 3.2vw, 2.75rem);
  line-height: 1.35;
  letter-spacing: 0.06em;
  margin: 18px 0 20px;
  font-weight: 700;
  color: var(--navy);
}

.page-heading > p {
  max-width: 680px;
  color: var(--ink-sub);
  font-size: 15px;
  line-height: 1.95;
  margin: 0;
}

.reading-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 60px;
  padding: 16px 56px 64px 72px;
}

article {
  min-width: 0;
  max-width: 820px;
}

section {
  padding: 52px 0 28px;
  border-bottom: 1px solid var(--line-subtle);
}

h2 {
  font-size: 1.45rem;
  letter-spacing: 0.06em;
  line-height: 1.5;
  margin: 0 0 28px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--navy-deep);
  color: var(--navy);
  font-weight: 700;
  position: relative;
}
h2::before {
  content: "■";
  color: var(--blue-accent);
  font-size: 0.85em;
  margin-right: 10px;
}

h3 {
  font-size: 1.15rem;
  line-height: 1.6;
  margin: 32px 0 14px;
  color: var(--navy);
  font-weight: 700;
  letter-spacing: 0.03em;
}

p {
  margin: 0 0 24px;
  color: var(--ink);
}

/* ==========================================================================
   Components (判定式、注記、カード、テーブル)
   ========================================================================== */

/* 判定式（ターミナル風） */
.formula {
  font-family: var(--font-en), var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--navy-deep);
  color: #f1f8fc;
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-left: 4px solid var(--cyan-core);
  padding: 20px 24px;
  margin: 20px 0 32px;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 16px rgba(6, 19, 30, 0.08);
}

/* 例示ボックス */
.example {
  padding: 26px 30px;
  border: 1px solid var(--line-crisp);
  border-radius: 1px;
  margin: 28px 0;
  background: #fbfdfd;
  position: relative;
}
.example::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 2px;
  background: var(--blue-accent);
}
.example h3 {
  margin-top: 6px;
}

/* 注記（Note） */
.note {
  font-size: 14px;
  background: #f4f7f9;
  border: 1px solid #d4e0e6;
  border-left: 4px solid var(--slate);
  padding: 20px 24px;
  color: var(--ink-sub);
  margin: 28px 0;
  line-height: 1.9;
}

/* テーブル（公的帳票・データシート風） */
.table-wrap {
  overflow-x: auto;
  margin: 24px 0 36px;
  border: 1px solid var(--line-crisp);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
  line-height: 1.8;
}

th {
  background: #eef3f6;
  color: var(--navy);
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 2px solid var(--line-crisp);
}

th, td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-subtle);
  vertical-align: middle;
}

tbody tr:nth-child(even) {
  background: #fafcfd;
}

tbody tr:hover {
  background: #f1f7f9;
}

td:first-child {
  font-weight: 700;
  color: var(--navy);
}

/* ボタンスタイル */
.button {
  display: inline-block;
  font-family: var(--font-en), var(--font-sans);
  background: var(--navy);
  color: #fff;
  padding: 12px 28px;
  text-decoration: none;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.08em;
  border: 1px solid var(--navy);
  transition: all 0.2s ease;
}
.button:hover {
  background: var(--blue-accent);
  border-color: var(--blue-accent);
  box-shadow: 0 4px 14px rgba(0, 119, 153, 0.25);
}
.button.secondary {
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line-crisp);
}
.button.secondary:hover {
  background: #f4f8fa;
  border-color: var(--navy);
}

/* リスト */
ul, ol {
  padding-left: 1.4em;
  margin: 0 0 28px;
}
li {
  margin-bottom: 10px;
  color: var(--ink);
}

/* 右側 目次（TOC） */
.toc {
  position: sticky;
  top: 104px;
  align-self: start;
  margin-top: 52px;
  border-left: 1px solid var(--line-subtle);
  padding-left: 20px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}
.toc a {
  display: block;
  font-size: 13px;
  line-height: 1.7;
  color: var(--slate);
  text-decoration: none;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
.toc a:hover {
  color: var(--navy);
  padding-left: 4px;
}
.toc .back-top {
  margin-top: 28px;
  font-family: var(--font-en);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--blue-accent);
  font-weight: 700;
}

/* ホームのチャプターカード */
.chapter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 32px 0 40px;
}
.chapter-card {
  display: flex;
  gap: 18px;
  padding: 24px 22px;
  border: 1px solid var(--line-subtle);
  background: #ffffff;
  text-decoration: none;
  color: var(--ink);
  transition: all 0.2s ease;
  position: relative;
}
.chapter-card:hover {
  border-color: var(--blue-accent);
  box-shadow: 0 6px 20px rgba(0, 119, 153, 0.08);
  transform: translateY(-2px);
}
.chapter-no {
  font-family: var(--font-en);
  font-size: 26px;
  font-weight: 700;
  color: var(--slate-light);
  line-height: 1;
}
.chapter-card:hover .chapter-no {
  color: var(--blue-accent);
}
.chapter-card h3 {
  margin: 6px 0 4px;
  font-size: 1.05rem;
}
.chapter-card p {
  font-size: 13px;
  color: var(--slate);
  line-height: 1.6;
  margin: 0;
}
.arrow {
  color: var(--slate-light);
  margin-left: auto;
  font-family: var(--font-en);
  transition: all 0.2s ease;
}
.chapter-card:hover .arrow {
  color: var(--blue-accent);
  transform: translate(2px, -2px);
}

/* NPC カード */
.npc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 28px 0 36px;
}
.npc-card {
  border: 1px solid var(--line-subtle);
  border-top: 3px solid var(--navy);
  padding: 24px;
  background: #ffffff;
  transition: border-color 0.2s ease;
}
.npc-card:hover {
  border-color: var(--blue-accent);
}
.npc-card h3 {
  font-size: 1.25rem;
  margin: 8px 0 4px;
}
.npc-kana {
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--slate);
  margin-bottom: 16px;
}
.npc-card p {
  font-size: 13.5px;
  line-height: 1.95;
  color: var(--ink-sub);
  margin: 0;
}

/* ページネーション & フッター */
.pagination {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  padding: 48px 0 32px;
  margin-top: 24px;
  border-top: 1px solid var(--line-subtle);
}
.pagination a {
  font-weight: 700;
  text-decoration: none;
  font-size: 15px;
}
.pagination small {
  display: block;
  font-family: var(--font-en);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--slate-light);
  font-weight: 500;
  margin-bottom: 4px;
}
.footer {
  padding: 36px 0 48px;
  border-top: 1px solid var(--line-subtle);
  font-size: 12px;
  color: var(--slate);
  font-family: var(--font-en), var(--font-sans);
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Responsive (モバイル / タブレット対応)
   ========================================================================== */
.menu-toggle {
  display: none;
}

@media (max-width: 1180px) {
  .reading-layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 40px 60px;
  }
  .toc {
    display: none;
  }
  .page-heading {
    padding: 44px 40px;
  }
  .layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 768px) {
  .topbar {
    min-height: 64px;
    height: auto;
    padding: 10px 18px;
  }
  .brand {
    font-size: 21px;
    white-space: nowrap;
  }
  .brand small {
    font-size: 8px;
    letter-spacing: 0.18em;
  }
  .version {
    display: none;
  }
  .sheet-link {
    font-size: 12px;
    padding: 6px 12px;
  }
  .menu-toggle {
    display: block;
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    font-size: 13px;
    font-family: var(--font-sans);
    cursor: pointer;
  }
  .layout {
    display: block;
  }
  .sidebar {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    height: calc(100vh - 64px);
    z-index: 90;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  }
  .sidebar.open {
    display: flex;
  }
  .page-heading {
    padding: 36px 20px;
  }
  .reading-layout {
    padding: 12px 20px 48px;
  }
  .chapter-grid, .npc-grid {
    grid-template-columns: 1fr;
  }
}