/* SaveSlot docs. Paper look shared with saveslot.ai: warm ivory, serif headings, tinted callouts. */
:root {
  --paper: #f8f5f0; --chrome: #f3f0ea; --card: #fffefc; --sunk: #f6f2ec;
  --ink: #2b2824; --muted: #5f584f; --faint: #6f675d; --line: rgba(43, 40, 36, .13); --soft: #ebe5dc;
  --accent: #3d6650; --accent-pale: #f0f6f1; --accent-rim: #9cbfa6;
  --note-rim: #97c0e2; --note-pale: #edf5fb; --note-ink: #2f5d86;
  --draft-rim: #e3c76f; --draft-pale: #fbf6e2; --draft-ink: #6d5711;
  --warn-rim: #e8ab95; --warn-pale: #fcefe9; --warn-ink: #8f3d24;
  --code-bg: #2b2824; --code-fg: #f3ede4; --code-dim: #a69d90; --inline-code: #f1ebe2;
  --f-body: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --f-serif: "Newsreader", "Noto Serif SC", "Songti SC", Georgia, serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --sh: 0 1px 2px rgba(70, 50, 30, .05), 0 10px 26px -14px rgba(70, 50, 30, .22);
  --top: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1a1815; --chrome: #1e1c18; --card: #24221e; --sunk: #201e1a;
    --ink: #efe9e0; --muted: #c2b9ac; --faint: #a89f92; --line: rgba(255, 250, 240, .12); --soft: #34302a;
    --accent: #8cc0a1; --accent-pale: #1f3127; --accent-rim: #5e8a6b;
    --note-rim: #4f7aa3; --note-pale: #1c2733; --note-ink: #a9cbec;
    --draft-rim: #9c8636; --draft-pale: #2b2615; --draft-ink: #e6d18a;
    --warn-rim: #a5644c; --warn-pale: #301f19; --warn-ink: #f0b9a3;
    --code-bg: #121110; --code-fg: #f3ede4; --code-dim: #a0978a; --inline-code: #2f2b25;
    --sh: 0 1px 0 rgba(255, 250, 240, .04) inset, 0 12px 30px -16px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1a1815; --chrome: #1e1c18; --card: #24221e; --sunk: #201e1a;
  --ink: #efe9e0; --muted: #c2b9ac; --faint: #a89f92; --line: rgba(255, 250, 240, .12); --soft: #34302a;
  --accent: #8cc0a1; --accent-pale: #1f3127; --accent-rim: #5e8a6b;
  --note-rim: #4f7aa3; --note-pale: #1c2733; --note-ink: #a9cbec;
  --draft-rim: #9c8636; --draft-pale: #2b2615; --draft-ink: #e6d18a;
  --warn-rim: #a5644c; --warn-pale: #301f19; --warn-ink: #f0b9a3;
  --code-bg: #121110; --code-fg: #f3ede4; --code-dim: #a0978a; --inline-code: #2f2b25;
  --sh: 0 1px 0 rgba(255, 250, 240, .04) inset, 0 12px 30px -16px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.7 var(--f-body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 10px; }
.serif { font-family: var(--f-serif); }

/* ---------- Top bar ---------- */
.top { position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--chrome); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 16px; white-space: nowrap; }
.brand-d { font-family: var(--f-serif); font-weight: 500; font-size: 18px; color: var(--muted); }
.mark { width: 18px; height: 18px; border-radius: 5px; background:
  radial-gradient(circle at 25% 25%, var(--ink) 2px, transparent 2.5px),
  radial-gradient(circle at 75% 25%, var(--ink) 2px, transparent 2.5px),
  radial-gradient(circle at 25% 75%, var(--ink) 2px, transparent 2.5px),
  radial-gradient(circle at 75% 75%, #c96f4a 2px, transparent 2.5px); }
.search { position: relative; flex: 1; min-width: 0; max-width: 440px; margin-left: 12px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--faint); }
.search:focus-within { border-color: var(--accent-rim); box-shadow: 0 0 0 3px var(--accent-pale); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14.5px; }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { font: 12px var(--f-mono); color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; }
.results { position: absolute; top: 44px; left: 0; right: 0; max-height: min(70vh, 520px); overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh); padding: 6px; }
.results a { display: block; padding: 9px 11px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.results a[aria-selected="true"], .results a:hover { background: var(--accent-pale); }
.results .r-t { font-weight: 600; font-size: 14.5px; }
.results .r-h { color: var(--muted); font-weight: 400; }
.results .r-x { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results mark { background: var(--draft-pale); color: inherit; border-radius: 3px; }
.results .r-none { padding: 12px; color: var(--muted); font-size: 14px; }
.top-links { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.top-links > a { white-space: nowrap; }
.top-links > a:not(.btn) { color: var(--muted); text-decoration: none; font-size: 14.5px; padding: 8px 10px; border-radius: 8px; }
.top-links > a:not(.btn):hover { color: var(--ink); background: var(--soft); }
.btn { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px; background: var(--ink); color: var(--paper); text-decoration: none; font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn:hover { opacity: .9; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--soft); color: var(--ink); }
.menu-btn { display: none; margin-left: -8px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 264px minmax(0, 1fr) 220px; max-width: 1440px; margin: 0 auto; }
.sidebar { position: sticky; top: var(--top); height: calc(100dvh - var(--top)); overflow: auto; padding: 22px 14px 40px 20px; border-right: 1px solid var(--line); }
.sidebar-h { display: none; }
.nav-sec + .nav-sec { margin-top: 18px; }
.nav-h { margin: 0 0 6px; padding: 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
html[data-lang="zh"] .nav-h { letter-spacing: .02em; text-transform: none; }
.sidebar ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14.5px; line-height: 1.45; }
.sidebar a:hover { color: var(--ink); background: var(--soft); }
.sidebar a[aria-current="page"] { color: var(--ink); background: var(--card); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent-rim), var(--sh); }
.scrim { display: none; }
main { min-width: 0; padding: 40px 56px 60px; }
main:focus { outline: none; }
.toc { position: sticky; top: var(--top); align-self: start; max-height: calc(100dvh - var(--top)); overflow: auto; padding: 40px 20px 40px 8px; }
.toc a { display: block; padding: 4px 8px; color: var(--muted); text-decoration: none; font-size: 13.5px; line-height: 1.45; border-left: 2px solid transparent; }
.toc .l3 a { padding-left: 20px; font-size: 13px; }
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--ink); border-left-color: var(--accent-rim); }

/* ---------- Article ---------- */
.doc { max-width: 760px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.doc h1 { margin: 0 0 18px; font: 500 44px/1.12 var(--f-serif); letter-spacing: -.01em; }
.doc h2 { margin: 44px 0 12px; font: 500 28px/1.25 var(--f-serif); }
.doc h3 { margin: 30px 0 8px; font-size: 18.5px; font-weight: 650; line-height: 1.4; }
.doc h4 { margin: 22px 0 6px; font-size: 16px; font-weight: 650; }
html[data-lang="zh"] .doc h1 { font-size: 38px; font-weight: 600; }
html[data-lang="zh"] .doc h2 { font-size: 25px; font-weight: 600; }
.doc h2, .doc h3, .doc h4 { position: relative; }
.anchor { margin-left: 8px; color: var(--faint); text-decoration: none; opacity: 0; font-family: var(--f-body); font-weight: 400; }
.doc :is(h2, h3, h4):hover .anchor { opacity: 1; }
.doc p, .doc ul, .doc ol { margin: 0 0 14px; }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc li > ul { margin: 4px 0 0; }
.doc strong { font-weight: 650; }
.doc :not(pre) > code { font: .88em var(--f-mono); background: var(--inline-code); padding: .1em .38em; border-radius: 5px; overflow-wrap: anywhere; }
.code { position: relative; margin: 0 0 18px; }
.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; background: var(--code-bg); color: var(--code-fg); border-radius: 12px; font: 13.5px/1.65 var(--f-mono); }
.code pre[data-lang]::before { content: attr(data-lang); position: absolute; top: 8px; right: 70px; color: var(--code-dim); font-size: 11.5px; }
.copy { position: absolute; top: 8px; right: 8px; height: 28px; padding: 0 10px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 7px; background: rgba(255, 255, 255, .06); color: var(--code-fg); font: 12px var(--f-body); cursor: pointer; }
.copy:hover { background: rgba(255, 255, 255, .14); }
.table { margin: 0 0 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.table table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.55; }
.table th, .table td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table th { background: var(--sunk); font-weight: 600; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td code { white-space: nowrap; }
.callout { margin: 0 0 18px; padding: 14px 18px; border: 2px solid var(--note-rim); background: var(--note-pale); border-radius: 12px; }
.callout > :last-child { margin-bottom: 0; }
.callout.draft { border-color: var(--draft-rim); background: var(--draft-pale); }
.callout.warn { border-color: var(--warn-rim); background: var(--warn-pale); }
.callout-t { font-weight: 650; margin: 0 0 6px !important; display: flex; align-items: center; gap: 8px; }
.callout.note .callout-t { color: var(--note-ink); }
.callout.draft .callout-t { color: var(--draft-ink); }
.callout.warn .callout-t { color: var(--warn-ink); }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; border: 1.5px solid var(--draft-rim); background: var(--draft-pale); color: var(--draft-ink); font: 600 12px/1 var(--f-body); letter-spacing: .02em; vertical-align: middle; }
.doc h2 .badge, .doc h3 .badge { margin-left: 8px; position: relative; top: -2px; }

.pager { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 48px; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); text-decoration: none; font-weight: 600; }
.pager a:hover { border-color: var(--accent-rim); }
.pager span { display: block; color: var(--faint); font-size: 13px; font-weight: 400; }
.pager .next { text-align: right; }
.foot { max-width: 760px; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
.foot p { margin: 4px 0; }
.foot a { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 248px minmax(0, 1fr); }
  .toc { display: none; }
  main { padding: 36px 40px 56px; }
}
@media (max-width: 900px) {
  :root { --top: 56px; }
  .layout { display: block; }
  .menu-btn { display: inline-grid; }
  .top { padding: 0 12px; gap: 8px; }
  .search { margin-left: 0; }
  .search kbd, .hide-sm { display: none; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 41; width: min(320px, 86vw); height: 100dvh; background: var(--chrome); transform: translateX(-102%); transition: transform .2s ease; padding-top: 8px; border-right: 1px solid var(--line); }
  .sidebar.open { transform: none; box-shadow: var(--sh); }
  .sidebar-h { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 12px 10px; font-weight: 600; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(20, 16, 12, .35); }
  main { padding: 28px 20px 48px; }
  .doc h1, html[data-lang="zh"] .doc h1 { font-size: 34px; }
}
@media (max-width: 560px) {
  .brand-d, .top-links .btn { display: none; }
  .top-links { gap: 0; }
  .top-links > a:not(.btn) { padding: 8px 6px; }
  .search { height: 36px; }
  main { padding: 24px 16px 44px; }
  .doc h1, html[data-lang="zh"] .doc h1 { font-size: 30px; }
  .doc h2, html[data-lang="zh"] .doc h2 { font-size: 23px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
