/* RTS Terrain Studio manual - offline single page documentation.
   No external requests: the fonts ship with the package, all icons are inline SVG.
   Visual identity "Atlas": parchment panels, sepia ink, map-legend frames, an oxblood accent.
   Light theme = Paper palette, dark theme = Ink palette (same token names). */

/* ------------------------------------------------------------------ fonts */
/* Paths are relative to this file: the fonts sit next to the manual (assets/fonts), so browsers that only load files from the manual folder (Firefox with file://) find them too. */
@font-face {
  font-family: "Spectral SC";
  src: url("fonts/SpectralSC-SemiBold.ttf") format("truetype");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("fonts/Spectral-Italic.ttf") format("truetype");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/SourceSans3-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/SourceSans3-Semibold.ttf") format("truetype");
  font-weight: 600; font-style: normal; font-display: swap;
}

/* ------------------------------------------------------------------ tokens */
:root {
  /* System fallbacks; the Chinese and Japanese pages replace this list (see below). */
  --font-system: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-sans: "Source Sans 3", var(--font-system);
  --font-display: "Spectral SC", Georgia, "Times New Roman", var(--font-system);
  --font-italic: "Spectral", Georgia, "Times New Roman", var(--font-system);
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --topbar-h: 56px;
  --sidebar-w: 300px;
  --content-w: 880px;

  /* Paper */
  --paper: #e8d9bb;
  --paper-raised: #f3e8d2;
  --paper-sunken: #dccaa6;
  --ink: #3a2618;
  --frame: #3a2618;
  --muted: #77604a;
  --faint: #a68c70;
  --rule: #b39371;
  --hover: rgba(58, 38, 24, .08);
  --press: rgba(58, 38, 24, .14);
  --accent: #8e3524;
  --accent-text: #8e3524;
  --on-accent: #f6ecd8;
  --second: #2f5c45;
  --warning: #9a6a12;
  --danger: #8e3524;
  --scrim: rgba(40, 26, 14, .45);

  --link: var(--second);
  --mark-bg: rgba(154, 106, 18, .30);
  --mark-text: var(--ink);
  --selection: rgba(142, 53, 36, .22);
  --code-label: #614d3d;

  /* Syntax colours: warm and green hues, at least 4.5:1 on paper-sunken. */
  --tok-keyword: #8e3524;
  --tok-type: #2c5a40;
  --tok-string: #475614;
  --tok-comment: #614d3d;
  --tok-number: #83400c;
  --tok-fn: #733059;
  --tok-preproc: #6e4d06;

  color-scheme: light;
}

/* Ink: used when the reader's system is dark and no theme was picked, and when the dark theme was picked. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #27221b;
    --paper-raised: #322b22;
    --paper-sunken: #1f1b15;
    --ink: #ece3cc;
    --frame: #8c7c5e;
    --muted: #a8997c;
    --faint: #6e624f;
    --rule: #5c503d;
    --hover: rgba(236, 227, 204, .07);
    --press: rgba(236, 227, 204, .12);
    --accent: #b9503a;
    --accent-text: #e0806a;
    --on-accent: #fbf3e4;
    --second: #6fae84;
    --warning: #d9a441;
    --danger: #e0806a;
    --scrim: rgba(0, 0, 0, .55);
    --mark-bg: rgba(217, 164, 65, .32);
    --selection: rgba(224, 128, 106, .30);
    --code-label: #a8997c;
    --tok-keyword: #e0806a;
    --tok-type: #86bf94;
    --tok-string: #b8c36c;
    --tok-comment: #9a8b70;
    --tok-number: #e39a5c;
    --tok-fn: #d48aa9;
    --tok-preproc: #d9b46a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #27221b;
  --paper-raised: #322b22;
  --paper-sunken: #1f1b15;
  --ink: #ece3cc;
  --frame: #8c7c5e;
  --muted: #a8997c;
  --faint: #6e624f;
  --rule: #5c503d;
  --hover: rgba(236, 227, 204, .07);
  --press: rgba(236, 227, 204, .12);
  --accent: #b9503a;
  --accent-text: #e0806a;
  --on-accent: #fbf3e4;
  --second: #6fae84;
  --warning: #d9a441;
  --danger: #e0806a;
  --scrim: rgba(0, 0, 0, .55);
  --mark-bg: rgba(217, 164, 65, .32);
  --selection: rgba(224, 128, 106, .30);
  --code-label: #a8997c;
  --tok-keyword: #e0806a;
  --tok-type: #86bf94;
  --tok-string: #b8c36c;
  --tok-comment: #9a8b70;
  --tok-number: #e39a5c;
  --tok-fn: #d48aa9;
  --tok-preproc: #d9b46a;
  color-scheme: dark;
}

/* Chinese and Japanese pages: native UI fonts after the Latin faces. */
:root:lang(zh) { --font-system: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif; }
:root:lang(ja) { --font-system: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo UI", Meiryo, "Noto Sans JP", sans-serif; }
:lang(zh) body, :lang(ja) body { line-break: strict; }

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 16px);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16.5px/1.65 var(--font-sans);
  overflow-x: hidden;
}

::selection { background: var(--selection); color: var(--ink); }

a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2.5px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0; }

img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--accent); color: var(--on-accent); padding: 8px 14px; border: 1px solid var(--frame);
  font: 600 14px/1.2 var(--font-display); letter-spacing: 1px; text-decoration: none;
}
.skip-link:focus { top: 8px; }

/* Scroll bars: 6 px, thumb in the rule colour, no track. */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
}

/* ------------------------------------------------------------------ top bar */
/* Paper bar with a double rule at the bottom: 1 px frame, 2 px gap, 1 px frame. */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 40;
  display: flex; align-items: center; gap: 12px; padding: 0 16px 4px;
  background: var(--paper);
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; pointer-events: none;
  border-top: 1px solid var(--frame); border-bottom: 1px solid var(--frame);
}
.brand {
  display: flex; align-items: center; gap: 11px; min-width: 0;
  color: var(--ink); text-decoration: none;
  font: 600 17px/1.2 var(--font-display); letter-spacing: .5px;
}
.brand-logo { width: 30px; height: 30px; flex: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The logo is recoloured as an inked stamp: ink square, oxblood ground, parchment lines. */
.brand-logo rect { fill: var(--ink); rx: 0; ry: 0; }
.brand-logo path:nth-of-type(1) { fill: var(--accent); }
.brand-logo path:nth-of-type(2) { stroke: var(--paper-raised); }
.brand-logo path:nth-of-type(3) { stroke: var(--paper-raised); stroke-width: 1.6; stroke-linecap: butt; }
.brand-logo path:nth-of-type(4) { fill: var(--paper-raised); }

/* Version stamp. */
.version {
  flex: none; padding: 3px 6px 2px;
  font: 600 12px/1 var(--font-sans); letter-spacing: .04em; font-variant-numeric: tabular-nums;
  color: var(--accent-text); border: 1px solid var(--accent);
}
.topbar-spacer { flex: 1; }

/* Icon buttons in bars have no border. */
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 0; background: transparent; color: var(--ink);
  cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:active { background: var(--press); }
.icon-btn svg { width: 19px; height: 19px; }
.menu-btn { display: none; }

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ------------------------------------------------------------------ language switcher */
/* A drop-down: no box, an ink underline and a small caret. */
.lang { position: relative; flex: none; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 6px 0 7px;
  border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink);
  font: 600 13px/1 var(--font-sans); letter-spacing: .06em; cursor: pointer;
}
.lang-btn:hover, .lang-btn[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.lang-chevron { width: 12px; height: 12px; transition: transform .15s ease; }
.lang-btn[aria-expanded="true"] .lang-chevron { transform: rotate(180deg); }
/* Flags keep their colours, slightly aged to sit on parchment. */
.flag {
  display: inline-block; width: 21px; height: 14px; flex: none; overflow: hidden; border-radius: 0;
  outline: 1px solid color-mix(in srgb, var(--ink) 40%, transparent);
  filter: sepia(.28) saturate(.85);
}
.flag svg { display: block; width: 100%; height: 100%; }
.lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; min-width: 210px;
  margin: 0; padding: 4px 0; list-style: none;
  background: var(--paper-raised); border: 1px solid var(--frame); border-radius: 0;
}
.lang-menu[hidden] { display: none; }
.lang-menu li { margin: 0; }
.lang-menu li + li { border-top: 1px solid color-mix(in srgb, var(--rule) 55%, transparent); }
.lang-menu a {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px;
  border-left: 2px solid transparent;
  color: var(--ink); text-decoration: none; font-size: 14.5px; line-height: 1.3;
}
.lang-menu a:hover, .lang-menu a:focus-visible { background: var(--hover); color: var(--ink); outline: none; }
.lang-menu a:focus-visible { border-left-color: var(--accent); }
.lang-menu a[aria-current="true"] { font-weight: 600; border-left-color: var(--accent); }
.lang-code { margin-left: auto; padding-left: 12px; font: 600 11px/1 var(--font-sans); letter-spacing: .08em; color: var(--muted); }

/* ------------------------------------------------------------------ search */
/* A field without a box: transparent, 1 px ink underline, 2 px oxblood underline while focused. */
.search { position: relative; width: min(420px, 42vw); }
.search-input {
  width: 100%; height: 36px; padding: 1px 64px 0 30px;
  -webkit-appearance: none; appearance: none;
  border: 0; border-bottom: 1px solid var(--ink); border-radius: 0;
  background: transparent; color: var(--ink); font: 15px/1 var(--font-sans);
}
.search-input::placeholder { color: var(--faint); opacity: 1; }
.search-input:hover { background: var(--hover); }
.search-input:focus { outline: none; border-bottom: 2px solid var(--accent); padding-bottom: 0; background: transparent; }
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 11px; height: 11px; margin-right: 2px; cursor: pointer;
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='black' stroke-width='1.8'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='black' stroke-width='1.8'/%3E%3C/svg%3E") center / contain no-repeat;
}
.search-input::-webkit-search-cancel-button:hover { background: var(--accent-text); }
.search-icon { position: absolute; left: 6px; top: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-hint {
  position: absolute; right: 4px; top: 8px; padding: 0 5px;
  font: 600 11px/18px var(--font-sans); letter-spacing: .04em; color: var(--muted);
  border: 1px solid var(--rule); border-radius: 0; pointer-events: none; background: transparent;
}
.search-input:focus + .search-hint { display: none; }

/* Results: a pop-up menu on paper-raised with a frame line and rule separators. */
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  max-height: min(70vh, 560px); overflow-y: auto; overscroll-behavior: contain;
  margin: 0; padding: 0; list-style: none;
  background: var(--paper-raised); border: 1px solid var(--frame); border-radius: 0;
  min-width: 340px;
}
.search-results li { margin: 0; }
.search-results li + li { border-top: 1px solid color-mix(in srgb, var(--rule) 55%, transparent); }
.search-result {
  display: block; padding: 9px 12px 10px; border-left: 2px solid transparent;
  color: var(--ink); text-decoration: none; cursor: pointer;
}
.search-result:hover { background: var(--hover); color: var(--ink); }
.search-result[aria-selected="true"] { background: var(--hover); border-left-color: var(--accent); color: var(--ink); }
.search-result .sr-path { display: block; font: 600 12px/1.35 var(--font-display); letter-spacing: 1px; color: var(--muted); }
.search-result .sr-title { display: block; font-weight: 600; font-size: 15px; line-height: 1.35; }
.search-result .sr-snippet { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.search-empty { padding: 14px 12px; color: var(--muted); font: italic 15px/1.4 var(--font-italic); }
.search-results mark, mark.search-hit {
  background: var(--mark-bg); color: var(--mark-text); border-radius: 0; padding: 0;
}

/* ------------------------------------------------------------------ sidebar */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 30;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 12px 40px;
  background: var(--paper); border-right: 1px solid var(--frame);
}
/* Section header: Spectral SC caption followed by a double hairline that fills the row. */
.nav-title {
  display: flex; align-items: center; gap: 10px;
  margin: 0 10px 12px; font: 600 13px/1.2 var(--font-display); letter-spacing: 1px; color: var(--ink);
}
.nav-title::after {
  content: ""; flex: 1; height: 4px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.nav, .nav ul { list-style: none; margin: 0; padding: 0; }
.nav-group { margin: 1px 0; }
.nav-group-head { display: flex; align-items: stretch; }
.nav-group-head:hover { background: var(--hover); }
.nav-chapter {
  flex: 1; display: block; padding: 6px 4px 6px 10px; color: var(--ink); text-decoration: none;
  font: 600 14.5px/1.35 var(--font-display); letter-spacing: .3px;
}
.nav-group.active > .nav-group-head .nav-chapter { color: var(--accent-text); }
.nav-toggle {
  flex: none; width: 32px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 0;
  display: grid; place-items: center;
}
.nav-toggle:hover { color: var(--ink); background: var(--hover); }
.nav-toggle svg { width: 13px; height: 13px; transition: transform .18s ease; }
.nav-group.open > .nav-group-head .nav-toggle svg { transform: rotate(90deg); }
/* Sub-entries hang from a 1 px rule; the active one thickens it to a 2 px oxblood bar. */
.nav-items { display: none; padding: 2px 0 8px !important; margin-left: 12px !important; border-left: 1px solid var(--rule); }
.nav-group.open > .nav-items { display: block; }
.nav-item {
  display: block; padding: 4px 10px 4px 12px; margin: 1px 0 1px -1px; border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-size: 14.2px; line-height: 1.4;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { color: var(--ink); font-weight: 600; border-left-color: var(--accent); }
.nav-chapter code, .nav-item code { font-size: .9em; background: none; border: 0; padding: 0; }

.sidebar-footer {
  margin: 26px 10px 0; padding-top: 12px; border-top: 1px solid var(--rule);
  font-size: 13px; line-height: 1.5; color: var(--muted);
}

.backdrop {
  display: none; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 25; background: var(--scrim);
}

/* ------------------------------------------------------------------ content */
.content {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 28px) 40px 80px;
  min-width: 0;
}
.content-inner { max-width: var(--content-w); margin: 0 auto; }

/* Chapters end with a double hairline. */
section.chapter {
  position: relative;
  padding-bottom: 36px; margin-bottom: 44px; border-bottom: 1px solid var(--rule);
}
section.chapter::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 2px; border-top: 1px solid var(--rule); pointer-events: none;
}
section.chapter:last-of-type { border-bottom: 0; }
section.chapter:last-of-type::after { content: none; }
section { scroll-margin-top: calc(var(--topbar-h) + 16px); }

h1, h2, h3, h4, h5 { color: var(--ink); scroll-margin-top: calc(var(--topbar-h) + 16px); position: relative; }
/* Chapter title: Spectral SC over a double frame rule. */
h2 {
  margin: 8px 0 22px; padding: 8px 0 12px; border-bottom: 1px solid var(--frame);
  font: 600 2.15rem/1.15 var(--font-display); letter-spacing: .5px;
}
h2::after { content: ""; position: absolute; left: 0; right: 0; bottom: 2px; border-top: 1px solid var(--frame); pointer-events: none; }
/* Section title: Spectral SC under a double hairline. */
h3 {
  margin: 48px 0 12px; padding-top: 16px; border-top: 1px solid var(--rule);
  font: 600 1.5rem/1.25 var(--font-display); letter-spacing: .5px;
}
h3::before { content: ""; position: absolute; left: 0; right: 0; top: 2px; border-top: 1px solid var(--rule); pointer-events: none; }
h4 { margin: 32px 0 8px; font: 600 1.16rem/1.3 var(--font-display); letter-spacing: .5px; }
h5 { margin: 24px 0 6px; font: italic 400 1.12rem/1.35 var(--font-italic); }
h2 code, h3 code, h4 code { font-size: .8em; letter-spacing: 0; }
h5 code { font-style: normal; }

.anchor {
  margin-left: .35em; padding: 0 .2em; color: var(--faint); text-decoration: none;
  font: 400 .8em/1 var(--font-sans); letter-spacing: 0;
  opacity: 0; transition: opacity .12s ease;
}
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus { opacity: 1; }
.anchor:hover { color: var(--accent-text); }

p, ul, ol, dl { margin: 0 0 14px; }
ul, ol { padding-left: 1.5em; }
li { margin: 4px 0; }
li > p { margin: 4px 0; }
.content-inner ul { list-style-type: square; }
.content-inner ul ul { list-style-type: "\2013\00a0\00a0"; }
.content-inner ul > li::marker { color: var(--accent-text); }
.content-inner ol:not(.steps) > li::marker { color: var(--accent-text); font-weight: 600; }
strong, b { font-weight: 600; }
/* Names in running text (scenes, settings, maps) are set in Spectral Italic. */
em { font-family: var(--font-italic); font-style: italic; font-size: 1.04em; }
em code, em kbd { font-style: normal; }

code {
  font-family: var(--font-mono); font-size: .84em;
  background: var(--paper-raised); color: var(--ink); padding: .08em .34em;
  border: 1px solid var(--rule); border-radius: 0;
  overflow-wrap: break-word;
}

kbd {
  display: inline-block; min-width: 1.7em; padding: .08em .42em 0; text-align: center;
  font: 600 .8em/1.55 var(--font-sans); letter-spacing: .02em; color: var(--ink);
  background: var(--paper-raised); border: 1px solid var(--rule); border-bottom: 2px solid var(--frame); border-radius: 1px;
  white-space: nowrap; vertical-align: .08em;
}
kbd + kbd { margin-left: 3px; }

/* Menu paths ("Tools > RTS Terrain Studio > ..."): a shaded label on a rule, like a legend entry. */
.menu {
  display: inline; padding: .06em .38em .08em;
  font-family: var(--font-sans); font-style: normal; font-weight: 600; font-size: .96em; letter-spacing: 0;
  color: var(--ink); background: var(--hover); border-bottom: 1px solid var(--rule);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* steps */
ol.steps { list-style: none; counter-reset: step; padding-left: 0; margin: 12px 0 18px; }
ol.steps > li {
  counter-increment: step; position: relative; padding: 2px 0 10px 44px; margin: 0;
}
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 1px;
  width: 27px; height: 27px; display: grid; place-items: center;
  background: var(--paper-raised); color: var(--accent-text); border: 1px solid var(--frame);
  font: 600 14px/1 var(--font-sans); font-variant-numeric: lining-nums tabular-nums;
}
ol.steps > li:not(:last-child)::after {
  content: ""; position: absolute; left: 13px; top: 32px; bottom: 3px; width: 1px; background: var(--rule);
}

/* callouts: paper-raised legend boxes with a 2 px line on the left */
.note, .tip, .warning {
  position: relative; margin: 18px 0; padding: 12px 18px 12px 46px;
  background: var(--paper-raised); border-left: 2px solid; font-size: .97em;
}
.note > :last-child, .tip > :last-child, .warning > :last-child { margin-bottom: 0; }
.note > :first-child, .tip > :first-child, .warning > :first-child { margin-top: 0; }
.note::before, .tip::before, .warning::before {
  position: absolute; left: 15px; top: 14px; width: 19px; height: 19px;
  display: grid; place-items: center; font: 600 13px/1 var(--font-sans); color: var(--paper-raised);
}
.note { border-color: var(--second); }
.note::before { content: "i"; background: var(--second); font: italic 400 15px/1 var(--font-italic); }
.tip { border-color: var(--accent); }
.tip::before { content: "\2713"; background: var(--accent); color: var(--on-accent); }
.warning { border-color: var(--warning); }
.warning::before { content: "!"; background: var(--warning); }
.note code, .tip code, .warning code, .note kbd, .tip kbd, .warning kbd { background: var(--paper); }

/* tables: Spectral SC header on paper-raised, 1 px rule lines */
.table-wrap { margin: 14px 0 20px; overflow-x: auto; border: 1px solid var(--frame); border-radius: 0; background: transparent; }
table.ref { width: 100%; border-collapse: collapse; font-size: 14.8px; line-height: 1.5; }
.table-wrap > table.ref { margin: 0; }
table.ref:not(.table-wrap > table) { margin: 14px 0 20px; border: 1px solid var(--frame); }
table.ref th, table.ref td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
table.ref th + th, table.ref td + td { border-left: 1px solid color-mix(in srgb, var(--rule) 55%, transparent); }
table.ref thead th {
  background: var(--paper-raised); color: var(--ink); border-bottom: 1px solid var(--frame);
  font: 600 14px/1.3 var(--font-display); letter-spacing: 1px;
  white-space: nowrap;
}
table.ref tbody tr:last-child td { border-bottom: 0; }
table.ref tbody tr:hover td { background: var(--hover); }
table.ref td:first-child { font-weight: 600; }
table.ref td[colspan] { background: var(--paper-sunken); font-weight: 400; }
table.ref td[colspan] strong { font: 600 1.02em/1.3 var(--font-display); letter-spacing: .5px; }
table.ref code { font-size: .84em; }

/* code blocks: paper-sunken, 1 px rule border, a title strip with the language and the copy button */
.code-block { position: relative; margin: 14px 0 20px; }
pre {
  margin: 14px 0 20px; padding: 16px 18px; overflow-x: auto;
  background: var(--paper-sunken); color: var(--ink); border: 1px solid var(--rule); border-radius: 0;
  font: 13.4px/1.6 var(--font-mono); tab-size: 4;
}
.code-block > pre { margin: 0; padding-top: 46px; }
.code-block::before {
  content: ""; position: absolute; left: 1px; right: 1px; top: 33px; border-top: 1px solid var(--rule); pointer-events: none;
}
pre code { background: none; border: 0; color: inherit; padding: 0; font-size: inherit; border-radius: 0; overflow-wrap: normal; white-space: pre; }
.code-lang {
  position: absolute; top: 10px; left: 15px; font: 600 13px/1 var(--font-display); letter-spacing: 1px;
  color: var(--code-label); pointer-events: none;
}
.copy-btn {
  position: absolute; top: 5px; right: 5px; height: 24px; padding: 0 9px;
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 12px/1 var(--font-sans); letter-spacing: .03em; color: var(--ink); background: transparent;
  border: 1px solid var(--rule); border-radius: 0; cursor: pointer;
}
.copy-btn:hover { background: var(--hover); border-color: var(--frame); color: var(--ink); }
.copy-btn:active { background: var(--press); }
.copy-btn.copied { color: var(--second); border-color: var(--second); }
.copy-btn svg { width: 13px; height: 13px; }
.copy-btn svg rect { rx: 0; ry: 0; }

.tok-k { color: var(--tok-keyword); }
.tok-t { color: var(--tok-type); }
.tok-s { color: var(--tok-string); }
.tok-c { color: var(--tok-comment); font-style: italic; }
.tok-n { color: var(--tok-number); }
.tok-f { color: var(--tok-fn); }
.tok-p { color: var(--tok-preproc); }

/* figures: screenshots mounted like map plates, 1 px frame around a parchment mat */
figure { margin: 22px 0 26px; }
figure img {
  display: block; margin: 0 auto; padding: 4px;
  border: 1px solid var(--frame); border-radius: 0; background: var(--paper-raised);
}
figcaption {
  margin-top: 9px; text-align: center;
  font: italic 400 14.5px/1.45 var(--font-italic); color: var(--muted);
}
figcaption code, figcaption kbd { font-style: normal; }

/* ------------------------------------------------------------------ hero */
/* Neatline panel: 2 px frame, 3 px gap, 1 px inner frame line. */
.hero {
  position: relative; overflow: hidden; margin: 0 0 36px; padding: 46px 44px 42px;
  color: var(--ink); background: var(--paper-raised);
  border: 2px solid var(--frame); outline: 1px solid var(--frame); outline-offset: -6px;
}
/* The landscape vignette stands on the inner frame line, drawn in sepia, forest green and oxblood. */
.hero-art { position: absolute; right: 4px; bottom: 4px; width: 56%; max-width: 460px; pointer-events: none; }
.hero-art path[fill="#ffffff"] { fill: var(--ink); }
.hero-art path[stroke="#ffffff"] { stroke: var(--ink); }
.hero-art path[fill^="url"] { fill: var(--second); fill-opacity: .16; }
.hero-art path[stroke-linecap="round"] { stroke: var(--second); stroke-opacity: .55; }
.hero-art g[fill="#d6f0c8"] { fill: var(--second); fill-opacity: .9; }
.hero-art g[fill="#ffffff"] { fill: var(--accent); fill-opacity: 1; }
.hero-art g[fill="#ffffff"] rect { rx: 0; ry: 0; }
.hero-content { position: relative; max-width: 560px; }
.hero-eyebrow {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  font: italic 400 16px/1.3 var(--font-italic); color: var(--accent-text);
}
.hero-eyebrow::before { content: ""; flex: none; width: 28px; height: 1px; background: var(--accent); }
.hero h1 {
  margin: 0 0 14px; padding-bottom: 16px;
  font: 600 clamp(2.3rem, 4.8vw, 3.25rem)/1.05 var(--font-display); letter-spacing: .5px; color: var(--ink);
}
.hero h1::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 84px; height: 4px;
  border-top: 1px solid var(--accent); border-bottom: 1px solid var(--accent);
}
.hero-tagline { margin: 0 0 26px; font: italic 400 1.14rem/1.5 var(--font-italic); color: var(--muted); }
.hero-links { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; white-space: nowrap;
  font: 600 14.5px/1 var(--font-sans); text-decoration: none; color: var(--ink);
  background: transparent; border: 1px solid var(--rule); border-radius: 0;
  transition: background .15s ease, border-color .15s ease;
}
.hero-btn:hover { background: var(--hover); border-color: var(--frame); color: var(--ink); }
.hero-btn:active { background: var(--press); }
.hero-btn.primary {
  background: var(--accent); color: var(--on-accent); border-color: var(--frame);
  font: 600 15px/1 var(--font-display); letter-spacing: 1px;
}
.hero-btn.primary:hover { color: var(--on-accent); background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.hero-btn svg { width: 14px; height: 14px; }
.hero-btn.primary svg { fill: currentColor; stroke: none; }
.hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; margin-top: 24px; font-size: 13.5px; color: var(--muted); }
.hero-meta span { display: inline-flex; align-items: center; gap: 9px; }
/* Each fact is keyed with a diamond, like the slider thumbs of the editor. */
.hero-meta span::before {
  content: ""; flex: none; width: 5px; height: 5px; background: var(--accent); transform: rotate(45deg);
}

/* ------------------------------------------------------------------ misc */
.target-flash { animation: flash 1.6s ease; }
@keyframes flash {
  0%, 30% { background: var(--mark-bg); }
  100% { background: transparent; }
}

.to-top {
  position: fixed; right: 20px; bottom: 20px; z-index: 35;
  width: 40px; height: 40px; border-radius: 0; border: 1px solid var(--frame);
  background: var(--paper-raised); color: var(--ink); cursor: pointer;
  display: grid; place-items: center;
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.to-top.visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--ink); color: var(--paper-raised); }
.to-top svg { width: 18px; height: 18px; }

/* Colophon under a double hairline. */
.page-footer {
  position: relative; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--rule);
  font: italic 400 15px/1.5 var(--font-italic); color: var(--muted);
}
.page-footer::before { content: ""; position: absolute; left: 0; right: 0; top: 2px; border-top: 1px solid var(--rule); }

/* Chinese and Japanese have no true italics: the italic roles stay upright (Latin text keeps Spectral Italic). */
:lang(zh) em, :lang(ja) em, :lang(zh) h5, :lang(ja) h5, :lang(zh) figcaption, :lang(ja) figcaption,
:lang(zh) .hero-eyebrow, :lang(ja) .hero-eyebrow, :lang(zh) .hero-tagline, :lang(ja) .hero-tagline,
:lang(zh) .page-footer, :lang(ja) .page-footer, :lang(zh) .search-empty, :lang(ja) .search-empty { font-style: normal; }
:lang(zh) em, :lang(ja) em { font-size: 1em; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  :root { --sidebar-w: 270px; }
  .content { padding-left: 28px; padding-right: 28px; }
}

@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .sidebar {
    width: min(86vw, 320px); transform: translateX(-102%); transition: transform .22s ease;
    border-right: 2px solid var(--frame);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; }
  .content { margin-left: 0; padding: calc(var(--topbar-h) + 20px) 16px 64px; }
  .topbar { gap: 8px; padding: 0 10px 4px; }
  .search { width: auto; flex: 1; min-width: 0; }
  .search-hint { display: none; }
  .search-input { padding-right: 8px; }
  .search-results { position: fixed; top: calc(var(--topbar-h) + 4px); left: 8px; right: 8px; min-width: 0; }
  .topbar-spacer { display: none; }
  .brand-name { display: none; }
  .hero { padding: 32px 22px 30px; }
  .hero-art { width: 86%; opacity: .3; }
  h2 { font-size: 1.8rem; }
  h3 { font-size: 1.32rem; }
}

@media (max-width: 480px) {
  .version { display: none; }
  .lang-label { display: none; }
  .hero-btn { flex: 1 1 calc(50% - 8px); justify-content: center; padding: 0 8px; }
  .hero-btn.primary { letter-spacing: .5px; }
  ol.steps > li { padding-left: 38px; }
  .note, .tip, .warning { padding-left: 42px; padding-right: 14px; }
  .note::before, .tip::before, .warning::before { left: 12px; }
}

/* ------------------------------------------------------------------ print */
@media print {
  /* html:root:not(...) outranks the dark theme selectors, so print is always on white paper with dark ink. */
  html:root:not([data-print-dark]) {
    --paper: #fff; --paper-raised: #fff; --paper-sunken: #f4f0e8;
    --ink: #1e140c; --frame: #3a2618; --muted: #4a3a2c; --faint: #6e5a48; --rule: #b39371;
    --hover: transparent; --press: transparent;
    --accent: #8e3524; --accent-text: #8e3524; --on-accent: #fff; --second: #2f5c45; --warning: #9a6a12; --link: #1e140c;
    --mark-bg: transparent; --mark-text: inherit; --code-label: #4a3a2c;
    --tok-keyword: #8e3524; --tok-type: #2c5a40; --tok-string: #475614; --tok-comment: #614d3d; --tok-number: #83400c; --tok-fn: #733059; --tok-preproc: #6e4d06;
    color-scheme: light;
  }
  html { scroll-behavior: auto; }
  body { background: #fff; color: var(--ink); font-size: 11pt; }
  .topbar, .sidebar, .backdrop, .to-top, .copy-btn, .anchor, .skip-link, .search-results, .hero-art { display: none !important; }
  .content { margin: 0; padding: 0; }
  .content-inner { max-width: none; }
  .hero { background: none; padding: 22px; }
  .hero-links { display: none; }
  section.chapter { break-before: page; border: 0; }
  section.chapter::after { content: none; }
  section.chapter:first-of-type { break-before: auto; }
  h2, h3, h4 { break-after: avoid; }
  pre, table, figure, .note, .tip, .warning { break-inside: avoid; }
  pre { white-space: pre-wrap; }
  pre code { white-space: pre-wrap; }
  .table-wrap { overflow: visible; }
  a { color: var(--ink); text-decoration: none; }
  .menu { background: none; }
  figure img { padding: 0; }
}

/* Portrait screenshots (editor window) keep their natural width. */
figure.screenshot.portrait img { max-width: 430px; width: 100%; margin: 0 auto; display: block; }
