:root {
  --bg: #171411;
  --heading: #f4efe6;
  --text: #dcd3c6;
  --muted: #b9ae9f;
  --accent: #c9a56a;
  --line: #2e2924;
  --serif: Georgia, "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", YuMincho, "Hiragino Mincho", serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17.5px;
  line-height: 1.9;
  overflow-wrap: break-word;
}

[hidden] { display: none !important; }

.progress,
.mono-label,
.toc-num { display: none !important; }

html.js .h1-sep { display: none; }
html:not(.js) .lang-switch { display: none; }

html.js[lang="ja"] .only-en,
html.js[lang="en"] .only-ja { display: none !important; }

:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;
  z-index: 20;
  padding: 0.45rem 0.8rem;
  background: var(--bg);
  color: var(--heading);
  border: 1px solid var(--line);
  text-decoration: none;
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 0.75rem;
}

.topbar {
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 1.35rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.7rem 1.1rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--heading);
  text-decoration: none;
}

.doc-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.15rem;
  font-size: 0.9rem;
}

.doc-switch a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.2rem 0;
  color: var(--muted);
  text-decoration: none;
}

.doc-switch a:hover,
.doc-switch a[aria-current="page"] {
  color: var(--heading);
  text-decoration: underline;
  text-underline-offset: 0.28em;
  text-decoration-thickness: 1px;
}

.lang-switch {
  display: flex;
  flex-wrap: wrap;
  margin-left: auto;
  gap: 0.15rem 0.65rem;
}

.lang-switch button {
  appearance: none;
  margin: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  padding: 0.25rem 0.1rem;
}

.lang-switch button:hover,
.lang-switch button[aria-pressed="true"] {
  color: var(--heading);
  text-decoration: underline;
  text-underline-offset: 0.28em;
}

.page {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.75rem 1.1rem 4rem;
}

.hero { margin: 0 0 0.25rem; }

h1 {
  margin: 0;
  max-width: 100%;
  color: var(--heading);
  font-family: var(--serif);
  font-size: clamp(1.2rem, 4.6vw + 0.35rem, 2.2rem);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.h1-sep {
  margin: 0 0.35em;
  color: var(--muted);
  font-weight: 400;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.chip {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-weight: 400;
}

.chip b {
  font-weight: 500;
  color: inherit;
}

.chip + .chip::before {
  content: "·";
  display: inline-block;
  margin: 0 0.7rem;
  color: var(--muted);
}

.hero-rule {
  margin: 1.6rem 0 1.85rem;
  border: 0;
  border-top: 1px solid var(--line);
}

html:not(.js) .doc + .doc {
  margin-top: 2.75rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.toc {
  margin: 0 0 1.5rem;
  padding: 0 0 1.1rem;
  border-bottom: 1px solid var(--line);
}

.toc-title {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.toc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-list a {
  display: inline-block;
  max-width: 100%;
  min-height: 2.5rem;
  padding: 0.3rem 0;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.45;
}

.toc-list a:hover,
.toc-list a[data-active="true"] {
  color: var(--heading);
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.doc-body { min-width: 0; }

.prose {
  max-width: 68ch;
  color: var(--text);
}

.prose p { margin: 0 0 1.05em; }

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.prose a:hover { color: var(--heading); }

.clause {
  margin: 0 0 1.85rem;
  scroll-margin-top: 1.25rem;
}

.clause + .clause {
  padding-top: 1.55rem;
  border-top: 1px solid var(--line);
}

.clause h2 {
  margin: 0 0 0.65rem;
  color: var(--heading);
  font-family: var(--serif);
  font-size: clamp(1.08rem, 1.6vw + 0.7rem, 1.32rem);
  font-weight: 600;
  line-height: 1.4;
  text-wrap: balance;
}

.doc { scroll-margin-top: 1.25rem; }

main > .prose {
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}

.site-footer {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.15rem 1.1rem 2.4rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
}

@media (min-width: 960px) {
  .page { padding: 2.25rem 1.75rem 5rem; }

  .doc {
    display: grid;
    grid-template-columns: minmax(11rem, 14.5rem) minmax(0, 1fr);
    column-gap: 3.25rem;
    align-items: start;
  }

  .toc {
    margin: 0;
    padding: 0 1.4rem 0 0;
    border: 0;
    border-right: 1px solid var(--line);
  }

  html.js .toc {
    position: sticky;
    top: 1.25rem;
  }

  .toc-list {
    display: block;
  }

  .toc-list a {
    display: block;
    min-height: 0;
    margin: 0 0 0.45rem;
    padding: 0.12rem 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  :root {
    color-scheme: light;
    --bg: #fff;
    --heading: #111;
    --text: #222;
    --muted: #555;
    --accent: #65481e;
    --line: #ccc;
  }

  body {
    background: #fff;
    color: #222;
    font-size: 12pt;
    line-height: 1.65;
  }

  .progress,
  .skip-link,
  .topbar,
  .toc,
  .lang-switch,
  .hero-rule { display: none !important; }

  h1, h2 { color: #111; break-after: avoid; }

  a {
    color: inherit;
    text-decoration: underline;
  }

  .page,
  .prose,
  .site-footer {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }

  .clause { break-inside: avoid; }
}
