:root {
  --bg: #EDEEEA;
  --bg-panel: #E3E4DF;
  --bg-panel-2: #D8D9D3;
  --border: #CCCDC6;
  --accent: #2B3040;
  --accent-dark: #171A23;
  --text: #15161A;
  --text-muted: #5E6066;
  --success: #4A7A5C;
  --warn: #A57A34;
  --error: #A6473A;
  --bg-tint: #E7E8E4;
  --ink-block: #141518;
  --ink-rule: #26282D;
  --ink-hair: #8A8C90;
  --on-ink: #EDEEEA;
  --on-ink-muted: #9A9CA1;
  --on-ink-link: #E3E4DF;
  --veil: rgb(20 21 24 / 48%);
  --paper-sage: #8FA38C;
  --paper-ochre: #C9A066;
  --paper-mist: #8FA6BF;
  --paper-clay: #B97C66;
  --color-primary: var(--accent);
  --color-accent: var(--accent);
  --color-text: var(--text);
  --color-bg: var(--on-ink);
  --color-canvas: var(--bg);

  --font-display: 'Inter', 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --font-body: 'Inter', 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --font-serif: Georgia, 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --fs-body: 16px;
  --fs-mono: 12px;
  --fs-h1: clamp(34px, 3.4vw, 48px);
  --fs-h2: clamp(24px, 2.5vw, 36px);
  --fs-h3: clamp(18px, 1.65vw, 23px);
  --fs-serif: 19px;
  --lh-body: 1.6;
  --lh-title: 1.24;
  --weight-display: 800;
  --weight-strong: 700;
  --weight-button: 600;
  --track-title: -.02em;

  --r-card: 24px;
  --r-btn: 10px;
  --r-panel: 32px;
  --r-pill: 999px;
  --r-focus: 4px;
  --rule: 1px;
  --touch: 44px;
  --header-h: 76px;
  --strip-h: 40px;
  --gutter: 96px;
  --edge: 48px;
  --reading-width: 1128px;
  --mast-width: 1280px;
  --section-space: clamp(52px, 6.6vw, 104px);
  --card-space: clamp(20px, 3vw, 36px);
  --column-gap: clamp(24px, 4vw, 64px);
  --sticky-inset: 16px;
  --reveal-time: 360ms;
  --reveal-offset: 8px;
  --z-header: 30;
  --z-toc: 5;
  --z-fab: 15;

  --surface: var(--bg);
  --fg: var(--text);
  --muted: var(--text-muted);
  --link: var(--accent);
  --divider: var(--border);
  --focus: var(--accent);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html.nav-open { overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  line-break: strict;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
:where(main, section, article, aside, div, nav, header, footer, figure, ul, li, dl, dd, pre) { min-width: 0; }
:where(img, svg, video) { max-width: 100%; }
:where(img, video) { height: auto; }
:where(svg, .brand-mark, .badge-dot, .app-icon, .fixed-icon) { flex-shrink: 0; }
:where(button, input, select, textarea) { font: inherit; color: inherit; }
button:not(:disabled), summary { cursor: pointer; }
a { color: var(--link); text-underline-offset: .24em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-focus); }
:where([id]) { scroll-margin-block-start: 5rem; }
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  line-height: var(--lh-title);
  letter-spacing: var(--track-title);
  margin: 0 0 .6em;
  text-wrap: wrap;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
p, ul, ol, dl, pre, blockquote { margin-block: 0 1em; }
p, li, dd, figcaption { overflow-wrap: break-word; text-wrap: pretty; }
.keep { white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: var(--fs-mono); }
.dek { font-family: var(--font-serif); font-size: var(--fs-serif); color: var(--muted); }
code, pre, kbd { font-family: var(--font-mono); }
code { overflow-wrap: anywhere; }
pre {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 1rem 1.1rem;
  border: var(--rule) solid var(--ink-rule);
  border-radius: var(--r-btn);
  background: var(--ink-block);
  color: var(--on-ink);
}
pre code { white-space: pre; color: inherit; }
.wrap { width: 100%; max-width: var(--reading-width); padding-inline: var(--gutter); margin-inline: auto; }
.prose { line-height: 1.8; }
.wrap.prose {
  max-width: 820px;
  padding-inline: clamp(20px, 4vw, 40px);
}
@media (max-width: 640px) {
  :lang(ja) .wrap.prose > div > h1 { font-size: 24px; }
}
.prose :where(h2, h3):not(:first-child) { margin-block-start: 1.7em; }
.section-space { padding-block: var(--section-space); }
.sec--base, .sec--tint, .sec--ink { background: var(--surface); color: var(--fg); }
.sec--tint { --surface: var(--bg-tint); }
.sec--ink {
  --surface: var(--ink-block);
  --fg: var(--on-ink);
  --muted: var(--on-ink-muted);
  --link: var(--on-ink-link);
  --divider: var(--ink-rule);
  --focus: var(--on-ink);
}
.art-boundary { position: relative; overflow-x: clip; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 1rem; }
.card-grid > *, .hero > *, .footer-grid > *, .chapter-grid > *, .dl-entry > * { min-width: 0; }
.card, .panel {
  --surface: var(--bg-panel);
  --fg: var(--text);
  --muted: var(--text-muted);
  --link: var(--accent);
  --focus: var(--accent);
  --divider: var(--border);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--r-card);
  padding: var(--card-space);
}
.panel { --surface: var(--bg-panel-2); }
:where(.card, .panel) > :last-child { margin-block-end: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  max-width: 100%;
  padding: 9px 22px;
  border: var(--rule) solid var(--accent);
  border-radius: var(--r-btn);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--weight-button);
  letter-spacing: -.005em;
  line-height: var(--lh-body);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.btn svg { display: block; width: 16px; height: 16px; }
.btn-glyph { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn-ink { background: var(--accent); color: var(--on-ink); }
.btn-ink:is(:hover, .is-hover) { background: var(--accent-dark); color: var(--on-ink); border-color: var(--accent-dark); }
.btn-ink:is(:active, .is-pressed) { background: var(--ink-block); color: var(--on-ink); border-color: var(--ink-block); }
.btn-line { background: transparent; color: var(--fg); border-color: var(--fg); }
.btn-line:is(:hover, .is-hover) { background: var(--bg-panel); color: var(--text); border-color: var(--text); }
.btn-line:is(:active, .is-pressed) { background: var(--bg-panel-2); color: var(--text); border-color: var(--text); }
.btn:is(:disabled, .is-disabled) { background: var(--bg-panel); color: var(--text-muted); border-color: var(--border); cursor: not-allowed; }
.btn.is-focus { outline: 2px solid var(--focus); outline-offset: 3px; }

.masthead {
  position: relative;
  z-index: var(--z-header);
  min-height: var(--header-h);
  max-width: min(100%, calc(var(--mast-width) + var(--gutter) * 2));
  margin-inline: auto;
  padding-inline: var(--gutter) var(--edge);
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--bg);
  color: var(--text);
}
.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
  text-decoration: none;
  color: var(--fg);
  font-family: var(--font-display);
  font-weight: var(--weight-strong);
  font-size: 17px;
  letter-spacing: -.01em;
}
.brand-mark { width: 32px; height: 32px; display: block; }
.main-trail { min-width: 0; margin-inline-start: auto; }
.trail { display: flex; align-items: center; list-style: none; margin: 0; padding: 0; gap: 14px; font-size: 15px; }
.trail li { display: flex; align-items: center; gap: inherit; }
.trail li + li::before { content: "/"; color: var(--text-muted); }
.trail a { text-decoration: none; color: var(--text); padding-block: 6px; }
.trail a:hover { text-decoration: underline; text-decoration-thickness: var(--rule); text-underline-offset: 6px; }
.trail a[aria-current="page"] { font-weight: var(--weight-button); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.mast-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lang-dock { position: relative; }
.lang, .burger {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: var(--rule) solid var(--border);
  border-radius: var(--r-btn);
  padding: 7px 12px;
  white-space: nowrap;
}
.lang:hover, .burger:hover { border-color: var(--text); }
.lang::marker, .burger::marker { content: ""; }
.lang::-webkit-details-marker, .burger::-webkit-details-marker { display: none; }
.lang-short, .burger, .mast-drawer, .preview-drawer { display: none; }
.lang-list {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 3;
  min-width: 10rem;
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--bg);
  color: var(--text);
  border: var(--rule) solid var(--border);
  border-radius: var(--r-btn);
}
.lang-list a, .drawer-list a {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--touch);
  padding: 8px 12px;
  color: var(--accent);
  text-decoration: none;
}
.lang-list a:is(:hover, [aria-current]), .drawer-list a:is(:hover, [aria-current]) { background: var(--bg-panel); color: var(--text); }
.mast-veil { position: fixed; inset: 0; z-index: -1; background: var(--veil); color: var(--on-ink); }
.footer-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr 1.4fr .8fr;
  gap: var(--column-gap);
}
.site-footer { padding-block: 56px 24px; }
.site-footer h2 { font-size: var(--fs-body); margin-block-end: 12px; }
.site-footer p { color: var(--muted); margin-block-start: 12px; }
.foot-list { list-style: none; padding: 0; margin: 0; }
.foot-list a { display: inline-block; padding-block: 4px; color: var(--fg); text-decoration: none; }
.foot-list a:hover { text-decoration: underline; text-underline-offset: .22em; }
.foot-end { margin-block-start: 32px; border-top: var(--rule) solid var(--divider); padding-block-start: 18px; }
.foot-end p { margin: 0; }

.reveal { opacity: 1; }
.reveal-ready .reveal { transition: opacity var(--reveal-time) ease, transform var(--reveal-time) ease; }
.reveal-ready .reveal:not(.shown):not(:focus-within):not(:target) { opacity: 0; transform: translateY(var(--reveal-offset)); }

@media (min-width: 961px) and (max-width: 1160px) {
  .masthead { padding-inline: 40px; gap: 20px; }
  .trail, .trail li { gap: 10px; }
}
@media (max-width: 960px) {
  :root { --gutter: 20px; --edge: 20px; --header-h: 72px; --fs-h1: clamp(24px, 7vw, 30px); }
  .masthead { gap: 8px; padding-block: 10px; }
  .mast-tools { margin-inline-start: auto; }
  .main-trail { display: none; }
  .burger { display: inline-flex; min-width: var(--touch); min-height: var(--touch); padding: 6px; }
  .lang { min-height: var(--touch); }
  .mast-drawer, .preview-drawer[open] .drawer-sheet {
    display: block;
    position: absolute;
    inset-inline: 0;
    inset-block-start: 100%;
    z-index: 2;
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg);
    color: var(--text);
    padding: 8px var(--gutter) 16px;
    border-block: var(--rule) solid var(--border);
  }
  .drawer-sheet { display: none; }
  .drawer-list { list-style: none; padding: 0; margin: 0; }
  .drawer-list + .drawer-list { margin-block-start: 8px; border-top: var(--rule) solid var(--border); padding-block-start: 8px; }
  .preview-drawer { display: block; }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .tilt, .tilt:hover { transform: none; rotate: none; }
  .lang-full { display: none; }
  .lang-short { display: inline; }
  .lang { padding-inline: 8px; }
  .masthead .brand { flex-shrink: 1; gap: 7px; font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
  .masthead .brand-mark { width: 26px; height: 26px; }
  .site-footer .brand { flex-shrink: 1; font-size: var(--fs-body); }
  .footer-grid > :first-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal-ready .reveal.reveal { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}