:root {
  color-scheme: light;
  --navy: #17375f;
  --ink: #162238;
  --paper: #f2efe7;
  --panel: #fffef9;
  --blue: #075b9a;
  --gold: #a76800;
  --line: #b6a68d;
  --green: #237858;
  --stamp: #b3332f;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 22px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.78 "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
}
a { color: var(--blue); text-underline-offset: .2em; }
a:hover { color: #00385e; }
button, input { font: inherit; color: inherit; }
button {
  min-height: 42px;
  padding: 7px 14px;
  border: 1px solid #998970;
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
}
button:hover { background: #eee8d9; }
:focus-visible { outline: 3px solid #c88b27; outline-offset: 3px; }
.skip-link { position: absolute; left: 10px; top: -100px; z-index: 1000; background: white; padding: 10px; }
.skip-link:focus { top: 8px; }
.utility {
  max-width: 1480px;
  margin: auto;
  padding: 8px 110px 8px 4vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}
.guide-home { font-size: .85rem; font-weight: 700; }
.language { display: flex; gap: 8px; }
.language button { font-size: .78rem; min-height: 36px; border-radius: 24px; }
.language button[aria-pressed="true"] { background: var(--navy); color: white; border-color: var(--navy); }
.hero { background: linear-gradient(118deg, #17375f, #24476f); color: white; }
.hero-inner { max-width: 1480px; padding: 40px 5.2vw 28px; margin: auto; }
h1 {
  font-family: YuMincho, "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(2rem, 4.1vw, 3.45rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .015em;
  margin: 0;
  text-wrap: balance;
}
html[lang="en"] h1 { font-size: clamp(1.9rem, 3.7vw, 3.25rem); }
.edition { font-size: .85rem; margin: 10px 0 0; color: #f2eadb; }
.category-nav { background: var(--panel); border-bottom: 1px solid #aeb8c7; overflow-x: auto; }
.category-nav > div { display: flex; gap: 26px; width: max-content; min-width: 100%; padding: 10px 5.2vw; }
.category-nav a { white-space: nowrap; font-size: .93rem; font-weight: 800; text-decoration: none; padding: 3px 0; border-bottom: 2px solid transparent; }
.category-nav a[aria-current] { color: var(--navy); border-color: var(--gold); }
.toolbar { display: flex; justify-content: flex-end; gap: 8px; max-width: 1440px; padding: 12px 4vw; margin: auto; }
main { max-width: 1440px; margin: auto; padding: 12px clamp(18px, 4vw, 56px) 65px; }
.progress-panel, .paper, .intro, .contents, .chapter {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--panel);
  box-shadow: 0 10px 26px #2330470d;
}
.progress-panel { padding: 22px 24px 16px; margin-bottom: 20px; }
.progress-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.progress-head strong { color: var(--blue); }
#count { font-size: 1.3rem; color: #8e5d00; margin-left: auto; font-variant-numeric: tabular-nums; }
.progress-track { height: 10px; border: 1px solid #aa987f; border-radius: 10px; background: #e8e1d4; margin-top: 16px; overflow: hidden; }
#progress-fill { height: 100%; background: var(--green); transition: width .45s ease; }
.save-note, #save-status { font-size: .86rem; margin: 10px 0 0; }
#save-status { color: #973c2e; font-weight: 700; }
#save-status:empty { display: none; }
body:not([data-page="story"]) .warnings,
body:not([data-page="story"]) .progress-panel { display: none; }
body:not([data-page="story"]) .progress-panel.storage-failed { display: block; }
body:not([data-page="story"]) .progress-head,
body:not([data-page="story"]) .progress-track,
body:not([data-page="story"]) .save-note { display: none; }
.warnings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0 0 20px; }
.warnings p { margin: 0; padding: 16px 18px; border: 1px solid #aa6d56; background: #f5e8dd; border-radius: 14px; font-weight: 650; }
.search-panel { margin-bottom: 26px; padding: 18px; border: 1px solid #a9b4c3; border-radius: 13px; background: #f8f5ec; }
.search-panel > label { display: block; margin-bottom: 7px; font-size: .9rem; font-weight: 750; }
.search-controls { display: flex; gap: 10px; }
#search { flex: 1; min-width: 0; border: 1px solid #879ab1; border-radius: 8px; padding: 10px 12px; background: white; width: 100%; }
.result-count { font-weight: 700; }
#search-results ul { padding: 0; margin-bottom: 0; list-style: none; max-height: 480px; overflow: auto; }
#search-results li { padding: 13px 5px; border-top: 1px solid #d8cdbb; }
#search-results li p { margin: 4px 0 0; font-size: .88rem; color: #495364; }
.category-label { display: inline-block; margin-right: 14px; font-size: .78rem; color: #7d560b; }
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 34px; align-items: start; }
.contents { position: sticky; top: 20px; max-height: calc(100vh - 42px); overflow-y: auto; padding: 20px 16px; }
.contents h2 { margin: 0 7px 12px; font-size: .82rem; color: var(--gold); letter-spacing: .14em; }
.contents a { display: block; text-decoration: none; padding: 8px 7px; font-size: .86rem; line-height: 1.5; color: #46536a; border-radius: 6px; }
.contents a:hover { background: #f0eadd; color: var(--navy); }
.reading { min-width: 0; }
.intro { padding: 23px; margin-bottom: 23px; }
h2 { color: var(--navy); font-size: 1.3rem; line-height: 1.5; margin: 0 0 14px; }
.intro p, .paper > p { margin: 0 0 18px; }
.route-overview { display: grid; gap: 7px; }
.route-overview a { padding: 6px 0; font-size: .9rem; }
.chapter-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chapter { margin-bottom: 22px; overflow: clip; }
.chapter > summary { padding: 24px 22px; cursor: pointer; font-weight: 800; color: var(--navy); font-size: 1.14rem; line-height: 1.6; }
.chapter-body { background: #e9e2d4; padding: 20px; border-top: 1px solid #c4b69f; }
.route-card { position: relative; border: 1px solid #c2b39c; border-radius: 14px; background: var(--panel); padding: 20px 22px; margin-bottom: 14px; box-shadow: 0 4px 11px #34291a0b; scroll-margin-top: 24px; }
.route-card:last-child { margin-bottom: 0; }
.route-heading { display: flex; align-items: flex-start; gap: 16px; font-weight: 800; cursor: pointer; line-height: 1.65; }
.route-check { margin: 3px 0 0; width: 24px; height: 24px; min-width: 24px; accent-color: var(--green); cursor: pointer; }
.route-card ol { padding-left: 24px; margin: 13px 0 0 39px; }
.route-card li { padding: 4px 0; }
.route-card.complete { padding-bottom: 60px; border-color: var(--green); opacity: 1; }
.route-card.complete::after {
  content: "完了";
  position: absolute;
  right: 15px;
  bottom: 12px;
  width: 62px;
  height: 31px;
  display: grid;
  place-items: center;
  border: 2px solid var(--stamp);
  border-radius: 4px 6px 4px 3px;
  background: radial-gradient(circle, #fffef9 0 1px, transparent 1.4px) 0 0 / 9px 8px, #fffdf8ed;
  color: var(--stamp);
  font-size: .9rem;
  font-weight: 900;
  letter-spacing: .1em;
  line-height: 1;
  transform: none;
}
html[lang="en"] .route-card.complete::after { content: "DONE"; }
.route-card.bump { animation: card-bump .58s ease; }
.route-card.bump.complete::after { animation: stamp-pop .58s ease; }
@keyframes card-bump { 0%, 100% { transform: scale(1); } 35% { transform: scale(1.012); } }
@keyframes stamp-pop { 0% { transform: scale(1.4); opacity: 0; } 65% { transform: scale(.94); opacity: 1; } 100% { transform: scale(1); } }
.note { border: 1px solid #b8a588; border-radius: 8px; background: #f2ead6; font-size: .9rem; padding: 12px 14px; margin: 14px 0 0 39px; }
.cross-reference { margin: 12px 0 0 39px; font-size: .88rem; }
.paper { padding: 25px; margin-bottom: 24px; }
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid #b1bed0; border-radius: 10px; }
table { border-collapse: collapse; min-width: 750px; width: 100%; font-size: .9rem; line-height: 1.7; }
th { color: white; background: #223f63; text-align: left; font-weight: 750; padding: 12px 13px; border: 1px solid #6b7e97; }
td { padding: 12px 13px; border: 1px solid #cdd5df; vertical-align: top; }
tr:nth-child(even) td { background: #eff2f5; }
td:first-child { min-width: 150px; font-weight: 700; }
td:last-child { min-width: 120px; }
tr:target td { background: #fff0c6; }
footer { max-width: 1440px; margin: auto; padding: 24px 6vw 60px; border-top: 1px solid #c4b69f; }
footer a { font-weight: 700; }
.floating-progress { position: fixed; z-index: 20; right: 18px; top: 13px; width: 72px; height: 72px; border: 3px solid #294f7d; border-radius: 50%; background: #fffef9f5; box-shadow: 0 5px 15px #112b4b33, inset 0 0 0 5px white; display: grid; place-items: center; font-weight: 800; color: #195d46; pointer-events: none; }
#back-top { position: fixed; z-index: 30; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 46px; height: 46px; min-height: 0; padding: 0; border: 1px solid #7e8998; border-radius: 50%; background: #fffdf8; color: var(--navy); box-shadow: 0 7px 20px #112b4b33; font-weight: 900; font-size: 1.2rem; }
@media (max-width: 760px) {
  .utility { padding: 8px 80px 8px 16px; align-items: flex-start; flex-wrap: wrap; gap: 6px 12px; }
  .guide-home { font-size: .8rem; }
  .language button { padding: 4px 11px; min-height: 34px; }
  .hero-inner { padding: 27px 20px 24px; }
  h1, html[lang="en"] h1 { font-size: clamp(1.6rem, 7vw, 2.15rem); line-height: 1.35; }
  .edition { font-size: .78rem; }
  .category-nav > div { padding: 9px 20px; gap: 21px; }
  .category-nav a { font-size: .86rem; }
  .floating-progress { width: 58px; height: 58px; right: 10px; top: 10px; border-width: 2px; font-size: .9rem; }
  .toolbar { padding: 11px 16px; }
  main { padding: 8px 78px 65px 14px; }
  .progress-panel { padding: 17px 16px; }
  .progress-head { gap: 9px; align-items: center; }
  #count { font-size: 1.08rem; }
  .progress-head #reset { flex-basis: 100%; }
  .warnings { grid-template-columns: 1fr; gap: 11px; }
  .warnings p { padding: 14px 15px; font-size: .94rem; }
  .search-panel { padding: 15px; }
  .search-controls { gap: 7px; padding-right: 0; }
  .search-controls { flex-wrap: wrap; }
  #search { flex: 1 1 100%; }
  .search-controls button { margin-right: auto; }
  .search-controls button { padding: 6px 10px; }
  .layout { grid-template-columns: 1fr; gap: 20px; }
  .contents { position: static; max-height: none; padding: 17px; }
  .intro { padding: 19px; }
  .chapter > summary { padding: 20px 17px; font-size: 1.06rem; }
  .chapter-body { padding: 12px; }
  .route-card { padding: 17px 15px; }
  .route-heading { gap: 11px; flex-wrap: wrap; padding-right: 0; }
  .route-heading span { flex: 1 1 180px; }
  .route-card ol { margin-left: 0; padding-left: 22px; }
  .note, .cross-reference { margin-left: 0; }
  .paper { padding: 18px 14px; }
  table { min-width: 780px; }
  td:first-child { min-width: 160px; }
  footer { padding-left: 20px; padding-right: 78px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .utility, .category-nav, .toolbar, .contents, .search-panel, .chapter-actions,
  .floating-progress, #back-top, #reset, #retry, footer, .skip-link { display: none !important; }
  .hero { background: white; color: black; }
  .edition { color: #333; }
  h1, html[lang="en"] h1 { font-size: 24pt; }
  main { max-width: none; padding: 0; }
  .layout { display: block; }
  .chapter, .paper, .route-card { box-shadow: none; }
  .route-card { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; font-size: 9pt; }
  th { color: black; background: #eee; }
  .warnings { display: block; }
  .warnings p { margin-bottom: 8px; }
}
