:root {
  --paper: #f4f0e8;
  --paper-soft: #fbf8f1;
  --ink: #292824;
  --muted: #6d675d;
  --line: rgba(41, 40, 36, 0.16);
  --accent: #515c48;
  --theme: #2f3334;
  --max-text: 74ch;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  font-kerning: normal;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
html:lang(ja) body,
html:lang(ko) body,
html:lang(zh-Hans) body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP", "Noto Sans CJK KR", "Noto Sans CJK SC", sans-serif;
}
a { color: inherit; text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  min-height: 64px;
  padding: 0.8rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--paper-soft) 92%, white);
  border-bottom: 1px solid var(--line);
}
.site-mark {
  grid-column: 2;
  justify-self: center;
  max-width: min(48rem, 56vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
  text-decoration: none;
}
.menu-toggle {
  grid-column: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.85rem;
  height: 2.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper-soft);
  box-shadow: 0 8px 22px rgba(0,0,0,0.06);
  cursor: pointer;
}
.menu-toggle__bars,
.menu-toggle__bars::before,
.menu-toggle__bars::after {
  display: block;
  width: 1.12rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}
.menu-toggle__bars {
  position: relative;
}
.menu-toggle__bars::before,
.menu-toggle__bars::after {
  position: absolute;
  left: 0;
}
.menu-toggle__bars::before { top: -0.38rem; }
.menu-toggle__bars::after { top: 0.38rem; }
.site-nav {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: clamp(1rem, 4vw, 3rem);
  display: none;
  min-width: min(24rem, calc(100vw - 2rem));
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper-soft) 96%, white);
  box-shadow: 0 18px 40px rgba(0,0,0,0.12);
  flex-direction: column;
  align-items: stretch;
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
}
.site-nav.is-open { display: flex; }
.site-nav a {
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
}
.site-nav a:hover,
.site-nav a:focus-visible {
  background: rgba(41, 40, 36, 0.07);
  outline: none;
}
.site-language {
  grid-column: 3;
  justify-self: end;
  position: relative;
  font-family: system-ui, sans-serif;
}
.site-language__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.site-language__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.55rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper-soft);
  box-shadow: 0 8px 22px rgba(0,0,0,0.06);
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
}
.site-language__toggle::after {
  width: 0;
  height: 0;
  margin-left: 0.1rem;
  border-left: 0.25rem solid transparent;
  border-right: 0.25rem solid transparent;
  border-top: 0.32rem solid currentColor;
  content: "";
}
.site-language__list {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  display: none;
  min-width: 10rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper-soft) 96%, white);
  box-shadow: 0 18px 40px rgba(0,0,0,0.12);
}
.site-language.is-open .site-language__list { display: grid; }
.site-language__link {
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  text-decoration: none;
}
.site-language__link:hover,
.site-language__link:focus-visible {
  background: rgba(41, 40, 36, 0.07);
  outline: none;
}
.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 360px);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
  max-width: 1120px;
  min-height: calc(100svh - 72px);
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 5rem) clamp(1rem, 4vw, 3rem);
}
.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, h3 { line-height: 1.08; letter-spacing: 0; }
h1 { margin: 0; font-size: clamp(2.6rem, 8vw, 5.6rem); }
.subtitle {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: clamp(1.1rem, 2vw, 1.45rem);
}
.lead {
  max-width: 62ch;
  margin: 1.5rem 0 0;
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
}
.format-note {
  max-width: 62ch;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: 0.96rem;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.8rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--ink);
  border-radius: 4px;
  font-family: system-ui, sans-serif;
  font-weight: 800;
  text-decoration: none;
}
.button--primary { color: var(--paper-soft); background: var(--ink); }
.button--secondary { background: transparent; }
.home-hero__cover { margin: 0; }
.home-hero__cover img {
  display: block;
  width: min(100%, 360px);
  height: auto;
  margin-inline: auto;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0,0,0,0.16);
}
.professional-notice {
  max-width: 1120px;
  margin: 0 auto clamp(2rem, 5vw, 4rem);
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.28);
}
.professional-notice--compact {
  margin: 0 0 3rem;
  padding: 1rem;
}
.professional-notice p { max-width: var(--max-text); margin: 0.35rem 0; }
.professional-notice__label {
  color: var(--accent);
  font-family: system-ui, sans-serif;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
}
.reader-shell {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 58px;
  height: calc(100svh - 58px);
  overflow: auto;
  padding: 1.4rem;
  border-right: 1px solid var(--line);
  background: var(--paper-soft);
}
.sidebar h1 { font-size: 1.7rem; }
.sidebar-note { color: var(--muted); font-family: system-ui, sans-serif; font-size: 0.9rem; }
.toc {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.88rem;
  line-height: 1.35;
}
.toc ul { list-style: none; padding-left: 1rem; margin: 0.35rem 0 0.8rem; }
.toc li { position: relative; }
.toc a {
  display: block;
  margin: 0.08rem 0;
  padding: 0.24rem 0.42rem;
  border-inline-start: 3px solid transparent;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.toc a:hover { color: var(--ink); }
.toc a.is-current,
.toc a[aria-current="location"],
.toc li.is-current > a {
  color: var(--ink);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  font-weight: 800;
}
.toc a.is-current-parent,
.toc li.is-current-parent > a {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  font-weight: 700;
}
.reader-main { min-width: 0; }
.reading-frame {
  max-width: 940px;
  margin: 0 auto;
  padding: clamp(1.2rem, 4vw, 4rem);
}
.cover-page {
  display: grid;
  grid-template-columns: minmax(120px, 220px) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: center;
  min-height: 60svh;
  margin-bottom: 3rem;
}
.cover-page img { width: 100%; height: auto; border: 1px solid var(--line); }
.cover-page h1 { font-size: clamp(2.4rem, 7vw, 4.8rem); }
.author, .by { color: var(--muted); font-family: system-ui, sans-serif; font-weight: 700; }
.part, .chapter, .subchapter { scroll-margin-top: 5.2rem; }
.part { margin: 6rem 0; }
.part-header {
  margin: 0 0 3rem;
  padding: clamp(2.2rem, 6vw, 4.5rem);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), rgba(255,255,255,0.3)),
    color-mix(in srgb, var(--paper-soft) 86%, white);
  box-shadow: 0 18px 46px rgba(0,0,0,0.07);
  text-align: center;
}
.chapter {
  margin: 4.8rem 0 5.6rem;
}
.chapter-header {
  max-width: var(--max-text);
  margin: 0 0 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.part-label, .chapter-label {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}
.part-label { color: var(--theme); }
.part-header h2 {
  max-width: 14ch;
  margin: 0 auto;
  color: var(--theme);
  font-size: clamp(2.45rem, 6vw, 4.9rem);
  font-style: italic;
  line-height: 0.98;
}
.chapter-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
}
.chapter-epigraph, .section-epigraph {
  max-width: 42rem;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}
.subchapter { max-width: var(--max-text); margin: 3rem 0; }
.subchapter-head h3 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.2rem); }
.subchapter-head hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0 1.5rem; }
.subchapter p {
  margin: 0 0 1.05rem;
  font-size: clamp(1.04rem, 1.25vw, 1.12rem);
  line-height: 1.78;
  text-align: justify;
  text-wrap: pretty;
  hyphens: auto;
  overflow-wrap: break-word;
  hanging-punctuation: first last;
}
.ending, .reader-contact {
  max-width: var(--max-text);
  margin: 4rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: system-ui, sans-serif;
}
.mobile-endmatter { display: none; }
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem clamp(1rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: system-ui, sans-serif;
}
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: 3px;
  background: transparent;
}
.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}
@media (max-width: 820px) {
  .site-header {
    gap: 0.45rem;
    min-height: 58px;
    padding-inline: 0.8rem;
  }
  .site-mark {
    max-width: 52vw;
    font-size: 0.88rem;
  }
  .menu-toggle {
    width: 2.55rem;
    height: 2.55rem;
  }
  .site-language__toggle { min-height: 2.45rem; padding-inline: 0.65rem; }
  .site-nav {
    left: 0.8rem;
    right: 0.8rem;
    min-width: 0;
  }
  .home-hero { grid-template-columns: 1fr; min-height: auto; }
  .home-hero__cover { order: -1; }
  .home-hero__cover img { width: min(70vw, 280px); }
  .reader-shell { display: block; }
  .sidebar { display: none; }
  .reading-frame { padding: 1rem; }
  .cover-page { grid-template-columns: 1fr; min-height: auto; }
  .cover-page img { max-width: 220px; }
  .part { margin: 4rem 0; }
  .part-header { padding: 1.6rem; text-align: left; }
  .part-header h2 { margin-inline: 0; font-size: clamp(2rem, 12vw, 3.2rem); }
  .chapter { margin: 3.5rem 0 4rem; }
  .subchapter p { text-align: left; hyphens: manual; }
  .mobile-endmatter { display: block; }
}
