/* Raggie Code website.
   Same design language as the Raggie web UI (web-ui/src/app.css): ink on
   white, 1px borders, square corners, IBM Plex Sans + Mono, and an
   inverted-mono dark theme. Color tokens are copied from the web UI so the
   two stay visually identical; type sizes are scaled up for reading. */

/* ---------- Fonts (self-hosted) ---------- */
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  /* Colors: identical to the web UI */
  --fg: #1e1e1e;
  --fg-muted: #3f3f3d;
  --fg-subtle: #5c6066;
  --fg-disabled: #c4c4c2;

  --bg: #fff;
  --bg-page: #dddddd;
  --bg-hover: #f6f6f4;
  --bg-hover-alt: #f1f1ef;
  --bg-active: #f0f0ee;
  --bg-code: #f6f6f4;

  --border: #1e1e1e;
  --border-soft: #e9ecef;

  --primary-bg: #1e1e1e;
  --primary-bg-hover: #3a3a3a;
  --primary-fg: #fff;

  --warn-bg: #ffec99;
  --warn-fg: #956521;
  --success-fg: #2e7d32;
  --success-bg: #ebfbee;
  --danger-fg: #b54747;

  --bubble-bg: #1e1e1e;
  --bubble-fg: #fff;

  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Type: the web UI scale, sized up for long-form reading */
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-md: 13.5px;
  --fs-body: 15px;
  --fs-lg: 17px;
  --fs-h3: 16px;
  --fs-h2: 24px;
  --fs-h1: clamp(30px, 4.6vw, 46px);

  --border-w: 1px;
  --control: 28px;
  --page-max: 1100px;
  --gutter: 32px;
  --header-h: 49px;
}

html[data-theme='dark'] {
  color-scheme: dark;

  --fg: #e8e8e4;
  --fg-muted: #b8b8b2;
  --fg-subtle: #878b91;
  --fg-disabled: #4a4a48;

  --bg: #1c1c1a;
  --bg-page: #101010;
  --bg-hover: #242422;
  --bg-hover-alt: #2a2a27;
  --bg-active: #282825;
  --bg-code: #242422;

  --border: #6f6f6b;
  --border-soft: #33332f;

  --primary-bg: #f0f0ec;
  --primary-bg-hover: #d8d8d2;
  --primary-fg: #151514;

  --warn-bg: #43390f;
  --warn-fg: #e0b53e;
  --success-fg: #6fce7a;
  --success-bg: #17291a;
  --danger-fg: #e06c6c;

  --bubble-fg: #151514;
  --bubble-bg: #e1e1e1;
}

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

html {
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg-page);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--fg);
}

a:hover {
  color: var(--fg-muted);
}

::selection {
  background: #b7e4c7;
  color: #1b4332;
}

html[data-theme='dark'] ::selection {
  background: #2f6b46;
  color: #d8f3dc;
}

:focus-visible {
  outline: 2px solid var(--fg-subtle);
  outline-offset: 2px;
}

img {
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  user-select: none;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 8px;
  top: 8px;
  z-index: 100;
  padding: 6px 10px;
  background: var(--primary-bg);
  color: var(--primary-fg);
}

/* ---------- Window: the app card on the gray page ---------- */
.window {
  width: min(100%, var(--page-max));
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  border-inline: var(--border-w) solid var(--border);
  display: flex;
  flex-direction: column;
}

@media (max-width: 1100px) {
  .window {
    border-inline: none;
  }
}

/* ---------- Header (the web UI pane header) ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
  padding: 0 var(--gutter);
  background: var(--bg);
  border-bottom: var(--border-w) solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-lg);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 22px;
  height: 22px;
  display: block;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  flex: 1;
  min-width: 0;
}

.site-nav a {
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover {
  background: var(--bg-hover-alt);
  color: var(--fg);
}

.site-nav a[aria-current='page'] {
  color: var(--fg);
  background: var(--bg-active);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control);
  padding: 0 12px;
  white-space: nowrap;
  background: var(--bg);
  color: var(--fg-muted);
  border: var(--border-w) solid var(--border);
  font-family: var(--sans);
  font-size: var(--fs-md);
  line-height: 1;
  text-decoration: none;
}

.btn:hover {
  background: var(--bg-hover-alt);
  color: var(--fg);
}

.btn-primary {
  background: var(--primary-bg);
  color: var(--primary-fg);
}

.btn-primary:hover {
  background: var(--primary-bg-hover);
  color: var(--primary-fg);
}

.btn.nav-toggle {
  display: none;
}

.btn-lg {
  height: 38px;
  padding: 0 18px;
  font-size: var(--fs-body);
}

/* ---------- Sections ---------- */
.section {
  padding: 64px var(--gutter);
  border-top: var(--border-w) solid var(--border);
}

.section:first-of-type {
  border-top: none;
}

.label {
  display: block;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section h2 {
  font-size: var(--fs-h2);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.section-lede {
  max-width: 62ch;
  margin-top: 12px;
  color: var(--fg-muted);
  text-wrap: pretty;
}

.section-body {
  margin-top: 32px;
}

/* ---------- Hero ---------- */
.hero {
  padding: 72px var(--gutter) 56px;
}

.hero h1 {
  max-width: 21ch;
  font-size: var(--fs-h1);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.hero-lede {
  max-width: 60ch;
  margin-top: 20px;
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--fg-muted);
  text-wrap: pretty;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
}

.hero-meta {
  margin-top: 16px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

/* ---------- Command chip with copy ---------- */
.cmd {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  border: var(--border-w) solid var(--border);
  background: var(--bg-code);
  font-family: var(--mono);
  font-size: var(--fs-md);
}

.cmd code {
  display: block;
  padding: 9px 12px;
  overflow-x: auto;
  white-space: nowrap;
}

.cmd code::before {
  content: '$ ';
  color: var(--fg-subtle);
  user-select: none;
}

.cmd .copy {
  flex-shrink: 0;
  padding: 0 12px;
  border: none;
  border-left: var(--border-w) solid var(--border);
  background: var(--bg);
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: var(--fs-xs);
}

.cmd .copy:hover {
  background: var(--bg-hover-alt);
  color: var(--fg);
}

.cmd .copy.copied {
  color: var(--success-fg);
}

/* ---------- Chat mock: a replica of the web UI chat view ---------- */
.mock {
  margin-top: 72px;
  border: 6px solid var(--border);
  background: var(--bg);
  font-size: 12.5px;
  line-height: 16px;
}

.mock-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: var(--border-w) solid var(--border);
}

.mock-back {
  color: var(--fg);
  font-size: 12.5px;
}

.mock-title {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mock-chip {
  flex-shrink: 0;
  height: 22px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  border: var(--border-w) solid var(--border);
  color: var(--fg-muted);
  font-size: 11.5px;
}

.mock-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
}

.m-user {
  align-self: flex-end;
  max-width: 70%;
  padding: 8px 10px;
  background: var(--bubble-bg);
  color: var(--bubble-fg);
  text-wrap: pretty;
}

.m-agent {
  font-family: var(--mono);
  font-size: 11.5px;
  text-wrap: pretty;
}

.m-thought {
  padding-left: 10px;
  border-left: 5px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-subtle);
}

.m-tool {
  padding: 8px 10px;
  border: var(--border-w) dotted var(--border);
  font-family: var(--mono);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

.m-tool::before {
  content: '>';
  margin-right: 6px;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--success-fg);
}

.m-tool .arg {
  color: var(--fg-subtle);
}

.m-sub {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 2px solid var(--fg);
}

.m-sub-label {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.m-perm {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 18px 18px;
  border: var(--border-w) solid var(--border);
}

.m-perm-title {
  font-size: 18px;
  line-height: 1.2;
}

.m-perm-cmd {
  padding: 8px;
  background: var(--bg-code);
  font-family: var(--mono);
  font-size: 11.5px;
}

.m-perm-actions {
  display: flex;
  gap: 12px;
}

.m-perm-actions span {
  min-width: 70px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: var(--border-w) solid var(--border);
}

.m-perm-actions .yes {
  background: var(--primary-bg);
  color: var(--primary-fg);
}

.m-perm-actions .no {
  background: var(--border-soft);
}

.m-todo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px 8px;
  padding: 4px 10px;
  border: var(--border-w) solid var(--border-soft);
  font-family: var(--mono);
  font-size: 11.5px;
}

.m-todo .k {
  padding-right: 8px;
  border-right: var(--border-w) solid var(--border-soft);
  font-size: 10.5px;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.m-todo .dim {
  font-size: 10.5px;
  color: var(--fg-subtle);
}

.m-todo .next {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mock-caption {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

/* ---------- Bordered grids ---------- */
.grid {
  display: grid;
  border-top: var(--border-w) solid var(--border);
  border-left: var(--border-w) solid var(--border);
}

.grid > * {
  padding: 22px 22px 24px;
  border-right: var(--border-w) solid var(--border);
  border-bottom: var(--border-w) solid var(--border);
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cell h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: 1.35;
}

.cell p {
  margin-top: 8px;
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--fg-muted);
  text-wrap: pretty;
}

.cell .tag {
  display: block;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

.cell code,
.section-lede code,
.faq code,
.steps code,
.compare code {
  padding: 1px 4px;
  background: var(--bg-code);
  font-family: var(--mono);
  font-size: 0.88em;
}

a.cell {
  display: block;
  text-decoration: none;
}

a.cell:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.cell .more {
  display: inline-block;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg);
  text-decoration: underline;
}

/* ---------- Stats strip ---------- */
.stats .cell {
  padding: 20px 22px;
}

.stat-num {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-label {
  margin-top: 6px;
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--fg-muted);
}

/* ---------- Numbered steps ---------- */
.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  border-top: var(--border-w) solid var(--border);
}

.steps > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 0 8px;
  padding: 18px 0;
  border-bottom: var(--border-w) solid var(--border-soft);
}

.steps > li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--fg-subtle);
  padding-top: 2px;
}

.steps h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
}

.steps p {
  margin-top: 4px;
  max-width: 68ch;
  font-size: var(--fs-md);
  color: var(--fg-muted);
  text-wrap: pretty;
}

.steps .cmd {
  margin-top: 10px;
}

/* ---------- Comparison table ---------- */
.table-wrap {
  overflow-x: auto;
}

.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
}

.compare th,
.compare td {
  padding: 11px 14px;
  border: var(--border-w) solid var(--border-soft);
  text-align: start;
  vertical-align: top;
}

.compare thead th {
  background: var(--bg-code);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
}

.compare tbody th {
  width: 24%;
  font-weight: 500;
}

.compare td:last-child {
  color: var(--fg-subtle);
}

/* ---------- FAQ (styled like web UI tool rows) ---------- */
.faq {
  border-top: var(--border-w) solid var(--border);
}

.faq details {
  border-bottom: var(--border-w) solid var(--border-soft);
}

.faq summary {
  display: flex;
  gap: 10px;
  padding: 14px 4px;
  cursor: pointer;
  list-style: none;
  font-weight: 500;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::before {
  content: '>';
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 24px;
  color: var(--success-fg);
  transition: transform 120ms ease;
}

.faq details[open] summary::before {
  transform: rotate(90deg);
}

.faq summary:hover {
  background: var(--bg-hover);
}

.faq .answer {
  max-width: 72ch;
  padding: 0 4px 18px 26px;
  font-size: var(--fs-md);
  color: var(--fg-muted);
}

.faq .answer p + p {
  margin-top: 10px;
}

/* ---------- Closing call to action ---------- */
.cta {
  background: var(--primary-bg);
  color: var(--primary-fg);
}

.cta h2 {
  max-width: 24ch;
}

.cta .section-lede {
  color: var(--primary-fg);
  opacity: 0.75;
}

.cta .btn {
  border-color: var(--primary-fg);
}

.cta .btn-primary {
  background: var(--primary-fg);
  color: var(--primary-bg);
}

.cta .btn-primary:hover {
  opacity: 0.88;
}

.cta .btn-ghost {
  background: transparent;
  color: var(--primary-fg);
}

.cta .btn-ghost:hover {
  background: transparent;
  opacity: 0.75;
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: auto;
  padding: 32px var(--gutter) 28px;
  border-top: var(--border-w) solid var(--border);
  font-size: var(--fs-md);
}

.footer-cols {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.footer-cols h4 {
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.footer-cols ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-cols li {
  margin: 4px 0;
}

.footer-cols a {
  color: var(--fg-muted);
  text-decoration: none;
}

.footer-cols a:hover {
  color: var(--fg);
  text-decoration: underline;
}

.footer-note {
  max-width: 34ch;
  margin-top: 8px;
  color: var(--fg-muted);
}

.footer-legal {
  margin-top: 28px;
  padding-top: 14px;
  border-top: var(--border-w) solid var(--border-soft);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

/* ---------- Docs layout ---------- */
.docs {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  flex: 1;
}

.docs-side {
  border-right: var(--border-w) solid var(--border);
}

.docs-side-inner {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 18px 0 28px;
}

.docs-side summary {
  display: none;
}

.docs-group {
  padding: 14px 20px 4px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.docs-side a {
  display: block;
  padding: 5px 20px;
  border-left: 3px solid transparent;
  font-size: var(--fs-md);
  color: var(--fg-muted);
  text-decoration: none;
}

.docs-side a:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.docs-side a[aria-current='page'] {
  background: var(--bg-active);
  border-left-color: var(--fg);
  color: var(--fg);
  font-weight: 500;
}

.docs-main {
  min-width: 0;
  padding: 36px 44px 56px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 48px;
  border: var(--border-w) solid var(--border);
}

.pager a {
  display: block;
  padding: 14px 16px;
  text-decoration: none;
}

.pager a:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.pager a + a,
.pager span + a {
  border-left: var(--border-w) solid var(--border);
  text-align: right;
}

.pager small {
  display: block;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

.edit-link {
  display: inline-block;
  margin-top: 20px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

/* ---------- Long-form content (the web UI .md rules, scaled) ---------- */
.md {
  max-width: 760px;
  overflow-wrap: anywhere;
}

.md > :first-child {
  margin-top: 0;
}

.md p,
.md ul,
.md ol,
.md blockquote,
.md pre,
.md .table-wrap {
  margin: 14px 0;
}

.md h1 {
  margin-bottom: 18px;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.md h2 {
  margin: 44px 0 14px;
  padding-top: 22px;
  border-top: var(--border-w) solid var(--border-soft);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.3;
}

.md h3 {
  margin: 30px 0 10px;
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: 1.4;
}

.md h4 {
  margin: 22px 0 8px;
  font-size: var(--fs-body);
  font-weight: 600;
}

.md h2 .anchor,
.md h3 .anchor,
.md h4 .anchor {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--fg-disabled);
  text-decoration: none;
  visibility: hidden;
}

.md h2:hover .anchor,
.md h3:hover .anchor,
.md h4:hover .anchor,
.md .anchor:focus-visible {
  visibility: visible;
}

.md ul,
.md ol {
  padding-inline-start: 22px;
}

.md li {
  margin: 4px 0;
}

.md li > ul,
.md li > ol {
  margin: 4px 0;
}

.md code {
  padding: 1px 4px;
  background: var(--bg-code);
  font-family: var(--mono);
  font-size: 0.87em;
  overflow-wrap: anywhere;
}

.md h1 code,
.md h2 code,
.md h3 code {
  font-size: 0.9em;
}

.md pre {
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--bg-code);
  border: var(--border-w) solid var(--border-soft);
}

.md pre code {
  padding: 0;
  background: none;
  font-size: var(--fs-sm);
  line-height: 1.55;
  white-space: pre;
  overflow-wrap: normal;
}

.md blockquote {
  margin-inline: 0;
  padding-inline-start: 14px;
  border-inline-start: 3px solid var(--border-soft);
  color: var(--fg-muted);
}

.md a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
}

.md th,
.md td {
  padding: 7px 10px;
  border: var(--border-w) solid var(--border-soft);
  text-align: start;
  vertical-align: top;
  overflow-wrap: normal;
}

.md th {
  background: var(--bg-code);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

.md td code {
  overflow-wrap: normal;
}

.md hr {
  margin: 28px 0;
  border: none;
  border-top: var(--border-w) solid var(--border-soft);
}

/* ---------- Blog ---------- */
.page-head {
  padding: 52px var(--gutter) 40px;
  border-bottom: var(--border-w) solid var(--border);
}

.page-head h1 {
  max-width: 30ch;
  font-size: clamp(26px, 3.6vw, 38px);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.page-head .section-lede {
  font-size: var(--fs-lg);
}

.byline {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

.article {
  padding: 40px var(--gutter) 64px;
}

.article-foot {
  max-width: 760px;
  margin-top: 48px;
}

.rows a {
  display: block;
  padding: 20px var(--gutter);
  border-bottom: var(--border-w) solid var(--border-soft);
  text-decoration: none;
}

.rows a:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.row-title {
  font-size: var(--fs-lg);
  font-weight: 500;
  line-height: 1.35;
}

.row-time {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

.row-preview {
  max-width: 78ch;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--fg-muted);
}

/* ---------- 404 ---------- */
.notfound {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px var(--gutter);
}

.notfound h1 {
  font-size: var(--fs-h1);
  font-weight: 500;
  letter-spacing: -0.02em;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  :root {
    --gutter: 20px;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .docs {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-side {
    border-right: none;
    border-bottom: var(--border-w) solid var(--border);
  }

  .docs-side-inner {
    position: static;
    max-height: none;
    padding: 0;
  }

  .docs-side summary {
    display: block;
    padding: 11px var(--gutter);
    cursor: pointer;
    font-family: var(--mono);
    font-size: var(--fs-sm);
    list-style: none;
  }

  .docs-side summary::-webkit-details-marker {
    display: none;
  }

  .docs-side summary::before {
    content: '>';
    display: inline-block;
    margin-right: 8px;
    font-weight: 700;
    color: var(--success-fg);
    transition: transform 120ms ease;
  }

  .docs-side details[open] summary::before {
    transform: rotate(90deg);
  }

  .docs-side details[open] {
    padding-bottom: 14px;
  }

  .docs-main {
    padding: 28px var(--gutter) 48px;
  }

  .footer-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .btn.nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 6px 0;
    background: var(--bg);
    border-bottom: var(--border-w) solid var(--border);
  }

  .site-nav.open {
    display: flex;
  }

  .site-nav a {
    padding: 9px var(--gutter);
  }

  .header-actions {
    margin-left: auto;
  }

  .header-actions .hide-sm {
    display: none;
  }

  .hero {
    padding: 48px var(--gutter) 40px;
  }

  .section {
    padding: 48px var(--gutter);
  }

  .m-user {
    max-width: 88%;
  }
}

@media (max-width: 560px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .steps > li {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager a + a,
  .pager span + a {
    border-left: none;
    border-top: var(--border-w) solid var(--border);
    text-align: left;
  }

  .footer-cols {
    grid-template-columns: minmax(0, 1fr);
  }

  .mock-body {
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media print {
  .site-header,
  .docs-side,
  .site-footer,
  .pager {
    display: none;
  }

  body {
    background: #fff;
  }

  .window {
    border: none;
  }
}

/* ---------- Overrides for nested components ---------- */
.cell .cmd code,
.steps .cmd code {
  padding: 9px 12px;
  background: none;
  font-size: 1em;
}

.cell .steps {
  margin-top: 14px;
}

/* ---------- Terminal-style motion ----------
   Two moments: the headline types out behind a block cursor, and the chat
   preview plays back like a live session. Driven by site.js; everything
   is visible as normal without scripts or with reduced motion. */

/* Characters wrapped by site.js. Hidden with visibility so the text keeps
   its final layout while it is revealed. */
.ch {
  visibility: hidden;
}

.ch.on {
  visibility: visible;
}

/* Block cursor: an empty inline span, so it takes no space and adds no
   line-break opportunity inside the word being typed. */
.cursor {
  position: relative;
}

.cursor::after {
  content: '';
  position: absolute;
  left: 0.08em;
  bottom: 0.16em;
  width: 0.52em;
  height: 0.84em;
  background: currentColor;
  animation: blink 1.06s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* Avoid a flash of the finished headline before site.js starts typing. If
   the script never runs, the delayed animation reveals it anyway. */
.js [data-type]:not(.typed) {
  visibility: hidden;
  animation: reveal 0s 2s forwards;
}

.js .mock[data-play]:not(.armed) [data-step] {
  visibility: hidden;
  animation: reveal 0s 2s forwards;
}

@keyframes reveal {
  to {
    visibility: visible;
  }
}

.mock.armed [data-step] {
  visibility: hidden;
}

.mock.armed [data-step].on {
  visibility: visible;
}

/* A running tool call shows the classic | / - \ spinner where its green
   marker will be. site.js cycles the data-spin attribute. */
.m-tool[data-spin]::before {
  content: attr(data-spin);
  color: var(--fg-subtle);
}

.replay {
  padding: 0 6px;
  border: var(--border-w) solid var(--border-soft);
  background: none;
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: var(--fs-xs);
}

.replay:hover {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

/* Reverse video on hover, like a selected line in a terminal. */
.site-nav a:hover {
  background: var(--fg);
  color: var(--bg);
}

@media (prefers-reduced-motion: reduce) {
  .cursor::after {
    animation: none;
  }
}
