/* StarCompliance knowledge base — the only stylesheet, no build step.
   Color logic follows Radix Colors: 12-step scales (gray = slate, accent = indigo).
   Steps 1–2 page backgrounds, 3–5 component fills, 6–8 borders, 9–10 solid fills,
   11–12 text. Amber marks drafts / stale pages, red marks risk and conflicts, green success.
   Text pairs are chosen for WCAG AA (4.5:1) in both light and dark schemes. */

:root {
  color-scheme: light dark;

  --gray-1: #fcfcfd; --gray-2: #f9f9fb; --gray-3: #f0f0f3; --gray-4: #e8e8ec; --gray-5: #e0e1e6;
  --gray-6: #d9d9e0; --gray-7: #cdced6; --gray-8: #b9bbc6; --gray-9: #8b8d98; --gray-10: #80838d;
  --gray-11: #60646c; --gray-12: #1c2024;

  --accent-2: #f7f9ff; --accent-3: #edf2fe; --accent-4: #e1e9ff; --accent-5: #d2deff; --accent-6: #c1d0ff;
  --accent-7: #abbdf9; --accent-8: #8da4ef; --accent-9: #3e63dd; --accent-10: #3358d4; --accent-11: #3a5bc7;
  --accent-12: #1f2d5c;

  --amber-bg: #fff7c2; --amber-border: #f3d673; --amber-solid: #e2a336; --amber-text: #7a4a00;
  --red-bg: #feebec; --red-border: #fdbdbe; --red-solid: #e5484d; --red-text: #b4232a;
  --green-bg: #e6f6eb; --green-border: #adddc0; --green-solid: #30a46c; --green-text: #1a7048;
  --mark-bg: #ffe770;

  --bg: #ffffff;
  --bg-subtle: var(--gray-2);
  --surface: #ffffff;
  --border: var(--gray-6);
  --border-strong: var(--gray-7);
  --text: var(--gray-12);
  --text-muted: var(--gray-11);
  --link: var(--accent-11);
  --focus: var(--accent-9);
  --on-accent: #ffffff;
  --shadow-menu: 0 8px 24px rgb(0 0 0 / 0.1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-read: 15px; --fs-lg: 17px; --fs-xl: 22px;
  --r-1: 4px; --r-2: 6px;
  --header-h: 48px;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%238b8d98' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --gray-1: #111113; --gray-2: #18191b; --gray-3: #212225; --gray-4: #272a2d; --gray-5: #2e3135;
    --gray-6: #363a3f; --gray-7: #43484e; --gray-8: #5a6169; --gray-9: #696e77; --gray-10: #777b84;
    --gray-11: #b0b4ba; --gray-12: #edeef0;

    --accent-2: #141726; --accent-3: #182449; --accent-4: #1d2e62; --accent-5: #253974; --accent-6: #304384;
    --accent-7: #3a4f97; --accent-8: #435db1; --accent-9: #3e63dd; --accent-10: #5472e4; --accent-11: #9eb1ff;
    --accent-12: #d6e1ff;

    --amber-bg: #302008; --amber-border: #5c3d05; --amber-solid: #ffc53d; --amber-text: #ffca16;
    --red-bg: #3b1219; --red-border: #72232d; --red-solid: #e5484d; --red-text: #ff9592;
    --green-bg: #132d21; --green-border: #20573e; --green-solid: #30a46c; --green-text: #3dd68c;
    --mark-bg: #5c3d05;

    --bg: var(--gray-1);
    --bg-subtle: var(--gray-2);
    --surface: var(--gray-2);
    --focus: var(--accent-11);
    --shadow-menu: 0 8px 24px rgb(0 0 0 / 0.5);
  }
}

/* ── base ──────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: var(--fs-base)/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
img, svg { display: inline-block; vertical-align: middle; }
a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: var(--fs-xl); letter-spacing: -0.01em; }
p { margin: 0; }
code, kbd, pre { font-family: var(--mono); }
time, .num { font-variant-numeric: tabular-nums; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mono-sm { font-family: var(--mono); font-size: var(--fs-xs); overflow-wrap: anywhere; }

.icon { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-fill { fill: currentColor; }
.icon-ext { width: 12px; height: 12px; margin-left: 3px; vertical-align: -1px; opacity: 0.8; }

/* ── controls ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-2);
  background: var(--bg-subtle); color: var(--text);
  font: inherit; font-weight: 500; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--gray-3); border-color: var(--gray-8); text-decoration: none; }
.btn:active { background: var(--gray-4); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent-9); border-color: var(--accent-9); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-10); border-color: var(--accent-10); }
.btn-primary:active { background: var(--accent-10); }
.btn-danger { color: var(--red-text); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red-border); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-quiet:hover { background: var(--gray-4); border-color: transparent; color: var(--text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-xs { height: 24px; padding: 0 8px; font-size: var(--fs-xs); }
.btn-lg { height: 40px; padding: 0 16px; font-size: var(--fs-read); }
.btn-block { display: flex; width: 100%; }

input[type="text"], input[type="search"], input[type="email"], select, textarea {
  font: inherit; color: var(--text); background-color: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-2);
}
input[type="text"], input[type="search"], input[type="email"], select { height: 32px; padding: 0 10px; min-width: 0; }
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: var(--select-chevron); background-repeat: no-repeat;
  background-position: right 8px center; background-size: 14px;
}
select:disabled { cursor: not-allowed; opacity: 0.6; }
.select-sm { height: 28px; font-size: var(--fs-sm); }
textarea { display: block; padding: 8px 10px; line-height: 1.5; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--gray-10); opacity: 1; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-9); }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .issued-label { font-size: var(--fs-sm); font-weight: 600; }
.field-grow { flex: 1 1 260px; }
.field-grow input { width: 100%; }
.field-check { justify-content: flex-end; min-height: 32px; }
.field-hint { color: var(--text-muted); font-size: var(--fs-sm); }
.field-error { color: var(--red-text); font-size: var(--fs-sm); font-weight: 600; }
.has-error input, .has-error textarea { border-color: var(--red-solid); box-shadow: inset 0 0 0 1px var(--red-solid); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-base); cursor: pointer; }

/* ── badges, callouts, states ──────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: var(--r-1);
  background: var(--gray-3); color: var(--text-muted);
  font-size: var(--fs-xs); font-weight: 500; line-height: 1; white-space: nowrap; vertical-align: middle;
}
.badge-accent { background: var(--accent-3); border-color: var(--accent-6); color: var(--accent-11); }
.badge-amber { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber-text); }
.badge-red { background: var(--red-bg); border-color: var(--red-border); color: var(--red-text); }
.badge-green { background: var(--green-bg); border-color: var(--green-border); color: var(--green-text); }

.callout {
  padding: 8px 12px; border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r-1);
  background: var(--bg-subtle); color: var(--text); font-size: var(--fs-sm); line-height: 1.5;
}
.callout-title { font-weight: 600; }
.callout-info { background: var(--accent-2); border-color: var(--accent-5); border-left-color: var(--accent-9); }
.callout-warning { background: var(--amber-bg); border-color: var(--amber-border); border-left-color: var(--amber-solid); }
.callout-risk, .callout-error { background: var(--red-bg); border-color: var(--red-border); border-left-color: var(--red-solid); }
.callout-success { background: var(--green-bg); border-color: var(--green-border); border-left-color: var(--green-solid); }

.state { padding: 20px 0; color: var(--text-muted); }
.state-loading { display: flex; align-items: center; gap: 8px; }
.state-title { margin-bottom: 4px; color: var(--text); font-weight: 600; }
.state-text + .btn, .state-text + a { margin-top: 12px; }
.state-error {
  margin: 12px 0; padding: 12px 16px; color: var(--text);
  background: var(--red-bg); border: 1px solid var(--red-border); border-left: 3px solid var(--red-solid); border-radius: var(--r-1);
}
.state-empty { padding: 32px 16px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--r-2); }
.state-empty .btn { margin-top: 12px; }
.spinner {
  display: inline-block; flex: none; width: 14px; height: 14px;
  border: 2px solid var(--gray-6); border-top-color: var(--accent-9); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── shell ─────────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 12px;
  background: var(--bg); color: var(--text); border: 2px solid var(--focus); border-radius: var(--r-2);
}
.skip-link:focus { top: 8px; }

.site-header { position: sticky; top: 0; z-index: 20; background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 20px; max-width: 1280px; height: var(--header-h); margin: 0 auto; padding: 0 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; text-decoration: none; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-org { color: var(--text-muted); font-weight: 400; font-size: var(--fs-sm); }
.menu-toggle { display: none; }

.nav-panel { display: flex; flex: 1; align-items: center; gap: 16px; min-width: 0; height: 100%; }
.nav-list { display: flex; gap: 2px; height: 100%; margin: 0; padding: 0; list-style: none; }
.nav-list li { display: flex; align-items: center; }
.nav-list a {
  position: relative; display: flex; align-items: center; height: 32px; padding: 0 10px;
  border-radius: var(--r-2); color: var(--text-muted); font-weight: 500; text-decoration: none; white-space: nowrap;
}
.nav-list a:hover { background: var(--gray-4); color: var(--text); }
.nav-list a[aria-current="page"] { color: var(--text); font-weight: 600; }
.nav-list a[aria-current="page"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -9px; height: 2px;
  background: var(--accent-9); border-radius: 2px;
}

.user-area { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar { flex: none; width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: var(--gray-5); }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 10px; font-weight: 600; }
.user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.user-name { max-width: 180px; overflow: hidden; font-size: var(--fs-sm); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.user-role { color: var(--text-muted); font-size: var(--fs-xs); }

.site-main { max-width: 960px; margin: 0 auto; padding: 24px 24px 64px; }
.site-main.is-wide { max-width: 1280px; }
.site-main:focus { outline: none; }
.view h1:focus { outline: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 20px; }
.page-sub { margin-top: 4px; color: var(--text-muted); }
.page-actions { display: flex; align-items: center; gap: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-title { font-size: 16px; }
.section-count { color: var(--text-muted); font-weight: 400; }
.section-note { margin: -4px 0 8px; color: var(--text-muted); font-size: var(--fs-sm); }
.view section + section { margin-top: 32px; }
.view > .callout { margin-bottom: 16px; }

.meta-line { display: flex; flex-wrap: wrap; gap: 0 6px; color: var(--text-muted); font-size: var(--fs-sm); }
.meta-item + .meta-item::before { content: "·"; margin-right: 6px; color: var(--gray-9); text-decoration: none; }

/* ── markdown ──────────────────────────────────────────────────────────── */

.md { font-size: var(--fs-read); line-height: 1.6; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md .table-wrap { margin: 0 0 12px; }
.md h2, .md h3, .md h4, .md h5, .md h6 { margin: 22px 0 8px; }
.md h2 { font-size: 19px; }
.md h3 { font-size: 17px; }
.md h4 { font-size: 15px; }
.md h5, .md h6 { font-size: 14px; }
.md ul, .md ol { padding-left: 1.5em; }
.md li { margin: 3px 0; }
.md li > p { margin-bottom: 6px; }
.md li > ul, .md li > ol { margin: 3px 0; }
.md .md-task { list-style: none; }
.md .md-task > input { margin: 0 6px 0 -1.4em; vertical-align: -2px; }
.md code { padding: 0.1em 0.35em; background: var(--gray-3); border: 1px solid var(--gray-5); border-radius: var(--r-1); font-size: 0.875em; }
.md pre { padding: 10px 12px; overflow-x: auto; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-2); line-height: 1.45; }
.md pre code { padding: 0; background: none; border: 0; font-size: 13px; white-space: pre; }
.md blockquote { padding: 0 12px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.md hr { margin: 20px 0; border: 0; border-top: 1px solid var(--border); }
.md a { overflow-wrap: anywhere; }
.md .md-image { color: var(--text-muted); font-style: italic; }
.md table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: var(--fs-sm); line-height: 1.45; }
.md th, .md td { max-width: 420px; padding: 6px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); border-right: 1px solid var(--gray-5); }
.md th { background: var(--bg-subtle); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }
.md th:last-child, .md td:last-child { border-right: 0; }
.md .al-center { text-align: center; }
.md .al-right { text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-2); }

.cite {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 17px; margin: 0 1px; padding: 0 4px;
  border: 1px solid var(--accent-6); border-radius: var(--r-1);
  background: var(--accent-3); color: var(--accent-11);
  font: 600 11px/1 var(--font); font-variant-numeric: tabular-nums;
  text-decoration: none; vertical-align: 2px; cursor: pointer;
}
.cite:hover { background: var(--accent-4); border-color: var(--accent-8); text-decoration: none; }

/* ── ask ───────────────────────────────────────────────────────────────── */

.view-ask { display: flex; flex-direction: column; min-height: calc(100vh - var(--header-h) - 88px); }
.ask-counter { color: var(--text-muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.ask-counter.is-low { color: var(--amber-text); font-weight: 500; }
.ask-empty { padding-bottom: 24px; }
.ask-empty h2 { margin-bottom: 4px; font-size: 16px; }
.ask-empty > p { max-width: 70ch; color: var(--text-muted); }
.examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.example {
  display: block; width: 100%; height: 100%; padding: 10px 12px; text-align: left;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-2);
  font: inherit; cursor: pointer;
}
.example:hover { background: var(--accent-2); border-color: var(--accent-7); }

.conversation { display: flex; flex-direction: column; gap: 32px; }
.turn { scroll-margin-top: calc(var(--header-h) + 16px); }
.turn-q {
  margin-bottom: 12px; padding: 10px 12px;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-2);
  font-size: var(--fs-read); font-weight: 600; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}
.turn-status { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--text-muted); font-size: var(--fs-sm); }
.turn-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.turn-actions:empty { display: none; }

.answer-body { max-width: 75ch; }
.answer-body.is-streaming > :last-child::after {
  content: ""; display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: var(--accent-9); animation: caret 1s steps(2, start) infinite;
}
@keyframes caret { to { visibility: hidden; } }
.answer.is-incomplete .answer-body { padding-left: 12px; border-left: 3px solid var(--amber-solid); }
.answer-notices { display: flex; flex-direction: column; gap: 8px; max-width: 75ch; margin-top: 12px; }
.answer-notices:empty { display: none; }
.answer-sources:empty { display: none; }
.sources-block { margin-top: 16px; }
.sources-title { margin-bottom: 6px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
.sources { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.source {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 8px 6px;
  border-bottom: 1px solid var(--border); scroll-margin: calc(var(--header-h) + 16px) 0 160px;
}
.source:focus { outline: 2px solid var(--focus); outline-offset: -2px; }
.source.is-target { background: var(--accent-2); }
.source-n {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 20px; margin-top: 1px;
  background: var(--gray-3); border: 1px solid var(--border); border-radius: var(--r-1);
  color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums;
}
.source-title { font-weight: 500; }
.source-meta { display: flex; flex-wrap: wrap; gap: 0 6px; color: var(--text-muted); font-size: var(--fs-sm); }
.source-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.source .callout { margin-top: 6px; }
.sources-note { margin-top: 8px; color: var(--text-muted); font-size: var(--fs-sm); }
.answer-meta { margin-top: 8px; color: var(--text-muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.answer-meta:empty { display: none; }

.composer { position: sticky; bottom: 0; z-index: 5; margin-top: auto; padding: 12px 0 16px; background: var(--bg); }
.conversation:not(:empty) { margin-bottom: 24px; }
.conversation:not(:empty) + .composer { border-top: 1px solid var(--border); }
.composer textarea { width: 100%; min-height: 64px; max-height: 240px; resize: none; font-size: var(--fs-read); }
.composer .field-error { margin-top: 6px; }
.composer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
.composer-domain { display: flex; align-items: center; gap: 6px; }
.composer-domain label { color: var(--text-muted); font-size: var(--fs-sm); }
.composer-domain select { max-width: 220px; height: 28px; font-size: var(--fs-sm); }
.composer-hint { color: var(--text-muted); font-size: var(--fs-xs); }
.composer-actions { display: flex; gap: 8px; margin-left: auto; }

/* ── search, filters ───────────────────────────────────────────────────── */

.filter-form { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.filter-form .field-submit { justify-content: flex-end; padding-top: 24px; }
.filter-form select { max-width: 100%; }
.results-status { margin-bottom: 8px; color: var(--text-muted); font-size: var(--fs-sm); }
.results-status:empty { display: none; }
.search-results > .callout { margin-bottom: 12px; }
.results { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.result { padding: 14px 0; border-bottom: 1px solid var(--border); }
.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.result-title { font-size: var(--fs-read); font-weight: 600; }
.result-path { margin-top: 2px; color: var(--text-muted); font-family: var(--mono); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.result .meta-line { margin-top: 2px; }
.result .callout { margin-top: 8px; }
.result-snippet { margin-top: 8px; font-size: var(--fs-sm); }
.snippet-path { margin-bottom: 2px; color: var(--text-muted); font-size: var(--fs-xs); }
.snippet-text { line-height: 1.55; }
.result-links { margin-top: 6px; font-size: var(--fs-sm); }
mark { padding: 0 1px; background: var(--mark-bg); color: inherit; border-radius: 2px; }
.overview .section-title { margin-bottom: 8px; }

/* ── document ──────────────────────────────────────────────────────────── */

.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; font-size: var(--fs-sm); text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.doc-head { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.doc-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.doc-meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; margin: 12px 0 0; font-size: var(--fs-sm); }
.doc-meta dt { color: var(--text-muted); }
.doc-meta dd { margin: 0; overflow-wrap: anywhere; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.doc-content > .callout { margin-bottom: 16px; }
.doc-summary { max-width: 75ch; margin-bottom: 16px; color: var(--text-muted); font-size: var(--fs-read); }
.doc-facts { margin-bottom: 24px; }
.doc-facts .section-title { margin-bottom: 8px; }
.doc-fact-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--r-2); }
.doc-fact-list li { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr) auto; gap: 4px 12px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.doc-fact-list li:first-child { border-top: 0; }
.doc-fact-list li.is-conflict { box-shadow: inset 3px 0 0 var(--red-solid); }
.doc-fact-topic { color: var(--text-muted); }
.doc-fact-value { font-weight: 500; white-space: pre-wrap; }
.doc-fact-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.doc-body { max-width: 80ch; padding-top: 8px; }

/* ── facts ─────────────────────────────────────────────────────────────── */

.fact-domain { margin-top: 28px; }
.fact-domain > h2 { display: flex; align-items: baseline; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); font-size: var(--fs-lg); }
.fact-domain-count { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 400; }
.topic { margin-top: 16px; padding-left: 12px; border-left: 3px solid var(--border); }
.topic.is-conflict { border-left-color: var(--red-solid); }
.topic-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 8px; }
.topic-head h3 { font-size: var(--fs-base); }
.fact-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.fact { padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-2); }
.fact.is-conflict { border-color: var(--red-border); }
.fact-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 4px 12px; }
.fact-value { flex: 1 1 240px; font-size: var(--fs-read); font-weight: 600; white-space: pre-wrap; }
.fact-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.fact-quote { margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--border-strong); color: var(--text-muted); font-size: var(--fs-sm); white-space: pre-wrap; }
.fact .meta-line { margin-top: 6px; font-size: var(--fs-xs); }
.fact-notes { margin-top: 6px; font-size: var(--fs-sm); }
.fact-notes-label { color: var(--text-muted); }

/* ── history ───────────────────────────────────────────────────────────── */

.history { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.hist-item { border-bottom: 1px solid var(--border); }
.hist-heading { font-size: inherit; font-weight: inherit; }
.hist-toggle {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 2px 8px; width: 100%; padding: 10px 6px;
  background: none; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.hist-toggle:hover { background: var(--bg-subtle); }
.hist-toggle:focus-visible { outline-offset: -2px; }
.hist-chevron { margin-top: 2px; color: var(--text-muted); transition: transform 0.15s ease; }
.hist-toggle[aria-expanded="true"] .hist-chevron { transform: rotate(90deg); }
.hist-q { display: -webkit-box; overflow: hidden; font-weight: 500; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.hist-toggle[aria-expanded="true"] .hist-q { display: block; white-space: pre-wrap; }
.hist-meta { grid-column: 2; color: var(--text-muted); font-size: var(--fs-xs); }
.hist-panel { padding: 4px 6px 16px 30px; }
.more-row { display: flex; justify-content: center; margin-top: 16px; }

/* ── connect ───────────────────────────────────────────────────────────── */

.explain { max-width: 75ch; }
.explain .section-title { margin-bottom: 8px; }
.explain p + ul, .explain ul + p { margin-top: 8px; }
.explain ul { margin: 8px 0 0; padding-left: 1.25em; }
.explain li { margin: 2px 0; }
.explain code, .issued code { padding: 0.1em 0.35em; background: var(--gray-3); border: 1px solid var(--gray-5); border-radius: var(--r-1); font-size: 0.9em; overflow-wrap: anywhere; }
.token-new .section-title, .token-list .section-title { margin-bottom: 8px; }
.token-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; max-width: 720px; }
.token-form .field-submit { justify-content: flex-end; }
.issued {
  display: flex; flex-direction: column; gap: 12px; max-width: 820px; margin-top: 16px; padding: 16px;
  background: var(--accent-2); border: 1px solid var(--accent-6); border-left: 3px solid var(--accent-9); border-radius: var(--r-2);
}
.issued h3 { font-size: var(--fs-read); }
.issued h3:focus { outline: none; }
.issued .btn { align-self: flex-start; }
.issued-field { display: flex; flex-direction: column; gap: 4px; }
.secret-row { display: flex; align-items: flex-start; gap: 8px; }
.secret-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; }
.cmd {
  flex: 1; min-width: 0; margin: 0; padding: 7px 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-2);
  font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-all;
}

/* ── data tables (admin, tokens, overview) ─────────────────────────────── */

.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 7px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { background: var(--bg-subtle); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; }
.data-table .num { text-align: right; }
.data-table tbody tr:hover { background: var(--bg-subtle); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tr.is-muted td { color: var(--text-muted); }
.cell-wrap { min-width: 180px; max-width: 360px; white-space: normal !important; }
.cell-query { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.cell-hint { margin-top: 2px; color: var(--text-muted); font-size: var(--fs-xs); }
.cell-actions { text-align: right !important; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; background: none; border: 0;
  color: inherit; font: inherit; text-align: inherit; white-space: nowrap; cursor: pointer;
}
.sort-btn:hover { color: var(--text); }
th.num .sort-btn { flex-direction: row-reverse; }
.sort-icon { width: 12px; height: 12px; opacity: 0.35; }
.sort-icon.is-active { opacity: 1; color: var(--accent-11); }
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-cell-name { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.user-cell-name.is-placeholder { color: var(--text-muted); font-weight: 400; font-style: italic; }
.user-cell-email { color: var(--text-muted); font-size: var(--fs-xs); }
.access-cell { display: flex; align-items: center; gap: 8px; }
.admin-msg:not(:empty) { margin-bottom: 8px; }

/* ── sign-in ───────────────────────────────────────────────────────────── */

.signin-page { min-height: 100vh; background: var(--bg-subtle); }
.signin { width: 100%; max-width: 440px; margin: 0 auto; padding: 12vh 16px 32px; }
.signin-panel { padding: 28px 24px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-2); }
.signin-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--text-muted); font-weight: 600; }
.signin h1 { margin-bottom: 4px; font-size: 24px; }
.signin-lede { margin-bottom: 20px; color: var(--text-muted); }
.signin-error { margin-bottom: 16px; }
.signin-lark .state { padding: 8px 0; }
.signin-lark .field-hint { margin-bottom: 8px; }
.signin-dev { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--border-strong); }
.signin-dev h2 { margin-bottom: 4px; font-size: var(--fs-base); }
.dev-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.dev-form input, .dev-form select { width: 100%; }
.dev-form .callout:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.signin-foot { margin-top: 16px; color: var(--text-muted); font-size: var(--fs-xs); text-align: center; }

/* ── responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1023px) {
  .brand-org { display: none; }
  .user-name { max-width: 120px; }
}

@media (max-width: 899px) {
  .header-inner { position: relative; gap: 12px; }
  .menu-toggle { display: inline-flex; margin-left: auto; }
  .nav-panel {
    display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0; height: auto; padding: 8px 12px 12px;
    background: var(--bg-subtle); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-menu);
  }
  .nav-panel.is-open { display: flex; }
  .nav-list { flex-direction: column; height: auto; }
  .nav-list a { height: 40px; }
  .nav-list a[aria-current="page"] { background: var(--gray-4); }
  .nav-list a[aria-current="page"]::after { top: 10px; bottom: 10px; left: 0; right: auto; width: 3px; height: auto; }
  .user-area { justify-content: space-between; margin: 8px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
  .user-name { max-width: 200px; }
}

@media (max-width: 640px) {
  .site-main { padding: 16px 16px 48px; }
  h1 { font-size: 20px; }
  .page-head { align-items: flex-start; margin-bottom: 16px; }
  .view-ask { min-height: calc(100vh - var(--header-h) - 64px); }
  .composer-domain { flex: 1 1 100%; }
  .composer-domain select { flex: 1; max-width: none; }
  .composer-actions { flex: 1; }
  .composer-actions .btn { flex: 1; }
  .filter-form .field { flex: 1 1 100%; }
  .filter-form .field-submit { padding-top: 0; }
  .filter-form .field-submit .btn { width: 100%; }
  .filter-form select, .token-form input { width: 100%; }
  .token-form .field-submit .btn { width: 100%; }
  .token-form .field-submit { flex: 1 1 100%; }
  .secret-row { flex-direction: column; align-items: stretch; }
  .secret-row .btn { align-self: flex-start; }
  .doc-meta { grid-template-columns: 1fr; gap: 0; }
  .doc-meta dd { margin-bottom: 6px; }
  .doc-fact-list li { grid-template-columns: 1fr; }
  .hist-panel { padding-left: 6px; }
  .examples { grid-template-columns: 1fr; }
  .signin { padding-top: 6vh; }
  .signin-panel { padding: 20px 16px; }
}

@media (pointer: coarse) {
  .composer-hint { display: none; }
  .btn-xs { height: 32px; padding: 0 10px; }
  .btn-sm { height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .badge, .cite, .callout, .btn { border-color: CanvasText; }
  .nav-list a[aria-current="page"]::after { background: Highlight; }
}
