/* Component kit — classes built ONLY on the semantic tokens (import tokens.css first, themes.css
 * second, this file third). Because components never name a raw color, a palette/mode attribute swap
 * restyles every one of them (see themes.css + occasions.md). STARTER — grow as needed. */

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading);
}

:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: var(--radius-sm); }

/* -- Links: a token so a hyperlink is readable in EVERY theme, never the browser default (which is an
   unreadable blue on dark surfaces). It auto-tracks each palette's anchor — `--accent-deep` in light
   (the darker shade, high contrast on light paper), the brighter `--accent` in dark — the same idea as
   the org system (arcsystem: `a { color: var(--accent-deep) }`). Defined on `body` (where the palette
   lives) so `var()` resolves in the active palette's context. -- */
body { --link: var(--accent-deep); --link-hover: var(--accent); }
body[data-mode="dark"] { --link: var(--accent); --link-hover: var(--accent-deep); }
/* A brand whose DEFAULT palette has a too-light --accent-deep (abacus: #e5650a reads at only 3.39:1 as
   text) pins an explicit readable link ink via --brand-link-ink in its tokens file. Scoped to no-theme +
   light so seasonal palettes keep tracking their own anchor and dark keeps the bright --accent. When a
   brand sets no ink, this falls back to --accent-deep, i.e. exactly the rule above. qa/ verifies it. */
body:not([data-theme]):not([data-mode="dark"]) { --link: var(--brand-link-ink, var(--accent-deep)); }

/* -- Secondary / category accents: theme-TRACKING personality colours (tags, chips, category dots), so
   a themed page wears more than its single anchor. `--accent` is category 1; 2–4 use the abacus gear
   tokens when the brand ships them, and fall back to the standalone signal hues otherwise — so a bland
   app still gets four distinct categories, and `mono` (which greys the gear tokens) stays monochrome.
   Derived on `body`, like --link, so the var() resolves in the ACTIVE palette (not on :root/html, where
   a seasonal override wouldn't reach — see the --link note). Distinct from --chart-* (tokens.css), which
   is the STABLE data-encoding scale that must not recolour per theme. -- */
body {
  --accent-2: var(--gear-blue, var(--info));
  --accent-3: var(--gear-yellow, var(--warning));
  --accent-4: var(--gear-red, var(--danger-fg));
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
/* mono is grayscale — colour can't signal "link", so underline them (the classic, accessible cue). */
body[data-theme="mono"] a { text-decoration: underline; text-underline-offset: 2px; }

/* -- App shell: header/nav + width-capped content (server_rendered app pages) -- */
.app-header {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elev); border-bottom: 1px solid var(--border);
}
.app-header .brand { font-weight: var(--weight-bold); }
.app-nav { display: flex; gap: var(--space-4); }
.app-nav a { color: var(--fg-muted); text-decoration: none; }
.app-nav a:hover { color: var(--fg); }
.app-content { max-width: var(--content-max); margin: 0 auto; padding: var(--space-6) var(--space-4); }

/* -- Occasion banner: one line above the header while a dated occasion is active (occasions.md) -- */
.occasion-banner {
  background: var(--accent); color: var(--on-accent); text-align: center;
  padding: var(--space-2) var(--space-4); font-weight: var(--weight-medium); font-size: var(--text-sm);
}
.occasion-banner p { margin: 0; display: inline; }
.occasion-banner a { color: inherit; text-decoration: underline; }

/* -- View-as bar: the impersonation banner + picker (impersonation.md). A full-width strip above the
   header. The banner (while impersonating) uses the warning wash so it reads as a persistent "you are not
   yourself" state; the picker (idle) is a quiet elevated strip. Inert unless the markup exists. -- */
.impersonation-bar,
.impersonation-picker {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-2) var(--space-4); font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}
.impersonation-bar {
  background: var(--warning-bg); border-bottom-color: var(--warning-border); color: var(--warning-fg);
  font-weight: var(--weight-medium);
}
.impersonation-bar[data-mode="user"] { background: var(--accent-soft); border-bottom-color: color-mix(in srgb, var(--accent) 40%, var(--border)); color: var(--fg); }
.impersonation-bar-msg { flex: 1 1 auto; }
.impersonation-bar form,
.impersonation-form { margin: 0; display: flex; align-items: center; gap: var(--space-2); }
.impersonation-picker { background: var(--bg-elev); color: var(--fg-muted); }
.impersonation-form-label { display: inline-flex; align-items: center; gap: var(--space-2); }

/* -- Auth shell: one centered card (login, logged-out, ums-setup) -- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); }
.auth-card {
  width: 100%; max-width: var(--card-max);
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-8); box-shadow: var(--shadow-card);
}
/* Auth branding: the app mark + name atop the card */
.auth-brand { display: flex; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-1); }
.auth-mark {
  width: 38px; height: 38px; border-radius: var(--radius-md);
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: var(--weight-bold);
}
.auth-title { margin: 0; font-size: var(--text-lg); }
.auth-sub { color: var(--fg-muted); margin: var(--space-1) 0 var(--space-6); }

/* -- Page head + panel: the top of an app-shell page and its content container -- */
.page-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6);
}
.page-title { margin: 0; font-size: var(--text-xl); }
.page-sub { color: var(--fg-muted); margin: var(--space-1) 0 0; }
.panel {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-6);
  box-shadow: var(--shadow-card); /* panels were border-only and blended into the page */
}

/* -- Cards: a flat, ELEVATED container (dashboards, list items, kanban / gallery tiles). No border, no
   accent chrome — the accent belongs on the primary action or the SELECTED state, never a rail (the old
   .card-accent rail is retired below; shadcn-gap-audit.md). radius-md (lg read as over-rounded). -- */
.card {
  position: relative; /* stickers / stamps pin to the card's corners */
  background: var(--bg-elev); border: 1px solid transparent;
  border-radius: var(--radius-md); box-shadow: var(--shadow-soft); overflow: hidden;
}
/* An INTERACTIVE card (a kanban/list/gallery tile you click): lifts on hover, and on SELECT gets an accent
   ring + a title-underline that draws across (the one place the accent appears). Selection is app-driven —
   toggle .is-selected. An <a class="card"> is interactive implicitly. */
.card-interactive, a.card { cursor: pointer; transition: box-shadow 0.16s ease, transform 0.16s ease; }
.card-interactive:hover, a.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.card-interactive:focus-visible, a.card:focus-visible { outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent), var(--shadow-soft); }
.card-interactive.is-selected, a.card.is-selected { box-shadow: 0 0 0 1px var(--accent), var(--shadow-lift); }
.card-interactive .card-title, a.card .card-title {
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 100% / 0% 2px; padding-bottom: 2px;
  transition: background-size 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.card-interactive:hover .card-title, a.card:hover .card-title { background-size: 24% 2px; }  /* hover hint */
.card-interactive.is-selected .card-title, a.card.is-selected .card-title { background-size: 100% 2px; }
.card-header, .card-body, .card-footer { padding: var(--space-4) var(--space-6); }
.card-header { border-bottom: 1px solid var(--border); }
.card-footer { border-top: 1px solid var(--border); background: var(--bg); }
.card-title { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-bold); }
.card-subtitle { margin: var(--space-1) 0 0; color: var(--fg-muted); font-size: var(--text-sm); }
/* Card anatomy: hero media on top, tag chips, a corner sticker, a clamped summary, a code well. */
.card-hero { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg-sunken); }
.card-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-2) 0 0; }
.tag {
  font-size: var(--text-sm); padding: 1px var(--space-2); border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--fg);
}
.card-sticker {
  position: absolute; top: var(--space-2); right: var(--space-2); z-index: 1;
  background: var(--accent); color: var(--on-accent); font-size: var(--text-sm);
  font-weight: var(--weight-medium); padding: 2px var(--space-3); border-radius: 999px;
  box-shadow: var(--shadow-card); transform: rotate(3deg);
}
.card-summary {
  color: var(--fg-muted); margin: var(--space-2) 0 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
pre {
  font-family: var(--font-mono); font-size: var(--text-sm); background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--space-3); overflow-x: auto; margin: var(--space-2) 0 0;
}
pre > code { background: none; padding: 0; }
/* Responsive grid of cards */
.card-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* -- Gallery grid: a dense tile grid for media/thumbnails/swatches (denser than .card-grid).
   .span-2 widens a tile; captions sit on a scrim so they read over any image. -- */
.gallery-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.gallery-item { position: relative; border-radius: var(--radius-md); overflow: hidden; background: var(--bg-sunken); }
.gallery-item > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-item { aspect-ratio: 1; }
.gallery-item.span-2 { grid-column: span 2; aspect-ratio: auto; }
.gallery-caption {
  position: absolute; inset: auto 0 0 0; padding: var(--space-2) var(--space-3);
  background: rgba(0, 0, 0, 0.55); color: #ffffff; font-size: var(--text-sm);
}
@media (max-width: 480px) { .gallery-item.span-2 { grid-column: span 1; } }

/* -- Typography: headings wear the DISPLAY face (the font tokens are meant to be used) -- */
h1, h2, h3, .title, .page-title, .card-title, .auth-title { font-family: var(--font-display); }
.title { margin: 0 0 var(--space-1); font-size: var(--text-lg); }
.subtitle { color: var(--fg-muted); margin: var(--space-1) 0 var(--space-6); }
/* Every font token has a utility, so serif/script content never hard-codes a family. */
.font-sans { font-family: var(--font-sans); }
.font-serif { font-family: var(--font-serif); }
.font-mono { font-family: var(--font-mono); }
.font-script { font-family: var(--font-script); }
.font-display { font-family: var(--font-display); }

/* ================================================================================================
   BUTTONS — EMPHASIS (variant) x SIZE, with orthogonal STATES. One `.btn` base carries the layout +
   the size ramp (via --btn-* custom props); a variant class sets only colour; and the states
   (hover/active/focus-visible/disabled/loading) apply to ANY variant×size. Modelled on Primer/Radix.
   ================================================================================================ */
@keyframes kit-spin { to { transform: rotate(360deg); } }

.btn {
  /* the size ramp lives in these props — a size class overrides them, nothing else. md is the default. */
  --btn-pad-y: var(--space-2); --btn-pad-x: var(--space-4); --btn-font: var(--text-base); --btn-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--btn-pad-y) var(--btn-pad-x); border-radius: var(--btn-radius); line-height: 1.35;
  border: 1px solid var(--accent-deep); background: var(--accent); color: var(--on-accent);
  font: inherit; font-size: var(--btn-font); font-weight: var(--weight-medium);
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }

/* -- Variants (emphasis): primary=.btn (bold solid) · secondary (accent, tonal) · ghost (muted) · danger -- */
.btn-secondary {  /* medium emphasis: an accent OUTLINE with the readable accent ink (--link is the
     contrast-checked accent-on-surface token, so this passes on any app surface); hover fills subtly. */
  background: transparent; color: var(--link); border-color: var(--accent);
}
.btn-secondary:hover { background: var(--bg-sunken); border-color: var(--accent-deep); }
.btn-ghost {  /* low emphasis, still ENABLED (hover proves it) — never confuse this with the disabled look */
  background: transparent; color: var(--fg-muted); border-color: var(--border-strong); font-weight: var(--weight-normal);
}
.btn-ghost:hover { background: var(--bg-sunken); color: var(--fg); }
.btn-danger { background: transparent; color: var(--danger-fg); border-color: var(--danger-border); font-weight: var(--weight-normal); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-on { background: var(--accent); color: var(--on-accent); border-color: var(--accent-deep); }  /* active toggle state */

/* -- Sizes: one deliberate ramp (xs / sm / md=default / lg), all from the type + spacing tokens -- */
.btn-xs { --btn-pad-y: 1px;            --btn-pad-x: var(--space-2); --btn-font: var(--text-sm);   --btn-radius: var(--radius-sm); gap: var(--space-1); }
.btn-sm { --btn-pad-y: var(--space-1); --btn-pad-x: var(--space-2); --btn-font: var(--text-sm);   --btn-radius: var(--radius-sm); }
.btn-lg { --btn-pad-y: var(--space-3); --btn-pad-x: var(--space-6); --btn-font: var(--text-lg); }

/* -- States (orthogonal): disabled (dimmed, no pointer) + loading (spinner, keeps width) -- */
.btn:disabled, .btn[aria-disabled="true"], .btn.is-disabled {
  opacity: 0.5; cursor: not-allowed; pointer-events: none; transform: none; box-shadow: none;
}
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }  /* text hidden, WIDTH preserved */
.btn.is-loading::after {
  content: ""; position: absolute; width: 1em; height: 1em; border-radius: 50%;
  border: 2px solid var(--on-accent); border-top-color: transparent; animation: kit-spin 0.6s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after { border-color: var(--fg); border-top-color: transparent; }

/* -- Button GROUP: joined buttons, INDEPENDENT actions (a toolbar cluster) -- */
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; margin-left: -1px; }
.btn-group > .btn:first-child { border-start-start-radius: var(--radius-md); border-end-start-radius: var(--radius-md); margin-left: 0; }
.btn-group > .btn:last-child { border-start-end-radius: var(--radius-md); border-end-end-radius: var(--radius-md); }
.btn-group > .btn:hover, .btn-group > .btn:focus-visible { z-index: 1; }

/* -- SEGMENTED control: SINGLE-select (e.g. Board|List). Radio-backed, so it works with no JS and is
   fully accessible; the checked segment lifts onto the elevated surface. Markup:
   <div class="segmented"><label><input type="radio" name="view" value="board">Board</label>…</div> -- */
.segmented { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-md); }
.segmented label {
  display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer;
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--fg-muted); transition: background 0.12s, color 0.12s;
}
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:hover { color: var(--fg); }
.segmented label:has(input:checked) { background: var(--bg-elev); color: var(--fg); box-shadow: var(--shadow-card); font-weight: var(--weight-medium); }
.segmented label:has(input:focus-visible) { box-shadow: var(--shadow-focus); }

/* -- Toolbar with OVERFLOW: a single row of actions; controls.js moves the ones that don't fit into a
   "⋯ more" menu at the end (ResizeObserver, so it re-flows on resize). <div class="toolbar" data-overflow> -- */
.toolbar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: nowrap; overflow: hidden; }
.toolbar-more { position: relative; flex: none; }
.toolbar-more > summary { list-style: none; display: inline-flex; }
.toolbar-more > summary::-webkit-details-marker { display: none; }
.toolbar-more-menu {
  position: absolute; right: 0; z-index: 20; margin-top: var(--space-1);
  display: flex; flex-direction: column; gap: var(--space-1); min-width: 10rem; box-shadow: var(--shadow-card);
}
.toolbar-more-menu > .btn { justify-content: flex-start; border-color: transparent; }

/* ================================================================================================
   FORM CONTROLS — every field wears the kit, never OS chrome (the "search box uses system UI" fix,
   widened to every input type). The native picker POPUP (calendar, colour wheel, the <select> option
   list) stays OS-drawn on purpose; we normalise the FIELD only. Focus is a token ring everywhere.
   ================================================================================================ */
.field { display: block; margin: 0 0 var(--space-4); }
/* The label is the FIRST span; scope the block treatment to it so an inline control wrapper placed in
   the field (.stepper, .search-field) keeps its own display. */
.field > span:first-child { display: block; margin-bottom: var(--space-2); font-weight: var(--weight-medium); }
/* A checkbox field is a horizontal row (the OS-drawn box then its label), not a stacked label + control. */
.field-check { display: flex; align-items: center; gap: var(--space-2); }
.field-check > span { margin: 0; font-weight: var(--weight-normal); }

/* The text-like fields + select + textarea share ONE boundary. --border-input, not --border-strong: a
   control's boundary must hit WCAG 1.4.11 (3:1); decorative hairlines stay light. */
input[type="text"], input[type="password"], input[type="number"], input[type="email"],
input[type="search"], input[type="tel"], input[type="url"], input[type="date"], input[type="time"],
input[type="datetime-local"], input[type="month"], input[type="week"],
select, textarea {
  /* Vertical metrics match .btn (padding-y var(--space-2) + line-height 1.35) so a single-line field is
     the SAME height as a button beside it — they used to be ~10px taller (space-3 padding + 1.5 leading).
     Horizontal padding stays var(--space-3). Textarea overrides both below (multi-line wants room). */
  width: 100%; padding: var(--space-2) var(--space-3); line-height: 1.35;
  border: 1px solid var(--border-input, var(--border-strong));
  border-radius: var(--radius-md); background: var(--bg); color: var(--fg); font: inherit;
  appearance: none; -webkit-appearance: none;  /* strip the native field look — we redraw it */
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: var(--shadow-focus);
}
textarea { min-height: 88px; resize: vertical; font-family: var(--font-mono);
  padding: var(--space-3); line-height: var(--leading); }   /* multi-line: keep the roomier metrics */
/* The <select> LIST is a native popup, but browsers honour font + colours on <option>. */
select, option { font-family: var(--font-sans); }
option { background: var(--bg-elev); color: var(--fg); }

/* Select: our own caret (appearance:none removed the native one). Inline SVG, mid-grey (reads on both). */
select {
  padding-right: calc(var(--space-6) + var(--space-3));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5l4 4 4-4' fill='none' stroke='%237a828e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-3) center;
}

/* Search: kill the system search look; our own clear × comes from .search-field (below) or Esc. */
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }

/* Date / time: recolour the native calendar-picker indicator (the popup itself stays OS-drawn). */
::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.55; }
::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* Number: hide the ad-hoc native spinners — a normalised +/- is the .stepper component below. */
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Colour: a clean swatch chip (the eyedropper/wheel popup stays OS). */
input[type="color"] {
  width: 44px; height: 32px; padding: 2px; border: 1px solid var(--border-input); border-radius: var(--radius-md);
  background: var(--bg); cursor: pointer; appearance: none; -webkit-appearance: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: var(--radius-sm); }
input[type="color"]::-moz-color-swatch { border: none; border-radius: var(--radius-sm); }

/* Range = OUR slider: track + thumb, both engines. The fill uses an accent gradient set from --pct. The
   thumb shares the progress ENDPOINT-handle look (a glowing accent node) — a slider IS a draggable
   progress, so the two read as one family (progress.md). */
input[type="range"] { width: 100%; height: 20px; background: transparent; cursor: pointer; appearance: none; -webkit-appearance: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px;
  background: linear-gradient(var(--accent), var(--accent)) 0 / var(--pct, 0%) 100% no-repeat, var(--bg-sunken); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--bg-sunken); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-elev);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent), 0 0 8px color-mix(in srgb, var(--accent) 55%, transparent); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 2px solid var(--bg-elev); border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent), 0 0 8px color-mix(in srgb, var(--accent) 55%, transparent); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--shadow-focus); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: var(--shadow-focus); }

/* File: style the trigger button (kit look), keep the native pick dialog. */
input[type="file"] { font: inherit; color: var(--fg-muted); }
input[type="file"]::file-selector-button {
  margin-right: var(--space-3); padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: transparent; color: var(--fg);
  font: inherit; font-weight: var(--weight-medium); cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--bg-sunken); }

/* Checkbox + radio: OUR own box/dot (appearance:none kills the OS control); accent when checked. */
input[type="checkbox"], input[type="radio"] {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; vertical-align: -3px;
  width: 18px; height: 18px; border: 1px solid var(--border-input); background: var(--bg);
  cursor: pointer; display: inline-grid; place-content: center; transition: background 0.12s, border-color 0.12s;
}
input[type="checkbox"] { border-radius: var(--radius-sm); }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:checked, input[type="radio"]:checked { background: var(--accent); border-color: var(--accent-deep); }
input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 10px; background: var(--on-accent);
  clip-path: polygon(14% 46%, 0 63%, 42% 100%, 100% 15%, 82% 0, 40% 62%); }
input[type="radio"]:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-accent); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { box-shadow: var(--shadow-focus); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* A search field with our OWN clear ×: <span class="search-field"><input type="search">…</span> — the
   button is revealed by controls.js only when there's text, and clears + refocuses on click. */
.search-field { position: relative; display: inline-flex; align-items: center; }
.search-field input[type="search"] { padding-right: calc(var(--space-6) + var(--space-2)); }
.search-field .search-clear {
  position: absolute; right: var(--space-2); border: 0; background: none; color: var(--fg-subtle);
  cursor: pointer; font-size: var(--text-base); line-height: 1; padding: 2px; border-radius: 50%;
}
.search-field .search-clear:hover { color: var(--fg); background: var(--bg-sunken); }

/* -- Password fields: masked input + reveal toggle (password-fields.md; password-toggle.js) -- */
.password-field { position: relative; display: block; }
.password-field input { padding-right: 72px; }
.pw-toggle {
  position: absolute; top: 50%; right: var(--space-2); transform: translateY(-50%);
  border: 0; background: none; color: var(--fg-muted);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium);
  cursor: pointer; padding: var(--space-1) var(--space-2);
}
.pw-toggle:hover { color: var(--fg); }

/* -- Pager: the house pagination control (backend helpers/paging.py + _macros.html). One layout on
   every list — « First ‹ Prev · Page [N] of M · T total · Next › Last » · Show [25▾] per page. -- */
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  flex-wrap: wrap; margin-top: var(--space-6);
}
.pager-nav { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.pager-jump, .pager-size { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
.pager-jump label, .pager-size label { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; }
/* The kit makes inputs/selects width:100% — the pager's are inline controls, so constrain them. */
.pager-page-input { width: 4.5rem; text-align: center; padding: var(--space-1) var(--space-2); }
.pager-size-select { width: auto; padding: var(--space-1) var(--space-2); }
/* A disabled step is a <span>, not a link — it must look inert and not be focusable. */
.pager [aria-disabled="true"] { opacity: 0.45; cursor: default; pointer-events: none; }

/* -- Table controls: search / sort / filters / columns / saved views (backend helpers/tables.py +
   _macros.html). A toolbar row above a table; each piece degrades to plain HTML without JS. -- */
.table-toolbar {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.table-toolbar .spacer { flex: 1 1 auto; }
.table-search { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin: 0; }
.table-search-input { width: auto; min-width: 16rem; }
.table-search-meta { flex-basis: 100%; }
.table-filters { display: flex; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; margin: 0; }
.table-filter { margin: 0; }
.table-filter select, .table-filter input { width: auto; min-width: 8rem; padding: var(--space-1) var(--space-2); }
.saved-views { display: flex; align-items: center; gap: var(--space-2); }
/* The quick-switch dropdown (table.js fills it); inline, so it must not be the kit's full-width input. */
.views-switch { width: auto; max-width: 12rem; padding: var(--space-1) var(--space-2); }

/* -- Bulk selection (bulk.js + the bulk_* macros): the two-tier select-all banner + the action bar. -- */
.bulk-banner {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2);
  padding: var(--space-2) var(--space-4); font-size: var(--text-sm); color: var(--fg-muted);
  background: var(--bg-sunken); border: 1px dashed var(--border-strong); border-radius: var(--radius-md);
}
.bulk-bar {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-4); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: var(--radius-md);
}
.bulk-count { font-weight: var(--weight-medium); }
.bulk-ops { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.bulk-bar > [data-role="bulk-clear"] { margin-left: auto; }
/* the display:flex above beats the UA [hidden]{display:none}; restore it so hidden actually hides. */
.bulk-bar[hidden], .bulk-banner[hidden] { display: none; }

/* -- Ordered selection (sequence.js + the sequence_bar macro): a mode toggle turns the SAME bulk
   checkboxes into a numbered picker. The slot overlays the native checkbox (kept for keyboard/click)
   with a numbered badge that stamps pick order 1,2,3… -- */
.sequence { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.sequence-panel {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-2) var(--space-4); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: var(--radius-md);
}
.sequence-panel[hidden] { display: none; }
.sequence-preview { font-family: var(--font-mono); font-weight: var(--weight-medium); color: var(--fg); }
.sequence-panel > [data-role="sequence-confirm"] { margin-left: auto; }
[data-role="sequence-toggle"][aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
/* the live-region announcer is spoken, not shown */
.sequence-live {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.seq-slot { position: relative; display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; vertical-align: middle; }
.seq-slot > .bulk-row {           /* keep the checkbox: it stays the keyboard/click target, just invisible */
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1;
}
.seq-badge {
  display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--fg-subtle);
  font-size: var(--text-xs); font-weight: var(--weight-bold); line-height: 1; font-variant-numeric: tabular-nums;
}
.seq-badge.is-picked { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seq-slot > .bulk-row:focus-visible ~ .seq-badge { outline: 2px solid var(--accent); outline-offset: 2px; }

.column-picker { position: relative; }
.column-picker > summary { list-style: none; display: inline-flex; }
.column-picker > summary::-webkit-details-marker { display: none; }
.column-picker-menu {
  position: absolute; right: 0; z-index: 20; margin-top: var(--space-1);
  display: flex; flex-direction: column; gap: var(--space-2); min-width: 12rem;
  box-shadow: var(--shadow-card);
}
.column-picker-item { display: flex; align-items: center; gap: var(--space-2); }

/* Filter menu: a multi-select checkbox dropdown (filter_bar). Same <details> popover pattern as the
   column picker; the count badge on the button shows how many values are active. */
.filter-menu { position: relative; }
.filter-menu > summary { list-style: none; display: inline-flex; align-items: center; gap: var(--space-1); }
.filter-menu > summary::-webkit-details-marker { display: none; }
.filter-menu-panel {
  position: absolute; left: 0; z-index: 20; margin-top: var(--space-1);
  display: flex; flex-direction: column; gap: var(--space-2); min-width: 12rem; max-height: 16rem;
  overflow-y: auto; box-shadow: var(--shadow-card);
}
.filter-menu-item { display: flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.filter-count {
  display: inline-grid; place-items: center; min-width: 1.25em; height: 1.25em; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 0.75em; font-weight: var(--weight-bold); line-height: 1;
}

/* Sortable header: the whole cell is a link; the icon (inline SVG) shows sort state — an up/down arrow
   when active, a faint up-down when merely sortable. currentColor, so it tints with the rules below. */
.sort-th > a { display: inline-flex; align-items: center; gap: var(--space-1); color: inherit; text-decoration: none; }
.sort-th .sort-icon { display: inline-flex; color: var(--fg-subtle); }
.sort-th.is-sorted .sort-icon { color: var(--accent); }
.sort-th > a:hover .sort-icon { color: var(--fg); }

/* -- Archive row actions (deletion.md): Restore + Delete-forever, the only two actions in the Archive.
   The icon buttons sit inline; the destroy button reads as danger. `.inline-form` keeps each POST form
   from breaking onto its own line. -- */
.archive-actions { display: inline-flex; gap: var(--space-2); align-items: center; }
.inline-form { display: inline; margin: 0; }
.btn svg { vertical-align: -2px; }

/* -- Modal + toast (dialog.js) — the kit's in-page replacements for window.confirm/alert/prompt -- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.5);
  display: grid; place-items: center; padding: var(--space-4);
}
.modal {
  background: var(--bg-elev); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  width: 100%; max-width: 34rem; max-height: 85vh; overflow: auto;
}
.modal:focus { outline: none; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border);
}
.modal-title { margin: 0; font-size: var(--text-lg); font-family: var(--font-display); }
.modal-body { padding: var(--space-4) var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }
.modal-close { border: 0; background: none; color: var(--fg-muted); cursor: pointer; font-size: var(--text-lg); line-height: 1; padding: var(--space-1); }
.modal-close:hover { color: var(--fg); }
.modal-error { color: var(--danger-fg); font-size: var(--text-sm); }

/* Toast queue (dialog.js kitToast): a stacking, self-dismissing message. v1.94 style — a coloured icon
   badge carries the kind, NO accent rail; a countdown bar shows time-to-dismiss. The host caps the visible
   stack (oldest drops). Bottom-centre; actionable (pairs with kitUndo) + optionally persistent. */
.toast-host {
  position: fixed; left: 50%; bottom: var(--space-4); transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: var(--space-2); align-items: stretch; pointer-events: none;
  width: 360px; max-width: calc(100vw - 2 * var(--space-4));
}
.toast {
  position: relative; overflow: hidden; display: flex; align-items: flex-start; gap: var(--space-3);
  background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lift);
  padding: var(--space-3) var(--space-4); font-size: var(--text-sm);
  transition: opacity 0.2s, transform 0.2s; pointer-events: auto;
  animation: kit-toast-in 0.22s cubic-bezier(0.2, 1, 0.4, 1);
}
@keyframes kit-toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.toast-ico { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.8rem; font-weight: var(--weight-bold); background: var(--bg-sunken); color: var(--fg-muted); margin-top: 1px; }
.toast-content { flex: 1 1 auto; min-width: 0; }
.toast-title { font-weight: var(--weight-medium); }
.toast-title + .toast-msg { margin-top: 1px; }
.toast-msg { color: var(--fg-muted); }
.toast .btn { flex: none; }
.toast-close { flex: none; border: 0; background: none; color: var(--fg-subtle); cursor: pointer;
  font-size: var(--text-sm); line-height: 1; padding: 2px; }
.toast-close:hover { color: var(--fg); }
.toast-out { opacity: 0; transform: translateX(16px); }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: currentColor; color: var(--fg-subtle); opacity: 0.5; }
@keyframes kit-toast-bar { from { width: 100%; } to { width: 0; } }
.toast-success .toast-ico { background: var(--success-bg); color: var(--success-fg); } .toast-success .toast-bar { color: var(--success-fg); }
.toast-error .toast-ico { background: var(--danger-bg); color: var(--danger-fg); } .toast-error .toast-bar { color: var(--danger-fg); }
.toast-warning .toast-ico { background: var(--warning-bg); color: var(--warning-fg); } .toast-warning .toast-bar { color: var(--warning-fg); }
.toast-info .toast-ico { background: color-mix(in srgb, var(--info) 16%, var(--bg-elev)); color: var(--info); } .toast-info .toast-bar { color: var(--info); }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .toast-bar { display: none; } }

/* -- Build tag: a DISCRETE running-version marker (version.js). Bottom-corner, muted, monospace; the
   short revision shows, and env + deploy time + full commit ride the title tooltip (hover) — deploy
   info without a "prod" pill in anyone's face. Fixed + outside the shell, so it shows on every page
   (incl. the login card) and survives an app's shell override. -- */
.build-badge {
  position: fixed; right: var(--space-3); bottom: var(--space-3); z-index: 50;
  display: inline-flex; align-items: center; gap: 6px; cursor: default; user-select: none;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--fg-subtle);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px var(--space-2);
}
.build-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success-fg); flex: none; }
@media (max-width: 480px) { .build-badge { display: none; } }  /* stay out of the way on phones */
/* The badge also carries [data-tooltip]; the generic `[data-tooltip] { position: relative }` below would
   otherwise un-fix it (equal specificity, later in the file). Re-pin the corner pill — a fixed element is
   still a positioning context, so its tooltip ::after anchors to it just the same. */
.build-badge[data-tooltip] { position: fixed; }

/* -- Optional app footer (shell region, ui.footer.enabled). OFF by default; when off, the corner
   .build-badge above remains. Padded + width-capped to line up with the content column, theme-aware via
   tokens. When ON, the build tag lives INSIDE here (position reset below) instead of the corner pill. -- */
.app-footer { margin-top: var(--space-8); background: var(--bg-elev); border-top: 1px solid var(--border); }
.app-footer-inner {
  max-width: var(--content-max); margin: 0 auto;
  padding: var(--space-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4) var(--space-6);
  flex-wrap: wrap; font-size: 0.82rem; color: var(--fg-muted);
}
.app-footer-org { display: flex; align-items: center; gap: var(--space-2) var(--space-3); flex-wrap: wrap; }
.app-footer-logo { height: 20px; width: auto; display: block; }
.app-footer-owner { font-weight: var(--weight-medium); color: var(--fg); }
.app-footer-owner a { color: inherit; text-decoration: none; }
.app-footer-owner a:hover { text-decoration: underline; }
.app-footer-copy { color: var(--fg-subtle); }
.app-footer-meta { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.app-footer-links { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.app-footer-links a { color: var(--fg-muted); text-decoration: none; }
.app-footer-links a:hover { color: var(--fg); }
/* the build tag in the footer is inline, not the fixed corner pill — and it stays visible on phones. */
.app-footer .build-badge { position: static; right: auto; bottom: auto; z-index: auto; }
@media (max-width: 480px) { .app-footer .build-badge { display: inline-flex; } }

/* -- Saved-views modal (table.js): a list of views with a muted description under each name -- */
.views-list { list-style: none; margin: 0; padding: 0; }
.views-item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border); }
.views-item:first-child { border-top: 0; }
.views-item-main { flex: 1 1 auto; min-width: 0; }
.views-item-name { font-weight: var(--weight-medium); }
.views-item-desc { color: var(--fg-muted); font-size: var(--text-sm); margin-top: 2px; } /* the muted description */
.views-item-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.views-default-star { border: 0; background: none; cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 2px; color: var(--fg-subtle); }
.views-default-star.is-default { color: var(--warning); }
.views-empty { color: var(--fg-muted); }
.views-divider { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* -- Prose: the render target for a rich-text field (helpers/richtext.py — plain / markdown / html).
   Leans on the whole token set (display font for headings, --link, accent-bordered quotes, sunken
   code wells) so rendered content reads as part of the system, in any theme. -- */
.prose { color: var(--fg); line-height: var(--leading); }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-display); font-weight: var(--weight-bold);
  line-height: 1.25; margin: var(--space-6) 0 var(--space-3);
}
.prose h1 { font-size: var(--text-xl); }
.prose h2 { font-size: var(--text-lg); }
.prose h3 { font-size: var(--text-base); }
.prose p { margin: 0 0 var(--space-4); }
.prose a { color: var(--link); }
.prose a:hover { text-decoration: underline; }
.prose ul, .prose ol { margin: 0 0 var(--space-4); padding-left: var(--space-6); }
.prose li { margin: var(--space-1) 0; }
.prose blockquote {
  margin: 0 0 var(--space-4); padding: var(--space-2) var(--space-4);
  border-left: 3px solid var(--accent); background: var(--bg-sunken);
  color: var(--fg-muted); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.prose code {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--bg-sunken); padding: 1px var(--space-1); border-radius: var(--radius-sm);
}
.prose pre {
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-3); overflow-x: auto; margin: 0 0 var(--space-4);
}
.prose pre code { background: none; padding: 0; font-size: var(--text-sm); }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius-md); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-6) 0; }
.prose .table-wrap { overflow-x: auto; margin: 0 0 var(--space-4); } /* wide tables scroll (richtext.py) */
.prose table { margin: 0; }

/* -- Rich-text field: a textarea with a Format selector and a Write/Preview toggle (rich_field macro
   + richtext.js). The preview pane renders through the server's own sanitiser, so it never diverges
   from what will display. -- */
.rich-field { border: 1px solid var(--border-input, var(--border-strong)); border-radius: var(--radius-md); background: var(--bg); }
.rich-field-bar {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border);
}
.rich-field-bar .spacer { flex: 1 1 auto; }
.rich-field-format { width: auto; padding: var(--space-1) var(--space-2); }
.rich-field-tab { border: 0; background: none; color: var(--fg-muted); cursor: pointer; font: inherit; font-size: var(--text-sm); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); }
.rich-field-tab.is-active { color: var(--fg); background: var(--bg-sunken); font-weight: var(--weight-medium); }
.rich-field-input { border: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); background: transparent; min-height: 8rem; }
.rich-field-input:focus { box-shadow: none; }
.rich-field-preview { padding: var(--space-3); min-height: 8rem; }
.rich-field-preview:empty::before { content: "Nothing to preview yet."; color: var(--fg-subtle); }

/* -- Tables -- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
th { color: var(--fg-muted); font-weight: var(--weight-medium); }

/* -- Flash messages -- */
.flash {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  margin-bottom: var(--space-3); border: 1px solid;
}
.flash-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-fg); }
.flash-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-fg); }

/* -- Inline code / pill -- */
code {
  font-family: var(--font-mono); background: var(--bg);
  padding: 1px var(--space-2); border-radius: var(--radius-sm);
}
.pill {
  font-size: var(--text-sm); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 1px var(--space-2); color: var(--fg-muted);
}

/* -- Badges: status chips (triage queues, tables) -- */
.badge {
  display: inline-block; padding: 1px var(--space-2); border-radius: 999px;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  border: 1px solid var(--border-strong); color: var(--fg-muted);
}
.badge-new { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-fg); }
.badge-done { background: var(--success-bg); border-color: var(--success-border); color: var(--success-fg); }
/* A neutral accent badge for non-signal emphasis (a count, a "beta" flag) — reads as the palette, not
   as success/warning/danger. Text stays ink on a soft accent wash, so it passes contrast everywhere. */
.badge-accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); color: var(--fg); }

/* ================================================================================================
   COLOUR: categories, accents & data-viz. The kit leaned almost entirely on --accent + ink + paper,
   so every theme read as "three colours" even though the palettes carry more (gear accents, seasonal
   secondaries). These components put the rest of the palette to work.

   Two families, on purpose:
   - CATEGORY chips/tags use --accent + --accent-2..4 — theme-TRACKING, so they wear the active season.
   - The SWATCH/legend/bar data-viz primitives use --chart-1..6 — the STABLE encoding scale.

   The colour recipe is contrast-safe in every palette and mode: a soft wash (color-mix of the hue into
   the elevated surface) carries the colour, ink (--fg) carries the text, and the fuller hue is used
   only for a dot/rule (never behind text). So no category needs a hand-tuned "on-colour".
   ================================================================================================ */

/* Category chip: a rounded pill with a leading colour dot. `.chip` alone = accent; -2/-3/-4 shift hue.
   Set --chip-color directly for a bespoke one. Pair with a label: <span class="chip chip-3">Docs</span> */
.chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-sm); padding: 2px var(--space-3); border-radius: 999px;
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 14%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--chip-color, var(--accent)) 38%, var(--border));
  color: var(--fg);
}
.chip::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--chip-color, var(--accent)); }
.chip-1 { --chip-color: var(--accent); }
.chip-2 { --chip-color: var(--accent-2); }
.chip-3 { --chip-color: var(--accent-3); }
.chip-4 { --chip-color: var(--accent-4); }

/* Category tag variants (the existing .tag stays accent-soft). Same soft-wash + ink recipe as chips,
   without the dot — for the card-tags row and inline labels. */
.tag-1 { background: color-mix(in srgb, var(--accent)   18%, var(--bg-elev)); }
.tag-2 { background: color-mix(in srgb, var(--accent-2) 18%, var(--bg-elev)); }
.tag-3 { background: color-mix(in srgb, var(--accent-3) 18%, var(--bg-elev)); }
.tag-4 { background: color-mix(in srgb, var(--accent-4) 18%, var(--bg-elev)); }

/* DEPRECATED (v1.94.0): the accent RAIL read dated (shadcn-gap-audit.md). .panel-accent / .card-accent now
   render as a plain elevated panel/card — the left rule + wash are gone. Kept as no-op aliases so existing
   call sites don't break; drop the class next time you touch the markup. Accent goes on the primary action
   or the selected state, not container chrome. .title-accent (a heading underline) stays — that's type. */
.panel-accent { border-left: 1px solid var(--border); background: var(--bg-elev); }
.card-accent { border-left: 1px solid transparent; background: var(--bg-elev); }
.title-accent { position: relative; padding-bottom: var(--space-2); }
.title-accent::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 2.5rem; height: 3px; border-radius: 999px; background: var(--accent);
}

/* Data-viz: swatches + legend + a bar primitive, all reading the STABLE --chart-1..6 scale (mono greys
   them). Charts (SVG/canvas) should pull the same tokens via getComputedStyle so series colours match
   the legend. A single bar: <div class="bar-track"><div class="bar-fill swatch-2" style="width:60%">
   </div></div>. See dataviz archetype. */
.legend { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--fg-muted); }
.bar-track { background: var(--bg-sunken); border-radius: 999px; overflow: hidden; height: 12px; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
/* swatch-N last, so adding one to a .bar-fill (or a legend .swatch) sets the series colour — it wins on
   source order over the .bar-fill default without needing extra specificity. */
.swatch { flex: none; width: 14px; height: 14px; border-radius: var(--radius-sm); }
.swatch.dot { border-radius: 50%; }
.swatch-1 { background: var(--chart-1); }
.swatch-2 { background: var(--chart-2); }
.swatch-3 { background: var(--chart-3); }
.swatch-4 { background: var(--chart-4); }
.swatch-5 { background: var(--chart-5); }
.swatch-6 { background: var(--chart-6); }

/* -- Text helpers -- */
.muted { color: var(--fg-muted); }
.small { font-size: var(--text-sm); }
.optional { font-weight: var(--weight-normal); color: var(--fg-muted); }

/* -- Two-column form grid (collapses on phones) -- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }

/* ================================================================================================
   DISPLAY & FEEDBACK — tabs · progress · tooltip · spinner · stepper · the pill/tag family.
   ================================================================================================ */

/* -- Tabs: a real tablist. controls.js adds the ARIA roles, roving arrow-key focus, and panel toggling.
   Markup: <div class="tabs"><button class="tab" data-tab="a">A</button>…</div> and panels
   <div class="tab-panel" data-tab="a">…</div>. Underline by default; add .tabs-pill for the pill look. -- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); }
.tab {
  border: 0; background: none; font: inherit; cursor: pointer; color: var(--fg-muted);
  padding: var(--space-2) var(--space-3); border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--link); border-bottom-color: var(--accent); font-weight: var(--weight-medium); }
.tab:focus-visible { box-shadow: var(--shadow-focus); border-radius: var(--radius-sm); }
.tabs-pill { border-bottom: 0; }
.tabs-pill .tab { border-bottom: 0; border-radius: 999px; margin-bottom: 0; }
.tabs-pill .tab[aria-selected="true"] { background: var(--accent-soft); color: var(--link); }
.tab-panel[hidden] { display: none; }

/* -- Progress (progress.md): ONE component for every state. Adopt by CLASS —
   <div class="progress" data-value="60"> — and progress.js builds the track/fill/endpoint/readout, sets
   ARIA, and drives the states. Token-driven + reduced-motion-safe. Legacy <span class="progress-bar">
   markup still works (the enhancer reuses it as the fill). Data-attrs (all optional):
     data-value / data-max          the value (0..max, default max 100)
     data-mode   determinate|buffer|indeterminate|query   (default determinate)
     data-buffer                    the buffer % (buffer mode)
     data-colour accent|ramp|by-range  (+ data-stops="40:warm,80:success" for by-range)
     data-glow   off|soft|strong    (default strong; intensifies toward 100%)
     data-marks  "25,50:Halfway,75" milestone ticks (light up once passed)
     data-endpoint                  a handle on the leading edge (data-endpoint-shape=circle|bar,
                                    data-endpoint-size=sm|md|lg)
     data-units  pct|frac|count     the readout; data-header="Uploading" adds a title row
     data-celebrate                 the bigger 100% moment (confetti)
     data-fx     shimmer|…          in-progress effect (pixelate/sparkle are a later drop-in)
     data-size   sm|md|lg           track thickness
   With no JS a bare .progress shows an empty track; set --progress-value inline for a static fill. -- */
:root {
  --progress-h-sm: 6px;  --progress-h-md: 10px;  --progress-h-lg: 16px;
  --progress-track: var(--bg-sunken);
  --progress-accent: var(--accent);
  --progress-success: var(--success-fg);
}
.progress { --progress-value: 0%; --progress-glow: 0.5; display: block; }
/* Legacy .progress-bar with no .progress-track wrapper (pre-progress.js DOM — no JS, or the brief window
   before it runs): .progress-fill/.progress-bar below is position:absolute + height:100%, which needs a
   position:relative ancestor with a REAL height to resolve against. .progress-track normally supplies
   that, but bare legacy markup (<div class="progress"><span class="progress-bar" style="width:X%">) has
   no track wrapper at all — so with nothing here, the absolute box falls through to the INITIAL
   containing block (the viewport), rendering as a giant fill the size of the page until JS restructures
   the DOM. That's a broken promise: the comment below says "(also matches legacy .progress-bar)" — this
   is what makes that literally true, without waiting on JS. Scoped to :not(:has(.progress-track)) so the
   new head+track markup (which stacks taller than one bar) is completely untouched. */
.progress:not(:has(.progress-track)) { position: relative; height: var(--progress-h-md); border-radius: 999px;
  overflow: hidden; background: var(--progress-track); }
.progress[data-size="sm"]:not(:has(.progress-track)) { height: var(--progress-h-sm); }
.progress[data-size="lg"]:not(:has(.progress-track)) { height: var(--progress-h-lg); }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3);
  margin-bottom: var(--space-1); font-size: var(--text-sm); }
.progress-title { color: var(--fg-muted); font-weight: var(--weight-medium); }
.progress-readout { color: var(--fg-muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.progress.is-complete .progress-readout { color: var(--progress-success); font-weight: var(--weight-medium); }

/* The track is the pill; a clip child holds the moving parts (so they round to the pill) while the
   endpoint + marks overflow it (the handle sits proud of the bar, like a slider). */
.progress-track { position: relative; height: var(--progress-h-md); border-radius: 999px;
  background: var(--progress-track); }
.progress[data-size="sm"] .progress-track { height: var(--progress-h-sm); }
.progress[data-size="lg"] .progress-track { height: var(--progress-h-lg); }
.progress-clip { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }

/* Buffer track (buffer mode): a lighter fill ahead of the primary, with a dotted remainder beyond it. */
.progress-buffer { position: absolute; inset: 0 auto 0 0; width: var(--progress-buffer, 0%); height: 100%;
  background: color-mix(in srgb, var(--progress-color, var(--progress-accent)) 28%, transparent); }
.progress[data-mode="buffer"] .progress-track {
  background: radial-gradient(circle, var(--fg-subtle) 1px, transparent 1.4px) 0 50% / 8px 100% repeat-x, var(--progress-track); }

/* The fill (also matches legacy .progress-bar). */
.progress-fill, .progress-bar { position: absolute; inset: 0 auto 0 0; display: block; height: 100%;
  width: var(--progress-value, 0%); border-radius: 999px;
  background: var(--progress-color, var(--progress-accent));
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s; }
.progress.is-over .progress-fill, .progress.is-over .progress-bar { background: var(--danger-fg); }
.progress.is-complete .progress-fill, .progress.is-complete .progress-bar { background: var(--progress-success); }

/* Glow — an accent halo on the fill; layered for strong, and it scales with --progress-glow (JS raises
   it toward 100%). The colour is mixed from the live fill colour, so it tracks ramp/by-range + the theme. */
.progress[data-glow="soft"] .progress-fill, .progress[data-glow="soft"] .progress-bar {
  box-shadow: 0 0 calc(4px + 8px * var(--progress-glow, 0.5))
    color-mix(in srgb, var(--progress-color, var(--progress-accent)) 55%, transparent); }
.progress[data-glow="strong"] .progress-fill, .progress[data-glow="strong"] .progress-bar {
  box-shadow: 0 0 calc(5px + 9px * var(--progress-glow, 0.5))
      color-mix(in srgb, var(--progress-color, var(--progress-accent)) 60%, transparent),
    0 0 calc(11px + 20px * var(--progress-glow, 0.5))
      color-mix(in srgb, var(--progress-color, var(--progress-accent)) 40%, transparent); }

/* Shimmer (data-fx="shimmer") — a light sweeps the filled part while in progress. */
.progress-shimmer { position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, #fff 55%, transparent) 50%, transparent 80%);
  background-size: 220% 100%; animation: kit-progress-shimmer 1.6s linear infinite; }
.progress.is-complete .progress-shimmer { display: none; }
@keyframes kit-progress-shimmer { 0% { background-position: 180% 0; } 100% { background-position: -80% 0; } }

/* Indeterminate + query — a sliver travels the track (no known value). Query is faster + reversed. */
.progress-sliver { position: absolute; top: 0; bottom: 0; width: 35%; border-radius: 999px;
  background: var(--progress-color, var(--progress-accent)); }
.progress[data-mode="indeterminate"] .progress-sliver { animation: kit-progress-indeterminate 1.4s ease-in-out infinite; }
.progress[data-mode="query"] .progress-sliver { width: 30%; animation: kit-progress-query 0.9s ease-in-out infinite; }
@keyframes kit-progress-indeterminate { 0% { left: -40%; } 100% { left: 105%; } }
@keyframes kit-progress-query { 0% { left: 105%; } 100% { left: -40%; } }

/* Milestone marks — ticks at any %; light up once the fill passes them. Optional label sits under. */
.progress-mark { position: absolute; top: 50%; width: 2px; height: calc(100% + 4px); transform: translate(-50%, -50%);
  background: var(--border-strong); border-radius: 1px; z-index: 2; }
.progress-mark.is-passed { background: var(--on-accent); box-shadow: 0 0 0 1px var(--progress-color, var(--progress-accent)); }
.progress-mark-label { position: absolute; top: calc(100% + 6px); left: 0; transform: translateX(-50%);
  font-size: var(--text-sm); color: var(--fg-subtle); white-space: nowrap; }
.progress.has-mark-labels { margin-bottom: var(--space-6); }

/* Endpoint — a glowing node riding the LEADING EDGE of the live fill (reads like a slider handle). */
.progress-endpoint { position: absolute; top: 50%; left: var(--progress-value, 0%); z-index: 3;
  width: 14px; height: 14px; transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--progress-color, var(--progress-accent)); border: 2px solid var(--bg-elev);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--progress-color, var(--progress-accent)) 50%, transparent),
    0 0 calc(6px + 10px * var(--progress-glow, 0.5)) color-mix(in srgb, var(--progress-color, var(--progress-accent)) 65%, transparent);
  transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s; }
.progress[data-endpoint-size="sm"] .progress-endpoint { width: 10px; height: 10px; }
.progress[data-endpoint-size="lg"] .progress-endpoint { width: 20px; height: 20px; }
.progress[data-endpoint-shape="bar"] .progress-endpoint { border-radius: 3px; width: 8px; height: calc(100% + 8px); }
.progress[data-endpoint-shape="bar"][data-endpoint-size="lg"] .progress-endpoint { width: 10px; }
.progress.is-complete .progress-endpoint { background: var(--progress-success); }

/* Completion — the fill goes green (above), an SVG check self-draws + pops, and a one-shot burst fires. */
.progress-check { position: absolute; top: 50%; right: 0; transform: translate(50%, -50%); z-index: 4;
  width: 22px; height: 22px; border-radius: 50%; background: var(--progress-success); color: var(--on-accent);
  display: none; place-items: center; opacity: 0; }
.progress.is-complete .progress-check { display: grid; animation: kit-progress-pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
.progress-check svg { width: 14px; height: 14px; }
.progress-check path { stroke-dasharray: 20; stroke-dashoffset: 20; }
.progress.is-complete .progress-check path { animation: kit-progress-draw 0.4s 0.15s ease forwards; }
@keyframes kit-progress-pop { 0% { opacity: 0; transform: translate(50%, -50%) scale(0.4); }
  60% { opacity: 1; transform: translate(50%, -50%) scale(1.15); } 100% { opacity: 1; transform: translate(50%, -50%) scale(1); } }
@keyframes kit-progress-draw { to { stroke-dashoffset: 0; } }
.progress-burst { position: absolute; top: 50%; right: 0; width: 4px; height: 4px; z-index: 3; pointer-events: none; }
.progress.is-bursting .progress-burst::before, .progress.is-bursting .progress-burst::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--progress-success); animation: kit-progress-burst 0.6s ease-out forwards; }
.progress.is-bursting .progress-burst::after { animation-delay: 0.08s; }
@keyframes kit-progress-burst { 0% { transform: scale(0.5); opacity: 0.9; } 100% { transform: scale(6); opacity: 0; } }

/* Legacy readout row (pre-component markup): <div class="progress-meta"><span>…</span><span data-role=
   "progress-pct"></span></div>. The new component renders the readout in .progress-head instead. */
.progress-meta { display: flex; justify-content: space-between; font-size: var(--text-sm); color: var(--fg-muted); margin-top: 2px; }
.progress-meta .is-over, .progress-readout.is-over { color: var(--danger-fg); font-weight: var(--weight-medium); }

/* Reduced motion: no shimmer, no travelling sliver, no completion animation — the value still updates,
   the states still READ (a static indeterminate fill, the check shown), just without movement. */
@media (prefers-reduced-motion: reduce) {
  .progress-fill, .progress-bar, .progress-endpoint { transition: none; }
  .progress-shimmer { animation: none; display: none; }
  .progress-sliver { animation: none !important; left: 0; right: 0; width: 100%; opacity: 0.35; }
  .progress.is-complete .progress-check, .progress.is-complete .progress-check path { animation: none; }
  .progress.is-complete .progress-check { opacity: 1; }
  .progress.is-complete .progress-check path { stroke-dashoffset: 0; }
  .progress.is-bursting .progress-burst::before, .progress.is-bursting .progress-burst::after { animation: none; display: none; }
}

/* Skeleton / loading placeholder (progress.md) — pairs with indeterminate/query for content that hasn't
   arrived. <span class="skeleton" style="width:12rem"></span> or .skeleton-text / .skeleton-circle. */
.skeleton { display: block; border-radius: var(--radius-sm);
  background: linear-gradient(100deg, var(--bg-sunken) 30%, color-mix(in srgb, var(--fg-subtle) 22%, var(--bg-sunken)) 50%, var(--bg-sunken) 70%);
  background-size: 220% 100%; animation: kit-skeleton 1.4s linear infinite; }
.skeleton-text { height: 0.8em; margin: 0.25em 0; }
.skeleton-circle { border-radius: 50%; }
@keyframes kit-skeleton { 0% { background-position: 180% 0; } 100% { background-position: -80% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* -- Tooltip: [data-tooltip="…"] shows a themed bubble on hover AND keyboard focus (accessible, no OS
   `title` lag). Ink bubble, so it reads on any surface. Used by the build tag's hover detail. -- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; left: 50%; bottom: calc(100% + 6px);
  transform: translateX(-50%) translateY(4px); z-index: 300; max-width: 18rem; width: max-content;
  background: var(--fg); color: var(--bg-elev); font: var(--weight-normal) var(--text-sm)/1.4 var(--font-sans);
  white-space: pre-line; text-align: left; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-card);
  opacity: 0; pointer-events: none; transition: opacity 0.12s, transform 0.12s;
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tooltip].tooltip-end::after { left: auto; right: 0; transform: translateY(4px); }
[data-tooltip].tooltip-end:hover::after, [data-tooltip].tooltip-end:focus-visible::after { transform: translateY(0); }

/* -- Spinner: a standalone loader (the button's is built in). <span class="spinner"></span> -- */
.spinner { display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -0.15em; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: kit-spin 0.6s linear infinite; }
.spinner-lg { width: 2em; height: 2em; border-width: 3px; }

/* -- Stepper: a normalised number field with −/+ (controls.js clamps to min/max/step). Markup:
   <div class="stepper"><button type="button" data-step="-1">−</button><input type="number">
   <button type="button" data-step="1">+</button></div> -- */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--border-input); border-radius: var(--radius-md); overflow: hidden; }
.stepper input[type="number"] { width: 4rem; flex: none; border: 0; border-radius: 0; text-align: center; padding: var(--space-2); }
.stepper input[type="number"]:focus-visible { box-shadow: none; }
.stepper button { border: 0; width: 2rem; background: var(--bg-sunken); color: var(--fg); font: inherit; line-height: 1; cursor: pointer; }
.stepper button:hover { background: var(--border); }
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }

/* -- Pill / tag family: shape (pill rounded default | .pill-square rectangle), an optional "#" on tags,
   a dismiss ×, row/column orientation, and a subtle hover lift. The base .pill / .tag / .tag-1..4 above
   still work; these add variety on top. -- */
.tag, .pill { transition: transform 0.1s, background 0.12s, border-color 0.12s; }
.tag:hover, .pill:hover { transform: translateY(-1px); }
.tag { display: inline-flex; align-items: center; gap: 2px; }
.tag--hash::before { content: "#"; opacity: 0.6; }
.pill-square { border-radius: var(--radius-sm); }
.pill-solid { background: var(--accent); color: var(--on-accent); border-color: var(--accent-deep); }
.pill-outline { background: transparent; color: var(--fg); }
.tags { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.tags-col { flex-direction: column; align-items: flex-start; }
.tag-dismiss, .pill-dismiss { border: 0; background: none; color: inherit; cursor: pointer; opacity: 0.55; font-size: 1em; line-height: 1; padding: 0 1px; margin-left: 2px; }
.tag-dismiss:hover, .pill-dismiss:hover { opacity: 1; }

/* -- Toggle switch: a checkbox in a slider costume — <label class="switch"><input type="checkbox">
   <span class="track"></span> Label text</label>. The input stays real (forms, a11y, focus). -- */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  flex: none; width: 40px; height: 22px; border-radius: 999px;
  background: var(--border-input, var(--border-strong)); position: relative; transition: background 0.15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--bg-elev); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: left 0.15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { left: 20px; }
.switch input:focus-visible + .track { box-shadow: var(--shadow-focus); }

/* -- Accordion: a styled native <details> — open/close, keyboard, and a11y come free -- */
.accordion { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-elev); }
.accordion + .accordion { margin-top: var(--space-2); }
.accordion > summary {
  cursor: pointer; padding: var(--space-3) var(--space-4); font-weight: var(--weight-medium);
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::after { content: "+"; color: var(--fg-muted); }
.accordion[open] > summary::after { content: "\2212"; }
.accordion[open] > summary { border-bottom: 1px solid var(--border); }
.accordion-body { padding: var(--space-3) var(--space-4); }

/* -- Word art: expressive text utilities. Colors ride the theme tokens, so word art restyles with
   the palette like every other component. True ARCHED text needs SVG <textPath> (CSS cannot bend a
   baseline) — .wa-arch styles the SVG text; the design page carries a copy-ready snippet. -- */
.wa-strike { text-decoration: line-through; text-decoration-color: var(--danger-fg); text-decoration-thickness: 0.12em; }
.wa-wavy { text-decoration: underline wavy var(--accent); text-underline-offset: 0.2em; }
.wa-glow { text-shadow: 0 0 6px var(--accent-soft), 0 0 18px var(--accent); }
.wa-pop { text-shadow: 0.045em 0.045em 0 var(--accent), 0.09em 0.09em 0 var(--warning); }
.wa-angled { display: inline-block; transform: rotate(-4deg); }
.wa-outline { -webkit-text-stroke: 0.045em var(--fg); color: transparent; }
.wa-script { font-family: var(--font-script); font-size: 1.35em; }
.wa-arch { fill: var(--accent); font-family: var(--font-display); font-weight: var(--weight-bold); }

/* -- Comments / discussion (comments.md) — the drop-in [data-comments] panel + composer. Rendered by
      comments.js; bodies reuse .prose (the sanitised render target). No per-app markup. -- */
.comments { margin-top: var(--space-6); border-top: 1px solid var(--border); padding-top: var(--space-4); }
.comments-title { font-size: var(--text-lg); font-weight: var(--weight-medium); margin: 0 0 var(--space-4); }
.comment-list, .comment-replies { list-style: none; margin: 0; padding: 0; }
.comment { padding: var(--space-3) 0; border-top: 1px solid var(--border); }
.comment-list > .comment:first-child { border-top: 0; }
.comment-head { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.comment-author { font-weight: var(--weight-medium); color: var(--fg); }
.comment-meta { font-size: var(--text-sm, .875rem); color: var(--fg-subtle); }
.comment-body { margin-top: var(--space-2); }
.comment-tombstone { font-style: italic; margin: 0; }
.comment--deleted .comment-author { color: var(--fg-subtle); font-weight: normal; }
.comment-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
/* Replies indent one level only (threading is shallow), with a rule to show they hang off the parent. */
.comment-replies { margin-top: var(--space-2); margin-left: var(--space-4);
  padding-left: var(--space-3); border-left: 2px solid var(--border); }
.comment-replies:empty { display: none; }
/* Composer (top-level), reply and edit forms share one look. */
.comment-composer, .comment-reply-form, .comment-edit-form { margin-top: var(--space-3); }
.comment-input { width: 100%; min-height: 3.5rem; resize: vertical; }
.comment-composer-bar { display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-2); margin-top: var(--space-2); }
.comment-btns { display: inline-flex; gap: var(--space-2); }
.comment-hint { font-size: var(--text-sm, .875rem); }
.comment-status { color: var(--fg-muted); padding: var(--space-2) 0; }
.comment-error { color: var(--danger-fg); }
.comment-readonly { margin-top: var(--space-3); }
@media (max-width: 768px) {
  /* On a phone the reply rail eases off so the text keeps its width. */
  .comment-replies { margin-left: var(--space-2); padding-left: var(--space-2); }
}

/* -- Notifications (notifications.md) — the shell bell + inbox dropdown ([data-notifications]), driven by
      notifications.js. Bodies are plain text. -- */
.notif { position: relative; display: inline-flex; }
.notif-bell { position: relative; background: none; border: 0; color: inherit; cursor: pointer;
  padding: var(--space-2); border-radius: var(--radius-sm); font-size: 1.1rem; line-height: 1; }
.notif-bell:hover { background: var(--bg-sunken); }
.notif-icon { display: block; }  /* an inline SVG, not an emoji — block kills the baseline gap */
.notif-badge { position: absolute; top: 0; right: 0; box-sizing: border-box; min-width: 1.1rem; height: 1.1rem;
  padding: 0 0.25rem; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem;
  font-weight: var(--weight-bold); color: var(--on-accent); background: var(--accent); border-radius: 999px; }
.notif-panel { position: absolute; top: calc(100% + var(--space-2)); right: 0; z-index: 50;
  width: min(22rem, 90vw); max-height: 70vh; overflow-y: auto; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.notif-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-2); padding: var(--space-3); background: var(--bg-elev); border-bottom: 1px solid var(--border); }
.notif-heading { font-weight: var(--weight-medium); }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item { padding: var(--space-3); border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--bg-sunken); }
.notif-item--unread { background: var(--accent-soft); }
.notif-item--unread .notif-item-title { font-weight: var(--weight-medium); }
.notif-item-title { color: var(--fg); }
.notif-item-body { margin-top: 2px; color: var(--fg-muted); font-size: var(--text-sm, .875rem); }
.notif-item-meta { margin-top: var(--space-1); color: var(--fg-subtle); font-size: var(--text-sm, .875rem); }
.notif-status { padding: var(--space-4); text-align: center; }
.notif-error { color: var(--danger-fg); }
@media (max-width: 768px) {
  /* On a phone the dropdown spans the width instead of hanging off the bell. */
  .notif-panel { position: fixed; top: auto; right: var(--space-2); left: var(--space-2); width: auto; }
}

/* -- Changelog (versioning.md) — the /changelog page + the (now linked) build pill. -- */
.build-badge { text-decoration: none; }
.changelog { list-style: none; margin: var(--space-4) 0 0; padding: 0; }
.changelog-entry { padding: var(--space-4) 0; border-top: 1px solid var(--border); }
.changelog-entry:first-child { border-top: 0; }
.changelog-entry-head { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.changelog-version { font-family: var(--font-mono); font-weight: var(--weight-bold); }
.changelog-date { color: var(--fg-subtle); font-size: var(--text-sm, .875rem); }
.changelog-headline { margin: var(--space-2) 0 0; }
.changelog-details { margin: var(--space-2) 0 0; padding-left: var(--space-4); color: var(--fg-muted); }
.changelog-details li { margin: var(--space-1) 0; }
.changelog-kind { text-transform: capitalize; }
.changelog-kind--feature { background: var(--accent-soft); color: var(--accent-deep); }
.changelog-kind--security, .changelog-kind--breaking { background: var(--danger-bg); color: var(--danger-fg); }
.changelog-build { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4);
  font-size: var(--text-sm, .875rem); color: var(--fg-muted); }
.changelog-build code { font-family: var(--font-mono); }
.changelog-foot { margin-top: var(--space-4); }

/* -- User settings (user-settings.md) — the /settings preferences form. Reuses .field / .input / .switch. -- */
.settings-form { display: flex; flex-direction: column; gap: var(--space-4); }
.settings-field { margin: 0; max-width: 32rem; }
.settings-actions { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-2); }
.settings-status { font-size: var(--text-sm, .875rem); }

/* -- Keyboard shortcuts (keymap.md) — the /keymap remap page (capture buttons). -- */
.keymap-list { list-style: none; margin: var(--space-4) 0 0; padding: 0; }
.keymap-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-top: 1px solid var(--border); }
.keymap-row:first-child { border-top: 0; }
.keymap-label { flex: 1; }
.keymap-chord { min-width: 7rem; font-family: var(--font-mono); }
.keymap-chord.keymap-capturing { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.keymap-chord.keymap-unbound { color: var(--fg-subtle); font-style: italic; }
.keymap-actions { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.keymap-status { font-size: var(--text-sm, .875rem); }

/* -- Responsive: the kit must survive resize AND rotation (layout.md breakpoints) -- */
@media (max-width: 1024px) {
  /* Wide tables (audit trails, code cells) scroll in place instead of widening the page. */
  table { display: block; overflow-x: auto; }
}
@media (max-width: 768px) {
  /* Below md the header collapses by WRAPPING — nav drops under the brand, nothing overflows. */
  .app-header { flex-wrap: wrap; }
  .app-nav { flex-wrap: wrap; row-gap: var(--space-2); }
}

/* ================================================================================================
   SHADCN-PARITY PRIMITIVES (v1.94.0, shadcn-gap-audit.md) — status treatments, semantic badges, switch,
   dropdown-menu, avatar, alert, separator, the tabs view-switcher. All adopt-by-class, token-driven,
   light + dark, a11y + reduced-motion-safe.
   ================================================================================================ */

/* -- Status colours: ONE shared token set the dot / pill / chip / stamp all read, so a status looks the
   same everywhere. Each is a soft-bg + deep-fg PAIR (the badge contract) → legible in BOTH themes; --st is
   the saturated hue for the dot/LED/stamp ink. Six kanban states. -- */
.st-todo     { --st: var(--fg-subtle);  --st-bg: var(--bg-sunken);    --st-fg: var(--fg-muted); }
.st-progress { --st: var(--accent);     --st-bg: var(--accent-soft);  --st-fg: var(--accent-deep); }
.st-review   { --st: var(--warning);    --st-bg: var(--warning-bg);   --st-fg: var(--warning-fg); }
.st-blocked  { --st: var(--danger-fg);  --st-bg: var(--danger-bg);    --st-fg: var(--danger-fg); }
.st-approved { --st: var(--gear-blue);  --st-bg: color-mix(in srgb, var(--gear-blue) 15%, var(--bg-elev)); --st-fg: var(--gear-blue-deep); }
.st-done     { --st: var(--success-fg); --st-bg: var(--success-bg);   --st-fg: var(--success-fg); }

/* Plain status affordances (the cheap default): a dot, or a labelled pill. */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--st); flex: none; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--st-bg); color: var(--st-fg);
  border-radius: 999px; padding: 1px var(--space-3); font-size: var(--text-sm); font-weight: var(--weight-medium); }

/* Card status — PHYSICAL treatments (put on a .card.st-<state>; apps pick one, or hybridise: stamp on
   terminal states, chip on the rest). Both live on the card, never as a chrome rail. */

/* Rubber stamp: an angled, slightly-worn ink imprint. Best for terminal states (Approved/Done/Blocked). */
.card-stamp { position: absolute; top: var(--space-3); right: var(--space-3); transform: rotate(-8deg);
  color: var(--st); border: 2px solid var(--st); border-radius: var(--radius-sm); padding: 2px var(--space-2);
  font-size: var(--text-sm); font-weight: var(--weight-bold); letter-spacing: 0.08em; text-transform: uppercase;
  opacity: 0.62; mix-blend-mode: multiply; pointer-events: none; z-index: 2; }
body[data-mode="dark"] .card-stamp { mix-blend-mode: screen; opacity: 0.8; }

/* Flat LED chip (NOT embossed): a soft-bg chip with a lit status light; In-progress + Blocked gently pulse. */
.status-chip { display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
  background: var(--st-bg); color: var(--st-fg); border-radius: 999px; padding: 3px var(--space-3) 3px var(--space-2);
  font-size: var(--text-sm); font-weight: var(--weight-medium); }
.status-led { width: 8px; height: 8px; border-radius: 50%; background: var(--st); flex: none;
  box-shadow: 0 0 0 2px var(--st-bg), 0 0 6px var(--st); }
.st-progress .status-led, .st-blocked .status-led { animation: kit-led 1.6s ease-in-out infinite; }
@keyframes kit-led { 0%, 100% { box-shadow: 0 0 0 2px var(--st-bg), 0 0 4px var(--st); }
  50% { box-shadow: 0 0 0 2px var(--st-bg), 0 0 9px var(--st); } }
@media (prefers-reduced-motion: reduce) { .status-led { animation: none !important; } }

/* -- Badge: semantic variants over the existing .badge base (soft-bg + deep-fg → a11y-safe both themes). -- */
.badge-info    { background: color-mix(in srgb, var(--info) 12%, var(--bg-elev)); border-color: color-mix(in srgb, var(--info) 38%, var(--border)); color: var(--info); }
.badge-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-fg); }
.badge-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-fg); }
.badge-danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger-fg); }
.badge-neutral { background: var(--bg-sunken);  border-color: var(--border-strong);  color: var(--fg-muted); }

/* -- Switch: a toggle over a REAL checkbox (add role="switch"), so it's keyboard + screen-reader native.
   <label class="switch"><input type="checkbox" role="switch"><span class="switch-slider"></span> Label</label> -- */
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.switch > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-slider { position: relative; width: 36px; height: 20px; flex: none; border-radius: 999px;
  background: var(--border-strong); transition: background 0.16s ease; }
.switch-slider::before { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--bg-elev); box-shadow: var(--shadow-soft); transition: transform 0.16s ease; }
.switch > input:checked + .switch-slider { background: var(--accent); }
.switch > input:checked + .switch-slider::before { transform: translateX(16px); }
.switch > input:focus-visible + .switch-slider { box-shadow: var(--shadow-focus); }
.switch > input:disabled + .switch-slider { opacity: 0.5; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .switch-slider, .switch-slider::before { transition: none; } }

/* -- Dropdown-menu: native <details> (opens with no JS); controls.js adds outside-click close when present.
   <details class="dropdown"><summary class="btn btn-sm">Actions</summary>
     <div class="dropdown-menu" role="menu"><button class="dropdown-item" role="menuitem">Edit</button>…</div>
   </details> -- */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; min-width: 180px;
  display: flex; flex-direction: column; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lift); padding: var(--space-1); }
.dropdown-menu.dropdown-end { left: auto; right: 0; }
.dropdown-item { display: flex; align-items: center; gap: var(--space-2); width: 100%; text-align: left;
  background: none; border: 0; font: inherit; color: var(--fg); text-decoration: none; cursor: pointer;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); }
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--bg-sunken); outline: none; }
.dropdown-item.danger { color: var(--danger-fg); }
.dropdown-item[aria-disabled="true"] { color: var(--fg-subtle); pointer-events: none; }
.dropdown-sep { height: 1px; background: var(--divider); margin: var(--space-1) 0; }

/* -- Avatar: initials or an image, in sizes; group to overlap. -- */
.avatar { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
  overflow: hidden; background: var(--bg-sunken); color: var(--fg); font-size: var(--text-sm);
  font-weight: var(--weight-bold); user-select: none; }
.avatar > img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 24px; height: 24px; font-size: var(--text-sm); }
.avatar-lg { width: 44px; height: 44px; font-size: var(--text-lg); }
.avatar-group { display: inline-flex; }
.avatar-group > .avatar { border: 2px solid var(--bg-elev); }
.avatar-group > .avatar + .avatar { margin-left: -8px; }

/* -- Alert: a PERSISTENT, semantic inline message (distinct from the transient flash / kitToast).
   <div class="alert alert-warning"><span class="alert-icon">…</span><div><p class="alert-title">…</p>
   <p class="alert-body">…</p></div></div> -- */
.alert { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-elev); }
.alert-icon { flex: none; line-height: 1.5; display: inline-flex; }
.alert-title { margin: 0 0 2px; font-weight: var(--weight-medium); }
.alert-body { margin: 0; color: var(--fg-muted); font-size: var(--text-sm); }
.alert-info    { background: color-mix(in srgb, var(--info) 8%, var(--bg-elev)); border-color: color-mix(in srgb, var(--info) 32%, var(--border)); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger-border); }
.alert-info .alert-icon { color: var(--info); } .alert-success .alert-icon { color: var(--success-fg); }
.alert-warning .alert-icon { color: var(--warning-fg); } .alert-danger .alert-icon { color: var(--danger-fg); }

/* -- Separator: a themed rule. Horizontal by default; .separator-v between inline items; a labelled one. -- */
.separator { height: 1px; border: 0; background: var(--divider); margin: var(--space-4) 0; }
.separator-v { align-self: stretch; width: 1px; background: var(--divider); margin: 0 var(--space-3); }
.separator-label { display: flex; align-items: center; gap: var(--space-3); color: var(--fg-subtle); font-size: var(--text-sm); }
.separator-label::before, .separator-label::after { content: ""; flex: 1; height: 1px; background: var(--divider); }

/* -- Tabs, the workspace VIEW-SWITCHER look: a segmented control. Add .tabs-segment alongside .tabs so the
   controls.js roving-tab a11y still applies. <div class="tabs tabs-segment">…</div> -- */
.tabs-segment { border-bottom: 0; gap: 2px; padding: 3px; background: var(--bg-sunken); border-radius: var(--radius-md); }
.tabs-segment .tab { margin-bottom: 0; border-bottom: 0; border-radius: var(--radius-sm); padding: var(--space-1) var(--space-3); color: var(--fg-muted); }
.tabs-segment .tab:hover { color: var(--fg); }
.tabs-segment .tab[aria-selected="true"] { background: var(--bg-elev); color: var(--fg); border-bottom: 0; box-shadow: var(--shadow-soft); }

/* ================================================================================================
   OVERLAYS (v1.98.0, overlays.md) — command palette · combobox · rich popover. Toast queue is the
   reworked kitToast above. All adopt-by-class + a small enhancer (palette.js / combobox.js / popover.js).
   ================================================================================================ */

/* A themed keycap, for shortcut hints. */
kbd { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--fg-muted);
  background: var(--bg-sunken); border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: var(--radius-sm); padding: 1px 6px; }

/* Command palette (palette.js) — rendered inside a kitModal panel flagged .modal-bare (no modal chrome, the
   palette brings its own). */
.modal.modal-bare { padding: 0; background: transparent; border: 0; box-shadow: none; width: min(560px, 92vw); max-width: none; }
.cmdk { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift); overflow: hidden; }
.cmdk-input-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--divider); }
.cmdk-input-row svg { color: var(--fg-subtle); flex: none; }
.cmdk-input { flex: 1; border: 0; background: none; font: inherit; font-size: 1.05rem; color: var(--fg); outline: none; }
.cmdk-input::placeholder { color: var(--fg-subtle); }
.cmdk-list { max-height: min(52vh, 360px); overflow: auto; padding: var(--space-1); }
.cmdk-group { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-subtle); padding: 10px 10px 4px; font-weight: var(--weight-bold); }
.cmdk-item { display: flex; align-items: center; gap: var(--space-3); padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--fg); }
.cmdk-ico { width: 20px; text-align: center; color: var(--fg-muted); flex: none; }
.cmdk-lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-hint { color: var(--fg-subtle); }
.cmdk-item.active { background: var(--accent-soft); }
.cmdk-item.active .cmdk-ico { color: var(--accent-deep); }
.cmdk-empty { padding: var(--space-6) var(--space-3); text-align: center; color: var(--fg-subtle); }
.cmdk-foot { display: flex; gap: var(--space-4); padding: 9px var(--space-4); border-top: 1px solid var(--divider); font-size: var(--text-sm); color: var(--fg-subtle); }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* Combobox (combobox.js) — a typeahead over authored <li role=option> children. */
.combobox { position: relative; }
.combobox-input { width: 100%; font: inherit; padding: var(--space-2) var(--space-3); line-height: 1.35;
  background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border-input); border-radius: var(--radius-sm); }
.combobox-input:focus { outline: none; box-shadow: var(--shadow-focus); border-color: var(--accent); }
.combobox-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40; list-style: none;
  margin: 0; padding: var(--space-1); max-height: 240px; overflow: auto; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lift); }
.combobox-list[hidden] { display: none; }
.combobox-list li { display: flex; align-items: center; gap: var(--space-2); padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.combobox-list li.active { background: var(--accent-soft); }
.combobox-list li[hidden] { display: none; }
.combobox-list mark { background: transparent; color: var(--accent-deep); font-weight: var(--weight-bold); }

/* Tag input (taginput.js) — a chip field: many free-text values, keyboard-driven, chips spring in/out + reflow. */
.taginput { --ti-move: 280ms cubic-bezier(.2, .8, .2, 1); --ti-fade: 170ms ease; width: 100%; }
.taginput-list { list-style: none; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 40px; max-height: 116px; overflow-y: auto; overscroll-behavior: contain; padding: 4px;
  border: 2px solid var(--border-input); border-radius: var(--radius-md); background: var(--bg-sunken, var(--bg-elev));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06); transition: background-color .15s, border-color .15s, box-shadow .15s; cursor: text; }
.taginput-list:focus-within { border-color: var(--accent); background: var(--bg-elev); box-shadow: var(--shadow-focus); }
.taginput-chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; max-width: 100%; flex: 0 0 auto;
  padding: 0 5px 0 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elev);
  color: var(--fg); font-size: 12.5px; user-select: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  transition: transform var(--ti-move), opacity var(--ti-fade), background-color .15s, border-color .15s, color .15s; }
.taginput-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.taginput-chip.is-lit { background: var(--fg); color: var(--bg-elev); border-color: var(--fg); }
.taginput-chip.is-flash { animation: ti-flash 460ms ease; }
.taginput-chip.is-entering { opacity: 0; transform: scale(.9); }
.taginput-chip.is-leaving { opacity: 0; transform: scale(.86); }
.taginput-chip-x { display: grid; place-items: center; width: 14px; height: 14px; margin-right: -1px; padding: 0; border: 0;
  background: transparent; color: var(--fg-subtle); cursor: pointer; border-radius: 5px; transition: color .15s, background-color .15s; }
.taginput-chip-x:hover { color: var(--fg); }
.taginput-chip.is-lit .taginput-chip-x { color: color-mix(in srgb, var(--bg-elev) 70%, transparent); }
.taginput-chip.is-lit .taginput-chip-x:hover { color: var(--bg-elev); }
.taginput-chip-x svg { width: 9px; height: 9px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.taginput-entry-wrap { position: relative; display: inline-flex; height: 24px; flex: 1 1 60px; min-width: 60px; }
.taginput-sizer { visibility: hidden; white-space: pre; max-width: 220px; overflow: hidden; padding: 0 4px; font-size: 12.5px; }
.taginput-entry { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; font: inherit;
  font-size: 12.5px; color: var(--fg); padding: 0 4px; outline: none; }
.taginput-entry::placeholder { color: var(--fg-subtle); }
.taginput-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 6px; }
.taginput-hintwrap { position: relative; flex: 1; min-width: 0; }
.taginput-hint, .taginput-msg { margin: 0; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity var(--ti-fade); }
.taginput-hint { color: var(--fg-subtle); }
.taginput-msg { position: absolute; inset: 0; color: var(--fg); opacity: 0; }
.taginput.is-rejecting .taginput-hint { opacity: 0; }
.taginput.is-rejecting .taginput-msg { opacity: 1; }
.taginput-count { margin: 0; flex: 0 0 auto; font-size: 11.5px; color: var(--fg-subtle); font-variant-numeric: tabular-nums; }
.taginput-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@keyframes ti-flash { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .taginput-chip { transition: background-color .15s, border-color .15s, color .15s; } }

/* Federated search (search.js, search.md) — a global search box + inline field autofill over /api/v1/search.
   Grouped, highlighted, keyboard-navigable results in a dropdown panel; scope chips + a "Recent" band. */
.search { position: relative; }
.search-input { width: 100%; font: inherit; padding: var(--space-2) var(--space-3); line-height: 1.35;
  background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border-input); border-radius: var(--radius-sm); }
.search-input:focus { outline: none; box-shadow: var(--shadow-focus); border-color: var(--accent); }
.search-panel { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 45; padding: var(--space-1);
  max-height: 380px; overflow: auto; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lift); }
.search-panel[hidden] { display: none; }
.search-scopes { display: flex; flex-wrap: wrap; gap: var(--space-1); padding: 4px 4px 8px; }
.search-chip { font: inherit; font-size: var(--text-sm); padding: 3px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg-muted); }
.search-chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.search-group { font-size: var(--text-sm); letter-spacing: .06em; text-transform: uppercase; color: var(--fg-subtle);
  font-weight: var(--weight-bold); padding: 8px 10px 4px; }
.search-result { display: flex; align-items: center; gap: var(--space-2); padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; color: var(--fg); }
.search-result.active, .search-result:hover { background: var(--accent-soft); }
.search-icon { flex: 0 0 auto; width: 1.2em; text-align: center; color: var(--fg-muted); }
.search-main { min-width: 0; display: flex; flex-direction: column; }
.search-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-sub { font-size: var(--text-sm); color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-kind { flex: 0 0 auto; margin-left: auto; font-size: var(--text-sm); letter-spacing: .04em; text-transform: uppercase;
  color: var(--fg-subtle); background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 1px 6px; }
.search-result mark { background: transparent; color: var(--accent-deep); font-weight: var(--weight-bold); }
.search-empty { padding: 14px 10px; color: var(--fg-muted); font-size: var(--text-sm); text-align: center; }
.search-panel[aria-busy="true"]::after { content: "Searching…"; display: block; padding: 8px 10px;
  color: var(--fg-subtle); font-size: var(--text-sm); }

/* Rich popover (popover.js) — an anchored panel with arbitrary content + an arrow. */
.popover-anchor { position: relative; display: inline-block; }
.popover { position: absolute; top: calc(100% + 10px); left: 0; z-index: 50; min-width: 240px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift); padding: var(--space-4); }
.popover[hidden] { display: none; }
.popover::before { content: ""; position: absolute; top: -6px; left: 22px; width: 11px; height: 11px;
  background: var(--bg-elev); border-left: 1px solid var(--border); border-top: 1px solid var(--border); transform: rotate(45deg); }
.popover-end { left: auto; right: 0; }
.popover-end::before { left: auto; right: 22px; }
.popover-above { top: auto; bottom: calc(100% + 10px); }
.popover-above::before { top: auto; bottom: -6px; border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* ================================================================================================
   TERMINAL / CONSOLE TUI KIT (v1.100.0, terminal.md) — a pseudo-monitor surface for commands, live logs,
   and job runs. Mono, box-drawing, ANSI colours from the FIXED terminal palette (tokens.css). The console
   is a deliberately dark surface in both page themes. console.js drives the log tail + prompt + tui-select;
   the text progress bars are rendered by progress.js.
   ================================================================================================ */

/* Light/dark access + palette tie. Default is the dark console (tokens.css). `.term-light` forces a light
   terminal; `.term-auto` follows the page theme. The light set maps the ANSI roles onto the palette's
   semantic tokens (which suit a light surface), so brand + occasion palettes recolour it. Put the modifier
   on the terminal root (.console / .tui-table / .statusline …); the custom properties inherit to children. */
.term-light, .term-auto {
  --term-bg: var(--bg-elev); --term-panel: var(--bg-sunken); --term-head: var(--bg-sunken);
  --term-border: var(--border); --term-fg: var(--fg); --term-dim: var(--fg-subtle); --term-sel: var(--accent-soft);
  --t-green: var(--success-fg); --t-red: var(--danger-fg); --t-yellow: var(--warning-fg);
  --t-blue: var(--accent); --t-cyan: var(--info); --t-magenta: var(--gear-blue);
}
/* .term-auto → dark set when the page is dark (OS-dark with no stamp, or data-mode="dark"); re-assert light
   when the operator explicitly chose light. Mirrors the kit's own token contract (tokens.css). */
.term-dark-tokens, body[data-mode="dark"] .term-auto {
  --term-bg: #0b0e15; --term-panel: #10151f; --term-head: #161c28; --term-border: #232b3a;
  --term-fg: #cdd6e4; --term-dim: #67718a; --term-sel: #1b2740;
  --t-green: #5ad07a; --t-red: #ff6b6b; --t-yellow: #ffcf5a; --t-cyan: #4fd6e0; --t-magenta: #c79bff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode]) .term-auto {
    --term-bg: #0b0e15; --term-panel: #10151f; --term-head: #161c28; --term-border: #232b3a;
    --term-fg: #cdd6e4; --term-dim: #67718a; --term-sel: #1b2740;
    --t-green: #5ad07a; --t-red: #ff6b6b; --t-yellow: #ffcf5a; --t-cyan: #4fd6e0; --t-magenta: #c79bff;
  }
}
body[data-mode="light"] .term-auto {
  --term-bg: var(--bg-elev); --term-panel: var(--bg-sunken); --term-head: var(--bg-sunken);
  --term-border: var(--border); --term-fg: var(--fg); --term-dim: var(--fg-subtle); --term-sel: var(--accent-soft);
  --t-green: var(--success-fg); --t-red: var(--danger-fg); --t-yellow: var(--warning-fg);
  --t-blue: var(--accent); --t-cyan: var(--info); --t-magenta: var(--gear-blue);
}

.console { background: var(--term-bg); border: 1px solid var(--term-border); border-radius: var(--radius-md);
  overflow: hidden; font-family: var(--font-mono); font-size: 13px; line-height: 1.65; color: var(--term-fg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.console-head { display: flex; align-items: center; gap: var(--space-3); padding: 9px var(--space-3);
  background: var(--term-head); border-bottom: 1px solid var(--term-border); }
.console-lights { display: flex; gap: 6px; }
.console-lights i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.console-lights .r { background: #ff5f57; } .console-lights .y { background: #febc2e; } .console-lights .g { background: #28c840; }
.console-title { color: var(--term-dim); font-size: 12px; }
.console-title b { color: var(--term-fg); font-weight: var(--weight-medium); }
.console-tools { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }
.console-btn { font: inherit; font-size: 11px; cursor: pointer; background: transparent; color: var(--term-dim);
  border: 1px solid var(--term-border); border-radius: var(--radius-sm); padding: 2px 8px; }
.console-btn:hover { color: var(--term-fg); border-color: var(--term-dim); }
.console-tail { display: inline-flex; align-items: center; gap: 5px; color: var(--term-dim); font-size: 12px; }
.console-tail::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--t-green);
  box-shadow: 0 0 6px var(--t-green); animation: kit-blink 1.2s step-start infinite; }
.console[data-tailing="off"] .console-tail::before { background: var(--term-dim); box-shadow: none; animation: none; }
@keyframes kit-blink { 50% { opacity: 0.25; } }
.console-log { padding: var(--space-3) var(--space-4); max-height: 340px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console-line { display: block; }
.console-ts { color: var(--term-dim); }
.console-lvl { font-weight: var(--weight-bold); }
.lvl-ok { color: var(--t-green); } .lvl-info { color: var(--t-blue); } .lvl-warn { color: var(--t-yellow); }
.lvl-err { color: var(--t-red); } .lvl-dbg { color: var(--term-dim); }
.console .path, .tui-path { color: var(--t-cyan); } .console .num, .tui-num { color: var(--t-magenta); } .console .dim, .tui-dim { color: var(--term-dim); }
.console-prompt { display: flex; align-items: center; gap: var(--space-2); padding: 9px var(--space-4);
  border-top: 1px solid var(--term-border); background: rgba(0, 0, 0, 0.2); }
.console-ps1 { color: var(--t-green); flex: none; }
.console-input { flex: 1; background: none; border: 0; outline: none; color: var(--term-fg); font-family: var(--font-mono); font-size: 13px; }
.console-input::placeholder { color: var(--term-dim); }

/* Box-drawing table + status line + terminal badges — mono, on the terminal palette. */
.tui-table { font-family: var(--font-mono); font-size: 13px; line-height: 1.5; color: var(--term-fg);
  background: var(--term-bg); border: 1px solid var(--term-border); border-radius: var(--radius-md);
  padding: var(--space-3); margin: 0; overflow-x: auto; }
.statusline { display: inline-flex; font-family: var(--font-mono); font-size: 12px; border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--term-border); }
.statusline .seg { padding: 3px 10px; }
.statusline .sl-mode { background: var(--t-green); color: #04120a; font-weight: var(--weight-bold); }
.statusline .sl-path { background: var(--term-head); color: var(--term-fg); }
.statusline .sl-spacer { background: var(--term-panel); flex: 1; }
.statusline .sl-info { background: var(--term-head); color: var(--term-dim); }
.statusline .sl-pos { background: var(--t-blue); color: #04121f; font-weight: var(--weight-bold); }
.term-badge { font-family: var(--font-mono); font-size: 12px; padding: 1px 8px; border-radius: var(--radius-sm); border: 1px solid currentColor; }
.term-badge.run { color: var(--t-green); } .term-badge.warn { color: var(--t-yellow); }
.term-badge.err { color: var(--t-red); } .term-badge.idle { color: var(--term-dim); }

/* TUI select — a keyboard menu with a ">" cursor (console.js drives ↑↓ + click). */
.tui-select { list-style: none; margin: 0; padding: 0; font-family: var(--font-mono); font-size: 13px; color: var(--term-fg); }
.tui-select li { display: flex; gap: var(--space-2); padding: 2px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.tui-select li .cur { width: 12px; color: var(--t-green); }
.tui-select li.sel { background: var(--term-sel); }
.tui-select li .badge { margin-left: auto; color: var(--term-dim); }

/* Braille spinner — pure-CSS frame cycle. <span class="tui-spinner"></span> */
.tui-spinner::after { content: "⠋"; animation: kit-braille 0.9s steps(1) infinite; }
@keyframes kit-braille { 0%{content:"⠋"} 10%{content:"⠙"} 20%{content:"⠹"} 30%{content:"⠸"} 40%{content:"⠼"}
  50%{content:"⠴"} 60%{content:"⠦"} 70%{content:"⠧"} 80%{content:"⠇"} 90%{content:"⠏"} }

/* Text progress bar (progress.js text renderer) — a monospace bar in any of several styles. Works on a
   light page (bg-sunken track) or inside a console (term-sel track). */
.progress-text { font-family: var(--font-mono); display: inline-flex; align-items: center; gap: var(--space-2); }
.progress-text .pbar { white-space: pre; letter-spacing: 0.5px; }
.progress-text .track { background: var(--bg-sunken); border-radius: 2px; }
.progress-text .ppct { color: var(--fg-muted); }
.console .progress-text .track, .tui-table .track { background: var(--term-sel); }
.console .progress-text .ppct { color: var(--t-magenta); }
@media (prefers-reduced-motion: reduce) { .tui-spinner::after, .console-tail::before { animation: none; } }

/* Reorder list (reorder.js) — a manual-order list: drag a row, or grab it with the keyboard and move it. */
.reorder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.reorder-item { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3);
  background: var(--bg-elev); border: 1px solid var(--border-input); border-radius: var(--radius-md);
  cursor: grab; outline: none; user-select: none; touch-action: pan-x;
  transition: border-color .15s, box-shadow .15s, background-color .15s; }
.reorder-item:focus-visible { box-shadow: var(--shadow-focus); border-color: var(--accent); }
.reorder-item.is-grabbed { cursor: grabbing; border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--shadow-focus); }
.reorder-item.is-dragging { cursor: grabbing; position: relative; z-index: 2; border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 14px 28px -16px rgba(0, 0, 0, .5); }
.reorder-grip { flex: 0 0 auto; width: 10px; height: 16px; cursor: grab; color: var(--fg-subtle);
  background-image: radial-gradient(currentColor 1.1px, transparent 1.3px); background-size: 5px 4.6px;
  background-position: 0 2px; align-self: center; transition: color .15s; }
.reorder-item:hover .reorder-grip, .reorder-item.is-dragging .reorder-grip, .reorder-item.is-grabbed .reorder-grip { color: var(--fg); }
.reorder-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .reorder-item { transition: border-color .15s, background-color .15s; } }

/* Sketch — a small paint block (sketch.js + vendored perfect-freehand). Chrome is theme-aware via
   tokens; the drawing surface is a CONSTANT paper set by the JS (artwork colours never touch the CSS,
   so this block stays on semantic tokens like the rest of the kit). */
.sketch { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); overflow: hidden; }
.sketch-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  padding: 10px var(--space-3); border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--bg-elev), color-mix(in srgb, var(--bg-elev) 88%, var(--bg-sunken))); }
.sketch-group { display: flex; align-items: center; gap: 4px; }
.sketch-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.sketch-spring { flex: 1 1 auto; }
.sketch-tool { appearance: none; -webkit-appearance: none; cursor: pointer; display: inline-grid;
  place-items: center; width: 38px; height: 36px; padding: 0; background: transparent; color: var(--fg-muted);
  border: 1px solid transparent; border-radius: var(--radius-md);
  transition: background-color .12s ease, color .12s ease, border-color .12s ease, transform .06s ease; }
.sketch-tool svg { width: 20px; height: 20px; display: block; }
.sketch-tool:hover:not(:disabled) { background: var(--bg-sunken); color: var(--fg); }
.sketch-tool:active:not(:disabled) { transform: translateY(1px); }
.sketch-tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-deep);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent); }
.sketch-tool:disabled { opacity: .38; cursor: not-allowed; }
.sketch-tool:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.sketch-tool-text { width: auto; padding: 0 12px; gap: 6px; grid-auto-flow: column;
  font-size: var(--text-sm); font-weight: var(--weight-medium); }
.sketch-swatches { flex-wrap: wrap; gap: 5px; }
.sketch-swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent); position: relative;
  transition: transform .1s ease; }
.sketch-swatch:hover { transform: scale(1.12); }
.sketch-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--accent); }
.sketch-swatch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg-elev), var(--shadow-focus); }
.sketch-swatch-custom { display: grid; place-items: center; overflow: hidden;
  background: conic-gradient(from 90deg, #ef4444, #eab308, #22c55e, #06b6d4, #3b82f6, #a855f7, #ef4444); }
.sketch-swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0; border: 0; }
.sketch-size { gap: 10px; padding: 0 4px; }
.sketch-size-preview { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; }
.sketch-size-preview i { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--fg); }
.sketch-size input[type=range] { width: 108px; accent-color: var(--accent); cursor: pointer; }
.sketch-readout { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--fg-muted);
  font-variant-numeric: tabular-nums; min-width: 42px; }
.sketch-stage { position: relative; padding: clamp(14px, 3vw, 28px);
  background: repeating-linear-gradient(45deg, transparent, transparent 9px,
    color-mix(in srgb, var(--bg-sunken) 60%, transparent) 9px, color-mix(in srgb, var(--bg-sunken) 60%, transparent) 10px); }
.sketch-frame { position: relative; margin: 0 auto; max-width: 100%; border-radius: var(--radius-sm);
  box-shadow: 0 1px 1px rgba(16,24,40,.05), 0 22px 50px -18px rgba(16,24,40,.30); }
body[data-mode="dark"] .sketch-frame { box-shadow: 0 1px 1px rgba(0,0,0,.4), 0 26px 60px -20px rgba(0,0,0,.7); }
.sketch-canvas { display: block; width: 100%; height: auto; border-radius: var(--radius-sm);
  touch-action: none; cursor: crosshair; }
.sketch-text-input { position: absolute; z-index: 5; background: transparent; border: none; outline: none;
  padding: 0; margin: 0; line-height: 1; min-width: 20px; font-family: var(--font-sans);
  border-bottom: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); }
.sketch-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-4); border-top: 1px solid var(--border); background: var(--bg-sunken);
  font-family: var(--font-mono); font-size: var(--text-sm); color: var(--fg-muted); }
.sketch-status b { color: var(--fg); font-weight: var(--weight-medium); }
.sketch-chip { display: inline-flex; align-items: center; gap: 6px; }
.sketch-ink-dot { width: 11px; height: 11px; border-radius: 3px;
  border: 1px solid color-mix(in srgb, var(--fg) 25%, transparent); }
.sketch-status .sketch-hint { margin-left: auto; color: var(--fg-subtle); }
.sketch-status kbd { font-family: var(--font-mono); font-size: 11px; background: var(--bg-elev);
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--fg-muted); }
.sketch-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 560px) { .sketch-status .sketch-hint { display: none; } }
@media (prefers-reduced-motion: reduce) { .sketch-tool, .sketch-swatch { transition: none; } }

/* Lightbox (lightbox.js) — the thumbnail container is a bare wrapper (its links style themselves / your
   grid). Everything visible below is the ONE shared overlay: it is deliberately DARK in every theme (a
   photo reads best on black, not on a themed paper), so its surface colours are literal rgba on black —
   the only spot in the kit that leaves the semantic tokens, and on purpose. --accent still tints the
   active thumbstrip frame so it tracks the brand. */
/* The container doubles as a thumbnail grid out of the box (override the grid to lay out your own way).
   Each link is a zoom-in tile; a video link wears a ▶ badge. */
.lightbox { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-2); }
.lightbox > a { display: block; position: relative; aspect-ratio: 4 / 3; overflow: hidden; cursor: zoom-in;
  border-radius: var(--radius-md); background: var(--bg-sunken); box-shadow: var(--shadow-soft); }
.lightbox > a > img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s ease; }
.lightbox > a:hover > img { transform: scale(1.05); }
.lightbox > a:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.lightbox > a[data-type="video"]::after { content: "\25B6"; position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px;
  color: #fff; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); }
@media (prefers-reduced-motion: reduce) { .lightbox > a > img { transition: none; } }

.lightbox-overlay { position: fixed; inset: 0; z-index: 400; display: none;  /* above modal(100) + toasts(200/300) */
  flex-direction: column; background: rgba(12, 11, 9, 0.92); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.2s ease; color: #ece7dc; }
.lightbox-overlay.is-open { display: flex; opacity: 1; }

.lightbox-top { display: flex; align-items: center; gap: var(--space-3); padding: 12px 16px; }
.lightbox-count { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: var(--weight-bold);
  letter-spacing: 0.02em; flex: 0 0 auto; }
.lightbox-caption { color: #cfc9bd; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1 1 auto; min-width: 0; }
.lightbox-tools { margin-left: auto; display: flex; gap: 6px; flex: 0 0 auto; }
.lightbox-btn { width: 38px; height: 38px; border-radius: var(--radius-md); display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.06); color: #ece7dc;
  cursor: pointer; text-decoration: none; transition: background-color 0.15s ease, opacity 0.15s ease; }
.lightbox-btn svg { width: 19px; height: 19px; display: block; }
.lightbox-btn:hover { background: rgba(255, 255, 255, 0.16); }
.lightbox-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.lightbox-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(12, 11, 9, 0.9), 0 0 0 4px var(--accent); }

.lightbox-stage { flex: 1 1 auto; position: relative; display: grid; place-items: center; overflow: hidden;
  touch-action: none; }
.lightbox-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); color: #bdb7ab;
  font-size: 11.5px; pointer-events: none; opacity: 0.8; transition: opacity 0.2s ease; }
.lightbox-media { max-width: 92vw; max-height: 74vh; will-change: transform; transform-origin: center center;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); cursor: default; }
.lightbox-media.is-zoomed { cursor: grab; }
.lightbox-media.is-panning { transition: none; cursor: grabbing; }
.lightbox-media.is-video { cursor: default; }
.lightbox-el { display: block; max-width: 92vw; max-height: 74vh; width: auto; height: auto;
  border-radius: var(--radius-sm); box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.8); }
video.lightbox-el { background: #000; }

.lightbox-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 46px; height: 46px;
  border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(20, 18, 14, 0.55); color: #fff; cursor: pointer; transition: background-color 0.15s ease; }
.lightbox-arrow svg { width: 22px; height: 22px; display: block; }
.lightbox-arrow:hover { background: rgba(40, 36, 28, 0.85); }
.lightbox-arrow:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(12, 11, 9, 0.9), 0 0 0 4px var(--accent); }
.lightbox-prev { left: 14px; } .lightbox-next { right: 14px; }

.lightbox-meta { padding: 4px 16px 2px; text-align: center; }
.lightbox-meta-cap { margin: 0 0 4px; color: #ece7dc; font-size: var(--text-sm); }
.lightbox-exif { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; font-size: 12px;
  color: #a9a394; }
.lightbox-exif-item { display: inline-flex; align-items: center; gap: 5px; }
.lightbox-exif-item b { color: #cfc9bd; font-weight: var(--weight-medium); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.04em; }
.lightbox-exif-raw { font-family: var(--font-mono); color: #cfc9bd; }

.lightbox-strip { display: flex; gap: 7px; padding: 11px 16px 16px; justify-content: center; overflow-x: auto; }
.lightbox-thumb { position: relative; flex: 0 0 auto; width: 64px; height: 44px; padding: 0; border-radius: 6px;
  overflow: hidden; border: 2px solid transparent; cursor: pointer; opacity: 0.55; background: none;
  transition: opacity 0.15s ease, border-color 0.15s ease; }
.lightbox-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox-thumb:hover { opacity: 0.85; }
.lightbox-thumb.on { opacity: 1; border-color: var(--accent); }
.lightbox-thumb:focus-visible { outline: none; opacity: 1; box-shadow: 0 0 0 2px var(--accent); }
.lightbox-thumb-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff;
  background: rgba(0, 0, 0, 0.35); }
.lightbox-thumb-play svg { width: 18px; height: 18px; }

.lightbox-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 560px) {
  .lightbox-media, .lightbox-el { max-width: 96vw; max-height: 68vh; }
  .lightbox-arrow { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .lightbox-overlay, .lightbox-media, .lightbox-hint, .lightbox-btn, .lightbox-arrow, .lightbox-thumb { transition: none; }
}

/* Node graph editor (nodegraph.js) — an infinite pan/zoom canvas of draggable nodes wired by typed,
   validated, directional edges. The mount IS the framed editor; JS fills it. Node accent colour rides a
   per-node `--nc` (a semantic token picked from the node's `tone`); `--nodegraph-edge` is the resting wire
   colour, exposed as a var so the JS-built arrowheads (an inline fill string) can resolve it. */
.nodegraph { --nodegraph-edge: var(--fg-subtle); position: relative; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-soft); }
.nodegraph-viewport { position: absolute; inset: 0; cursor: grab; touch-action: none; outline: none;
  background-image: radial-gradient(var(--border-strong) 1px, transparent 1px); background-size: 22px 22px; }
.nodegraph-viewport.is-panning { cursor: grabbing; }
.nodegraph-viewport:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.nodegraph-world { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.nodegraph-edges { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.nodegraph-hit { stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; fill: none; }
.nodegraph-wire { fill: none; stroke: var(--nodegraph-edge); stroke-width: 2.5; transition: stroke .12s ease; }
.nodegraph-wire.is-sel { stroke: var(--accent); stroke-width: 3; }
.nodegraph-wire.is-temp { stroke: var(--accent); stroke-dasharray: 5 5; }
.nodegraph-wire.is-bad { stroke: var(--danger-fg); }

/* nodes — `--nc` tints the border, kind tag, and handles */
.nodegraph-node { position: absolute; min-width: 118px; background: var(--bg-elev);
  border: 2px solid var(--nc); border-radius: 10px; user-select: none; cursor: grab;
  box-shadow: 0 1px 2px rgba(16,24,40,.10), 0 8px 20px -12px rgba(16,24,40,.4); }
body[data-mode="dark"] .nodegraph-node { box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 22px -12px rgba(0,0,0,.7); }
.nodegraph-node.is-sel { box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 20px -12px rgba(16,24,40,.4); }
.nodegraph-node-body { padding: 11px 14px; font-weight: var(--weight-bold); font-size: var(--text-sm);
  text-align: center; color: var(--fg); line-height: 1.25; }
.nodegraph-node-kind { display: block; font-family: var(--font-mono); font-size: 9px; font-weight: var(--weight-medium);
  color: var(--nc); text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }
/* handles — one dot per pin, placed along its side by an inline top/left %; `--hc` tints it (falls back
   to the node's `--nc`). A handle sits centred on its edge, so its transform depends on the side axis. */
.nodegraph-handle { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: var(--bg-elev);
  border: 2px solid var(--hc, var(--nc)); cursor: crosshair; z-index: 2;
  transition: transform .1s ease, background-color .1s ease; }
.nodegraph-handle.side-l { left: -8px; transform: translateY(-50%); }
.nodegraph-handle.side-r { right: -8px; transform: translateY(-50%); }
.nodegraph-handle.side-t { top: -8px; transform: translateX(-50%); }
.nodegraph-handle.side-b { bottom: -8px; transform: translateX(-50%); }
.nodegraph-handle.side-l:hover, .nodegraph-handle.side-l.is-tgt,
.nodegraph-handle.side-r:hover, .nodegraph-handle.side-r.is-tgt { background: var(--hc, var(--nc)); transform: translateY(-50%) scale(1.35); }
.nodegraph-handle.side-t:hover, .nodegraph-handle.side-t.is-tgt,
.nodegraph-handle.side-b:hover, .nodegraph-handle.side-b.is-tgt { background: var(--hc, var(--nc)); transform: translateX(-50%) scale(1.35); }
/* pin labels — a small mono tag in the frame's padding gutter, aligned with its handle */
.nodegraph-pin { position: absolute; font-family: var(--font-mono); font-size: 9px; font-weight: var(--weight-medium);
  color: var(--fg-muted); letter-spacing: .02em; pointer-events: none; white-space: nowrap; z-index: 1; }
.nodegraph-pin.side-l { left: 6px; transform: translateY(-50%); }
.nodegraph-pin.side-r { right: 6px; transform: translateY(-50%); }
.nodegraph-pin.side-t { top: 3px; transform: translateX(-50%); }
.nodegraph-pin.side-b { bottom: 3px; transform: translateX(-50%); }

/* edge labels + reconnect endpoints */
.nodegraph-labels { position: absolute; top: 0; left: 0; }
.nodegraph-label { position: absolute; transform: translate(-50%, -50%); background: var(--bg-elev);
  border: 1px solid var(--border-strong); border-radius: 20px; padding: 2px 9px; font-size: var(--text-sm);
  font-weight: var(--weight-medium); color: var(--fg-muted); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-soft); }
.nodegraph-label.is-sel { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.nodegraph-label-input { border: 0; background: transparent; font: inherit; color: inherit; width: 84px; outline: none; text-align: center; }
.nodegraph-rc { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--bg-elev); transform: translate(-50%, -50%); cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,.3); }

/* chrome — toolbar, hint, toast, minimap */
.nodegraph-toolbar { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; z-index: 6; }
.nodegraph-tbtn { border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--fg-muted);
  border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: var(--weight-medium); padding: 6px 11px;
  cursor: pointer; box-shadow: var(--shadow-soft); transition: border-color .12s ease, color .12s ease; }
.nodegraph-tbtn:hover:not(:disabled) { border-color: var(--accent); color: var(--fg); }
.nodegraph-tbtn:disabled { opacity: .45; cursor: not-allowed; }
.nodegraph-tbtn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.nodegraph-hint { position: absolute; left: 10px; bottom: 10px; z-index: 5; font-size: 11px; color: var(--fg-subtle);
  background: color-mix(in srgb, var(--bg-elev) 85%, transparent); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px; max-width: 62%; line-height: 1.4; }
.nodegraph-hint b { color: var(--fg-muted); font-weight: var(--weight-medium); }
.nodegraph-toast { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 8;
  background: var(--danger-fg); color: var(--bg-elev); font-size: var(--text-sm); font-weight: var(--weight-medium);
  padding: 6px 14px; border-radius: 20px; opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.nodegraph-toast.is-on { opacity: 1; }
.nodegraph-mini { position: absolute; right: 10px; bottom: 10px; z-index: 5; width: 150px; height: 96px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-soft); cursor: pointer; touch-action: none; }
.nodegraph-mini rect.n { opacity: .6; } .nodegraph-mini rect.vp { fill: none; stroke: var(--accent); stroke-width: 2; }
.nodegraph-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 560px) { .nodegraph-mini { width: 108px; height: 70px; } .nodegraph-hint { max-width: 52%; } }
@media (prefers-reduced-motion: reduce) {
  .nodegraph-wire, .nodegraph-handle, .nodegraph-tbtn, .nodegraph-toast { transition: none; }
}

/* ================================================================================================
   AUTHORIZATION MATRIX  (authzmatrix.js)
   A per-app permissions matrix with three modes (admin chart · user inspector · restricted self-view).
   All colour is semantic + theme-aware: grant → success, deny → danger, protected/locked → warning,
   role provenance → accent, group → success, bundle → info, direct → neutral ink.
   ================================================================================================ */
.authzmatrix { display: block; color: var(--fg); }
.authzmatrix-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.authzmatrix-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.authzmatrix-ctx { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--accent-deep);
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 3px 10px; }
.authzmatrix-ctx-env { font-weight: var(--weight-medium); color: var(--accent); }
.authzmatrix-mode { margin-left: auto; font-size: var(--text-sm); font-weight: var(--weight-medium); letter-spacing: .04em;
  text-transform: uppercase; color: var(--fg-subtle); }
.authzmatrix-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: var(--space-3); align-items: start; }
@media (max-width: 860px) { .authzmatrix-grid { grid-template-columns: 1fr; } }

.authzmatrix-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft); margin-bottom: var(--space-3); }
.authzmatrix-card-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin: 0;
  padding: var(--space-3) var(--space-3) 0; font-size: var(--text-sm); font-weight: var(--weight-bold);
  text-transform: uppercase; letter-spacing: .05em; color: var(--fg-subtle); }
.authzmatrix-card-hint { margin-left: auto; font-weight: var(--weight-normal); text-transform: none; letter-spacing: 0; color: var(--fg-muted); }
.authzmatrix-card-body { padding: var(--space-3); }
.authzmatrix-scroll { overflow-x: auto; }

/* ── the matrix ── */
.authzmatrix-mx { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.authzmatrix-mx th, .authzmatrix-mx td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: center; }
.authzmatrix-mx thead th { font-weight: var(--weight-bold); color: var(--fg-muted); border-bottom: 2px solid var(--border-strong); text-transform: capitalize; }
.authzmatrix-mx .authzmatrix-mx-perm { text-align: left; white-space: nowrap; font-weight: var(--weight-normal); }
.authzmatrix-mx tr.is-protected { background: var(--bg-sunken); }
.authzmatrix-perm-label { display: inline-flex; align-items: center; gap: 5px; font-weight: var(--weight-medium); color: var(--fg); }
.authzmatrix-perm-key { display: block; font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-subtle); }
.authzmatrix-lockico { width: .82em; height: .95em; fill: none; stroke: var(--warning-fg); stroke-width: 1.3; vertical-align: -1px; }
.authzmatrix-cell { width: 24px; height: 24px; padding: 0; border-radius: var(--radius-sm); border: 1.5px solid var(--border-strong);
  background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--on-accent);
  transition: background-color .1s ease, border-color .1s ease; }
.authzmatrix-cell:hover:not(.is-lock):not(.is-on) { border-color: var(--success-fg); }
.authzmatrix-cell.is-on { background: var(--success-fg); border-color: var(--success-fg); }
.authzmatrix-cell.is-lock { cursor: not-allowed; opacity: .8; }
.authzmatrix-cell.is-lock.is-on { background: var(--warning-fg); border-color: var(--warning-fg); }
.authzmatrix-cell-mark { font-size: 13px; font-weight: var(--weight-bold); line-height: 1; }
.authzmatrix-cell:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* ── inspector: search + subject list ── */
.authzmatrix-search { display: flex; }
.authzmatrix-search-input { flex: 1; font: inherit; font-size: var(--text-sm); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-input); background: var(--bg); color: var(--fg); border-radius: var(--radius-md); }
.authzmatrix-search-input:focus { outline: none; box-shadow: var(--shadow-focus); border-color: var(--accent); }
.authzmatrix-ulist { margin-top: var(--space-2); display: flex; flex-direction: column; gap: 2px; max-height: 148px; overflow: auto; }
.authzmatrix-urow { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: 6px 8px; border: 0;
  background: transparent; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: var(--text-sm); color: var(--fg); text-align: left; }
.authzmatrix-urow:hover { background: var(--bg-sunken); }
.authzmatrix-urow.is-sel { background: var(--accent-soft); }
.authzmatrix-urow:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.authzmatrix-uname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.authzmatrix-av { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-size: 10px; font-weight: var(--weight-bold); }
.authzmatrix-urole { margin-left: auto; font-size: 10.5px; color: var(--fg-subtle); font-family: var(--font-mono); }

/* ── inspector: the subject detail ── */
.authzmatrix-insp { border-top: 1px solid var(--border); margin-top: var(--space-2); padding-top: var(--space-3); }
.authzmatrix-fld { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); font-size: var(--text-sm); }
.authzmatrix-fld-top { align-items: flex-start; }
.authzmatrix-fld-lbl { flex: 0 0 auto; width: 56px; color: var(--fg-subtle); font-weight: var(--weight-medium); }
.authzmatrix-fld-lbl label { color: inherit; }
.authzmatrix-rolesel { font: inherit; font-size: var(--text-sm); padding: 5px 8px; border: 1px solid var(--border-input);
  background: var(--bg); color: var(--fg); border-radius: var(--radius-sm); }
.authzmatrix-rolesel:focus { outline: none; box-shadow: var(--shadow-focus); border-color: var(--accent); }
.authzmatrix-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.authzmatrix-eff-title { font-size: 11px; font-weight: var(--weight-bold); text-transform: uppercase; letter-spacing: .05em;
  color: var(--fg-subtle); margin: var(--space-3) 0 4px; }
.authzmatrix-eff-row { display: flex; align-items: center; gap: var(--space-2); padding: 5px 2px; border-bottom: 1px solid var(--border); font-size: var(--text-sm); }
.authzmatrix-eff-st { flex: 0 0 auto; width: 16px; text-align: center; font-weight: var(--weight-bold); }
.authzmatrix-eff-row.is-granted .authzmatrix-eff-st { color: var(--success-fg); }
.authzmatrix-eff-row.is-denied .authzmatrix-eff-st { color: var(--danger-fg); }
.authzmatrix-eff-row.is-none { opacity: .5; }
.authzmatrix-eff-key { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted);
  overflow: hidden; text-overflow: ellipsis; }
.authzmatrix-eff-row.is-denied .authzmatrix-eff-key { text-decoration: line-through; text-decoration-color: var(--danger-fg); }
.authzmatrix-eff-badges { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; }
.authzmatrix-eff-act { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; }

/* provenance badges */
.authzmatrix-prov { font-size: 10px; font-weight: var(--weight-bold); border-radius: var(--radius-sm); padding: 1px 6px; display: inline-flex; align-items: center; gap: 3px; }
.authzmatrix-prov.is-role { color: var(--accent-deep); background: var(--accent-soft); border: 1px solid var(--accent); }
.authzmatrix-prov.is-group { color: var(--success-fg); background: var(--success-bg); border: 1px solid var(--success-border); }
.authzmatrix-prov.is-bundle { color: var(--info); background: color-mix(in srgb, var(--info) 12%, transparent); border: 1px solid color-mix(in srgb, var(--info) 34%, transparent); }
.authzmatrix-prov.is-direct { color: var(--fg-muted); background: var(--bg-sunken); border: 1px solid var(--border-strong); }
.authzmatrix-prov.is-deny { color: var(--danger-fg); background: var(--danger-bg); border: 1px solid var(--danger-border); }
.authzmatrix-prov.is-protected { color: var(--warning-fg); background: var(--warning-bg); border: 1px solid var(--warning-border); }
.authzmatrix-prov.is-protected .authzmatrix-lockico { stroke: var(--warning-fg); }

/* chips (group membership, group card, removable direct entries) + mini add buttons */
.authzmatrix-chip { font: inherit; font-size: 11px; font-weight: var(--weight-medium); border-radius: var(--radius-sm); padding: 2px 8px;
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid transparent; }
.authzmatrix-chip.is-mem { color: var(--accent-deep); background: var(--accent-soft); border-color: var(--accent); }
.authzmatrix-chip.is-grant { color: var(--success-fg); background: var(--success-bg); border-color: var(--success-border); }
.authzmatrix-chip.is-deny { color: var(--danger-fg); background: var(--danger-bg); border-color: var(--danger-border); }
button.authzmatrix-chip { cursor: pointer; }
button.authzmatrix-chip:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.authzmatrix-add { display: inline-flex; gap: 3px; }
.authzmatrix-mini { font: inherit; font-size: 10.5px; font-weight: var(--weight-medium); line-height: 1; padding: 3px 7px;
  border-radius: var(--radius-sm); border: 1px dashed var(--border-strong); background: transparent; color: var(--fg-subtle); cursor: pointer; }
.authzmatrix-mini:hover { color: var(--fg); border-color: var(--fg-muted); }
.authzmatrix-mini.authzmatrix-addg:hover { color: var(--success-fg); border-color: var(--success-fg); }
.authzmatrix-mini.authzmatrix-addd:hover { color: var(--danger-fg); border-color: var(--danger-fg); }
.authzmatrix-mini:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* groups card */
.authzmatrix-glist { display: flex; flex-direction: column; gap: var(--space-2); }
.authzmatrix-grow { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 9px 11px; }
.authzmatrix-gn { font-weight: var(--weight-bold); font-size: var(--text-sm); margin-bottom: 6px; }
.authzmatrix-note { font-size: var(--text-sm); color: var(--fg-muted); background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius-md); padding: 9px 12px; margin: var(--space-3) 0 0; line-height: 1.45; }
.authzmatrix-note b { color: var(--accent-deep); }
.authzmatrix-muted, .authzmatrix-empty { color: var(--fg-subtle); font-size: var(--text-sm); }
.authzmatrix-empty { padding: 12px 4px; }

/* ── restricted self-view ── */
.authzmatrix-self .authzmatrix-card { max-width: 560px; }
.authzmatrix-myrow { display: flex; align-items: center; gap: var(--space-2); padding: 9px 12px; margin-bottom: 7px;
  border: 1px solid var(--success-border); background: var(--success-bg); border-radius: var(--radius-md); }
.authzmatrix-myck { flex: 0 0 auto; color: var(--success-fg); font-weight: var(--weight-bold); }
.authzmatrix-myl { font-weight: var(--weight-medium); font-size: var(--text-base); color: var(--fg); display: inline-flex; align-items: center; gap: 5px; }
.authzmatrix-myk { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-subtle); }

@media (prefers-reduced-motion: reduce) {
  .authzmatrix-cell { transition: none; }
}

/* Tree view (tree-view.js) — an accessible, animated hierarchical tree (WAI-ARIA "tree"): roving-tabindex
   keyboard nav, an animated caret + smooth open/close, light-DOM, tokens-only, reduced-motion aware. */
.tree-view { --tv-indent: 18px; --tv-row-h: 28px; display: block; width: 100%; }
.tv-root, .tv-group { list-style: none; margin: 0; padding: 0; }
.tv-group { overflow: hidden; }
.tv-node { position: relative; outline: none; }
.tv-node:focus-visible { outline: none; box-shadow: none; }
.tv-row { display: flex; align-items: center; gap: 6px; min-height: var(--tv-row-h);
  padding: 2px 8px 2px calc(6px + var(--tv-depth, 0) * var(--tv-indent)); border-radius: var(--radius-sm);
  color: var(--fg); cursor: pointer; user-select: none;
  transition: background-color .12s ease, color .12s ease, box-shadow .12s ease; }
.tv-row:hover { background: var(--bg-sunken, var(--bg-elev)); }
.tv-node:focus-visible > .tv-row { box-shadow: var(--shadow-focus); background: var(--bg-sunken, var(--bg-elev)); }
.tv-node[aria-selected="true"] > .tv-row { background: var(--accent-soft); color: var(--accent-deep); }
.tv-node[aria-selected="true"]:focus-visible > .tv-row { box-shadow: var(--shadow-focus); }
.tv-caret { flex: 0 0 auto; width: 12px; height: 12px; color: var(--fg-subtle);
  transition: transform .18s cubic-bezier(.2,.8,.2,1); }
.tv-node[aria-expanded="true"] > .tv-row > .tv-caret { transform: rotate(90deg); }
.tv-caret-leaf { display: inline-block; } /* keeps leaves aligned with branch rows */
.tv-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--text-base, 13.5px); }
.tv-meta { flex: 0 0 auto; margin-left: auto; padding-left: 8px; font-size: 11px; color: var(--fg-subtle);
  font-variant-numeric: tabular-nums; }
.tv-node[aria-selected="true"] > .tv-row > .tv-meta { color: color-mix(in srgb, var(--accent-deep) 70%, transparent); }
/* depth: aria-level drives the row indent (levels 1..8 covered; deeper nodes clamp to 8) */
.tv-node[aria-level="1"] > .tv-row { --tv-depth: 0; }
.tv-node[aria-level="2"] > .tv-row { --tv-depth: 1; }
.tv-node[aria-level="3"] > .tv-row { --tv-depth: 2; }
.tv-node[aria-level="4"] > .tv-row { --tv-depth: 3; }
.tv-node[aria-level="5"] > .tv-row { --tv-depth: 4; }
.tv-node[aria-level="6"] > .tv-row { --tv-depth: 5; }
.tv-node[aria-level="7"] > .tv-row { --tv-depth: 6; }
.tv-node[aria-level="8"] > .tv-row { --tv-depth: 7; }
.tv-hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  .tv-caret, .tv-row { transition: none; }
}

/* ============================================================================================
   INTERIOR COMPONENTS (v0.13.0) — ported from ddoemonn/interior. JS builds structure + behavior;
   all static appearance lives here. Tokens only; dark mode via body[data-mode="dark"] token remap.
   ============================================================================================ */

/* ==== PASSWORD STRENGTH (password-strength.js) — per-rule segment meter, crossfaded label stack,
   tone thresholds (danger <=34% / caution <=67% / safe), commonly-guessed flag, tick-pop checklist. ==== */
.password-strength { --ps-tone: var(--fg-subtle); --ps-text: var(--fg-muted); display: block; }
.password-strength.is-danger { --ps-tone: var(--danger-fg); --ps-text: var(--danger-fg); }
.password-strength.is-caution { --ps-tone: var(--warning-fg); --ps-text: var(--warning-fg); }
.password-strength.is-safe { --ps-tone: var(--success-fg); --ps-text: var(--success-fg); }
.ps-meter { display: grid; gap: 6px; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.ps-cell { position: relative; height: 6px; overflow: hidden; border-radius: 2px; background: var(--bg-sunken); }
.ps-cell-fill { position: absolute; inset: 0; transform-origin: left; transform: scaleX(0); border-radius: 2px;
  background: var(--ps-tone); transition: transform .28s cubic-bezier(.2,.8,.2,1), background-color .2s; }
.ps-cell-fill.is-on { transform: scaleX(1); }
.ps-row { margin-top: 8px; display: flex; height: 20px; align-items: center; justify-content: space-between; gap: 12px; }
.ps-labels { display: inline-grid; font-size: 12.5px; font-weight: var(--weight-medium); line-height: 20px; }
.ps-label { grid-column: 1; grid-row: 1; white-space: nowrap; opacity: 0; color: var(--ps-text); transition: opacity .3s, color .2s; }
.ps-label.is-on { opacity: 1; }
.ps-guess { white-space: nowrap; font-size: 11.5px; line-height: 20px; color: var(--warning-fg); opacity: 0; transition: opacity .3s; }
.ps-guess.is-on { opacity: 1; }
.ps-list { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.ps-rule { display: flex; align-items: center; gap: 8px; }
.ps-check { position: relative; display: grid; width: 14px; height: 14px; flex: 0 0 auto; place-items: center;
  border-radius: 4px; border: 1px solid var(--border-strong); }
.ps-check-bg { position: absolute; inset: 0; border-radius: 3px; background: var(--success-fg); opacity: 0; transition: opacity .3s; }
.ps-check-ico { position: relative; width: 9px; height: 9px; color: var(--success-bg); opacity: 0; transform: scale(.6);
  transition: opacity .28s, transform .28s cubic-bezier(.2,.8,.2,1); }
.ps-rule.is-met .ps-check-bg { opacity: 1; }
.ps-rule.is-met .ps-check-ico { opacity: 1; transform: scale(1); }
.ps-rule-txt { font-size: 12.5px; line-height: 20px; color: var(--fg-muted); transition: color .2s; }
.ps-rule.is-met .ps-rule-txt { color: var(--fg); }

/* ==== OTP INPUT (otp-input.js) — inset empty / active-ring / filled cells, blur-in glyph, blinking
   caret, group gap, error shake + status crossfade. ==== */
.otp-input { --otp-inset: inset 0 1px 2px rgba(0,0,0,.08); display: block; }
.otp-group { position: relative; display: flex; gap: 8px; }
.otp-cell { position: relative; height: 48px; width: 40px; }
.otp-cell.otp-gap { margin-left: 12px; }
.otp-field { height: 48px; width: 40px; border-radius: var(--radius-md); border: 2px solid var(--border);
  text-align: center; font-size: 15px; color: transparent; caret-color: transparent; outline: none;
  background: var(--bg-sunken); box-shadow: var(--otp-inset);
  transition: border-color .15s, background-color .15s, box-shadow .15s; }
.otp-cell.is-active .otp-field { border-color: var(--accent); background: var(--bg-elev); box-shadow: none; }
.otp-cell.is-filled .otp-field { border-color: var(--border-strong); background: var(--bg-elev); box-shadow: none; }
.otp-cell.is-error .otp-field { border-color: var(--danger-fg); background: var(--bg-elev); box-shadow: none; }
.otp-cell.is-success .otp-field { border-color: var(--success-fg); background: var(--bg-elev); box-shadow: none; }
.otp-glyph { pointer-events: none; position: absolute; inset: 0; display: grid; place-items: center; }
.otp-digit { font-family: var(--font-mono); font-size: 15px; color: var(--fg); animation: otpIn .22s cubic-bezier(.23,1,.32,1); }
.otp-caret { display: block; height: 17px; width: 1.5px; border-radius: 1px; background: var(--fg); animation: otpCaret 1.06s linear infinite; }
.otp-msg { margin-top: 8px; height: 16px; font-size: 11.5px; line-height: 16px; color: var(--fg-muted); transition: opacity .2s, transform .2s; }
.otp-msg.is-error { color: var(--danger-fg); }
.otp-msg.is-success { color: var(--success-fg); }
.otp-group.is-shake { animation: otpShake .32s cubic-bezier(.23,1,.32,1); }
@keyframes otpIn { from { opacity: 0; transform: translateY(10px) scale(.97); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes otpCaret { 0%, 45% { opacity: 1; } 55%, 100% { opacity: 0; } }
@keyframes otpShake { 0% { transform: translateX(0); } 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-3px); } 100% { transform: translateX(0); } }

/* ==== TASK STEPS (task-steps.js) — done tick-pop, active spinning arc + shimmer label, pending
   square, error cross; vertical list or horizontal with a fill-through connector. ==== */
.task-steps { display: block; }
.ts-list { margin: 0; padding: 0; list-style: none; }
.ts-list.is-vertical { display: flex; flex-direction: column; gap: 2px; }
.ts-list.is-horizontal { display: flex; flex-direction: row; gap: 0; align-items: flex-start; overflow-x: auto; }
.ts-step { position: relative; }
.ts-list.is-vertical .ts-step { display: flex; height: 28px; align-items: center; gap: 10px; padding: 0 4px; }
.ts-list.is-horizontal .ts-step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 96px; text-align: center; }
.ts-marker { position: relative; display: grid; width: 16px; height: 16px; flex: 0 0 auto; place-items: center; }
.ts-list.is-horizontal .ts-marker { z-index: 1; }
.ts-list.is-vertical .ts-body { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-list.is-horizontal .ts-body { padding: 0 6px; }
.ts-mark { display: grid; width: 16px; height: 16px; place-items: center; border-radius: 5px; }
.ts-mark.is-done { color: var(--success-fg); background: color-mix(in srgb, var(--success-fg) 15%, transparent); animation: tsPop .3s cubic-bezier(.2,.9,.3,1); }
.ts-mark.is-error { color: var(--danger-fg); background: color-mix(in srgb, var(--danger-fg) 13%, transparent); animation: tsPop .3s cubic-bezier(.2,.9,.3,1); }
.ts-mark.is-active { color: var(--fg-muted); }
.ts-ico { width: 11px; height: 11px; }
.ts-mark.is-error .ts-ico { width: 10px; height: 10px; }
.ts-arc { width: 12px; height: 12px; animation: tsSpin .8s linear infinite; }
.ts-dot { display: block; width: 5px; height: 5px; border-radius: 2px; background: var(--border-strong); }
.ts-label { font-size: 12.5px; transition: color .2s; color: var(--fg); }
.ts-label.is-done { color: var(--fg-muted); }
.ts-label.is-pending { color: var(--fg-subtle); }
.ts-label.is-error { color: var(--danger-fg); font-weight: var(--weight-medium); }
.ts-shimmer { font-size: 12.5px; font-weight: var(--weight-medium);
  background: linear-gradient(90deg, var(--fg-muted) 38%, var(--fg) 50%, var(--fg-muted) 62%);
  background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: tsShine 1.6s linear infinite; }
.ts-meta { flex: 0 0 auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-subtle); opacity: 0; transition: opacity .2s; }
.ts-step.is-done .ts-meta { opacity: 1; }
.ts-connector { position: absolute; top: 8px; left: calc(50% + 12px); right: calc(-50% + 12px); height: 2px; background: var(--border); transition: background .3s; }
.ts-connector.is-filled { background: var(--success-fg); }
.ts-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@keyframes tsSpin { to { transform: rotate(360deg); } }
@keyframes tsPop { 0% { opacity: 0; transform: scale(.4); } 100% { opacity: 1; transform: scale(1); } }
@keyframes tsShine { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ==== PRESS DEPTH (press-depth.js) — 3D pushable: a shadow base, the face translating down on press,
   pointer-origin tilt, fading top gloss. (Translucent white/black are lighting effects, not theme colors.) ==== */
.press-depth.pd-root { position: relative; display: inline-flex; user-select: none; border-radius: var(--radius-md);
  vertical-align: middle; outline: none; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.pd-base { position: absolute; left: 0; right: 0; bottom: 0; border-radius: var(--radius-md); background: var(--border-strong); }
.pd-face { position: relative; display: inline-flex; height: 36px; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-md); background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border);
  padding: 0 16px; font-size: 13px; font-weight: var(--weight-medium); transform-origin: center;
  transform: translateY(0) perspective(340px); transition: transform .28s cubic-bezier(.2,.85,.25,1); will-change: transform; }
.press-depth.is-accent .pd-face { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.pd-gloss { pointer-events: none; position: absolute; inset: 0; border-radius: var(--radius-md);
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.85), inset 0 -1px 0 rgba(0,0,0,0.06); transition: opacity .28s; }
.press-depth.is-accent .pd-gloss { box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.35), inset 0 -1px 0 rgba(0,0,0,0.1); }
.press-depth.pd-root:focus-visible { box-shadow: var(--shadow-focus); }
/* v0.16.0 hold lifecycle. `is-held` is set for the WHOLE hold from every source (pointer, keyboard,
   gamepad, programmatic), so a controller-driven press looks identical to a finger. `is-hold` is the
   hold-to-drive opt-in: touch-action none so a finger parked on a D-pad can't be stolen by a scroll
   gesture, and no long-press callout. */
.press-depth.is-hold { touch-action: none; -webkit-touch-callout: none; }
.press-depth.is-held .pd-face { box-shadow: inset 0 2px 4px rgba(0,0,0,0.14); }
.press-depth.is-accent.is-held .pd-face { box-shadow: inset 0 2px 5px rgba(0,0,0,0.22); }

/* ==== TABS/SEGMENTED STRIP TOKENS (v0.14.0) ===============================================
   The row tint that makes the tabs plateau (and the segmented-control thumb) read as a FILLED shape
   lifted out of a recessed strip. Interior tints the strip in LIGHT mode only and leaves dark
   border-only; we keep that asymmetry, but LIGHT is pushed well past interior's own ~1.04:1 tint so the
   active tab is unmistakable on a large high-DPI display.

   Derived from existing palette tokens (never a hardcoded colour), so all 20+ themes and both brands get
   a correct value for free. components.css owns these universal derived defaults for the same reason it
   owns the universal `--link` default (see tools/build_tokens.py). A theme sheet may override them: a
   `[data-theme=…]` / `body[data-theme=…][data-mode=dark]` rule outranks the `body` / `body[data-mode]`
   selectors used here, so promoting these into design-tokens later is a drop-in.

   Light-mode contrast, browser-measured across all 18 light palette/brand combinations
   (plateau fill = --bg-elev):
     strip vs plateau  1.47 - 1.75 : 1  (mean 1.62)   [interior 1.04 : 1, shipped v0.13.0 1.00 : 1]
     border vs plateau 3.40 - 17.74: 1  (mean 5.71)
     border vs strip   2.05 - 11.93: 1  (mean 3.60)
     inactive label on strip 4.97 - 9.14 : 1 (every palette clears WCAG AA)
     active label on plateau 14.80 - 19.72 : 1 (AAA)
   Dark: --tabs-strip == --bg-elev in all 18 dark palettes; dark labels 6.55 - 8.89 : 1.
   ========================================================================================== */
body {
  --tabs-strip: color-mix(in srgb, var(--bg-sunken) 86%, var(--fg));
  --tabs-strip-fg: color-mix(in srgb, var(--fg-muted) 70%, var(--fg));
  --tabs-plateau-border: color-mix(in srgb, var(--border-strong) 60%, var(--fg));
}
body[data-mode="dark"] {
  /* interior's deliberate asymmetry — dark is border-only, so the strip IS the surface */
  --tabs-strip: var(--bg-elev);
  --tabs-strip-fg: var(--fg-muted);
  --tabs-plateau-border: var(--border);
}

/* ==== TABS (tabs.js) — sliding + resizing plateau indicator, directional panel slide. Geometry is
   driven by a rAF spring in JS (transform + width), NOT a CSS transition on left/width. Base scoped to
   [data-tabs] so the legacy .tabs (controls.js) is untouched. ==== */
.tabs[data-tabs] { display: block; }
.tabs-shell { width: 100%; overflow: hidden; border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--bg-elev); box-shadow: var(--shadow-soft); }
.tabs-list { position: relative; display: flex; width: 100%; gap: 4px; border-bottom: 1px solid var(--border);
  background: var(--tabs-strip); padding: 4px 4px 0; }
/* Two layers: the FILL (below) and a nested border-only child, so the hairline is laid out independently
   of the fill and can't smear while the width is being animated. */
.tabs-plateau { position: absolute; bottom: -1px; top: 4px; left: 0; width: 0; background: var(--bg-elev);
  border-radius: 8px 8px 0 0; opacity: 0; z-index: 0; }
.tabs-plateau.is-shown { opacity: 1; }
.tabs-plateau-border { position: absolute; inset: 0; border: 1px solid var(--tabs-plateau-border);
  border-bottom: 0; border-radius: 8px 8px 0 0; }
.tabs-tab { position: relative; z-index: 1; display: flex; height: 32px; flex: 0 0 auto; align-items: center;
  justify-content: center; border-radius: 8px 8px 0 0; padding: 0 14px; font-size: 12.5px; border: 0; background: transparent;
  cursor: default; outline: none; color: var(--tabs-strip-fg); transition: color .15s, background-color .15s; }
.tabs-tab:not(.is-active):not(:disabled):hover { background: color-mix(in srgb, var(--bg-elev) 55%, transparent); color: var(--fg); }
.tabs-tab.is-active { color: var(--fg); }
.tabs-tab:disabled { color: var(--fg-subtle); cursor: default; }
/* INSET focus ring on an ::after that inherits the tab's own 8px top radius — an outer glow would spill
   outside the shell's overflow:hidden clip and would re-round the tab. */
.tabs-tab::after { content: ""; position: absolute; inset: 0; border-radius: 8px 8px 0 0; pointer-events: none; }
.tabs-tab:focus-visible::after { box-shadow: inset 0 0 0 1px var(--accent); }
/* Width reservation: an invisible medium-weight ghost stacked under the visible copy in one grid cell,
   so bold-on-select can never reflow the row (or drag the plateau's target mid-flight). */
.tabs-label { position: relative; display: grid; place-items: center; line-height: 1.4; }
.tabs-ghost { grid-area: 1 / 1; visibility: hidden; font-weight: var(--weight-medium); }
.tabs-real { grid-area: 1 / 1; }
.tabs-tab.is-active .tabs-real { font-weight: var(--weight-medium); }
.tabs-panel { padding: 16px; font-size: 13.5px; line-height: 1.6; color: var(--fg); outline: none; border-radius: 11px; }
.tabs-panel:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }

/* ==== SEGMENTED CONTROL (segmented-control.js) — the other half of interior's tabs section, and a
   DISTINCT component from tabs (tabs own a panel, this owns a value). Three layers share ONE grid
   template so they line up exactly: a DIM label layer, the clipped THUMB carrying a counter-translated
   copy of every label, and a transparent radio HIT layer. Only transforms animate (JS springs). The
   thumb window + counter-mask is what keeps the selected label CRISP rather than crossfaded. The tray
   reuses --tabs-strip, so it inherits the same light/dark asymmetry as the tabs row. ==== */
.segmented-control[data-segmented-control] { display: inline-block; }
.seg-tray { position: relative; display: inline-block; user-select: none; -webkit-user-select: none;
  padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--tabs-strip);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.07); }
body[data-mode="dark"] .seg-tray { box-shadow: inset 0 1px 2px rgba(0,0,0,.45); }
.seg-grid { position: relative; display: grid; touch-action: manipulation; }
.seg-dim, .seg-on { padding: 7px 12px; text-align: center; font-size: 13px; line-height: 18px;
  font-weight: var(--weight-medium); letter-spacing: -.01em; white-space: nowrap; }
.seg-dim { pointer-events: none; color: var(--tabs-strip-fg); transition: color .15s; }
.seg-dim.is-hover { color: var(--fg); }
.seg-dim.is-disabled { color: var(--fg-subtle); }
/* the clipped thumb: an overflow window sliding over a full-width, counter-translated label track */
.seg-thumb { pointer-events: none; position: absolute; top: 0; bottom: 0; left: 0; overflow: hidden;
  border-radius: 6px; background: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.28); }
body[data-mode="dark"] .seg-thumb { box-shadow: 0 1px 2px rgba(0,0,0,.5); }
.seg-mask { position: absolute; inset: 0; }
.seg-track { position: absolute; top: 0; bottom: 0; left: 0; display: grid; }
.seg-on { color: var(--bg-elev); }
.seg-hits { position: absolute; inset: 0; display: grid; }
.seg-hit { padding: 0; margin: 0; border: 0; background: transparent; font: inherit; color: inherit;
  cursor: default; outline: none; border-radius: 6px; }
.seg-hit:focus-visible { background: color-mix(in srgb, var(--accent) 6%, transparent);
  box-shadow: inset 0 0 0 1px var(--accent); }
.seg-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ==== RANGE WITH DETENTS (range-detents.js) — interior's magnetic slider. Rail, ticks and thumb are
   inset by thumb/2 (9px) each side so the thumb CENTRE maps linearly to 0-100% of the value range and
   never overhangs. The fill is a 2000px block anchored right:100% inside a translated carriage, so
   nothing animates `width` — the JS springs write transform only. The readout reserves the widest
   possible string in a 1x1 grid so it can't jitter. The per-detent label row under the track is OPT-IN
   via data-detent-labels; by default only the active detent's name appears, in the readout. ==== */
.range-detents[data-range-detents] { display: block; width: 100%; user-select: none; -webkit-user-select: none; }
.rng-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.rng-label { font-size: 12.5px; color: var(--fg-muted); }
.rng-read { display: grid; justify-items: start; }
.rng-ghost, .rng-value { grid-area: 1 / 1; white-space: pre; font-family: var(--font-mono);
  font-size: 11px; font-variant-numeric: tabular-nums; }
.rng-ghost { visibility: hidden; }
.rng-value { color: var(--fg); }
.rng-suffix { color: var(--fg-muted); opacity: 0; transition: opacity .28s; }
.rng-suffix.is-on { opacity: 1; }
.rng-track { position: relative; height: 36px; width: 100%; border-radius: 9px; outline: none;
  cursor: grab; touch-action: none; }
.rng-track.is-dragging { cursor: grabbing; }
.rng-track:focus-visible { background: color-mix(in srgb, var(--accent) 6%, transparent);
  box-shadow: inset 0 0 0 1px var(--accent); }
.rng-rail { pointer-events: none; position: absolute; left: 0; right: 0; top: 9px; height: 10px;
  overflow: hidden; border-radius: 5px; background: color-mix(in srgb, var(--fg) 18%, transparent); }
.rng-rail-inner, .rng-ticks, .rng-lane { position: absolute; top: 0; bottom: 0; left: 9px; right: 9px; }
.rng-ticks, .rng-lane { pointer-events: none; }
.rng-carriage { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }
.rng-fill { position: absolute; top: 0; bottom: 0; right: 100%; width: 2000px; background: var(--fg); }
.rng-tick { position: absolute; top: 26px; display: block; width: 2px; height: 5px; border-radius: 1px;
  transform: translateX(-50%); background: color-mix(in srgb, var(--fg) 35%, transparent); }
.rng-thumb { position: absolute; top: 4px; margin-left: -9px; width: 18px; height: 20px;
  border-radius: 6px; border: 2px solid var(--bg-elev); background: var(--fg);
  box-shadow: 0 1px 2px rgba(0,0,0,.28); }
.rng-detent-labels { position: relative; height: 16px; margin: 2px 9px 0; }
.rng-detent-label { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap;
  font-size: 10.5px; color: var(--fg-subtle); }

/* ==== ORG CHART (org-chart.js) — the people-shaped sibling of nodegraph: a strict reporting tree,
   tidily auto-laid-out on a pan/zoom canvas with rounded SVG elbow connectors. JS owns structure +
   geometry (it writes only transforms and the stage box); every static pixel lives here. Card size is
   published as --oc-card-w / --oc-card-h so the layout maths and the paint can never drift apart.
   Tokens only; dark mode via the body[data-mode="dark"] token remap. ==== */
.org-chart { --oc-card-w: 220px; --oc-card-h: 84px; --oc-tint: var(--accent);
  display: block; position: relative; }

/* -- toolbar -- */
.oc-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.oc-sep { width: 1px; align-self: stretch; min-height: 22px; background: var(--border); }
.oc-spacer { flex: 1 1 auto; }
.oc-btn { font: inherit; font-size: 12.5px; color: var(--fg-muted); background: var(--bg-elev);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: 6px 11px;
  cursor: pointer; white-space: nowrap; outline: none;
  transition: color .15s, border-color .15s, background-color .15s; }
.oc-btn:hover { color: var(--fg); border-color: var(--accent); }
.oc-btn:focus-visible { box-shadow: var(--shadow-focus); }
.oc-btn.oc-icon { width: 30px; height: 30px; padding: 0; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 15px; line-height: 1; }
.oc-zoomval { min-width: 46px; text-align: center; font-family: var(--font-mono); font-size: 11.5px;
  color: var(--fg-subtle); }

.oc-seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-md); }
.oc-segbtn { font: inherit; font-size: 12.5px; color: var(--fg-muted); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 5px 12px; cursor: pointer;
  white-space: nowrap; outline: none; transition: color .15s, background-color .15s; }
.oc-segbtn:hover { color: var(--fg); }
.oc-segbtn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  font-weight: var(--weight-medium); }
.oc-segbtn:focus-visible { box-shadow: var(--shadow-focus); }

.oc-search { position: relative; display: flex; align-items: center; }
.oc-mag { position: absolute; left: 9px; font-size: 12px; color: var(--fg-subtle); pointer-events: none; }
.oc-input { font: inherit; font-size: 13px; color: var(--fg); background: var(--bg-elev);
  border: 1px solid var(--border-input); border-radius: var(--radius-md);
  padding: 6px 92px 6px 28px; width: 264px; max-width: 52vw; outline: none;
  transition: border-color .15s; }
.oc-input::placeholder { color: var(--fg-subtle); }
.oc-input::-webkit-search-cancel-button { display: none; }
.oc-input:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.oc-count { position: absolute; right: 30px; font-family: var(--font-mono); font-size: 10.5px;
  color: var(--fg-subtle); pointer-events: none; }
.oc-clear { position: absolute; right: 5px; border: 0; background: transparent; color: var(--fg-subtle);
  font-size: 13px; line-height: 1; padding: 4px; cursor: pointer; opacity: 0; pointer-events: none;
  outline: none; transition: opacity .15s, color .15s; }
.oc-search.is-active .oc-clear { opacity: 1; pointer-events: auto; }
.oc-clear:hover { color: var(--accent); }
.oc-clear:focus-visible { opacity: 1; box-shadow: var(--shadow-focus); border-radius: var(--radius-sm); }

/* -- canvas -- */
.oc-viewport { position: relative; height: min(66vh, 620px); min-height: 340px; overflow: hidden;
  cursor: grab; touch-action: none; user-select: none;   /* a pan drag must not sweep-select card text */
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  background: radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0) 0 0 / 22px 22px,
              var(--bg-elev); }
.oc-viewport.is-panning { cursor: grabbing; }
.oc-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; outline: none; }
.oc-stage.is-gliding { transition: transform .32s cubic-bezier(.22,.75,.3,1); }
.oc-edges { position: absolute; top: 0; left: 0; z-index: 0; overflow: visible; pointer-events: none;
  transition: opacity .18s ease; }
.oc-edges.is-settling { opacity: .25; }
.oc-edge { fill: none; stroke: var(--border-strong); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.oc-edge.is-orphan { stroke: var(--fg-subtle); stroke-dasharray: 4 5; }
.oc-edge.is-path { stroke: var(--accent); stroke-width: 2.2; }

/* -- person card -- */
.oc-card { position: absolute; top: 0; left: 0; z-index: 1;
  width: var(--oc-card-w); height: var(--oc-card-h); padding: 9px 11px;
  display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; align-items: center;
  text-align: left; cursor: pointer; outline: none; line-height: 1.3;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  transition: transform .28s cubic-bezier(.22,.75,.3,1), opacity .2s, border-color .15s, box-shadow .15s; }
.oc-card:hover { border-color: var(--accent); }
.oc-card:focus-visible { box-shadow: var(--shadow-focus); border-color: var(--accent); }
.oc-card.is-root { border-color: var(--border-strong); }
.oc-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), var(--shadow-soft); }
.oc-card.is-hidden { opacity: 0; pointer-events: none; }
.oc-card.is-dim { opacity: .24; }
.oc-card.is-match { border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent), var(--shadow-soft); }
.oc-card.is-current { box-shadow: 0 0 0 3px var(--accent), var(--shadow-lift); }

.oc-card[data-tint="1"] { --oc-tint: var(--chart-1); }
.oc-card[data-tint="2"] { --oc-tint: var(--chart-2); }
.oc-card[data-tint="3"] { --oc-tint: var(--chart-3); }
.oc-card[data-tint="4"] { --oc-tint: var(--chart-4); }
.oc-card[data-tint="5"] { --oc-tint: var(--chart-5); }
.oc-card[data-tint="6"] { --oc-tint: var(--chart-6); }

.oc-av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: var(--weight-bold); letter-spacing: .02em;
  color: var(--oc-tint); background: color-mix(in srgb, var(--oc-tint) 20%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--oc-tint) 42%, var(--border)); }
.oc-av-img { object-fit: cover; background: var(--bg-sunken); }

.oc-body { min-width: 0; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.oc-name { font-size: 13px; line-height: 17px; font-weight: var(--weight-medium); letter-spacing: -.005em;
  color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc-role { font-size: 11.5px; line-height: 15px; color: var(--fg-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc-meta { font-size: 10.5px; line-height: 14px; color: var(--fg-subtle);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc-chiprow { display: flex; align-items: center; gap: 5px; margin: 2px 0; min-width: 0; }
.oc-chip { flex: 0 1 auto; font-size: 9.5px; line-height: 13px; font-weight: var(--weight-medium);
  letter-spacing: .04em; text-transform: uppercase; padding: 0 6px; border-radius: 999px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  color: var(--oc-tint); background: color-mix(in srgb, var(--oc-tint) 14%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--oc-tint) 38%, var(--border)); }
.oc-badge { flex: 0 0 auto; font-family: var(--font-mono); font-size: 9.5px; line-height: 13px;
  color: var(--fg-subtle); background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 6px; white-space: nowrap; }
.oc-badge.is-off { display: none; }
.oc-badge.is-hidden-count { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.oc-flag { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }

.oc-toggle { position: absolute; width: 20px; height: 20px; padding: 0; z-index: 2;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer; outline: none;
  font-family: var(--font-mono); font-size: 12px; line-height: 1;
  color: var(--fg-muted); background: var(--bg-elev); border: 1px solid var(--border-strong);
  transition: color .15s, background-color .15s, border-color .15s; }
.oc-toggle:hover { color: var(--accent); border-color: var(--accent); }
.oc-toggle:focus-visible { box-shadow: var(--shadow-focus); }
.oc-toggle.is-closed { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.oc-card[data-layout="horizontal"] .oc-toggle { bottom: -11px; left: 50%; margin-left: -10px; }
.oc-card[data-layout="vertical"] .oc-toggle { right: -11px; top: 50%; margin-top: -10px; }

/* -- hint pill + assistive text -- */
.oc-hint { position: absolute; left: 10px; bottom: 10px; z-index: 5; pointer-events: none;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-subtle);
  background: color-mix(in srgb, var(--bg-elev) 84%, transparent);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; }
.oc-sr, .oc-live { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }

/* Dark mode — the tokens carry the palette; only the card lift needs a heavier, tighter shadow so a
   pale card still separates from the dotted canvas. */
body[data-mode="dark"] .oc-card { box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 22px -12px rgba(0,0,0,.7); }
body[data-mode="dark"] .oc-card.is-selected { box-shadow: 0 0 0 2px var(--accent), 0 10px 22px -12px rgba(0,0,0,.7); }

/* Reduced motion — cards jump straight to their new seats, the canvas stops gliding; every state still reads. */
@media (prefers-reduced-motion: reduce) {
  .oc-card, .oc-btn, .oc-segbtn, .oc-toggle, .oc-edges, .oc-clear, .oc-input { transition: none; }
  .oc-stage.is-gliding { transition: none; }
}

/* ==== CONTEXT MENU (context-menu.js) — pointer-anchored right-click menu with submenus. Every layer is
   a body-level position:fixed .cm-menu (no overflow:hidden ancestor can clip it); JS sets left/top/width/
   transform-origin only, everything else lives here. Rows are 32px with a 16px icon gutter, a mono
   shortcut hint and a chevron for submenu parents. Long menus scroll inside the layer. ==== */
.cm-menu { position: fixed; top: 0; left: 0; z-index: 9000; box-sizing: border-box; padding: 5px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--bg-elev); box-shadow: var(--shadow-lift);
  font-family: var(--font-sans); color: var(--fg); overflow-y: auto; overscroll-behavior: contain;
  outline: none; user-select: none; -webkit-user-select: none;
  opacity: 0; transform: scale(.955); transition: opacity .11s ease-out, transform .11s ease-out; }
.cm-menu.is-open { opacity: 1; transform: scale(1); }

.cm-item { display: flex; align-items: center; gap: 8px; box-sizing: border-box; height: 32px; padding: 0 10px;
  border-radius: var(--radius-md); font-size: 13px; line-height: 1; text-align: left; color: var(--fg);
  cursor: default; outline: none; }
.cm-item.is-active { background: var(--accent-soft); color: var(--fg); }
.cm-item[aria-disabled="true"] { color: var(--fg-subtle); opacity: .6; }
.cm-item[aria-disabled="true"].is-active { background: transparent; }
.cm-item.is-danger { color: var(--danger-fg); }
.cm-item.is-danger .cm-icon { color: var(--danger-fg); }
.cm-item.is-danger.is-active { background: var(--danger-bg); }

.cm-icon { flex: 0 0 16px; width: 16px; height: 16px; display: grid; place-items: center; color: var(--fg-subtle); }
.cm-icon svg { display: block; width: 16px; height: 16px; }
.cm-item.is-active .cm-icon { color: currentColor; }
.cm-label { flex: 1 1 auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cm-shortcut { flex-shrink: 0; margin-left: auto; padding-left: 12px; font-family: var(--font-mono);
  font-size: 10.5px; font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--fg-subtle); }
.cm-arrow { flex: 0 0 16px; width: 16px; height: 16px; margin-left: auto; display: grid; place-items: center;
  color: var(--fg-subtle); }
.cm-shortcut + .cm-arrow { margin-left: 6px; }
.cm-arrow svg { display: block; width: 16px; height: 16px; }
.cm-item.is-active .cm-arrow { color: currentColor; }

.cm-sep { padding: 4px 0; }
.cm-sep-line { display: block; height: 1px; background: var(--divider); }
.cm-heading { display: flex; align-items: center; height: 24px; padding: 0 10px; font-size: 10.5px;
  font-weight: var(--weight-medium); letter-spacing: .06em; text-transform: uppercase; color: var(--fg-subtle); }

/* Dark mode — the accent wash needs more presence on a dark panel, and the danger row reads on --danger-fg. */
body[data-mode="dark"] .cm-item.is-active { background: var(--accent-soft); color: var(--fg); }
body[data-mode="dark"] .cm-menu { border-color: var(--border-strong); }

/* Reduced motion — the menu appears in place; position and state still read. */
@media (prefers-reduced-motion: reduce) {
  .cm-menu { transition: none; }
}

/* ==== PROGRESS — interior restyle (progress.js). Keeps ALL FOUR richer variants:
   determinate / buffer / indeterminate / query. Adds the inset-tray look + glossy inset accent fill on top
   of the existing width-driven fill (left-origin). range-with-detents variant DEFERRED. ==== */
.progress-track { padding: 2px; box-shadow: inset 0 1px 2px rgba(0,0,0,.10), inset 0 0 0 1px rgba(0,0,0,.05); }
.progress-fill { box-shadow: inset 0 1px 0 rgba(255,255,255,.35), inset 0 -1px 0 rgba(0,0,0,.18); }

/* Reduced motion — drop the interior-component motion; the states still read. */
@media (prefers-reduced-motion: reduce) {
  .ps-cell-fill, .ps-label, .ps-guess, .ps-check-bg, .ps-check-ico, .ps-rule-txt,
  /* tabs/segmented geometry is spring-driven in JS and jumps under reduced motion (see tabs.js,
     segmented-control.js) — only their colour transitions need suppressing here. */
  .otp-field, .otp-msg, .tabs-tab, .seg-dim, .rng-suffix, .pd-face, .pd-gloss, .ts-meta, .ts-connector, .ts-label { transition: none !important; }
  .otp-digit, .otp-caret, .otp-group.is-shake, .ts-arc, .ts-mark, .ts-shimmer { animation: none !important; }
  .otp-caret { opacity: 1; }
  .ts-shimmer { color: var(--fg); -webkit-text-fill-color: currentColor; }
}

/* ==== VIEW CUBE (view-cube.js) — a 3x3x3 lattice of 26 real sub-cubes over a quaternion core.
   NEW DERIVED TOKENS (--vc-*): like --link and --tabs-strip above, these are derived from existing
   palette tokens with color-mix, never a hardcoded colour, so all 20+ themes and both brands get a
   correct value for free and tools/build_tokens.py --verify still passes. A theme sheet can promote
   them later with no code change ([data-theme=...] outranks the body selectors used here).
   GEOMETRY IS PX, NEVER GRID: every face is an absolutely-positioned square sized from --vc-sub, so
   no label can ever stretch a track and skew the cube (`1fr` is `minmax(auto,1fr)` — the v1 bug). ==== */
body {
  --vc-face: var(--bg-elev);
  --vc-edge: color-mix(in srgb, var(--bg-elev) 90%, var(--fg));
  --vc-corner: color-mix(in srgb, var(--bg-elev) 80%, var(--fg));
  --vc-ink: var(--fg);
  --vc-seam: color-mix(in srgb, var(--fg) 20%, transparent);
  --vc-axis-x: var(--gear-red, var(--danger-fg));
  --vc-axis-y: var(--gear-yellow, var(--success-fg));
  --vc-axis-z: var(--gear-blue, var(--info));
}
.view-cube {
  --vc-size: 150px;
  position: relative; z-index: 20;
  width: calc(var(--vc-size) * 2.15); height: calc(var(--vc-size) * 2.15);
  display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.view-cube[data-position] { position: absolute; }
.view-cube[data-position="top-right"] { top: var(--space-1); right: var(--space-1); }
.view-cube[data-position="top-left"] { top: var(--space-1); left: var(--space-1); }
.view-cube[data-position="bottom-right"] { bottom: var(--space-1); right: var(--space-1); }
.view-cube[data-position="bottom-left"] { bottom: var(--space-1); left: var(--space-1); }
.view-cube[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.vc-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  perspective: calc(var(--vc-size) * 7); }
.vc-cube { position: relative; transform-style: preserve-3d;
  width: var(--vc-size); height: var(--vc-size); cursor: grab; }
.view-cube.is-dragging .vc-cube { cursor: grabbing; }
.view-cube:focus { outline: none; }
.view-cube:focus-visible .vc-stage { box-shadow: var(--shadow-focus); border-radius: var(--radius-md); }

/* one sub-cube — .vc-sub is a zero-size anchor holding the lattice translate, .vc-sub-i a zero-size
   anchor holding ONLY the hover scale, and .vc-sub-i > i the six real faces of that little cube. */
.vc-sub { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d;
  --c: var(--vc-face); }
.vc-sub.vc-k-edge { --c: var(--vc-edge); }
.vc-sub.vc-k-corner { --c: var(--vc-corner); }
.vc-sub-i { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d;
  transform: scale3d(1, 1, 1); transition: transform .17s cubic-bezier(.2, .9, .3, 1.35); }
.vc-sub-i > i {
  position: absolute; display: block;
  width: var(--vc-sub); height: var(--vc-sub);              /* SQUARE by construction */
  margin-left: calc(var(--vc-sub) / -2); margin-top: calc(var(--vc-sub) / -2);
  background: var(--c); border: 1px solid var(--vc-seam);
  backface-visibility: hidden; transition: background-color .15s ease;
}
.vc-sub-i > i.vc-sh-top { background: color-mix(in srgb, var(--c) 86%, var(--bg)); }
.vc-sub-i > i.vc-sh-bottom { background: color-mix(in srgb, var(--c) 78%, var(--fg)); }
.vc-sub-i > i.vc-sh-side { background: color-mix(in srgb, var(--c) 92%, var(--fg)); }
/* hover GROWS — faces, edges AND corners, all 26 */
.vc-sub:hover, .vc-sub.is-hot { --c: var(--accent); }
.vc-sub:hover .vc-sub-i, .vc-sub.is-hot .vc-sub-i { transform: scale3d(1.26, 1.26, 1.26); }
.vc-sub.is-active .vc-sub-i > i { box-shadow: inset 0 0 0 2px var(--accent); }
/* the far side stops taking hits, so a back cube can never steal one from the front */
.vc-sub[data-culled="1"] { pointer-events: none; }

/* FULL-FACE label overlay: six cube-sized squares floating just above the lattice. pointer-events:none
   keeps all 26 sub-cubes reachable underneath; a one-third-face label would be ~36px at the 108px
   overlay size and unreadable. Fixed footprint + shrink-to-fit: geometry drives layout, text never does. */
.vc-labels { position: absolute; left: 50%; top: 50%; width: 0; height: 0;
  transform-style: preserve-3d; pointer-events: none; transition: opacity .2s ease; }
.vc-lbl { position: absolute; overflow: hidden; backface-visibility: hidden; contain: paint; }
.vc-lbl > span {
  position: absolute; left: 50%; top: 50%;
  white-space: nowrap;                                       /* never wraps, never widens the face */
  transform-origin: 50% 50%; transform: translate(-50%, -50%) scale(1);
  font-family: var(--font-sans); font-weight: var(--weight-bold);
  letter-spacing: .06em; text-transform: uppercase; color: var(--vc-ink); line-height: 1;
}

/* XYZ triad (a child of the cube, so it inherits the orientation; the letters are billboarded in JS) */
.vc-triad { position: absolute; left: 50%; top: 50%; width: 0; height: 0;
  transform-style: preserve-3d; pointer-events: none; }
.vc-triad .vc-tb { position: absolute; height: 3px; border-radius: 2px; transform-origin: 0 50%; }
.vc-triad .vc-tc {
  position: absolute; width: 19px; height: 19px; margin: -9.5px 0 0 -9.5px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font: var(--weight-bold) 11px/1 var(--font-mono); color: var(--on-accent); box-shadow: var(--shadow-soft);
}

/* compass ring */
.vc-compass-wrap { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.vc-compass {
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--vc-size) * 1.92); height: calc(var(--vc-size) * 1.92);
  margin-left: calc(var(--vc-size) * -.96); margin-top: calc(var(--vc-size) * -.96);
  border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--fg-muted) 50%, transparent);
  transform-style: preserve-3d; pointer-events: none;
  background: radial-gradient(circle, transparent 62%, color-mix(in srgb, var(--fg-muted) 10%, transparent) 63%, transparent 74%);
}
.vc-compass span { position: absolute; left: 50%; top: 50%; width: 22px; height: 16px;
  margin: -8px 0 0 -11px; text-align: center;
  font: var(--weight-bold) 11px/16px var(--font-mono); color: var(--fg-muted); }
.vc-compass span.vc-n { color: var(--accent); }

/* controls */
.vc-controls { position: absolute; display: flex; flex-direction: column; gap: var(--space-1);
  right: 0; top: 50%; transform: translateY(-50%); z-index: 30; }
.vc-btn {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev); color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; padding: 0; box-shadow: var(--shadow-soft);
}
.vc-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.vc-btn[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.vc-btn:disabled { opacity: .45; cursor: not-allowed; }
.vc-btn svg { width: 15px; height: 15px; display: block; }
.vc-tip {
  position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  background: var(--fg); color: var(--bg);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
  opacity: 0; transition: opacity .12s ease; pointer-events: none; z-index: 40;
}
.vc-tip.is-shown { opacity: 1; }

/* ==== COLOUR PICKER (color-picker.js + color-utils.js) — one component, five form factors chosen by
   data-variant. A variant decides which panes are BUILT, not which are hidden, so there is no
   display:none pane anywhere in this block. ==== */
.cp-checker {
  background-color: var(--bg);
  background-image:
    linear-gradient(45deg, color-mix(in srgb, var(--fg) 18%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--fg) 18%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--fg) 18%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--fg) 18%, transparent) 75%);
  background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}
.color-picker { display: inline-block; }
.color-picker[data-variant="swatches"], .color-picker[data-variant="inline"] { display: block; }
/* the in-flow variants need a width cap of their own: `position:static` drops the popover's fixed
   width, and an aspect-ratio swatch grid would otherwise stretch to the whole column. */
.color-picker[data-variant="inline"], .color-picker[data-variant="swatches"] { max-width: 262px; }
.color-picker[data-variant="swatches"] .cp-pop,
.color-picker[data-variant="inline"] .cp-pop { position: static; width: auto; box-shadow: none; border: 0; padding: 0; }

.cp-trigger {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font: inherit; font-size: var(--text-sm); cursor: pointer; padding: 5px 10px 5px 6px;
  border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border);
}
.cp-trigger:hover:not(:disabled) { background: var(--bg-sunken); }
.cp-trigger[aria-expanded="true"] { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.cp-trigger .cp-chip { width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--border);
  position: relative; overflow: hidden; flex: none; }
.cp-trigger .cp-chip i { position: absolute; inset: 0; }
.cp-trigger .cp-val { font-family: var(--font-mono); letter-spacing: -.01em; }
.cp-trigger.cp-bare { padding: 3px; gap: 0; border-radius: 7px; }
.cp-trigger.cp-bare .cp-chip { width: 24px; height: 24px; border-radius: 4px; }
.cp-trigger:disabled { opacity: .45; cursor: not-allowed; }

/* anchored: the field wrapper an app puts round its own <input> */
.cp-field { display: inline-flex; align-items: center; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-elev); overflow: hidden; max-width: 100%; }
.cp-field:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.cp-field input { font-family: var(--font-mono); font-size: var(--text-sm); padding: 7px 9px;
  border: 0; background: transparent; color: var(--fg); width: 150px; min-width: 0; outline: none; }
.cp-field .cp-trigger { border: 0; border-left: 1px solid var(--border); border-radius: 0;
  padding: 5px 7px; background: var(--bg-sunken); }
.cp-field.is-invalid, input.cp-hex.is-invalid { border-color: var(--danger-fg); }

.cp-pop { position: fixed; z-index: 150; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lift); padding: 11px; width: 238px; }
.cp-pop[hidden] { display: none; }
.cp-pop.cp-grid-only { width: auto; padding: 9px; }

.cp-sv { position: relative; width: 100%; height: 132px; border-radius: var(--radius-sm);
  cursor: crosshair; touch-action: none; overflow: hidden; border: 1px solid var(--border); }
.cp-sv-layer { position: absolute; inset: 0; pointer-events: none; }
.cp-sv-white { background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0)); }
.cp-sv-black { background: linear-gradient(to top, #000, rgba(0, 0, 0, 0)); }
.cp-thumb { position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
  transform: translate(-50%, -50%); pointer-events: none; }
.cp-sv-thumb { top: 0; left: 0; }
.cp-sv:focus-visible, .cp-slider:focus-visible { box-shadow: var(--shadow-focus); }
.cp-sliders { display: flex; flex-direction: column; gap: 9px; margin-top: 11px; }
.cp-slider { position: relative; height: 11px; border-radius: 999px; touch-action: none;
  cursor: pointer; border: 1px solid var(--border); }
.cp-hue { background: linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%); }
.cp-alpha-fill { position: absolute; inset: 0; border-radius: 999px; pointer-events: none; }
.cp-slider .cp-thumb { top: 50%; }

.cp-row { display: flex; gap: 7px; align-items: center; margin-top: 11px; }
.cp-grow { flex: 1; }
.cp-prev { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border);
  flex: none; position: relative; overflow: hidden; }
.cp-prev i { position: absolute; inset: 0; }
.cp-hex { font-family: var(--font-mono); font-size: var(--text-sm); padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-sunken); color: var(--fg);
  width: 100%; min-width: 0; outline: none; }
.cp-hex:focus { border-color: var(--accent); }
.cp-mini { font: inherit; font-size: var(--text-sm); font-family: var(--font-mono); padding: 6px 7px;
  border-radius: 6px; cursor: pointer; flex: none; display: inline-flex; align-items: center;
  background: var(--bg-sunken); color: var(--fg-muted); border: 1px solid var(--border); }
.cp-mini:hover:not(:disabled) { background: var(--bg); color: var(--fg); }
.cp-mini:disabled { opacity: .4; cursor: not-allowed; }

.cp-grp { margin-top: 11px; }
.cp-grp:first-child { margin-top: 0; }
.cp-gl { font-size: 9.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--fg-muted);
  margin-bottom: 5px; display: flex; justify-content: space-between; gap: var(--space-2); }
.cp-gl .cp-src { font-family: var(--font-mono); text-transform: none; letter-spacing: 0; opacity: .75; }
.cp-sw { display: grid; grid-template-columns: repeat(var(--cp-cols, 6), minmax(0, 1fr)); gap: 5px; }
.cp-swatch { width: 100%; aspect-ratio: 1 / 1; min-height: 22px; border-radius: 5px;
  border: 1px solid var(--border); cursor: pointer; padding: 0; position: relative; overflow: hidden;
  transition: transform .09s; }
.cp-swatch i { position: absolute; inset: 0; }
.cp-swatch:hover:not(:disabled) { transform: scale(1.11); }
.cp-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--accent); }
.cp-swatch:disabled { cursor: not-allowed; }
.cp-foot { display: flex; gap: var(--space-1); margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--border); }
.cp-btn { font: inherit; font-size: var(--text-sm); padding: 6px 11px; border-radius: 6px; cursor: pointer;
  background: var(--bg-sunken); color: var(--fg); border: 1px solid var(--border); }
.cp-btn:hover { background: var(--bg); }
.cp-btn.cp-primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }

/* Reduced motion — the view cube's hover still GROWS (that is the affordance, not decoration), just
   without the springy transition; the picker's swatch pop and the cube tooltip fade are dropped. */
@media (prefers-reduced-motion: reduce) {
  .vc-sub-i, .vc-sub-i > i, .vc-tip, .vc-labels { transition: none !important; }
  .vc-sub:hover .vc-sub-i, .vc-sub.is-hot .vc-sub-i { transform: scale3d(1.08, 1.08, 1.08); }
  .cp-swatch { transition: none !important; }
  .cp-swatch:hover:not(:disabled) { transform: none; }
}
