:root {
  color-scheme: light;
  --navy: #17375f;
  --navy-light: #1d3f6b;
  --paper: #fffef9;
  --background: #f2efe7;
  --ink: #111827;
  --muted: #374151;
  --line: #b7aa95;
  --blue: #075b9a;
  --gold: #9a6500;
  --green: #237858;
  --stamp: #b3332f;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: linear-gradient(180deg, #e6e0d2, var(--background) 38rem);
  color: var(--ink);
  font: 16px/1.78 "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
}
a { color: var(--blue); text-underline-offset: 3px; }
button, input, select { font: inherit; }
button, .button {
  min-height: 42px;
  padding: 7px 14px;
  color: var(--navy);
  background: var(--paper);
  border: 1px solid #7e8998;
  border-radius: 9px;
  cursor: pointer;
}
button:hover, .button:hover { background: #f4ecdc; }
:focus-visible { outline: 3px solid #bc8123; outline-offset: 3px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 100; background: white; padding: 8px; }
.skip:focus { top: 10px; }
.language-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px max(20px, calc((100vw - 1328px) / 2));
  background: #eee8dc;
  border-bottom: 1px solid var(--line);
}
.language-bar button { min-height: 34px; padding: 4px 15px; border-radius: 24px; font-size: .82rem; }
.language-bar [aria-pressed=true] { background: var(--navy); color: white; }
.hero { color: white; background: linear-gradient(118deg, var(--navy), var(--navy-light)); }
.hero-inner { max-width: 1480px; margin: auto; padding: 34px clamp(24px, 5.2vw, 80px) 38px; }
.edition { display: block; font-size: .85rem; font-weight: 700; letter-spacing: .05em; margin-bottom: 8px; }
h1 {
  margin: 0;
  font: 700 clamp(2rem, 4.1vw, 3.45rem)/1.24 YuMincho, "Yu Mincho", serif;
  text-wrap: balance;
}
html[lang=en] h1 { font-size: clamp(1.8rem, 3.7vw, 3.25rem); }
.category-nav { overflow-x: auto; background: #fffdf8; border-bottom: 1px solid #aeb8c7; box-shadow: 0 3px 12px #14233c12; }
.category-inner { display: flex; gap: 24px; width: max-content; min-width: min(100%, 1440px); margin: auto; padding: 11px clamp(24px, 5.2vw, 80px); }
.category-nav a { min-height: 32px; display: inline-flex; align-items: center; white-space: nowrap; text-decoration: none; font-size: .92rem; font-weight: 800; border-bottom: 2px solid transparent; }
.category-nav [aria-current=page] { border-bottom-color: var(--gold); color: var(--navy); }
.tools, .search-panel, .notice-block { max-width: 1328px; margin: 22px auto; }
.tools { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 0 20px; }
.tool-buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.progress-summary { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.progress-disc { width: 66px; height: 66px; border: 2px solid var(--navy); border-radius: 50%; background: var(--paper); display: grid; place-items: center; color: #194a3c; font-weight: 900; box-shadow: inset 0 0 0 4px #fff, 0 3px 12px #09182c18; }
.progress-caption { font-size: .85rem; color: var(--muted); }
.search-panel { padding: 18px 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.search-controls { display: flex; gap: 10px; align-items: end; }
.search-label { flex: 1; min-width: 0; font-weight: 700; color: var(--navy); }
.search-label span { display: block; margin-bottom: 5px; }
#search { width: 100%; min-height: 45px; padding: 8px 12px; border: 1px solid #7c8ca3; border-radius: 6px; background: white; color: var(--ink); }
#results-count { margin: 10px 0 0; color: var(--muted); font-size: .87rem; }
#search-results { margin: 12px 0 0; padding: 0; list-style: none; }
#search-results li { padding: 12px 0; border-top: 1px solid #d9cebd; }
#search-results a { font-weight: 750; }
#search-results p { font-size: .9rem; margin: 4px 0 0; }
.result-category { display: block; font-size: .78rem; color: var(--gold); }
.notice-block { padding: 0 20px; }
.notice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.notice { background: #f5e7df; border: 1px solid #a56651; border-radius: 14px; padding: 16px 18px; }
.notice h2 { font-size: 1rem; margin: 0 0 6px; }
.notice p { margin: 0; font-size: .92rem; }
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 34px; max-width: 1440px; margin: auto; padding: 14px clamp(20px, 4vw, 56px) 40px; align-items: start; }
.toc { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 40px #2e26191a; }
.toc h2 { font-size: .8rem; color: var(--gold); margin: 0 0 10px; letter-spacing: .1em; }
.toc a { display: block; padding: 8px 9px; text-decoration: none; font-size: .86rem; line-height: 1.5; border-radius: 6px; }
.toc a:hover { background: #f4ecdc; }
main { min-width: 0; }
.panel { padding: 24px; margin-bottom: 22px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 30px #2e261912; }
h2 { font-size: 1.35rem; line-height: 1.5; margin: 0 0 15px; color: var(--navy); }
h3 { font-size: 1.04rem; line-height: 1.5; margin: 0; }
p { margin: 10px 0; }
.overview { color: var(--muted); }
.chapter-tools { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0; }
details.chapter { margin-bottom: 22px; background: #e9e1d2; border: 1px solid var(--line); border-radius: 18px; overflow: clip; box-shadow: 0 12px 30px #2e261912; }
details.chapter > summary { display: flex; gap: 15px; align-items: center; justify-content: space-between; padding: 20px 22px; background: var(--paper); cursor: pointer; list-style: none; color: var(--navy); font-weight: 800; font-size: 1.2rem; }
details.chapter > summary::-webkit-details-marker { display: none; }
details.chapter > summary::after { content: "+"; display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); font-weight: 700; }
details.chapter[open] > summary::after { content: "−"; }
.chapter-body { padding: 0 20px 22px; }
.route-card { position: relative; margin-top: 14px; padding: 18px 20px 20px; border: 1px solid #c4b8a4; border-radius: 14px; background: var(--paper); }
.route-head { display: flex; gap: 14px; align-items: flex-start; }
.route-check { width: 24px; height: 24px; flex: 0 0 24px; margin: 2px 0 0; accent-color: var(--green); cursor: pointer; }
.route-head label { cursor: pointer; flex: 1; font-weight: 800; line-height: 1.5; }
.route-body { padding-left: 38px; }
.route-body ol, .route-body ul { padding-left: 1.35em; margin: 10px 0; }
.route-body li + li { margin-top: 6px; }
.tag { display: inline-block; font-size: .7rem; padding: 2px 7px; border: 1px solid #8c784d; color: #79541c; border-radius: 20px; margin-bottom: 8px; }
.tip { padding: 10px 12px; margin-top: 12px; background: #f4ecdc; border: 1px solid #c4b8a4; border-radius: 8px; font-size: .9rem; }
.references { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.references a { border: 1px solid #7b899b; border-radius: 6px; padding: 4px 9px; font-size: .85rem; text-decoration: none; }
.route-card.is-done { padding-bottom: 60px; border-color: var(--green); box-shadow: 0 7px 18px #18574219; }
.completion-stamp { position: absolute; right: 15px; bottom: 12px; display: grid; place-items: center; width: 62px; height: 31px; border: 2px solid var(--stamp); border-radius: 4px 6px 5px 3px; background: radial-gradient(circle at 16% 28%, #fffdf8 0 1px, transparent 1.35px) 0 0 / 9px 8px, #fffdf8d9; color: var(--stamp); font-weight: 900; font-size: .9rem; letter-spacing: .08em; line-height: 1; transform: none; }
.route-card.bump { animation: card-bump .58s cubic-bezier(.22, 1.3, .36, 1); }
.route-card.bump .completion-stamp { animation: stamp-pop .58s cubic-bezier(.22, 1.3, .36, 1); }
.progress-disc.bump { animation: progress-bump .64s ease; }
@keyframes card-bump { 0%, 100% { transform: scale(1); } 36% { transform: scale(1.012); } 68% { transform: scale(.996); } }
@keyframes stamp-pop { 0% { opacity: 0; transform: scale(1.42); } 58% { opacity: 1; transform: scale(.92); } 100% { opacity: 1; transform: none; } }
@keyframes progress-bump { 0%, 100% { transform: scale(1); } 35% { transform: scale(1.12); } 65% { transform: scale(.96); } }
.table-scroll { overflow-x: auto; border: 1px solid #9daac0; border-radius: 10px; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; line-height: 1.65; }
th, td { padding: 11px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid #c6d0df; border-right: 1px solid #d3dbe6; }
th { background: #243f63; color: white; font-weight: 800; }
td:first-child { min-width: 140px; font-weight: 750; }
td { min-width: 100px; }
td.long { min-width: 230px; }
td.number { min-width: 72px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:nth-child(even) td { background: #f0f3f6; }
tr:target td { background: #fff1c9; }
tr.is-collected td:first-child { color: var(--green); }
.collection-check { width: 22px; height: 22px; accent-color: var(--green); vertical-align: middle; margin-right: 8px; }
.collection-status { display: block; color: var(--stamp); font-size: .8rem; }
.storage-message { margin: 10px 0; padding: 12px; background: #fff0c9; border: 1px solid #ad812b; border-radius: 8px; }
footer { margin: 12px auto 0; max-width: 1328px; padding: 28px 80px 110px 20px; border-top: 1px solid var(--line); }
.back-top { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 50; width: 46px; height: 46px; padding: 0; display: grid; place-items: center; border: 1px solid #7e8998; border-radius: 50%; background: #fffdf8; color: var(--navy); box-shadow: 0 8px 22px #09182c33; font-weight: 900; }
.target-highlight { outline: 3px solid #bc8123; outline-offset: 3px; }
@media (max-width: 900px) {
  .layout { display: block; }
  .toc { position: static; max-height: none; margin-bottom: 24px; }
  .toc-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notice-grid { grid-template-columns: 1fr; }
  .search-panel { margin: 20px; }
}
@media (max-width: 600px) {
  .hero-inner { padding: 28px 20px; }
  h1 { font-size: clamp(1.55rem, 7vw, 2.15rem); }
  html[lang=en] h1 { font-size: 1.8rem; }
  .edition { font-size: .78rem; }
  .category-inner { padding: 9px 20px; gap: 20px; }
  .category-nav a { font-size: .84rem; }
  .tools { align-items: flex-start; gap: 12px; }
  .tool-buttons { gap: 7px; }
  .tool-buttons button, .tool-buttons a { font-size: .82rem; }
  .progress-summary { flex-direction: column; gap: 3px; }
  .progress-disc { width: 54px; height: 54px; font-size: .9rem; }
  .progress-caption { font-size: .7rem; text-align: center; }
  .search-panel { margin: 18px 58px 18px 14px; padding: 14px; }
  .search-controls { align-items: end; gap: 8px; }
  .search-label { font-size: .9rem; }
  .search-controls button { font-size: .8rem; padding: 8px; }
  .notice-block { padding: 0 58px 0 14px; }
  .layout { padding: 10px 58px 30px 14px; }
  .toc-links { grid-template-columns: 1fr; }
  .panel { padding: 20px 16px; }
  details.chapter > summary { padding: 18px 16px; font-size: 1.1rem; }
  .chapter-body { padding: 0 10px 14px; }
  .route-card { padding: 16px 14px 18px; }
  .route-body { padding-left: 0; }
  .route-head { gap: 10px; }
  table { font-size: .86rem; }
  td:first-child { min-width: 145px; }
  footer { padding-left: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .language-bar, .category-nav, .tools, .search-panel, .toc, .chapter-tools, .back-top, .storage-message, .skip { display: none !important; }
  body { background: white; color: black; }
  .hero { color: black; background: white; }
  .hero-inner { padding: 0 0 18px; }
  h1 { font-size: 24pt; }
  .layout { display: block; padding: 0; }
  .panel, details.chapter, .route-card, .notice { box-shadow: none; break-inside: avoid; }
  .table-scroll { overflow: visible; }
  table { font-size: 8pt; }
  th, td { min-width: 0 !important; padding: 5px; }
  .notice-block { padding: 0; }
  footer { padding: 15px 0; }
}

.diagram-frame {
  overflow: auto;
  margin: 1.2rem 0;
  border: 1px solid #b7c3d2;
  border-radius: 12px;
  background: #d9edf4;
}
.diagram-frame svg { display: block; width: 100%; min-width: 680px; }
.diagram-island { fill: #c8d6b5; stroke: #779c88; stroke-width: 3; stroke-linejoin: round; }
.diagram-marker rect { fill: #17375f; stroke: #fffef9; stroke-width: 2; }
.diagram-marker text { font: bold 15px 'Yu Gothic UI', sans-serif; fill: #fffef9; }
.diagram-marker:hover rect, .diagram-marker:focus rect { fill: #a76800; stroke: #17375f; stroke-width: 3; }
.diagram-frame ~ p { overflow-wrap: anywhere; }
@media print {
  .diagram-frame { overflow: visible; break-inside: avoid; }
  .diagram-frame svg { min-width: 0; }
}
