/* =====================================================================================================================
   DevOps Buddy website. Same design system as the product (docs/DESIGN.md): shadcn/ui "Neutral", light by default,
   dark as its own palette, Inter + JetBrains Mono, status colour only at dot / icon / thin-bar size, brand ember only
   on the logo and the Buddy sparkles that mark AI-written content. No gradients, halo effects, blur or coloured shadows.

   Tokens are copied verbatim from apps/buddy/src/web/design/theme.css. Keep them in sync when that file changes.
   Theme: light by default; `.dark` on <html> (set before paint by the inline boot script, key `buddy.theme`).
   Without JS the OS preference applies (media query at the end of the token block).
   ===================================================================================================================== */

:root {
  --radius: 0.5rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --sidebar: oklch(0.985 0 0);
  --success: oklch(50.8% 0.118 165.612);
  --warning: oklch(55.4% 0.135 66.442);
  --info: oklch(54.6% 0.245 262.881);
  --neutral: oklch(0.556 0 0);
  --diff-add: oklch(59.6% 0.145 163.225 / 0.1);
  --diff-add-strong: oklch(59.6% 0.145 163.225 / 0.24);
  --diff-remove: oklch(57.7% 0.245 27.325 / 0.08);
  --diff-remove-strong: oklch(57.7% 0.245 27.325 / 0.2);
  --brand: oklch(64.6% 0.222 41.116);

  /* Site-only helpers, all derived from the tokens above. */
  --well: color-mix(in oklab, var(--muted) 55%, var(--background));
  --skeleton: color-mix(in oklab, var(--foreground) 7%, transparent);
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, monospace;
  --radius-sm: calc(var(--radius) - 4px);  /* 4  kbd, chips */
  --radius-md: calc(var(--radius) - 2px);  /* 6  buttons, inputs */
  --radius-lg: var(--radius);              /* 8  dialogs, code */
  --radius-xl: calc(var(--radius) + 4px);  /* 12 cards, frames */

  --gutter: 24px;
  color-scheme: light;
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --sidebar: oklch(0.205 0 0);
  --success: oklch(76.5% 0.177 163.223);
  --warning: oklch(82.8% 0.189 84.429);
  --info: oklch(70.7% 0.165 254.624);
  --neutral: oklch(0.708 0 0);
  --diff-add: oklch(69.6% 0.17 162.48 / 0.12);
  --diff-add-strong: oklch(69.6% 0.17 162.48 / 0.28);
  --diff-remove: oklch(63.7% 0.237 25.331 / 0.12);
  --diff-remove-strong: oklch(63.7% 0.237 25.331 / 0.3);
  --brand: oklch(70.5% 0.19 40);
  --well: color-mix(in oklab, var(--card) 45%, var(--background));
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.35), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

/* No JS: follow the OS. (With JS the boot script sets .dark itself.) */
@media (prefers-color-scheme: dark) {
  :root:not(.js) {
    --background: oklch(0.145 0 0); --foreground: oklch(0.985 0 0); --card: oklch(0.205 0 0);
    --card-foreground: oklch(0.985 0 0); --popover: oklch(0.205 0 0); --popover-foreground: oklch(0.985 0 0);
    --primary: oklch(0.922 0 0); --primary-foreground: oklch(0.205 0 0); --secondary: oklch(0.269 0 0);
    --secondary-foreground: oklch(0.985 0 0); --muted: oklch(0.269 0 0); --muted-foreground: oklch(0.708 0 0);
    --accent: oklch(0.269 0 0); --accent-foreground: oklch(0.985 0 0); --destructive: oklch(0.704 0.191 22.216);
    --border: oklch(1 0 0 / 10%); --input: oklch(1 0 0 / 15%); --ring: oklch(0.556 0 0); --sidebar: oklch(0.205 0 0);
    --success: oklch(76.5% 0.177 163.223); --warning: oklch(82.8% 0.189 84.429); --info: oklch(70.7% 0.165 254.624);
    --neutral: oklch(0.708 0 0); --diff-add: oklch(69.6% 0.17 162.48 / 0.12);
    --diff-add-strong: oklch(69.6% 0.17 162.48 / 0.28); --diff-remove: oklch(63.7% 0.237 25.331 / 0.12);
    --diff-remove-strong: oklch(63.7% 0.237 25.331 / 0.3); --brand: oklch(70.5% 0.19 40);
    --well: color-mix(in oklab, var(--card) 45%, var(--background));
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font: 400 16px/1.6 var(--font-sans); font-feature-settings: "cv05";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
img, video, svg { display: block; max-width: 100%; }
a { color: inherit; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
ul, ol { margin: 0; padding: 0; }
button { font: inherit; color: inherit; }
code, kbd, pre, samp, .mono { font-family: var(--font-mono); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
code { font-size: 0.86em; background: var(--muted); border-radius: var(--radius-sm); padding: 1px 5px; overflow-wrap: anywhere; }
::selection { background: color-mix(in oklab, var(--ring) 35%, transparent); }
:focus-visible { outline: 3px solid color-mix(in oklab, var(--ring) 50%, transparent); outline-offset: 2px; border-radius: var(--radius-md); }
[hidden] { display: none !important; }

.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 14px; height: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted-foreground); }
.nums { font-variant-numeric: tabular-nums; }

.wrap { width: 100%; max-width: calc(1200px + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }

.skip { position: absolute; left: 16px; top: -48px; z-index: 100; padding: 8px 12px; border-radius: var(--radius-md); background: var(--primary); color: var(--primary-foreground); text-decoration: none; font-size: 14px; font-weight: 500; }
.skip:focus { top: 12px; }

/* ---------- primitives: shadcn Button / Badge / Card, same metrics as components/ui ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border-radius: var(--radius-md); border: 1px solid transparent; font: 500 14px/1 var(--font-sans); white-space: nowrap;
  text-decoration: none; cursor: pointer; background: transparent; color: var(--foreground);
  transition: background-color .15s ease-out, color .15s ease-out, border-color .15s ease-out;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: color-mix(in oklab, var(--primary) 90%, transparent); }
.btn-outline { background: var(--background); border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-outline:hover { background: var(--accent); }
.dark .btn-outline { background: color-mix(in oklab, var(--input) 30%, transparent); border-color: var(--input); }
.dark .btn-outline:hover { background: color-mix(in oklab, var(--input) 50%, transparent); }
.btn-ghost:hover { background: var(--accent); }
.btn-sm { height: 32px; padding: 0 12px; gap: 6px; }
.btn-lg { height: 40px; padding: 0 24px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; width: fit-content; border-radius: 9999px; border: 1px solid transparent;
  padding: 2px 8px; font: 500 12px/16px var(--font-sans); white-space: nowrap;
}
.badge-outline { border-color: var(--border); color: var(--foreground); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }

.card { background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.t-fail { color: var(--destructive); }
.t-ok { color: var(--success); }
.t-warn { color: var(--warning); }
.t-info { color: var(--info); }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--foreground); }

.buddy { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; color: var(--muted-foreground); }
.buddy > .i { width: 14px; height: 14px; color: var(--brand); }
.buddy b { font-weight: 500; color: var(--foreground); }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: 50; background: var(--background); border-bottom: 1px solid transparent; transition: border-color .15s ease-out; }
.nav.scrolled, .nav.open { border-bottom-color: var(--border); }
.nav .wrap { display: flex; align-items: center; gap: 32px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; text-decoration: none; white-space: nowrap; }
.brand img { width: 26px; height: 26px; }
.nav-links { display: flex; align-items: center; gap: 4px; list-style: none; }
.nav-links a { display: block; padding: 6px 10px; border-radius: var(--radius-md); font-size: 14px; color: var(--muted-foreground); text-decoration: none; transition: color .15s ease-out; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--foreground); }
.nav-links .only-menu { display: none; }
.nav-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }
.theme-toggle .i-sun { display: none; }
.dark .theme-toggle .i-sun { display: block; }
.dark .theme-toggle .i-moon { display: none; }

/* ---------- sections ---------- */
.section { padding-block: 128px; border-top: 1px solid var(--border); }
.sec-head { max-width: 720px; margin-bottom: 64px; }
.h2 { font-size: clamp(28px, 1.6vw + 18px, 40px); line-height: 1.15; letter-spacing: -0.03em; text-wrap: balance; }
.h3 { font-size: 20px; line-height: 28px; letter-spacing: -0.015em; }
.lede { margin-top: 16px; font-size: 18px; line-height: 28px; color: var(--muted-foreground); max-width: 640px; text-wrap: pretty; }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* ---------- hero ---------- */
.hero { padding: 96px 0 0; }
.kicker { font-size: 14px; line-height: 20px; color: var(--muted-foreground); margin-bottom: 24px; }
.hero-title {
  display: grid; gap: 6px; font-size: clamp(34px, 4.2vw + 12px, 72px); line-height: 1.08; letter-spacing: -0.035em;
  font-weight: 600; text-wrap: balance;
}
/* One row per step: [time] [node] [text]. The node sits on the first line (0.23em = (line-height - node) / 2), so
   rows may wrap on small screens; the hairline runs from each node to the next node whatever the row height. */
.hl { --node: 0.62em; --node-top: 0.23em; --node-x: calc(56px + 0.32em + 0.31em);
  display: grid; grid-template-columns: 56px var(--node) 1fr; align-items: start; column-gap: 0.32em; position: relative; }
.hl time { align-self: center; font: 400 13px/1 var(--font-mono); letter-spacing: 0; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.hl .node {
  position: relative; z-index: 1; display: grid; place-items: center; width: var(--node); height: var(--node); margin-top: var(--node-top);
  border-radius: 50%; border: 1px solid var(--border); background: var(--background);
}
.hl .node .i { width: 44%; height: 44%; stroke-width: 2.25; }
.hl:not(:last-child)::after {
  content: ""; position: absolute; left: var(--node-x); top: calc(var(--node-top) + var(--node)); bottom: calc(-6px - var(--node-top));
  width: 1px; margin-left: -0.5px; background: var(--border);
}
.hl.fail .node { color: var(--destructive); background: color-mix(in oklab, var(--destructive) 8%, var(--background)); border-color: color-mix(in oklab, var(--destructive) 22%, var(--background)); }
.hl.ai .node { color: var(--brand); }
.hl.ok .node { color: var(--success); background: color-mix(in oklab, var(--success) 8%, var(--background)); border-color: color-mix(in oklab, var(--success) 22%, var(--background)); }
.hl.fail .txt, .hl.ai .txt { color: var(--muted-foreground); }
.hero-sub { margin-top: 32px; max-width: 640px; font-size: 18px; line-height: 28px; color: var(--muted-foreground); text-wrap: pretty; }
.hero-sub strong { color: var(--foreground); font-weight: 500; }
.hero .cta-row { margin-top: 32px; }
.hero-note { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 14px; line-height: 20px; color: var(--muted-foreground); }
.hero-note span { display: inline-flex; align-items: center; gap: 8px; }
.hero-shot { margin-top: 64px; }

.strip { margin-top: 64px; padding-block: 24px; border-top: 1px solid var(--border); }
.strip .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 24px; font-size: 14px; color: var(--muted-foreground); }
.strip ul { display: flex; flex-wrap: wrap; gap: 4px 20px; list-style: none; }
.strip li { color: var(--foreground); }
.strip .label { color: var(--muted-foreground); }

/* ---------- browser frame for real screenshots ---------- */
.frame { position: relative; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-sm); overflow: hidden; }
.frame-bar { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--well); }
.frame-dots { display: flex; gap: 6px; }
.frame-dots i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--border); background: var(--background); }
.frame-url {
  flex: 1; min-width: 0; max-width: 340px; height: 24px; margin-inline: auto; display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background);
  font: 400 12px/1 var(--font-mono); color: var(--muted-foreground); white-space: nowrap; overflow: hidden;
}
.frame-url .i { width: 12px; height: 12px; }
.frame-bar .spacer { width: 46px; flex: none; }
.frame-media { position: relative; aspect-ratio: 16 / 10; background: var(--background); }
.frame-media > img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }

/* Placeholder while a screenshot doesn't exist yet: a neutral skeleton of the app shell. */
.ph { display: none; position: absolute; inset: 0; grid-template-columns: 17% 1fr; background: var(--background); }
.frame.missing .frame-media > img { display: none; }
.frame.missing .ph { display: grid; }
.ph-side { display: flex; flex-direction: column; gap: 14px; padding: 18px 16px; border-right: 1px solid var(--border); background: var(--sidebar); }
.ph-side i { display: block; height: 8px; width: 72%; border-radius: 4px; background: var(--skeleton); }
.ph-side .logo { width: 48%; height: 12px; margin-bottom: 10px; }
.ph-main { display: grid; grid-template-rows: auto auto 1fr; gap: 20px; padding: 18px 24px; min-width: 0; }
.ph-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ph-top b { display: block; width: 28%; height: 12px; border-radius: 4px; background: var(--skeleton); }
.ph-top span { font: 500 10px/1 var(--font-sans); color: var(--muted-foreground); border: 1px solid var(--border); border-radius: 9999px; padding: 3px 8px; }
.ph-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ph-kpis div { height: 56px; border: 1px solid var(--border); border-radius: 8px; }
.ph-rows { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ph-rows i { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 13%; min-height: 20px; border-top: 1px solid var(--border); }
.ph-rows i:first-child { border-top: 0; }
.ph-rows i::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--c, var(--success)); }
.ph-rows i::after { content: ""; height: 7px; width: var(--w, 50%); border-radius: 4px; background: var(--skeleton); }
.ph-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; gap: 2px; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); box-shadow: var(--shadow-sm); text-align: left; min-width: 200px;
}
.ph-label b { font-size: 14px; font-weight: 600; }
.ph-label span { font-size: 12px; color: var(--muted-foreground); }

/* ---------- story: failure -> root cause -> fix -> follow-up ---------- */
.story { list-style: none; display: grid; gap: 128px; }
.story-row { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 64px; align-items: start; }
.story-copy { position: sticky; top: 104px; }
.step-tag { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 14px; color: var(--muted-foreground); }
.step-no {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border);
  font: 500 12px/1 var(--font-sans); color: var(--foreground); font-variant-numeric: tabular-nums;
}
.story-copy p { margin-top: 12px; color: var(--muted-foreground); text-wrap: pretty; }
.facts { list-style: none; display: grid; gap: 12px; margin-top: 24px; font-size: 15px; line-height: 22px; }
.facts li { display: flex; gap: 12px; }
.facts .i { margin-top: 3px; color: var(--muted-foreground); }

.stage { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--well); padding: 32px; min-width: 0; }
.stage-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-bottom: 16px; font-size: 14px; }
.stage-head .muted { font-size: 13px; }

/* RootCauseCard */
.rca { font-size: 14px; line-height: 20px; overflow: hidden; }
.rca-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 20px 24px 0; }
.rca-head .end { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.meter { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-foreground); }
.meter .bars { display: inline-flex; gap: 2px; }
.meter .bars i { width: 4px; height: 12px; border-radius: 1px; background: var(--border); }
.meter .bars i.on { background: var(--foreground); }
.meter b { font-weight: 500; color: var(--foreground); }
.rca-body { display: grid; gap: 16px; padding: 16px 24px 24px; }
.rca-sum { font-size: 16px; line-height: 24px; font-weight: 500; text-wrap: pretty; }
.cite { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-sm); background: var(--muted); color: var(--muted-foreground); font: 400 11px/1 var(--font-mono); vertical-align: 1px; font-style: normal; }
.lbl { display: block; margin-bottom: 8px; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.evidence { list-style: none; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.evidence li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 12px; padding: 10px 12px; border-top: 1px solid var(--border); }
.evidence li:first-child { border-top: 0; }
.evidence .cite { margin-top: 2px; }
.evidence code { display: block; padding: 0; background: none; font-size: 12px; line-height: 20px; color: var(--foreground); overflow-wrap: anywhere; }
.evidence small { display: block; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.rca-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 24px; border-top: 1px solid var(--border); }
.rca-foot p { font-size: 12px; line-height: 16px; color: var(--muted-foreground); flex: 1 1 220px; }
.rca-foot .cta-row { gap: 8px; }

/* DiffView */
.fix-stage { display: grid; }
.diff-card { grid-area: 1 / 1; margin-right: 72px; align-self: start; overflow: hidden; font-size: 14px; line-height: 20px; }
.diff-head { display: flex; align-items: flex-start; gap: 16px; padding: 20px 20px 0; }
.diff-head h4 { font-size: 16px; line-height: 24px; font-weight: 600; }
.diff-head .btn { margin-left: auto; }
.diff-meta { padding: 12px 20px 12px; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.plus { color: var(--success); }
.minus { color: var(--destructive); }
.diff-file { margin: 0 20px 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.diff-file:last-child { margin-bottom: 20px; }
.diff-file-head { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px; background: var(--well); font: 400 12px/1.4 var(--font-mono); }
.diff-file:not(.collapsed) .diff-file-head { border-bottom: 1px solid var(--border); }
.diff-file-head .i { width: 14px; height: 14px; color: var(--muted-foreground); }
.diff-file-head .path { min-width: 0; overflow-wrap: anywhere; }
.diff-file-head .path span { color: var(--muted-foreground); }
.diff-file-head .path b { font-weight: 500; }
.diff-file-head .count { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.diff-scroll { overflow-x: auto; }
.diff { border-collapse: collapse; width: 100%; font: 400 12px/20px var(--font-mono); }
.diff td { padding: 0; white-space: pre; vertical-align: top; }
.diff .ln { width: 1%; min-width: 32px; padding: 0 8px; text-align: right; color: var(--muted-foreground); user-select: none; font-variant-numeric: tabular-nums; }
.diff .sg { width: 1%; padding: 0 4px 0 2px; color: var(--muted-foreground); user-select: none; }
.diff .code { padding-right: 16px; }
.diff .hunk td { padding: 2px 8px; background: var(--well); color: var(--muted-foreground); }
.diff .add td { background: var(--diff-add); }
.diff .del td { background: var(--diff-remove); }
.diff .add .sg { color: var(--success); }
.diff .del .sg { color: var(--destructive); }
.diff mark { color: inherit; border-radius: 2px; }
.diff .add mark { background: var(--diff-add-strong); }
.diff .del mark { background: var(--diff-remove-strong); }

/* AlertDialog (ConfirmActionDialog) */
.dialog {
  display: grid; gap: 16px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--background); box-shadow: var(--shadow-lg); font-size: 14px; line-height: 20px; min-width: 0;
}
.dark .dialog { background: var(--card); }
.dialog h4 { font-size: 18px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; }
.dialog-desc { margin-top: 4px; color: var(--muted-foreground); }
.effects { list-style: none; display: grid; gap: 6px; }
.effects li { display: flex; gap: 8px; }
.effects .i { margin-top: 2px; color: var(--muted-foreground); }
.effects code { font-size: 12px; }
.panel { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 20px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.panel dt { color: var(--muted-foreground); }
.panel dd { margin: 0; display: grid; gap: 6px; }
.panel dd > span { display: flex; align-items: flex-start; gap: 8px; }
.panel dd .i { width: 14px; height: 14px; margin-top: 3px; }
.panel .prov { color: var(--muted-foreground); }
.audit-note { font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.fix-stage .dialog { grid-area: 1 / 1; justify-self: end; align-self: start; width: min(440px, 100%); margin-top: 318px; }

/* Timeline (FixEvent) */
.tl { padding: 24px; font-size: 14px; line-height: 20px; }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.tl-head h4 { font-size: 16px; line-height: 24px; font-weight: 600; }
.tl-head .mono { font-size: 12px; color: var(--muted-foreground); }
.tl-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.tl-status .status { font-size: 12px; }
.events { list-style: none; margin-top: 20px; display: grid; }
.events li { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 12px; padding-bottom: 18px; }
.events li:last-child { padding-bottom: 0; }
.events li:not(:last-child)::before { content: ""; position: absolute; left: 11.5px; top: 28px; bottom: 4px; width: 1px; background: var(--border); }
.events .node { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground); }
.events .node .i { width: 13px; height: 13px; }
.events .node.fail { color: var(--destructive); background: color-mix(in oklab, var(--destructive) 10%, var(--card)); border-color: transparent; }
.events .node.ok { color: var(--success); background: color-mix(in oklab, var(--success) 10%, var(--card)); border-color: transparent; }
.events .node.info { color: var(--info); background: color-mix(in oklab, var(--info) 10%, var(--card)); border-color: transparent; }
.events .node.pending { border-style: dashed; background: transparent; }
.events .what { padding-top: 2px; min-width: 0; }
.events .what b { font-weight: 500; }
.events .what small { display: block; margin-top: 2px; font-size: 14px; color: var(--muted-foreground); }
.events .what code { font-size: 12px; }
.events time { padding-top: 2px; font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Cloudflare actions ---------- */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 64px; align-items: start; }
.split .sec-head { margin-bottom: 0; }
.action-list { list-style: none; margin-top: 32px; border-top: 1px solid var(--border); }
.action-list li { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); font-size: 15px; line-height: 22px; }
.action-list .i { margin-top: 3px; color: var(--muted-foreground); }
.action-list small { display: block; font-size: 14px; color: var(--muted-foreground); }
.action-stage { display: grid; gap: 16px; }
.action-stage .dialog { max-width: 480px; }
.toast {
  display: flex; align-items: center; gap: 10px; justify-self: end; width: min(380px, 100%); padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--popover); box-shadow: var(--shadow-lg); font-size: 14px; line-height: 20px;
}
.toast .i { color: var(--success); }
.toast a { margin-left: auto; font-weight: 500; text-decoration: none; }
.toast a:hover { text-decoration: underline; }

/* ---------- product tour (vertical tabs + real screenshots) ---------- */
.tour { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 48px; align-items: start; }
.tour-tabs { display: grid; gap: 4px; }
.tour-tab {
  display: grid; gap: 4px; padding: 12px 16px; border: 1px solid transparent; border-radius: var(--radius-lg); background: none; text-align: left; cursor: pointer;
  transition: background-color .15s ease-out, border-color .15s ease-out;
}
.tour-tab:hover { background: var(--well); }
.tour-tab[aria-selected="true"] { background: var(--card); border-color: var(--border); box-shadow: var(--shadow-xs); }
.tour-tab .t { display: flex; align-items: center; gap: 10px; font-size: 15px; line-height: 22px; font-weight: 500; color: var(--muted-foreground); }
.tour-tab[aria-selected="true"] .t, .tour-tab:hover .t { color: var(--foreground); }
.tour-tab .t .i { color: var(--muted-foreground); }
.tour-tab .d { padding-left: 26px; font-size: 14px; line-height: 20px; color: var(--muted-foreground); }
.tour-tab[aria-selected="false"] .d { display: none; }
.tour-panels { min-width: 0; }
.tour-panels figcaption { display: none; }

/* ---------- security ---------- */
.fact-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 48px; list-style: none; }
.fact-grid li { padding: 24px 0 40px; border-top: 1px solid var(--border); }
.fact-grid .i { width: 20px; height: 20px; color: var(--foreground); margin-bottom: 16px; }
.fact-grid h3 { font-size: 16px; line-height: 24px; letter-spacing: -0.01em; }
.fact-grid p { margin-top: 8px; font-size: 15px; line-height: 24px; color: var(--muted-foreground); text-wrap: pretty; }
.audit { margin-top: 24px; }
.audit-cap { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 12px; }
.audit-cap h3 { font-size: 16px; line-height: 24px; }
.audit-cap span { font-size: 13px; color: var(--muted-foreground); }
.table-box { border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.table th { padding: 10px 16px; text-align: left; font-weight: 500; color: var(--muted-foreground); background: color-mix(in oklab, var(--muted) 40%, var(--card)); border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: top; }
.table tr:first-child td { border-top: 0; }
.table td small { display: block; color: var(--muted-foreground); font-size: 13px; }
.table .r { text-align: right; white-space: nowrap; }
.table .status { font-weight: 400; }

/* ---------- how it works ---------- */
.steps { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px; }
.steps li { padding-top: 24px; border-top: 1px solid var(--border); }
.steps .step-no { margin-bottom: 16px; }
.steps h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 16px; line-height: 24px; letter-spacing: -0.01em; }
.steps p { margin-top: 8px; font-size: 15px; line-height: 24px; color: var(--muted-foreground); }
.steps + .cta-row { margin-top: 56px; }

/* ---------- demo video ---------- */
.video .frame-media { aspect-ratio: 16 / 9; background: var(--well); }
.video video { width: 100%; height: 100%; object-fit: cover; background: var(--well); }
.vph { display: none; position: absolute; inset: 0; place-items: center; padding: 24px; text-align: center; }
.video.missing video { display: none; }
.video.missing .vph { display: grid; }
.vph > div { display: grid; justify-items: center; gap: 12px; max-width: 420px; }
.vph .ring { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border); background: var(--background); }
.vph .ring .i { width: 16px; height: 16px; fill: currentColor; stroke: none; margin-left: 2px; }
.vph b { font-size: 16px; font-weight: 600; }
.vph p { font-size: 14px; color: var(--muted-foreground); }
.under-video { margin-top: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; font-size: 14px; color: var(--muted-foreground); }

/* ---------- FAQ (shadcn Accordion) ---------- */
.faq-grid { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 64px; align-items: start; }
.faq-grid .sec-head { position: sticky; top: 104px; margin-bottom: 0; }
.faq-grid .lede a { color: var(--foreground); text-underline-offset: 3px; }
.faq { border-top: 1px solid var(--border); }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0; cursor: pointer; list-style: none;
  font-size: 16px; line-height: 24px; font-weight: 500;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { text-decoration: underline; text-underline-offset: 4px; }
.faq summary .i { color: var(--muted-foreground); transition: transform .2s ease-out; }
.faq details[open] summary .i { transform: rotate(180deg); }
.faq .ans { display: grid; gap: 12px; padding-bottom: 20px; font-size: 15px; line-height: 24px; color: var(--muted-foreground); max-width: 680px; }
.faq .ans a { color: var(--foreground); text-underline-offset: 3px; }
.faq .ans b { color: var(--foreground); font-weight: 500; }

/* ---------- final CTA ---------- */
.final { padding-block: 0 128px; }
.cta-panel {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 32px; padding: 48px;
  border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--well);
}
.cta-panel .lede { margin-top: 12px; }
.cta-panel .talk { margin-top: 12px; font-size: 14px; color: var(--muted-foreground); }
.cta-panel .talk a { color: var(--foreground); }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 64px 0 40px; font-size: 14px; }
.foot-grid { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 32px; }
.foot-grid > div:first-child p { margin-top: 12px; max-width: 320px; color: var(--muted-foreground); line-height: 22px; }
.footer h4 { font-size: 14px; font-weight: 500; margin-bottom: 12px; }
.footer ul { list-style: none; display: grid; gap: 8px; }
.footer ul a { color: var(--muted-foreground); text-decoration: none; }
.footer ul a:hover { color: var(--foreground); }
.legal { display: grid; gap: 8px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); font-size: 12px; line-height: 18px; color: var(--muted-foreground); }

/* ---------- docs ---------- */
.docs-hero { padding: 80px 0 56px; border-bottom: 1px solid var(--border); }
.docs-hero h1 { font-size: clamp(32px, 2vw + 20px, 48px); line-height: 1.1; letter-spacing: -0.035em; }
.docs-hero .cta-row { margin-top: 32px; }
.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 64px; padding-block: 64px 128px; }
.toc { position: sticky; top: 96px; align-self: start; font-size: 14px; }
.toc h4 { font-size: 12px; font-weight: 500; color: var(--muted-foreground); margin-bottom: 12px; }
.toc ol { list-style: none; display: grid; gap: 2px; border-left: 1px solid var(--border); }
.toc a { display: block; margin-left: -1px; padding: 4px 0 4px 14px; border-left: 1px solid transparent; color: var(--muted-foreground); text-decoration: none; line-height: 20px; }
.toc a:hover { color: var(--foreground); }
.toc a.active { color: var(--foreground); border-left-color: var(--foreground); font-weight: 500; }
.prose { max-width: 720px; font-size: 16px; line-height: 28px; }
.prose section + section { margin-top: 64px; padding-top: 64px; border-top: 1px solid var(--border); }
.prose h2 { font-size: 24px; line-height: 32px; letter-spacing: -0.02em; margin-bottom: 16px; }
.prose h3 { font-size: 17px; line-height: 26px; letter-spacing: -0.01em; margin: 32px 0 8px; }
.prose p + p, .prose p + ul, .prose p + ol, .prose ul + p, .prose ol + p, .prose ol + ul, .prose ul + ol, .prose .perm + ol, .prose .perm + p,
.prose .callout + p, .prose p + .callout, .prose .callout + h3, .prose ol + .callout, .prose ul + .callout, .prose .perm + .callout, .prose p + .perm { margin-top: 16px; }
.prose ul, .prose ol { padding-left: 22px; display: grid; gap: 6px; }
.prose li::marker { color: var(--muted-foreground); }
.prose a { text-underline-offset: 3px; }
.prose strong { font-weight: 600; }
.perm { list-style: none; padding: 0 !important; gap: 0 !important; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-top: 12px; }
.perm li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 15px; line-height: 22px; }
.perm li:first-child { border-top: 0; }
.perm li b { font-weight: 500; }
.perm li small { display: block; width: 100%; order: 3; font-size: 13px; line-height: 20px; color: var(--muted-foreground); }
.callout { display: flex; gap: 12px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); font-size: 14px; line-height: 22px; }
.callout .i { margin-top: 3px; color: var(--foreground); }
.callout.warn .i { color: var(--warning); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.two-col > div { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.two-col h4 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.two-col ul { font-size: 14px; line-height: 22px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .nav-links a { padding-inline: 8px; }
  .story-row, .split { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .story-copy { position: static; max-width: 640px; }
  .tour { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .tour-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 3px; margin: -3px; }
  .tour-tabs::-webkit-scrollbar { display: none; }
  .tour-tab { flex: none; padding: 6px 12px; border-radius: var(--radius-md); }
  .tour-tab .d { display: none !important; }
  .tour-panels figcaption { display: block; margin-top: 12px; font-size: 14px; color: var(--muted-foreground); }
  .fact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .faq-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .faq-grid .sec-head { position: static; }
}

@media (max-width: 900px) {
  .nav .wrap { gap: 16px; }
  .menu-btn { display: inline-flex; }
  .nav-links {
    display: none; position: absolute; left: 0; right: 0; top: 64px; flex-direction: column; align-items: stretch; gap: 0;
    padding: 8px var(--gutter) 16px; background: var(--background); border-bottom: 1px solid var(--border);
  }
  .nav.open .nav-links { display: flex; }
  .nav-links a { padding: 12px 0; font-size: 15px; color: var(--foreground); border-bottom: 1px solid var(--border); border-radius: 0; }
  .nav-links li:last-child a { border-bottom: 0; }
  .nav-links .only-menu { display: block; }
  .nav-demo { display: none; }
  .docs { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .toc { position: static; }
  .foot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .foot-grid > div:first-child { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
  .hl { grid-template-columns: var(--node) 1fr; --node-x: 0.31em; }
  .hl time { display: none; }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .section { padding-block: 80px; }
  .sec-head { margin-bottom: 40px; }
  .hero { padding-top: 48px; }
  .hero-sub, .lede { font-size: 17px; line-height: 26px; }
  .hero .cta-row .btn { flex: 1 1 auto; }
  .hero-shot { margin-top: 40px; }
  .frame-bar { height: 32px; padding: 0 10px; }
  .frame-dots i { width: 8px; height: 8px; }
  .frame-url { height: 20px; font-size: 11px; }
  .frame-bar .spacer { display: none; }
  .story { gap: 72px; }
  .stage { padding: 12px; }
  .stage-head { margin: 4px 4px 12px; }
  .rca-head, .rca-body { padding-inline: 16px; }
  .rca-foot { padding-inline: 16px; }
  .rca-head .end { margin-left: 0; }
  .fix-stage { display: grid; gap: 12px; }
  .diff-card, .fix-stage .dialog { grid-area: auto; margin: 0; width: auto; }
  .diff-head { padding: 16px 16px 0; flex-wrap: wrap; }
  .diff-head .btn { margin-left: 0; }
  .diff-meta { padding-inline: 16px; }
  .diff-file { margin-inline: 12px; }
  .dialog { padding: 20px; }
  .dialog-foot .btn { flex: 1 1 auto; }
  .tl { padding: 16px; }
  .events li { grid-template-columns: 24px minmax(0, 1fr); }
  .events time { grid-column: 2; padding-top: 0; margin-top: -12px; }
  .fact-grid { grid-template-columns: minmax(0, 1fr); }
  .fact-grid li { padding-bottom: 32px; }
  .table .hide-sm { display: none; }
  .table th, .table td { padding-inline: 12px; }
  .steps { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .final { padding-bottom: 80px; }
  .cta-panel { padding: 28px 20px; }
  .cta-panel .cta-row .btn { flex: 1 1 auto; }
  .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ph { grid-template-columns: 1fr; }
  .ph-side { display: none; }
  .ph-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ph-kpis div { height: 32px; }
  .ph-kpis div:nth-child(n + 3) { display: none; }
  .ph-main { padding: 12px; gap: 12px; }
  .docs-hero { padding: 48px 0 40px; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, ::before, ::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
