/* InceptionDB console. Plain CSS, no build step. Components only use the
   tokens below; the light theme redefines them. */

:root {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #111729;
  --surface-2: #172036;
  --surface-3: #1e2943;
  --sunken: #0d1324;
  --border: #222d45;
  --border-strong: #33415f;
  --text: #dbe3f0;
  --text-strong: #f5f8fc;
  --text-muted: #93a1b8;
  --text-faint: #66748c;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-text: #8ab4ff;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --danger: #f87171;
  --danger-solid: #dc2626;
  --danger-soft: rgba(239, 68, 68, 0.13);
  --success: #34d399;
  --success-soft: rgba(16, 185, 129, 0.13);
  --warning: #fbbf24;
  --warning-soft: rgba(245, 158, 11, 0.13);
  --focus: rgba(59, 130, 246, 0.55);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar: 264px;
  --json-key: #8ab4ff;
  --json-string: #86efac;
  --json-number: #fcd34d;
  --json-literal: #f0abfc;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f2f5fa;
    --surface-3: #e8edf5;
    --sunken: #f8fafc;
    --border: #e3e8f0;
    --border-strong: #cdd5e1;
    --text: #1f2a3d;
    --text-strong: #0b1220;
    --text-muted: #556378;
    --text-faint: #7a8699;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-text: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.09);
    --danger: #dc2626;
    --danger-solid: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.07);
    --success: #059669;
    --success-soft: rgba(5, 150, 105, 0.09);
    --warning: #b45309;
    --warning-soft: rgba(217, 119, 6, 0.1);
    --focus: rgba(37, 99, 235, 0.4);
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --json-key: #1d4ed8;
    --json-string: #047857;
    --json-number: #b45309;
    --json-literal: #a21caf;
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
pre, code, kbd, .mono { font-family: var(--mono); }
kbd { font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--text-muted); background: var(--surface-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- helpers ---------- */

.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.stack-sm { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.stack-lg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.grow { flex: 1; min-width: 0; }
.end { justify-content: flex-end; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; color: var(--text-strong); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.msg-error { color: var(--danger); font-size: 13px; }
.msg-success { color: var(--success); font-size: 13px; }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

/* ---------- layout ---------- */

.layout { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-right: 44px; } /* room for the activity rail */
.content { padding: 28px 32px 48px; width: 100%; max-width: 1480px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }

.sidebar { width: var(--sidebar); flex: none; height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-top { padding: 18px 16px 12px; display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-strong); font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, #3b82f6, #8b5cf6); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 0.02em; }
.sidebar-section { padding: 6px 16px 4px; display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.sidebar-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; cursor: pointer; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); text-align: left; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-text); }
.nav-item .count { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.nav-item.is-active .count { color: var(--accent-text); }
.nav-icon { width: 16px; height: 16px; flex: none; opacity: 0.8; }
.sidebar-footer { border-top: 1px solid var(--border); padding: 10px 12px; display: grid; gap: 4px; }
.footer-button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; cursor: pointer; padding: 7px 8px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: 13px; text-align: left; }
.footer-button:hover { background: var(--surface-2); color: var(--text); }

.topbar { display: none; }

/* ---------- controls ---------- */

.input, .select, .textarea { width: 100%; background: var(--sunken); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 11px; color: var(--text); transition: border-color 0.15s, box-shadow 0.15s; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.textarea { font-family: var(--mono); font-size: 13px; line-height: 1.55; resize: vertical; min-height: 120px; tab-size: 2; }
.input-sm, .select-sm { padding: 5px 9px; font-size: 13px; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2393a1b8' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.search { position: relative; }
.search .input { padding-left: 32px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.input[type="file"] { padding: 6px; }
.input[type="file"]::file-selector-button { margin-right: 12px; border: 0; border-radius: 6px; padding: 6px 12px; background: var(--surface-3); color: var(--text); cursor: pointer; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-sm); transition: background 0.15s, border-color 0.15s, color 0.15s; }
.btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text-strong); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-danger-soft { color: var(--danger); }
.btn-danger-soft:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: none; box-shadow: none; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }
.btn-block { width: 100%; }

.segmented { display: inline-flex; padding: 2px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { border: 0; background: none; color: var(--text-muted); padding: 4px 11px; font-size: 12px; font-weight: 600; border-radius: 6px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text-strong); box-shadow: var(--shadow-sm); }

/* ---------- badges ---------- */

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.badge-accent { color: var(--accent-text); background: var(--accent-soft); border-color: transparent; }
.badge-success { color: var(--success); background: var(--success-soft); border-color: transparent; }
.badge-warning { color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.dot.is-pulsing { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.status-online { color: var(--success); }
.status-degraded { color: var(--warning); }
.status-offline { color: var(--danger); }
.status-unknown { color: var(--text-faint); }

/* ---------- surfaces ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 15px; font-weight: 650; color: var(--text-strong); }
.card-sub { font-size: 13px; color: var(--text-muted); }
.panel { background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 10px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-strong); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-sub { color: var(--text-muted); margin-top: 4px; }
.page-title .badge { font-size: 12px; letter-spacing: 0; }
.page-title a.badge:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text-strong); }
.page-title a.badge-accent:hover { color: var(--accent-text); }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stat-label { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text-strong); letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12px; color: var(--text-faint); }

.tabs-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs-nav::-webkit-scrollbar { display: none; }
.tabs-nav a { flex: none; }
.tabs-nav a { padding: 9px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-muted); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 7px; }
.tabs-nav a:hover { color: var(--text-strong); text-decoration: none; }
.tabs-nav a[aria-current="page"] { color: var(--text-strong); border-bottom-color: var(--accent); }
.tabs-nav .badge { padding: 0 7px; }

.empty { padding: 48px 24px; display: grid; justify-items: center; text-align: center; gap: 10px; }
.empty-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.empty h3 { font-size: 16px; color: var(--text-strong); }
.empty p { color: var(--text-muted); max-width: 420px; }

/* ---------- query bar ---------- */

.querybar { display: grid; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.conditions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.condition { display: inline-flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--sunken); overflow: hidden; max-width: 100%; }
.condition > * { border: 0; background: none; padding: 5px 9px; font-size: 13px; min-width: 0; }
.condition > * + * { border-left: 1px solid var(--border); }
.condition input { width: 130px; outline: none; }
.condition input.field { width: 110px; font-family: var(--mono); color: var(--accent-text); }
.condition select { appearance: none; cursor: pointer; color: var(--text-muted); font-weight: 600; outline: none; }
.condition select option { background: var(--surface); color: var(--text); }
.condition button { cursor: pointer; color: var(--text-faint); padding: 5px 8px; }
.condition button:hover { color: var(--danger); background: var(--danger-soft); }
.condition:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.index-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--accent-text); background: var(--accent-soft); border-radius: var(--radius-sm); padding: 6px 10px; }

/* ---------- data table ---------- */

.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.data-table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--text-muted); background: var(--surface-2); padding: 8px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: top; max-width: 320px; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tbody tr.is-selected td { background: var(--accent-soft); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .col-index { width: 1%; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.cell { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-string { color: var(--text); }
.cell-number { font-family: var(--mono); color: var(--json-number); font-variant-numeric: tabular-nums; }
.cell-bool { font-family: var(--mono); color: var(--json-literal); }
.cell-null { font-family: var(--mono); color: var(--text-faint); font-style: italic; }
.cell-json { font-family: var(--mono); color: var(--text-muted); font-size: 12px; }
.cell-id { font-family: var(--mono); color: var(--accent-text); }
.cell-missing { color: var(--text-faint); }

/* Always visible at the bottom of the window while the list is on screen */
.results-foot {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted); background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -8px 16px -12px rgba(0, 0, 0, 0.5);
}
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }

.pager { display: inline-flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--sunken); font-size: 12px; }
.pager > * + * { border-left: 1px solid var(--border); }
.pager button { display: inline-flex; align-items: center; gap: 3px; border: 0; background: none; padding: 4px 10px; font-weight: 600; color: var(--text); cursor: pointer; }
.pager button:hover:not(:disabled) { background: var(--surface-2); }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager label { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); }
.pager input { width: 68px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); font: 12px var(--mono); color: var(--text-strong); text-transform: none; }
.pager input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus); }
/* The table scrolls with the footer bar (.hscroll); its own bar would be out of view. */
/* Header that stays at the top of the window (below the mobile top bar). The
   table's own header only sets the column widths and stays for screen readers. */
.table-head-sticky { position: sticky; top: var(--sticky-top, 0px); z-index: 3; overflow: hidden; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.table-head-sticky .data-table { table-layout: fixed; }
.table-head-sticky th { border-bottom: 0; overflow: hidden; text-overflow: ellipsis; }
.thead-measure tr { visibility: collapse; }
.table-wrap-synced { scrollbar-width: none; }
.table-wrap-synced::-webkit-scrollbar { display: none; }
/* Spans the full card width so it scrolls exactly like the table. */
.hscroll { flex: 0 0 calc(100% + 32px); order: -1; margin: -10px -16px 0; overflow-x: auto; overflow-y: hidden; height: 14px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.hscroll > div { height: 1px; }
.hscroll::-webkit-scrollbar { height: 10px; }
.hscroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--surface); }
.hscroll::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
.doc-list { display: grid; gap: 10px; padding: 16px; }
.doc-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--sunken); padding: 12px 14px; cursor: pointer; display: grid; gap: 6px; }
.doc-item:hover { border-color: var(--border-strong); }

.json { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.6; color: var(--text); }
.json-key { color: var(--json-key); }
.json-string { color: var(--json-string); }
.json-number { color: var(--json-number); }
.json-literal { color: var(--json-literal); }
.code-block { margin: 0; background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; font-size: 12.5px; line-height: 1.6; white-space: pre; }

.kv { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; }
.kv > div + div { border-top: 1px solid var(--border); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-family: var(--mono); color: var(--text-strong); }

/* ---------- home ---------- */

.collection-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.collection-card { text-align: left; cursor: pointer; display: grid; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); color: inherit; transition: border-color 0.15s, transform 0.15s; }
.collection-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.collection-card .name { font-weight: 650; font-size: 15px; color: var(--text-strong); }
.collection-card .figure { font-size: 22px; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }

/* ---------- dialogs, drawers ---------- */

dialog { color: var(--text); }
dialog::backdrop { background: rgba(5, 8, 18, 0.62); backdrop-filter: blur(2px); }
.modal { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.modal-wide { width: min(680px, calc(100vw - 32px)); }
.modal-head { padding: 20px 22px 0; display: grid; gap: 4px; }
.modal-title { font-size: 17px; font-weight: 650; color: var(--text-strong); }
.modal-body { padding: 18px 22px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 16px 16px; }

.drawer { border: 0; border-left: 1px solid var(--border); background: var(--surface); padding: 0; margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(620px, 100vw); box-shadow: var(--shadow); display: none; }
.drawer[open] { display: flex; flex-direction: column; animation: drawer-in 0.18s ease-out; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-title { font-size: 17px; font-weight: 650; color: var(--text-strong); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; background: var(--surface-2); }

.choice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.choice { display: grid; gap: 4px; text-align: left; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--sunken); cursor: pointer; color: inherit; }
.choice:hover { border-color: var(--text-faint); }
.choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); background: var(--accent-soft); }
.choice .title { font-weight: 650; color: var(--text-strong); }
.choice .desc { font-size: 12px; color: var(--text-muted); }

.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 200px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); display: grid; }
.menu-list button { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.menu-list button:hover { background: var(--surface-2); }
.menu-list button.is-danger { color: var(--danger); }
.menu-list button.is-danger:hover { background: var(--danger-soft); }
.menu-list .divider { margin: 4px 2px; }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: none; color: var(--text-muted); border-radius: 6px; padding: 4px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text-strong); box-shadow: var(--shadow-sm); }
.tab-panel { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.tab-panel pre { margin: 0; max-height: 360px; overflow: auto; padding: 12px 14px; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; background: var(--sunken); }

.request-list { display: grid; }
.request { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 4px; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; cursor: pointer; color: inherit; }
.request:hover { background: var(--surface-2); }
.method { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--text-muted); width: 42px; }

/* ---------- activity rail ---------- */

.activity-rail {
  /* Free floating in the right gutter: no box, and the rail itself lets clicks through. */
  position: fixed; right: 16px; top: 50%; transform: translateY(-50%); z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 12px; pointer-events: none;
}
.activity-rail > * { pointer-events: auto; }
.rail-head { width: 24px; height: 24px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; color: var(--text-faint); background: none; transition: color 0.15s, background 0.15s; }
.rail-head:hover { color: var(--accent-text); background: var(--accent-soft); }
.rail-markers { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.activity-marker {
  --marker: var(--accent); position: relative; width: 12px; height: 12px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; flex: none;
  background: var(--marker);
  /* Thin ring in the page color keeps the dot readable over any content */
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px color-mix(in srgb, var(--marker) 25%, transparent);
  animation: marker-in 0.35s ease-out both; transition: transform 0.15s ease;
}
.activity-marker:hover, .activity-marker:focus-visible { transform: scale(1.3); }
.activity-marker.is-pending { --marker: #38bdf8; }
.activity-marker.is-pending::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--bg); animation: pulse 0.9s ease-in-out infinite; opacity: 0; }
.activity-marker.is-success { --marker: #34d399; }
.activity-marker.is-error { --marker: #f87171; }
.activity-marker.is-background { width: 7px; height: 7px; opacity: 0.5; box-shadow: 0 0 0 2px var(--bg); }
.activity-marker.is-selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--marker); }
/* Attention ring around the newest request */
.activity-marker.is-newest:not(.is-background)::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--marker);
  animation: marker-ring 1.2s ease-out 0.15s 2 both; pointer-events: none;
}
@keyframes marker-in { 0% { opacity: 0; transform: scale(0.4); } 60% { opacity: 1; transform: scale(1.15); } 100% { opacity: 1; transform: scale(1); } }
@keyframes marker-ring { 0% { transform: scale(1); opacity: 0.8; } 100% { transform: scale(2.6); opacity: 0; } }

.activity-fab { display: none; }

/* ---------- toasts ---------- */

.toasts { position: fixed; right: 64px; bottom: 20px; z-index: 100; display: grid; gap: 8px; width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); animation: toast-in 0.2s ease-out; font-size: 13px; }
.toast .dot { margin-top: 6px; }
.toast-code { flex: none; align-self: center; }
.toast-success .dot { color: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-error .dot { color: var(--danger); }
.toast-info .dot { color: var(--accent); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(5, 8, 18, 0.6); }
  .topbar { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
  .main { --sticky-top: 52px; }
  .content { padding: 18px 14px 40px; }
  .page-title { font-size: 20px; }
  .tabs-nav { gap: 0; }
  .tabs-nav a { padding: 9px 10px; font-size: 13px; }
  .data-table td { max-width: 200px; }
  .pager-text { display: none; }
  .results-foot { padding-right: 80px; }
  .hscroll { flex-basis: calc(100% + 96px); margin-right: -80px; }
  .pager input { width: 54px; }
  .pager label { padding: 3px 6px; }
  .main { padding-right: 0; }
  .activity-rail { display: none; }
  .toasts { right: 14px; bottom: 80px; }
  .activity-fab {
    display: grid; place-items: center; position: fixed; right: 16px; bottom: 16px; z-index: 30; width: 52px; height: 52px; border-radius: 50%;
    border: 0; cursor: pointer; color: #fff; background: var(--accent); box-shadow: var(--shadow); animation: marker-in 0.35s ease-out both;
  }
  .activity-fab.is-error { background: var(--danger-solid); }
  .fab-count { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px; font-size: 11px; font-weight: 700; display: grid; place-items: center; background: var(--surface); color: var(--text-strong); border: 1px solid var(--border); }
}
