:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6b6a65;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #006300;
  --good-bg: #e6f4e6;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --bad: #b42d2d;
  --bad-bg: #fbe7e7;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --seq: #2a78d6;
  --radius: 8px;
  /* page frame: gutters grow with the viewport; content fills the column up to a wide-screen ceiling */
  --gutter: clamp(16px, 2.4vw, 40px);
  --content-max: 1920px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9a9890;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --good: #0ca30c;
    --good-bg: #12301a;
    --warn: #fab219;
    --warn-bg: #33280f;
    --bad: #e66767;
    --bad-bg: #3a1a1a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --seq: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #9a9890;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --accent: #3987e5;
  --good: #0ca30c; --good-bg: #12301a; --warn: #fab219; --warn-bg: #33280f; --bad: #e66767; --bad-bg: #3a1a1a;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --seq: #3987e5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 12px; border-radius: 6px; margin: 0; max-height: 480px; overflow: auto; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* layout */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ico { width: 18px; height: 18px; flex: none; }
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .18s cubic-bezier(.2, .8, .2, 1); }
.nav { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; }
.nav-top { display: flex; align-items: center; gap: 6px; padding-bottom: 12px; }
.nav-toggle { padding: 7px; border: none; background: none; color: var(--ink-2); }
.nav-toggle:hover { background: var(--surface-2); }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 6px; color: var(--ink-2); white-space: nowrap; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 8px 4px; white-space: nowrap; }
.nav .who { margin-top: auto; padding: 12px 8px 4px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.nav .who .signout { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; }
.nav .who .signout .ico { width: 16px; height: 16px; }
.nav .who .theme-toggle { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--ink-2); }
.nav .who .theme-toggle .ico { width: 16px; height: 16px; }
.theme-icon { display: none; }
:root:not([data-theme]) .theme-icon[data-for="system"],
:root[data-theme="light"] .theme-icon[data-for="light"],
:root[data-theme="dark"] .theme-icon[data-for="dark"] { display: inline-flex; }
/* collapsed sidebar: an icon rail */
[data-nav="collapsed"] .shell { grid-template-columns: 58px minmax(0, 1fr); }
[data-nav="collapsed"] .nav { padding: 12px 8px; }
[data-nav="collapsed"] .nav .label,
[data-nav="collapsed"] .brand,
[data-nav="collapsed"] .who-details { display: none; }
[data-nav="collapsed"] .nav a, [data-nav="collapsed"] .nav-top { justify-content: center; }
[data-nav="collapsed"] .nav a { padding: 9px; }
[data-nav="collapsed"] .nav .section { font-size: 0; padding: 0; margin: 10px 6px; border-top: 1px solid var(--border); }
[data-nav="collapsed"] .nav .who { padding: 10px 0 4px; text-align: center; }
.nav-tip { position: fixed; z-index: 900; pointer-events: none; padding: 4px 9px; border-radius: 6px; background: var(--ink); color: var(--page); font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18); }
/* main fills whatever the sidebar leaves, so collapsing the rail hands its width straight to the content */
main { padding: 24px var(--gutter) 0; width: 100%; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.main-body, main > .footer { width: 100%; max-width: var(--content-max); margin-inline: auto; }
.main-body { flex: 1; padding-bottom: 32px; }
.footer { border-top: 1px solid var(--border); padding: 14px 0 18px; font-size: 12px; color: var(--muted); text-align: center; }
.center-page .footer { margin-top: 32px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-chart { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-chart > .card { margin-bottom: 0; }
.grid-chart + * { margin-top: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .label { font-size: 12px; color: var(--ink-2); }
.tile .value { font-size: 24px; font-weight: 650; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--ink-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.clip { max-width: clamp(240px, 30vw, 720px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* forms */
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 8px 16px 0 0; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--axis); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
textarea.prompt { min-height: 460px; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
/* forms stay at a comfortable field width even when the page is very wide */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; max-width: 1200px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.prompt-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
button, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--axis);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.link { border: none; background: none; padding: 0; color: var(--accent); font-weight: 500; }
button:disabled, button:disabled:hover { opacity: .45; cursor: not-allowed; background: var(--surface); filter: none; }
button.small-btn, .btn.small-btn { padding: 3px 10px; font-size: 12px; }
.actions.tight { margin: 0; }
.actions .spacer { flex: 1; }
form.inline { display: inline; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters select, .filters input { width: auto; }
.filters input[type=text], .filters input[type=search] { flex: 1 1 260px; max-width: 520px; }

/* flashes & badges */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid var(--border); }
.flash.ok { background: var(--good-bg); }
.flash.warn { background: var(--warn-bg); }
.flash.error { background: var(--bad-bg); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--surface-2); color: var(--accent); }

/* navigation: the location bar (back button + breadcrumbs) that opens every sub-page */
.locbar { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; min-height: 28px; margin: -4px 0 10px; }
.locbar .back { display: inline-flex; align-items: center; gap: 2px; padding: 3px 11px 3px 5px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.locbar .back svg { width: 16px; height: 16px; flex: none; transition: transform .18s cubic-bezier(.2, .8, .2, 1); }
.locbar .back:hover { background: var(--surface-2); border-color: var(--axis); color: var(--ink); text-decoration: none; }
.locbar .back:hover svg { transform: translateX(-2px); }
.locbar .pager { margin-left: auto; display: inline-flex; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); overflow: hidden; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.locbar .pager > * { padding: 3px 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.locbar .pager > * + * { border-left: 1px solid var(--border); }
.locbar .pager a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.locbar .pager .off { color: var(--axis); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin: 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); min-width: 0; }
.crumbs li { display: inline-flex; align-items: center; min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--axis); padding: 0 8px; }
.crumbs a { color: var(--ink-2); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; max-width: 48ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.subhead h2 { margin: 0; }

/* list pages: toolbar, bulk actions, selectable/sortable tables */
.intro { margin: 0; max-width: 760px; }
.strong { font-weight: 600; }
.error-text { color: var(--bad); }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 960px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--grid); }
.toolbar input[type=search] { flex: 1 1 280px; width: auto; padding: 7px 9px; border: 1px solid var(--axis); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; }
.toolbar select { width: auto; max-width: 280px; }
.toolbar [data-count-for] { margin-left: auto; white-space: nowrap; }
.bulkbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 14px; background: var(--surface-2); border-bottom: 1px solid var(--grid); }
.bulkbar [data-selected-count] { margin-right: 4px; }
.bulkbar label.inline { margin: 0 8px 0 0; }
.bulkbar button { padding: 4px 12px; font-size: 13px; }
.bulkbar select { width: auto; max-width: 260px; padding: 4px 8px; font-size: 13px; }
table.list th { position: sticky; top: 0; background: var(--surface); z-index: 1; white-space: nowrap; }
table.list th, table.list td { padding: 9px 12px; }
table.list tbody tr[data-row]:hover { background: var(--surface-2); }
table.list tr.is-added { opacity: .6; }
table.list th.check, table.list td.check { width: 36px; padding-right: 0; }
table.list input[type=checkbox] { width: 15px; height: 15px; margin: 2px 0 0; }
table.list td.empty { padding: 24px 12px; text-align: center; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: " ↕"; color: var(--axis); font-weight: 400; }
th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.clip-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: clamp(240px, 28vw, 640px); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; }
.empty-state { text-align: center; padding: 36px 16px; }
.empty-state .actions { justify-content: center; }
.catalog-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 14px; }

/* board picker (knowledge sources) */
.picker-summary { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; min-height: 28px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; }
.chip.warn { background: var(--warn-bg); border-color: var(--warn); }
.chip .id { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.chip button { padding: 0 6px; border: none; background: none; color: var(--ink-2); font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--bad); background: none; }
.picker-row { display: flex; gap: 8px; flex-wrap: wrap; }
.picker-row input { flex: 2 1 260px; width: auto; }
.picker-row select { flex: 1 1 220px; width: auto; }

/* role picker (bot account) */
.role-picker input[type=search] { width: 100%; padding: 7px 9px; border: 1px solid var(--axis); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; }
.role-picker .chips:empty { display: none; }
.role-picker .chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; background: var(--surface-2); color: var(--ink); font-size: 12.5px; }
.role-picker .chip .id { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.role-picker .picker-summary { margin: 8px 0; }
.role-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.role-group + .role-group { border-top: 1px solid var(--border); }
.role-group > summary { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; gap: 8px; margin: 0; padding: 8px 12px; background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 600; }
.role-group-count { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.role-group-count.has-selected { color: var(--accent); }
.role-row { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 7px 12px; font-weight: 400; cursor: pointer; }
.role-row:hover { background: var(--surface-2); }
.role-row input { flex: none; margin-top: 3px; }
.role-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.role-text .id { color: var(--muted); font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.role-list [data-role-empty] { margin: 0; padding: 16px 12px; text-align: center; }

/* tabs */
.tabs { position: relative; display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s ease, border-color .15s ease; }
.tabs a:hover { border-bottom-color: var(--axis); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* charts */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .grid.base { stroke: var(--axis); }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart rect:hover { opacity: .85; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin: 8px 0 0; padding: 0; list-style: none; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
details > summary { cursor: pointer; color: var(--accent); font-size: 12px; margin-top: 8px; }

.reply-preview { border: 1px solid var(--border); border-radius: 6px; padding: 12px 16px; background: var(--surface); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.center-page { max-width: 560px; margin: 8vh auto; padding: 0 16px; }

/* guided page tours (tour.js); everything is position: fixed, so the page layout never changes */
.tour-backdrop { position: fixed; inset: 0; z-index: 1000; background: transparent; }
.tour-spot { position: fixed; z-index: 1001; border-radius: 8px; pointer-events: none; box-shadow: 0 0 0 2px var(--accent), 0 0 0 200vmax rgba(0, 0, 0, 0.5); transition: left .2s ease, top .2s ease, width .2s ease, height .2s ease; }
.tour-spot[hidden] + .tour-pop { box-shadow: 0 0 0 200vmax rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.25); }
.tour-pop { position: fixed; z-index: 1002; width: 380px; display: flex; flex-direction: column; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25); }
.tour-pop:focus { outline: none; }
.tour-inner { overflow-y: auto; min-height: 0; }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.tour-skip { font-size: 12px; }
.tour-title { margin: 0 0 6px; font-size: 15px; }
.tour-body { color: var(--ink-2); font-size: 13.5px; }
.tour-body p { margin: 0 0 8px; }
.tour-body ul { margin: 0 0 8px; padding-left: 18px; }
.tour-body code { background: var(--surface-2); padding: 0 4px; border-radius: 4px; }
.tour-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.tour-dots { display: flex; gap: 4px; flex-wrap: wrap; margin-right: auto; min-width: 0; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--axis); }
.tour-dots i.on { background: var(--accent); }
.tour-arrow { position: absolute; width: 12px; height: 12px; background: var(--surface); border: 1px solid var(--border); transform: rotate(45deg); }
.tour-arrow[hidden] { display: none; }
.tour-arrow[data-side="bottom"] { top: -7px; margin-left: -6px; border-right: none; border-bottom: none; }
.tour-arrow[data-side="top"] { bottom: -7px; margin-left: -6px; border-left: none; border-top: none; }
.tour-arrow[data-side="right"] { left: -7px; margin-top: -6px; border-top: none; border-right: none; }
.tour-arrow[data-side="left"] { right: -7px; margin-top: -6px; border-bottom: none; border-left: none; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .shell, .locbar .back svg { transition: none; } }

@media (max-width: 900px) {
  .shell, [data-nav="collapsed"] .shell { grid-template-columns: 1fr; }
  .nav, [data-nav="collapsed"] .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 12px; border-right: none; border-bottom: 1px solid var(--border); }
  .nav-top { padding: 0; }
  [data-nav="collapsed"] .brand { display: block; }
  .nav-links { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
  [data-nav="collapsed"] .nav-links { display: none; }
  [data-nav="collapsed"] .nav .label { display: inline; }
  .nav .section, .nav .who { display: none; }
  main { padding: 16px 16px 0; }
  .toolbar [data-count-for] { margin-left: 0; }
  .grid-2, .grid-3, .grid-chart, .form-grid, .form-grid.cols-3, .prompt-grid { grid-template-columns: 1fr; }
  .filters input[type=text], .filters input[type=search] { max-width: none; }
  /* instance tabs: one row that scrolls sideways instead of wrapping into a second row */
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
  .tabs::-webkit-scrollbar { display: none; }
}
@media (max-width: 600px) {
  /* the back button already names the parent; the full trail would wrap over two lines */
  .locbar:has(.back) .crumbs { display: none; }
}

/* Grouped settings inside a form card (board escalation, bot texts). */
fieldset.subsection { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px 16px; margin: 16px 0 0; }
fieldset.subsection legend { font-weight: 600; padding: 0 6px; }

/* Moderator monitor: bucket tabs with counts. */
.buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 0 0 16px; }
.bucket { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); text-decoration: none; }
.bucket:hover { border-color: var(--axis); }
.bucket.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.bucket .n { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bucket .pct { color: var(--ink-2); font-size: 13px; margin-left: 6px; }
.bucket .label { color: var(--ink-2); font-size: 13px; }
.live { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; cursor: pointer; }
.live[hidden] { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip { display: inline-block; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 13px; color: var(--ink-2); text-decoration: none; background: var(--surface); }
.chip.active { border-color: var(--accent); color: var(--accent); }
.login-options { display: grid; gap: 12px; max-width: 360px; margin: 16px auto 0; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 0; }

/* Moderator monitor: outcome donuts per bot. */
.pies-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; }
.pies-head h2 { margin: 0; }
.pie-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2); }
.pie-legend span, .pie-stats li { display: flex; align-items: center; }
.pie-legend span i, .pie-stats li i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; flex: none; }
.pie-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-top: 12px; }
.pie { margin: 0; min-width: 0; }
.pie svg { max-width: 160px; margin: 8px auto; display: block; }
.pie-total { font-size: 22px; font-weight: 600; fill: var(--ink); font-variant-numeric: tabular-nums; }
.pie-stats { list-style: none; padding: 0; margin: 0; }
.pie-stats .num { float: right; font-variant-numeric: tabular-nums; margin-left: 8px; }
.pie-stats li { display: block; color: var(--ink-2); }
.pie-stats li i { vertical-align: -1px; }
.chart path:hover { opacity: .85; }
