
:root {
  --bg: #FFFFFF;
  --surface: #FAFAFA;
  --surface-2: #F2F2F2;
  --line: #E5E5E5;
  --line-strong: #C7C7C7;
  --fg: #000000;
  --fg-2: #525252;
  --fg-3: #6B6B6B;
  --allow: #12794A;  --allow-bg: rgba(18,121,74,.10);
  --block: #B42318;  --block-bg: rgba(180,35,24,.10);
  --escalate: #A15C00; --escalate-bg: rgba(161,92,0,.10);

  --font-display: 'Geist', 'Inter', system-ui, sans-serif;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;

  --radius: 6px;
  --radius-sm: 4px;
  --topbar-h: 60px;
  --side-w: 272px;
  --toc-w: 220px;
  --content-w: 760px;
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 24px); }
body {
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.7 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: var(--radius-sm); }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }


.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
          backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { color: var(--fg); }
.topbar .sep { width: 1px; height: 20px; background: var(--line-strong); }
.topbar .doc-label { font: 600 14px/1 var(--font-display); letter-spacing: -.01em; color: var(--fg-2); }
.topbar .grow { flex: 1; }
.menu-btn { display: none; width: 36px; height: 36px; border-radius: var(--radius); align-items: center; justify-content: center; }
.menu-btn:hover { background: var(--surface-2); }
.menu-btn span, .menu-btn span::before, .menu-btn span::after { display: block; width: 18px; height: 1.5px; background: var(--fg); content: ""; position: relative; }
.menu-btn span::before { position: absolute; top: -6px; }
.menu-btn span::after { position: absolute; top: 6px; }

.search-btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-width: 260px; height: 36px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  color: var(--fg-3); font-size: 14px; background: var(--bg);
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.search-btn:hover { background: var(--surface-2); border-color: var(--fg-3); }
.search-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.search-btn kbd { margin-left: auto; font: 500 11px/1 var(--font-mono); padding: 3px 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg-3); }


.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid transparent;
  font: 600 14px/1 var(--font-sans); text-decoration: none; white-space: nowrap;
  transition: background var(--dur-fast), transform var(--dur-fast);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover { background: #262626; }


.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1440px; margin: 0 auto;
}
.side {
  position: sticky; top: var(--topbar-h); align-self: start;
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: 28px 16px 48px 24px;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}
.side-group { margin-bottom: 26px; }
.side-group h3 {
  font: 600 11px/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg-3); padding: 0 10px; margin-bottom: 8px;
}
.side a {
  display: block; padding: 6px 10px; border-radius: var(--radius);
  font-size: 14px; line-height: 1.4; color: var(--fg-2); text-decoration: none;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.side a:hover { background: var(--surface-2); color: var(--fg); }
.side a[aria-current="page"] { background: var(--fg); color: var(--bg); font-weight: 600; }

.main { padding: 48px clamp(24px, 4vw, 64px) 96px; min-width: 0; }
.article { max-width: var(--content-w); margin: 0 auto; animation: docIn var(--dur-slow) var(--ease-out); }
@keyframes docIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.crumb { font: 600 11px/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 14px; }
.article h1 { font: 700 clamp(2rem, 4vw, 2.6rem)/1.12 var(--font-display); letter-spacing: -.02em; text-wrap: balance; margin-bottom: 16px; }
.article .lead { font-size: 18px; line-height: 1.6; color: var(--fg-2); margin-bottom: 8px; max-width: 62ch; }
.article h2 { font: 700 1.5rem/1.25 var(--font-display); letter-spacing: -.02em; margin: 52px 0 14px; padding-top: 28px; border-top: 1px solid var(--line); text-wrap: balance; }
.article h2:first-of-type { margin-top: 36px; }
.article h3 { font: 700 1.1rem/1.3 var(--font-display); letter-spacing: -.01em; margin: 30px 0 8px; }
.article p { margin: 0 0 16px; color: var(--fg-2); max-width: 68ch; }
.article strong { color: var(--fg); font-weight: 600; }
.article a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); transition: text-decoration-color var(--dur-fast); }
.article a:hover { text-decoration-color: var(--fg); }
.article ul, .article ol { margin: 0 0 18px 1.3em; color: var(--fg-2); max-width: 68ch; }
.article li { margin-bottom: 6px; padding-left: 4px; }
.article li::marker { color: var(--fg-3); }
.article hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }

.article .anchor { margin-left: 8px; opacity: 0; font-weight: 400; color: var(--fg-3); text-decoration: none; transition: opacity var(--dur-fast); }
.article h2:hover .anchor, .article h3:hover .anchor { opacity: 1; }

.article code {
  font: 500 .86em/1 var(--font-mono);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 2px 6px; border-radius: var(--radius-sm); color: var(--fg);
}
.codeblock { position: relative; margin: 0 0 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.codeblock .cap {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font: 500 12px/1 var(--font-mono); color: var(--fg-3); background: var(--bg);
}
.codeblock .copy { font: 600 12px/1 var(--font-sans); color: var(--fg-2); padding: 5px 8px; border-radius: var(--radius-sm); transition: background var(--dur-fast); }
.codeblock .copy:hover { background: var(--surface-2); color: var(--fg); }
.codeblock pre { margin: 0; padding: 16px 18px; overflow-x: auto; font: 400 13px/1.7 var(--font-mono); color: var(--fg); tab-size: 2; }
.codeblock pre code { all: unset; font: inherit; white-space: pre; }
.tok-c { color: var(--fg-3); }

.note { margin: 0 0 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 14px; color: var(--fg-2); max-width: 68ch; }
.note > :last-child { margin-bottom: 0; }
.note strong:first-child { display: block; font: 600 11px/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; color: var(--fg); }
.note.warn { border-color: var(--escalate); background: var(--escalate-bg); }
.note.block { border-color: var(--block); background: var(--block-bg); }

.tablewrap { overflow-x: auto; margin: 0 0 22px; border: 1px solid var(--line); border-radius: var(--radius); }
.article table { width: 100%; border-collapse: collapse; font-size: 14px; }
.article th { text-align: left; font: 600 12px/1.2 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--fg-3); background: var(--surface); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.article td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--fg-2); }
.article tr:last-child td { border-bottom: 0; }
.article td:first-child { color: var(--fg); }

.badge { display: inline-block; font: 600 11px/1 var(--font-mono); letter-spacing: .04em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; border: 1px solid currentColor; vertical-align: 1px; }
.badge.allow { color: var(--allow); background: var(--allow-bg); }
.badge.block { color: var(--block); background: var(--block-bg); }
.badge.escalate { color: var(--escalate); background: var(--escalate-bg); }
.badge.neutral { color: var(--fg-2); background: var(--surface-2); }


.flow { margin: 0 0 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 8px; display: grid; gap: 8px; }
.flow .step { display: grid; grid-template-columns: 36px 1fr; gap: 14px; align-items: start; padding: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.flow .num { width: 28px; height: 28px; border-radius: 50%; background: var(--fg); color: var(--bg); display: grid; place-items: center; font: 700 13px/1 var(--font-display); }
.flow .step h4 { font: 700 15px/1.3 var(--font-display); margin-bottom: 4px; }
.flow .step p { margin: 0; font-size: 14px; max-width: none; }
.flow .step .tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.flow .tag { font: 500 12px/1 var(--font-mono); padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--fg-2); background: var(--surface); }
.flow .branch { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 0 0 28px; }
.card { display: block; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none !important; transition: background var(--dur-fast), border-color var(--dur-fast); }
.card:hover { background: var(--surface-2); border-color: var(--line-strong); }
.card h4 { font: 700 15px/1.3 var(--font-display); color: var(--fg); margin-bottom: 6px; }
.card p { font-size: 13.5px; line-height: 1.55; margin: 0; color: var(--fg-2); }

.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); }
.prevnext a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; transition: background var(--dur-fast), border-color var(--dur-fast); }
.prevnext a:hover { background: var(--surface-2); border-color: var(--line-strong); }
.prevnext small { display: block; font: 600 11px/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 6px; }
.prevnext span { font: 700 15px/1.3 var(--font-display); }
.prevnext .next { text-align: right; grid-column: 2; }
.prevnext .prev { grid-column: 1; }


.toc { position: sticky; top: var(--topbar-h); align-self: start; max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 48px 24px 48px 8px; }
.toc h3 { font: 600 11px/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 12px; }
.toc a { display: block; font-size: 13px; line-height: 1.4; padding: 5px 0 5px 12px; border-left: 1px solid var(--line); color: var(--fg-3); text-decoration: none; transition: color var(--dur-fast), border-color var(--dur-fast); }
.toc a:hover { color: var(--fg); }
.toc a.on { color: var(--fg); border-left-color: var(--fg); font-weight: 500; }


.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.35); display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.overlay.open { display: flex; animation: fadeIn var(--dur-base) var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.palette { width: 100%; max-width: 640px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.35); overflow: hidden; animation: popIn var(--dur-slow) var(--ease-out); }
@keyframes popIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.palette input { width: 100%; height: 56px; padding: 0 20px; border: 0; border-bottom: 1px solid var(--line); outline: 0; font: 400 16px/1 var(--font-sans); background: var(--bg); color: var(--fg); }
.palette ul { list-style: none; max-height: 52vh; overflow-y: auto; padding: 8px; }
.palette li a { display: block; padding: 10px 12px; border-radius: var(--radius); text-decoration: none; }
.palette li a:hover, .palette li a.sel { background: var(--surface-2); }
.palette .r-t { font: 600 14px/1.3 var(--font-sans); color: var(--fg); }
.palette .r-g { font: 600 10.5px/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3); margin-left: 8px; }
.palette .r-s { font-size: 13px; color: var(--fg-3); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.palette mark { background: var(--fg); color: var(--bg); border-radius: 2px; padding: 0 2px; }
.palette .empty { padding: 28px 16px; text-align: center; color: var(--fg-3); font-size: 14px; }

.loading { padding: 80px 0; color: var(--fg-3); text-align: center; }


@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .menu-btn { display: inline-flex; }
  .topbar .sep, .topbar .doc-label, .topbar .btn { display: none; }
  .search-btn { min-width: 0; padding: 0 10px; }
  .search-btn .lbl, .search-btn kbd { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 30; width: min(86vw, 320px);
    height: auto; background: var(--bg); border-right: 1px solid var(--line-strong);
    transform: translateX(-102%); transition: transform var(--dur-slow) var(--ease-out);
  }
  body.nav-open .side { transform: none; }
  .main { padding: 32px 18px 72px; }
  .prevnext { grid-template-columns: 1fr; }
  .prevnext .next, .prevnext .prev { grid-column: 1; }
}
@media print {
  .topbar, .side, .toc, .prevnext, .codeblock .copy { display: none !important; }
  .shell { display: block; }
}
