:root {
  --paper: #f7f3ea;
  --sheet: #fffdf8;
  --ink: #1d1913;
  --mute: #6d6558;
  --line: #e4d8c4;
  --line-strong: #cbb899;
  --aside: #1b1712;
  --aside-ink: #f3ead8;
  --aside-mute: #b5a78c;
  --aside-line: #3a3228;
  --aside-active: #f4d7a3;
  --copper: #b45309;
  --copper-ink: #fffaf2;
  --copper-soft: #fde8c8;
  --link: #9a3412;
  --link-hover: #7c2d12;
  --ok: #3f6212;
  --ok-bg: #ecfccb;
  --warn: #a16207;
  --warn-bg: #fef3c7;
  --halt: #9f1239;
  --halt-bg: #ffe4e6;
  --tip: #1d4ed8;
  --tip-bg: #dbeafe;
  --code: #221c16;
  --code-ink: #f5ead4;
  --code-mute: #9c8b72;
  --key: #f0c674;
  --str: #86c8a4;
  --cmt: #8d7f6a;
  --focus: #b45309;
  --shadow: 0 12px 32px rgba(29, 25, 19, 0.08);
  --aside-w: 268px;
  --content: 760px;
  --sans: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "Courier New", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: auto;
}

html.motion-ok {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
}

body.is-locked {
  overflow: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--link-hover);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -3.2rem;
  z-index: 90;
  padding: 0.45rem 0.75rem;
  background: var(--ink);
  color: var(--sheet);
  text-decoration: none;
}

.skip:focus {
  top: 0.75rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(247, 243, 234, 0.92);
  border-bottom: 1px solid var(--line);
}

.topbar.is-stuck {
  box-shadow: 0 8px 20px rgba(29, 25, 19, 0.06);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  padding: 0 1.15rem;
  max-width: 1280px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--sheet);
}

.brand strong {
  display: block;
  font-size: 0.98rem;
  letter-spacing: 0.01em;
}

.brand small {
  display: block;
  color: var(--mute);
  font-size: 0.75rem;
  font-weight: 500;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.nav ul {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 0.7rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.92rem;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: var(--copper-soft);
  color: var(--link);
}

.nav a.cta,
.btn-primary {
  background: var(--copper);
  color: var(--copper-ink);
  font-weight: 600;
}

.nav a.cta:hover,
.btn-primary:hover {
  background: #9a4108;
  color: var(--copper-ink);
}

.shell {
  display: grid;
  grid-template-columns: var(--aside-w) minmax(0, 1fr);
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 64px);
}

.sidebar {
  position: sticky;
  top: 64px;
  align-self: start;
  height: calc(100vh - 64px);
  overflow: auto;
  padding: 1.1rem 0.95rem 2rem;
  background: var(--aside);
  color: var(--aside-ink);
  border-right: 1px solid #2a241c;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.sidebar-head strong {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--aside-mute);
}

.sidebar-close {
  display: none;
  border: 0;
  background: transparent;
  color: var(--aside-ink);
  font: inherit;
  cursor: pointer;
}

.group {
  margin: 0 0 1.05rem;
}

.group h2 {
  margin: 0 0 0.35rem;
  padding: 0 0.45rem;
  color: var(--aside-mute);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.group a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.2rem 0.5rem;
  color: var(--aside-ink);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.9rem;
}

.group a:hover,
.group a.is-active {
  background: #2b241b;
  color: var(--aside-active);
}

.group a span {
  width: 1.35rem;
  color: var(--aside-mute);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.content {
  min-width: 0;
  padding: 1.4rem 1.5rem 3.4rem;
}

.page {
  max-width: var(--content);
}

.crumb {
  margin: 0 0 0.7rem;
  color: var(--mute);
  font-size: 0.86rem;
}

.crumb a {
  color: inherit;
  text-decoration: none;
}

.crumb a:hover {
  color: var(--link);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 0.6rem;
  border-radius: 999px;
  background: var(--copper-soft);
  color: #9a3412;
  font-size: 0.78rem;
  font-weight: 600;
}

.chip.quiet {
  background: #efe7d6;
  color: var(--mute);
}

h1,
h2,
h3 {
  line-height: 1.28;
  letter-spacing: -0.02em;
}

h1 {
  margin: 0 0 0.7rem;
  font-size: clamp(1.7rem, 3vw, 2.25rem);
}

h2 {
  margin: 0 0 0.55rem;
  font-size: 1.28rem;
}

h3 {
  margin: 0 0 0.4rem;
  font-size: 1.02rem;
}

.lead,
.intro {
  margin: 0 0 1rem;
  color: #433d34;
}

.chapter {
  margin: 2.1rem 0 0;
  padding-top: 0.2rem;
}

.chapter-kicker {
  margin: 0 0 0.35rem;
  color: var(--copper);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.1rem 0 0;
}

.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 1rem;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 650;
}

.btn-primary {
  background: var(--copper);
  color: var(--copper-ink);
}

.btn-ghost {
  border: 1px solid var(--line-strong);
  background: var(--sheet);
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: var(--copper);
  color: var(--link);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 1.25rem 0 0;
}

.metric {
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sheet);
}

.metric strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 1.2rem;
}

.metric span {
  color: var(--mute);
  font-size: 0.84rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.card,
.os-card {
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sheet);
}

a.card {
  color: inherit;
  text-decoration: none;
}

a.card:hover {
  border-color: #d7b27a;
  box-shadow: var(--shadow);
}

.kicker {
  display: inline-block;
  margin-bottom: 0.35rem;
  color: var(--copper);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
}

.card p,
.os-card p {
  margin: 0;
  color: #514a40;
}

.callout {
  margin: 1rem 0;
  padding: 0.85rem 0.95rem 0.85rem 1rem;
  border-left: 4px solid var(--tip);
  border-radius: 0 10px 10px 0;
  background: var(--tip-bg);
}

.callout.warn {
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

.callout.halt {
  border-left-color: var(--halt);
  background: var(--halt-bg);
}

.callout.ok {
  border-left-color: var(--ok);
  background: var(--ok-bg);
}

.callout h3,
.callout p {
  margin: 0;
}

.callout h3 {
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.fence {
  margin: 1rem 0;
  overflow: hidden;
  border: 1px solid #3a3228;
  border-radius: 12px;
  background: var(--code);
  color: var(--code-ink);
}

.fence-bar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.8rem;
  background: #2a231c;
  color: var(--code-mute);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.fence pre {
  margin: 0;
  padding: 0.9rem 1rem 1.05rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.6;
}

.fence .c {
  color: var(--cmt);
}

.fence .k {
  color: var(--key);
}

.fence .s {
  color: var(--str);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sheet);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f3ead6;
  font-size: 0.8rem;
}

tr:last-child td {
  border-bottom: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
}

p code,
td code,
li code {
  padding: 0.08em 0.32em;
  border-radius: 4px;
  background: #efe4cf;
}

.ticks {
  margin: 0 0 1rem;
  padding: 0 0 0 1.1rem;
}

.ticks li {
  margin: 0.3rem 0;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--sheet);
}

.figure img {
  width: 100%;
}

.figure figcaption {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  color: var(--mute);
  font-size: 0.78rem;
}

.faq details {
  margin: 0.5rem 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sheet);
}

.faq summary {
  cursor: pointer;
  padding: 0.8rem 0.95rem;
  font-weight: 650;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  float: right;
  content: "+";
  color: var(--mute);
}

.faq details[open] summary::after {
  content: "−";
}

.faq details p {
  margin: 0;
  padding: 0 0.95rem 0.9rem;
  color: #4d463c;
}

.foot {
  padding: 2rem 1.2rem 1.3rem;
  background: var(--aside);
  color: var(--aside-ink);
}

.foot-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1.15fr;
  gap: 1.2rem;
  max-width: 1280px;
  margin: 0 auto 1.2rem;
}

.foot a {
  color: #f0d7a8;
}

.foot .brand {
  margin-bottom: 0.55rem;
  color: var(--aside-ink);
}

.foot .brand small {
  color: var(--aside-mute);
}

.foot h3 {
  margin: 0 0 0.45rem;
  font-size: 0.86rem;
  color: var(--aside-mute);
}

.foot ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.foot li {
  margin: 0.28rem 0;
}

.foot p {
  margin: 0.4rem 0 0;
  color: #d7c8ad;
  font-size: 0.9rem;
}

.legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 1280px;
  margin: 0 auto;
  padding-top: 0.9rem;
  border-top: 1px solid var(--aside-line);
  color: var(--aside-mute);
  font-size: 0.82rem;
}

[data-reveal] {
  opacity: 1;
  transform: none;
}

html.motion-ok [data-reveal] {
  opacity: 0;
  transform: translateY(10px);
}

html.motion-ok [data-reveal].is-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .icon-btn {
    display: inline-flex;
  }

  .nav {
    position: fixed;
    inset: 64px 0.75rem auto;
    z-index: 50;
    display: none;
    padding: 0.55rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--sheet);
    box-shadow: var(--shadow);
  }

  .nav.is-open {
    display: block;
  }

  .nav ul {
    flex-direction: column;
    align-items: stretch;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 55;
    width: min(86vw, 320px);
    height: 100vh;
    transform: translateX(-105%);
  }

  .sidebar.is-open {
    transform: none;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .metrics,
  .grid,
  .split,
  .foot-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 1rem 0.9rem 2.4rem;
  }

  .topbar-inner {
    padding: 0 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  html.motion-ok [data-reveal],
  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
