/* =====================================================================
   AI Platform — admin layer over Pico CSS v2 (loaded in _Layout.cshtml).

   RULES:
     1. Spacing: --s-1..--s-4 (only 4 values — 4, 8, 12, 24).
     2. Font: --fs-tiny / --fs-base / --fs-h2 / --fs-h1 (only 4 values).
     3. Element sizes: --z-1..--z-4 (16, 24, 32, 56).
     4. Radii: --r-1, --r-2, --r-pill (only 3 values).
     5. Lines: --line-N (neutral) and --ok-line/--warn-line/--accent-line/
        --err-line (state). NO raw rgba() in component rules.
     6. Every BUTTON looks identical (Pico primary/secondary/contrast all
        overridden to the same outline). The .icon-btn is the only variant.
     7. Every TOGGLE shares ONE rule (.pill-toggle).
     8. Every LIST ROW (.list-item) shares ONE rule.
     9. Every PANEL (.surface), HEAD (.panel-head), FOOT (.panel-foot)
        share ONE rule each.
    10. Every UPPERCASE MINI-HEADING (.eyebrow) shares ONE rule.
    11. NO bespoke font-size, cursor, user-select, white-space on
        individual selectors.
   ===================================================================== */

/* ============== Pico variable overrides ============== */
/* Theme-NEUTRAL Pico size overrides — apply in both light and dark mode so
   the only visual difference between themes is colour, not spacing/font size. */
:root {
	--pico-border-radius: 4px;
	--pico-spacing: 0.75rem;
	--pico-typography-spacing-vertical: 0.75rem;
	--pico-form-element-spacing-vertical: 0.4rem;
	--pico-form-element-spacing-horizontal: 0.65rem;
	--pico-block-spacing-vertical: 0.85rem;
	--pico-block-spacing-horizontal: 1.1rem;
	--pico-font-size: 90%;
}

[data-theme="dark"] {
	--pico-background-color: #06080f;
	--pico-card-background-color: #0f1524;
	/* Inputs sit DEEPER than buttons (--bg-1 vs --bg-3) so the two never
	   visually merge on the same form. Buttons keep their --bg-3 surface
	   from the *-background overrides below. */
	--pico-form-element-background-color: #0b0f1a;
	/* All three button variants paint identically: dark surface bg (matches
	   the toggle off-state), subtle border, light text. Hover lifts to a
	   faint accent tint with full accent border. `*-inverse` is the TEXT
	   colour on the bg — Pico defaults it to dark, which made buttons
	   invisible against our dark surface. */
	--pico-primary-background:       #131a2c;  /* var(--bg-3) literal */
	--pico-primary-hover-background: rgba(56,189,248,0.12);
	--pico-primary-border:           rgba(148,163,184,0.18);
	--pico-primary-hover-border:     #38bdf8;
	--pico-primary-focus:            rgba(56,189,248,0.30);
	--pico-primary-inverse:          #b8c4d9;  /* var(--fg-1) — button text */
	--pico-primary:                  #38bdf8;  /* link colour stays accent  */
	--pico-primary-hover:            #38bdf8;
	--pico-secondary-background:       #131a2c;
	--pico-secondary-hover-background: rgba(56,189,248,0.12);
	--pico-secondary-border:           rgba(148,163,184,0.18);
	--pico-secondary-hover-border:     #38bdf8;
	--pico-secondary-focus:             rgba(56,189,248,0.30);
	--pico-secondary-inverse:           #b8c4d9;
	--pico-secondary:                   #b8c4d9;
	--pico-secondary-hover:             #38bdf8;
	--pico-contrast-background:        #131a2c;
	--pico-contrast-hover-background:  rgba(56,189,248,0.12);
	--pico-contrast-border:            rgba(148,163,184,0.18);
	--pico-contrast-hover-border:      #38bdf8;
	--pico-contrast-focus:             rgba(56,189,248,0.30);
	--pico-contrast-inverse:           #b8c4d9;
	--pico-contrast:                   #b8c4d9;
	--pico-contrast-hover:             #38bdf8;
}

/* ============== App tokens (single source of truth) ============== */
:root {
	/* Spacing — 4 values, multiples of 4. Drop one of these and pages start
	   collapsing visually; add more and they drift apart again.            */
	--s-1: 4px;   /* tight: inline gap between icon and label                */
	--s-2: 8px;   /* small: row gap, default flex gap                         */
	--s-3: 12px;  /* medium: cell padding, panel body padding (the "pad")    */
	--s-4: 24px;  /* large: page padding, section margins                    */
	/* Font sizes — 4 values */
	--fs-tiny: 12px;  /* meta, captions, mini-headings, footer               */
	--fs-base: 14px;  /* default body — usually inherited                    */
	--fs-h2:   16px;  /* subheadings, dialog titles                          */
	--fs-h1:   22px;  /* page title, login hero                              */
	/* Element heights/widths — 4 values, multiples of 4 (or 8)              */
	--z-1: 16px;  /* glyph: pill thumb, status dot, tile-status              */
	--z-2: 24px;  /* control: pill height (icon-btn auto-sizes from content) */
	--z-3: 32px;  /* avatar: brand mark, user avatar, dialog icon, pill width */
	--z-4: 56px;  /* hero: auth mark, textarea min-height, n8n orb           */
	/* Radii */
	--r-1: 4px; --r-2: 8px; --r-pill: 999px;
	--pad: var(--s-3);

	/* Surfaces / lines / text */
	--bg-1: #0b0f1a; --bg-2: #0f1524; --bg-3: #131a2c;
	--line-1:       rgba(148,163,184,0.10);
	--line-2:       rgba(148,163,184,0.18);
	--neutral-soft: rgba(148,163,184,0.06);
	--fg-0: #eef3fb; --fg-1: #b8c4d9; --fg-2: #7d8aa3; --fg-3: #5b6884;

	/* Accent + state — soft fill + matching line */
	--accent: #38bdf8; --accent-2: #a78bfa;
	--gradient-accent: linear-gradient(135deg, #38bdf8 0%, #a78bfa 100%);
	--gradient-on:     linear-gradient(135deg, #38bdf8 0%, #34d399 100%);
	--ok: #34d399; --warn: #fbbf24; --err: #f87171;
	--ok-soft:     rgba(52,211,153,0.13);   --ok-line:     rgba(52,211,153,0.30);
	--warn-soft:   rgba(251,191,36,0.13);   --warn-line:   rgba(251,191,36,0.30);
	--err-soft:    rgba(248,113,113,0.13);  --err-line:    rgba(248,113,113,0.45);
	--accent-soft: rgba(56,189,248,0.12);   --accent-line: rgba(56,189,248,0.30);
	--accent-glow: rgba(56,189,248,0.45);

	/* Brand mark (phyllotaxis "orchestration radiance" seed-head). Cyan core =
	   control plane, periwinkle = dispatched agents. See docs/plan/2026-06-24-logo-*.md.
	   The favicon/app-icon PNG+SVG assets in wwwroot are generated from the same
	   geometry (docs/media/source/build_final.py). */
	--brand-core: #3acdff; --brand-cyan: #49b8ed; --brand-agent: #897fd1; --brand-hi: #b6f3ff;

	/* Layout sizes */
	/* Sidebar autosizes to its widest nav row; this is just a floor so a
	   site with all-short labels doesn't collapse the panel uncomfortably. */
	--sidebar-w-min: 200px;
	/* Column min-widths for auto-fit content grids. Named after how many
	   columns of that size fit a 960px-class content row, so any grid using
	   `minmax(var(--col-N), 1fr)` collapses cleanly: --col-1 = full row,
	   --col-2 = 2-up, --col-3 = 3-up. Auto-fit lets the same grid expand to
	   4+ columns on a wide viewport and collapse to 1 on narrow without
	   per-page media queries. */
	--col-1: 960px;
	--col-2: 480px;
	--col-3: 320px;
	/* Cap for the widest single content card (edit modal panel etc.) — keeps
	   3-up grids readable on ultra-wide monitors. */
	--col-max: 1480px;
	/* Toggle pill — width is wider than height (~1.7:1) so the thumb has
	   travel room. Thumb diameter = pill height - 8 so it sits with 4px
	   inset on each side. Fixed proportion, not derived from --z-N. */
	--pill-h:     20px;
	--pill-w:     36px;
	--pill-thumb: 12px;
	--text-on-accent: #06080f;

	/* Opacity */
	--opacity-inactive: 0.5;
	--opacity-loading:  0.7;
	--opacity-disabled: 0.4;
	color-scheme: dark;
}

/* Light-theme overrides — only the colour tokens flip; spacing, fonts, sizes,
   radii are theme-neutral and stay defined in :root above. Accent alphas are
   bumped slightly higher than the dark-mode ones so the accent radial gradient
   on body, the soft pill backgrounds, and accent-tinted hovers remain visible
   against a near-white surface (low alpha + white = invisible). Triggered by
   the theme toggle (theme.js) writing data-theme="light" on <html>. */
/* A D2 diagram drawn in both themes (Diagrams/D2Renderer): the page shows the one that matches. It
   keeps its drawn size on screen, so its text stays readable, and a wide one scrolls sideways; on
   paper it shrinks to the page. */
.org-chart { overflow-x: auto; display: flex; justify-content: safe center; margin: 0; }
.org-chart svg { height: auto; }
@media print { .org-chart svg { max-width: 100%; } }
.org-chart a { cursor: pointer; text-decoration: none; }
.org-chart a:hover .shape > * { stroke-width: 3px; }
:root[data-theme="light"] .d2-dark, :root:not([data-theme="light"]) .d2-light { display: none; }
/* Office plan: a floor's desks and rooms drawn from its layout; fills come from the department. */
.office-plan { overflow-x: auto; margin: 0; }
.office-plan svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.office-plan figcaption { display: flex; flex-wrap: wrap; gap: var(--s-3); justify-content: center; margin-top: var(--s-2); }
.office-plan .plan-floor { fill: var(--bg-1); stroke: var(--line-2); }
.office-plan .plan-block { fill: var(--line-2); }
.office-plan .plan-area { fill: none; stroke: var(--fg-3); stroke-dasharray: 4 3; }
.office-plan .plan-room { fill-opacity: 0.18; stroke: var(--fg-2); }
.office-plan .plan-desk { fill-opacity: 0.85; stroke: var(--bg-1); }
.office-plan .plan-desk.hot { fill: none; stroke: var(--fg-2); stroke-dasharray: 3 2; }
.office-plan .closed { opacity: 0.35; }
.office-plan a { text-decoration: none; }
.office-plan .plan-desk-code { font-size: 11px; text-anchor: middle; fill: var(--fg-0); pointer-events: none; }
.office-plan .plan-code, .office-plan .plan-label { font-size: 12px; fill: var(--fg-2); pointer-events: none; }
.office-plan .plan-code { fill: var(--fg-1); }
.office-plan .plan-person { fill: var(--fg-0); stroke: var(--bg-1); }
.office-plan .plan-pad { fill: none; stroke: var(--accent); stroke-width: 2; }
.office-plan a:hover .plan-desk, .office-plan a:focus .plan-desk, .office-plan a:hover .plan-room { stroke: var(--accent); stroke-width: 2; }

:root[data-theme="light"] {
	--bg-1: #f5f7fb; --bg-2: #ffffff; --bg-3: #eef2f8;
	--line-1:       rgba(15,23,42,0.08);
	--line-2:       rgba(15,23,42,0.16);
	--neutral-soft: rgba(15,23,42,0.04);
	--fg-0: #0f172a; --fg-1: #1f2937; --fg-2: #475569; --fg-3: #64748b;
	--accent-soft: rgba(56,189,248,0.22);  --accent-line: rgba(56,189,248,0.45);
	--accent-glow: rgba(56,189,248,0.45);
	/* Brand mark — deeper inks so cyan/periwinkle clear WCAG 3:1 on near-white. */
	--brand-core: #0081cb; --brand-cyan: #007cb8; --brand-agent: #6156a3; --brand-hi: #78adca;
	--ok-soft:    rgba(16,185,129,0.18);   --ok-line:    rgba(16,185,129,0.45);
	--warn-soft:  rgba(217,119,6,0.18);    --warn-line:  rgba(217,119,6,0.45);
	--err: #dc2626;
	--err-soft:   rgba(220,38,38,0.16);    --err-line:   rgba(220,38,38,0.50);
	--text-on-accent: #ffffff;
	/* Pico light-mode surface overrides so the body radial gradients (cyan +
	   purple glows) actually paint against a slightly cooler-than-white base
	   instead of being washed out by Pico's default #ffffff. Inputs use a
	   slightly deeper grey (--bg-3 = #eef2f8) than the card (#ffffff) so the
	   form fields read as sunken next to buttons (which inherit white). */
	--pico-background-color: #f5f7fb;
	--pico-card-background-color: #ffffff;
	--pico-form-element-background-color: #eef2f8;
	color-scheme: light;
}

/* Theme toggle button — fixed top-right pill, present on both layouts.
   line-height:1 on both the button and the icon kills the baseline padding
   Font Awesome glyphs inherit (line-height defaults to ~1.5), which would
   otherwise push the glyph below the geometric centre even with grid
   place-items:center. */
.theme-toggle {
	position: fixed; top: var(--s-3); right: var(--s-3);
	width: var(--z-3); height: var(--z-3); border-radius: 50%;
	display: inline-grid; place-items: center;
	background: var(--bg-2); color: var(--fg-0);
	border: 1px solid var(--line-2); cursor: pointer; z-index: 50;
	padding: 0; line-height: 1;
}
.theme-toggle i { line-height: 1; font-size: 14px; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent-line); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* Pico's actual rule is `[type=button],[type=reset],[type=submit]
   { margin-bottom: var(--pico-spacing); }` — an attribute selector with
   specificity (0,1,0). A plain `button { margin: 0 }` has specificity
   (0,0,1) and loses. Match Pico's exact selectors AND add the type-less
   ones so every form control is reset.

   `vertical-align: middle` is the OTHER half of the fix: inline-level
   buttons (display: inline-grid / inline-block) default to baseline,
   which aligns them to surrounding text's baseline — not the table
   cell's middle. */
button,
[type=button], [type=reset], [type=submit],
input, select, textarea, fieldset {
	margin: 0;
	vertical-align: middle;
}
body {
	min-height: 100vh; font-size: var(--fs-base);
	background:
		radial-gradient(900px 500px at 12% -10%, var(--accent-soft), transparent 60%),
		radial-gradient(700px 400px at 90% -5%, rgba(167,139,250,0.08), transparent 60%),
		var(--pico-background-color);
}
.skip-link { position: absolute; left: -10000px; }
.skip-link:focus { left: var(--s-3); top: var(--s-2); padding: var(--s-2) var(--s-3); background: var(--bg-2); color: var(--fg-0); border-radius: var(--r-1); z-index: 1000; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ============== GRID UTILITIES ============== */
.grid-1-1                   { display: grid; grid-template-columns: 1fr 1fr; }
.grid-1-2                   { display: grid; grid-template-columns: 1fr 2fr; }
.grid-2-1                   { display: grid; grid-template-columns: 2fr 1fr; }
.grid-auto-1fr,
.app-dialog-body-wrap,
.edit-form > .field-bool   { display: grid; grid-template-columns: auto 1fr; }
.grid-1fr-auto,
.edit-modal-head, .app-dialog-head,
.chat-sessions-head, .link-picker-head,
.chat-composer             { display: grid; grid-template-columns: 1fr auto; }
.grid-min-1fr, body.app-shell, .chat-shell { display: grid; grid-template-columns: min-content 1fr; }
.grid-side-3                   { display: grid; grid-template-columns: auto 1fr auto; }
/* user-block: avatar | name | gear | logout (four columns, no wrap). */
.user-block                    { display: grid; grid-template-columns: auto 1fr auto auto; gap: var(--s-2); }
/* Second user-block line shown while impersonating: the ORIGINAL user +
   quit button. Slightly dimmed so the effective identity reads first. */
.user-impersonator             { margin-top: var(--s-1); opacity: .85; }
.grid-mid-3,  .link-picker-grid { display: grid; grid-template-columns: 1fr auto 1fr; }
.grid-rows-3,
.sidebar, .list-page,
.edit-modal-panel, .app-dialog-panel,
.chat-main, .link-picker { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.grid-rows-2t, .chat-sessions, .link-picker-side { display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.grid-rows-2b, body.app-shell > main { display: grid; grid-template-rows: 1fr auto; min-height: 0; }
.stack,
.brand-text, .user-meta,
.sidenav,
.edit-form > .field, .field-resource,
.auth-form, .auth-field,
.chat-stream, .chat-msg,
.link-picker-buttons, .help-doc-list,
.tree-branch { display: grid; grid-auto-rows: min-content; }
.row,
.actions, .toolbar,
.brand a, .nav-item,
.pager, .pager-nav,
.run-sync-form, .user-links,
.app-dialog-buttons,
.chat-action-head, .chat-action-buttons,
.link-picker-toolbar, .link-picker-actions {
	display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
}
.app-dialog-buttons, .edit-form > .actions, .link-picker-actions { justify-content: flex-end; }
.pager { justify-content: space-between; }

/* Buttons / submit inputs / .btn anchors inside action rows are intrinsic-
   width flex items. Pico's reset can leak `width: 100%` onto certain
   form children; this is the canonical override so an action row of
   `[Apply] [Discard]` never stretches to fill the page. */
.actions > button,
.pager-nav > button,
.actions > input[type="submit"],
.actions > input[type="button"],
.actions > a.btn,
.actions > .btn { width: auto; flex: 0 0 auto; }

/* Anchors used as buttons (`<a class="btn">`) — inherit Pico's button look
   without requiring `role="button"` on every callsite. Mirrors the variables
   Pico applies to <button>, so hover / focus stay consistent. */
a.btn {
	display: inline-block;
	padding: var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);
	background: var(--pico-primary-background);
	border: 1px solid var(--pico-primary-border);
	border-radius: var(--pico-border-radius);
	color: var(--pico-primary-inverse);
	line-height: var(--pico-line-height, 1.5);
	font-weight: var(--pico-font-weight, 400);
	text-align: center;
	text-decoration: none;
	cursor: pointer;
}
a.btn:hover, a.btn:focus {
	background: var(--pico-primary-hover-background);
	border-color: var(--pico-primary-hover-border);
	color: var(--pico-primary-inverse);
	text-decoration: none;
}

/* Chat conversation row title — truncate-with-ellipsis. Was an inline
   style on a <span>; now a real class so future renderers can drop it
   in without copy-pasting `style="overflow:..."`. */
.chat-session-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-session-title .meta { margin-left: var(--s-1); }

/* ============== VISUAL PRIMITIVES ============== */

/* SURFACE — every card / panel / list-body / map / msg / flash / hint */
.surface,
.card, section.card,
.list-page > .list-body, .pager,
.edit-modal-panel, .app-dialog-panel,
.chat-sessions, .chat-main, .link-picker-side,
.user-block, .chat-action, .chat-msg,
.flash, .auth-hint, .help-doc-list li {
	background: var(--bg-2);
	border: 1px solid var(--line-1);
	border-radius: var(--r-2);
}

/* PANEL HEAD / FOOT */
.panel-head,
.edit-modal-head, .app-dialog-head,
.chat-sessions-head, .chat-header, .link-picker-head {
	padding: var(--s-2) var(--s-3);
	border-bottom: 1px solid var(--line-1);
}
.panel-foot,
.edit-form > .actions,
.link-picker-actions,
.chat-composer {
	padding: var(--s-2) var(--s-3);
	border-top: 1px solid var(--line-1);
}

/* ICON-BTN — every small square icon button. Padding + aspect-ratio do the
   work: the glyph + padding sets the height, aspect-ratio: 1 forces a
   square. No fixed width/height — the button shrinks to its content. */
.icon-btn,
.btn-pencil,
.pager-btn, .link-picker-btn,
.edit-modal-close, .app-dialog-close,
.user-logout button {
	display: inline-grid; place-items: center;
	aspect-ratio: 1; padding: var(--s-1);
	background: transparent; color: var(--fg-2);
	border: 1px solid var(--line-2); border-radius: var(--r-1);
	cursor: pointer; line-height: 1;
	/* Several of these render as <a> (_RowLinkButton et al.) — kill the
	   browser/Pico link underline that would otherwise paint under the glyph. */
	text-decoration: none;
}
.icon-btn:hover, .btn-pencil:hover,
.pager-btn:hover:not(:disabled), .link-picker-btn:hover,
.edit-modal-close:hover {
	color: var(--accent); border-color: var(--accent-glow);
}
/* btn-danger — a destructive text button (<button> or a.btn). It sets the primary-* variables Pico's button rules
   and a.btn read on the element itself, so the danger colour wins at every state with no specificity contest: the
   dark theme's outline in the danger colour, the light theme's filled button in it. */
.btn-danger {
	--pico-primary-inverse: var(--err);
	--pico-primary-border: var(--err-line);
	--pico-primary-hover-border: var(--err);
	--pico-primary-hover-background: var(--err-soft);
	--pico-primary-focus: var(--err-soft);
}
[data-theme="light"] .btn-danger {
	--pico-primary-background: var(--err);
	--pico-primary-border: var(--err);
	--pico-primary-inverse: var(--text-on-accent);
	--pico-primary-hover-background: #b91c1c;
	--pico-primary-hover-border: #b91c1c;
}
.icon-btn-danger:hover, .btn-pencil-danger:hover,
.user-logout button:hover, .app-dialog-close:hover {
	color: var(--err); border-color: var(--err-line); background: var(--err-soft);
}

/* LIST-ITEM — every clickable list row */
.list-item,
.nav-item,
.link-picker-item,
.help-doc-list li {
	padding: var(--s-1) var(--s-2);
	border-radius: var(--r-1);
	color: var(--fg-1);
	cursor: pointer; -webkit-user-select: none; user-select: none;
	text-decoration: none;
	border: 1px solid transparent;
}
.list-item:hover,
.nav-item:hover,
.link-picker-item:hover,
.help-doc-list li:hover { background: var(--neutral-soft); color: var(--fg-0); }
.list-item.is-active,
.link-picker-item.is-selected,
.nav-item[aria-current="page"] {
	background: var(--accent-soft); color: var(--fg-0);
	border-color: var(--accent-line);
}

/* PILL-TOGGLE — filter-toggle AND on/off button share ONE rule */
.pill-toggle,
.filter-toggle-pill,
button.toggle-on, button.toggle-off {
	width: var(--pill-w); height: var(--pill-h); min-width: 0; padding: 0;
	border-radius: var(--r-pill); position: relative;
	background: var(--bg-3); border: 1px solid var(--line-2);
	color: transparent; font-size: 0; cursor: pointer; flex-shrink: 0;
}
.pill-toggle::after,
.filter-toggle-pill::after,
button.toggle-on::after, button.toggle-off::after {
	content: ""; position: absolute; top: 50%; transform: translateY(-50%);
	width: var(--pill-thumb); height: var(--pill-thumb); border-radius: 50%;
	background: var(--fg-2); left: 2px; transition: left 180ms ease;
}
.pill-toggle.is-on,
.filter-toggle-input:checked ~ .filter-toggle-pill,
button.toggle-on {
	background: var(--gradient-on); border-color: transparent;
}
.pill-toggle.is-on::after,
.filter-toggle-input:checked ~ .filter-toggle-pill::after,
button.toggle-on::after {
	left: calc(var(--pill-w) - var(--pill-thumb) - 2px);
	background: var(--text-on-accent);
}
.pill-toggle:hover,
.filter-toggle:hover .filter-toggle-pill,
button.toggle-on:hover, button.toggle-off:hover { filter: brightness(1.08); }
/* The checkbox stretches across the label as a transparent overlay so it has
   a real in-viewport hit box. Screen readers and Playwright.click() resolve
   the input directly; the visible focus ring still lands on the pill via the
   sibling selector below. Do not fold this into the generic .visually-hidden
   helper — that pattern must keep its offscreen clip for decorative labels. */
.filter-toggle { display: inline-flex; align-items: center; gap: var(--s-2); position: relative; }
.filter-toggle-input { position: absolute; inset: 0; width: auto; height: auto; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.filter-toggle-input:focus-visible ~ .filter-toggle-pill { outline: 2px solid var(--accent); outline-offset: 2px; }

/* DECISION BUTTONS — Accept / D1 / D7 / D30 / Suppress group on Work Items
   list rows, Board cards, and the Execution Plan panel. The button group stays
   on ONE line (controls never wrap); the row's wide .col-desc column absorbs
   width and wraps instead. */
.wi-decision-buttons { display: inline-flex; flex-wrap: nowrap; gap: var(--s-1); }
.wi-decision-buttons button {
	width: auto;
	margin: 0;
	padding: var(--s-1) var(--s-2);
	font-size: var(--fs-tiny);
	line-height: var(--z-1);
}

/* EYEBROW — every uppercase mini-heading. Sidebar sections, panel <h2>/<h3>,
   map band headings, chat-meta, brand-sub, edit-form field labels, etc. */
.eyebrow,
.sidenav-section,
.chat-sessions-head h2,
.link-picker-head h3,
.chat-meta, .brand-sub,
.edit-form > .field > label,
.auth-field label {
	font-size: var(--fs-tiny);
	font-weight: 600;
	color: var(--fg-2);
	letter-spacing: 0.12em;
	text-transform: uppercase;
	margin: 0;
}

/* A .field whose inputs are gated off by a master toggle (e.g. the
   "Sync from source branch" switch on the Vector Collection edit form). */
.edit-form > .field.is-disabled { opacity: 0.5; }

/* ============== Page shell ============== */
/* Scrollbars follow the theme (standard scrollbar-color, Chromium 121+ and
   Firefox): slate thumb from the fg token — flips with data-theme — and a
   transparent track so the bar sits directly on whichever surface scrolls.
   Set once on :root; the property inherits into every scroll container. */
:root { scrollbar-color: var(--fg-3) transparent; }
body.app-shell { height: 100dvh; overflow: hidden; }
/* Override the shared `min-content 1fr` track from .grid-min-1fr above:
   the sidebar must use `max-content` so the track sizes to the widest
   nowrap nav row exactly. With `min-content` and `overflow-x: hidden`,
   browsers can collapse the track below the row's natural width and
   clip the count badge at the right edge. */
body.app-shell {
	grid-template-columns: max-content 1fr;
	/* Full-width top header row above the sidebar+main row. */
	grid-template-rows: var(--topbar-h, 3.25rem) 1fr;
	grid-template-areas: "topbar topbar" "sidebar main";
}
body.app-shell.is-anonymous {
	grid-template-columns: 1fr;
	grid-template-areas: "topbar" "main";
}
body.app-shell > .topbar { grid-area: topbar; }
body.app-shell > .sidebar { grid-area: sidebar; }
body.app-shell > main { grid-area: main; min-width: 0; overflow: hidden; }
body.app-shell > main > .content { min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden; }
.content { padding: var(--s-3) var(--s-4) var(--s-2); }
.content.content-fill { overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.content.content-fill > * { flex: 0 0 auto; min-width: 0; }
.content.content-fill > form.link-picker { flex: 1 1 auto; min-height: 0; }

/* ============== Sidebar ============== */
.sidebar {
	/* No explicit width: the parent grid column is `min-content`, so the
	   sidebar takes the natural width of its widest nowrap nav row.
	   `overflow-x: hidden` is needed because `overflow-y: auto` on the
	   nested .sidenav implicitly turns on `overflow-x: auto` per spec, and
	   that would let stray content scroll horizontally and hide the count
	   badge behind the scrolled-out region. */
	min-width: var(--sidebar-w-min);
	overflow-x: hidden;
	/* Theme token, not a hardcoded gradient — must flip with the light theme,
	   and must equal --bg-1 exactly so the tree-line eraser (::after on the
	   last .tree-node, painted --bg-1) disappears into the background. */
	background: var(--bg-1);
	border-right: 1px solid var(--line-1);
	padding: var(--s-3) var(--s-2) var(--s-2); gap: var(--s-2);
}
/* Brand + user/auth moved to the global top bar, so the sidebar is just a
   head (label + collapse toggle) over the scrolling nav — two rows now. */
.sidebar { grid-template-rows: auto 1fr; }
/* `scrollbar-gutter: stable` reserves the vertical scrollbar's track. The sidebar
   column is `max-content` (sized to the widest nowrap row), so without a reserved
   gutter the scrollbar that appears when a subtree expands eats into the row and
   overlaps the right-aligned `.nav-count` badges (and the bar visibly "reduces" on
   expand). The reserved gutter is included in the max-content track, so the sidebar
   widens by the gutter instead — the scrollbar sits in it and the badges stay clear. */
.sidebar > .sidenav { min-height: 0; gap: var(--s-1); overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 0 var(--s-2) var(--s-2); margin-bottom: var(--s-1); border-bottom: 1px solid var(--line-1); }
.sidebar-head-label { font-size: var(--fs-tiny); text-transform: uppercase; letter-spacing: .06em; color: var(--fg-3); white-space: nowrap; }
:root.sidebar-collapsed-init .sidebar .sidebar-head-label,
.sidebar.is-collapsed .sidebar-head-label { display: none; }
.sidebar.is-collapsed .sidebar-head { justify-content: center; }
/* Brand seed-head mark: an inline SVG (topbar small ring, auth larger disc) whose
   circles are filled from the --brand-* tokens, so it flips with the theme. */
.brand-mark { width: var(--z-3); height: var(--z-3); display: inline-block; flex-shrink: 0; line-height: 0; }
.brand-mark svg, .auth-mark svg { width: 100%; height: 100%; display: block; }
.bm-core { fill: var(--brand-core); }
.bm-cyan { fill: var(--brand-cyan); }
.bm-peri { fill: var(--brand-agent); }
.bm-hi   { fill: var(--brand-hi); }

.sidenav-section { padding: var(--s-3) var(--s-2) var(--s-1); color: var(--fg-3); }
/* Sidebar nav rows: icon + label + count badge stay on a single line.
   The sidebar autosizes to the widest row, so labels never need to
   ellipsize — they always render in full. `flex: 1 1 auto` on the label
   span lets margin-left:auto on .nav-count push the badge to the right
   edge of the row when the row is wider than its content (every row
   except the widest one). */
.nav-item    { position: relative; flex-wrap: nowrap; }
.nav-item > span:not(.nav-count) { flex: 1 1 auto; white-space: nowrap; }
.nav-item .ico { width: var(--z-1); text-align: center; color: var(--fg-2); flex-shrink: 0; }
.nav-item:hover .ico { color: var(--accent); }
.nav-item-group { cursor: default; font-weight: 600; }
.nav-item-group:hover { background: transparent; color: var(--fg-1); }
.nav-item-group:hover .ico { color: var(--fg-2); }
.nav-item[data-depth="1"], .nav-item[data-depth="2"], .nav-item[data-depth="3"], .nav-item[data-depth="4"] { font-weight: 400; }
.nav-item[aria-current="page"] .ico { color: var(--accent); }
/* Dense tree rows: the shared .list-item padding is roomier than the sidebar
   needs. Zero vertical padding + control-height line box makes every row
   exactly --z-2 tall — the same height as the expander button, which also
   centers the tree connectors (drawn at top: var(--s-3) = half of --z-2). */
.sidenav .nav-item { padding-top: 0; padding-bottom: 0; line-height: var(--z-2); }

.tree-branch { position: relative; gap: 1px; padding-left: var(--s-3); border-left: 1px solid var(--line-2); }
.tree-node   { position: relative; }
/* Connector to the row's leftmost element. For leaf nodes that's .nav-item;
   for nodes with children the .tree-row wrapper sits there instead. */
.tree-branch > .tree-node > .nav-item::before,
.tree-branch > .tree-node > .tree-row::before { content: ""; position: absolute; left: -12px; top: var(--s-3); width: 8px; height: 1px; background: var(--line-2); z-index: 2; }
/* Leaf rows carry the expander-slot margin (--z-1) and the ::before is
   positioned relative to the .nav-item itself, so their connector must start
   --z-1 further left and run --z-1 longer to still reach the branch line —
   it bridges the empty expander slot and stops 4px short of the row, the
   same gap parent connectors leave before the chevron. */
.tree-branch > .tree-node > .nav-item::before {
	left: calc(-12px - var(--z-1));
	width: calc(8px + var(--z-1));
}
.tree-branch > .tree-node:last-child::after  { content: ""; position: absolute; left: -13px; top: var(--s-3); bottom: -1px; width: 2px; background: var(--bg-1); z-index: 1; }
/* When a tree branch is collapsed, sidebar.js sets `hidden` on it. The
   `[hidden]` attribute selector overrides the `display: grid` default
   from the .grid-auto-rows family above, which would otherwise win. */
[data-tree-branch][hidden] { display: none; }

/* Tree row: wraps a toggle chevron + the nav-item link/span for nodes that
   have children. Toggle chevron rotates 90° when the branch is collapsed
   so the affordance reads as "click to expand". */
.tree-row { display: flex; align-items: center; gap: 0; }
.tree-row > .nav-item { flex: 1 1 auto; min-width: 0; }
.tree-toggle {
	flex-shrink: 0;
	background: transparent; border: 0;
	color: var(--fg-2);
	padding: 0;
	margin: 0;
	cursor: pointer;
	border-radius: var(--r-1);
	display: inline-grid; place-items: center;
	/* Windows-Explorer geometry: the expander owns a fixed glyph-width slot
	   (--z-1) at the start of the row. Leaf rows reserve the same slot via
	   margin-left below, so icon + label start at the same x for every node
	   of a level — a parent no longer reads as the leaf's child. Height
	   stays --z-2 to keep a comfortable click target. */
	width: var(--z-1); height: var(--z-2);
}
/* Leaf rows (no .tree-row wrapper): reserve the expander slot so they align
   with sibling parent rows — both at top level (.sidenav direct children,
   including the static API/Help links) and inside branches (.tree-node). */
.sidenav > .nav-item,
.tree-node > .nav-item { margin-left: var(--z-1); }
.tree-toggle:hover { background: var(--neutral-soft); color: var(--fg-0); }
/* Inset focus ring: root-level toggles sit flush against the .sidenav clip
   edge (overflow-x: hidden), so Pico's outward focus box-shadow gets its
   left side cut off. Drawing the ring inside the button keeps it fully
   visible at every depth. */
.tree-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; box-shadow: none; }
.tree-toggle .ico { transition: transform 120ms ease; font-size: var(--fs-tiny); }
.tree-toggle[aria-expanded="false"] .ico { transform: rotate(-90deg); }

/* Count keeps its intrinsic width so the number isn't clipped when the
   row is tight; the label is the only flex-shrinkable child (it ellipsizes).
   Plain dim text, no pill container — the sidebar is max-content sized, so
   every pixel of badge chrome widens the whole panel. */
.nav-count { margin-left: auto; flex-shrink: 0; white-space: nowrap; font-size: var(--fs-tiny); font-variant-numeric: tabular-nums; color: var(--fg-2); }
.nav-count-warn { color: var(--warn); }

/* ============== Sidebar collapse toggle ============== */
/* Small chevron button at the right of the brand row. Persists via
   localStorage('sidebar.collapsed'); pre-FOUC handled by an inline head
   script that puts `.sidebar-collapsed-init` on <html>. */
.sidebar-toggle {
	background: transparent;
	color: var(--fg-2);
	border: 1px solid transparent;
	border-radius: var(--r-1);
	padding: var(--s-1) var(--s-2);
	margin: 0;
	cursor: pointer;
	display: inline-grid; place-items: center;
	width: var(--z-3); height: var(--z-3);
	flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--neutral-soft); color: var(--fg-0); }
.sidebar-toggle .ico { transition: transform 120ms ease; }

/* The brand row hosts both the link and the toggle; flex-justify them
   apart so the toggle hugs the right edge. */
.sidebar > .brand { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.sidebar > .brand > a { flex: 1 1 auto; min-width: 0; }

/* Collapsed state: only icons + avatar visible. Width auto-shrinks via the
   parent grid's `min-content` track to fit a single icon column. */
:root.sidebar-collapsed-init .sidebar,
.sidebar.is-collapsed {
	min-width: 0;
	max-width: none;
}
:root.sidebar-collapsed-init .sidebar .brand-text,
:root.sidebar-collapsed-init .sidebar .sidenav-section,
:root.sidebar-collapsed-init .sidebar .nav-item > span:not(.nav-count),
:root.sidebar-collapsed-init .sidebar .nav-count,
:root.sidebar-collapsed-init .sidebar .user-name,
:root.sidebar-collapsed-init .sidebar .tree-toggle,
:root.sidebar-collapsed-init .sidebar .tree-branch,
.sidebar.is-collapsed .brand-text,
.sidebar.is-collapsed .sidenav-section,
.sidebar.is-collapsed .nav-item > span:not(.nav-count),
.sidebar.is-collapsed .nav-count,
.sidebar.is-collapsed .user-name,
.sidebar.is-collapsed .tree-toggle,
.sidebar.is-collapsed .tree-branch { display: none; }
/* Icon-only mode: the expander slot is gone, so drop the matching leaf
   reservation or the remaining icons would sit 16px off-centre. */
:root.sidebar-collapsed-init .sidebar .sidenav > .nav-item,
:root.sidebar-collapsed-init .sidebar .tree-node > .nav-item,
.sidebar.is-collapsed .sidenav > .nav-item,
.sidebar.is-collapsed .tree-node > .nav-item { margin-left: 0; }
/* In the collapsed state the user block degrades to a single-column
   icon stack so avatar / settings / logout still fit on one icon-wide
   sidebar without overflowing. */
:root.sidebar-collapsed-init .sidebar .user-block,
.sidebar.is-collapsed .user-block { grid-template-columns: 1fr; justify-items: center; gap: var(--s-1); }
/* Toggle chevron flips when collapsed so the affordance reads as
   "click to expand". */
.sidebar.is-collapsed .sidebar-toggle .ico { transform: rotate(180deg); }

.user-block { align-items: center; padding: var(--s-2); }
.user-avatar { width: var(--z-3); height: var(--z-3); border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; color: var(--text-on-accent); background: var(--gradient-accent); }
.user-meta   { min-width: 0; }
.user-name   { color: var(--fg-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============== .card alias ============== */
.card, section.card, form.card { padding: var(--pad); margin-bottom: var(--s-3); }
form.card { max-width: 24rem; }

/* ============== List page ============== */
/* On content-fill the list takes the height that is left and only its rows scroll. A window too short for that keeps
   the list body's minimum and scrolls the content instead. */
.content.content-fill > .list-page { flex: 1 0 auto; }
.content.content-fill > .list-page > .list-body { contain: size; min-height: 12rem; }
.list-page > .list-body { min-height: 0; overflow: auto; }
.list-page > .list-body > table { border: 0; margin: 0; }
.list-page > .list-body > table thead th { position: sticky; top: 0; z-index: 1; background: var(--bg-2); box-shadow: inset 0 -1px 0 var(--line-2); }
.list-page > .list-body > table th, .list-page > .list-body > table td { white-space: nowrap; }
.list-page > .list-body > table th.col-desc, .list-page > .list-body > table td.col-desc { white-space: normal; }
table.list { width: 100%; }
table.list th.col-desc, table.list td.col-desc { width: 100%; }
/* A row that expands in place (details in its free-text cell) drops Pico's block margin, so its summary lines up with the row. */
table.list td.col-desc > details { margin-bottom: 0; }
th.col-spacer, td.col-spacer { width: 100%; padding: 0; }

.pager { padding: var(--s-2) var(--s-3); margin-top: var(--s-2); gap: var(--s-3); }
.pager-info, .pager-page { color: var(--fg-2); font-size: var(--fs-tiny); white-space: nowrap; }
/* Pager controls wrap at narrow widths while each label stays with its select. */
.pager-nav { gap: var(--s-1); margin: 0; padding: 0; flex-wrap: wrap; align-items: center; }
/* Per-page selector inside the pager — compact, label sits flush with the select. */
.pager-page-size { display: inline-flex; align-items: center; gap: var(--s-1); margin: 0 var(--s-2) 0 0; font-size: var(--fs-tiny); color: var(--fg-2); white-space: nowrap; }
/* width: auto sizes to the longest option label; padding-right reserves
   room for Pico's dropdown chevron so digits don't slide under it. */
.pager-page-size select { margin: 0; padding: 2px 1.6em 2px var(--s-1); font-size: var(--fs-tiny); height: auto; min-width: 0; width: auto; }
.pager-btn  { font-size: var(--fs-tiny); }
.pager-btn:disabled { opacity: var(--opacity-disabled); }

/* ============== Toolbar — children stay at intrinsic width ============== */
.toolbar { padding: var(--s-2) var(--s-3); gap: var(--s-3); margin-bottom: var(--s-2); }
.toolbar-group { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin: 0; }
.toolbar-group > label,
.toolbar-group > select,
.toolbar-group > input,
.toolbar-group > button,
.toolbar-group > .filter-toggle { width: auto; max-width: none; margin: 0; }
.toolbar-group > select,
.toolbar-group > input { min-width: 8rem; max-width: 16rem; }
.toolbar-group > label { color: var(--fg-2); white-space: nowrap; }
.toolbar-grouped {
	align-items: start;
	gap: var(--s-2) var(--s-3);
}
.toolbar-grouped > .toolbar-group {
	min-inline-size: 0;
	max-inline-size: 100%;
	align-items: end;
}
.toolbar-grouped > .toolbar-filter {
	flex-basis: 100%;
	padding-bottom: var(--s-2);
	border-bottom: 1px solid var(--line-1);
}
.toolbar-grouped > fieldset.toolbar-group {
	width: auto;
	padding: 0 var(--s-2) var(--s-2);
}
.toolbar-grouped legend {
	width: auto;
	margin: 0;
	padding-inline: var(--s-1);
	font-size: var(--fs-tiny);
	color: var(--fg-2);
}
.toolbar-grouped fieldset > .toolbar-group { align-items: end; max-inline-size: 100%; }
.toolbar-grouped fieldset > form.toolbar-group { min-inline-size: 0; }
.toolbar-grouped fieldset > .meta {
	flex-basis: 100%;
	contain: inline-size;
}
.toolbar-grouped fieldset:has(.flash) { max-inline-size: min(100%, 40rem); }
.toolbar-grouped .field {
	display: grid;
	gap: var(--s-1);
	min-inline-size: 0;
	max-inline-size: min(100%, 14rem);
}
.toolbar-grouped .toolbar-filter .field { min-inline-size: min(100%, 8rem); }
.toolbar-grouped .field > label { margin: 0; color: var(--fg-2); }
.toolbar-grouped .field input,
.toolbar-grouped .field select { width: 100%; min-width: 0; margin: 0; }
.toolbar-grouped .toolbar-sync .field { flex-basis: 8rem; }
.toolbar-grouped .toolbar-sync .field-wide {
	flex-basis: auto;
	max-inline-size: min(100%, 40rem);
}
.toolbar-grouped .toolbar-sync .field-wide select { inline-size: auto; max-inline-size: 100%; }

/* Shared search box (_SearchBox): the Clear (×) is overlaid INSIDE the input's
   right edge so toggling it never shifts Apply or the other toolbar controls.
   The wrapper shrink-wraps the input, and the input keeps the SAME auto-width +
   8–16rem clamp the bare toolbar input had, so dropping in the wrapper doesn't
   change the toolbar's flow/wrapping. */
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box > input { width: auto; min-width: 8rem; max-width: 16rem; margin: 0; padding-right: 1.7rem; }
.search-clear {
	position: absolute; right: var(--s-1); top: 0; bottom: 0;
	display: inline-flex; align-items: center; justify-content: center;
	width: 1.3rem; padding: 0; border: 0; background: none;
	color: var(--fg-2); text-decoration: none; cursor: pointer;
}
.search-clear:hover { color: var(--fg-1); }

/* Action columns — every cell that contains an icon button (Edit pencil,
   Manage, Delete) or a toggle. Center the control horizontally and let
   <td>'s native vertical-align: middle handle the vertical axis. */
.col-edit, .col-toggle, td.col-edit, td.col-toggle { text-align: center; }
.col-edit  { width: var(--z-3); }   /* 32 — narrow column for one icon-btn  */
.col-toggle { width: var(--z-4); }  /* 56 — wider column for the pill toggle */
.btn-pencil i { font-size: var(--fs-tiny); }

/* Row "open" trigger — the Id rendered as a link that opens the row's Edit
   page (or read-only Details report) in the shared modal. Replaces the old
   dedicated Edit/View column: the Id itself is the affordance. */
.id-link { font-variant-numeric: tabular-nums; cursor: pointer; }

/* External redirect link — points off-site to the source provider (a PR or
   work-item page) and opens a new tab. The entity prefix (PR/WI) + trailing ↗
   glyph mark it as LEAVING the app, distinct from a local .id-link that opens
   an in-app modal. */
.ext-link i { font-size: 0.85em; opacity: 0.7; margin-left: 2px; }

/* Country flag + code cell. Used by _CountryFlag.cshtml in any list
   that shows a CountryA2 column. The <img> is sized identically to
   the alpha-2 <code> so a row of mixed countries lines up cleanly,
   and `onerror` hides the box silently when /flags/xx.svg returns
   404 (our XL/XE/XB/XH private-network sentinels have no flag). */
.country-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.country-flag {
	width: 20px; height: 15px;
	border: 1px solid var(--line-2, rgba(255,255,255,0.06));
	border-radius: 2px;
	object-fit: cover;
	vertical-align: middle;
	flex: 0 0 auto;
}
.country-code { font-family: var(--font-mono); }

/* Meta / side-info column — dim only the TEXT colour of "context path"
   cells (org/project path, parent breadcrumbs). Background, borders, and
   adjacent cells stay full strength; child <a> / <code> inherit the dim
   colour so the whole path reads as secondary. */
.col-meta, td.col-meta { color: var(--fg-3); }
.col-meta a, .col-meta code { color: inherit; }

/* ============== Edit form — responsive auto-fit grid ==============
   Fields auto-pack into columns: minimum 220px per cell, more columns
   as the viewport widens. Bool toggles, action rows, and any field
   marked .field-wide span the full row. Single utility, zero markup
   classes per page beyond .field / .field-bool / .field-wide. */
.edit-form {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(var(--col-2), 1fr));
	gap: var(--s-3);
	align-items: start;
}
form.card.edit-form { overflow: visible; max-width: none; }
.edit-form > .field { gap: var(--s-1); }
/* Span full row: explicit .field-wide, bool toggles, action rows, section
   headings with their notes, AND any field that contains a textarea (no
   markup change needed). */
.edit-form > .field-wide,
.edit-form > .field-bool,
.edit-form > .actions,
.edit-form > :is(h2, h3, p),
.edit-form > .field:has(textarea) { grid-column: 1 / -1; }
.edit-form > .field-bool { display: flex; align-items: center; gap: var(--s-2); }
.edit-form textarea { min-height: var(--z-4); resize: vertical; }
/* Repository Filters page: 4 multiline textareas in a 2-up grid, full row.
   Lifts each .field out of the auto-fit textarea-spans-row default so the
   four filter buckets sit side-by-side on wide viewports and stack on
   narrow ones. */
.edit-form > .filter-grid { grid-column: 1 / -1; }
.filter-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(var(--col-3), 1fr));
	gap: var(--s-3);
}
.filter-grid > .field { gap: var(--s-1); }
form.inline { display: inline; margin: 0; vertical-align: middle; }

/* ============== Resource-backed field row ============== */
/* Container for a set of .field-resource rows. One column when narrow, as many as
   fit when wide — no breakpoints: repeat(auto-fit, minmax()) derives the count from
   the space available, so it stays right at any zoom, font size or sidebar state.
   A settings form is mostly short values, and one field per full-width row wastes
   most of a wide screen.
   The 22rem floor is the width at which a label, its help text and the
   input+Save+Reset row stop wrapping awkwardly; below that a second column would be
   worse than one. */
.field-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
	gap: 0 var(--s-4);
	align-items: start;
}
/* A textarea in a third of a wide screen is unusable, so json fields take the whole
   row whatever the column count. */
.field-grid > [data-valuetype="json"], .field-grid > [data-valuetype="text"] { grid-column: 1 / -1; }

.field-resource { gap: var(--s-1); padding: var(--s-3) 0; border-bottom: 1px dashed var(--line-1); }
.field-resource:last-child { border-bottom: 0; }
/* In a grid the dashed rule reads as a divider between COLUMNS rather than between
   fields, and :last-child only clears the final cell. The column gap already
   separates them, so the rule is dropped in grid mode. */
.field-grid > .field-resource { border-bottom: 0; }
.field-resource > label { color: var(--fg-0); font-weight: 600; }
.field-resource textarea { min-height: var(--z-4); resize: vertical; }
.field-resource > .meta { margin: 0; color: var(--fg-2); font-size: var(--fs-tiny); }
.field-resource > .actions { margin-top: var(--s-1); }
/* Compact input row: input/textarea flexes to fill; Save+Reset hug the right.
   The bool variant uses the same row so the toggle+description sits inline
   with its action buttons rather than stacking. flex-wrap lets the buttons
   drop below on narrow viewports without overflowing the card. */
.field-resource > .field-row {
	display: flex; gap: var(--s-2); align-items: stretch; flex-wrap: wrap;
}
.field-resource > .field-row > input,
.field-resource > .field-row > textarea { flex: 1 1 16rem; min-width: 0; }
.field-resource > .field-row > .filter-toggle { flex: 1 1 auto; }
.field-resource > .field-row > .actions { margin-top: 0; flex-shrink: 0; align-items: center; }

/* ============== Modal panels ============== */
.edit-modal, .app-dialog { position: fixed; inset: 0; display: grid; place-items: start center; padding: 6vh var(--s-3) var(--s-3); }
.edit-modal { z-index: 100; }
.app-dialog { z-index: 200; padding-top: 14vh; }
.edit-modal[hidden], .app-dialog[hidden] { display: none !important; }
.edit-modal-overlay, .app-dialog-overlay { position: absolute; inset: 0; background: rgba(7,11,22,0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }

.edit-modal-panel { position: relative; width: 100%; max-width: var(--col-max); max-height: calc(100dvh - 12vh); }
.app-dialog-panel { position: relative; width: 100%; min-width: 320px; max-width: 480px; }
.edit-modal-head h2, .app-dialog-head h2 { margin: 0; font-size: var(--fs-h2); font-weight: 600; }

.edit-modal-body { padding: var(--pad); overflow-y: auto; min-height: 0; }
.edit-modal-body .card { box-shadow: none; border: 0; padding: 0; max-width: none !important; }
.edit-modal-status { padding: 0 var(--pad) var(--s-2); font-size: var(--fs-tiny); min-height: var(--z-1); }
.edit-modal-status.is-err { color: var(--err); }
.edit-modal-status.is-ok  { color: var(--ok); }
.edit-modal-status:empty  { display: none; }

.app-dialog-body-wrap { align-items: start; gap: var(--s-3); padding: var(--pad); }
.app-dialog-body { margin: 0; white-space: pre-line; }
.app-dialog-icon { width: var(--z-3); height: var(--z-3); border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; border: 1px solid currentColor; }
.app-dialog-icon-info     { color: var(--accent); background: var(--accent-soft); }
.app-dialog-icon-info::before     { content: 'i'; font-style: italic; font-family: serif; }
.app-dialog-icon-question { color: var(--accent); background: var(--accent-soft); }
.app-dialog-icon-question::before { content: '?'; }
.app-dialog-icon-warning  { color: var(--warn); background: var(--warn-soft); }
.app-dialog-icon-warning::before  { content: '!'; }
.app-dialog-icon-error    { color: var(--err); background: var(--err-soft); }
.app-dialog-icon-error::before    { content: '\00D7'; line-height: 1; }
.app-dialog-icon-success  { color: var(--ok); background: var(--ok-soft); }
.app-dialog-icon-success::before  { content: '\2713'; }
.app-dialog-buttons { padding: var(--s-2) var(--pad) var(--pad); gap: var(--s-2); }
.app-dialog-input-wrap { padding: 0 var(--pad); }
.app-dialog-input { width: 100%; }

/* ============== Status badges ============== */
.badge { display: inline-flex; align-items: center; vertical-align: middle; padding: 2px var(--s-2); border-radius: var(--r-pill); font-size: var(--fs-tiny); font-weight: 500; border: 1px solid transparent; }
/* -pass / -ok are synonyms; -fail / -err are synonyms. One rule per state. */
.badge-pass, .badge-ok    { color: var(--ok);     background: var(--ok-soft);     border-color: var(--ok-line); }
.badge-fail, .badge-err   { color: var(--err);    background: var(--err-soft);    border-color: var(--err-line); }
.badge-warn               { color: var(--warn);   background: var(--warn-soft);   border-color: var(--warn-line); }
.badge-on                 { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.badge-off, .badge-loading{ color: var(--fg-2);   background: var(--line-1);      border-color: var(--line-2); }
.badge-loading            { font-style: italic; }
/* Assignee chip — shared by Board card, Work Items list, Pull Requests list, Jobs list.
   AI members get the accent tint + a robot icon; humans get the neutral off-tint.
   Reuses badge tokens (r-pill, fs-tiny) so it stays visually consistent with .badge. */
.member-chip { display: inline-flex; align-items: center; gap: var(--s-1); padding: 2px var(--s-2); border-radius: var(--r-pill); font-size: var(--fs-tiny); font-weight: 500; border: 1px solid transparent; max-width: 14rem; }
.member-chip-human { color: var(--fg-1); background: var(--line-1);      border-color: var(--line-2); }
.member-chip-ai    { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.member-chip-name  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Inline stuck/error affordance — the "No Silent Stops" rule. Presence = parked/erroring;
   colour = severity; title/aria-label = reason + resume action. See _StatusIcon.cshtml. */
.status-icon       { vertical-align: middle; margin-left: var(--s-1); cursor: help; }
.status-icon-info  { color: var(--accent); }
.status-icon-warn  { color: var(--warn); }
.status-icon-err   { color: var(--err); }
/* When the icon opens a deep link (FixUrl present), _StatusIcon.cshtml wraps it in <a class="status-icon-link">.
   Drop Pico's default link styling so the anchor keeps the icon-only variant's cursor: help hint and only
   brightens the glyph on hover/focus — a link masquerading as a status indicator, not a text link. */
.status-icon-link  { text-decoration: none; cursor: help; display: inline-flex; align-items: center; }
.status-icon-link:hover .status-icon,
.status-icon-link:focus-visible .status-icon { filter: brightness(1.15); }
/* Live-agent activity chip (issue #190) — presence = an Agents.Job row is
   queued/running against this row's target (work item card or PR row). Same
   three-state colour vocabulary the Board station dots use so the eye reads
   them as one system: approval=warn, queued=accent-outlined, running=accent-
   filled with a pulsing icon. Shared partial: Pages/Shared/_JobActivityChip.cshtml. */
/* No border. It is a link, so it behaves like one -- underline on hover -- rather than
   a boxed widget whose outline changes colour. A bordered box that also underlines is
   two affordances for one behaviour, and the border competed with the state tint it
   sat next to. */
/* The pill's look is .member-chip-ai. This adds only link behaviour, so there is no
   second background, radius or border to keep in step with the shared chip.
   The shared 14rem cap is sized for a name alone; this pill also carries the model and
   the task, so it lifts the cap and stays on one line rather than clipping the name to
   "Evo Jocy..." and wrapping the task. */
.job-activity { text-decoration: none; max-width: none; white-space: nowrap; }
.job-activity:hover { text-decoration: underline; }
.job-activity-state { font-weight: 600; }
.job-activity-mode  { color: var(--fg-1); }
.job-activity-sep   { color: var(--fg-3); }
/* The agent is a .member-chip now -- no separate agent styling to keep in step. */
.job-activity-cli   { color: var(--fg-1); font-weight: 600; text-transform: uppercase; font-size: 0.85em; letter-spacing: 0.03em; }
/* Approval carries ONE indicator: the tint. The border stays neutral and the icon
   does not pulse -- awaiting a human is a resting state, not activity, and the card
   already says so in its sentence and its buttons. */

/* ============== KPI grid (schema-landing dashboards) ============== */
/* auto-fit grid of headline tiles. Each tile is a small .card variant
   with an oversized number. Supports both <a class="kpi"> (clickable,
   navigates to the detail page) and <div class="kpi"> (read-only). */
.kpi-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: var(--s-3);
	margin-bottom: var(--s-4);
}
.kpi {
	display: block;
	padding: var(--s-3);
	background: var(--surface-1);
	border: 1px solid var(--line-1);
	border-radius: var(--r-md);
	color: var(--fg-1);
	text-decoration: none;
	transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
a.kpi:hover {
	border-color: var(--accent-line);
	background: var(--accent-soft);
	transform: translateY(-1px);
}
.kpi-warn { border-color: var(--warn-line); background: var(--warn-soft); }
.kpi-label { font-size: var(--fs-tiny); color: var(--fg-2); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: var(--s-1); }
.kpi-value { font-size: 28px; font-weight: 600; color: var(--fg-0); line-height: 1.1; }
.kpi-suffix { font-size: var(--fs-tiny); color: var(--fg-2); font-weight: 400; margin-left: 2px; }

/* ============== Run-sync ============== */
.run-sync-form { gap: var(--s-2); margin: 0; }
.run-sync-btn:disabled { cursor: progress; opacity: var(--opacity-loading); }
/* aria-busy announces the in-flight sync to assistive tech. Drop Pico's own
   ::before loading glyph on .run-sync-btn: the shared _RunSyncButton already
   renders the .chat-dots spinner (this avoids a duplicate), and the classic
   Members submit button conveys busy via its "Syncing…" label plus the
   role="status" progress panel. */
.run-sync-btn[aria-busy="true"]::before { display: none; }
.run-sync-status { font-size: var(--fs-tiny); }
.run-sync-ok  { color: var(--ok); }
.run-sync-err { color: var(--err); }
/* Scheduler-state suffix inside the run-pass button — carries the "(M:SS)"
   countdown to the next automatic run (Board only; webhook-only buttons on
   other pages omit the element). Colours: default = dim, disabled = warn
   (a suspended scheduler must not look like a pending one), due = accent so
   the eye lands on the button that is about to fire. */
.run-sync-schedule { margin-left: 0.35em; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.run-sync-schedule-off { color: var(--warn); }
.run-sync-schedule .time-countdown-due { color: var(--accent); }

/* ============== Crumb / flash / footer ============== */
.crumb { color: var(--fg-2); font-size: var(--fs-tiny); margin-bottom: var(--s-2); }
.crumb a { color: var(--fg-1); }
.flash { padding: var(--s-2) var(--s-3); margin-bottom: var(--s-3); }
.flash-ok   { background: var(--ok-soft);     color: var(--ok);     border-color: var(--ok-line); }
.flash-err  { background: var(--err-soft);    color: var(--err);    border-color: var(--err-line); }
.flash-info { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.meta { color: var(--fg-2); font-size: var(--fs-tiny); }

/* Transient highlight applied by focus-field.js when a page is opened with
   ?focus=<id> — draws the eye to the field the operator (or an AI agent) must
   change. Removed after ~2.5s. Motion only when the user allows it. */
.focus-flash {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	border-radius: 2px;
}
@media (prefers-reduced-motion: no-preference) {
	.focus-flash { animation: focusFlash 2.5s ease-out; }
	@keyframes focusFlash {
		0%   { box-shadow: 0 0 0 0 var(--accent-soft); background-color: var(--accent-soft); }
		100% { box-shadow: 0 0 0 12px transparent;     background-color: transparent; }
	}
}

footer { padding: var(--s-3) var(--s-4); color: var(--fg-3); font-size: var(--fs-tiny); border-top: 1px solid var(--line-1); }
footer a { color: var(--fg-2); }

/* ============== Auth page ============== */
/* Atmosphere: the body's two radial gradients (cyan top-left + violet
   top-right) give the colour; the shell's ::before adds only a neutral
   line grid that fades out toward the edges. No extra coloured or blurred
   layer — translucent cyan + violet stacked again mix into muddy mid-tones. */
.auth-shell { min-height: 100vh; display: grid; place-items: center; align-content: center; grid-auto-rows: min-content; padding: var(--s-4) var(--s-3); gap: var(--s-3); justify-items: center; position: relative; isolation: isolate; }
.auth-shell::before {
	content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
	background:
		linear-gradient(var(--line-1) 1px, transparent 1px) 0 0 / calc(var(--s-4) * 4) calc(var(--s-4) * 4),
		linear-gradient(90deg, var(--line-1) 1px, transparent 1px) 0 0 / calc(var(--s-4) * 4) calc(var(--s-4) * 4),
		linear-gradient(var(--neutral-soft) 1px, transparent 1px) 0 0 / var(--s-4) var(--s-4),
		linear-gradient(90deg, var(--neutral-soft) 1px, transparent 1px) 0 0 / var(--s-4) var(--s-4);
	-webkit-mask: radial-gradient(ellipse at center, #000 20%, transparent 75%);
	mask: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}
/* The auth pages now carry the global top bar; subtract its height so the card
   stays centered in the remaining space instead of overflowing the viewport. */
.auth-body .auth-shell { min-height: calc(100dvh - var(--topbar-h, 3.25rem)); }
.auth-card  {
	width: 100%; max-width: 420px;
	background: var(--bg-2);
	border: 1px solid var(--line-2);
	border-radius: var(--r-2);
	position: relative;
	box-shadow:
		0 1px 0 rgba(255,255,255,0.04) inset,
		0 0 0 1px var(--accent-soft) inset,
		0 24px 64px -24px rgba(0,0,0,0.55),
		0 0 80px -20px var(--accent-glow);
}
.auth-card::before {
	content: ""; position: absolute; inset: -1px; border-radius: inherit;
	padding: 1px; pointer-events: none;
	background: linear-gradient(135deg, var(--accent-line), transparent 40%, transparent 60%, rgba(167,139,250,0.30));
	-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	-webkit-mask-composite: xor; mask-composite: exclude;
	opacity: 0.6;
}
:root[data-theme="light"] .auth-card {
	box-shadow:
		0 1px 0 rgba(255,255,255,0.6) inset,
		0 0 0 1px var(--accent-soft) inset,
		0 20px 50px -20px rgba(15,23,42,0.18),
		0 0 60px -10px var(--accent-glow);
}
/* Window title bar: auth-window.js moves the card by dragging it. */
.auth-window-head {
	display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
	white-space: nowrap;
	background: var(--bg-1);
	border-radius: var(--r-2) var(--r-2) 0 0;
	font-size: var(--fs-tiny); text-transform: uppercase; letter-spacing: 0.08em;
	color: var(--fg-2);
	cursor: move; user-select: none; touch-action: none;
}
.auth-window-title .fa-solid { color: var(--accent); }
.auth-window-state-warn { color: var(--warn); }
.auth-window-body { padding: var(--s-4); }
.auth-hero  { text-align: center; margin-bottom: var(--s-3); }
.auth-mark  {
	display: inline-block; line-height: 0;
	width: var(--z-4); height: var(--z-4);
	margin-bottom: var(--s-3);
	filter: drop-shadow(0 12px 26px var(--accent-glow));
}
.auth-title { margin: 0 0 var(--s-1); font-size: var(--fs-h1); background: var(--gradient-accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-subtitle { color: var(--fg-2); margin: 0; }
.auth-form  { gap: var(--s-3); margin: 0 0 var(--s-3); }
.auth-field { gap: var(--s-1); margin: 0; }
.auth-submit {
	width: 100%;
	background: var(--gradient-accent); border: 0;
	color: var(--text-on-accent); font-weight: 600;
	box-shadow: 0 8px 24px -8px var(--accent-glow);
}
.auth-submit:hover { filter: brightness(1.08); box-shadow: 0 10px 28px -8px var(--accent-glow); }
.auth-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.auth-hint   { padding: var(--s-2) var(--s-3); font-size: var(--fs-tiny); }
/* External provider sign-in buttons (rendered per enabled [Security].[AuthProvider] row). */
.auth-external { display: flex; flex-direction: column; gap: var(--s-2); margin: 0 0 var(--s-3); }
.auth-external-divider { text-align: center; padding: 0; margin: 0; color: var(--fg-3); }
.auth-external-form { margin: 0; }
.auth-external-btn {
	background: var(--bg-1);
	color: var(--fg-1);
	border: 1px solid var(--line-2);
	box-shadow: none;
}
.auth-external-btn:hover { filter: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.auth-features { padding: var(--s-3) 0 0; margin: 0; list-style: none; border-top: 1px solid var(--line-1); }
.auth-features li { list-style: none; padding: var(--s-1) 0; font-size: var(--fs-tiny); color: var(--fg-2); }
.auth-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: var(--s-2); background: var(--gradient-accent); box-shadow: 0 0 8px var(--accent-glow); vertical-align: middle; }
/* Window status bar: the bottom edge of the auth card. */
.auth-footer { color: var(--fg-3); font-size: var(--fs-tiny); text-align: center; background: var(--bg-1); border-radius: 0 0 var(--r-2) var(--r-2); }
.auth-footer a { color: var(--fg-2); }

/* ============== Error page ============== */
.error-page { max-width: 720px; margin: 0 auto; padding: var(--s-4); }
.error-page p { color: var(--fg-1); }
.error-token code { background: var(--bg-1); padding: 2px var(--s-2); border-radius: var(--r-1); font-size: var(--fs-base); border: 1px solid var(--line-2); color: var(--accent); }
.error-blob, .error-stack { margin-top: var(--s-3); }
.error-blob summary, .error-stack summary { cursor: pointer; color: var(--fg-2); font-size: var(--fs-tiny); padding: var(--s-1) 0; }
.error-blob textarea { width: 100%; font-family: monospace; font-size: var(--fs-tiny); background: var(--bg-1); color: var(--fg-1); border: 1px solid var(--line-2); border-radius: var(--r-1); padding: var(--s-2); resize: vertical; }
.error-stack pre { background: var(--bg-1); color: var(--fg-1); border: 1px solid var(--line-2); border-radius: var(--r-1); padding: var(--s-3); overflow: auto; font-size: var(--fs-tiny); }

/* ============== Chat ============== */
/* Chat fills the bounded main region; the session list and message stream own
   their scrolling instead of extending the page past the footer. */
.content.content-fill > .chat-shell { flex: 1 1 auto; min-height: 0; }
.chat-shell {
	grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
	gap: var(--s-3);
	height: auto;
	min-height: 0;
}
.chat-sessions { width: auto; min-width: 0; }
.chat-sessions .list-body { min-height: 0; overflow: auto; }
.chat-sessions table.list { table-layout: fixed; }
.chat-sessions table.list :is(th, td).col-edit { padding-inline: 0; }
/* The conversation list uses the standard <table class="list"> shape now;
   the only chat-specific bit is making the rows feel clickable (the
   table cells that wrap the title trigger openSession on click). */
.chat-sessions table.list tr { cursor: pointer; }
.chat-sessions table.list tr.is-active { background: var(--accent-soft); }
.chat-sessions table.list tr:hover    { background: var(--neutral-soft); }
.chat-sessions table.list tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.chat-header h1 { font-size: var(--fs-h2); margin: 0 0 var(--s-1); }
.chat-stream    { min-height: 0; overflow-y: auto; padding: var(--s-3); gap: var(--s-3); align-content: start; }
/* Messages span the full stream width; the stream is a grid (justify-items
   stretch), so a row fills its column on its own — role is conveyed by the
   background tint, not by width/side. (No max-width cap, and no align-self:
   in a grid align-self is the vertical axis, so it never aligned sideways.) */
.chat-msg       { gap: var(--s-1); padding: var(--s-3); }
.chat-msg-user      { background: var(--accent-soft); border-color: var(--accent-line); }
/* assistant uses the base card background (--bg-2) from the shared rule above */
.chat-msg-system    { background: var(--neutral-soft); }
.chat-content { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.chat-action  { margin-top: var(--s-2); padding: var(--s-3); }
.chat-action-summary { color: var(--fg-1); font-size: var(--fs-tiny); margin-bottom: var(--s-2); }
.chat-action details pre { background: var(--bg-1); padding: var(--s-2); border-radius: var(--r-1); overflow: auto; margin: 0; }
.chat-action-status  { color: var(--fg-2); font-size: var(--fs-tiny); margin-top: var(--s-1); }
.chat-composer  { gap: var(--s-2); }
.chat-composer textarea { resize: vertical; max-width: none; min-height: var(--z-3); max-height: 200px; }
.chat-thinking .chat-content { color: var(--fg-2); }
.chat-dots   { display: inline-flex; gap: 3px; }
.chat-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--fg-2); animation: chat-dot 1.4s infinite; }
.chat-dots i:nth-child(2) { animation-delay: 0.2s; }
.chat-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (max-width: 860px) {
	.chat-shell { grid-template-columns: 1fr; height: auto; }
	.chat-sessions { width: auto; max-height: 200px; }
}

/* ============== Link picker ============== */
.link-picker         { margin: 0 0 var(--s-3); }
.link-picker-toolbar { margin: 0 0 var(--s-3); }
.link-picker-filter  { flex: 1 1 auto; max-width: 420px; }
.link-picker-grid    { min-height: 0; gap: var(--s-3); align-items: stretch; }
.link-picker-side    { overflow: hidden; }
.link-picker-count   { color: var(--fg-2); font-size: var(--fs-tiny); background: var(--line-1); border: 1px solid var(--line-2); border-radius: var(--r-pill); padding: 0 var(--s-2); }
.link-picker-list    { list-style: none; margin: 0; padding: var(--s-1); min-height: 0; overflow-y: auto; gap: var(--s-1); display: grid; grid-auto-rows: min-content; }
.link-picker-list:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.link-picker-list.is-drop-target { background: var(--accent-soft); }
.link-picker-item { gap: var(--s-2); cursor: grab; }
.link-picker-item.is-hidden { display: none; }
.link-picker-item:active { cursor: grabbing; }
.link-picker-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; }
/* Country picker: "zone" entries (private network ranges modelled as
   ISO 3166 X-prefixed fake countries — XL Local, XE Enterprise, XB
   Business, XH Home) get a network icon and a small "zone" tag so the
   admin can distinguish them from real countries. */
.country-picker-zone-icon { width: 20px; text-align: center; color: var(--accent); flex-shrink: 0; }
.country-picker-zone-tag {
	flex-shrink: 0;
	font-size: var(--fs-tiny);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--accent);
	background: var(--accent-soft);
	border: 1px solid var(--accent-line);
	border-radius: var(--r-pill);
	padding: 0 var(--s-2);
}
.link-picker-item.is-zone { border-color: var(--accent-line); }
.link-picker-buttons { gap: var(--s-1); align-self: center; padding: 0 var(--s-1); }
.link-picker-btn i { font-size: var(--fs-base); }
.link-picker-payload { display: none; }
.link-picker-actions { margin-top: var(--s-3); }
@media (max-width: 720px) {
	.link-picker { min-height: calc(100dvh - 160px); }
	.link-picker-grid { grid-template-columns: 1fr; }
	.link-picker-buttons { grid-auto-flow: column; justify-content: center; padding: var(--s-1) 0; }
}

/* ============== Help docs ============== */
.help-doc-list { list-style: none; padding: 0; margin: 0; gap: var(--s-3); }
.help-doc-list li { padding: var(--s-3); }
.help-doc-title { display: inline-block; font-weight: 600; color: var(--fg-0); margin-bottom: var(--s-1); }
.help-doc-desc  { color: var(--fg-1); font-size: var(--fs-tiny); margin: var(--s-1) 0; }
.doc-header     { padding-bottom: var(--s-3); margin-bottom: var(--s-3); border-bottom: 1px solid var(--line-1); }

/* ============== Narrow viewports ============== */
@media (max-width: 860px) {
	body.app-shell {
		/* minmax(0, ...): the open tree's widest nowrap row never widens the page past the screen. */
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: auto auto 1fr;
		grid-template-areas: "topbar" "sidebar" "main";
		height: auto; overflow: visible;
	}
	body.app-shell.is-anonymous {
		grid-template-rows: auto 1fr;
		grid-template-areas: "topbar" "main";
	}
	/* Narrow viewport: the sidebar spans the row under the top bar, and its tree stays a
	   vertical tree, closed until the sidebar toggle opens it (.nav-open, as the top bar's
	   menu opens), so the page's content starts at the top of the screen. */
	.sidebar { min-width: 0; max-width: none; padding: var(--s-2) var(--s-3); border-right: 0; border-bottom: 1px solid var(--line-1); }
	.sidebar-head { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
	.sidebar > .sidenav { display: none; }
	.sidebar.nav-open > .sidenav { display: grid; max-height: 70dvh; overflow-y: auto; padding-top: var(--s-2); }
	/* Rows a finger taps reliably: a pill and a half high rather than the desktop's one pill. */
	.sidebar.nav-open .sidenav .nav-item { line-height: calc(var(--z-2) * 1.75); }
	.sidebar-toggle .ico { transform: rotate(-90deg); }
	.sidebar.nav-open .sidebar-toggle .ico { transform: rotate(90deg); }
	.content { padding: var(--s-3); }
	/* A list's filter form lays its fields out as label | field rows, so a label never ends one line and its field starts
	   the next. A label that wraps its own control (page size, a filter toggle) and every other child (Apply, a search
	   box with no label) take a whole row. */
	form.toolbar-group { display: grid; grid-template-columns: max-content minmax(0, 1fr); }
	form.toolbar-group > * { grid-column: 1 / -1; }
	form.toolbar-group > label:not(.visually-hidden, :has(input, select, textarea)) { grid-column: 1; }
	form.toolbar-group > label:not(.visually-hidden, :has(input, select, textarea)) + * { grid-column: 2; max-width: none; }
	body.app-shell > main { display: block; overflow: visible; }
	body.app-shell .content { overflow: visible; }
	.content.content-fill { overflow: visible; display: block; }
	.content.content-fill > form.link-picker { flex: none; }
}
@media (max-width: 860px) {
	.list-page { display: block; }
	.content.content-fill > .list-page > .list-body { contain: none; min-height: 0; }
	/* overflow-x stays auto: a table wider than the viewport must scroll
	   inside the list body. */
	.list-page > .list-body { overflow-x: auto; border: 0; background: transparent; }
	.list-page > .list-body > table thead th { position: static; }
}

/* Two-line row wrap fires on the actual list-body width, not the viewport: the
   sidebar can eat ~280px of the viewport on wider screens, so a viewport media
   query mistimes the wrap (a 1200px viewport with an expanded sidebar still has
   only ~620px of list-body). Container queries are baseline since 2023.
   The @media block above keeps the sticky-thead / overflow reset it always had. */
.list-page > .list-body { container-type: inline-size; container-name: list-body; }
/* The list page is a container too, so the tiers below can strip the
   list-body surface whenever rows are in card mode: bg-2 cards on the
   bg-2 list-body surface would melt together — cards must sit directly
   on the page background, exactly like Board cards. (A size query cannot
   style its own container, hence this second, outer container. Thresholds
   are the wrap tiers + 2px of list-body border.) */
.list-page { container-type: inline-size; container-name: list-page; }
/* Card-mode mirror content lives inside the row markup but only renders in
   card (wrap) mode — the table mode shows the same values in their own
   columns instead: header tag badges, the #number title prefix, and the
   AI-proposal reason text beside the decision buttons. */
table.list .card-head-tags,
table.list .card-head-num,
table.list .card-proposal-text,
table.list .col-meta-label { display: none; }
@container list-page (max-width: 622px) {
	.list-page > .list-body { background: transparent; border: 0; }
}
@container list-page (max-width: 2402px) {
	.list-page > .list-body:has(> table.list-wide) { background: transparent; border: 0; }
}

/* Two wrap tiers arm the flag; the style() block below applies the wrap.
   Tier 1 (620px, every list): the canonical short admin lists only overflow
   once the body is genuinely narrow.
   Tier 2 (2400px, tables marked .list-wide — Work Items and Pull Requests
   with source, action and activity columns): they overflow most screens,
   so they wrap whenever the body is narrower than the table needs; keep the
   tier roughly at the widest .list-wide table's natural width.
   The flag lives on the <table> and inherits, so the style() query reads it
   from any row/cell's nearest ancestor. The table's own display:block must
   ride the size tiers directly (a style() query cannot style the element
   the flag is set on) — left as display:table, the table wraps the flex
   rows in anonymous cells and sizes itself to intrinsic content width, so
   the rows and cell caps could never resolve against the container.
   Browsers with size queries but no style() queries (e.g. Firefox ESR)
   simply keep the one-row table with its horizontal scroll. */
@container list-body (max-width: 620px) {
	table.list { --list-wrap: on; display: block; width: 100%; }
}
@container list-body (max-width: 2400px) {
	table.list.list-wide { --list-wrap: on; display: block; width: 100%; }
}

@container style(--list-wrap: on) {
	/* Each row becomes a wrapping flex line: narrow cells (Id / toggles /
	   edit icons / dates / status) flow left-to-right at their natural width
	   and wrap onto further lines as the container tightens; the greedy
	   .col-desc cell takes a full line of its own, so no data column ever
	   falls off the right edge. The row stays ONE <tr> so :hover /
	   bulk-select / any tr:nth-child alternation still groups the lines as
	   one item. Header row hides the .col-desc <th> — the description needs
	   no label. Flex, not auto-fit grid: intrinsic-width cells wrapping is
	   one-dimensional flow, and repeat(auto-fit, ...) requires a real
	   minimum track size — with minmax(0, max-content) the tracks collapse
	   to slivers and the max-content cells overprint each other. */
	table.list > thead,
	table.list > tbody { display: block; width: 100%; }
	table.list > thead > tr,
	table.list > tbody > tr {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: var(--s-1) var(--s-2);
	}
	/* Empty-state rows use <td colspan="N"> for a full-row placeholder. The
	   colspan attribute has no effect on a flex item, so span the whole line
	   explicitly instead. */
	table.list > tbody > tr > td[colspan] {
		flex: 1 1 100%;
	}
	/* Every cell shows its FULL content in wrap mode — nothing may be
	   clipped, ellipsized, or pushed out of view. Long free-text cells
	   (e.g. a PR title alone on its wrap line) break onto further lines;
	   overflow-wrap covers unbroken tokens like branch names and URLs.
	   Short cells hit no break point and stay single-line. The selector
	   mirrors the base `.list-page > .list-body > table td` nowrap rule —
	   anything shorter loses the specificity contest and the cells keep
	   refusing to wrap. */
	.list-page > .list-body > table.list > tbody > tr > td {
		max-width: 100%;
		white-space: normal;
		overflow-wrap: anywhere;
	}
	table.list > thead > tr > th.col-desc,
	table.list > tbody > tr > td.col-desc {
		flex: 1 1 100%;
		white-space: normal;
		width: auto;
		padding-left: 0;
	}
	/* Column labels carry no meaning once cells wrap at per-item widths —
	   hide every text-only header cell (including .col-desc). Header cells
	   hosting real controls (select-all trio, bulk delete) stay. */
	table.list > thead > tr > th:not(:has(button, input, select, a, label)) { display: none; }
	/* col-spacer is a slack-absorber column that's only useful when the row is
	   laid out as a table. In the wrap mode it just adds a gap — hide it so
	   the remaining cells pack tightly at the row's natural width. */
	table.list > thead > tr > th.col-spacer,
	table.list > tbody > tr > td.col-spacer { display: none; }
	/* Cells lose their table chrome — striped backgrounds, cell borders,
	   roomy cell padding, sticky headers. Inside a wrapped item those read
	   as dozens of floating boxes (and a sticky transparent header would
	   float over the cards). Spacing comes from the row's flex gap. */
	.list-page > .list-body > table.list :is(th, td) {
		background: transparent;
		border: 0;
		padding: 0;
		position: static;
	}
	/* Each item is a card with the Board's exact .wi-card recipe: bg-2
	   surface on the page background, line-1 border, r-2 radius, s-2/s-3
	   padding, s-1 internal row gap, s-3 between cards. */
	table.list > tbody > tr {
		background: var(--bg-2);
		border: 1px solid var(--line-1);
		border-radius: var(--r-2);
		padding: var(--s-2) var(--s-3);
		margin-bottom: var(--s-3);
	}
	/* Board-card anatomy inside each item: TITLE BAND first, data in the
	   middle, ACTIONS bottom-right — the eye reads top-left to bottom-right
	   and the final decision sits where reading ends. The band replicates
	   .wi-card-title exactly: bg-3 tint bleeding edge-to-edge over the card
	   padding via matching negative margins, line-2 underline, top corners
	   rounded to the card radius, base-size medium-weight text, and the
	   item's tag badges pushed to the band's right edge. */
	.list-page > .list-body > table.list > tbody > tr > td.col-desc {
		order: -1;
		font-size: var(--fs-base);
		font-weight: 500;
		line-height: 1.3;
		margin: calc(var(--s-2) * -1) calc(var(--s-3) * -1) 0;
		/* A flex item's 100% basis does not include the bled margins (a
		   block's width:auto would): without the extra 2×s-3 the band paints
		   100% starting 12px left and stops 12px short of the card's right
		   edge. The max-width override beats the generic 100% cell cap. */
		flex: 0 0 calc(100% + var(--s-3) * 2);
		max-width: calc(100% + var(--s-3) * 2);
		padding: var(--s-2) var(--s-3);
		background: var(--bg-3);
		border-bottom: 1px solid var(--line-2);
		border-radius: var(--r-2) var(--r-2) 0 0;
		display: flex;
		align-items: baseline;
		gap: var(--s-1) var(--s-2);
		flex-wrap: wrap;
	}
	/* Band = title + badges ONLY (Board rule): the reason preview moves to
	   the proposal row beside the decision buttons; the "(draft)" title
	   suffix becomes a band badge. */
	table.list > tbody > tr > td.col-desc .meta,
	table.list > tbody > tr > td.col-desc .card-title-draft { display: none; }
	table.list > tbody > tr > td.col-desc .card-head-num { display: inline; }
	/* Basis 0 so the title PACKS on line one with the badges and then grows
	   — with basis auto a long title's natural width fills the line and the
	   badges drop below the band's first line instead of anchoring
	   top-right. The title text wraps inside its own item. */
	table.list > tbody > tr > td.col-desc > .card-title-text { flex: 1 1 0; min-width: 0; }
	table.list > tbody > tr > td.col-desc > .card-head-tags {
		display: inline-flex;
		gap: var(--s-1);
		flex-wrap: wrap;
		margin-left: auto;
	}
	/* Provider states arrive lowercase ("completed"); band badges read as
	   labels, so normalize casing the way the Board's hand-written badges
	   appear. */
	table.list > tbody > tr > td.col-desc > .card-head-tags .badge { text-transform: capitalize; }
	/* Cells whose value is mirrored into the band tags hide here — the tag
	   would otherwise appear twice on the card. */
	table.list > tbody > tr > td.col-tag { display: none; }
	/* Dates read as "last changed" — order them to the end of the data
	   lines so Work Items and Pull Requests share one content grammar. */
	table.list > tbody > tr > td:has(time) { order: 50; }
	/* Context-path cells (.col-meta: provider / project / repo, branches)
	   become their own full-width meta line — the Board's stacked-meta
	   grammar — instead of towering inside the data line and pushing the
	   date onto an orphan line. Same slot on every list. */
	table.list > tbody > tr > td.col-meta { order: 60; flex: 1 1 100%; }
	table.list .col-meta-label { display: inline; color: var(--fg-2); }
	/* Empty-value placeholder dashes are table furniture; in card mode they
	   are pure noise between real values. */
	table.list > tbody > tr .dash-empty { display: none; }
	/* The next-action cell stacks its badge over a caption with <br> for
	   the table; on a card line the stack breaks the row baseline — flow it
	   inline instead. */
	table.list > tbody > tr > td:has([data-testid^="pr-next-"]) br { display: none; }
	table.list > tbody > tr > td:has([data-testid^="pr-next-"]) small { margin-left: var(--s-1); }
	/* <small> inside cards must not drop below the tiny size — branch refs
	   and captions were shrinking to ~10px and failing contrast. */
	table.list > tbody > tr > td small { font-size: var(--fs-tiny); }
	/* Full-width break before the action group: without it the first action
	   cell can stay on the data line (pushed right) while the rest wrap to
	   the next line packed left — a scattered mess. The break guarantees the
	   actions form ONE bottom row. */
	table.list > tbody > tr::before {
		content: "";
		order: 98;
		flex-basis: 100%;
	}
	/* Bottom row = the Board's proposal row: reason text left, decision
	   buttons pushed right, icon actions after them. The decision cell
	   stretches to own the line; icon cells trail it. */
	/* flex-basis 0 (not auto): in a wrapping flex container, line packing
	   uses base sizes — with basis auto the reason text's natural width
	   forces the trailing icon buttons onto their own line; with basis 0
	   the cell packs WITH the icons and then grows into the slack, so the
	   bottom row never shears its control group. */
	table.list > tbody > tr > td:has(.wi-decision-buttons, .card-proposal-text) {
		order: 99;
		flex: 1 1 0;
		min-width: 0;
		display: flex;
		align-items: center;
		gap: var(--s-2);
	}
	table.list > tbody > tr > td:has(.wi-decision-buttons, .card-proposal-text) .card-proposal-text {
		display: inline-block;
		flex: 1 1 auto;
		min-width: 0;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	table.list > tbody > tr > td:has(.wi-decision-buttons, .card-proposal-text) .wi-decision-buttons {
		margin-left: auto;
		flex-shrink: 0;
	}
	table.list > tbody > tr > td.col-edit {
		order: 100;
		margin-left: auto;
	}
	/* Cells after the first of the bottom row sit snug at the buttons' own
	   s-1 rhythm (the tr column-gap is s-2; the negative margin nets s-1). */
	table.list > tbody > tr > td:is(.col-edit, :has(.wi-decision-buttons, .card-proposal-text))
		~ td.col-edit {
		margin-left: calc(var(--s-1) - var(--s-2));
	}
	/* One control metric for every card action — the Board normalizes all
	   card buttons to the decision-button size (s-1/s-2 padding, tiny font,
	   z-1 line box = 26px). Without this the icon buttons (Queue / Delete)
	   render 32px tall against the 26px text buttons. Icon buttons keep
	   square proportions via their own aspect-ratio and equal padding. */
	table.list > tbody > tr > td:is(.col-edit, :has(.wi-decision-buttons)) :is(button, .btn) {
		padding: var(--s-1) var(--s-2);
		font-size: var(--fs-tiny);
		line-height: var(--z-1);
		margin: 0;
		width: auto;
	}
	table.list > tbody > tr > td.col-edit .btn-pencil { aspect-ratio: auto; }
	table.list > tbody > tr > td.col-edit .btn-pencil i { line-height: var(--z-1); }
}

/* Layout-only resets for <ai-enum-flags> / <ai-enum-flags-dropdown> wrappers:
   vertical stack via grid, nested groups get a single design-token indent.
   width:100% so the parent .field grid column expands to the form's width
   (otherwise the column auto-sizes to the widest pill and sibling .meta
   text wraps narrow). */
fieldset[data-flag-set] { border: 0; padding: 0; margin: 0; display: grid; gap: var(--s-1); min-width: 0; width: 100%; }
fieldset[data-flag-set] > fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: var(--s-1); min-width: 0; }
details[data-flag-set] > *:not(summary) { display: grid; gap: var(--s-1); }

/* Inheritance mode — Allow / Deny / Permission table. A real <table> beats
   CSS Grid here because the pill labels are inline-flex inside an outer
   fieldset that's already a grid; table columns align unconditionally.
   Pico CSS sets `td, th { padding: 0.5rem 1rem }` by default which would
   otherwise eat into the pill columns — every cell-padding rule below is
   qualified to override Pico's element-level rule. */
fieldset[data-flag-set].enum-flags-grid .enum-flags-table {
    width: 100%; border-collapse: collapse; table-layout: fixed;
}
/* Pill column comfortably wider than the pill itself so cell padding can
   never push the pill out of its column. (pill 36px + 2 × 8px gap + slack.) */
.enum-flags-col-pill { width: 64px; }
/* Default cells: padding + reset borders. NOTE no white-space rule here —
   the Permission name (the widest, most-likely-to-wrap content) must be
   free to wrap. Pill cells get nowrap via the .enum-flags-col-pill-cell
   class below; thead labels are short enough to fit naturally. */
fieldset[data-flag-set].enum-flags-grid .enum-flags-table thead th,
fieldset[data-flag-set].enum-flags-grid .enum-flags-table tbody td,
fieldset[data-flag-set].enum-flags-grid .enum-flags-table tbody th {
    padding: var(--s-1) var(--s-2); vertical-align: middle;
    border: 0; background: transparent;
}
/* Keep the two narrow pill columns nowrap — they hold only a 36px toggle
   each, wrapping them would push the pill onto two visual rows. */
fieldset[data-flag-set].enum-flags-grid .enum-flags-table .enum-flags-col-pill-cell {
    white-space: nowrap;
}
fieldset[data-flag-set].enum-flags-grid .enum-flags-table thead th {
    font-size: var(--fs-tiny); text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--fg-2); font-weight: 500; text-align: left;
    padding-bottom: var(--s-1);
}
/* Caption is the "Inherited from <link>" header — visible block above the
   thead, set into the table block so it scrolls with the table and inherits
   its column width. */
fieldset[data-flag-set].enum-flags-grid .enum-flags-table > caption.enum-flags-caption {
    caption-side: top; text-align: left;
    padding: 0 var(--s-2) var(--s-1);
    color: var(--fg-2); font-size: var(--fs-tiny);
}
fieldset[data-flag-set].enum-flags-grid .enum-flags-table .enum-flags-group th {
    padding-top: var(--s-3); padding-bottom: var(--s-1);
    font-weight: 500; text-align: left;
}
.enum-flags-name { font-size: var(--fs-base); }
/* Greyed + non-interactive look for inherited (disabled) pills.
   pointer-events: none on the whole label blocks every click path:
   - clicking the label can't toggle the (also-disabled) input
   - clicking the pill span can't bubble up to the label
   The DOUBLE block is intentional — `disabled` alone leaves browsers free
   to highlight the pill on hover, which reads as "clickable". */
.filter-toggle.is-inherited {
    opacity: 0.5; cursor: not-allowed; pointer-events: none;
}
.filter-toggle.is-inherited .filter-toggle-pill { filter: grayscale(0.6); }

/* ============== Agent inspect header (Agents/Inspect) ============== */
/* The <dl> header had no rule, so it fell back to block layout — every label
   and value on its own line, wasting vertical space. Lay it out as compact
   label:value pairs; two pairs per row once there's width for them. */
.meta-grid {
    display: grid; grid-template-columns: max-content minmax(0, 1fr);
    gap: var(--s-1) var(--s-3); align-items: baseline; margin: 0 0 var(--s-3);
}
@media (min-width: 720px) {
    .meta-grid {
        grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr);
        column-gap: var(--s-4);
    }
}
.meta-grid dt { color: var(--fg-2); font-size: var(--fs-tiny); white-space: nowrap; }
.meta-grid dd { margin: 0; min-width: 0; }

/* ============== Agent log (Agents/Inspect) ============== */
/* The Inspect "Formatted" view reuses the .chat-* / .chat-action / .badge
   styles above so every agent (OpenAI Codex, Claude Code, future Gemini) reads
   like the /Agents/Chat stream. /js/agent-log.js normalises each agent's JSONL
   onto shared entry types; only the extras below aren't already covered. */
.alog-stream {
    display: flex; flex-direction: column; gap: var(--s-3);
    max-height: 70vh; overflow: auto;
    padding: var(--s-3); background: var(--bg-1); border-radius: var(--r-1);
}
/* Reasoning: a collapsed, dimmed action card (.chat-action gives the frame). */
.chat-reason details > summary { cursor: pointer; color: var(--fg-2); font-size: var(--fs-tiny); }
.chat-reason pre {
    color: var(--fg-2); font-style: italic; margin: var(--s-2) 0 0;
    background: var(--bg-1); padding: var(--s-2); border-radius: var(--r-1);
    white-space: pre-wrap; word-break: break-word; overflow-x: auto;
}
/* Tool/command cards: the shell line and the collapsed body summary. */
.chat-action-target code { font-size: var(--fs-tiny); color: var(--fg-0); word-break: break-all; }
.chat-action > details > summary { cursor: pointer; color: var(--fg-2); font-size: var(--fs-tiny); }
/* turn.completed token/cost summary, rendered inside a system bubble. */
.chat-usage-chips { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.chat-chip {
    display: inline-flex; align-items: center; gap: var(--s-1);
    padding: 1px var(--s-2); background: var(--neutral-soft);
    border-radius: var(--r-pill); font-size: var(--fs-tiny);
}
.chat-chip-k { color: var(--fg-3); }
.chat-chip-v { color: var(--fg-1); font-variant-numeric: tabular-nums; }
/* "--- latest job: ... ---" section markers from the probe — a centred rule. */
.alog-divider {
    display: flex; align-items: center; gap: var(--s-2);
    color: var(--fg-3); font-size: var(--fs-tiny);
    text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.alog-divider::before, .alog-divider::after {
    content: ""; flex: 1; height: 1px; background: var(--line-1);
}
/* Plain, non-JSON probe lines (running-process info, etc.). */
.alog-text { color: var(--fg-2); font-size: var(--fs-tiny); white-space: pre-wrap; word-break: break-word; }
/* A line the parser couldn't read — shown verbatim, flagged so it's obvious
   the view isn't hiding it. */
.alog-raw {
    color: var(--warn); border: 1px dashed var(--warn-line);
    padding: var(--s-2); border-radius: var(--r-1);
    white-space: pre-wrap; word-break: break-word; font-size: var(--fs-tiny);
}


/* ---- List multi-select (Web/App/Lists) ---- */
/* Leading checkbox column, and the bulk action icon-buttons that live in the matching
   column headers (select column = 3 selection buttons; Enabled column = On/Off; Delete
   column = trash). All reuse the .btn-pencil icon-button style; only colour differs. */
.col-select { width: auto; text-align: center; white-space: nowrap; }
.list-select-actions,
.bulk-toggle-actions { display: inline-flex; align-items: center; gap: var(--s-1); }
.bulk-toggle-actions form { display: inline; }
/* On = accent/green power, Off = muted power — same shape, colour disambiguates (tooltips too). */
.btn-pencil.btn-bulk-on { color: var(--ok); }
.btn-pencil.btn-bulk-off { color: var(--fg-3); }
/* Selected count in the pager bar. */
.pager-selected { margin-left: var(--s-2); color: var(--fg-2); white-space: nowrap; }

/* ======================================================================
   Public site + docs engine (top header, marketing templates, wiki)
   Renders docs/ markdown into the marketing landing + in-app wiki.
   ====================================================================== */

/* ---- Global top header: [brand] [nav .......] [actions] ---- */
.topbar {
	display: flex; align-items: center; gap: var(--s-4);
	min-height: var(--topbar-h, 3.25rem);
	padding: 0 var(--s-4);
	background: var(--bg-1, var(--neutral-soft));
	border-bottom: 1px solid var(--line-1);
	min-width: 0;
}
.topbar-brand { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 700; color: var(--fg-0); flex: 0 0 auto; text-decoration: none; }
.topbar-brand:hover { color: var(--accent); }
.topbar-brand .brand-mark { width: var(--z-3); height: var(--z-3); display: inline-block; line-height: 0; }
.topbar-brand-text { white-space: nowrap; font-size: 1.05rem; }
/* justify-content:flex-start overrides Pico's nav default (space-between),
   which would otherwise scatter the links across the whole bar. */
.topbar-nav { display: flex; align-items: center; justify-content: flex-start; gap: var(--s-1); flex: 1 1 auto; min-width: 0; overflow-x: auto; }
.topbar-link {
	display: inline-flex; align-items: center; gap: var(--s-1);
	padding: var(--s-1) var(--s-2); border-radius: var(--radius-1, 6px);
	color: var(--fg-1); white-space: nowrap; font-weight: 500; text-decoration: none;
}
.topbar-link > i { color: var(--fg-3); font-size: .9em; width: 1em; text-align: center; }
.topbar-link:hover > i, .topbar-link[aria-current="page"] > i { color: var(--accent); }
.topbar-link:hover { color: var(--fg-0); background: var(--neutral-soft); }
.topbar-link[aria-current="page"] { color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, transparent); }
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; flex: 0 0 auto; }
/* The theme toggle lives inside the header. Flatten it to a plain icon button,
   as the bar's other actions are. */
.topbar .theme-toggle { position: static; width: auto; height: auto; border: none; background: none; border-radius: var(--radius-1, 6px); padding: var(--s-1); color: var(--fg-2); }
.topbar .theme-toggle:hover { color: var(--accent); background: var(--neutral-soft); }
/* In the top bar the theme icon takes the bar's icon size instead of the base toggle's fixed 14 px. */
.topbar .theme-toggle i { font-size: inherit; }
/* Hamburger — desktop hides it; narrow viewports reveal it (see media query). */
.topbar-burger { display: none; align-items: center; padding: var(--s-1) var(--s-2); border: 1px solid var(--line-2); border-radius: var(--radius-1, 6px); background: none; color: var(--fg-1); cursor: pointer; }
.topbar-burger:hover { color: var(--accent); border-color: var(--accent-line, var(--line-2)); }
.btn-topbar {
	display: inline-flex; align-items: center; padding: var(--s-1) var(--s-3);
	border: 1px solid var(--accent-line, var(--line-2)); border-radius: var(--radius-1, 6px);
	color: var(--accent); white-space: nowrap; font-weight: 600; text-decoration: none;
}
.btn-topbar:hover { background: var(--accent); color: var(--bg-0, #0b0e14); }

/* User / auth cluster (top-right) — replaces the old sidebar footer block. */
.topbar-user { display: inline-flex; align-items: center; gap: var(--s-2); padding-left: var(--s-2); border-left: 1px solid var(--line-1); }
.topbar-user .user-avatar { width: var(--z-3); height: var(--z-3); border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; color: var(--text-on-accent); background: var(--gradient-accent); flex: 0 0 auto; text-decoration: none; }
.topbar-user-name { color: var(--fg-1); white-space: nowrap; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
.topbar-icon-btn { display: inline-flex; align-items: center; gap: var(--s-1); padding: var(--s-1); border-radius: var(--radius-1, 6px); color: var(--fg-2); background: none; border: none; cursor: pointer; }
.topbar-icon-btn:hover { color: var(--accent); background: var(--neutral-soft); }
.topbar-logout { display: inline-flex; margin: 0; }
.topbar-impersonation { display: inline-flex; }
.topbar-impersonation form { margin: 0; }
.topbar-impersonation-btn { color: var(--warn, #d29922); }
.topbar-impersonation-name { font-size: var(--fs-small); }

/* ---- Marketing layout (landing / feature templates) ---- */
.content.content-marketing { padding: 0; }
.content.content-marketing > * { max-width: 72rem; margin-inline: auto; }
.content.content-marketing > .hero { max-width: none; }

.hero {
	display: grid; gap: var(--s-4); align-items: center;
	padding: clamp(var(--s-4), 6vw, 5rem) var(--s-4);
	background:
		radial-gradient(60rem 30rem at 75% -10%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 60%),
		var(--bg-1, var(--neutral-soft));
	border-bottom: 1px solid var(--line-1);
}
.hero.hero-has-image { grid-template-columns: 1.1fr 0.9fr; }
.hero-inner { max-width: 40rem; margin-inline: auto; }
.hero.hero-has-image .hero-inner { margin-inline: 0; }
/* The landing hero is a transparent emblem (the logo in 3D), not a card — it floats
   on the themed page background and adapts to light/dark automatically. A drop-shadow
   (follows the alpha shape) adds soft depth on light and is invisible on dark. */
.hero-media { position: relative; align-self: stretch; min-height: 0; }
.hero-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 10px 26px rgba(2,8,23,.18)); }
.hero-eyebrow {
	display: inline-block; margin: 0 0 var(--s-3);
	font-size: var(--fs-small); font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
	color: var(--accent); background: color-mix(in oklab, var(--accent) 14%, transparent);
	padding: .25rem .7rem; border-radius: 999px;
}
.hero-title { font-size: clamp(2rem, 4.5vw, 3.25rem); line-height: 1.1; margin: 0 0 var(--s-3); }
.hero-subtitle { font-size: clamp(1.05rem, 1.8vw, 1.4rem); color: var(--fg-1); margin: 0 0 var(--s-4); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

.btn-cta {
	display: inline-flex; align-items: center; gap: var(--s-1);
	padding: var(--s-2) var(--s-4); border-radius: var(--radius-1, 8px);
	background: var(--accent); color: var(--bg-0, #0b0e14); font-weight: 700;
	border: 1px solid var(--accent);
}
.btn-cta:hover { filter: brightness(1.08); }
.btn-cta-ghost { background: transparent; color: var(--accent); }
.btn-cta-ghost:hover { background: color-mix(in oklab, var(--accent) 14%, transparent); filter: none; }

/* Value band: a titled section wrapping the feature cards (the "sell"). */
.value { padding: clamp(var(--s-4), 5vw, 4rem) var(--s-4); }
.value-title { text-align: center; font-size: clamp(1.5rem, 3vw, 2.2rem); margin: 0 auto var(--s-4); max-width: 40rem; }
.feature-grid {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	gap: var(--s-3); max-width: 72rem; margin-inline: auto;
}
.feature-card {
	padding: var(--s-4); border: 1px solid var(--line-1); border-radius: var(--radius-2, 12px);
	background: var(--bg-1, var(--neutral-soft));
	transition: border-color 120ms ease, transform 120ms ease;
}
.feature-card:hover { border-color: var(--accent-line, var(--line-2)); transform: translateY(-2px); }
.feature-icon { display: inline-flex; font-size: 1.5rem; color: var(--accent); margin-bottom: var(--s-2); }
.feature-icon-lg { font-size: 2rem; }
.feature-title { margin: 0 0 var(--s-1); font-size: 1.15rem; }
.feature-body { margin: 0; color: var(--fg-1); }

.feature-head { padding: clamp(var(--s-4), 5vw, 4rem) var(--s-4) var(--s-3); text-align: center; }
.feature-page-title { font-size: clamp(1.8rem, 4vw, 2.8rem); margin: 0 0 var(--s-2); }
.feature-page-subtitle { color: var(--fg-1); font-size: 1.2rem; margin: 0 auto; max-width: 42rem; }
.feature-hero-media img { width: 100%; max-width: 48rem; height: auto; margin-top: var(--s-4); border-radius: var(--radius-2, 12px); }
.feature-rows { display: grid; gap: var(--s-3); padding: var(--s-4); }
.feature-row { display: grid; grid-template-columns: auto 1fr; gap: var(--s-3); align-items: start; padding: var(--s-3); border-radius: var(--radius-2, 12px); }
.feature-row-alt { background: var(--bg-1, var(--neutral-soft)); }
.marketing-body { padding: clamp(var(--s-4), 4vw, 3rem) var(--s-4); }

/* ---- Docs / wiki layout ---- */
.content.content-docs { padding: 0; }
.docs-layout { display: grid; grid-template-columns: minmax(13rem, 16rem) 1fr; gap: 0; align-items: start; min-height: 0; }
.docs-toc {
	position: sticky; top: 0; align-self: start;
	padding: var(--s-3); border-right: 1px solid var(--line-1);
	max-height: calc(100dvh - var(--topbar-h, 3.25rem)); overflow-y: auto;
	background: var(--bg-1, var(--neutral-soft));
}
.docs-main { padding: var(--s-3) clamp(var(--s-3), 4vw, var(--s-4)); min-width: 0; max-width: 56rem; }
/* Single-column doc page (no TOC rail): centered, comfortable measure. */
.docs-page { max-width: 60rem; margin-inline: auto; padding: var(--s-3) clamp(var(--s-3), 5vw, var(--s-4)) var(--s-4); }
.docs-index .docs-index-tree {
	margin-top: var(--s-3);
	/* The tree owns its spacing; Pico's horizontal navigation gutters do not apply. */
	--pico-nav-element-spacing-horizontal: 0;
	--pico-nav-link-spacing-horizontal: 0;
	--pico-nav-link-spacing-vertical: 0;
}

/* Force a vertical list even inside a <nav> (Pico styles nav ul/li as a
   horizontal bar otherwise). */
.docs-tree, .docs-tree ul { list-style: none; margin: 0; padding: 0; display: block; }
.docs-tree li { display: block; margin: 0; padding: 0; }
.docs-tree ul { margin-left: var(--s-3); border-left: 1px solid var(--line-1); padding-left: var(--s-2); }
.docs-tree-link { display: flex; align-items: center; gap: var(--s-1); padding: var(--s-1) var(--s-2); border-radius: var(--radius-1, 6px); color: var(--fg-1); }
.docs-tree-link:hover { color: var(--fg-0); background: var(--neutral-soft); }
.docs-tree-item.is-current > .docs-tree-link, .docs-tree-link[aria-current="page"] { color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, transparent); }
.docs-tree-group { display: block; padding: var(--s-1) var(--s-2); color: var(--fg-2); font-size: var(--fs-tiny); text-transform: uppercase; letter-spacing: .04em; }

.crumb { color: var(--fg-2); font-size: var(--fs-small); margin-bottom: var(--s-2); }
.crumb a { color: var(--fg-1); }
.doc-article-head { padding-bottom: var(--s-3); margin-bottom: var(--s-3); border-bottom: 1px solid var(--line-1); }
.doc-article-lead { color: var(--fg-1); font-size: 1.1rem; margin: var(--s-2) 0 0; }
.doc-article-foot { margin-top: var(--s-4); padding-top: var(--s-2); border-top: 1px solid var(--line-1); }

/* ---- Rendered markdown typography ---- */
.markdown-body { line-height: 1.65; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { line-height: 1.25; margin: 1.6em 0 .5em; }
.markdown-body h2 { padding-bottom: .2em; border-bottom: 1px solid var(--line-1); }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body table { margin: 0 0 1em; }
.markdown-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.markdown-body img { max-width: 100%; height: auto; border-radius: var(--radius-1, 8px); }
.markdown-body code { background: var(--neutral-soft); padding: .1em .35em; border-radius: 4px; font-size: .92em; }
.markdown-body pre { background: var(--bg-1, #0d1117); border: 1px solid var(--line-1); border-radius: var(--radius-1, 8px); padding: var(--s-3); overflow-x: auto; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote { padding: var(--s-1) var(--s-3); border-left: 3px solid var(--accent-line, var(--line-2)); color: var(--fg-1); }
.markdown-body table { border-collapse: collapse; }
.markdown-body th, .markdown-body td { border: 1px solid var(--line-1); padding: var(--s-1) var(--s-2); text-align: left; }
/* Custom-container callouts (:::note / :::warning from UseAdvancedExtensions). */
.markdown-body .note, .markdown-body .warning, .markdown-body .tip {
	padding: var(--s-2) var(--s-3); border-radius: var(--radius-1, 8px); margin: 0 0 1em; border-left: 4px solid var(--accent-line, var(--line-2));
	background: var(--bg-1, var(--neutral-soft));
}
.markdown-body .warning { border-left-color: var(--warn, #d29922); }

@media (max-width: 860px) {
	.hero.hero-has-image { grid-template-columns: 1fr; }
	.hero-media { min-height: 15dvh; }
	.docs-layout { grid-template-columns: 1fr; }
	.docs-toc { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--line-1); }

	/* Collapse the top nav into a dropdown instead of a hidden scroll strip. */
	.topbar { position: relative; }
	.topbar-burger { display: inline-flex; }
	.topbar-nav {
		display: none; position: absolute; left: 0; right: 0; top: 100%;
		flex-direction: column; align-items: stretch; gap: var(--s-1);
		background: var(--bg-1, var(--neutral-soft)); border-bottom: 1px solid var(--line-1);
		padding: var(--s-2); overflow: visible; z-index: 60;
		box-shadow: 0 1rem 2rem rgba(0, 0, 0, .35);
	}
	.topbar.nav-open .topbar-nav { display: flex; }
	.topbar-nav .topbar-link { padding: var(--s-2); }
	/* The avatar names the account on a phone, so the name leaves room for Sign out within the screen. The name stays
	   the account link for a keyboard and a screen reader, and shows while it has the focus. */
	.topbar-user-name:not(:focus-visible) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

/* Offline: a live job whose agent stopped calling in. Warning colours, not error --
   the job is fine, the worker is gone, and the fix is to bring it back. */
/* Offline is the one state the pill shows, so it is the one recolour. */
.job-activity-offline { color: var(--warn); border-color: var(--warn); }
/* Ran: a finished job kept as provenance. Muted, because it is history rather than
   activity -- it must not compete with a live chip elsewhere on the card. */
