:root {
  --bg: #f6f3ec; --panel: #fdfbf7; --wash: #efeae0; --rule: #e2dccf; --rule-strong: #d6cebf;
  --ink: #1e2a3a; --muted: #6b6357; --accent: #b5532d; --accent-wash: #f1e3d9; --shadow: rgba(30, 42, 58, 0.10);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --panel: #1c1b19; --wash: #2c2a26; --rule: #34312c; --rule-strong: #4a463f;
    --ink: #e9e4da; --muted: #a39b8c; --accent: #e07a4f; --accent-wash: #3a2c24; --shadow: rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --panel: #1c1b19; --wash: #2c2a26; --rule: #34312c; --rule-strong: #4a463f;
  --ink: #e9e4da; --muted: #a39b8c; --accent: #e07a4f; --accent-wash: #3a2c24; --shadow: rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
.eyebrow { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
kbd { font: 12.5px var(--mono); padding: 1px 6px; border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--panel); white-space: nowrap; }
code { font: 0.9em var(--mono); background: var(--wash); padding: 1px 5px; border-radius: 3px; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--rule); }
.brand { font-weight: 900; font-size: 20px; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand span { font-weight: 500; font-size: 14px; letter-spacing: 0; color: var(--muted); margin-left: 4px; }
.search { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.search input { width: 100%; height: 34px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--bg); color: var(--ink); font: inherit; font-size: 14px; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#hits { position: absolute; top: 40px; left: 0; right: 0; max-height: 70vh; overflow: auto; margin: 0; padding: 4px 0; list-style: none; background: var(--panel); border: 1px solid var(--rule-strong); border-radius: 4px; box-shadow: 0 10px 30px var(--shadow); }
#hits a { display: block; padding: 8px 12px; color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.4; }
#hits a:hover, #hits a.on { background: var(--accent-wash); }
#hits small { display: block; color: var(--muted); }
#hits .none { padding: 8px 12px; color: var(--muted); font-size: 14px; }
.theme { width: 34px; height: 34px; border: 1px solid var(--rule-strong); border-radius: 4px; background: none; color: var(--ink); cursor: pointer; font-size: 16px; }
.langs { position: relative; }
.langs summary { list-style: none; padding: 6px 10px; border: 1px solid var(--rule-strong); border-radius: 4px; color: var(--ink); font-size: 13px; white-space: nowrap; cursor: pointer; user-select: none; }
.langs summary::-webkit-details-marker { display: none; }
.langs summary::after { content: "▾"; margin-left: 6px; color: var(--muted); }
.langs summary:hover, .langs[open] summary { border-color: var(--accent); color: var(--accent); }
.langs .short { display: none; }
.langs ul { position: absolute; right: 0; top: 40px; z-index: 20; min-width: 150px; margin: 0; padding: 4px 0; list-style: none; background: var(--panel); border: 1px solid var(--rule-strong); border-radius: 4px; box-shadow: 0 10px 30px var(--shadow); }
.langs a { display: block; padding: 7px 14px; color: var(--ink); text-decoration: none; font-size: 14px; }
.langs a:hover { background: var(--wash); }
.langs a[aria-current] { color: var(--accent); font-weight: 600; background: var(--accent-wash); }
.untranslated { margin-top: 0; }
.open { padding: 7px 14px; border-radius: 4px; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none; white-space: nowrap; }

.layout { display: grid; grid-template-columns: 240px minmax(0, 760px) 220px; gap: 48px; justify-content: center; padding: 0 24px; }
.pages { position: sticky; top: 56px; align-self: start; max-height: calc(100vh - 56px); overflow: auto; padding: 28px 0; }
.pages summary { display: none; }
.pages ol { list-style: none; margin: 0; padding: 0; counter-reset: p; }
.pages li a { display: block; padding: 6px 12px; border-left: 2px solid var(--rule); color: var(--ink); text-decoration: none; font-size: 14.5px; }
.pages li a:hover { border-left-color: var(--rule-strong); background: var(--wash); }
.pages li a[aria-current] { border-left-color: var(--accent); color: var(--accent); font-weight: 600; background: var(--accent-wash); }
.toc { position: sticky; top: 56px; align-self: start; padding: 28px 0; font-size: 13.5px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; line-height: 1.35; }
.toc a:hover, .toc a.on { color: var(--accent); }

main { padding: 32px 0 48px; min-width: 0; }
h1 { font-size: 38px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 10px; }
.lead { font-size: 19px; color: var(--muted); margin: 0 0 28px; }
h2 { font-size: 25px; letter-spacing: -0.01em; margin: 48px 0 12px; padding-top: 20px; border-top: 1px solid var(--rule); }
h3 { font-size: 18px; margin: 28px 0 8px; }
h1 + h2, .lead + h2 { border-top: none; padding-top: 0; }
.anchor { float: left; margin-left: -1.1em; width: 1em; color: var(--rule-strong); text-decoration: none; opacity: 0; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
article p, article li { max-width: 68ch; }
article ul, article ol { padding-left: 1.4em; }
article li { margin: 4px 0; }
figure { margin: 22px 0 28px; }
figure a { display: block; cursor: zoom-in; }
figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--rule-strong); border-radius: 6px; box-shadow: 0 6px 24px var(--shadow); background: var(--panel); }
figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); }
table { border-collapse: collapse; margin: 16px 0 24px; font-size: 15px; width: 100%; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.note { margin: 20px 0; padding: 12px 18px; border-left: 3px solid var(--accent); background: var(--accent-wash); border-radius: 0 4px 4px 0; }
.note p { margin: 6px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 0; list-style: none; margin: 20px 0; }
.cards li { margin: 0; max-width: none; }
.cards a { display: block; height: 100%; padding: 14px 16px; border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--panel); color: var(--ink); text-decoration: none; }
.cards a:hover { border-color: var(--accent); }
.cards b { display: block; margin-bottom: 4px; }
.cards span { font-size: 14px; color: var(--muted); line-height: 1.45; display: block; }
.video { margin: 22px 0 28px; }
.video-play { position: relative; display: block; width: 100%; padding: 0; border: 1px solid var(--rule-strong); border-radius: 6px; overflow: hidden; background: #000; cursor: pointer; box-shadow: 0 6px 24px var(--shadow); aspect-ratio: 16 / 9; }
.video-play img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0.92; transition: opacity 0.2s; }
.video-play:hover img, .video-play:focus-visible img { opacity: 1; }
.video-play:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.video-icon { position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px; border-radius: 50%; background: var(--accent); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); transition: transform 0.15s; }
.video-icon::after { content: ""; position: absolute; left: 29px; top: 22px; border-style: solid; border-width: 14px 0 14px 22px; border-color: transparent transparent transparent #fff; }
.video-play:hover .video-icon { transform: scale(1.08); }
.video-len { position: absolute; right: 10px; bottom: 10px; padding: 2px 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.72); color: #fff; font: 600 13px var(--font); }
.video iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--rule-strong); border-radius: 6px; background: #000; }
.video figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); }
.video figcaption b { color: var(--ink); }
.videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px 20px; }
.videos .video { margin: 12px 0; }
.videos .video-icon { width: 56px; height: 56px; margin: -28px 0 0 -28px; }
.videos .video-icon::after { left: 22px; top: 17px; border-width: 11px 0 11px 17px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; }
.pager a { padding: 14px 16px; border: 1px solid var(--rule-strong); border-radius: 6px; text-decoration: none; color: var(--ink); font-weight: 600; }
.pager a:hover { border-color: var(--accent); }
.pager .next { text-align: right; }
main > footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--muted); }

@media (max-width: 1180px) { .layout { grid-template-columns: 220px minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 820px) {
  .top { padding: 0 16px; gap: 10px; }
  .brand span, .open { display: none; }
  .langs .long { display: none; }
  .langs .short { display: inline; }
  .layout { display: block; padding: 0 16px; }
  .pages { position: static; max-height: none; padding: 12px 0 0; }
  .pages summary { display: list-item; cursor: pointer; font-weight: 600; padding: 8px 0; }
  main { padding-top: 16px; }
  h1 { font-size: 30px; }
  .anchor { display: none; }
  .pager { grid-template-columns: 1fr; }
}
