/* The admin UI's whole stylesheet. No inline styles anywhere: the CSP allows only this file.
   Colours are tokens on :root, redefined for dark (the system's, unless the theme switch picked one; theme.js).
   Chart series s1/s2 are a blue and an orange that stay apart for colour-blind readers in both themes. */
:root {
  color-scheme: light;
  --sans: "Inter", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --page: #f4f5f7; --surface: #ffffff; --surface-2: #f2f4f7; --surface-3: #e8ebef;
  --ink: #141a22; --ink-2: #4a5563; --muted: #78818d;
  --border: rgba(20, 26, 34, 0.10); --border-strong: rgba(20, 26, 34, 0.20);
  --accent: #2557c8; --accent-hover: #1d47a6; --accent-wash: rgba(37, 87, 200, 0.08); --on-accent: #ffffff;
  --s1: #2463a6; --s2: #d9692b; --s3: #9aa3ae;
  --good: #0ca30c; --good-text: #0b6e1f; --good-wash: rgba(12, 163, 12, 0.10);
  --warn: #e8a317; --warn-text: #865700; --warn-wash: rgba(232, 163, 23, 0.14);
  --bad: #d03b3b; --bad-text: #b42f2f; --bad-wash: rgba(208, 59, 59, 0.10);
  --mark: rgba(250, 178, 25, 0.35);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, 0.14);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0c1016; --surface: #141a22; --surface-2: #1a222c; --surface-3: #232c38;
    --ink: #e8ebef; --ink-2: #b7bfc9; --muted: #8a939e;
    --border: rgba(232, 235, 239, 0.09); --border-strong: rgba(232, 235, 239, 0.18);
    --accent: #6b9bff; --accent-hover: #8ab0ff; --accent-wash: rgba(107, 155, 255, 0.12); --on-accent: #0c1016;
    --s1: #4c8ed8; --s2: #dc7236; --s3: #5d6773;
    --good-text: #4cd06a; --good-wash: rgba(76, 208, 106, 0.12);
    --warn-text: #fab219; --warn-wash: rgba(250, 178, 25, 0.14);
    --bad-text: #ee7373; --bad-wash: rgba(238, 115, 115, 0.14);
    --mark: rgba(250, 178, 25, 0.30);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0c1016; --surface: #141a22; --surface-2: #1a222c; --surface-3: #232c38;
  --ink: #e8ebef; --ink-2: #b7bfc9; --muted: #8a939e;
  --border: rgba(232, 235, 239, 0.09); --border-strong: rgba(232, 235, 239, 0.18);
  --accent: #6b9bff; --accent-hover: #8ab0ff; --accent-wash: rgba(107, 155, 255, 0.12); --on-accent: #0c1016;
  --s1: #4c8ed8; --s2: #dc7236; --s3: #5d6773;
  --good-text: #4cd06a; --good-wash: rgba(76, 208, 106, 0.12);
  --warn-text: #fab219; --warn-wash: rgba(250, 178, 25, 0.14);
  --bad-text: #ee7373; --bad-wash: rgba(238, 115, 115, 0.14);
  --mark: rgba(250, 178, 25, 0.30);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.45);
}

/* ── Base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 var(--sans); font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h2 .ic { color: var(--muted); width: 15px; height: 15px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 6px; }
p { margin: 0 0 10px; }
code, kbd { font-family: var(--mono); font-size: 12px; }
td code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
small, .small { font-size: 12px; }
.sub, .muted { color: var(--muted); }
.sub { font-size: 13px; margin: 2px 0 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.ic { display: inline-block; width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }

/* ── Shell: a sidebar of sections, the page beside it */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); padding: 4px 6px; }
.brand:hover { text-decoration: none; }
.brand b { display: block; font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.brand small { display: block; color: var(--muted); font-size: 11px; line-height: 1.2; }
.mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--on-accent); }
.mark .ic { width: 19px; height: 19px; stroke-width: 2; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav-link .ic { color: var(--muted); }
.nav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-wash); color: var(--accent); }
.nav-link[aria-current="page"] .ic { color: var(--accent); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 8px; padding: 8px 6px 0; border-top: 1px solid var(--border); }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); font-weight: 600; font-size: 12px; }
.who { min-width: 0; flex: 1; line-height: 1.25; }
.who b { display: block; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: var(--muted); font-size: 11px; }
.main { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }
.solo { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }

/* ── Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--ink-2); }
.crumbs .ic { width: 13px; height: 13px; }
.title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Segmented control (theme switch, filters) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button, .seg a { border: 0; background: none; color: var(--ink-2); padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg > * + * { border-left: 1px solid var(--border); }
.seg button:hover, .seg a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.seg.theme { align-self: flex-start; }
.seg.theme button { padding: 5px 9px; }

/* ── Cards and grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; min-width: 0; }
.card-head > :not(h2) { flex: none; }
/* Label left, figure right: the small fact lists in the overview's cards. */
.facts { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; margin: 0; font-size: 13px; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 14px 16px 0; }
.card.flush > .empty { padding: 28px 16px; }
.grid2, .grid3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
@media (min-width: 1000px) {
  .grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.section { margin-bottom: 14px; }
.section-top { margin-top: 14px; }
.spaced-top { margin-top: 12px; margin-bottom: 0; }
.legend.spaced { margin: 10px 0 14px; }

/* ── Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { display: flex; flex-direction: column; gap: 2px; }
.tile .label { color: var(--ink-2); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tile .label .ic { color: var(--muted); width: 14px; height: 14px; }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.tile .note { color: var(--muted); font-size: 12px; }
.tile .spark { margin-top: 8px; }
.tile .spark svg { height: 28px; }
.delta { font-weight: 600; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--bad-text); }

/* ── Charts: the plot stretches; its labels are HTML so they never do */
.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 8px; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.2em; }
.chart-plot { position: relative; }
.chart-x { grid-column: 2; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
svg.plot { display: block; width: 100%; height: 150px; overflow: visible; }
.tile .spark svg.plot { height: 28px; }
svg .gridline { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg .s1 { fill: var(--s1); } svg .s2 { fill: var(--s2); } svg .s3 { fill: var(--s3); }
svg .good { fill: var(--good); } svg .warn { fill: var(--warn); } svg .bad { fill: var(--bad); }
svg .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
svg .line.s1 { stroke: var(--s1); } svg .line.s2 { stroke: var(--s2); }
svg .hit { fill: transparent; cursor: default; }
svg .hit:hover { fill: var(--accent-wash); }
svg .hit[hx-get] { cursor: pointer; }
svg.meter { display: block; width: 64px; height: 6px; }
svg.meter .track { fill: var(--surface-3); }
svg.split { display: block; width: 100%; height: 8px; border-radius: 4px; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin: -4px 0 10px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -0.5px; }
.legend i.s1 { background: var(--s1); } .legend i.s2 { background: var(--s2); } .legend i.s3 { background: var(--s3); }
.legend i.good { background: var(--good); } .legend i.warn { background: var(--warn); } .legend i.bad { background: var(--bad); }
.legend i.line { height: 3px; border-radius: 2px; vertical-align: 2px; }
#tip { position: fixed; z-index: 20; display: none; pointer-events: none; max-width: 320px; padding: 7px 10px; border-radius: 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); font-size: 12px; white-space: pre-line; }
#tip.on { display: block; }

/* ── Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap, .nowrap { white-space: nowrap; }
td.title-cell { min-width: 240px; }
.person { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
td .title-link { font-weight: 600; color: var(--ink); }
td .title-link:hover { color: var(--accent); }
td.error-text { color: var(--bad-text); font-size: 12px; max-width: 360px; }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 16px; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 16px; }
/* Query lists: the query takes what the fixed columns leave, cut with an ellipsis (the whole query is its tooltip). */
table.queries { table-layout: fixed; }
table.queries .query-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.queries .w-key { width: 120px; }
table.queries .w-num { width: 76px; }
table.queries .w-when { width: 100px; }
table.queries td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Status badges: a dot and a word */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.badge.ok, .badge.status-ready, .badge.status-done, .badge.status-active { background: var(--good-wash); color: var(--good-text); border-color: transparent; }
.badge.ok::before, .badge.status-ready::before, .badge.status-done::before, .badge.status-active::before { background: var(--good); }
.badge.warn, .badge.status-queued, .badge.status-extracting, .badge.status-chunking, .badge.status-embedding, .badge.status-running { background: var(--warn-wash); color: var(--warn-text); border-color: transparent; }
.badge.warn::before, .badge.status-queued::before, .badge.status-extracting::before, .badge.status-chunking::before, .badge.status-embedding::before, .badge.status-running::before { background: var(--warn); }
.badge.status-extracting::before, .badge.status-chunking::before, .badge.status-embedding::before, .badge.status-running::before { animation: pulse 1.2s ease-in-out infinite; }
.badge.error, .badge.status-failed, .badge.status-revoked, .badge.status-disabled { background: var(--bad-wash); color: var(--bad-text); border-color: transparent; }
.badge.error::before, .badge.status-failed::before, .badge.status-revoked::before, .badge.status-disabled::before { background: var(--bad); }
.badge.status-superseded { opacity: 0.75; }
.flags { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: 6px; vertical-align: middle; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 6px; font-size: 11px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip b { color: var(--ink); font-weight: 600; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ── Buttons */
.btn, button { font: inherit; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; line-height: 1.35; white-space: nowrap; transition: background 0.12s, border-color 0.12s; }
.btn:hover, button:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary, button[type="submit"]:not(.btn) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover, button[type="submit"]:not(.btn):hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--bad-text); }
.btn.danger:hover { background: var(--bad-wash); border-color: var(--bad-wash); }
.btn.small { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.btn.icon { padding: 6px; }
.btn.small.icon { padding: 4px; }
button:disabled, .btn:disabled { opacity: 0.45; cursor: default; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
td .actions { justify-content: flex-end; flex-wrap: nowrap; }

/* ── Forms */
label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); }
label > input, label > select, label > textarea { margin-top: 5px; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; width: 100%; max-width: 100%; transition: border-color 0.12s, box-shadow 0.12s; }
input::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0 6px 0 0; accent-color: var(--accent); vertical-align: -2px; }
input[type="file"] { padding: 6px; background: var(--surface-2); }
input[type="file"]::file-selector-button { font: inherit; font-size: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); border-radius: 6px; padding: 3px 9px; margin-right: 10px; cursor: pointer; }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
form.stack-form { display: flex; flex-direction: column; gap: 12px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
label.check { display: flex; align-items: flex-start; gap: 2px; font-weight: 400; color: var(--ink-2); font-size: 13px; }
form.inline { display: inline-flex; gap: 6px; margin: 0; align-items: center; }
form.inline select { width: auto; padding-top: 3px; padding-bottom: 3px; font-size: 13px; }
progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-3); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

/* ── Panels that open (add a document, create a key) */
details.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
details.panel > summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary .ic { color: var(--accent); }
details.panel > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s; }
details.panel[open] > summary::after { transform: rotate(-135deg); }
details.panel > .panel-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.panel-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
@media (min-width: 1000px) { .panel-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .panel-cols > * + * { border-left: 1px solid var(--border); padding-left: 20px; } }
.panel-cols h3 { display: flex; align-items: center; gap: 6px; }
details.more { margin-top: 8px; }
details.more > summary { cursor: pointer; color: var(--ink-2); font-size: 12px; font-weight: 500; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; font-size: 10px; transition: transform 0.15s; }
details.more[open] > summary::before { transform: rotate(90deg); }
details.more > :not(summary) { margin-top: 8px; }

/* ── Messages */
#flash:empty { display: none; }
.flash { display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; border-radius: var(--radius); margin: 0 0 14px; font-size: 13px; border: 1px solid transparent; }
.flash .ic { margin-top: 1px; }
.flash.ok { background: var(--good-wash); color: var(--good-text); }
.flash.error { background: var(--bad-wash); color: var(--bad-text); }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }
.secret { border-left: 3px solid var(--warn); }
.secret pre { margin: 8px 0; }

/* ── Text blocks */
pre { margin: 0; font: 12px/1.55 var(--mono); }
pre.text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 30rem; overflow: auto; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; color: var(--ink); }
pre.context { opacity: 0.6; }
pre.text + pre.text { margin-top: 8px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.meta-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
@media (min-width: 900px) { .meta-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.page-links { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.page-links a { display: inline-block; min-width: 26px; text-align: center; padding: 0 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.page-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.check-line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.check-line b { font-weight: 600; }
.page-view { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 14px; margin-top: 14px; }
.page-view .card-head { margin-bottom: 8px; }
.chunk-meta { color: var(--muted); font-size: 12px; margin: 10px 0 4px; }
.chunk-meta:first-of-type { margin-top: 0; }
.page-picker { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.page-picker label { width: 110px; }

/* ── Playground */
.searchbar { display: flex; gap: 8px; align-items: stretch; }
.searchbar .field { position: relative; flex: 1; }
.searchbar .field .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; }
.searchbar input[type="search"] { padding: 10px 12px 10px 38px; font-size: 15px; border-radius: 10px; }
.searchbar button { padding: 0 18px; border-radius: 10px; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
@media (min-width: 900px) { .options { grid-template-columns: 2fr 1.4fr 1fr 1fr; } }
.result-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin: 18px 0 10px; color: var(--ink-2); font-size: 13px; }
.timing { flex: 1 1 280px; max-width: 420px; }
.timing .legend { margin: 6px 0 0; }
ol.hits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hit { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 0 12px; }
.hit .rank { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.hit-head { display: flex; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.hit-title { font-weight: 600; color: var(--ink); }
.hit-path { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.hit-text { margin: 0 0 8px; line-height: 1.6; }
.hit-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.scoreline { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.debugline { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Sign in */
.login { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; margin-bottom: 18px; }
.login .card { padding: 24px; }
.login h1 { font-size: 18px; margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.login button[type="submit"] { width: 100%; padding: 9px; }
.login .seg.theme { margin: 16px auto 0; display: flex; width: max-content; }
#login-error .flash { margin: 14px 0 0; }

/* ── htmx */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Narrow screens: the sidebar becomes a bar across the top */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand small { display: none; }
  .nav { order: 3; flex-direction: row; width: 100%; overflow-x: auto; gap: 4px; padding-bottom: 2px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-link { white-space: nowrap; padding: 6px 10px; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: 8px; }
  .me { border-top: 0; padding: 0; }
  .who { display: none; }
  .main { padding: 18px 16px 40px; }
  .hit { grid-template-columns: minmax(0, 1fr); }
  .hit .rank { display: none; }
}
@media (max-width: 520px) {
  .tile .value { font-size: 22px; }
  .searchbar { flex-direction: column; }
  .searchbar button { padding: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
