/* AI Query Labs. One stylesheet: tokens, named type styles, components, page layout.
   Tokens and type styles are copied from the design system (tokens.json / tokens.css). */

@font-face {
  font-family: "Geist";
  src: url("../fonts/geist-variable.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/geist-mono-variable.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens (light) ---------- */
:root {
  color-scheme: light;
  --sidebar: #e9e9e9;
  --background: #f5f5f5;
  --card: #ffffff;
  --popover: #ffffff;
  --muted: #ececec;
  --secondary: #e2e2e2;
  --accent: #d6d6d6;
  --foreground: #0a0a0a;
  --card-foreground: #0a0a0a;
  --secondary-foreground: #0a0a0a;
  --accent-foreground: #0a0a0a;
  --sidebar-foreground: #0a0a0a;
  --muted-foreground: #474747;
  --subtle-foreground: #686868;
  --primary: #141414;
  --primary-foreground: #ffffff;
  --border: #0000001a;
  --input: #909090;
  --divider: #cdcdcd;
  --ring: #0b6fe0;
  --destructive: #b91c1c;
  --success: #0b8a4f;
  --warning: #a16207;
  --shadow-float: 0 12px 32px #00000024;

  --space-inline: 6px;
  --space-cell-y: 8px;
  --space-cell-x: 12px;
  --space-panel: 16px;
  --space-gutter: 20px;
  --space-tab-gap: 24px;
  --space-section: 28px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-3xl: 24px;
  --radius-full: 9999px;
  --size-app-bar: 44px;
  --size-button-lg: 32px;
  --size-control: 30px;
  --size-button: 28px;
  --size-button-sm: 24px;
  --size-checkbox: 16px;
  --size-icon: 14px;
  --size-status-dot: 7px;
  --size-reply: 62ch;
  --font-sans: Geist, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, monospace;

  /* Page measure for a marketing site (not in the app spec). */
  --size-page: 1040px;
}

/* ---------- Tokens (dark), following the visitor's system theme ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --sidebar: #161616;
    --background: #1f1f1f;
    --card: #2a2a2a;
    --popover: #333333;
    --muted: #141414;
    --secondary: #3b3b3b;
    --accent: #3d3d3d;
    --foreground: #f2f2f2;
    --card-foreground: #f2f2f2;
    --secondary-foreground: #f2f2f2;
    --accent-foreground: #f2f2f2;
    --sidebar-foreground: #f2f2f2;
    --muted-foreground: #bdbdbd;
    --subtle-foreground: #9a9a9a;
    --primary: #e8e8e8;
    --primary-foreground: #141414;
    --border: #ffffff1a;
    --input: #747474;
    --divider: #0b0b0b;
    --ring: #1084fe;
    --destructive: #ff6b6b;
    --success: #00c972;
    --warning: #ffd400;
    --shadow-float: 0 12px 32px #00000073;
  }
}

/* ---------- Named type styles ---------- */
.type-display { font: 600 3.5rem/0.95 var(--font-mono); letter-spacing: -0.035em; }
.type-hero { font: 600 1.75rem/1.05 var(--font-mono); letter-spacing: -0.035em; }
.type-quote-title { font: 600 1.25rem/1.2 var(--font-mono); letter-spacing: -0.02em; }
.type-section { font: 600 0.9375rem/1.2 var(--font-sans); letter-spacing: -0.01em; }
.type-value { font: 500 0.875rem/1.3 var(--font-sans); }
.type-tab { font: 500 0.8125rem/1 var(--font-sans); }
.type-group { font: 600 0.78125rem/1rem var(--font-sans); }
.type-field-label { font: 400 0.75rem/1rem var(--font-sans); color: var(--muted-foreground); }
.type-helper { font: 400 0.75rem/1rem var(--font-sans); color: var(--subtle-foreground); }
.type-data-label { font: 500 0.625rem/1 var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--subtle-foreground); }
.type-data { font: 400 0.8125rem/1.25rem var(--font-mono); font-variant-numeric: tabular-nums; }
.type-data-sm { font: 400 0.71875rem/1rem var(--font-mono); font-variant-numeric: tabular-nums; }
.text-sm { font: 400 0.8125rem/1.25rem var(--font-sans); }
.text-2sm { font: 400 0.78125rem/1.125rem var(--font-sans); }
.text-xs { font: 400 0.75rem/1rem var(--font-sans); }
.text-muted { color: var(--muted-foreground); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--size-app-bar); }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 400 0.8125rem/1.25rem var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
img, svg { display: block; max-width: 100%; }
strong, b, summary { font-weight: 600; }
em, i, cite { font-style: normal; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--input); }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 50%, transparent); border-radius: var(--radius-sm); }
code {
  font: 400 0.71875rem/1rem var(--font-mono);
  background: var(--muted); border-radius: var(--radius-sm); padding: 1px 4px;
}
.skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--popover); color: var(--foreground); box-shadow: var(--shadow-float);
  padding: var(--space-cell-y) var(--space-cell-x); border-radius: var(--radius-lg);
}
.skip:focus { left: var(--space-panel); top: var(--space-panel); }
.wrap { width: min(var(--size-page), calc(100% - 2 * var(--space-gutter))); margin-inline: auto; }
.stack { display: flex; flex-direction: column; gap: var(--space-panel); }
.prose { display: flex; flex-direction: column; gap: var(--space-cell-x); max-width: var(--size-reply); }
.prose ul, .prose ol { display: flex; flex-direction: column; gap: var(--space-inline); padding-left: var(--space-gutter); }

/* Visually hidden, still read by screen readers */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Icons (lucide, stroked in currentColor) ---------- */
svg.i { width: var(--size-icon); height: var(--size-icon); flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.md { width: var(--size-checkbox); height: var(--size-checkbox); }

/* ---------- Brand: flask mark + type wordmark ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--foreground); text-decoration: none; }
.brand-mark { width: 18px; height: 18px; flex: none; }
.wordmark { font: 600 0.75rem/1 var(--font-sans); letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.wordmark span { color: var(--subtle-foreground); }

/* ---------- Button ---------- */
.btn {
  display: inline-flex; flex: none; align-items: center; justify-content: center; gap: var(--space-inline);
  height: var(--size-button); padding: 0 14px; border: 0; border-radius: var(--radius-full);
  background: var(--secondary); color: var(--secondary-foreground);
  font: 500 0.78125rem/1.125rem var(--font-sans); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.btn:hover { background: var(--accent); }
.btn:focus-visible { border-radius: var(--radius-full); }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 85%, transparent); }
.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--accent); color: var(--foreground); }
.btn-outline { background: transparent; color: var(--foreground); box-shadow: inset 0 0 0 1px var(--input); }
.btn-outline:hover { background: var(--accent); }
.btn-outline:focus-visible { box-shadow: inset 0 0 0 1px var(--input), 0 0 0 2px color-mix(in srgb, var(--ring) 50%, transparent); }
.btn-sm { height: var(--size-button-sm); padding: 0 10px; font-size: 0.75rem; line-height: 1rem; }
.btn-lg { height: var(--size-button-lg); padding: 0 16px; font-size: 0.8125rem; line-height: 1.25rem; }
.btn-icon { width: var(--size-button); padding: 0; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .45; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: var(--radius-full);
  background: var(--secondary); color: var(--muted-foreground);
  font: 500 0.6875rem/1 var(--font-sans); white-space: nowrap;
}
.badge-default { background: var(--primary); color: var(--primary-foreground); }
.badges, .prose .badges { display: flex; flex-direction: row; flex-wrap: wrap; gap: var(--space-inline); padding: 0; list-style: none; }

/* ---------- Status dot ---------- */
.status { display: inline-flex; align-items: center; gap: var(--space-inline); white-space: nowrap; }
.dot { display: inline-block; flex: none; width: var(--size-status-dot); height: var(--size-status-dot); border-radius: var(--radius-full); background: var(--subtle-foreground); }
.dot-success { background: var(--success); }
.dot-warning { background: var(--warning); }
.dot-destructive { background: var(--destructive); }

/* ---------- App bar ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--sidebar); color: var(--sidebar-foreground);
  border-bottom: 1px solid var(--divider);
}
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: var(--size-app-bar); }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-toggle { display: none; margin-left: auto; }

/* ---------- Sections ---------- */
main section { padding: calc(var(--space-section) * 2) 0; border-top: 1px solid var(--divider); }
main section:first-child { border-top: 0; }
.section-head { display: flex; flex-direction: column; gap: var(--space-cell-x); max-width: var(--size-reply); }
.section-body { display: flex; flex-direction: column; gap: var(--space-section); }
.lede { color: var(--muted-foreground); max-width: var(--size-reply); }
.split { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: calc(var(--space-section) * 2); align-items: start; }

/* ---------- Hero ---------- */
.hero { padding: calc(var(--space-section) * 3) 0 calc(var(--space-section) * 2.5); }
.hero-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: calc(var(--space-section) * 2); align-items: center; }
.hero-copy { display: flex; flex-direction: column; gap: var(--space-gutter); }
.hero-copy .lede { font: 500 0.875rem/1.3 var(--font-sans); }

/* Fan-out example, built from the Message component */
.chat {
  display: flex; flex-direction: column; gap: 12px; padding: var(--space-panel);
  background: var(--sidebar); color: var(--sidebar-foreground); border-radius: var(--radius-lg);
}
.bubble { padding: var(--space-cell-y) var(--space-cell-x); border-radius: var(--radius-xl); overflow-wrap: break-word; }
.bubble-user { align-self: flex-end; max-width: 83.333%; background: var(--accent); color: var(--accent-foreground); border-bottom-right-radius: var(--radius-sm); }
.bubble-assistant { align-self: flex-start; width: 100%; max-width: var(--size-reply); background: var(--card); color: var(--card-foreground); border-bottom-left-radius: var(--radius-sm); display: flex; flex-direction: column; gap: var(--space-inline); }
.fanout-list { display: flex; flex-direction: column; padding: 0; list-style: none; }
.fanout-list li { padding: 6px 0; border-top: 1px solid var(--border); }
.fanout-list li:first-child { border-top: 0; }

/* ---------- How it works ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-gutter); }
.step { display: flex; flex-direction: column; gap: var(--space-cell-y); padding: var(--space-panel); background: var(--card); border-radius: var(--radius-lg); }
.step p { color: var(--muted-foreground); }

/* ---------- Pricing ---------- */
.plans { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: var(--space-gutter); align-items: start; }
.plan { display: flex; flex-direction: column; gap: var(--space-panel); padding: calc(var(--space-panel) * 1.5); background: var(--card); border-radius: var(--radius-lg); }
.plan-top { display: flex; flex-direction: column; gap: var(--space-cell-y); align-items: flex-start; }
.price { display: flex; align-items: baseline; gap: var(--space-inline); }
.includes { display: flex; flex-direction: column; padding: 0; list-style: none; }
.includes li { padding: var(--space-cell-y) 0; border-top: 1px solid var(--border); }
.includes li:last-child { border-bottom: 1px solid var(--border); }

/* ---------- Sample audit card ---------- */
.audit { display: grid; grid-template-columns: 220px 1fr; gap: var(--space-section); padding: calc(var(--space-panel) * 1.5); background: var(--card); border-radius: var(--radius-lg); }
.score { display: flex; flex-direction: column; gap: var(--space-cell-y); }
.score-value { display: flex; align-items: baseline; gap: var(--space-inline); }
.findings { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-gutter) var(--space-tab-gap); }
.finding { display: flex; flex-direction: column; gap: 4px; }
.finding p { color: var(--muted-foreground); }

/* ---------- Table ---------- */
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 8px 12px 10px; text-align: left; vertical-align: bottom; white-space: nowrap; border-bottom: 1px solid var(--divider); }
td { padding: var(--space-cell-y) var(--space-cell-x); vertical-align: top; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--card); }
th:first-child, td:first-child { padding-left: 0; }
th.num, td.num { text-align: right; white-space: nowrap; }
td.meter-cell { width: 30%; vertical-align: middle; }
.meter { display: block; height: 4px; background: var(--muted); border-radius: var(--radius-full); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--foreground); border-radius: inherit; }
.w-0 { width: 0; } .w-16 { width: 16%; } .w-80 { width: 80%; } .w-100 { width: 100%; }

/* ---------- Labelled facts ---------- */
.facts { display: flex; flex-wrap: wrap; gap: var(--space-panel) var(--space-tab-gap); }
.facts div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.facts dt, .facts dd { margin: 0; }

/* ---------- Notes (open items) ---------- */
.notes { display: flex; flex-direction: column; gap: var(--space-inline); padding: 12px var(--space-panel); list-style: none; background: var(--card); border-radius: var(--radius-lg); }
.notes li { display: flex; align-items: baseline; gap: 8px; }
.notes .dot { transform: translateY(-1px); }

/* ---------- FAQ ---------- */
.faq-list { display: flex; flex-direction: column; max-width: 46rem; }
details { border-top: 1px solid var(--border); }
details:last-child { border-bottom: 1px solid var(--border); }
summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-panel); padding: 12px 0; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary .i { color: var(--muted-foreground); transition: transform .1s; }
details[open] summary .i { transform: rotate(180deg); }
details > p { padding: 0 0 var(--space-panel); color: var(--muted-foreground); max-width: var(--size-reply); }

/* ---------- Form (Input component) ---------- */
.form { display: flex; flex-direction: column; gap: var(--space-panel); padding: calc(var(--space-panel) * 1.5); background: var(--card); border-radius: var(--radius-lg); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-panel); }
.control {
  width: 100%; min-width: 0; height: var(--size-control); padding: 0 8px;
  border: 1px solid var(--input); border-radius: var(--radius-md);
  background: var(--muted); color: var(--foreground);
  font: 400 0.8125rem/1.25rem var(--font-sans); outline: none; transition: border-color .15s;
}
textarea.control { height: auto; min-height: 88px; padding: 5px 8px; resize: vertical; }
select.control { appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23686868' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; }
.control::placeholder { color: var(--subtle-foreground); }
.control:hover { border-color: var(--muted-foreground); }
.control:focus-visible { border-color: var(--ring); border-radius: var(--radius-md); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 35%, transparent); }
.control[aria-invalid="true"] { border-color: var(--destructive); box-shadow: 0 0 0 2px color-mix(in srgb, var(--destructive) 30%, transparent); }
.form-actions { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-cell-y); }
.form-status { min-height: 1rem; }

/* ---------- Footer ---------- */
.site-footer { background: var(--sidebar); color: var(--sidebar-foreground); border-top: 1px solid var(--divider); padding: var(--space-section) 0; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-gutter) var(--space-section); }
.footer-col { display: flex; flex-direction: column; gap: var(--space-cell-y); max-width: 40ch; }
.footer-col p { color: var(--muted-foreground); }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 12px; }

/* ---------- Inner page ---------- */
.page-hero { display: flex; flex-direction: column; gap: var(--space-panel); padding: calc(var(--space-section) * 2) 0 var(--space-section); }
.report { display: flex; flex-direction: column; gap: var(--space-section); padding-bottom: calc(var(--space-section) * 3); }
.report > section, .report-block { display: flex; flex-direction: column; gap: var(--space-cell-x); padding: 0; border: 0; }
.report .table-scroll { max-width: none; }

/* ---------- 404 ---------- */
.notfound { min-height: calc(100vh - var(--size-app-bar) * 4); display: grid; place-items: center; padding: calc(var(--space-section) * 3) var(--space-gutter); }
.notfound .stack { align-items: center; text-align: center; }

/* ---------- Open Graph render (og.html, 1200 × 630) ---------- */
.og-page { width: 1200px; height: 630px; overflow: hidden; }
.og { position: relative; width: 1200px; height: 630px; background: var(--background); color: var(--foreground); }
.og-art { position: absolute; inset: 0; }
.og-words { position: absolute; left: 72px; top: 72px; bottom: 72px; width: 600px; display: flex; flex-direction: column; justify-content: space-between; }
.og .wordmark { font-size: 1.375rem; }
.og .brand-mark { width: 40px; height: 40px; }
.og .brand { gap: 16px; }
.og-title { font: 600 6rem/0.95 var(--font-mono); letter-spacing: -0.035em; }
.og-url { font: 400 1.5rem/1 var(--font-mono); color: var(--muted-foreground); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .control, summary .i { transition: none; }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 860px) {
  .hero-grid, .split, .steps, .plans, .audit, .findings, .form-row { grid-template-columns: 1fr; }
  .hero { padding: calc(var(--space-section) * 2) 0; }
  .type-display { font-size: 2.5rem; }
  .split { gap: var(--space-gutter); }
}
@media (max-width: 640px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none; position: absolute; top: var(--size-app-bar); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    padding: var(--space-cell-y) var(--space-gutter) var(--space-panel);
    background: var(--popover); box-shadow: var(--shadow-float);
  }
  .nav.open { display: flex; }
  .nav .btn { justify-content: flex-start; }
}
