:root {
  --paper: #f5f0e5;
  --paper-soft: #fbf8ef;
  --ink: #1d1a16;
  --ink-soft: #5d554b;
  --line: #d7cbb8;
  --line-strong: #a58e72;
  --vermilion: #a43d2f;
  --vermilion-dark: #762a21;
  --indigo: #1c3147;
  --moss: #4d6543;
  --gold: #b48945;
  --shadow: 0 20px 45px rgba(33, 25, 16, 0.16);
  --font: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "Batang", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(164, 61, 47, 0.14), transparent 34rem),
    linear-gradient(90deg, rgba(28, 49, 71, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(var(--paper), #ede3d2);
  background-size: auto, 34px 34px, auto;
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.75;
}

a { color: var(--vermilion-dark); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--vermilion); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(111, 91, 66, 0.32);
  background: rgba(251, 248, 239, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fffaf0;
  background: var(--indigo);
  font-family: var(--serif);
  font-weight: 700;
}
.brand strong { display: block; line-height: 1.1; }
.brand small { display: block; color: var(--ink-soft); font-size: 12px; line-height: 1.2; }

.icon-button {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-soft);
  color: var(--ink);
  font-size: 20px;
}

.header-actions {
  margin-left: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.header-actions a,
.image-toggle {
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-decoration: none;
  color: var(--ink);
  font: inherit;
}
.image-toggle {
  border: 1px solid rgba(164, 61, 47, 0.28);
  white-space: nowrap;
  cursor: pointer;
}
.header-actions a:hover,
.image-toggle:hover { background: rgba(164, 61, 47, 0.08); }
.image-toggle[aria-pressed="false"] {
  color: var(--ink-soft);
  background: rgba(111, 91, 66, 0.08);
}
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  padding: 3px;
  border: 1px solid rgba(164, 61, 47, 0.28);
  border-radius: 9px;
}
.lang-link {
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink);
  opacity: 0.55;
  text-decoration: none;
  transition: 0.15s;
}
.lang-link:hover { background: rgba(164, 61, 47, 0.1); opacity: 1; }
.lang-link.cur { background: #a43d2f; color: #fff; opacity: 1; }
.site-footer { margin-top: 44px; border-top: 1px solid var(--line); background: var(--paper-soft); }
.footer-inner { max-width: 1180px; margin: 0 auto; padding: 26px 22px 36px; text-align: center; }
.footer-title { font-family: var(--serif); font-weight: 700; font-size: 15px; color: var(--ink); opacity: 0.9; }
.footer-meta { margin-top: 11px; display: flex; flex-wrap: wrap; gap: 6px 9px; justify-content: center; align-items: center; font-size: 12.5px; color: var(--ink-soft); }
.footer-meta a { color: var(--vermilion); text-decoration: none; }
.footer-meta a:hover { text-decoration: underline; }
.footer-meta .dot { opacity: 0.4; }
.footer-sub { margin-top: 11px; font-size: 11.5px; letter-spacing: 0.04em; color: var(--ink-soft); opacity: 0.75; }
@media (max-width: 760px) { .footer-meta .dot { display: none; } }
/* Anchor offset: keep headings clear of the sticky header when jumped to. */
.markdown-body h1[id], .markdown-body h2[id], .markdown-body h3[id],
.markdown-body h4[id], .markdown-body h5[id], .markdown-body h6[id] { scroll-margin-top: 78px; }
:target { scroll-margin-top: 78px; }
/* Print / PDF: drop site chrome, show clean content for tabletop use. */
@media print {
  .site-header, .sidebar, .toc, .scrim, .to-top, .page-nav, .breadcrumb, .doc-kicker { display: none !important; }
  .site-shell { display: block !important; padding: 0 !important; }
  .content { padding: 0 !important; }
  .doc-card { border: none !important; box-shadow: none !important; padding: 0 !important; max-width: none !important; }
  body, .markdown-body { color: #000 !important; background: #fff !important; }
  a { color: #000 !important; text-decoration: none !important; }
  .markdown-body table, .markdown-body pre, .markdown-body blockquote,
  .markdown-body .callout, .markdown-body img { break-inside: avoid; page-break-inside: avoid; }
  .markdown-body h1, .markdown-body h2, .markdown-body h3 { break-after: avoid; page-break-after: avoid; }
  .site-footer { margin-top: 24px; border-top: 1px solid #ccc; background: none !important; }
  .footer-meta a { color: #000 !important; }
  @page { margin: 16mm 14mm; }
}

.site-shell {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr) minmax(190px, 250px);
  gap: 22px;
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.sidebar,
.toc {
  position: sticky;
  top: 86px;
  align-self: start;
  max-height: calc(100vh - 108px);
}
.sidebar { overflow: hidden; }
.sidebar-inner,
.toc-inner {
  border: 1px solid rgba(111, 91, 66, 0.3);
  border-radius: 8px;
  background: rgba(251, 248, 239, 0.82);
  box-shadow: 0 10px 30px rgba(33, 25, 16, 0.08);
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 108px);
  min-height: 0;
  overflow: hidden;
  padding: 14px;
}
.toc-inner {
  max-height: calc(100vh - 108px);
  overflow: auto;
  padding: 16px;
}

.search-label,
.toc-title {
  display: block;
  flex: 0 0 auto;
  color: var(--moss);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-search {
  flex: 0 0 auto;
  width: 100%;
  margin: 8px 0 14px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--ink);
  font: inherit;
}
.nav-tree {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.nav-group { border-top: 1px solid rgba(111, 91, 66, 0.18); }
.nav-group:first-child { border-top: 0; }
.nav-group-title,
.nav-folder-title {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.nav-group-title {
  padding: 10px 4px;
  color: var(--indigo);
  font-weight: 800;
}
.nav-group-title::before {
  content: "▾";
  display: inline-block;
  width: 18px;
  color: var(--gold);
}
.nav-group-title[aria-expanded="false"]::before { content: "▸"; }
.nav-group-title[aria-expanded="false"] + .nav-group-items { display: none; }
.nav-folder {
  margin: 2px 0;
}
.nav-folder-title {
  padding: 7px 8px 7px 22px;
  border-radius: 5px;
  color: #3b4b46;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.4;
}
.nav-folder-title:hover {
  background: rgba(83, 112, 96, 0.08);
  color: var(--ink);
}
.nav-folder-title.active {
  background: rgba(164, 61, 47, 0.09);
  color: var(--ink);
}
.nav-folder-title::before {
  content: "▾";
  display: inline-block;
  width: 14px;
  margin-left: -14px;
  color: var(--gold);
}
.nav-folder-title[aria-expanded="false"]::before { content: "▸"; }
.nav-folder-title[aria-expanded="false"] + .nav-folder-items { display: none; }
.nav-folder-items {
  margin-left: 8px;
  border-left: 1px solid rgba(111, 91, 66, 0.16);
}
.nav-link {
  display: block;
  padding: 7px 8px 7px 22px;
  border-radius: 5px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.nav-index-link {
  color: #74644e;
  font-style: normal;
}
.nav-link:hover,
.nav-link.active {
  color: var(--ink);
  background: rgba(164, 61, 47, 0.09);
}
.nav-special {
  margin: 8px 6px;
  padding: 10px 12px 10px 12px;
  border: 1px solid rgba(164, 61, 47, 0.38);
  border-radius: 8px;
  background: rgba(164, 61, 47, 0.07);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  letter-spacing: 0.02em;
}
.nav-special:hover {
  border-color: rgba(164, 61, 47, 0.7);
  background: rgba(164, 61, 47, 0.14);
  color: var(--ink);
}
.nav-zn-entry { margin-top: 18px; }
.nav-base-return { margin-bottom: 14px; }
[data-theme="dark"] .nav-special { border-color: rgba(217, 138, 95, 0.4); background: rgba(217, 138, 95, 0.08); }
[data-theme="dark"] .nav-special:hover { border-color: rgba(217, 138, 95, 0.7); background: rgba(217, 138, 95, 0.16); }
.nav-group[data-root="qs"] .nav-group-title { color: #a43d2f; font-weight: 800; }
[data-theme="dark"] .nav-group[data-root="qs"] .nav-group-title { color: #e0876a; }

.content { min-width: 0; }
.doc-card {
  max-width: 920px;
  margin: 0 auto 70px;
  padding: clamp(24px, 4vw, 54px);
  border: 1px solid rgba(111, 91, 66, 0.25);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(247, 241, 229, 0.96)),
    var(--paper-soft);
  box-shadow: var(--shadow);
}
.home-page .doc-card {
  border-top: 5px solid var(--vermilion);
}
.doc-kicker {
  color: var(--moss);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.source-path {
  margin-top: 4px;
  color: #8a7a66;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.markdown-body {
  margin-top: 26px;
  font-size: 17px;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  position: relative;
  margin: 1.9em 0 0.65em;
  color: var(--ink);
  line-height: 1.35;
  letter-spacing: 0;
}
.markdown-body h1 {
  margin-top: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 800;
}
.markdown-body h2 {
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-size: clamp(24px, 3vw, 32px);
}
.markdown-body h3 { font-size: 22px; color: var(--indigo); }
.markdown-body h4 { font-size: 18px; color: var(--vermilion-dark); }
.anchor {
  position: absolute;
  left: -24px;
  opacity: 0;
  color: var(--gold);
  text-decoration: none;
}
.markdown-body h1:hover .anchor,
.markdown-body h2:hover .anchor,
.markdown-body h3:hover .anchor,
.markdown-body h4:hover .anchor { opacity: 1; }

.markdown-body p { margin: 0.75em 0; }
.markdown-body p:has(> .interior-illustration-open:only-child),
.markdown-body p:has(> img.interior-illustration-image:only-child) {
  margin: 1.65em 0;
  text-align: center;
}
.markdown-body .interior-illustration-open {
  display: inline-block;
  max-width: min(100%, 760px);
  color: inherit;
  line-height: 0;
  text-decoration: none;
  cursor: zoom-in;
}
.markdown-body .interior-illustration-open:focus-visible {
  outline: 3px solid rgba(46, 91, 126, 0.45);
  outline-offset: 5px;
}
.markdown-body img.interior-illustration-image {
  display: block;
  width: auto;
  max-width: min(100%, 760px);
  max-height: 820px;
  margin: 0 auto;
  border: 1px solid rgba(111, 91, 66, 0.22);
  border-radius: 4px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 12px 34px rgba(47, 33, 24, 0.08);
}
html[data-images="hidden"] .markdown-body p:has(> .interior-illustration-open:only-child),
html[data-images="hidden"] .markdown-body p:has(> img.interior-illustration-image:only-child),
html[data-images="hidden"] .markdown-body .interior-illustration-open,
html[data-images="hidden"] .markdown-body img.interior-illustration-image {
  display: none !important;
}
.image-lightbox[hidden] {
  display: none !important;
}
.image-lightbox {
  position: fixed;
  z-index: 90;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 30px);
}
.image-lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(16, 13, 10, 0.78);
  cursor: zoom-out;
}
.image-lightbox-frame {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: min(96vw, 1400px);
  max-height: 92vh;
  margin: 0;
}
.image-lightbox-frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(92vh - 56px);
  border: 1px solid rgba(244, 238, 227, 0.34);
  border-radius: 4px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.48);
}
.image-lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(244, 238, 227, 0.44);
  border-radius: 999px;
  background: rgba(18, 15, 12, 0.76);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.image-lightbox figcaption {
  max-width: min(96vw, 920px);
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(16, 13, 10, 0.62);
  color: #f8efe1;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}
body.lightbox-open {
  overflow: hidden;
}
.markdown-body blockquote {
  margin: 1.4em 0;
  padding: 14px 18px;
  border-left: 4px solid var(--vermilion);
  border-radius: 0 7px 7px 0;
  background: rgba(164, 61, 47, 0.07);
  color: #3f342a;
}
.markdown-body blockquote > :first-child { margin-top: 0; }
.markdown-body blockquote > :last-child { margin-bottom: 0; }
.markdown-body .callout { position: relative; padding-right: 38px; }
.markdown-body .callout::before {
  position: absolute;
  top: 10px;
  right: 13px;
  font-size: 15px;
  font-weight: 700;
  opacity: 0.5;
}
.callout-design { border-left-color: var(--gold); background: rgba(180, 137, 69, 0.10); }
.callout-design::before { content: "✎"; color: var(--gold); }
.callout-canon { border-left-color: var(--indigo); background: rgba(28, 49, 71, 0.08); }
.callout-canon::before { content: "⚖"; color: var(--indigo); }
.callout-warn { border-left-color: var(--vermilion); background: rgba(164, 61, 47, 0.11); }
.callout-warn::before { content: "⚠"; color: var(--vermilion-dark); }
.callout-gm { border-left-color: var(--moss); background: rgba(77, 101, 67, 0.10); }
.callout-gm::before { content: "▲"; color: var(--moss); }
.callout-key { border-left-color: var(--indigo); background: rgba(28, 49, 71, 0.06); }
.callout-key::before { content: "◈"; color: var(--indigo); }
.callout-weak { border-left-color: var(--vermilion-dark); background: rgba(118, 42, 33, 0.08); }
.callout-weak::before { content: "✖"; color: var(--vermilion-dark); }
.markdown-body .rule-tag {
  display: inline-block;
  padding: 0.05em 0.55em;
  border-radius: 999px;
  background: rgba(28, 49, 71, 0.1);
  border: 1px solid rgba(28, 49, 71, 0.22);
  color: var(--indigo);
  font-size: 0.85em;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: baseline;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.markdown-body .rule-tag[data-tip]:hover {
  background: rgba(28, 49, 71, 0.16);
  border-color: rgba(28, 49, 71, 0.4);
}
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-soft);
}
.breadcrumb a { color: var(--ink-soft); text-decoration: none; }
.breadcrumb a:hover { color: var(--vermilion-dark); text-decoration: underline; }
.breadcrumb .crumb-sep { color: var(--gold); }
.breadcrumb .crumb-current { color: var(--ink); font-weight: 700; }
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 48px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.page-nav a {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 15px;
  border: 1px solid rgba(111, 91, 66, 0.28);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.7);
  text-decoration: none;
}
.page-nav a:hover { border-color: var(--line-strong); background: rgba(164, 61, 47, 0.06); }
.page-nav-next { text-align: right; }
.page-nav-dir { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--moss); }
.page-nav-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 35;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(251, 248, 239, 0.95);
  color: var(--ink);
  font-size: 21px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(33, 25, 16, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { background: rgba(164, 61, 47, 0.1); }
.markdown-body .gloss { border-bottom: 1px dotted var(--line-strong); cursor: help; }
.markdown-body .gloss,
.markdown-body .rule-tag[data-tip] { position: relative; }
.markdown-body .rule-tag[data-tip] { cursor: help; }
.markdown-body .gloss::after,
.markdown-body .rule-tag[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 60;
  width: max-content;
  max-width: 264px;
  padding: 8px 11px;
  border-radius: 7px;
  background: #25303c;
  color: #f3ece0;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}
.markdown-body .gloss:hover::after,
.markdown-body .gloss:focus::after,
.markdown-body .rule-tag[data-tip]:hover::after,
.markdown-body .rule-tag[data-tip]:focus::after { opacity: 1; }
.theme-toggle {
  margin-left: auto;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-soft);
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover { background: rgba(164, 61, 47, 0.08); }
.search-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}
.sr-meta { padding: 2px 4px 9px; color: var(--ink-soft); font-size: 12px; }
.sr-item {
  display: block;
  padding: 9px 10px;
  margin-bottom: 6px;
  border: 1px solid rgba(111, 91, 66, 0.2);
  border-radius: 7px;
  background: rgba(255, 253, 247, 0.7);
  text-decoration: none;
}
.sr-item:hover { border-color: var(--line-strong); background: rgba(164, 61, 47, 0.06); }
.sr-root { color: var(--moss); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.sr-title { display: block; margin-top: 1px; color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.35; }
.sr-snippet { display: block; margin-top: 4px; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.sr-snippet mark { background: rgba(180, 137, 69, 0.38); color: inherit; padding: 0 1px; border-radius: 2px; }
.markdown-body ul,
.markdown-body ol { padding-left: 1.5em; }
.markdown-body li { margin: 0.28em 0; }
.markdown-body hr {
  margin: 2.2em 0;
  border: 0;
  border-top: 1px solid var(--line);
}
.markdown-body code {
  padding: 0.12em 0.32em;
  border-radius: 4px;
  background: rgba(28, 49, 71, 0.09);
  color: #172c42;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
}
.markdown-body pre {
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #17202a;
  color: #f6f0e5;
}
.markdown-body pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}
.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.4em auto;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(33, 25, 16, 0.18);
}
.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  margin: 1.3em 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  /* Scroll-shadow hint (Lea Verou pattern): the two edge "cover" gradients are
     pinned to the scroll viewport (scroll); the inner shadow gradients ride with
     the content (local). When scrolled to an edge the cover hides its shadow, so
     a soft fade appears only on the side that has more content off-screen. */
  background:
    linear-gradient(90deg, #fffdf7 30%, rgba(255, 253, 247, 0)) left center,
    linear-gradient(90deg, rgba(255, 253, 247, 0), #fffdf7 70%) right center,
    radial-gradient(farthest-side at 0 50%, rgba(33, 25, 16, 0.16), rgba(33, 25, 16, 0)) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(33, 25, 16, 0.16), rgba(33, 25, 16, 0)) right center;
  background-color: #fffdf7;
  background-repeat: no-repeat;
  background-size: 44px 100%, 44px 100%, 18px 100%, 18px 100%;
  background-attachment: local, local, scroll, scroll;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
  background: transparent;
}
th,
td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid rgba(215, 203, 184, 0.7);
  vertical-align: top;
}
th {
  position: sticky;
  top: 0; /* header row stays pinned to the top of the scroll container */
  z-index: 2;
  background: #e7ecf1;
  color: var(--indigo);
  font-weight: 800;
  box-shadow: inset 0 -1px 0 var(--line-strong);
}
tr:last-child td { border-bottom: 0; }
td:last-child,
th:last-child { border-right: 0; }

.toc-link {
  display: block;
  margin-top: 9px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.45;
}
.toc-link:hover { color: var(--vermilion-dark); }
.toc-l3 { padding-left: 14px; }
.toc-empty { margin: 10px 0 0; color: var(--ink-soft); font-size: 13px; }

/* Inline in-page TOC after the h1 — only shown when the right-rail TOC is hidden. */
.doc-toc { display: none; margin: 18px 0 6px; }
.doc-toc[open] { padding-bottom: 6px; }
.doc-toc-summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid rgba(111, 91, 66, 0.3);
  border-radius: 8px;
  background: rgba(251, 248, 239, 0.85);
  color: var(--moss);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}
.doc-toc-summary::-webkit-details-marker { display: none; }
.doc-toc-summary::before {
  content: "▸";
  color: var(--gold);
  transition: transform 0.15s ease;
}
.doc-toc[open] .doc-toc-summary::before { transform: rotate(90deg); }
.doc-toc-summary:hover { background: rgba(164, 61, 47, 0.08); }
.doc-toc-list {
  margin-top: 8px;
  padding: 4px 6px 4px 4px;
  border-left: 2px solid var(--line);
}
.doc-toc-link {
  display: block;
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
}
.doc-toc-link:hover { color: var(--vermilion-dark); background: rgba(164, 61, 47, 0.07); }
.doc-toc-l3 { padding-left: 22px; font-size: 13px; color: #6f6253; }

.sheet-app {
  margin: 1.5em 0 2em;
  border: 1px solid rgba(111, 91, 66, 0.32);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.7);
}
.sheet-toolbar {
  position: sticky;
  top: 74px;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(111, 91, 66, 0.22);
  background: rgba(246, 240, 228, 0.96);
}
.sheet-save-status {
  display: block;
  margin-top: 2px;
  color: #7c6d5a;
  font-size: 12px;
  font-weight: 600;
}
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.sheet-actions button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(111, 91, 66, 0.38);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.sheet-actions button:hover { background: rgba(164, 61, 47, 0.08); }
.fillable-sheet {
  padding: 16px;
}
.fillable-sheet fieldset {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid rgba(111, 91, 66, 0.28);
  border-radius: 8px;
  background: rgba(251, 248, 239, 0.72);
}
.fillable-sheet legend {
  padding: 0 8px;
  color: var(--indigo);
  font-weight: 850;
}
.sheet-note {
  color: var(--ink-soft);
  font-size: 14px;
}
.sheet-grid,
.sheet-repeat-row {
  display: grid;
  gap: 10px;
}
.sheet-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sheet-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sheet-derived-grid { margin-top: 12px; }
.sheet-repeat { display: grid; gap: 12px; }
.sheet-repeat-row { grid-template-columns: 1.25fr 0.55fr 0.75fr 1.5fr; }
.sheet-field {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: #2b261f;
  font-size: 13px;
  font-weight: 750;
}
.sheet-field span {
  line-height: 1.25;
}
.sheet-field small {
  color: #7e715f;
  font-weight: 500;
  line-height: 1.3;
}
.sheet-field input,
.sheet-field select,
.sheet-field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(111, 91, 66, 0.34);
  border-radius: 6px;
  background: #fffefa;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.sheet-field input,
.sheet-field select {
  min-height: 36px;
  padding: 7px 9px;
}
.sheet-field textarea {
  resize: vertical;
  padding: 8px 9px;
  line-height: 1.45;
}
.sheet-field input[readonly] {
  background: rgba(28, 49, 71, 0.07);
  color: var(--indigo);
  font-weight: 800;
}
.sheet-field-wide { grid-column: 1 / -1; }
.sheet-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}
.sheet-check-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 750;
}
.skill-sheet-grid,
.squad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.skill-group,
.squad-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(111, 91, 66, 0.2);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.76);
}
.skill-group h4,
.squad-card h3 {
  margin: 0 0 10px;
}
.skill-group {
  display: grid;
  gap: 8px;
}
.squad-card {
  display: grid;
  gap: 8px;
}
.sheet-line-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.scrim { display: none; }

@media (max-width: 1180px) {
  .site-shell { grid-template-columns: minmax(230px, 280px) minmax(0, 1fr); }
  .toc { display: none; }
  /* Right-rail TOC is gone here → surface the inline collapsible TOC instead. */
  .doc-toc { display: block; }
}

@media (max-width: 820px) {
  .site-header { height: 58px; padding: 0 12px; }
  .icon-button { display: grid; place-items: center; }
  .brand small { display: none; }
  .header-actions .ha-link { display: none; }
  .header-actions { gap: 6px; }
  .image-toggle { padding: 7px 8px; font-size: 12px; }
  .lang-switch { margin-left: auto; }
  .site-shell {
    display: block;
    padding: 12px;
  }
  .sidebar {
    display: none;
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 340px);
    max-height: none;
    overflow: hidden;
    transform: none;
  }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar {
    display: block;
  }
  .sidebar-inner {
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
  body.nav-open .scrim {
    display: block;
    position: fixed;
    z-index: 40;
    inset: 0;
    background: rgba(23, 20, 16, 0.42);
  }
  .doc-card {
    padding: 22px 17px 34px;
    border-radius: 6px;
  }
  .markdown-body { font-size: 16px; }
  .markdown-body {
    max-width: 100%;
    overflow-x: clip;
    overflow-wrap: anywhere;
  }
  .markdown-body .interior-illustration-open,
  .markdown-body img.interior-illustration-image {
    max-width: 100%;
  }
  .markdown-body img.interior-illustration-image {
    max-height: none;
  }
  .markdown-body h1 { font-size: 32px; }
  .image-lightbox {
    padding: 10px;
  }
  .image-lightbox-frame {
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }
  .image-lightbox-frame img {
    max-height: calc(100dvh - 76px);
  }
  .image-lightbox figcaption {
    max-width: calc(100vw - 20px);
    font-size: 12px;
  }
  .sheet-toolbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }
  .sheet-actions { justify-content: flex-start; }
  .fillable-sheet { padding: 11px; }
  .fillable-sheet fieldset { padding: 12px; }
  .sheet-grid-4,
  .sheet-grid-3,
  .sheet-repeat-row,
  .skill-sheet-grid,
  .squad-grid,
  .sheet-line-list {
    grid-template-columns: 1fr;
  }
  .page-nav { grid-template-columns: 1fr; }
  .to-top { right: 14px; bottom: 14px; }
  .anchor { display: none; }
  .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
  }
  table {
    width: max-content;
    min-width: 100%;
    max-width: none;
  }
}

@media print {
  .site-header,
  .sidebar,
  .toc,
  .doc-toc,
  .scrim,
  .source-path,
  .breadcrumb,
  .page-nav,
  .to-top,
  .image-lightbox,
  .doc-kicker,
  .sheet-toolbar {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .site-shell {
    display: block;
    padding: 0;
  }
  .doc-card {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }
  .sheet-app,
  .fillable-sheet fieldset,
  .skill-group,
  .squad-card {
    background: #fff;
    box-shadow: none;
  }
  .sheet-field input,
  .sheet-field select,
  .sheet-field textarea {
    border-color: #999;
    background: #fff;
  }
}

[data-theme="dark"] {
  --paper: #17140f;
  --paper-soft: #201b15;
  --ink: #ece3d3;
  --ink-soft: #b0a48f;
  --line: #3a322a;
  --line-strong: #5d5142;
  --vermilion: #e2856b;
  --vermilion-dark: #ec9b85;
  --indigo: #9fb6cd;
  --moss: #a3bd90;
  --gold: #cfa760;
  --shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(226, 133, 107, 0.1), transparent 34rem),
    linear-gradient(90deg, rgba(159, 182, 205, 0.045) 0 1px, transparent 1px 100%),
    linear-gradient(#17140f, #0f0d0a);
}
[data-theme="dark"] .site-header { background: rgba(23, 20, 15, 0.92); border-bottom-color: rgba(150, 130, 100, 0.22); }
[data-theme="dark"] .brand-mark { background: #2c3a49; color: #f3ece0; }
[data-theme="dark"] .icon-button,
[data-theme="dark"] .theme-toggle,
[data-theme="dark"] .image-toggle,
[data-theme="dark"] .nav-search { background: #241f18; }
[data-theme="dark"] .markdown-body img.interior-illustration-image {
  border-color: rgba(207, 167, 96, 0.24);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42);
}
[data-theme="dark"] .sidebar-inner,
[data-theme="dark"] .toc-inner { background: rgba(32, 27, 21, 0.85); border-color: rgba(120, 100, 78, 0.24); }
[data-theme="dark"] .doc-card {
  background: linear-gradient(180deg, rgba(36, 31, 25, 0.98), rgba(28, 24, 19, 0.97)), var(--paper-soft);
  border-color: rgba(120, 100, 78, 0.26);
}
[data-theme="dark"] .table-wrap {
  background:
    linear-gradient(90deg, #241f18 30%, rgba(36, 31, 24, 0)) left center,
    linear-gradient(90deg, rgba(36, 31, 24, 0), #241f18 70%) right center,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)) right center;
  background-color: #241f18;
  background-repeat: no-repeat;
  background-size: 44px 100%, 44px 100%, 18px 100%, 18px 100%;
  background-attachment: local, local, scroll, scroll;
}
[data-theme="dark"] table { background: transparent; }
[data-theme="dark"] th { background: #2a3440; box-shadow: inset 0 -1px 0 var(--line-strong); }
[data-theme="dark"] .markdown-body code { background: rgba(159, 182, 205, 0.15); color: #cfe0f0; }
[data-theme="dark"] .markdown-body blockquote { color: #d9cdb8; }
[data-theme="dark"] .rule-tag { background: rgba(159, 182, 205, 0.16); border-color: rgba(159, 182, 205, 0.3); color: #c3d6e8; }
[data-theme="dark"] .page-nav a,
[data-theme="dark"] .to-top,
[data-theme="dark"] .sr-item { background: #241f18; }
[data-theme="dark"] .doc-toc-summary { background: rgba(32, 27, 21, 0.85); border-color: rgba(120, 100, 78, 0.3); }
[data-theme="dark"] .doc-toc-l3 { color: #b0a48f; }
[data-theme="dark"] .sheet-app,
[data-theme="dark"] .fillable-sheet fieldset,
[data-theme="dark"] .skill-group,
[data-theme="dark"] .squad-card,
[data-theme="dark"] .sheet-toolbar { background: rgba(32, 27, 21, 0.72); }
[data-theme="dark"] .sheet-field input,
[data-theme="dark"] .sheet-field select,
[data-theme="dark"] .sheet-field textarea { background: #2a241d; color: var(--ink); border-color: rgba(120, 100, 78, 0.4); }
[data-theme="dark"] .sheet-field input[readonly] { background: rgba(159, 182, 205, 0.12); color: var(--indigo); }
[data-theme="dark"] .sheet-actions button { background: #2a241d; color: var(--ink); }

/* === UX pass v1.2 === */
.skip-link { position: fixed; left: 10px; top: -52px; z-index: 320; background: #8b2f23; color: #fff; padding: 9px 16px; border-radius: 10px; font-weight: 700; text-decoration: none; transition: top .15s ease; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.skip-link:focus { top: 10px; }
.read-progress { position: fixed; left: 0; top: 0; width: 100%; height: 3px; z-index: 300; pointer-events: none; }
.read-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8b2f23, #c4663a); transition: width .08s linear; }
.toc a.toc-active, .doc-toc a.toc-active { color: #8b2f23; font-weight: 700; }
.toc a.toc-active { border-left: 2px solid currentColor; padding-left: 8px; margin-left: -10px; }
[data-theme="dark"] .toc a.toc-active, [data-theme="dark"] .doc-toc a.toc-active { color: #d98a5f; }
.sr-item.sr-active { outline: 2px solid rgba(139, 47, 35, .55); outline-offset: -2px; border-radius: 6px; }
[data-theme="dark"] .sr-item.sr-active { outline-color: rgba(217, 138, 95, .65); }
.markdown-body h2 .anchor, .markdown-body h3 .anchor, .markdown-body h4 .anchor { opacity: 0; transition: opacity .12s; text-decoration: none; margin-right: 7px; cursor: pointer; }
.markdown-body h2:hover .anchor, .markdown-body h3:hover .anchor, .markdown-body h4:hover .anchor, .markdown-body .anchor:focus-visible { opacity: .75; }
.markdown-body .anchor.copied { opacity: 1 !important; }
.markdown-body .anchor.copied::after { content: attr(data-tip); font-size: 11px; margin-left: 7px; color: #3f7a4f; font-weight: 600; }
[data-theme="dark"] .markdown-body .anchor.copied::after { color: #8fc49a; }
:focus-visible { outline: 2px solid rgba(139, 47, 35, .55); outline-offset: 2px; }
.markdown-body h2.hb, .markdown-body h3.hb { padding-left: 12px; border-left: 4px solid #c4663a; }
.markdown-body h2.hb-beop, .markdown-body h3.hb-beop { border-left-color: #3d5a80; }
.markdown-body h2.hb-hyang::before, .markdown-body h3.hb-hyang::before { content: "香"; font-size: .68em; vertical-align: .14em; margin-right: 8px; color: #c4663a; opacity: .9; }
.markdown-body h2.hb-beop::before, .markdown-body h3.hb-beop::before { content: "法"; font-size: .68em; vertical-align: .14em; margin-right: 8px; color: #3d5a80; opacity: .9; }
[data-theme="dark"] .markdown-body h2.hb-hyang, [data-theme="dark"] .markdown-body h3.hb-hyang { border-left-color: #d98a5f; }
[data-theme="dark"] .markdown-body h2.hb-beop, [data-theme="dark"] .markdown-body h3.hb-beop { border-left-color: #9fb6cd; }
[data-theme="dark"] .markdown-body h2.hb-hyang::before, [data-theme="dark"] .markdown-body h3.hb-hyang::before { color: #d98a5f; }
[data-theme="dark"] .markdown-body h2.hb-beop::before, [data-theme="dark"] .markdown-body h3.hb-beop::before { color: #9fb6cd; }
@media print { .read-progress, .skip-link { display: none !important; } }