/* Cortex AI — one small design system: tokens, then components, then views. */
/* Tokens come from Scalar's theme (vendor/scalar-theme.css, .light-mode / .dark-mode on <html>),
   so this UI and the embedded API reference are one design. Fallbacks = Scalar's light theme. */
:root {
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23707070' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.75'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E");
  --bg: var(--scalar-background-2, #f6f6f6);
  --panel: var(--scalar-background-1, #fff);
  --panel-2: var(--scalar-background-2, #f6f6f6);
  --panel-3: var(--scalar-background-3, #e7e7e7);
  --text: var(--scalar-color-1, #1b1b1b);
  --muted: var(--scalar-color-2, #707070);
  --faint: var(--scalar-color-3, #8e8e8e);
  --line: var(--scalar-border-color, #dfdfdf);
  --line-strong: color-mix(in srgb, var(--line) 70%, var(--faint));
  --accent: var(--scalar-color-accent, #0099ff);
  --accent-ink: #fff;
  --accent-soft: var(--scalar-background-accent, #8ab4f81f);
  --primary: var(--scalar-button-1, #000);
  --primary-ink: var(--scalar-button-1-color, #fff);
  --primary-hover: var(--scalar-button-1-hover, rgb(0 0 0 / 0.8));
  --ok: var(--scalar-color-green, #069061);
  --ok-soft: color-mix(in srgb, var(--ok) 12%, transparent);
  --warn: var(--scalar-color-orange, #ff5800);
  --warn-soft: color-mix(in srgb, var(--warn) 12%, transparent);
  --bad: var(--scalar-color-red, #ef0006);
  --bad-soft: color-mix(in srgb, var(--bad) 10%, transparent);
  --blue: var(--scalar-color-blue, #0072bd);
  --purple: var(--scalar-color-purple, #5203d1);
  --real: var(--scalar-color-red, #ef0006);
  --real-soft: color-mix(in srgb, var(--real) 10%, transparent);
  --dummy: var(--scalar-color-green, #069061);
  --dummy-soft: color-mix(in srgb, var(--dummy) 12%, transparent);
  --fake: var(--purple, #7c3aed);
  --fake-soft: color-mix(in srgb, var(--fake) 12%, transparent);
  --code-bg: var(--scalar-background-2, #f6f6f6);
  --j-key: var(--scalar-color-purple, #5203d1);
  --j-str: var(--scalar-color-green, #069061);
  --j-num: var(--scalar-color-orange, #ff5800);
  --j-lit: var(--scalar-color-blue, #0072bd);
  --shadow: none;
  --shadow-lg: 0 20px 50px rgb(0 0 0 / 0.18);
  --radius: 10px;
  --radius-sm: 6px;
  font: 14px/1.5 var(--scalar-font, ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif);
  color-scheme: light;
}
.dark-mode {
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23a3a3a3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
}
.dark-mode { color-scheme: dark; --shadow-lg: 0 20px 50px rgb(0 0 0 / 0.6); --accent-ink: #000; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
code, pre, .mono { font-family: var(--scalar-font-code, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace); font-size: 12.5px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
h3 { font-size: 14px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }

/* ── buttons ─────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn .icon { width: 16px; height: 16px; flex: none; }
.btn.sm .icon { width: 14px; height: 14px; }
/* the sidebar's "New question": quiet, left-aligned, icon first */
.new-btn { justify-content: flex-start; gap: 9px; height: 36px; padding: 0 12px; font-weight: 500; }
.new-btn .icon { color: var(--muted); }
.new-btn:hover .icon { color: var(--text); }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid transparent; background: none; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── inputs ──────────────────────────────────────────────────────────── */
.input { width: 100%; height: 34px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); padding: 0 11px; }
textarea.input { height: auto; padding: 8px 11px; }
/* one dropdown for the whole app: our own chevron, inset like the search icon, instead of each browser's arrow */
select.input {
  appearance: none; -webkit-appearance: none;
  padding-right: 32px; cursor: pointer; text-overflow: ellipsis;
  background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 11px center; background-size: 12px 12px;
}
select.input:hover:not(:focus) { border-color: var(--faint); }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.45; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.search { position: relative; }
.search .input { padding-left: 32px; height: 34px; }
.search::before {
  content: ''; position: absolute; left: 11px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  background: var(--faint); pointer-events: none;
  -webkit-mask: var(--icon-search) center / contain no-repeat; mask: var(--icon-search) center / contain no-repeat;
}
.search:focus-within::before { background: var(--muted); }
.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }

/* ── segmented control ───────────────────────────────────────────────── */
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-2); }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button[aria-pressed='true'] { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.seg.full { display: flex; }
.seg.full button { flex: 1; }
.seg .n { color: var(--faint); font-weight: 400; margin-left: 3px; }

/* ── pills & badges ──────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--code-bg); color: var(--muted); white-space: nowrap; }
.pill.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.run { background: var(--accent-soft); color: var(--accent); }
.pill.run::before { animation: pulse 1.2s ease-in-out infinite; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.real { background: var(--real-soft); color: var(--real); }
.pill.dummy { background: var(--dummy-soft); color: var(--dummy); }
.pill.masked { background: color-mix(in srgb, var(--purple) 12%, transparent); color: var(--purple); }
.lock { max-width: 520px; margin: 12vh auto 0; text-align: center; display: grid; gap: 10px; justify-items: center; padding: 32px; }
.lock-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); color: var(--muted); }
.lock-icon .icon { width: 20px; height: 20px; }
.lock .row { justify-content: center; margin-top: 6px; }
@keyframes pulse { 50% { opacity: 0.25; } }
.method { display: inline-block; min-width: 42px; text-align: center; font: 700 11px/20px var(--scalar-font-code, ui-monospace, Menlo, monospace); border-radius: 5px; padding: 0 6px; background: color-mix(in srgb, var(--blue) 12%, transparent); color: var(--blue); }
.method.POST { background: var(--ok-soft); color: var(--ok); }
.method.DELETE { background: var(--bad-soft); color: var(--bad); }

/* ── cards ───────────────────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-body { padding: 18px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.section { margin-top: 20px; }
.section > .label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.empty { text-align: center; color: var(--muted); padding: 48px 18px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.error { color: var(--bad); background: var(--bad-soft); padding: 10px 12px; border-radius: var(--radius-sm); overflow-wrap: anywhere; white-space: pre-wrap; }
.notice { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }

/* ── header ──────────────────────────────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px; height: 56px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.brand span { color: var(--accent); }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 7px 13px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected='true'] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.top-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.data-switch { display: flex; align-items: center; gap: 8px; }
.data-switch > span { font-size: 12px; color: var(--muted); }
.data-switch .seg button[data-env='real'][aria-pressed='true'] { color: var(--real); }
.data-switch .seg button[data-env='dummy'][aria-pressed='true'] { color: var(--dummy); }
.real-banner { background: var(--real); color: #fff; text-align: center; font-size: 12.5px; font-weight: 600; padding: 5px 12px; letter-spacing: 0.01em; }
@media (max-width: 760px) {
  .top { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .top-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .data-switch > span { display: none; }
}

/* ── layout ──────────────────────────────────────────────────────────── */
main { padding: 20px; max-width: 1480px; margin: 0 auto; }
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.side { position: sticky; top: 76px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; overflow: hidden; }
.side-top { padding: 14px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.side-list { overflow-y: auto; flex: 1; }
.pane { display: grid; gap: 18px; min-width: 0; }
@media (max-width: 900px) {
  main { padding: 14px; }
  .split { grid-template-columns: 1fr; }
  .side { position: static; max-height: 320px; }
}

/* ── lists ───────────────────────────────────────────────────────────── */
.list { list-style: none; margin: 0; padding: 0; }
/* text carries ~5px of invisible space above its capitals; the pill below is solid. Padding evens out what the eye sees: ~14px above, ~11px between, ~13px below */
.list li.item { padding: 9px 14px 13px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 6px; }
.list li.item:hover { background: var(--panel-2); }
.list li.item.sel { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--text); }
.list li.group { padding: 12px 14px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.list .title { font-weight: 500; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list .meta .pill { height: 20px; padding: 0 8px; }
.list .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); min-width: 0; }
.list .path { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .none { padding: 16px 14px; color: var(--muted); font-size: 13px; }

/* ── composer (Ask) ──────────────────────────────────────────────────── */
.composer { padding: 16px; display: grid; gap: 12px; }
.composer textarea { border: 0; padding: 2px; min-height: 56px; resize: none; background: none; font-size: 15px; outline: none; }
.composer-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; }
.mode-help { font-size: 12.5px; color: var(--muted); }
.kbd { font-size: 11px; color: var(--faint); border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--text); text-align: left; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ── answer ──────────────────────────────────────────────────────────── */
.q-title { font-size: 19px; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; }
.meta-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.md { font-size: 14.5px; line-height: 1.6; }
.md h2, .md h3, .md h4, .md h5 { margin: 14px 0 6px; font-size: 15px; }
.md ul, .md ol { padding-left: 22px; margin: 6px 0; }
.md table { border-collapse: collapse; margin: 10px 0; font-size: 13px; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--panel-2); font-weight: 600; }
.md code { background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 6px 0; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sources { display: flex; flex-wrap: wrap; gap: 6px; }
.sources span { background: var(--code-bg); border-radius: 6px; padding: 2px 8px; font-size: 12px; color: var(--muted); }

/* ── code & json ─────────────────────────────────────────────────────── */
.code { position: relative; }
.code pre { margin: 0; background: var(--code-bg); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; max-height: 460px; line-height: 1.5; }
.code .copy { position: absolute; top: 6px; right: 6px; }
.j-key { color: var(--j-key); }
.j-str { color: var(--j-str); }
.j-num { color: var(--j-num); }
.j-lit { color: var(--j-lit); }
details.fold > summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.fold > summary::before { content: '▸'; transition: transform 0.15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > :not(summary) { margin-top: 8px; }

/* ── trace timeline ──────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.step { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; padding: 7px 0; }
.step .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent); border: 2px solid var(--panel); z-index: 1; }
.step.err .dot { background: var(--bad-soft); color: var(--bad); }
.step.note .dot { background: var(--code-bg); color: var(--muted); }
.step.stage .dot { background: var(--ok-soft); color: var(--ok); }
.step .what { font-weight: 600; }
.step .args { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.step .sum { font-size: 13px; overflow-wrap: anywhere; }
.step.err .sum { color: var(--bad); }
.step.note .sum { color: var(--muted); font-style: italic; }
.step .ms { color: var(--faint); font-size: 12px; white-space: nowrap; padding-top: 3px; }
.shots { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.shots button { padding: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; cursor: zoom-in; background: var(--code-bg); width: 168px; height: 105px; }
.shots img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }

/* ── APIs ────────────────────────────────────────────────────────────── */
.endpoint-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.endpoint-line code { font-size: 13.5px; }
.params { width: 100%; border-collapse: collapse; }
.params td { padding: 7px 8px 7px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.params tr:last-child td { border-bottom: 0; }
.params td.n { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; white-space: nowrap; padding-top: 14px; width: 1%; }
.params td.in { width: 1%; padding-top: 12px; }
.params .d { font-size: 12px; color: var(--muted); margin-top: 3px; }
.resp-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
.stepper { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 14px 0 4px; }
.stepper div { border-top: 3px solid var(--line); padding-top: 7px; font-size: 12.5px; color: var(--faint); }
.stepper div.done { border-color: var(--ok); color: var(--text); }
.stepper div.now { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.stepper div.fail { border-color: var(--bad); color: var(--bad); font-weight: 600; }
@media (max-width: 640px) { .stepper { grid-template-columns: 1fr 1fr; } }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px -18px 0; padding: 0 18px; overflow-x: auto; }
.subtabs button { border: 0; background: none; padding: 9px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; white-space: nowrap; }
.subtabs button[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checks li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; font-size: 13px; }
.checks .y { color: var(--ok); font-weight: 700; }
.checks .n { color: var(--bad); font-weight: 700; }
.checks .detail { color: var(--muted); overflow-wrap: anywhere; }
.pipeline { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.pipeline div { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; font-size: 12.5px; }
.pipeline b { display: block; font-size: 13px; margin-bottom: 3px; }
@media (max-width: 760px) { .pipeline { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; letter-spacing: -0.02em; }
.stat span { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ── settings: flat sections, title on the left, controls on the right ─ */
.settings { max-width: 1100px; margin: 0 auto; }
.set-sec { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 36px; padding: 28px 0; border-top: 1px solid var(--line); }
.set-sec:first-child { border-top: 0; padding-top: 6px; }
.set-head h2 { font-size: 15px; font-weight: 600; }
.set-head p { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 6px 0 0; }
.set-head code { font-size: 12px; background: var(--code-bg); padding: 0 4px; border-radius: 4px; }
.set-body { display: grid; gap: 14px; min-width: 0; align-content: start; }
@media (max-width: 900px) { .set-sec { grid-template-columns: 1fr; gap: 14px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h3 { font-size: 14px; font-weight: 600; }
.panel-body { padding: 16px; }
.panel-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--panel-2); flex-wrap: wrap; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; }
.panel-row + .panel-row { border-top: 1px solid var(--line); }
.warn-row { background: var(--warn-soft); font-size: 13px; }
.panel-empty { padding: 18px 16px; color: var(--muted); font-size: 13px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fields .span-2 { grid-column: span 2; }
.fields .subhead { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 2px; }
.fields .subhead p { margin: 4px 0 0; }
@media (max-width: 640px) { .fields { grid-template-columns: 1fr; } .fields .span-2 { grid-column: auto; } }

.env-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.env-dot.real { background: var(--real); }
.env-dot.dummy { background: var(--dummy); }
.statuses { display: flex; flex-wrap: wrap; gap: 4px 16px; min-width: 0; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.status::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.status.ok::before { background: var(--ok); }
.status.bad { color: var(--bad); }
.status.bad::before { background: var(--bad); }
.status.run::before { display: none; }
.spinner.sm { width: 12px; height: 12px; border-width: 2px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--muted); user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; margin: 0; width: 30px; height: 18px; border-radius: 999px; background: var(--panel-3); position: relative; cursor: pointer; transition: background 0.15s; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); transition: transform 0.15s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(12px); }

.create-row { flex-wrap: nowrap; }
.create-row #client-name { flex: 1; min-width: 0; }
.create-row select { width: auto; min-width: 160px; flex: none; }
/* masking rules editor */
.new-mask { display: block; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.mask-editor { display: grid; gap: 12px; }
.mask-editor textarea.input { min-height: 64px; resize: vertical; }
.mask-editor .field > span .muted { font-weight: 400; }
.mask-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 16px; }
.mask-cat { align-items: flex-start; font-size: 13px; }
.mask-cat input { margin-top: 2px; }
.mask-cat > span { display: grid; gap: 1px; }
.modal.wide { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow: auto; }
.locale-as select.input { max-width: 360px; }
.mask-editor .field > span .muted { display: block; font-size: 12px; margin-top: 1px; }
.create-row .check { white-space: nowrap; font-size: 13px; }
@media (max-width: 800px) { .create-row { flex-wrap: wrap; } .create-row #client-name, .create-row #brief-q { flex-basis: 100%; } }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
table.grid th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--panel-2); }
table.grid tr > :first-child { padding-left: 16px; }
table.grid tr > :last-child { padding-right: 16px; }
table.grid tbody tr:last-child td { border-bottom: 0; }
.cell-name { font-weight: 500; }
.row.end { justify-content: flex-end; flex-wrap: nowrap; gap: 6px; }
.table-wrap { overflow-x: auto; }
/* a new key, shown once: calm, with the key and its copy button side by side */
.key-created { margin: 14px 16px; border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line)); background: var(--ok-soft); border-radius: var(--radius-sm); padding: 12px 14px; display: grid; gap: 10px; }
.kc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kc-head > .icon { width: 16px; height: 16px; color: var(--ok); flex: none; }
.kc-key { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 4px 4px 12px; min-width: 0; }
.kc-key code { flex: 1; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
#new-key:not(:empty) + .table-wrap, #new-key:not(:empty) + .panel-empty { border-top: 1px solid var(--line); }
.keys-env { border-bottom: 1px solid var(--line); font-size: 13px; padding-top: 10px; padding-bottom: 10px; }
.keys-env .env-dot { display: inline-block; vertical-align: middle; margin-right: 2px; }
table.grid tr.off td { color: var(--muted); }

/* actions menu */
.menu-wrap { display: inline-flex; }
.menu { position: fixed; z-index: 40; min-width: 190px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px; display: grid; gap: 1px; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); white-space: nowrap; }
.menu-item .icon { width: 15px; height: 15px; color: var(--muted); flex: none; }
.menu-item:hover, .menu-item:focus-visible { background: var(--panel-2); outline: none; }
.menu-item.danger, .menu-item.danger .icon { color: var(--bad); }
table.grid td.actions { width: 1%; text-align: right; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.tile-head { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.tile-head h3 { font-size: 14px; font-weight: 600; }
.tile-head .pill { margin-left: auto; }
.tile .kv { font-size: 12.5px; gap: 8px 14px; }
.tile-foot { margin-top: auto; }

/* ── map ─────────────────────────────────────────────────────────────── */
.stat-tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.stat-tile { gap: 2px; padding: 14px 16px; }
.stat-tile b { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat-tile span { font-size: 13px; font-weight: 500; }
.stat-tile small { color: var(--muted); font-size: 12px; }
.refresh-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; font-size: 13px; }
table.grid td.wrap { white-space: normal; min-width: 180px; overflow-wrap: anywhere; }
table.map-grid td { vertical-align: top; }
table.map-grid tr.off td { opacity: 0.55; }
table.map-grid .n { color: var(--bad); }
code.ref { font-size: 11.5px; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
pre.brief { margin: 0; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--code-bg); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; line-height: 1.55; max-height: 420px; overflow: auto; }
details.panel-row { display: block; border-top: 1px solid var(--line); }
details.panel-row > ul { margin-top: 10px; }
.mono { font-family: var(--scalar-font-code, ui-monospace, Menlo, monospace); }

/* ── dialog, toast, lightbox ─────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgb(10 12 16 / 0.55); display: grid; place-items: center; padding: 20px; animation: fade 0.12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(460px, 100%); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 20px; display: grid; gap: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: grid; gap: 8px; }
.toast { background: var(--text); color: var(--panel); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 13px; max-width: 380px; animation: fade 0.15s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgb(8 10 14 / 0.88); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: fade 0.12s ease-out; }
.lightbox-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: #e5e7eb; font-size: 13px; gap: 12px; }
.lightbox-top .icon-btn, .lightbox .nav { color: #e5e7eb; }
.lightbox-top .icon-btn:hover, .lightbox .nav:hover { background: rgb(255 255 255 / 0.12); color: #fff; }
.lightbox-stage { position: relative; display: grid; place-items: center; padding: 0 64px; min-height: 0; }
.lightbox-stage img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 10px 40px rgb(0 0 0 / 0.5); background: #111; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgb(255 255 255 / 0.08); cursor: pointer; font-size: 20px; }
.lightbox .nav.prev { left: 12px; }
.lightbox .nav.next { right: 12px; }
.lightbox-foot { text-align: center; color: #9ca3af; font-size: 12px; padding: 10px; }

/* ── APIs: Scalar reference + AI-built requests ──────────────────────── */
.apis-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.ref-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-height: 480px; }
.ref-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.ref-wrap .loading { padding: 60px; text-align: center; color: var(--muted); }
a.btn { text-decoration: none; color: inherit; }

/* AI review of a masked key */
.values-cell { display: inline-flex; align-items: center; gap: 6px; }
.chip-btn { all: unset; cursor: pointer; border-radius: 999px; }
.chip-btn:hover .pill { filter: brightness(0.96); text-decoration: underline; text-underline-offset: 2px; }
.chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kc-review { display: flex; gap: 8px; align-items: flex-start; color: var(--purple); }
.kc-review .icon { width: 14px; height: 14px; flex: none; margin-top: 1px; }
.review-modal h2 { display: flex; align-items: center; gap: 8px; }
.review-modal h2 .icon { width: 18px; height: 18px; color: var(--purple); flex: none; }
.review-modal h3 { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 16px 0 6px; }
.review-modal h3 .icon { width: 14px; height: 14px; color: var(--purple); }
.review-meta { margin-bottom: 10px; }
.review-running { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 13px; }
.review-summary { margin: 8px 0 0; line-height: 1.5; white-space: pre-wrap; }
.review-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; line-height: 1.45; }
.review-verify { display: grid; gap: 6px; }
.review-steps { margin-top: 16px; font-size: 12px; }
.review-steps summary { cursor: pointer; color: var(--muted); }
.review-steps ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 3px; }
.bad-text { color: var(--bad); }
.review-list.audits li { display: grid; gap: 3px; }

/* the fake environment (generated US sample data) */
.pill.fake { background: var(--fake-soft); color: var(--fake); }
.env-dot.fake { background: var(--fake); }
.data-switch .seg button[data-env='fake'][aria-pressed='true'] { color: var(--fake); }
.fake-banner { background: var(--fake-soft); color: var(--fake); text-align: center; font-size: 12.5px; font-weight: 600; padding: 5px 12px; }
.fake-panel .kv { margin: 0; }

/* first install and sign-in */
.lock.auth { text-align: left; justify-items: stretch; max-width: 420px; }
.lock.auth > .lock-icon, .lock.auth > h2, .lock.auth > p { justify-self: center; text-align: center; }
.lock.auth > .btn.ghost { justify-self: center; }
.auth-form { display: grid; gap: 12px; margin-top: 6px; }
.auth-form .field { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
.auth-form .field .muted { font-weight: 400; }
.auth-error { color: var(--bad); font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }

/* AI-built list: filter by where an API stands in the other environment */
.chips { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.chip .n { font-variant-numeric: tabular-nums; opacity: 0.7; }
.chip[aria-pressed='true'] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.chip[aria-pressed='true'] .n { opacity: 0.85; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips[hidden] { display: none; }

/* failing endpoints */
.health-banner { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 16px; background: var(--bad-soft); color: var(--bad); font-size: 13px; cursor: pointer; }
.health-banner[hidden] { display: none; }
.health-banner .icon { width: 15px; height: 15px; flex: none; }
.health-banner code { background: transparent; color: inherit; font-size: 12.5px; }
.health-banner .link { text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.repairs li { display: grid; gap: 3px; }
.repair-note { white-space: pre-wrap; max-height: 7.5em; overflow: hidden; }
.keys-env .seg button { display: inline-flex; align-items: center; gap: 6px; }
.keys-env .seg .env-dot { width: 7px; height: 7px; }
.tile-foot { display: grid; gap: 6px; }
