/* ============ ClawAgen Docs — Design System ============ */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;600&family=Geist:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #FAF7F2;
  --bg-elev: #FFFFFF;
  --bg-sunken: #F2EDE5;
  --bg-code: #1B1714;
  --bg-code-elev: #221D19;
  --ink: #1B1714;
  --ink-2: #4A413A;
  --ink-3: #7A6E63;
  --ink-4: #A89B8E;
  --line: #E8E0D3;
  --line-2: #DCD2C2;
  --accent: oklch(0.62 0.14 45);
  --accent-soft: oklch(0.62 0.14 45 / 0.10);
  --accent-ink: oklch(0.45 0.14 45);
  --warn: oklch(0.70 0.14 75);
  --info: oklch(0.60 0.10 240);
  --success: oklch(0.62 0.12 150);
  --danger: oklch(0.58 0.18 25);

  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-serif: 'Instrument Serif', ui-serif, Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --sidebar-w: 272px;
  --toc-w: 240px;
  --topbar-h: 60px;
  --content-max: 760px;
}

[data-theme="dark"] {
  --bg: #15110E;
  --bg-elev: #1C1814;
  --bg-sunken: #110D0A;
  --bg-code: #0E0B09;
  --bg-code-elev: #181410;
  --ink: #F0EBE3;
  --ink-2: #C9C0B3;
  --ink-3: #948A7E;
  --ink-4: #6B6258;
  --line: #2A241F;
  --line-2: #3A332C;
  --accent: oklch(0.72 0.14 50);
  --accent-soft: oklch(0.72 0.14 50 / 0.14);
  --accent-ink: oklch(0.78 0.14 50);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}
body {
  font-family: var(--font-sans);
  font-size: 19px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
code, pre { font-family: var(--font-mono); }

/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0 24px 0 28px;
  height: var(--topbar-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 26px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 21px;
  line-height: 1;
  padding-bottom: 2px;
}
.brand-tag {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-left: 4px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 17.5px;
  color: var(--ink-2);
  padding-left: 4px;
}
.topnav a { padding: 6px 0; position: relative; }
.topnav a.active { color: var(--ink); }
.topnav a.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -19px;
  height: 1.5px; background: var(--ink);
}
.topnav a:hover { color: var(--ink); }

.topbar-right {
  display: flex; align-items: center; gap: 8px;
}

.search-trigger {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--ink-3);
  font-size: 17px;
  width: 220px;
  transition: border-color 0.15s;
}
.search-trigger:hover { border-color: var(--line-2); color: var(--ink-2); }
.search-trigger .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--ink-3);
}

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--ink-2);
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--ink); }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover { opacity: 0.9; }

.btn-ghost {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 17px;
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--bg-sunken); color: var(--ink); }

/* ============ Main grid ============ */
.main {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--toc-w);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 28px 16px 40px 28px;
  border-right: 1px solid var(--line);
  font-size: 17.5px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.side-section { margin-bottom: 4px; }
.side-section-header {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 8px 10px;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  text-align: left;
}
.side-section-header .chev {
  margin-left: auto;
  transition: transform 0.18s;
  opacity: 0.7;
}
.side-section.collapsed .chev { transform: rotate(-90deg); }
.side-section.collapsed .side-items { display: none; }

.side-items {
  display: flex; flex-direction: column;
  margin-bottom: 8px;
  position: relative;
}
.side-items::before {
  content: ''; position: absolute;
  left: 14px; top: 4px; bottom: 4px;
  width: 1px; background: var(--line);
}
.side-link {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 24px;
  border-radius: 6px;
  color: var(--ink-2);
  position: relative;
  transition: color 0.1s, background 0.1s;
}
.side-link:hover { color: var(--ink); }
.side-link.active {
  color: var(--accent-ink);
  font-weight: 500;
}
.side-link.active::before {
  content: ''; position: absolute;
  left: 14px; top: 6px; bottom: 6px;
  width: 1.5px; background: var(--accent);
  border-radius: 1px;
}
.side-link .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-sunken);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.side-link .badge.new { background: var(--accent-soft); color: var(--accent-ink); }

/* ============ Content ============ */
.content {
  padding: 48px 56px 120px;
  max-width: calc(var(--content-max) + 112px);
  width: 100%;
  min-width: 0;
}

/* Grid/flex children default to min-width: auto, which lets intrinsic content
   (long headings, code blocks, pre blocks, tables with white-space: pre/nowrap)
   inflate the track past the viewport. Force them to shrink below their
   intrinsic min-content when the parent is narrower. Root cause of mobile
   horizontal scroll — also applies to descendants of .content (.code-block,
   .codeblock, .doc-table). */
.main, .main > *, .api-split, .api-split > *,
.code-block, pre.codeblock, .doc-table {
  min-width: 0;
}
.content > * { max-width: 100%; }
pre, .code-block, .code-body { max-width: 100%; }

.crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 16.5px;
  color: var(--ink-3);
  margin-bottom: 24px;
}
.crumbs a:hover { color: var(--ink-2); }
.crumbs .sep { opacity: 0.5; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 14px;
}

.h1 {
  font-family: var(--font-serif);
  font-size: 60px;
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 0 0 18px;
  font-weight: 400;
}
.h1 em { font-style: italic; color: var(--ink-2); }

.lede {
  font-size: 22px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 620px;
  margin: 0 0 32px;
  text-wrap: pretty;
}

.h2 {
  font-family: var(--font-serif);
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 56px 0 14px;
  font-weight: 400;
  scroll-margin-top: 80px;
}
.h3 {
  font-size: 21px;
  font-weight: 600;
  margin: 36px 0 10px;
  letter-spacing: -0.005em;
  scroll-margin-top: 80px;
}
.h4 {
  font-size: 18px;
  font-weight: 600;
  margin: 24px 0 8px;
  letter-spacing: 0;
  scroll-margin-top: 80px;
}

.content p {
  margin: 0 0 16px;
  color: var(--ink-2);
  text-wrap: pretty;
  max-width: 660px;
}
.content p strong { color: var(--ink); font-weight: 600; }
.content a.inline {
  color: var(--accent-ink);
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
  transition: border-color 0.15s;
}
.content a.inline:hover { border-bottom-color: var(--accent); }

.content ul, .content ol {
  margin: 0 0 18px;
  padding-left: 22px;
  color: var(--ink-2);
  max-width: 660px;
}
.content li { margin-bottom: 6px; }
.content li::marker { color: var(--ink-4); }

.content code:not(pre code) {
  font-size: 0.86em;
  padding: 1px 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
}

/* ============ Code blocks ============ */
.code-block {
  background: var(--bg-code);
  border-radius: 10px;
  margin: 20px 0 28px;
  overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--bg-code) 80%, var(--line));
}
.code-head {
  display: flex; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 0 8px 0 14px;
  height: 38px;
}
.code-tabs {
  display: flex; gap: 2px;
}
.code-tab {
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 6px 10px;
  color: rgba(240,235,227,0.55);
  border-radius: 6px;
  position: relative;
}
.code-tab:hover { color: rgba(240,235,227,0.85); }
.code-tab.active {
  color: #F0EBE3;
  background: rgba(255,255,255,0.06);
}
.code-filename {
  font-family: var(--font-mono);
  font-size: 16px;
  color: rgba(240,235,227,0.55);
}
.code-actions { margin-left: auto; display: flex; gap: 2px; }
.code-icon-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: rgba(240,235,227,0.55);
  border-radius: 5px;
  transition: all 0.12s;
}
.code-icon-btn:hover { background: rgba(255,255,255,0.06); color: #F0EBE3; }
.code-icon-btn.copied { color: oklch(0.78 0.13 150); }

.code-body {
  display: block;
  font-family: var(--font-mono);
  font-size: 17px;
  line-height: 1.65;
  color: #E8E0D3;
  padding: 16px 18px;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}
.code-body .ln { color: rgba(240,235,227,0.25); display: inline-block; width: 28px; user-select: none; }
.tok-kw { color: oklch(0.78 0.14 320); }
.tok-str { color: oklch(0.80 0.13 110); }
.tok-num { color: oklch(0.78 0.14 50); }
.tok-fn { color: oklch(0.80 0.13 200); }
.tok-com { color: rgba(240,235,227,0.35); font-style: italic; }
.tok-var { color: oklch(0.85 0.05 60); }
.tok-pun { color: rgba(240,235,227,0.55); }

/* ============ Callouts ============ */
.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  margin: 20px 0 24px;
  max-width: 660px;
}
.callout .ico {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 5px;
  color: var(--ink-2);
  margin-top: 1px;
}
.callout-title { font-weight: 600; color: var(--ink); margin-bottom: 2px; font-size: 17.5px; }
.callout p { margin: 0; font-size: 17.5px; }
.callout.info .ico { background: color-mix(in oklab, var(--info) 15%, transparent); color: var(--info); }
.callout.warn .ico { background: color-mix(in oklab, var(--warn) 18%, transparent); color: oklch(0.50 0.12 75); }
.callout.note .ico { background: var(--accent-soft); color: var(--accent-ink); }
.callout.danger .ico { background: color-mix(in oklab, var(--danger) 15%, transparent); color: var(--danger); }

/* ============ TOC ============ */
.toc {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 48px 28px 40px 8px;
  font-size: 16.5px;
}
.toc-label {
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 12px;
  padding-left: 12px;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { position: relative; }
.toc a {
  display: block;
  padding: 5px 12px;
  color: var(--ink-3);
  border-left: 1.5px solid var(--line);
  transition: color 0.1s, border-color 0.15s;
  line-height: 1.4;
}
.toc a:hover { color: var(--ink-2); }
.toc a.active {
  color: var(--accent-ink);
  border-left-color: var(--accent);
}
.toc li.lvl-3 a { padding-left: 24px; font-size: 16px; }

.toc-foot {
  margin-top: 32px;
  padding: 16px 12px 0;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.toc-foot a {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px;
  color: var(--ink-3);
  padding: 4px 0;
}
.toc-foot a:hover { color: var(--ink); }

/* ============ Cards / grids on home ============ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 24px 0 40px;
  max-width: 820px;
}
.card {
  display: block;
  padding: 22px 22px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  transition: all 0.18s;
  position: relative;
}
.card:hover {
  border-color: var(--line-2);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -10px rgba(27,23,20,0.12);
}
.card-ico {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg-sunken);
  display: grid; place-items: center;
  color: var(--ink-2);
  margin-bottom: 14px;
}
.card h3 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.card p { margin: 0; font-size: 17px; color: var(--ink-3); }
.card .arr {
  position: absolute; top: 22px; right: 22px;
  color: var(--ink-4); transition: all 0.18s;
}
.card:hover .arr { color: var(--accent-ink); transform: translate(2px, -2px); }

/* ============ API reference layout ============ */
.api-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  margin: 28px 0 40px;
}
.api-doc h4 { margin-top: 18px; }
.api-doc h4:first-child { margin-top: 0; }
.api-side {
  position: sticky;
  top: 80px;
  align-self: start;
}

.endpoint {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 16px 0 24px;
  font-family: var(--font-mono);
  font-size: 17px;
}
.method {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}
.method.get { background: color-mix(in oklab, var(--info) 15%, transparent); color: var(--info); }
.method.post { background: color-mix(in oklab, var(--success) 15%, transparent); color: oklch(0.45 0.12 150); }
.method.del { background: color-mix(in oklab, var(--danger) 15%, transparent); color: var(--danger); }
.method.put { background: color-mix(in oklab, var(--warn) 18%, transparent); color: oklch(0.50 0.12 75); }
.endpoint .path { color: var(--ink); }
.endpoint .path .var { color: var(--accent-ink); }

.params {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0 24px;
  background: var(--bg-elev);
}
.param {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.param:last-child { border-bottom: none; }
.param-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.param-name {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}
.param-type {
  font-family: var(--font-mono);
  font-size: 15.5px;
  color: var(--ink-3);
}
.param-req {
  font-family: var(--font-mono);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--danger);
  padding: 1px 5px;
  background: color-mix(in oklab, var(--danger) 10%, transparent);
  border-radius: 3px;
}
.param-opt {
  font-family: var(--font-mono);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
}
.param-desc { font-size: 17px; color: var(--ink-2); margin: 0; }
.param-desc code { font-size: 0.85em; }

/* ============ Feedback widget ============ */
.feedback {
  margin: 80px 0 40px;
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  max-width: 660px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}
.feedback h4 { margin: 0 0 4px; font-size: 18px; }
.feedback p { margin: 0; font-size: 17px; color: var(--ink-3); }
.fb-actions { display: flex; gap: 8px; }
.fb-btn {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 17px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.12s;
}
.fb-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.fb-btn.selected { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.feedback-form {
  display: none;
  grid-column: 1 / -1;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.feedback.open .feedback-form { display: block; }
.feedback-form textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 17.5px;
  resize: vertical;
  outline: none;
}
.feedback-form textarea:focus { border-color: var(--accent); }
.feedback-form .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.page-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 40px 0 0;
  max-width: 660px;
}
.page-foot a {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
  transition: all 0.15s;
}
.page-foot a:hover { border-color: var(--line-2); }
.page-foot .label { font-size: 15.5px; color: var(--ink-3); margin-bottom: 4px; }
.page-foot .title { font-size: 18px; font-weight: 500; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.page-foot a.next { text-align: right; }
.page-foot a.next .title { justify-content: flex-end; }

/* ============ Search overlay ============ */
.search-overlay {
  position: fixed; inset: 0;
  background: color-mix(in oklab, var(--ink) 35%, transparent);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
}
.search-overlay.open { display: flex; }
.search-modal {
  width: 620px;
  max-width: calc(100vw - 32px);
  background: var(--bg-elev);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  height: 56px;
}
.search-input {
  flex: 1;
  border: none; outline: none; background: none;
  font-family: inherit;
  font-size: 20px;
  color: var(--ink);
}
.search-input::placeholder { color: var(--ink-4); }
.search-results { overflow-y: auto; padding: 8px; }
.search-empty {
  padding: 32px; text-align: center;
  font-size: 17px; color: var(--ink-3);
}
.search-group-label {
  font-size: 14.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 10px 12px 6px;
}
.search-result {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 17.5px;
}
.search-result.focused { background: var(--accent-soft); color: var(--accent-ink); }
.search-result .res-ico { color: var(--ink-3); }
.search-result.focused .res-ico { color: var(--accent-ink); }
.search-result .res-title { font-weight: 500; }
.search-result .res-path {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink-3);
}
.search-result mark { background: transparent; color: var(--accent-ink); font-weight: 600; }

.search-foot {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 15.5px;
  color: var(--ink-3);
}
.search-foot .item { display: flex; align-items: center; gap: 6px; }
.search-foot .kbd {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 1.5px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-sunken);
  color: var(--ink-2);
}

/* ============ 404 ============ */
.notfound {
  min-height: calc(100vh - var(--topbar-h));
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
}
.nf-num {
  font-family: var(--font-serif);
  font-size: 204px;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin: 0;
  font-style: italic;
}
.nf-num em { color: var(--accent); font-style: italic; }

/* ============ Changelog ============ */
.cl-entry {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 32px;
  padding: 32px 0;
  border-top: 1px solid var(--line);
}
.cl-entry:first-of-type { border-top: none; padding-top: 0; }
.cl-meta { padding-top: 4px; }
.cl-date {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--ink-3);
  letter-spacing: -0.005em;
  margin-bottom: 6px;
}
.cl-version {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 15.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.cl-title {
  font-family: var(--font-serif);
  font-size: 30px;
  line-height: 1.15;
  font-weight: 400;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
.cl-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  margin-right: 6px;
  margin-bottom: 10px;
}
.cl-tag.added { background: color-mix(in oklab, var(--success) 12%, transparent); color: oklch(0.45 0.12 150); }
.cl-tag.fixed { background: color-mix(in oklab, var(--info) 12%, transparent); color: var(--info); }
.cl-tag.changed { background: color-mix(in oklab, var(--warn) 16%, transparent); color: oklch(0.45 0.12 75); }
.cl-tag.removed { background: color-mix(in oklab, var(--danger) 12%, transparent); color: var(--danger); }

/* ============ Tweaks panel ============ */
.tweaks-panel {
  position: fixed;
  bottom: 16px; right: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.2);
  z-index: 200;
  display: none;
  font-size: 17px;
  min-width: 200px;
}
.tweaks-panel.visible { display: block; }
.tweaks-title {
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 10px;
}
.tweaks-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.tweaks-row:last-child { margin-bottom: 0; }
.toggle-group {
  display: flex; gap: 2px;
  background: var(--bg-sunken);
  border-radius: 6px;
  padding: 2px;
}
.toggle-btn {
  font-size: 16px;
  padding: 4px 10px;
  border-radius: 4px;
  color: var(--ink-3);
}
.toggle-btn.active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ============ Misc ============ */
.tag-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 15.5px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--bg-sunken);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

hr.rule {
  border: none;
  border-top: 1px solid var(--line);
  margin: 40px 0;
}

/* doc tables — used on concept pages like flow.html */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 17.5px;
  line-height: 1.55;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.doc-table thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-sunken);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 16.5px;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--line);
}
.doc-table tbody td {
  padding: 12px 14px;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.doc-table tbody tr:last-child td { border-bottom: none; }
.doc-table tbody tr:hover { background: var(--bg); }
.doc-table code {
  font-size: 16px;
}

/* inline ASCII diagram used in flow.jsx */
pre.codeblock {
  font-family: var(--font-mono);
  font-size: 16.5px;
  line-height: 1.55;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  overflow: auto;
  margin: 20px 0 28px;
  white-space: pre;
}

/* Mobile hamburger + sidebar drawer */
.menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  margin-right: 10px;
  flex-shrink: 0;
}
.menu-btn:hover { background: var(--bg-sunken); }
.sidebar-close {
  display: none;
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  z-index: 2;
}
.sidebar-close:hover { background: var(--bg-sunken); }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: color-mix(in oklab, var(--ink) 50%, transparent);
  z-index: 89;
  animation: fade-in 0.18s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }

/* responsive */
@media (max-width: 1180px) {
  .toc, .api-side { display: none; }
  .main { grid-template-columns: var(--sidebar-w) 1fr; }
  .api-split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  /* +15% base font size for better mobile readability */
  body { font-size: 17.25px; }

  /* Hard clamp every container to the viewport — no horizontal scroll, ever */
  html, body, .app, .main, .content, .topbar {
    max-width: 100vw;
    overflow-x: hidden;
  }
  .content > *, article.content > * {
    max-width: 100%;
  }
  .content img, .content video, .content iframe, .content svg {
    max-width: 100%;
    height: auto;
  }
  /* Changelog grid — collapse to single column on phones */
  .cl-entry { grid-template-columns: 1fr; gap: 12px; padding: 24px 0; }
  .cl-meta { padding-top: 0; }

  /* Hamburger + drawer */
  .menu-btn {
    display: inline-flex;
    width: 34px;
    height: 34px;
    margin-right: 8px;
  }
  .sidebar-close { display: inline-flex; }

  /* Topbar becomes flex on mobile so menu + brand + right-side buttons stay
     on one row. Grid's 1fr/auto columns were wrapping topbar-right below. */
  .topbar {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .topbar .brand { min-width: 0; flex-shrink: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .topbar .topnav { display: none; }
  .topbar-right {
    margin-left: auto;
    flex-shrink: 0;
    gap: 4px;
  }
  .topbar-right .btn-primary {
    padding: 6px 10px;
    font-size: 12.5px;
  }
  .topbar-right .icon-btn {
    width: 32px;
    height: 32px;
  }

  /* Turn the sidebar into a slide-in drawer */
  .sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 82vw;
    max-width: 320px;
    height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--line);
    z-index: 90;
    overflow-y: auto;
    padding: 56px 16px 40px 20px;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.35);
  }
  .sidebar-backdrop { display: block; }
  .main { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .topnav, .search-trigger { display: none; }
  .content { padding: 28px 16px 72px; max-width: 100%; }
  .h1 { font-size: 42px; }
  .h2 { font-size: 30px; margin: 40px 0 12px; }
  .h3 { font-size: 18px; margin: 28px 0 8px; }
  .lede { font-size: 19px; max-width: 100%; }
  .content p, .content ul, .content ol, .callout, .feedback, .page-foot { max-width: 100%; }
  .card-grid { grid-template-columns: 1fr !important; max-width: 100%; }
  .card { padding: 18px 18px 16px; }
  .card h3 { font-size: 17px; }
  .card p { font-size: 14.5px; }
  .card .arr { top: 18px; right: 18px; }
  .page-foot { grid-template-columns: 1fr; }
  .feedback {
    grid-template-columns: 1fr;
    padding: 20px 20px;
    margin: 56px 0 32px;
  }
  .fb-actions { justify-self: start; }
  .feedback h4 { font-size: 16px; }
  .feedback p, .feedback .fb-btn { font-size: 15px; }
  .callout { padding: 12px 14px; }
  .callout p, .callout-title { font-size: 15px; }
  .doc-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 15.5px;
  }
  .doc-table thead, .doc-table tbody, .doc-table tr { display: table; width: 100%; table-layout: auto; }
  .doc-table td, .doc-table th { white-space: normal; }
  .doc-table thead th { font-size: 14.5px; }
  pre.codeblock { font-size: 13px; padding: 14px 14px; max-width: 100%; }
  .code-block { margin: 16px 0 22px; }
  .code-body { font-size: 14px; padding: 14px 14px; }
  .code-head { padding: 0 6px 0 10px; height: 36px; }
  .code-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .code-tab { flex-shrink: 0; font-size: 13px; padding: 6px 8px; }
  .code-filename { font-size: 13px; }
  .eyebrow { font-size: 12px; }
  .tag-pill { font-size: 13px; }
  .btn-primary, .btn-ghost { font-size: 14px; padding: 7px 13px; }
  .crumbs { font-size: 14px; margin-bottom: 18px; flex-wrap: wrap; }
  .brand { font-size: 22px; gap: 8px; }
  .brand-mark { width: 24px; height: 24px; font-size: 17px; }
  .brand-tag { display: none; }
  .param-name { font-size: 15px; }
  .param-desc { font-size: 15px; }
  .param-type { font-size: 13px; }
  .param-req, .param-opt { font-size: 11.5px; }
  .toc-label { font-size: 13px; }
  .page-foot .label { font-size: 13px; }
  .page-foot .title { font-size: 16px; }
}
@media (max-width: 420px) {
  .content { padding: 24px 14px 64px; }
  .h1 { font-size: 35px; }
  .h2 { font-size: 25px; }
  .lede { font-size: 18px; }
  .brand { font-size: 20px; }
}
