﻿/* ── Theming (issue #40) ──────────────────────────────────────────────────
   Declares the `--lf-theme-*` custom properties (defaulted here to the
   framework's original hardcoded colors — the "Light" look) and applies them
   to the handful of element families the Theme customization page lets a
   user recolor: base background/font, header, footer ("status bar"), panels
   and grid column headers.

   Loaded once, right after site.css/core/section.css so it wins the cascade
   at equal selector specificity; a theme file under wwwroot/css/themes/ (or
   the inline <style> block _LiveLayout.cshtml emits for a Custom theme) is
   loaded straight after THIS file and only ever needs to redeclare the
   `:root` variables — never these selectors — to change the whole app's
   look. See issue #40. */

:root {
  color-scheme: var(--lf-theme-color-scheme, light);
  --lf-theme-body-bg: #e9ecef;
  --lf-theme-body-fg: #343a40;
  --lf-theme-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --lf-theme-header-bg: #212529;
  --lf-theme-header-fg: #f8f9fa;

  --lf-theme-footer-bg: #5a6268;
  --lf-theme-footer-fg: #f8f9fa;
  --lf-theme-footer-border: #4b5157;

  --lf-theme-panel-bg: #ffffff;
  --lf-theme-panel-fg: #212529;
  --lf-theme-panel-border: #dee2e6;

  --lf-theme-column-header-bg: #6c757d;
  --lf-theme-column-header-fg: #ffffff;

  --lf-theme-accent: #0d6efd;
  --lf-theme-accent-rgb: 13, 110, 253;

  /* ── Families the customization page added after the first six ────────────
     Every one of these is DERIVED from the pairs above rather than given a
     literal, and that is the whole point: a custom property's `var()` is
     resolved at use time against the winning value of the referenced property,
     so `--lf-theme-toolbar-bg: var(--lf-theme-panel-bg)` declared here follows
     whichever panel colour the theme file loaded AFTER this one sets. The six
     shipped themes therefore get sensible toolbar/editor/view/field colours
     without any of them being edited, and a theme may still override any single
     one of these by name when the derivation is wrong for it.

     The Custom theme is the exception, and by construction: _LiveLayout.cshtml
     emits every one of these as a literal from CustomThemeColors, so a user's
     own choice always wins over the derivation. */

  /* The command strip at the top of a view (section / tree / composite / detail
     toolbars). One faint step off the panel, the same relationship the
     hand-built #f8f9fa had to a white card, but computed so it steps the other
     way on a dark panel. */
  --lf-theme-toolbar-bg: color-mix(in srgb, var(--lf-theme-panel-bg) 94%, var(--lf-theme-panel-fg));
  --lf-theme-toolbar-fg: var(--lf-theme-panel-fg);
  --lf-theme-toolbar-border: var(--lf-theme-panel-border);

  /* The floating edit box (EditInPlace's cell editor, FieldEditor's overlay) and
     any focused form control. Its border is the accent on purpose: "this is the
     control you are typing into" is exactly the accent's job. */
  --lf-theme-editor-bg: var(--lf-theme-panel-bg);
  --lf-theme-editor-fg: var(--lf-theme-panel-fg);
  --lf-theme-editor-border: var(--lf-theme-accent);

  /* The ground the grid/card/list/form views are drawn on, inside the panel.
     Same as the panel by default — they are separable because a user may want
     the data area to read as a sheet laid on the card. */
  --lf-theme-view-bg: var(--lf-theme-panel-bg);

  /* Field values. The disabled pair is a separate choice, not an opacity: an
     opacity fades the background it sits on too, which on a dark theme makes a
     disabled field look like a hole rather than a field. */
  --lf-theme-field-fg: var(--lf-theme-panel-fg);
  --lf-theme-field-disabled-fg: color-mix(in srgb, var(--lf-theme-panel-fg) 45%, var(--lf-theme-panel-bg));
  --lf-theme-field-disabled-bg: color-mix(in srgb, var(--lf-theme-panel-fg) 8%, var(--lf-theme-panel-bg));

  /* Record-state flag (core/recordState.ts): unchanged / new / modified. Literals
     rather than derivations — these three are a traffic light, and a traffic
     light that changes hue with the theme stops being one. A theme with a
     background they cannot survive overrides them by name. */
  --lf-theme-recordstate-read: #198754;
  --lf-theme-recordstate-new: #ffc107;
  --lf-theme-recordstate-modified: #dc3545;

  /* The row of a record with unsaved changes, and of one that does not exist yet (issue #335
     F3): a wash of the flag colour over the panel, with the panel's own foreground on it, so any
     theme — dark ones included — gets a row that reads without being edited. The two pairs are
     what /Theme exposes; the flag colours above stay the traffic light. */
  --lf-theme-recordstate-modified-bg: color-mix(in srgb, var(--lf-theme-recordstate-modified) 13%, var(--lf-theme-panel-bg));
  --lf-theme-recordstate-modified-fg: var(--lf-theme-panel-fg);
  --lf-theme-recordstate-new-bg: color-mix(in srgb, var(--lf-theme-recordstate-new) 18%, var(--lf-theme-panel-bg));
  --lf-theme-recordstate-new-fg: var(--lf-theme-panel-fg);

  /* The field the server refused (.section-field-error, issue #165 F0). Literals
     for the same reason as the three above, and for one more: the background and
     the text are chosen as a PAIR, so deriving either off the view would break
     the pair the first time a theme moved the view. What the theme does get to
     say is all three at once, from /Theme. */
  --lf-theme-invalid-field-bg: #fdecee;
  --lf-theme-invalid-field-fg: #842029;
  --lf-theme-invalid-field-border: #dc3545;

  /* Progress bars — the seed's, a batch job's, an import pipeline's (issue #152).
     Derived, like the toolbar and editor families: the fill is the accent, the
     track a faint step off the panel, and the two label colours are whatever
     reads on the thing they sit on. So the six shipped themes get a progress bar
     in their own palette without one of the six files being edited, and what the
     Custom theme's four pickers write are literals that win over all of it. */
  --lf-theme-progress-track-bg: color-mix(in srgb, var(--lf-theme-panel-fg) 12%, var(--lf-theme-panel-bg));
  --lf-theme-progress-fill: var(--lf-theme-accent);
  --lf-theme-progress-fill-fg: #ffffff;
  --lf-theme-progress-track-fg: var(--lf-theme-panel-fg);

  /* ── The top bar (app bar) ─────────────────────────────────────────────────
     The bar's own background and text stay --lf-theme-header-bg/-fg. These are
     the pieces standing ON it — the menu and command buttons, the menu search
     box, the badge counting the functions that are not pinned. The rules that
     paint them are further down this file and already followed the theme; what
     they did not have was a name of their own, so there was no way to choose
     one of these colours without moving the whole header with it.

     Each default is exactly the derivation those rules used to inline, so the
     six shipped themes and every palette saved before this look unchanged —
     including the `…, transparent)` mixes, which are translucent lifts off the
     bar rather than flat colours and stay right at any header brightness. The
     Custom theme replaces them with the opaque colours its pickers produce. */
  --lf-theme-topbar-border: color-mix(in srgb, var(--lf-theme-header-fg) 18%, var(--lf-theme-header-bg));
  --lf-theme-topbar-btn-fg: var(--lf-theme-header-fg);
  --lf-theme-topbar-btn-border: color-mix(in srgb, var(--lf-theme-header-fg) 50%, transparent);
  --lf-theme-topbar-btn-hover-bg: color-mix(in srgb, var(--lf-theme-header-fg) 22%, transparent);
  --lf-theme-topbar-search-bg: color-mix(in srgb, var(--lf-theme-header-fg) 12%, transparent);
  --lf-theme-topbar-search-fg: var(--lf-theme-header-fg);
  --lf-theme-topbar-badge-bg: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  --lf-theme-topbar-badge-fg: var(--lf-theme-column-header-fg);

  /* Native widgets (select dropdowns, scrollbars, date pickers) follow this. Light by
     default; Dark sets it to `dark` so a white OS control never opens over a dark page. */
  --lf-theme-color-scheme: light;

  /* Floating cards (dialogs, Bootstrap modals, the account panel, the HTTP log). The
     panel pair is the page's raised surface; a popup is that surface one step further
     off the page, so it still reads when the panel itself is already a card. */
  --lf-theme-popup-bg: var(--lf-theme-panel-bg);
  --lf-theme-popup-fg: var(--lf-theme-panel-fg);
  --lf-theme-popup-border: var(--lf-theme-panel-border);
  --lf-theme-popup-header-bg: color-mix(in srgb, var(--lf-theme-panel-fg) 6%, var(--lf-theme-panel-bg));
  --lf-theme-popup-header-fg: var(--lf-theme-panel-fg);

  /* Nav tabs. Inactive is transparent so the surface underneath (page or panel)
     shows through; active is the panel, so the open pane and its tab are one
     surface. Bootstrap's active tab used --bs-body-bg, which this file never
     re-pointed, so every tab strip stayed white on Dark. */
  --lf-theme-tab-bg: transparent;
  --lf-theme-tab-fg: color-mix(in srgb, var(--lf-theme-body-fg) 72%, var(--lf-theme-body-bg));
  --lf-theme-tab-active-bg: var(--lf-theme-panel-bg);
  --lf-theme-tab-active-fg: var(--lf-theme-panel-fg);
  --lf-theme-tab-border: var(--lf-theme-panel-border);
}

/* Re-point Bootstrap's own primary/link colors at the theme accent, so buttons, focus rings
   and plain links move with it too without a second set of rules (bootstrap.css:351 already
   reads --bs-link-color-rgb).

   This is the single most invasive thing this stylesheet used to do, and the reason it is no
   longer on `:root`: a `--bs-*` declared on the document root needs no class of ours to bite.
   A host page that runs its own Bootstrap beside an Embedded surface (issue #86 §10) had
   every primary button and every link it owns repainted in OUR accent, without one of its
   elements matching one of our selectors. Issue #118, issue #73 §1.6/§3.7.

   The three roots are the ones site.css documents in full. `html.lf-shell` is what keeps the
   classic look unchanged: in a document we own end to end the variables inherit from the root
   exactly as before, chrome and body-level panels included. In a host's document they reach
   our mounted containers and our own portals, and stop there.

   The one rule in this file written with `:is()` rather than `:where()`: bootstrap.css declares
   these same tokens on `:root` (0,1,0), and a declaration that weighs nothing loses to it however
   late it comes. Everything else scoped here uses :where(), which adds no specificity and so
   leaves the cascade exactly as it was.

   `--bs-body-bg` is what Bootstrap paints cards, modals, form controls, tables and the active
   tab with. Re-pointing it here — on our three roots, never on `:root` — is what stops those
   surfaces staying white on Dark. The document's own `<body>` still uses `--lf-theme-body-bg`
   via the rule below, so the page ground and the raised surfaces stay two colours. */
:is(html.lf-shell, .lf-mount, .lf-scope) {
  color-scheme: var(--lf-theme-color-scheme, light);
  --bs-primary: var(--lf-theme-accent);
  --bs-primary-rgb: var(--lf-theme-accent-rgb);
  --bs-link-color: var(--lf-theme-accent);
  --bs-link-color-rgb: var(--lf-theme-accent-rgb);
  --bs-body-bg: var(--lf-theme-panel-bg);
  --bs-body-color: var(--lf-theme-panel-fg);
  --bs-border-color: var(--lf-theme-panel-border);
  --bs-border-color-translucent: color-mix(in srgb, var(--lf-theme-panel-fg) 18%, transparent);
  --bs-secondary-bg: color-mix(in srgb, var(--lf-theme-panel-fg) 8%, var(--lf-theme-panel-bg));
  --bs-tertiary-bg: color-mix(in srgb, var(--lf-theme-panel-fg) 12%, var(--lf-theme-panel-bg));
  --bs-emphasis-color: var(--lf-theme-panel-fg);
  --bs-heading-color: var(--lf-theme-body-fg);
  --bs-secondary-color: color-mix(in srgb, var(--lf-theme-panel-fg) 62%, transparent);
  --bs-tertiary-color: color-mix(in srgb, var(--lf-theme-panel-fg) 50%, transparent);
  --bs-form-valid-border-color: var(--lf-theme-accent);
}

/* ── Base ─────────────────────────────────────────────────────────────── */
/* `body` is the one surface that cannot be scoped to a mount — it CONTAINS the mount. So it
   is conditioned on the document being ours (issue #118, point 2): an Embedded host keeps its
   own background, colour and typeface, and only the pieces it mounted take the theme. */
:where(html.lf-shell) body {
  background-color: var(--lf-theme-body-bg);
  color: var(--lf-theme-body-fg);
  font-family: var(--lf-theme-font-family);
}

/* ── Header (app-bar / top bar) ───────────────────────────────────────────
   The background is declared on `.navbar` in core/shell.css rather than here:
   that rule carries an `!important` (it has to outrank Bootstrap's `.bg-*`
   utilities, which carry one too), so a plain declaration at this specificity
   could never have won. It reads --lf-theme-header-bg, so the colour is still
   this file's — what moved is only where it is applied. */
.lf-navbar {
  color: var(--lf-theme-header-fg);
  border-bottom: 1px solid var(--lf-theme-topbar-border);

  /* Bootstrap's own navbar names, re-pointed at the theme rather than fought
     rule by rule: the brand and every .nav-link the menu strip renders read
     these. `.navbar-dark` (which the layout still carries, and which pins them
     to fixed whites) is the same specificity and earlier in the cascade, so
     this wins. Declared on OUR class, never on :root — a host page running its
     own Bootstrap beside an Embedded surface keeps its own navbar (issue #118). */
  --bs-navbar-color: color-mix(in srgb, var(--lf-theme-header-fg) 78%, var(--lf-theme-header-bg));
  --bs-navbar-hover-color: var(--lf-theme-header-fg);
  --bs-navbar-active-color: var(--lf-theme-header-fg);
  --bs-navbar-brand-color: var(--lf-theme-header-fg);
  --bs-navbar-brand-hover-color: var(--lf-theme-header-fg);
}

/* ── Footer (status bar) ──────────────────────────────────────────────── */
.live-footer {
  background-color: var(--lf-theme-footer-bg);
  color: var(--lf-theme-footer-fg);
  border-top-color: var(--lf-theme-footer-border);
}

/* ── Panels (section cards, popup menus) ──────────────────────────────── */
.section-page-card,
.lf-popup-menu {
  background-color: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}

.lf-popup-menu-check {
  color: var(--lf-theme-accent);
}

/* ── Grid / table column headers ("colonne") ──────────────────────────── */
.section-grid-table thead th,
.section-grid-table thead .section-header-row th {
  background-color: var(--lf-theme-column-header-bg);
  color: var(--lf-theme-column-header-fg);
}

/* ══════════════════════════════════════════════════════════════════════════
   Extending the mapping to the rest of the shell (issue: "toolbar / barra
   delle applicazioni / menu a scomparsa e di contesto senza colori; chat e
   notifiche senza tema").

   Everything below is a MAPPING, not a redesign: only color, background and
   border-color change — never geometry, spacing, radius or z-index. All of
   these files load BEFORE theme.css (_LiveLayout.cshtml:86-98 vs :104), so a
   rule that merely matches its target's specificity already wins; where a
   component rule is more specific, the same compound is repeated here.

   Two recipes are reused throughout, so the same decision is not re-made
   twelve times:

     ACCENT CHIP — a solid accent surface that carries text or an icon:
       background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
       color:      var(--lf-theme-column-header-fg);
     Raw accent + #fff is unreadable on five of the six shipped themes (white
     on dark's #4dabf7 = 2.3:1) and raw accent + column-header-fg fails on dark
     for the same reason. Grounding the accent in column-header-bg — the one
     pair the theme defines as "a filled colour strip and text that reads on
     it" — keeps the accent hue dominant and lands at 4.9:1 (light), 4.5 (dark),
     5.0 (sunset), 4.3 (forest), 3.6 (ocean), 3.2 (candy): never worse than
     what the same theme already ships on its own app bar. It also survives
     sunset, where --lf-theme-accent IS --lf-theme-header-bg (#ff6b6b) and any
     raw-accent chrome would simply disappear.

     ACCENT INK — accent-coloured text/icons on a panel:
       color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
     Pulling the accent 30% toward the panel's own text darkens it on light
     panels and lightens it on dark ones; bare accent as text is only 2.6:1 on
     sunset's #fff8f0.

   Selection states are rgba(var(--lf-theme-accent-rgb), α) washes rather than
   solid fills wherever the element keeps its surrounding text colour, so a
   pale accent can never bleach a label.
   ══════════════════════════════════════════════════════════════════════════ */


/* ── Header chrome: function bar ("barra delle applicazioni"), tab strip ───
   Every button on the app bar — pinned functions, group splits, tabs, the
   sitemap, the scroll arrows, the chat/notification toggles — is
   `btn btn-outline-light`, hardcoded to white-alpha by core/shell.css's
   `.navbar .btn-outline-light` (0,2,0). Only the --bs-btn-* variables are
   redefined, never color/background-color: the rule after it there repaints those
   with !important for :hover/:focus/.active/.show, and that rule READS these
   variables — so feeding it themed values recolours every state at once.
   Matched at (0,2,0), later in the cascade.

   The three colours this block used to inline off header-fg are now named
   (--lf-theme-topbar-btn-fg / -border / -hover-bg), so the Theme page can offer
   them as pickers of their own; their defaults are the same mixes. Active stays
   one step stronger than hover, expressed as a mix of the hover value so it
   follows a picked colour as faithfully as it followed the derived one. */
.lf-navbar .btn-outline-light {
  --bs-btn-color: var(--lf-theme-topbar-btn-fg);
  --bs-btn-border-color: var(--lf-theme-topbar-btn-border);
  --bs-btn-hover-color: var(--lf-theme-topbar-btn-fg);
  --bs-btn-hover-bg: var(--lf-theme-topbar-btn-hover-bg);
  --bs-btn-hover-border-color: var(--lf-theme-topbar-btn-fg);
  --bs-btn-active-color: var(--lf-theme-topbar-btn-fg);
  --bs-btn-active-bg: color-mix(in srgb, var(--lf-theme-topbar-btn-hover-bg) 92%, var(--lf-theme-topbar-btn-fg));
  --bs-btn-active-border-color: var(--lf-theme-topbar-btn-fg);
  --bs-btn-disabled-color: var(--lf-theme-topbar-btn-fg);
  --bs-btn-disabled-border-color: var(--lf-theme-topbar-btn-border);
  --bs-btn-focus-shadow-rgb: var(--lf-theme-accent-rgb);
}

/* Drag grip on the bar (site.css:737, (0,1,1)). The dotted rule is the bar's
   own foreground at reduced strength — a muted label, not a border colour. */
.lf-menu-bar-grip::before {
  border-left-color: color-mix(in srgb, var(--lf-theme-header-fg) 70%, transparent);
  border-right-color: color-mix(in srgb, var(--lf-theme-header-fg) 70%, transparent);
}

/* Close chip on an open pin (site.css). Header colours on the bar; panel colours
   inside a group dropdown. Hover stays destructive red, same as .lf-window-close. */
.lf-menu-bar-close {
  background: color-mix(in srgb, var(--lf-theme-header-fg) 92%, transparent);
  color: var(--lf-theme-header-bg);
}
.lf-menu-bar-dropdown .lf-menu-bar-close {
  background: color-mix(in srgb, var(--lf-theme-panel-fg) 88%, transparent);
  color: var(--lf-theme-panel-bg);
}

/* The same grip once the group's members are listed in its dropdown: that is a
   panel, and site.css:820 (0,2,1) already flips it to dark — expressed against
   panel-fg it also stays visible when the panel itself is dark. */
.lf-menu-bar-dropdown .lf-menu-bar-grip::before {
  border-left-color: color-mix(in srgb, var(--lf-theme-panel-fg) 45%, transparent);
  border-right-color: color-mix(in srgb, var(--lf-theme-panel-fg) 45%, transparent);
}

/* Member-count pill on a group button (site.css:753). currentColor, not
   header-fg: the pill lives inside the button, whose foreground flips to
   --bs-btn-active-color while the dropdown is open, and the original white
   dissolved into that same hover wash. */
.lf-menu-bar-group-count {
  background: color-mix(in srgb, currentColor 22%, transparent);
}

/* "Drag a function here" placeholder (site.css:770) — a muted label on chrome. */
.lf-menu-bar-hint {
  color: color-mix(in srgb, var(--lf-theme-header-fg) 60%, transparent);
}

/* Header search field + the splitter beside it (site.css:588-606): both are
   hand-built white-alpha, i.e. they assume a dark header and vanish on a light
   one. Same translucent-lift idiom as the buttons above. */
.lf-menu-search {
  background: var(--lf-theme-topbar-search-bg);
  border-color: color-mix(in srgb, var(--lf-theme-topbar-btn-border) 70%, transparent);
  color: var(--lf-theme-topbar-search-fg);
}
.lf-menu-search::placeholder {
  color: color-mix(in srgb, var(--lf-theme-topbar-search-fg) 65%, transparent);
}
.lf-menu-search:focus {
  background: color-mix(in srgb, var(--lf-theme-topbar-search-bg) 90%, var(--lf-theme-topbar-search-fg));
  border-color: var(--lf-theme-accent);
  color: var(--lf-theme-topbar-search-fg);
}
.lf-menu-splitter::before {
  background: color-mix(in srgb, var(--lf-theme-header-fg) 35%, transparent);
}
/* Rule between menu strip and the end cluster (site.css .lf-navbar-sep) —
   same translucent-lift as the splitter, so a light header keeps it visible. */
.lf-navbar-sep {
  background: color-mix(in srgb, var(--lf-theme-header-fg) 35%, transparent);
}
.lf-menu-splitter:hover::before,
.lf-menu-splitter:focus-visible::before,
.lf-menu-splitter.is-dragging::before {
  background: color-mix(in srgb, var(--lf-theme-header-fg) 85%, transparent);
}
.lf-menu-splitter:focus-visible {
  outline-color: var(--lf-theme-accent);
}

/* Sitemap entry count (site.css:518): a count badge on the bar → accent chip.
   Its #ffc107 was decoration, not a warning. Named (--lf-theme-topbar-badge-*)
   because it is the one mark on the bar a user is most likely to want in a
   colour of their own; the default is the chip this rule already computed. */
.lf-menu-sitemap-count {
  background-color: var(--lf-theme-topbar-badge-bg);
  color: var(--lf-theme-topbar-badge-fg);
}

/* Reorder feedback while a pin/tab is dragged (site.css:779 (0,2,0) and
   site.css:797 (0,1,0), both #ffc107). Deliberately header-fg and not the
   accent for the two variants drawn ON the bar: sunset sets the accent to the
   header background, so an accent outline there would be invisible exactly
   while it matters. Only the *-color longhands are set, so site.css keeps
   owning the 2px/offset geometry. `.is-horizontal-line` (menuBar.ts:698) is the
   one drawn inside the group dropdown, on a panel, where the accent is safe. */
.lf-menu-bar-drop-target .btn,
.lf-menu-bar-drop-target.lf-menu-bar-slot {
  outline-color: var(--lf-theme-header-fg);
}
.lf-menu-bar-insert {
  background: var(--lf-theme-header-fg);
}
.lf-menu-bar-insert.is-horizontal-line {
  background: var(--lf-theme-accent);
}

/* The drag chip is position:fixed on <body> and follows the cursor across the
   content area as often as across the bar (menuBar.ts:613), so it is a floating
   surface ON the page → panel. site.css:784 (0,1,0); the border-color longhand
   lands after that rule's `border` shorthand. */
.lf-menu-bar-ghost {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}

/* Taskbar state: a pinned function that owns an open window (desktop.css:181,
   (0,2,0) — must stay after the .btn-outline-light block above, which is also
   (0,2,0)). The faint fill is a second carrier of the state, because on sunset
   the accent ring is drawn in the header's own colour. */
.lf-menu-bar-pin.lf-window-open {
  --bs-btn-bg: color-mix(in srgb, var(--lf-theme-header-fg) 16%, transparent);
  box-shadow: inset 0 0 0 2px rgba(var(--lf-theme-accent-rgb), 0.85);
}

/* SpaTabs marks the active tab's <li> (spaTabs.ts:120), not the button inside
   it. spaTabs.css:36 tints it with white 12%, which only works on a dark bar —
   and inside a group dropdown that same white-on-white marker is invisible
   today. Two carriers, two surfaces: (0,2,0) each, over the source's (0,1,0).
   The ::after underline is left alone on purpose: it is `currentColor`, which
   already resolves to header-fg on the bar and to panel-fg in the dropdown. */
.lf-spatabs-active-slot.lf-menu-bar-slot {
  background: color-mix(in srgb, var(--lf-theme-header-fg) 16%, transparent);
}
.lf-spatabs-active-slot.lf-menu-bar-member {
  background: rgba(var(--lf-theme-accent-rgb), 0.16);
}

/* Tab host. spaTabs.css:11/:27 declare no background at all, so the panel is
   only accidentally right (the themed <body> shows through) and an iframe
   paints white until its own document loads — body-bg, because what lands a
   moment later IS that document's body. */
.lf-tabs,
.lf-tab-surface {
  background-color: var(--lf-theme-body-bg);
}


/* ── Menus: dropdown ("a scomparsa"), context, popup, split-button ─────────
   A menu is a floating surface sitting ON the page → panel colours, never
   header/footer. Separators are panel-border; hover / focus / checked /
   selected are accent washes.

   One variable block reaches every Bootstrap-based menu at once: the navbar
   menu strip and its body-portaled copy (.lf-menu-dropdown-portal), the
   account and language menus, the pinned-group dropdowns, the section
   filter-operator / multiselect / FK menus, and the right-click context menu
   (contextMenu.ts:92 builds "dropdown-menu show lf-context-menu"). Overrides
   bootstrap.css:3427-3451 `.dropdown-menu` (0,1,0); --bs-dropdown-bg resolved
   to --bs-body-bg, which theme.css never re-points, so every menu in the app
   is white on all six themes today. */
:where(html.lf-shell, .lf-mount, .lf-scope) .dropdown-menu {
  --bs-dropdown-color: var(--lf-theme-panel-fg);
  --bs-dropdown-bg: var(--lf-theme-panel-bg);
  --bs-dropdown-border-color: var(--lf-theme-panel-border);
  --bs-dropdown-divider-bg: var(--lf-theme-panel-border);
  --bs-dropdown-link-color: var(--lf-theme-panel-fg);
  --bs-dropdown-link-hover-color: var(--lf-theme-panel-fg);
  --bs-dropdown-link-hover-bg: rgba(var(--lf-theme-accent-rgb), 0.14);
  --bs-dropdown-link-active-color: var(--lf-theme-panel-fg);
  --bs-dropdown-link-active-bg: rgba(var(--lf-theme-accent-rgb), 0.24);
  --bs-dropdown-link-disabled-color: color-mix(in srgb, var(--lf-theme-panel-fg) 45%, transparent);
  --bs-dropdown-header-color: color-mix(in srgb, var(--lf-theme-panel-fg) 62%, transparent);
}

/* Bootstrap styles :hover and :focus identically and draws no ring, so keyboard
   focus is indistinguishable from the mouse. :focus-visible only. */
:where(html.lf-shell, .lf-mount, .lf-scope) .dropdown-item:focus-visible {
  outline: 2px solid var(--lf-theme-accent);
  outline-offset: -2px;
}

/* Destructive items (contextMenu.ts:103, popupMenu.ts:35 add .text-danger) keep
   Bootstrap's red — that is meaning, not theme — but they must not have to sit
   on an accent wash of a similar hue. A neutral panel tint instead; (0,3,0)
   over bootstrap.css:3669 and site.css:319, both (0,2,0). */
:where(html.lf-shell, .lf-mount, .lf-scope) .dropdown-item.text-danger:hover,
:where(html.lf-shell, .lf-mount, .lf-scope) .dropdown-item.text-danger:focus,
.lf-popup-menu-item.text-danger:hover,
.lf-popup-menu-item.text-danger:focus-visible {
  background-color: color-mix(in srgb, var(--lf-theme-panel-fg) 10%, transparent);
}

/* Shadows are read against the PAGE behind the menu, so they track body-fg:
   dark ink on the light themes (indistinguishable from today), a soft halo on
   dark, where a black shadow does no lifting at all.
   section.css:2180 `.lf-context-menu` and site.css:277 `.lf-popup-menu`. */
.lf-context-menu {
  box-shadow: 0 0.5rem 1rem color-mix(in srgb, var(--lf-theme-body-fg) 25%, transparent);
}
.lf-popup-menu {
  box-shadow: 0 6px 20px color-mix(in srgb, var(--lf-theme-body-fg) 28%, transparent);
}

/* Footer popup menus (tools, language). Background/colour/border are already
   mapped above; these are the parts that were left flat. site.css:346. */
.lf-popup-menu-icon {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 65%, transparent);
}

/* popupMenu.ts:35 emits .is-checked but no stylesheet ever styled it — only the
   check glyph was coloured. One step lighter than hover, and it MUST stay above
   the :hover rule (both (0,2,0)) so hovering a checked row still changes it. */
.lf-popup-menu-item.is-checked {
  background-color: rgba(var(--lf-theme-accent-rgb), 0.12);
}
.lf-popup-menu-item:hover,
.lf-popup-menu-item:focus-visible {
  background-color: rgba(var(--lf-theme-accent-rgb), 0.14);
}
/* site.css:322 kills the outline for the mouse; keyboard focus gets it back. */
.lf-popup-menu-item:focus-visible {
  outline: 2px solid var(--lf-theme-accent);
  outline-offset: -2px;
}

/* Split-button menus — view switcher, filter split, bulk actions, the FullEdit
   splits (splitButton.ts:63). Hand-rolled, so the .dropdown-menu block does not
   reach them, and their var(--bs-body-bg, #fff) fallback keeps them white on
   every theme. section.css:1176/1194/1209/1222/1226. `.active` stays above
   `:hover` (both (0,2,0)); `.section-view-item:disabled:hover` (0,3,0) still
   wins, so disabled rows stay flat. `.section-view-check` already reads
   --bs-primary, which theme.css:40 points at the accent — untouched. */
.section-view-menu {
  background: var(--lf-theme-panel-bg);
  border-color: var(--lf-theme-panel-border);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--lf-theme-body-fg) 25%, transparent);
}
.section-view-item {
  color: var(--lf-theme-panel-fg);
}
.section-view-item-icon {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 60%, transparent);
}
.section-view-item.active {
  background-color: rgba(var(--lf-theme-accent-rgb), 0.12);
}
.section-view-item:hover {
  background-color: rgba(var(--lf-theme-accent-rgb), 0.14);
}

/* This local hover (section.css:562, (0,3,0)) outranks Bootstrap's item hover,
   so without an equal-specificity twin the multiselect would be the one menu
   left with a grey highlight. */
.section-multiselect-menu .section-multiselect-item:hover {
  background-color: rgba(var(--lf-theme-accent-rgb), 0.14);
}

/* Menu-search result list (site.css:607-655). It detaches from the navbar and
   hangs over the page → panel, not header. Its #e7f1ff / #d0e4ff / #0d6efd are
   a hand-mixed ramp of the old accent; the keyboard cursor stays roughly double
   the hover wash, and `.is-active` must remain after the shared hover rule. */
.lf-menu-search-results {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
  box-shadow: 0 0.5rem 1rem color-mix(in srgb, var(--lf-theme-body-fg) 28%, transparent);
}
.lf-menu-search-item {
  border-bottom-color: color-mix(in srgb, var(--lf-theme-panel-border) 60%, transparent);
}
.lf-menu-search-item:hover,
.lf-menu-search-item:focus,
.lf-menu-search-item.is-active {
  background: rgba(var(--lf-theme-accent-rgb), 0.12);
  border-left-color: var(--lf-theme-accent);
}
.lf-menu-search-item.is-active {
  background: rgba(var(--lf-theme-accent-rgb), 0.22);
}
.lf-menu-search-path {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 60%, transparent);
}
.lf-menu-search-help {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 78%, transparent);
}

/* Sitemap browser rows (site.css:839). rgba(0,0,0,.02) is nothing on a dark
   theme; hovering a navigable row is a selection cue → accent. */
/* Sitemap browser. The tree used to carry Bootstrap's `bg-white`, which is an
   `!important` utility and outranked the panel mapping; the class is gone, and
   this is the panel the page is. */
.app-menu-page {
  color: var(--lf-theme-body-fg);
}
.app-menu-tree {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}
.app-menu-row:hover {
  background: rgba(var(--lf-theme-accent-rgb), 0.08);
}


/* ── Toolbars ─────────────────────────────────────────────────────────────
   Two families. `.lf-full-edit-toolbar` is app chrome: the header's own second
   row, in the flow under the navbar, full width, never scrolls (fullEdit.css:1-32
   — it was position:fixed until issue #188 F1b), so it takes the HEADER pair.
   Every other toolbar is a command strip inside (or on) a panel — section / tree
   / composite / detail-modal toolbars, rich text, SQL, mail-merge, PDF — so it
   takes the PANEL pair with the ACCENT for hover, pressed and focus. */

/* fullEdit.css:18-31 (0,1,0). #3d4348 was deliberately a few steps lighter than
   the navbar so the two bars read as separate; 14% of header-fg reproduces that
   lift in any theme (light: #3f4346 vs #3d4348) and in the right direction for
   light-headed themes too. The bottom edge stays one step denser than the strip. */
.lf-full-edit-toolbar {
  background: color-mix(in srgb, var(--lf-theme-header-bg) 86%, var(--lf-theme-header-fg));
  border-bottom-color: color-mix(in srgb, var(--lf-theme-header-bg) 94%, var(--lf-theme-header-fg));
  color: var(--lf-theme-header-fg);
}

/* Its buttons are btn-sm btn-outline-light (_FullEditToolbar.cshtml:8-113) and
   are NOT in the navbar, so the header block above does not reach them.
   Hover and press swap the header pair, which is legible by construction in
   every theme. (0,2,0) over bootstrap.css:3294 (0,1,0). */
.lf-full-edit-toolbar .btn-outline-light {
  --bs-btn-color: var(--lf-theme-header-fg);
  --bs-btn-border-color: var(--lf-theme-header-fg);
  --bs-btn-hover-color: var(--lf-theme-header-bg);
  --bs-btn-hover-bg: var(--lf-theme-header-fg);
  --bs-btn-hover-border-color: var(--lf-theme-header-fg);
  --bs-btn-active-color: var(--lf-theme-header-bg);
  --bs-btn-active-bg: var(--lf-theme-header-fg);
  --bs-btn-active-border-color: var(--lf-theme-header-fg);
  --bs-btn-disabled-color: var(--lf-theme-header-fg);
  --bs-btn-disabled-border-color: var(--lf-theme-header-fg);
  --bs-btn-focus-shadow-rgb: var(--lf-theme-accent-rgb);
}

/* Toggled Query / Bulk edit (fullEditToolbar.ts) = active → accent. A wash
   rather than a fill, so header-fg stays the label colour whatever the accent
   is; it also replaces the black-on-dark that Bootstrap's .btn.active
   (bootstrap.css:3037) inherits from btn-outline-light today.
   (0,3,0) over fullEdit.css:44 (0,2,0); the split-button compound repeats
   fullEdit.css:45 exactly (0,4,0). */
.lf-full-edit-toolbar .lf-fe-btn.active,
.lf-full-edit-toolbar .lf-split-btn.active > .btn {
  background-color: rgba(var(--lf-theme-accent-rgb), 0.38);
  border-color: var(--lf-theme-accent);
  color: var(--lf-theme-header-fg);
}

/* The overflow menu of that same strip (core/toolbarOverflow.ts) holds its buttons,
   and its buttons are btn-outline-light: on the panel pair they would be white on
   white. It is part of the chrome bar, so it is drawn like the chrome bar. */
.lf-full-edit-toolbar .lf-tb-overflow-panel {
  background: color-mix(in srgb, var(--lf-theme-header-bg) 86%, var(--lf-theme-header-fg));
  border-color: color-mix(in srgb, var(--lf-theme-header-bg) 94%, var(--lf-theme-header-fg));
  color: var(--lf-theme-header-fg);
}

/* Its nested dropdowns are drawn flat inside it (css/core/toolbar.css), so they
   have to read on that ground rather than on the panel's. */
.lf-full-edit-toolbar .lf-tb-overflow-panel .section-view-menu {
  background: transparent;
  border-color: color-mix(in srgb, var(--lf-theme-header-bg) 70%, var(--lf-theme-header-fg));
  color: var(--lf-theme-header-fg);
}

.lf-full-edit-toolbar .lf-tb-overflow-panel .section-view-item {
  color: var(--lf-theme-header-fg);
}

/* "Sola lettura" is a toggle button pinned to the trailing edge
   (fullEdit.css). Off = outline-light like every other command; on =
   .lf-fe-btn.active above (accent wash). No extra colour rule needed. */

/* Neutral buttons of the in-panel toolbars: .section-toolbar-row
   (section.css:577, inside the already-themed .section-page-card), .tree-toolbar
   and .composite-page-toolbar (section.css:1257). Bootstrap's flat #6c757d
   (bootstrap.css:3209-3222) becomes mixes of the panel pair, which reproduce it
   under light (~#6b6b6b) and invert correctly on dark, where the literal grey is
   nearly invisible. (0,2,0) over (0,1,0). The two detail-modal toolbars sit in a
   Bootstrap .modal-content that now takes the popup pair, so they use the same
   mixes as every other in-panel strip. */
.section-toolbar-row .btn-outline-secondary,
.tree-toolbar .btn-outline-secondary,
.composite-page-toolbar .btn-outline-secondary,
.section-modal-toolbar .btn-outline-secondary,
.section-detail-fulledit-toolbar .btn-outline-secondary {
  --bs-btn-color: color-mix(in srgb, var(--lf-theme-panel-fg) 72%, var(--lf-theme-panel-bg));
  --bs-btn-border-color: color-mix(in srgb, var(--lf-theme-panel-fg) 55%, var(--lf-theme-panel-bg));
  --bs-btn-disabled-color: color-mix(in srgb, var(--lf-theme-panel-fg) 40%, var(--lf-theme-panel-bg));
  --bs-btn-disabled-border-color: color-mix(in srgb, var(--lf-theme-panel-fg) 30%, var(--lf-theme-panel-bg));
}

/* Hover / pressed / focus are the states the accent owns. Washes, not fills,
   keep a fifteen-button toolbar calm and keep the label at accent-ink, which is
   legible on any panel — including the modal's popup ground. */
.section-toolbar-row .btn-outline-secondary,
.tree-toolbar .btn-outline-secondary,
.composite-page-toolbar .btn-outline-secondary,
.section-modal-toolbar .btn-outline-secondary,
.section-detail-fulledit-toolbar .btn-outline-secondary {
  --bs-btn-hover-color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
  --bs-btn-hover-bg: rgba(var(--lf-theme-accent-rgb), 0.14);
  --bs-btn-hover-border-color: var(--lf-theme-accent);
  --bs-btn-active-color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
  --bs-btn-active-bg: rgba(var(--lf-theme-accent-rgb), 0.28);
  --bs-btn-active-border-color: var(--lf-theme-accent);
  --bs-btn-focus-shadow-rgb: var(--lf-theme-accent-rgb);
}

/* The primary toolbar action — Save/Edit (sectionModal.ts:78), tree Reload,
   section back-to-origin — IS the accent role, but .btn-outline-primary
   hardcodes #0d6efd (bootstrap.css:3192-3206) and does not read --bs-primary,
   so theme.css:40 never reached it: these stay Bootstrap blue on candy, forest
   and sunset today. The filled states use the accent chip recipe. */
.section-toolbar-row .btn-outline-primary,
.tree-toolbar .btn-outline-primary,
.composite-page-toolbar .btn-outline-primary,
.section-modal-toolbar .btn-outline-primary,
.section-detail-fulledit-toolbar .btn-outline-primary {
  --bs-btn-color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
  --bs-btn-border-color: var(--lf-theme-accent);
  --bs-btn-hover-color: var(--lf-theme-column-header-fg);
  --bs-btn-hover-bg: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  --bs-btn-hover-border-color: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  --bs-btn-active-color: var(--lf-theme-column-header-fg);
  --bs-btn-active-bg: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  --bs-btn-active-border-color: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  --bs-btn-disabled-color: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-panel-bg));
  --bs-btn-disabled-border-color: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-panel-bg));
  --bs-btn-focus-shadow-rgb: var(--lf-theme-accent-rgb);
}

/* "A link context is active" (section.css:728-736) and "filters are active"
   (section.css:739-749) are the same visual idiom and both hardcode a hand-built
   tint ramp of #0d6efd, which is why they clash on candy/forest/sunset. An alpha
   ramp of the accent reproduces them under light and follows any theme.
   (0,2,0)/(0,3,0), matching the originals.
   The warning-yellow siblings (.section-btn-bulk-active, section.css:752, and
   .section-tb-btn-active) are left alone: they mean "an edit/bulk operation is
   pending", the same signal as the dirty-field markers — not "selected". */
.section-tb-btn.section-btn-linkback,
.section-btn-filter.section-btn-filter-active,
.section-btn-filter.section-btn-filter-active > .btn {
  background-color: rgba(var(--lf-theme-accent-rgb), 0.16);
  border-color: var(--lf-theme-accent);
  color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
}
.section-tb-btn.section-btn-linkback:hover,
.section-btn-filter.section-btn-filter-active:hover,
.section-btn-filter.section-btn-filter-active > .btn:hover {
  background-color: rgba(var(--lf-theme-accent-rgb), 0.28);
  border-color: var(--lf-theme-accent);
  color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
}

/* Three levels of toolbar text on the panel — title, page info, then separator
   and row count — kept as three mixes of the same pair so the hierarchy survives
   on a dark panel instead of inverting. section.css:597, :643, :649, :654. */
.section-toolbar-title {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 80%, var(--lf-theme-panel-bg));
}
.section-page-info {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 60%, var(--lf-theme-panel-bg));
}
.section-page-info-sep,
.section-page-info-rows {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 35%, var(--lf-theme-panel-bg));
}

/* Attachment count on the toolbar's paperclip, and the clip+count chip beside
   the title (documents.css:11, :34, :44) — an unread-style badge → accent chip,
   its rgba ramp a one-for-one translation to the theme accent. */
.section-docs-badge {
  background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}
.section-docs-signal {
  background: rgba(var(--lf-theme-accent-rgb), 0.10);
  color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
}
.section-docs-signal:hover,
.section-docs-signal:focus-visible {
  background: rgba(var(--lf-theme-accent-rgb), 0.18);
  color: color-mix(in srgb, var(--lf-theme-accent) 80%, var(--lf-theme-panel-fg));
}

/* Toolbar strips of the embedded editors: the tree page's toolbar card
   (site.css:855 via .card) and the TipTap format bar (richText.css:17,20, whose
   --bs-tertiary-bg/--bs-border-color look themable but are fixed Bootstrap
   tokens). Both keep the original's faint step away from the panel ground. */
.tree-toolbar,
.lf-richtext-toolbar {
  background: var(--lf-theme-toolbar-bg);
  border-color: var(--lf-theme-toolbar-border);
  color: var(--lf-theme-toolbar-fg);
}

/* Group separators inside those strips, and the strips' own dividing rules —
   an outline inside a panel → panel-border. Colour only, so the 1px solid
   geometry of the source rules survives.
   richText.css:38, dbQueryPanel.css:12, mailmerge.css:42. */
.lf-richtext-toolbar-sep {
  background: var(--lf-theme-panel-border);
}
.dbqp-toolbar,
.mailmerge-toolbar {
  border-bottom-color: var(--lf-theme-panel-border);
}

/* A toggled format button is already accent-filled through --bs-primary, but
   its label was hard #fff (richText.css:31) — around 2:1 on dark's pale accent.
   Restated as the accent chip. (0,3,0) over (0,2,0). */
.lf-richtext-toolbar .lf-richtext-toolbar-btn.active {
  background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  border-color: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}


/* ── Desktop shell: floating windows ──────────────────────────────────────
   The window FRAME floats on the page → panel. A window TITLE BAR is chrome,
   and the shell has two chrome pairs for the window manager's two states, so
   both get spent: focused = header (the app's primary chrome at that moment,
   tying the active window to the navbar), unfocused = footer (the secondary,
   recessive one). Both are designed bg/fg pairs, so no theme can land dark text
   on a dark bar the way a hand-faded header would. */
.lf-window {
  background-color: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}
/* desktop.css:44's rgba(0,0,0,.175) frame is invisible over a dark body, so
   windows currently have no edge at all on dark; the focus border needs a
   little more alpha than .4 to separate from panel-border on desaturated
   accents (forest #6a994e). */
.lf-window.is-focused {
  border-color: rgba(var(--lf-theme-accent-rgb), 0.55);
}
.lf-window-titlebar {
  background-color: var(--lf-theme-footer-bg);
  color: var(--lf-theme-footer-fg);
}
.lf-window.is-focused .lf-window-titlebar {
  background-color: var(--lf-theme-header-bg);
  color: var(--lf-theme-header-fg);
}
/* Title-bar buttons inherit the bar's colour (desktop.css:103), which now
   differs between the two states — currentColor is the only wash correct on
   both, and the only one that survives a light title bar.
   .lf-window-close:hover keeps its #dc3545: destructive, not thematic. */
.lf-window-btn:hover {
  background: color-mix(in srgb, currentColor 18%, transparent);
}
/* The iframe hosts a whole framework page, so what paints a moment later is
   that document's own <body> — matching it removes the white flash on every
   window open under a dark theme (desktop.css:127). */
.lf-window-surface {
  background-color: var(--lf-theme-body-bg);
}
/* "The window will land here" is a selection preview → accent (desktop.css:21;
   the border-color longhand lands after the source's `border` shorthand). */
.lf-desktop-snap-preview {
  background: rgba(var(--lf-theme-accent-rgb), 0.18);
  border-color: rgba(var(--lf-theme-accent-rgb), 0.65);
}


/* ── Chat ─────────────────────────────────────────────────────────────────
   Roles: the panel frame, thread, other people's bubbles, menus and dialogs →
   panel; the conversation sidebar, a recessed strip behind the thread → body
   (its #f8f9fa-under-#fff step, re-created in both directions); the panel's own
   title bar → column-header, the theme's "filled strip + text that reads on it"
   pair, shared with the notification panel so the two dropdowns hanging off the
   same navbar agree; the floating call pill → footer, i.e. status chrome;
   selection, hover, my own messages and unread counts → accent.
   Left semantic on purpose: the call accept/decline/mute green and red, the
   presence dot and the modal scrims. */

.lf-chat {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
}
/* The chat's own splitter and its pinned border are gone (issue #188, F4/N7): the column is a
   dock zone now, and the handle that sizes it is the zone's — themed below with the others. */
.lf-dock-splitter::before {
  background: var(--lf-theme-panel-border);
}
.lf-dock-splitter:hover::before,
.lf-dock-splitter:focus-visible::before {
  background: var(--lf-theme-accent);
}
.lf-dock {
  background: var(--lf-theme-panel-bg);
}

/* Title bar (chat.css:116-131). The 2px rule under it is drawn from the strip's
   own foreground so it stays visible whether the strip is grey, near-black or
   orange. */
.lf-chat-titlebar {
  background: var(--lf-theme-column-header-bg);
  color: var(--lf-theme-column-header-fg);
  border-bottom-color: color-mix(in srgb, var(--lf-theme-column-header-fg) 30%, transparent);
}
.lf-chat-titlebar-title {
  color: var(--lf-theme-column-header-fg);
}

/* The active-user field sits ON that strip: a white card would be a hole in it,
   so it becomes a translucent lift of the strip's foreground — the standard
   field-on-a-coloured-bar idiom, correct on a light strip too (chat.css:136-151). */
.lf-chat-users {
  background: color-mix(in srgb, var(--lf-theme-column-header-fg) 14%, transparent);
  border-color: color-mix(in srgb, var(--lf-theme-column-header-fg) 40%, transparent);
  color: var(--lf-theme-column-header-fg);
}
.lf-chat-users input::placeholder {
  color: color-mix(in srgb, var(--lf-theme-column-header-fg) 65%, transparent);
}
.lf-chat-users:focus-within {
  border-color: var(--lf-theme-accent);
  box-shadow: 0 0 0 2px rgba(var(--lf-theme-accent-rgb), 0.35);
}

/* Its dropdown floats over the page → panel (chat.css:162-180). The presence
   ring punches the dot out of whatever surface is behind it, which here is the
   dropdown; `.lf-chat-users-list .lf-chat-row.is-active` repeats the source's
   (0,3,0), which would otherwise outrank the generic row rules below. */
.lf-chat-users-list {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}
.lf-chat-users-list .lf-chat-row .lf-chat-dot {
  border-color: var(--lf-theme-panel-bg);
}
.lf-chat-users-list .lf-chat-row.is-active {
  background: rgba(var(--lf-theme-accent-rgb), 0.18);
}
.lf-chat-users-empty {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 62%, transparent);
}

/* .lf-chat-icon-btn is shared by three surfaces. Its majority home (list head,
   thread head, reply bar) is a panel; the title bar and the call pill get the
   two contextual (0,2,0)/(0,2,1) rules below, and the pressed state must stay
   AFTER them or a toggled maximize/pin would lose its fill. chat.css:214/223. */
.lf-chat-icon-btn {
  color: var(--lf-theme-panel-fg);
}
.lf-chat-icon-btn:hover {
  background: rgba(var(--lf-theme-accent-rgb), 0.14);
  color: var(--lf-theme-panel-fg);
}
.lf-chat-titlebar .lf-chat-icon-btn {
  color: var(--lf-theme-column-header-fg);
}
.lf-chat-titlebar .lf-chat-icon-btn:hover {
  background: color-mix(in srgb, var(--lf-theme-column-header-fg) 18%, transparent);
  color: var(--lf-theme-column-header-fg);
}
/* A pressed toggle is an active state → accent chip (chat.css:133-134). */
.lf-chat-icon-btn.is-on {
  background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}
.lf-chat-icon-btn.is-on:hover {
  background: color-mix(in srgb, var(--lf-theme-accent) 72%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}

/* Conversation sidebar: the recessed strip behind the thread (chat.css:189-249). */
.lf-chat-list {
  background: var(--lf-theme-body-bg);
  color: var(--lf-theme-body-fg);
  border-right-color: var(--lf-theme-panel-border);
}
.lf-chat-list-head h2 {
  color: var(--lf-theme-body-fg);
}
/* A raised field on that strip → panel. Its typed text used to inherit the
   muted grey the wrapper sets for the magnifier icon, which is barely readable
   on a dark panel. */
.lf-chat-search {
  background: var(--lf-theme-panel-bg);
  border-color: var(--lf-theme-panel-border);
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 62%, transparent);
}
.lf-chat-search input {
  color: var(--lf-theme-panel-fg);
}
.lf-chat-search input::placeholder {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 58%, transparent);
}
.lf-chat-online-label {
  color: color-mix(in srgb, var(--lf-theme-body-fg) 62%, transparent);
}

/* chat.css:272-273 gives hover and selection the same flat #e9ecef; splitting
   the wash makes the open conversation distinguishable from the hovered one,
   and an alpha wash works on the sidebar and inside the users dropdown alike. */
.lf-chat-row:hover {
  background: rgba(var(--lf-theme-accent-rgb), 0.10);
}
.lf-chat-row.is-active {
  background: rgba(var(--lf-theme-accent-rgb), 0.18);
}

/* A filled chip carrying initials is the same role as a column strip — and
   column-header-bg/fg is close to the original #5a6268/#fff to begin with. The
   group variant was a blue-shifted version of it; mixing the accent in
   reproduces that shift in the theme's own hue. The presence ring punches the
   dot out of the sidebar behind it; `.lf-chat-dot.on` keeps its green, because
   presence is a status and the accent is already the unread colour two elements
   away. chat.css:279-298. */
.lf-chat-avatar {
  background: var(--lf-theme-column-header-bg);
  color: var(--lf-theme-column-header-fg);
}
.lf-chat-avatar.is-group {
  background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
}
.lf-chat-avatar.is-assistant {
  background: color-mix(in srgb, var(--lf-theme-accent) 75%, var(--lf-theme-body-fg));
}
.lf-chat-avatar .lf-chat-dot {
  background: color-mix(in srgb, var(--lf-theme-body-fg) 38%, var(--lf-theme-body-bg));
  border-color: var(--lf-theme-body-bg);
}
.lf-chat-row-preview {
  color: color-mix(in srgb, var(--lf-theme-body-fg) 62%, transparent);
}
.lf-chat-unread {
  background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}

/* Thread column and its muted metadata (chat.css:335-357, :376, :424). */
.lf-chat-thread {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
}
.lf-chat-thread-head {
  border-bottom-color: var(--lf-theme-panel-border);
}
.lf-chat-thread-sub,
.lf-chat-day,
.lf-chat-typing {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 62%, transparent);
}
.lf-chat-empty {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 58%, transparent);
}
/* The message canvas was never a colour of its own, just a barely-there step
   off the panel (chat.css:370) — as a tint it recedes on light themes and lifts
   on dark ones, so "theirs" bubbles stay distinguishable from it either way. */
.lf-chat-messages {
  background: linear-gradient(
    color-mix(in srgb, var(--lf-theme-panel-fg) 4%, var(--lf-theme-panel-bg)),
    color-mix(in srgb, var(--lf-theme-panel-fg) 8%, var(--lf-theme-panel-bg))
  );
}

/* My own message is the accent's natural home → accent chip; the other
   person's stays a pure panel surface one step above the tinted canvas, exactly
   as #fff sat above #f4f6f8. chat.css:391-407. */
.lf-chat-bubble.mine {
  background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}
.lf-chat-bubble.theirs {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}
.lf-chat-bubble.system {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 62%, transparent);
}
/* Inside my bubble the ground is already the accent, so an accent quote bar
   would vanish there; currentColor is whatever that bubble's own text is. In
   the other person's bubble (0,3,0) it goes back to the accent. chat.css:415. */
.lf-chat-quote {
  border-left-color: color-mix(in srgb, currentColor 60%, transparent);
}
.lf-chat-bubble.theirs .lf-chat-quote {
  border-left-color: rgba(var(--lf-theme-accent-rgb), 0.7);
}

/* Reply strip and composer (chat.css:435-469). The textarea and the dialog
   field below declare no colours at all, so on a dark theme they fall back to
   the browser's white box with black text inside a dark panel — a real bug,
   not just an untinted surface. Send is the panel's primary action, so it
   shares my-bubble's accent chip. */
.lf-chat-reply {
  background: color-mix(in srgb, var(--lf-theme-panel-fg) 6%, var(--lf-theme-panel-bg));
  color: var(--lf-theme-panel-fg);
  border-top-color: var(--lf-theme-panel-border);
}
.lf-chat-reply-body {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 62%, transparent);
}
.lf-chat-composer {
  background: var(--lf-theme-panel-bg);
  border-top-color: var(--lf-theme-panel-border);
}
.lf-chat-composer textarea {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}
.lf-chat-composer textarea::placeholder {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 58%, transparent);
}
.lf-chat-composer textarea:focus {
  border-color: var(--lf-theme-accent);
  box-shadow: 0 0 0 2px rgba(var(--lf-theme-accent-rgb), 0.25);
}
.lf-chat-send {
  background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}
.lf-chat-send:hover {
  background: color-mix(in srgb, var(--lf-theme-accent) 72%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}

/* Message "more" popup — a floating menu, same role the .lf-popup-menu rules
   above cover, but chat-local so it needs its own copy. chat.css:481 sets no
   colour and <button> does not inherit one, so items were painted with the UA's
   near-black on what is now a themed panel. */
.lf-chat-menu {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}
.lf-chat-menu button {
  color: var(--lf-theme-panel-fg);
}
.lf-chat-menu button:hover {
  background: rgba(var(--lf-theme-accent-rgb), 0.14);
}

/* Call and dialog surfaces. The active-call pill is transient status chrome
   floating over the app → footer pair (chat.css:547; its #212529/#f8f9fa was
   the light header pair frozen, but footer keeps the pill readable on sunset,
   where header-fg on header-bg is only 2.8:1). Its muted-mic button keeps
   chat.css:568's red, restated here with white so the glyph does not follow a
   dark footer foreground onto it. */
.lf-chat-incoming-card,
.lf-chat-dialog-card {
  background: var(--lf-theme-popup-bg);
  color: var(--lf-theme-popup-fg);
  border-color: var(--lf-theme-popup-border);
}
.lf-chat-active-call {
  background: var(--lf-theme-footer-bg);
  color: var(--lf-theme-footer-fg);
}
.lf-chat-active-call .lf-chat-icon-btn {
  color: var(--lf-theme-footer-fg);
}
.lf-chat-active-call .lf-chat-icon-btn:hover {
  background: color-mix(in srgb, var(--lf-theme-footer-fg) 18%, transparent);
  color: var(--lf-theme-footer-fg);
}
.lf-chat-active-call .lf-chat-icon-btn.is-on {
  color: #fff;
}
.lf-chat-field input {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}
.lf-chat-group-picks {
  border-color: var(--lf-theme-panel-border);
}


/* ── Notifications & toasts ───────────────────────────────────────────────
   The bell badge is an unread COUNT — severity lives separately on
   .lf-notif-sev-* — so it takes the accent chip, the same treatment as the
   chat's unread pill and the documents badge, and it stays distinct from the
   app bar in every theme (sunset included, where a raw accent badge would be
   the bar's own colour). The chat toggle's badge is the same kind of counter
   and moves with it, so the two never disagree. The list body sits inside
   .lf-shell-panel (NotificationsDockable); the shell title bar is already
   themed as a column-header strip — the mark-all toolbar under it is panel
   chrome, not a second header.

   Severity is NOT themed: notification.css green/amber/red and the
   success/warning/error toasts keep their values — the last three are restated
   here only because they are (0,1,0) and earlier in the cascade, so the themed
   base rule would otherwise repaint them. Only "info" follows the theme; its
   #0d6efd was never semantic, it is the default accent verbatim. */

.lf-notif-badge,
.lf-chat-badge {
  background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}

.lf-notif {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
}
.lf-notif-toolbar {
  border-bottom-color: color-mix(in srgb, var(--lf-theme-panel-border) 55%, transparent);
}
/* Mark-all is a secondary action on the panel surface — accent, not column-header
   foreground (that pairing was for when it sat on the old title strip). */
.lf-notif-mark-all {
  color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
}
.lf-notif-mark-all:hover {
  color: var(--lf-theme-accent);
}

/* #f4f8ff is literally a 4% wash of the default accent over white, so unread is
   an accent tint and must track the accent. The hover rules are new; both are
   (0,2,0), so `.lf-notif-item-unread:hover` has to stay last or an unread row
   would lose its stronger wash the moment it is hovered. */
.lf-notif-item {
  border-bottom-color: color-mix(in srgb, var(--lf-theme-panel-border) 55%, transparent);
}
.lf-notif-item-unread {
  background: rgba(var(--lf-theme-accent-rgb), 0.10);
}
.lf-notif-item:hover {
  background: rgba(var(--lf-theme-accent-rgb), 0.06);
}
.lf-notif-item-unread:hover {
  background: rgba(var(--lf-theme-accent-rgb), 0.18);
}
.lf-notif-sev-info {
  color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
}
/* Both hardcoded greys are just the panel's own text lightened over white. */
.lf-notif-item-body {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 78%, transparent);
}
.lf-notif-item-time {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 55%, transparent);
}

/* Row buttons are small surfaces on the panel. `-danger` is restated with its
   own red ON PURPOSE: it is (0,1,0) like the themed base and earlier in the
   cascade, so without this line the theme would silently swallow the
   destructive colour. No :hover is added, for the same reason — a (0,2,0) hover
   would beat that (0,1,0) border. */
.lf-notif-action {
  background: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}
.lf-notif-action-primary {
  border-color: var(--lf-theme-accent);
  color: color-mix(in srgb, var(--lf-theme-accent) 70%, var(--lf-theme-panel-fg));
}
.lf-notif-action-danger {
  border-color: #dc3545;
  color: #dc3545;
}

/* The quietest text on the panel. Dismiss darkens to full panel-fg rather than
   turning accent: it is destructive-ish and must not read as the primary
   affordance. */
.lf-notif-item-dismiss {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 45%, transparent);
}
.lf-notif-item-dismiss:hover {
  color: var(--lf-theme-panel-fg);
}
.lf-notif-empty {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 50%, transparent);
}

/* A toast is transient status feedback floating over the app → the footer, the
   theme's own status-bar pair. (Its hardcoded #212529/#fff is the light header
   pair, but header on sunset is white-on-#ff6b6b at 2.8:1, while every theme's
   footer pair clears 5.8:1.) */
.lf-toast {
  background: var(--lf-theme-footer-bg);
  color: var(--lf-theme-footer-fg);
}
/* MUST stay after .lf-toast — see the note above. `color: #fff` is added
   because these used to borrow it from .lf-toast, and a theme whose status-bar
   foreground is dark (sunset's #3b1f1f) would now put dark text on these dark
   slabs. */
.lf-toast-success { background: #146c43; color: #fff; }
.lf-toast-warning { background: #b25e09; color: #fff; }
.lf-toast-error   { background: #b02a37; color: #fff; }
.lf-toast-info {
  background: color-mix(in srgb, var(--lf-theme-accent) 55%, var(--lf-theme-column-header-bg));
  color: var(--lf-theme-column-header-fg);
}
/* The close "×" has to read on five different slabs — themed neutral, themed
   info and three fixed semantic ones — so the only correct value is whatever
   foreground its own toast ended up with. The :hover rule is required, not
   cosmetic: toast.css:47 hardcodes #fff at (0,2,0). */
.lf-toast-close { color: inherit; opacity: 0.8; }
.lf-toast-close:hover { color: inherit; opacity: 1; }


/* ══════════════════════════════════════════════════════════════════════════
   THE FAMILIES ADDED WITH `--lf-theme-toolbar-*`, `-editor-*`, `-view-bg`,
   `-field-*` AND `-recordstate-*`

   Same discipline as everything above: colour, background and border-colour
   only. What is new here is the SCOPING rule, and it is load-bearing —
   `.form-control` and `.form-select` are Bootstrap utilities used by the app
   bar's own search box as much as by a record's fields, and `.lf-menu-search`
   (theme.css:227) themes that one to the HEADER pair at the same (0,1,0) this
   file would reach it with. So every field rule below is anchored to a
   container that only ever holds record fields — the section card, the modal
   body, a rendered form — landing at (0,2,0) and leaving the header alone.
   The two floating editors are matched by their own class instead: they are
   `position: fixed` children of <body>, so no container selector can reach
   them.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── The function bar at the top of a view ────────────────────────────────
   `.section-toolbar-row` (section.css:577) had no ground of its own and read
   as part of the card; the tree/composite/detail strips each had a different
   hand-picked one. All of them are the same object — the row of commands that
   acts on what is below it — so all of them take the one pair the user picks. */
.section-toolbar-row,
.composite-page-toolbar {
  background: var(--lf-theme-toolbar-bg);
  border-color: var(--lf-theme-toolbar-border);
  color: var(--lf-theme-toolbar-fg);
}

/* The function bar's own overflow menu, on the other hand, belongs to the panel
   it sits on, like the bar around it. */
.section-toolbar-row .lf-tb-overflow-panel {
  background: var(--lf-theme-toolbar-bg);
  border-color: var(--lf-theme-toolbar-border);
  color: var(--lf-theme-toolbar-fg);
}

/* The title and the page info are drawn from the toolbar's own foreground now
   that the strip has one, instead of from the panel's (theme.css:559-568).
   The three-level hierarchy is preserved exactly. */
.section-toolbar-title {
  color: color-mix(in srgb, var(--lf-theme-toolbar-fg) 80%, var(--lf-theme-toolbar-bg));
}
.section-page-info {
  color: color-mix(in srgb, var(--lf-theme-toolbar-fg) 60%, var(--lf-theme-toolbar-bg));
}
.section-page-info-sep,
.section-page-info-rows {
  color: color-mix(in srgb, var(--lf-theme-toolbar-fg) 35%, var(--lf-theme-toolbar-bg));
}

/* Neutral toolbar buttons: same mixes as theme.css:484-491, re-based on the
   strip they actually sit on rather than on the panel behind it. (0,2,0),
   matching the rule they supersede, so source order decides — and this block
   is later in the same file. */
.section-toolbar-row .btn-outline-secondary,
.composite-page-toolbar .btn-outline-secondary {
  --bs-btn-color: color-mix(in srgb, var(--lf-theme-toolbar-fg) 72%, var(--lf-theme-toolbar-bg));
  --bs-btn-border-color: color-mix(in srgb, var(--lf-theme-toolbar-fg) 55%, var(--lf-theme-toolbar-bg));
  --bs-btn-disabled-color: color-mix(in srgb, var(--lf-theme-toolbar-fg) 40%, var(--lf-theme-toolbar-bg));
  --bs-btn-disabled-border-color: color-mix(in srgb, var(--lf-theme-toolbar-fg) 30%, var(--lf-theme-toolbar-bg));
}

/* ── The ground the views are drawn on ────────────────────────────────────
   Bootstrap paints every cell with `--bs-table-bg` and `--bs-table-color`
   (bootstrap.css:1878-1883), so setting the two tokens on the table reaches
   grid, card, list and form views at once — they are all the same <table>
   with a different `.section-view-*` class. Column headers keep their own
   pair: theme.css:80 is (0,1,2) and wins over Bootstrap's (0,1,1). */
.section-grid-table {
  --bs-table-bg: var(--lf-theme-view-bg);
  --bs-table-color: var(--lf-theme-field-fg);
  --bs-table-border-color: var(--lf-theme-panel-border);
}

/* The card and form views build their own boxes inside those cells, so they
   need the ground stated again rather than inherited from a cell they cover.
   section.css:1027, :1114, :1120. */
.section-card,
.section-form-view,
.section-form-view-group {
  background-color: var(--lf-theme-view-bg);
  border-color: var(--lf-theme-panel-border);
  color: var(--lf-theme-field-fg);
}

/* ── Field text, enabled and disabled ─────────────────────────────────────
   Two separate colours rather than one plus an opacity: see the variable
   declarations at the top of this file. `[readonly]` is included with
   `:disabled` deliberately — to the person reading the screen they are the
   same statement ("you cannot type here"), and the framework uses both. */
.section-page-card .form-control,
.section-page-card .form-select,
.section-modal-body .form-control,
.section-modal-body .form-select,
.section-form .form-control,
.section-form .form-select,
.section-form .form-control-plaintext {
  background-color: var(--lf-theme-editor-bg);
  border-color: color-mix(in srgb, var(--lf-theme-field-fg) 25%, var(--lf-theme-editor-bg));
  color: var(--lf-theme-field-fg);
}
.section-page-card .form-control:focus,
.section-page-card .form-select:focus,
.section-modal-body .form-control:focus,
.section-modal-body .form-select:focus,
.section-form .form-control:focus,
.section-form .form-select:focus {
  background-color: var(--lf-theme-editor-bg);
  border-color: var(--lf-theme-editor-border);
  color: var(--lf-theme-editor-fg);
}
.section-page-card .form-control:disabled,
.section-page-card .form-select:disabled,
.section-page-card .form-control[readonly],
.section-modal-body .form-control:disabled,
.section-modal-body .form-select:disabled,
.section-modal-body .form-control[readonly],
.section-form .form-control:disabled,
.section-form .form-select:disabled,
.section-form .form-control[readonly] {
  background-color: var(--lf-theme-field-disabled-bg);
  border-color: color-mix(in srgb, var(--lf-theme-field-disabled-fg) 40%, var(--lf-theme-field-disabled-bg));
  color: var(--lf-theme-field-disabled-fg);
}

/* Values shown as text rather than as a control — the card view's right-hand
   column and the form view's, plus their labels. section.css:1046-1060,
   :1154-:1168, :517. Labels stay one step quieter than the values, which is
   what the hardcoded #6c757d against #212529 was expressing. */
.section-card-value,
.section-form-view-value {
  color: var(--lf-theme-field-fg);
}
.section-card-label,
.section-form-view-label,
.section-form-view-legend,
.section-form label {
  color: color-mix(in srgb, var(--lf-theme-field-fg) 62%, var(--lf-theme-view-bg));
}

/* ── The edit box ─────────────────────────────────────────────────────────
   EditInPlace's floating cell editor (section.css:1828-1867) and FieldEditor's
   overlay (fullEdit.css:75-93). Both hardcoded `--bs-body-bg`/`--bs-primary`,
   i.e. Bootstrap's page colours, which on a dark theme put a white box over a
   dark grid. The "typing, not navigating" amber state (section.css:1865) keeps
   its meaning and takes the record-state "modified" colour, which is the same
   statement made in the same palette. */
.section-eip-editor,
.section-field-editor {
  background: var(--lf-theme-editor-bg);
  color: var(--lf-theme-editor-fg);
}
.section-eip-editor .section-eip-input,
.section-field-editor .section-field-editor-input {
  background: var(--lf-theme-editor-bg);
  border-color: var(--lf-theme-editor-border);
  color: var(--lf-theme-editor-fg);
}
.section-eip-editor .section-eip-input::placeholder,
.section-field-editor .section-field-editor-input::placeholder {
  color: color-mix(in srgb, var(--lf-theme-editor-fg) 55%, var(--lf-theme-editor-bg));
}
.section-eip-editor .section-eip-input:disabled,
.section-field-editor .section-field-editor-input:disabled,
.section-field-editor .section-field-editor-input[readonly] {
  background: var(--lf-theme-field-disabled-bg);
  border-color: color-mix(in srgb, var(--lf-theme-field-disabled-fg) 40%, var(--lf-theme-field-disabled-bg));
  color: var(--lf-theme-field-disabled-fg);
}
.section-eip-editor.section-eip-editor-editing .section-eip-input {
  border-color: var(--lf-theme-recordstate-modified);
}
/* Foreign-key cell overlay. section.css paints it with --bs-body-bg, and even
   after that token is re-pointed the compound has to be restated here so the
   editor pair — not the page pair — is what the user is typing into. */
.section-eip-fk {
  background: var(--lf-theme-editor-bg);
  color: var(--lf-theme-editor-fg);
  border-color: var(--lf-theme-editor-border);
}
.section-eip-fk-text {
  color: var(--lf-theme-editor-fg);
}

/* ── The field that would not commit ──────────────────────────────────────
   fullEdit.css draws the shape (a one-pixel outline); the colours are the
   user's. Three of them rather than the outline alone, because the outline
   alone is a hairline a dark theme swallows — the wash is what makes the cell
   findable in a grid, and it needs a text colour chosen to sit on it.

   Below the field-colour rules above on purpose: the mark goes on the CELL
   (.section-card-value, .section-form-view-value, a grid <td>), which those
   reach at the same (0,1,0), so order is what decides and the marked state has
   to be the later one. The `.form-control` rules are (0,2,0) but describe the
   editor's input, which is a different element. */
.section-field-error {
  background: var(--lf-theme-invalid-field-bg);
  color: var(--lf-theme-invalid-field-fg);
  outline-color: var(--lf-theme-invalid-field-border);
}

/* The cell the keyboard is on, before it becomes an editor (section.css:1823).
   FullEdit's own cursor (issue #112) is the same idea in the other editor, so
   it takes the same themed colour. */
.section-eip-cell-current,
.section-field-cell-current,
.section-field-cell-current:focus,
.section-field-cell-current:focus-visible {
  outline-color: var(--lf-theme-editor-border);
}

/* ── Record-state flag ────────────────────────────────────────────────────
   A wash carrying a full-strength dot, not a solid fill: recordState.ts used
   to hand the badge Bootstrap's `.text-bg-success|warning|danger`, whose text
   colour is `!important` and fixed (#fff, #000, #fff) — so a user picking
   their own three colours would have had a one-in-three chance of legible
   text. With the wash, the label is always the panel's own foreground and only
   the dot and the tint carry the colour, so ANY three choices stay readable.
   recordState.ts now emits the `lf-recordstate-*` classes below instead. */
.badge.lf-recordstate-read,
.badge.lf-recordstate-new,
.badge.lf-recordstate-modified {
  color: var(--lf-theme-panel-fg);
}
.badge.lf-recordstate-read {
  background-color: color-mix(in srgb, var(--lf-theme-recordstate-read) 20%, var(--lf-theme-panel-bg));
}
.badge.lf-recordstate-new {
  background-color: color-mix(in srgb, var(--lf-theme-recordstate-new) 20%, var(--lf-theme-panel-bg));
}
.badge.lf-recordstate-modified {
  background-color: color-mix(in srgb, var(--lf-theme-recordstate-modified) 20%, var(--lf-theme-panel-bg));
}
/* The row says it too (issue #335 F3): applied by recordSave.ts's syncRowStates() to the rows of
   a grid, the cards, the kanban cards and the form, from the same model as the badge. The cell
   rules are as specific as the table's own striping so the wash wins over it. */
.section-row.section-row-modified,
.section-row.section-row-modified > td,
.section-kanban-card.section-row-modified,
.section-card.section-row-modified {
  --bs-table-bg: var(--lf-theme-recordstate-modified-bg);
  --bs-table-accent-bg: transparent;
  background-color: var(--lf-theme-recordstate-modified-bg);
  color: var(--lf-theme-recordstate-modified-fg);
}
.section-row.section-full-edit-new,
.section-row.section-full-edit-new > td,
.section-kanban-card.section-full-edit-new,
.section-card.section-full-edit-new {
  --bs-table-bg: var(--lf-theme-recordstate-new-bg);
  --bs-table-accent-bg: transparent;
  background-color: var(--lf-theme-recordstate-new-bg);
  color: var(--lf-theme-recordstate-new-fg);
}

.lf-recordstate-read .section-toolbar-recordstate-dot,
.lf-recordstate-read .section-modal-recordstate-dot {
  color: var(--lf-theme-recordstate-read);
}
.lf-recordstate-new .section-toolbar-recordstate-dot,
.lf-recordstate-new .section-modal-recordstate-dot {
  color: var(--lf-theme-recordstate-new);
}
.lf-recordstate-modified .section-toolbar-recordstate-dot,
.lf-recordstate-modified .section-modal-recordstate-dot {
  color: var(--lf-theme-recordstate-modified);
}

/* The same three states said a second way, around the detail dialog and around
   each changed field (section.css:1774-1798). They were `--bs-warning` and
   `--bs-success` — the record-state palette is where they belong. */
.section-modal-dialog.section-modal-editing .modal-content {
  box-shadow: 0 0 0 2px var(--lf-theme-recordstate-modified);
}
.section-modal-dialog.section-modal-creating .modal-content {
  box-shadow: 0 0 0 2px var(--lf-theme-recordstate-new);
}
.section-field-dirty .form-control,
.section-field-dirty .form-select,
.section-field-dirty textarea.form-control {
  border-color: var(--lf-theme-recordstate-modified);
  box-shadow: 0 0 0 .12rem color-mix(in srgb, var(--lf-theme-recordstate-modified) 25%, transparent);
}
.section-field-dirty .form-label::after,
.section-modal-dirty .section-modal-recid::after {
  color: var(--lf-theme-recordstate-modified);
}

/* `.text-muted` is Bootstrap's own utility for secondary text and is fixed at #6c757d
   (bootstrap.css `--bs-secondary-color`), which is 2.0:1 on Dark's #15181c — the framework
   uses it for every help line and intro paragraph, including the two this page added, so on
   three of the six shipped themes those were barely readable. `!important` is not a choice
   here: the utility declares it, so nothing else can reach it. Colour only, as everywhere. */
:where(html.lf-shell, .lf-mount, .lf-scope) .text-muted {
  color: color-mix(in srgb, var(--lf-theme-body-fg) 62%, transparent) !important;
}

/* ── Popups, tabs, cards, forms, leftover Bootstrap whites ──────────────────
   The families `--lf-theme-popup-*` and `--lf-theme-tab-*` exist so a user can
   pick them. Everything below is the mapping those names were added for, plus
   the Bootstrap surfaces that were still reading --bs-body-bg / #fff after the
   rest of the shell had followed the theme: the application menu, seed
   settings card, account dialog, HTTP log, nav-tabs, form-select, .bg-white.

   Colour, background and border-colour only, same as the rest of this file. */

/* Dialogs (core/dialog.ts builds `modal dialog-modal` + `.modal-content`) and
   every other Bootstrap modal, including the section detail dialog. */
:where(html.lf-shell, .lf-mount, .lf-scope) .modal {
  --bs-modal-color: var(--lf-theme-popup-fg);
  --bs-modal-bg: var(--lf-theme-popup-bg);
  --bs-modal-border-color: var(--lf-theme-popup-border);
  --bs-modal-header-border-color: var(--lf-theme-popup-border);
  --bs-modal-footer-border-color: var(--lf-theme-popup-border);
  --bs-modal-footer-bg: var(--lf-theme-popup-bg);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .modal-content,
.dialog-modal .modal-content {
  background-color: var(--lf-theme-popup-bg);
  color: var(--lf-theme-popup-fg);
  border-color: var(--lf-theme-popup-border);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .modal-header,
.dialog-header {
  background-color: var(--lf-theme-popup-header-bg);
  color: var(--lf-theme-popup-header-fg);
  border-bottom-color: var(--lf-theme-popup-border);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .modal-title,
.dialog-header .modal-title {
  color: var(--lf-theme-popup-header-fg);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .modal-footer,
.dialog-footer {
  background-color: var(--lf-theme-popup-bg);
  color: var(--lf-theme-popup-fg);
  border-top-color: var(--lf-theme-popup-border);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .modal-body,
.dialog-body {
  color: var(--lf-theme-popup-fg);
}

/* Close × is a black SVG. Masking it with the header foreground is the only
   pairing that reads on both a white Light popup and a charcoal Dark one;
   Bootstrap's `.btn-close-white` filter is a Dark-only switch. */
:where(html.lf-shell, .lf-mount, .lf-scope) .btn-close {
  background-color: var(--lf-theme-popup-header-fg);
  background-image: none;
  opacity: 0.65;
  -webkit-mask: var(--bs-btn-close-bg) center / 1em auto no-repeat;
  mask: var(--bs-btn-close-bg) center / 1em auto no-repeat;
}
:where(html.lf-shell, .lf-mount, .lf-scope) .btn-close:hover {
  opacity: 0.9;
}

.footer-http-table {
  --bs-table-bg: var(--lf-theme-popup-bg);
  --bs-table-color: var(--lf-theme-popup-fg);
  --bs-table-border-color: var(--lf-theme-popup-border);
  --bs-table-striped-bg: color-mix(in srgb, var(--lf-theme-popup-fg) 6%, var(--lf-theme-popup-bg));
  color: var(--lf-theme-popup-fg);
}

/* Tabs: seed, batch, theme page, composite pages, lf-tabset. Inactive on the
   page colour, active on the panel — the pane underneath is a panel, so the
   selected tab has to be the same ground or it reads as a hole. */
:where(html.lf-shell, .lf-mount, .lf-scope) .nav-tabs {
  --bs-nav-tabs-border-color: var(--lf-theme-tab-border);
  --bs-nav-tabs-link-hover-border-color: var(--lf-theme-tab-border) var(--lf-theme-tab-border) var(--lf-theme-tab-border);
  --bs-nav-tabs-link-active-color: var(--lf-theme-tab-active-fg);
  --bs-nav-tabs-link-active-bg: var(--lf-theme-tab-active-bg);
  --bs-nav-tabs-link-active-border-color: var(--lf-theme-tab-border) var(--lf-theme-tab-border) var(--lf-theme-tab-active-bg);
  border-bottom-color: var(--lf-theme-tab-border);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .nav-tabs .nav-link {
  color: var(--lf-theme-tab-fg);
  background-color: var(--lf-theme-tab-bg);
  border-color: transparent;
}
:where(html.lf-shell, .lf-mount, .lf-scope) .nav-tabs .nav-link:hover,
:where(html.lf-shell, .lf-mount, .lf-scope) .nav-tabs .nav-link:focus {
  color: var(--lf-theme-tab-active-fg);
  isolation: isolate;
  border-color: var(--lf-theme-tab-border) var(--lf-theme-tab-border) var(--lf-theme-tab-border);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .nav-tabs .nav-link.active,
:where(html.lf-shell, .lf-mount, .lf-scope) .nav-tabs .nav-item.show .nav-link {
  color: var(--lf-theme-tab-active-fg);
  background-color: var(--lf-theme-tab-active-bg);
  border-color: var(--lf-theme-tab-border) var(--lf-theme-tab-border) var(--lf-theme-tab-active-bg);
}

/* lf-tabset restates the four-side active border against these names rather
   than Bootstrap's, so a tab on the bottom/left/right edge still meets its pane. */
.lf-tabset-bottom .lf-tabset-viewport > .nav-tabs .nav-link.active {
  border-color: var(--lf-theme-tab-active-bg) var(--lf-theme-tab-border) var(--lf-theme-tab-border);
}
.lf-tabset-left .lf-tabset-viewport > .nav-tabs .nav-link.active {
  border-color: var(--lf-theme-tab-border) var(--lf-theme-tab-active-bg) var(--lf-theme-tab-border) var(--lf-theme-tab-border);
}
.lf-tabset-right .lf-tabset-viewport > .nav-tabs .nav-link.active {
  border-color: var(--lf-theme-tab-border) var(--lf-theme-tab-border) var(--lf-theme-tab-border) var(--lf-theme-tab-active-bg);
}

/* Cards. site.css used to paint every .card #f8f9fa, which is why the seed
   settings card stayed a white island on Dark. */
:where(html.lf-shell, .lf-mount, .lf-scope) .card {
  --bs-card-bg: var(--lf-theme-panel-bg);
  --bs-card-color: var(--lf-theme-panel-fg);
  --bs-card-border-color: var(--lf-theme-panel-border);
  --bs-card-cap-bg: color-mix(in srgb, var(--lf-theme-panel-fg) 6%, var(--lf-theme-panel-bg));
  --bs-card-cap-color: var(--lf-theme-panel-fg);
  background-color: var(--lf-theme-panel-bg);
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .card-header,
:where(html.lf-shell, .lf-mount, .lf-scope) .card-footer {
  background-color: color-mix(in srgb, var(--lf-theme-panel-fg) 6%, var(--lf-theme-panel-bg));
  color: var(--lf-theme-panel-fg);
  border-color: var(--lf-theme-panel-border);
}

/* Form controls that do not live inside a section card — seed's database
   select, the AppMenu filter, dialog prompts, setup fields. The header search
   box is excluded: it is chrome and already takes the top-bar pair. */
:where(html.lf-shell, .lf-mount, .lf-scope) .form-control:not(.lf-menu-search),
:where(html.lf-shell, .lf-mount, .lf-scope) .form-select {
  background-color: var(--lf-theme-editor-bg);
  color: var(--lf-theme-editor-fg);
  border-color: color-mix(in srgb, var(--lf-theme-field-fg) 25%, var(--lf-theme-editor-bg));
}
:where(html.lf-shell, .lf-mount, .lf-scope) .form-control:not(.lf-menu-search):focus,
:where(html.lf-shell, .lf-mount, .lf-scope) .form-select:focus {
  background-color: var(--lf-theme-editor-bg);
  color: var(--lf-theme-editor-fg);
  border-color: var(--lf-theme-editor-border);
  box-shadow: 0 0 0 0.2rem rgba(var(--lf-theme-accent-rgb), 0.25);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .form-control:not(.lf-menu-search)::placeholder {
  color: color-mix(in srgb, var(--lf-theme-editor-fg) 55%, var(--lf-theme-editor-bg));
}
:where(html.lf-shell, .lf-mount, .lf-scope) .form-label {
  color: var(--lf-theme-panel-fg);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .form-check-input {
  background-color: var(--lf-theme-editor-bg);
  border-color: color-mix(in srgb, var(--lf-theme-field-fg) 40%, var(--lf-theme-editor-bg));
}
:where(html.lf-shell, .lf-mount, .lf-scope) .form-check-input:checked {
  background-color: var(--lf-theme-accent);
  border-color: var(--lf-theme-accent);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .form-check-label {
  color: var(--lf-theme-panel-fg);
}

/* Quiet status strips (seed "no job running", walkthrough empty). Semantic
   success/warning/danger alerts keep their meaning. */
:where(html.lf-shell, .lf-mount, .lf-scope) .alert-secondary,
:where(html.lf-shell, .lf-mount, .lf-scope) .alert-light {
  --bs-alert-color: var(--lf-theme-panel-fg);
  --bs-alert-bg: color-mix(in srgb, var(--lf-theme-panel-fg) 8%, var(--lf-theme-panel-bg));
  --bs-alert-border-color: var(--lf-theme-panel-border);
}

:where(html.lf-shell, .lf-mount, .lf-scope) .list-group {
  --bs-list-group-color: var(--lf-theme-panel-fg);
  --bs-list-group-bg: var(--lf-theme-panel-bg);
  --bs-list-group-border-color: var(--lf-theme-panel-border);
}

/* Bootstrap utilities that freeze a surface to white/grey with !important.
   Same specificity, later in the cascade, so AppMenu's old `bg-white` and the
   batch payload `bg-light` follow the theme even if markup still carries them. */
:where(html.lf-shell, .lf-mount, .lf-scope) .bg-white,
:where(html.lf-shell, .lf-mount, .lf-scope) .bg-light,
:where(html.lf-shell, .lf-mount, .lf-scope) .text-bg-light {
  background-color: var(--lf-theme-panel-bg) !important;
}

/* Filled primary used to be a frozen #6c757d (site.css). The column-header
   pair is that same grey-on-white under Light and a readable filled strip on
   every other theme. */
:where(html.lf-shell, .lf-mount, .lf-scope) .btn-primary {
  --bs-btn-bg: var(--lf-theme-column-header-bg);
  --bs-btn-border-color: var(--lf-theme-column-header-bg);
  --bs-btn-color: var(--lf-theme-column-header-fg);
  --bs-btn-hover-bg: color-mix(in srgb, var(--lf-theme-column-header-bg) 86%, var(--lf-theme-column-header-fg));
  --bs-btn-hover-border-color: color-mix(in srgb, var(--lf-theme-column-header-bg) 86%, var(--lf-theme-column-header-fg));
  --bs-btn-hover-color: var(--lf-theme-column-header-fg);
  --bs-btn-active-bg: color-mix(in srgb, var(--lf-theme-column-header-bg) 78%, var(--lf-theme-column-header-fg));
  --bs-btn-active-border-color: color-mix(in srgb, var(--lf-theme-column-header-bg) 78%, var(--lf-theme-column-header-fg));
  --bs-btn-active-color: var(--lf-theme-column-header-fg);
  --bs-btn-disabled-bg: var(--lf-theme-column-header-bg);
  --bs-btn-disabled-border-color: var(--lf-theme-column-header-bg);
  --bs-btn-disabled-color: var(--lf-theme-column-header-fg);
  background-color: var(--lf-theme-column-header-bg);
  border-color: var(--lf-theme-column-header-bg);
  color: var(--lf-theme-column-header-fg);
}

:where(html.lf-shell, .lf-mount, .lf-scope) .pagination .page-link {
  color: var(--lf-theme-panel-fg);
  background-color: var(--lf-theme-panel-bg);
  border-color: var(--lf-theme-panel-border);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .pagination .page-item.active .page-link {
  background-color: var(--lf-theme-column-header-bg);
  border-color: var(--lf-theme-column-header-bg);
  color: var(--lf-theme-column-header-fg);
}
:where(html.lf-shell, .lf-mount, .lf-scope) .pagination .page-item.disabled .page-link {
  color: color-mix(in srgb, var(--lf-theme-panel-fg) 45%, var(--lf-theme-panel-bg));
  background-color: var(--lf-theme-panel-bg);
  border-color: var(--lf-theme-panel-border);
}

/* ── Progress bars (issue #152) ──────────────────────────────────────────────
   One markup contract, seven looks. The page that renders progress — the seed,
   the batch console, an import pipeline — writes this and nothing else:

     <div class="lf-progress" role="progressbar" aria-valuenow="42"
          aria-valuemin="0" aria-valuemax="100" style="--lf-progress-value:42">
       <div class="lf-progress-track"><div class="lf-progress-fill"></div></div>
       <span class="lf-progress-label">42%</span>
       <span class="lf-progress-label lf-progress-label-fill" aria-hidden="true">42%</span>
     </div>

   and never names a shape or a colour. Which of the seven is drawn is
   `data-lf-progress` on <html>, written server-side by _LiveLayout.cshtml from
   the user's cookie (Theming/ProgressBarStyle.cs) and rewritten live by
   core/progressStyle.ts. That is the whole reason `ring` — which is not a bar at
   all — can exist without a single caller knowing about it.

   THE TWO LABELS. A percentage centred over the track lies half on the fill and
   half on the empty part, and one colour cannot read on both. So the label is
   written twice: the plain one takes the track colour, the copy takes the fill
   colour and is clipped to exactly the fill's width. The copy is aria-hidden —
   it is the same text, and a screen reader is owed one of it. */

.lf-progress {
  --lf-progress-value: 0;
  --lf-progress-height: 1.5rem;
  --lf-progress-radius: .375rem;
  position: relative;
  width: 100%;
}

.lf-progress-track {
  position: relative;
  overflow: hidden;
  height: var(--lf-progress-height);
  border-radius: var(--lf-progress-radius);
  background-color: var(--lf-theme-progress-track-bg);
}

.lf-progress-fill {
  height: 100%;
  width: calc(var(--lf-progress-value) * 1%);
  background-color: var(--lf-theme-progress-fill);
  /* The bar catches up with the number rather than jumping to it. Progress only
     ever moves one way, so there is nothing here to look wrong in reverse. */
  transition: width .25s linear;
}

.lf-progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1;
  color: var(--lf-theme-progress-track-fg);
  pointer-events: none;
}

/* The copy that lies on the fill: same box, same text, cut off exactly where the
   fill ends. `inset()` from the right by the empty remainder — no measuring, and
   no second copy of the geometry. */
.lf-progress-label-fill {
  color: var(--lf-theme-progress-fill-fg);
  clip-path: inset(0 calc(100% - var(--lf-progress-value) * 1%) 0 0);
}

/* ── Striped, still and moving ─────────────────────────────────────────────
   The stripe is the fill's own text colour at low opacity rather than white:
   white over a pale fill on a light theme is a stripe nobody can see. */
[data-lf-progress="striped"] .lf-progress-fill,
[data-lf-progress="striped-animated"] .lf-progress-fill {
  background-image: linear-gradient(45deg,
    color-mix(in srgb, var(--lf-theme-progress-fill-fg) 18%, transparent) 25%,
    transparent 25%, transparent 50%,
    color-mix(in srgb, var(--lf-theme-progress-fill-fg) 18%, transparent) 50%,
    color-mix(in srgb, var(--lf-theme-progress-fill-fg) 18%, transparent) 75%,
    transparent 75%, transparent);
  background-size: 1rem 1rem;
}

[data-lf-progress="striped-animated"] .lf-progress-fill {
  animation: lf-progress-stripes 1s linear infinite;
}

@keyframes lf-progress-stripes {
  from { background-position: 1rem 0; }
  to { background-position: 0 0; }
}

/* ── Gradient ──────────────────────────────────────────────────────────────
   Across the fill, not across the track: the sweep compresses as the bar grows,
   which reads as the head of the bar staying bright while the tail settles. */
[data-lf-progress="gradient"] .lf-progress-fill {
  background-image: linear-gradient(to right,
    color-mix(in srgb, var(--lf-theme-progress-fill) 70%, var(--lf-theme-progress-track-bg)),
    var(--lf-theme-progress-fill));
}

/* ── Segmented ─────────────────────────────────────────────────────────────
   The notches are cut out of the TRACK, so they go through the fill and the
   empty part alike and the page shows between the blocks — an installer's
   counter, where progress is read off instead of estimated. */
[data-lf-progress="segmented"] .lf-progress {
  --lf-progress-radius: .2rem;
}

[data-lf-progress="segmented"] .lf-progress-track {
  --lf-progress-segment: 1.35rem;
  --lf-progress-gap: .22rem;
  -webkit-mask-image: repeating-linear-gradient(to right,
    #000 0 calc(var(--lf-progress-segment) - var(--lf-progress-gap)),
    transparent calc(var(--lf-progress-segment) - var(--lf-progress-gap)),
    transparent var(--lf-progress-segment));
  mask-image: repeating-linear-gradient(to right,
    #000 0 calc(var(--lf-progress-segment) - var(--lf-progress-gap)),
    transparent calc(var(--lf-progress-segment) - var(--lf-progress-gap)),
    transparent var(--lf-progress-segment));
}

[data-lf-progress="segmented"] .lf-progress-fill {
  /* Blocks light up whole: sliding a segment half-on claims a precision the
     shape has already given up. */
  transition: none;
}

/* ── Minimal ───────────────────────────────────────────────────────────────
   A rule, with the percentage beside it as ordinary text. The label leaves the
   track, so the clipped copy has nothing to lie on and goes. */
[data-lf-progress="minimal"] .lf-progress {
  display: flex;
  align-items: center;
  gap: .5rem;
}

[data-lf-progress="minimal"] .lf-progress-track {
  flex: 1 1 auto;
  height: .25rem;
  border-radius: .125rem;
}

[data-lf-progress="minimal"] .lf-progress-label {
  position: static;
  flex: 0 0 auto;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

[data-lf-progress="minimal"] .lf-progress-label-fill {
  display: none;
}

/* ── Ring ──────────────────────────────────────────────────────────────────
   The compact shape, for a surface with no room for a full-width bar. The
   sweep is a conic gradient on the track itself and the fill element has
   nothing left to do; the hole is the panel colour, so the ring sits on
   whatever it was dropped onto. */
[data-lf-progress="ring"] .lf-progress {
  --lf-progress-ring-size: 5.5rem;
  --lf-progress-ring-thickness: .6rem;
  display: flex;
  justify-content: center;
  height: var(--lf-progress-ring-size);
}

[data-lf-progress="ring"] .lf-progress-track {
  flex: 0 0 auto;
  width: var(--lf-progress-ring-size);
  height: var(--lf-progress-ring-size);
  border-radius: 50%;
  background-image: conic-gradient(
    var(--lf-theme-progress-fill) calc(var(--lf-progress-value) * 1%),
    var(--lf-theme-progress-track-bg) 0);
}

[data-lf-progress="ring"] .lf-progress-track::after {
  content: "";
  position: absolute;
  inset: var(--lf-progress-ring-thickness);
  border-radius: 50%;
  background-color: var(--lf-theme-panel-bg);
}

[data-lf-progress="ring"] .lf-progress-fill {
  display: none;
}

[data-lf-progress="ring"] .lf-progress-label {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

[data-lf-progress="ring"] .lf-progress-label-fill {
  display: none;
}

/* A bar is a status line, not a decoration: what it says has to survive the
   animation being off. Only the motion goes. */
@media (prefers-reduced-motion: reduce) {
  [data-lf-progress="striped-animated"] .lf-progress-fill {
    animation: none;
  }

  .lf-progress-fill {
    transition: none;
  }
}

/* Bootstrap's own .progress, wherever it is still written — a module's page, a
   host's markup, a view this change did not touch. It costs two rules to stop
   those being #0d6efd on a dark theme, and they cannot be found by grepping
   this repository. */
:where(html.lf-shell, .lf-mount, .lf-scope) .progress,
:where(html.lf-shell, .lf-mount, .lf-scope) .progress-stacked {
  background-color: var(--lf-theme-progress-track-bg);
}

:where(html.lf-shell, .lf-mount, .lf-scope) .progress-bar {
  background-color: var(--lf-theme-progress-fill);
  color: var(--lf-theme-progress-fill-fg);
}
