/*
  The BSFT UI default theme. Built entirely on design tokens: applications re-skin by
  overriding the custom properties below (or by replacing this stylesheet), never by
  touching component behavior.

  Consumed via: <link rel="stylesheet" href="_content/Bsft.UI.Theme/bsft-ui.css" />

  Nothing in this file sits in an @layer, on purpose: a layered token or dark activation rule
  would lose to any unlayered host rule, so a host re-skin would beat dark mode, and the reduced
  -motion guard's documented escape hatch would turn around.

  The file is cut into named sections ("--- name ---"). Some are still empty: they reserve the
  place of components that are added later, so that work on two components never edits the same
  lines of this file.
*/

/* --- tokens ---------------------------------------------------------------- */

:root {
  --bsft-color-text: #1f2933;
  /* Secondary text, read on the surface and on the tinted surfaces the theme draws behind it (the own
     chat message's time on the primary surface, an option's description on the info surface): 5.4:1 on
     the surface and 5.0:1 on the tints, where #6b7280 read only 4.4:1, and still well below the body
     text's 13.6:1 there. */
  --bsft-color-muted: #636a77;
  --bsft-color-surface: #ffffff;
  --bsft-color-border: #d2d6dc;
  /* The three primary tokens read a brand source first. The brand sources (--bsft-brand-primary,
     --bsft-brand-primary-contrast, --bsft-brand-primary-surface and their three --bsft-brand-dark-*
     twins) are never declared here: a brand applier writes them, and without one the literal
     fallback is the theme's own colour. Reading them here rather than overriding the public token
     keeps the dark activation rules below working unchanged. */
  /* #215bd8 rather than #2563eb: primary text also sits on the hover tints (the 8% text tint under a
     navigation item, the 4% one under a table row), where #2563eb measured 4.45:1. This one keeps 5.1:1
     on the tint over the surface and 4.7:1 on the tint over the light tinted surfaces, and white on it
     5.9:1. */
  --bsft-color-primary: var(--bsft-brand-primary, #215bd8);
  --bsft-color-primary-contrast: var(--bsft-brand-primary-contrast, #ffffff);
  /* The primary colour as a surface: what a bubble, a chip or a row takes when it is the
     reader's own rather than merely selected. Its own token beside the info surface it
     resembles, because a re-skin that tints information must not tint ownership with it. */
  --bsft-color-primary-surface: var(--bsft-brand-primary-surface, #eff6ff);
  /* The plain-link palette (#5292). A rest colour of the primary itself, a hover/focus colour a
     quarter of the way towards the text colour (darkening it on the light surface, lightening it
     on the dark one) and a visited colour a little further still — distinguishable from both,
     never the browser's default purple. Derived from the two tokens that already carry a dark
     counterpart rather than given literal colours of their own, so a brand override of
     --bsft-color-primary reaches every link without a second place to tune. */
  --bsft-color-link: var(--bsft-color-primary);
  --bsft-color-link-hover: color-mix(in srgb, var(--bsft-color-primary) 75%, var(--bsft-color-text));
  --bsft-color-link-visited: color-mix(in srgb, var(--bsft-color-primary) 82%, var(--bsft-color-text));
  --bsft-color-danger: #b91c1c;
  --bsft-color-danger-surface: #fef2f2;
  /* The text colour a filled danger surface (the danger button) carries. Its own token rather
     than --bsft-color-primary-contrast: a brand's primary can turn dark without affecting it, and
     the dark theme below gives it a value of its own, because --bsft-color-danger there is tuned
     to read as text on the dark surface, which is too light to carry white text at 4.5:1. */
  --bsft-color-danger-contrast: #ffffff;
  --bsft-color-warning: #92400e;
  --bsft-color-warning-surface: #fffbeb;
  --bsft-color-success: #166534;
  --bsft-color-success-surface: #f0fdf4;
  /* The text colour a filled success surface (the Primary action button) carries, for the reason
     --bsft-color-danger-contrast exists: the dark theme's success green is tuned to read as text
     on the dark surface and is far too light to carry white (1.7:1). */
  --bsft-color-success-contrast: #ffffff;
  --bsft-color-info: #1e40af;
  --bsft-color-info-surface: #eff6ff;
  /* The resting colour of a placeholder standing in for content that has not arrived. Its own
     token rather than the border colour it happens to resemble: a skeleton is a surface, and a
     re-skin that darkens borders must not darken every loading page with them. */
  --bsft-color-skeleton: #e5e7eb;
  /* The label of a disabled action button, on the border colour that is its fill; nothing else
     reads it (a disabled .bsft-button, chip or toggle is drawn at reduced opacity instead). One
     step darker than --bsft-color-muted, which reads only 3.7:1 there: 5.2:1, still well below the
     enabled labels, so the action keeps reading as unavailable. */
  --bsft-color-action-disabled-text: #4b5563;
  /* The categorical palette of the charts: series without an explicit variant take these in order
     and repeat (dashed) after the eighth. Distinct from the semantic colors on purpose, so a series
     never reads as a warning. */
  --bsft-chart-1: #2563eb;
  --bsft-chart-2: #d97706;
  --bsft-chart-3: #059669;
  --bsft-chart-4: #7c3aed;
  --bsft-chart-5: #db2777;
  --bsft-chart-6: #0891b2;
  --bsft-chart-7: #65a30d;
  --bsft-chart-8: #475569;
  --bsft-spacing: 0.5rem;
  --bsft-radius-sm: 0.25rem;
  --bsft-radius: 0.375rem;
  --bsft-radius-lg: 0.75rem;
  --bsft-radius-full: 9999px;
  --bsft-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* The type scale. Every font-size in rem below reads one of these, so a host scales the
     theme's text in one place; sizes in em stay relative to their parent on purpose. -2xs exists
     for one use, the initials inside a small avatar. */
  --bsft-font-size-2xs: 0.6875rem;
  --bsft-font-size-xs: 0.75rem;
  --bsft-font-size-sm: 0.875rem;
  --bsft-font-size-md: 1rem;
  --bsft-font-size-lg: 1.125rem;
  --bsft-font-size-xl: 1.25rem;
  --bsft-font-size-2xl: 1.5rem;
  --bsft-font-size-3xl: 1.75rem;
  --bsft-line-height-tight: 1.25;
  --bsft-line-height-normal: 1.5;
  /* Elevation, lowest first. Shadows carry a colour, so each has a dark counterpart below. */
  --bsft-shadow-1: 0 1px 2px rgb(15 23 42 / 8%);
  --bsft-shadow-2: 0 2px 8px rgb(15 23 42 / 10%), 0 1px 2px rgb(15 23 42 / 6%);
  --bsft-shadow-3: 0 12px 32px rgb(15 23 42 / 16%), 0 2px 6px rgb(15 23 42 / 8%);
  /* The inner shadow at the end of a scrolled list that hides entries there: its depth and its
     colour. The colour has a dark counterpart below, as every shadow's has. */
  --bsft-scroll-cue-size: 1rem;
  --bsft-scroll-cue-color: rgb(15 23 42 / 28%);
  /* The smallest box a finger hits reliably (44 CSS px). Every control that is tapped takes at
     least this height; a compact size exists only where the pointer is fine. */
  --bsft-touch-target: 2.75rem;
  /* The smallest pointer target WCAG 2.2 allows (24 CSS px, success criterion 2.5.8). A control
     drawn smaller than this, such as the info hint's icon, extends its hit area to it without
     taking the room in the layout. */
  --bsft-target-size-min: 1.5rem;
  /* A button's height (36 CSS px) where the pointer is fine, so a toolbar or a table row of
     buttons stays compact on a desktop. Under a coarse pointer it is the touch target; see the
     pointer query after the token sections. */
  --bsft-button-height: 2.25rem;
  /* The widest a column of reading content grows before lines get too long to follow. */
  --bsft-content-width: 60rem;
  /* The three floating layers, ordered as one contract: an anchored popup never outranks a
     modal, and nothing outranks the toasts. */
  --bsft-z-popup: 10;
  --bsft-z-dialog: 100;
  --bsft-z-toast: 1000;
  /* Durations are tokens for the same reason colours are: a host toning the theme's motion down
     without turning it off should not have to find every transition in the file. The reduced
     -motion guard below is the other half of that and is not a substitute for it — it answers a
     stated user preference, while these answer a designer's. */
  --bsft-motion-fast: 150ms;
  --bsft-motion-spin: 800ms;
  --bsft-motion-pulse: 1500ms;
  /* Entrance, exit and movement of whole surfaces, and the delay between siblings that enter one
     after another. Exits are shorter than entrances: what leaves is no longer being read. */
  --bsft-motion-entrance: 250ms;
  --bsft-motion-exit: 200ms;
  --bsft-motion-move: 300ms;
  --bsft-motion-stagger: 50ms;
  --bsft-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  /* Effects (bsft-ui-effects.css). The glow is a share of the primary colour: --bsft-glow-max at
     full intensity, scaled by the intensity an effects applier writes as a source token. Glass is
     the surface's opacity and blur behind a translucent panel. Without bsft-ui-effects.css none of
     these is read. */
  --bsft-glow-max: 70%;
  --bsft-glow-intensity: var(--bsft-effects-light-intensity, 0.5);
  --bsft-glow: calc(var(--bsft-glow-max) * var(--bsft-glow-intensity));
  --bsft-glass-opacity: 72%;
  --bsft-glass-blur: 12px;
}

/* --- dark theme ---------------------------------------------------------- */

/* The standard three-state model: without an attribute the system preference decides
   (prefers-color-scheme), data-bsft-theme="light"|"dark" on <html> overrides it in either
   direction. The dark palette lives once in the --bsft-dark-* tokens; the two activation
   rules below only map the public tokens onto it, so they cannot drift apart. Only the
   colors change — spacing, radius and typography are theme-independent. */

:root {
  --bsft-dark-color-text: #e5e7eb;
  --bsft-dark-color-muted: #9ca3af;
  --bsft-dark-color-surface: #111827;
  --bsft-dark-color-border: #374151;
  /* Light enough to read as text on every dark surface the theme draws: 7.0:1 on the dark surface and
     5.8:1 on the dark primary and info surfaces (#172554), where #3b82f6 read only 4.0:1 behind the
     primary text of a selected graph row or an own chat message, and the links on it. */
  --bsft-dark-color-primary: var(--bsft-brand-dark-primary, #60a5fa);
  /* The dark theme's fills are bright and carry dark text, as the danger and success fills below
     do: white on #60a5fa reads only 2.5:1, the dark surface colour 7.0:1 (7.8:1 in the hover
     shade). A darker fill would carry white, but the same token is the dark theme's link colour,
     which then would no longer read 4.5:1 on the dark surface. */
  --bsft-dark-color-primary-contrast: var(--bsft-brand-dark-primary-contrast, #111827);
  --bsft-dark-color-primary-surface: var(--bsft-brand-dark-primary-surface, #172554);
  --bsft-dark-color-link: var(--bsft-dark-color-primary);
  --bsft-dark-color-link-hover: color-mix(in srgb, var(--bsft-dark-color-primary) 75%, var(--bsft-dark-color-text));
  --bsft-dark-color-link-visited: color-mix(in srgb, var(--bsft-dark-color-primary) 82%, var(--bsft-dark-color-text));
  --bsft-dark-color-danger: #f87171;
  --bsft-dark-color-danger-surface: #450a0a;
  /* White on --bsft-dark-color-danger reads 2.8:1: too light a red to carry white at 4.5:1. The
     dark surface colour does, at over 6:1 in both the resting and the hover shade below. */
  --bsft-dark-color-danger-contrast: #111827;
  --bsft-dark-color-warning: #fbbf24;
  --bsft-dark-color-warning-surface: #451a03;
  --bsft-dark-color-success: #4ade80;
  --bsft-dark-color-success-surface: #052e16;
  --bsft-dark-color-success-contrast: #111827;
  --bsft-dark-color-info: #93c5fd;
  --bsft-dark-color-info-surface: #172554;
  --bsft-dark-color-skeleton: #1f2937;
  /* 5.1:1 on the dark border fill: legible, and still clearly weaker than an enabled label. */
  --bsft-dark-color-action-disabled-text: #b0b6c0;
  --bsft-dark-chart-1: #60a5fa;
  --bsft-dark-chart-2: #fbbf24;
  --bsft-dark-chart-3: #34d399;
  --bsft-dark-chart-4: #a78bfa;
  --bsft-dark-chart-5: #f472b6;
  --bsft-dark-chart-6: #22d3ee;
  --bsft-dark-chart-7: #a3e635;
  --bsft-dark-chart-8: #94a3b8;
  /* A shadow on a dark surface needs more opacity to read as depth at all. */
  --bsft-dark-shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
  --bsft-dark-shadow-2: 0 2px 8px rgb(0 0 0 / 45%), 0 1px 2px rgb(0 0 0 / 30%);
  --bsft-dark-shadow-3: 0 12px 32px rgb(0 0 0 / 55%), 0 2px 6px rgb(0 0 0 / 35%);
  --bsft-dark-scroll-cue-color: rgb(148 163 184 / 45%);
  --bsft-dark-glow-intensity: var(--bsft-effects-dark-intensity, 0.8);
  --bsft-dark-glass-opacity: 64%;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-bsft-theme="light"]) {
    --bsft-color-text: var(--bsft-dark-color-text);
    --bsft-color-muted: var(--bsft-dark-color-muted);
    --bsft-color-surface: var(--bsft-dark-color-surface);
    --bsft-color-border: var(--bsft-dark-color-border);
    --bsft-color-primary: var(--bsft-dark-color-primary);
    --bsft-color-primary-contrast: var(--bsft-dark-color-primary-contrast);
    --bsft-color-primary-surface: var(--bsft-dark-color-primary-surface);
    --bsft-color-link: var(--bsft-dark-color-link);
    --bsft-color-link-hover: var(--bsft-dark-color-link-hover);
    --bsft-color-link-visited: var(--bsft-dark-color-link-visited);
    --bsft-color-danger: var(--bsft-dark-color-danger);
    --bsft-color-danger-surface: var(--bsft-dark-color-danger-surface);
    --bsft-color-danger-contrast: var(--bsft-dark-color-danger-contrast);
    --bsft-color-warning: var(--bsft-dark-color-warning);
    --bsft-color-warning-surface: var(--bsft-dark-color-warning-surface);
    --bsft-color-success: var(--bsft-dark-color-success);
    --bsft-color-success-surface: var(--bsft-dark-color-success-surface);
    --bsft-color-success-contrast: var(--bsft-dark-color-success-contrast);
    --bsft-color-info: var(--bsft-dark-color-info);
    --bsft-color-info-surface: var(--bsft-dark-color-info-surface);
    --bsft-color-skeleton: var(--bsft-dark-color-skeleton);
    --bsft-color-action-disabled-text: var(--bsft-dark-color-action-disabled-text);
    --bsft-chart-1: var(--bsft-dark-chart-1);
    --bsft-chart-2: var(--bsft-dark-chart-2);
    --bsft-chart-3: var(--bsft-dark-chart-3);
    --bsft-chart-4: var(--bsft-dark-chart-4);
    --bsft-chart-5: var(--bsft-dark-chart-5);
    --bsft-chart-6: var(--bsft-dark-chart-6);
    --bsft-chart-7: var(--bsft-dark-chart-7);
    --bsft-chart-8: var(--bsft-dark-chart-8);
    --bsft-shadow-1: var(--bsft-dark-shadow-1);
    --bsft-shadow-2: var(--bsft-dark-shadow-2);
    --bsft-shadow-3: var(--bsft-dark-shadow-3);
    --bsft-scroll-cue-color: var(--bsft-dark-scroll-cue-color);
    /* --bsft-glow is declared on :root as well, so it recomputes from this intensity. */
    --bsft-glow-intensity: var(--bsft-dark-glow-intensity);
    --bsft-glass-opacity: var(--bsft-dark-glass-opacity);
  }
}

:root[data-bsft-theme="dark"] {
  --bsft-color-text: var(--bsft-dark-color-text);
  --bsft-color-muted: var(--bsft-dark-color-muted);
  --bsft-color-surface: var(--bsft-dark-color-surface);
  --bsft-color-border: var(--bsft-dark-color-border);
  --bsft-color-primary: var(--bsft-dark-color-primary);
  --bsft-color-primary-contrast: var(--bsft-dark-color-primary-contrast);
  --bsft-color-primary-surface: var(--bsft-dark-color-primary-surface);
  --bsft-color-link: var(--bsft-dark-color-link);
  --bsft-color-link-hover: var(--bsft-dark-color-link-hover);
  --bsft-color-link-visited: var(--bsft-dark-color-link-visited);
  --bsft-color-danger: var(--bsft-dark-color-danger);
  --bsft-color-danger-surface: var(--bsft-dark-color-danger-surface);
  --bsft-color-danger-contrast: var(--bsft-dark-color-danger-contrast);
  --bsft-color-warning: var(--bsft-dark-color-warning);
  --bsft-color-warning-surface: var(--bsft-dark-color-warning-surface);
  --bsft-color-success: var(--bsft-dark-color-success);
  --bsft-color-success-surface: var(--bsft-dark-color-success-surface);
  --bsft-color-success-contrast: var(--bsft-dark-color-success-contrast);
  --bsft-color-info: var(--bsft-dark-color-info);
  --bsft-color-info-surface: var(--bsft-dark-color-info-surface);
  --bsft-color-skeleton: var(--bsft-dark-color-skeleton);
  --bsft-color-action-disabled-text: var(--bsft-dark-color-action-disabled-text);
  --bsft-chart-1: var(--bsft-dark-chart-1);
  --bsft-chart-2: var(--bsft-dark-chart-2);
  --bsft-chart-3: var(--bsft-dark-chart-3);
  --bsft-chart-4: var(--bsft-dark-chart-4);
  --bsft-chart-5: var(--bsft-dark-chart-5);
  --bsft-chart-6: var(--bsft-dark-chart-6);
  --bsft-chart-7: var(--bsft-dark-chart-7);
  --bsft-chart-8: var(--bsft-dark-chart-8);
  --bsft-shadow-1: var(--bsft-dark-shadow-1);
  --bsft-shadow-2: var(--bsft-dark-shadow-2);
  --bsft-shadow-3: var(--bsft-dark-shadow-3);
  --bsft-scroll-cue-color: var(--bsft-dark-scroll-cue-color);
  /* --bsft-glow is declared on :root as well, so it recomputes from this intensity. */
  --bsft-glow-intensity: var(--bsft-dark-glow-intensity);
  --bsft-glass-opacity: var(--bsft-dark-glass-opacity);
}

/* --- shared ------------------------------------------------------------- */

/* The document itself takes the surface and text tokens. Without this the tokens turn dark under a
   dark system preference (or data-bsft-theme="dark") while the browser keeps its white canvas, and
   text the theme does not style itself becomes light text on white. color-scheme tells the browser
   which palette its own chrome (scrollbars, form controls, autofill, the canvas before the
   stylesheet's colours apply) has to match: both while the system decides, the chosen one when the
   attribute does. A host rule on html or body still wins by coming later or naming body. */
:root {
  color-scheme: light dark;
  background-color: var(--bsft-color-surface);
  color: var(--bsft-color-text);
}

:root[data-bsft-theme="light"] {
  color-scheme: light;
}

:root[data-bsft-theme="dark"] {
  color-scheme: dark;
}

/* A finger needs the full touch target; a mouse or a pen does not. */
@media (pointer: coarse) {
  :root {
    --bsft-button-height: var(--bsft-touch-target);
  }
}

.bsft-error {
  color: var(--bsft-color-danger);
  background: var(--bsft-color-danger-surface);
  border: 1px solid var(--bsft-color-danger);
  border-radius: var(--bsft-radius);
  padding: var(--bsft-spacing);
  font-family: var(--bsft-font);
}

.bsft-empty,
.bsft-busy {
  color: var(--bsft-color-muted);
  font-family: var(--bsft-font);
  padding: var(--bsft-spacing);
}

/* --- links --------------------------------------------------------------- */

/* The theme styles only its own link components (the nav item, the breadcrumb label), so a plain
   <a> in a host — a table cell, a list, a card — fell back to the browser's blue underline and
   purple :visited colour, and a keyboard user got no focus ring at all (#5292). The selectors
   below are wrapped in :where() so the rule weighs nothing (0,0,1): a host's own link rule and
   every themed component above it keep winning by selector weight alone, never merely by coming
   later in the cascade.

   Rest takes the --bsft-color-link token (the primary colour) without an underline — the table
   cell, the list or the card it sits in already says it is a link. Hover and keyboard focus
   underline it and move it towards --bsft-color-link-hover, a shade closer to the text colour,
   which reads as a darkening on the light surface and a lightening on the dark one. A visited
   link moves a little further still towards the text colour than resting: distinguishable from
   both, never the browser's own purple. Focus adds the 2px primary ring every other control of
   the theme shows. */
:where(a) {
  color: var(--bsft-color-link);
  text-decoration-line: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  border-radius: 2px;
}

:where(a:visited) {
  color: var(--bsft-color-link-visited);
}

:where(a:hover),
:where(a:focus-visible) {
  color: var(--bsft-color-link-hover);
  text-decoration-line: underline;
}

:where(a:focus-visible) {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* Opt-in for running text (a paragraph of rendered markdown, prose copy): inside a sentence a
   link has to be told apart from the words around it by more than colour (WCAG 1.4.1), so the
   underline stays on at rest, drawn as a soft tint of the link's own colour rather than a solid
   line, and turns solid on hover or focus. Higher specificity than the :where(a) rules above, so
   it wins over them regardless of source order; a table cell, a list or a card is not running
   text and keeps the plain rest state above instead. */
.bsft-prose a {
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}

.bsft-prose a:hover,
.bsft-prose a:focus-visible {
  text-decoration-color: currentColor;
}

/* --- busy affordance ------------------------------------------------------ */

/* The busy region lays its affordance out beside the label rather than under it. The label is
   visually hidden and the affordance is aria-hidden, so what the viewer sees and what a screen
   reader hears are two disjoint halves of one region — which is why neither may be styled away:
   display:none on the label would take the announcement with it. */
.bsft-busy {
  display: flex;
  align-items: center;
  gap: var(--bsft-spacing);
}

/* The skeleton fills the width it was given, because it stands in for content that will. */
.bsft-busy-skeleton {
  display: block;
}

@keyframes bsft-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Opacity rather than a travelling highlight: a gradient sweep needs a background-position
   animation that composites on every frame, and the pulse says the same thing for less. */
@keyframes bsft-skeleton-pulse {
  50% {
    opacity: 0.5;
  }
}

/* A ring with one coloured quadrant, sized off the surrounding text so it matches whatever it
   sits beside. Frozen by the reduced-motion guard into exactly this shape, which is why the
   coloured quadrant is drawn at rest rather than only appearing mid-spin. */
.bsft-spinner {
  flex-shrink: 0;
  box-sizing: border-box;
  width: 1em;
  height: 1em;
  border: 2px solid var(--bsft-color-border);
  border-top-color: var(--bsft-color-primary);
  border-radius: 50%;
  animation: bsft-spin var(--bsft-motion-spin) linear infinite;
}

.bsft-skeleton {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
  width: 100%;
}

.bsft-skeleton-line {
  height: 0.75rem;
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-skeleton);
  animation: bsft-skeleton-pulse var(--bsft-motion-pulse) ease-in-out infinite;
}

/* The last line is short, the way a paragraph's last line is: a block of equal bars reads as a
   table that failed to load rather than as text on its way. */
.bsft-skeleton-line:last-child {
  width: 60%;
}

/* The shapes of BsftSkeletonShape. Each borrows the padding, radius and border of what it stands
   in for, so the page keeps its height and nothing moves when the content lands. They all pulse
   through the same keyframes as a line, which the reduced-motion guard below stops as a whole. */
.bsft-skeleton-rows {
  gap: 0;
}

.bsft-skeleton-row {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
  padding: var(--bsft-spacing) 0;
  border-bottom: 1px solid var(--bsft-color-border);
}

.bsft-skeleton-row .bsft-skeleton-line:first-child {
  width: 75%;
}

.bsft-skeleton-panel {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
  padding: calc(var(--bsft-spacing) * 2);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
}

.bsft-skeleton-heading {
  height: 1rem;
  width: 40%;
  margin-bottom: calc(var(--bsft-spacing) / 2);
}

.bsft-skeleton-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: var(--bsft-spacing);
}

.bsft-skeleton-tile {
  aspect-ratio: 4 / 3;
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-skeleton);
  animation: bsft-skeleton-pulse var(--bsft-motion-pulse) ease-in-out infinite;
}

.bsft-notice {
  color: var(--bsft-color-warning);
  background: var(--bsft-color-warning-surface);
  border: 1px solid var(--bsft-color-warning);
  border-radius: var(--bsft-radius);
  padding: var(--bsft-spacing);
  font-family: var(--bsft-font);
}

/* --- idp: remaining recovery codes ----------------------------------------- */

/* Shown after a recovery code sign-in. An informational surface while the supply is healthy and
   the warning surface once it is low; the low state also adds a sentence, so it never rests on
   colour alone. The actions wrap, so the link and the button stay usable at 375px. */
.bsft-idp-recovery-codes-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bsft-spacing);
  color: var(--bsft-color-info);
  background: var(--bsft-color-info-surface);
  border: 1px solid var(--bsft-color-info);
  border-radius: var(--bsft-radius);
  padding: var(--bsft-spacing);
  font-family: var(--bsft-font);
}

.bsft-idp-recovery-codes-left > p {
  flex: 1 1 100%;
  margin: 0;
}

.bsft-idp-recovery-codes-left[data-bsft-low="true"] {
  color: var(--bsft-color-warning);
  background: var(--bsft-color-warning-surface);
  border-color: var(--bsft-color-warning);
}

/* --- form --------------------------------------------------------------- */

.bsft-form {
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

.bsft-form-field {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
}

.bsft-form-field label {
  font-size: 0.875em;
  font-weight: 500;
  color: var(--bsft-color-text);
}

/* The required marker is presentational (aria-hidden); requiredness reaches assistive
   technology through the host's input. */
.bsft-form-field-required {
  color: var(--bsft-color-danger);
  margin-left: 0.25em;
}

/* Text inputs, selects and textareas share the control chrome. Checkboxes and radios keep
   their native rendering — boxing them in the same border/padding would break their layout
   next to a label. */
.bsft-form-field input:not([type="checkbox"]):not([type="radio"]),
.bsft-form-field select,
.bsft-form-field textarea {
  font-family: var(--bsft-font);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
}

.bsft-form-field input:not([type="checkbox"]):not([type="radio"]):focus-visible,
.bsft-form-field select:focus-visible,
.bsft-form-field textarea:focus-visible {
  border-color: var(--bsft-color-primary);
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 1px;
}

.bsft-form-field-hint {
  color: var(--bsft-color-muted);
  font-size: 0.875em;
  margin: 0;
}

.bsft-form-field-errors {
  color: var(--bsft-color-danger);
  font-size: 0.875em;
  margin: 0;
  padding-left: 1.25em;
}

.bsft-form-actions {
  display: flex;
  gap: var(--bsft-spacing);
}

/* --- button ---------------------------------------------------------------- */

/* The height counts the border and the padding (border-box), whatever element carries the class: a
   <button> sizes its border box by default, an <a> its content box, which made a link button 10px
   taller than the button beside it. A link button is also laid out as one (inline-flex, its label
   centred on both axes as a button centres its own), since min-height does not apply to an inline
   box at all, and it loses the link underline, at rest and under the pointer. Its text is centred
   too, so a label that wraps lines up as a button's does. :where() keeps that rule at the class's
   own specificity, so a host rule on .bsft-button still decides. */
.bsft-button {
  box-sizing: border-box;
  min-height: var(--bsft-button-height);
  font: inherit;
  font-family: var(--bsft-font);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  cursor: pointer;
}

/* One definition of the primary surface. The selected theme and locale options are that same
   surface, so they join the rule instead of restating its three declarations. */
.bsft-button-primary,
.bsft-theme-option[aria-pressed="true"],
.bsft-locale-option[aria-pressed="true"],
.bsft-scope-option[aria-pressed="true"] {
  background: var(--bsft-color-primary);
  border-color: var(--bsft-color-primary);
  color: var(--bsft-color-primary-contrast);
}

.bsft-button:where(a) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.bsft-button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Hover and keyboard focus. The hover is a border in the primary colour on the plain button and a
   shade towards the text colour on the filled ones, so it reads on the light and the dark surface
   alike; focus is the 2px primary ring every other control of the theme shows. */
.bsft-button:hover:not(:disabled) {
  border-color: var(--bsft-color-primary);
}

.bsft-button-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--bsft-color-primary) 85%, var(--bsft-color-text));
}

.bsft-button-danger:hover:not(:disabled) {
  border-color: var(--bsft-color-danger);
  background: color-mix(in srgb, var(--bsft-color-danger) 85%, var(--bsft-color-text));
}

.bsft-button:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* --- copy affordance ----------------------------------------------------- */

/* The affordance is a button plus the region that announces the verdict, laid out inline so it
   sits beside the value it copies rather than under it. It joins .bsft-button rather than
   restating a surface of its own: a copy button is an ordinary button that happens to have two
   more states to show. */
.bsft-copy {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
}

.bsft-copy-button {
  font-size: var(--bsft-font-size-sm);
  padding: calc(var(--bsft-spacing) / 4) calc(var(--bsft-spacing) / 2);
}

.bsft-copy-button:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* The two outcomes are tokenized like every other themed surface, and — the point of colouring
   them at all — never the only carrier of the verdict: the text beside the button says it too,
   for anyone who cannot tell the two tokens apart. */
.bsft-copy-button-copied {
  border-color: var(--bsft-color-success);
  color: var(--bsft-color-success);
}

.bsft-copy-button-failed {
  border-color: var(--bsft-color-danger);
  color: var(--bsft-color-danger);
}

.bsft-copy-status {
  font-size: var(--bsft-font-size-sm);
  color: var(--bsft-color-muted);
}

/* --- list --------------------------------------------------------------- */

.bsft-list {
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

.bsft-list table {
  width: 100%;
  border-collapse: collapse;
}

.bsft-list th,
.bsft-list td {
  text-align: left;
  padding: var(--bsft-spacing);
  border-bottom: 1px solid var(--bsft-color-border);
}

.bsft-list th button {
  all: unset;
  cursor: pointer;
  font: inherit;
}

/* The sort glyphs live here, not in markup, so a theme override (or an RTL layout)
   re-skins them without touching the component. */
.bsft-list-sort-asc::after {
  content: " ▲";
}

.bsft-list-sort-desc::after {
  content: " ▼";
}

.bsft-list-loaded {
  color: var(--bsft-color-muted);
}

/* The scrolling container a windowed list needs: something with a height for the browser to
   scroll, and spacer rows inside it standing in for the rows that are not drawn. Both numbers
   arrive as custom properties written by the rendering itself — the same row height it placed
   the spacers by — so the stylesheet and the arithmetic cannot disagree about how tall a row is.
   The fallbacks are the rendering's own defaults and exist for a host that styles a window of
   its own rather than as a second opinion. */
.bsft-list-window {
  overflow-y: auto;
  max-height: var(--bsft-list-window-height, 480px);
}

/* Uniform rows are the premise of the whole arrangement, so the window states the height rather
   than hoping the content agrees on one. The spacers carry their own inline height and override
   this, which is exactly what they are for. */
.bsft-list-window tbody tr {
  height: var(--bsft-list-row-height, 40px);
}

/* The header stays put while the rows scroll under it — a windowed list is the one place a user
   can lose sight of what the columns mean without leaving the screen. It needs its own background
   because the rows would otherwise show through it. */
.bsft-list-window thead th {
  position: sticky;
  top: 0;
  background: var(--bsft-color-surface);
}

/* Where the keyboard is. Painted only inside a window, because that is where the grid itself
   holds the focus and the cursor is the only thing saying which row the arrow keys are on; in a
   paged list every row's own controls are still in the tab order and a second cursor beside the
   focus ring would be two answers to one question. */
.bsft-list-window .bsft-list-row-active > td {
  background: var(--bsft-color-info-surface);
}

.bsft-list-pager {
  display: flex;
  align-items: center;
  gap: var(--bsft-spacing);
  padding-top: var(--bsft-spacing);
}

/* The page-size chooser sits at the far end of the pager, away from the previous/next
   pair, so a mis-aimed click changes the page rather than the whole page size. */
.bsft-list-pagesize {
  display: flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  margin-left: auto;
}

.bsft-list-select {
  width: 1px;
  white-space: nowrap;
}

/* The filter bar wraps rather than scrolls: a filter the user cannot see is a filter they
   cannot take off again, and a narrow viewport is exactly where that bites. */
.bsft-list-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--bsft-spacing);
  padding-bottom: var(--bsft-spacing);
}

.bsft-list-filter {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
}

.bsft-list-filter-label {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

.bsft-list-bulk {
  display: flex;
  align-items: center;
  gap: var(--bsft-spacing);
  /* Reserves its height even while nothing is selected, so the table does not jump down the
     page the moment the first row is ticked. */
  min-height: 2rem;
}

.bsft-list-bulk-count {
  color: var(--bsft-color-muted);
}

/* Hidden from sight, kept for assistive technology — never display:none, which takes the text
   out of the accessibility tree along with the pixels. */
.bsft-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* BsftTable: a plain table in the list's chrome for rows the caller writes itself. The container
   scrolls sideways, so a wide table never widens the page; with a label it is a focusable region
   and shows the theme's focus ring. */
.bsft-table {
  max-width: 100%;
  overflow-x: auto;
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

.bsft-table:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-table-grid {
  width: 100%;
  border-collapse: collapse;
}

.bsft-table-grid th,
.bsft-table-grid td {
  text-align: start;
  vertical-align: top;
  padding: var(--bsft-spacing);
  border-bottom: 1px solid var(--bsft-color-border);
}

.bsft-table-grid th {
  font-size: var(--bsft-font-size-sm);
  font-weight: 600;
  color: var(--bsft-color-muted);
  white-space: nowrap;
  vertical-align: bottom;
}

.bsft-table-grid > tbody > tr:hover {
  background: color-mix(in srgb, var(--bsft-color-text) 4%, transparent);
}

/* A filter field in a header cell takes its column's width instead of the browser's 20 characters. */
.bsft-table-grid th .bsft-input {
  width: 100%;
  min-width: 4rem;
  font-weight: 400;
}

/* --- detail ------------------------------------------------------------- */

.bsft-detail {
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

/* Compact filter choices wrap instead of scrolling sideways. Single-select chips announce
   radio state; multi-select chips announce pressed state, and the same visible surface is keyed
   from those two accessibility states. */
.bsft-chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  font-family: var(--bsft-font);
}

.bsft-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: 999px;
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.bsft-chip[aria-checked="true"],
.bsft-chip[aria-pressed="true"] {
  border-color: var(--bsft-color-primary);
  background: var(--bsft-color-primary);
  color: var(--bsft-color-primary-contrast);
}

.bsft-chip:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-chip[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

.bsft-chip-count {
  font-size: 0.75em;
  font-variant-numeric: tabular-nums;
}

/* The title block and actions are peers so actions move beneath the title as soon as the row no
   longer fits. Badges stay with the heading they qualify. */
.bsft-detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--bsft-spacing);
  margin-bottom: calc(var(--bsft-spacing) * 2);
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

.bsft-detail-header-main {
  min-width: 0;
}

.bsft-detail-header-title-row,
.bsft-detail-header-badges,
.bsft-detail-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bsft-spacing);
}

.bsft-detail-header-title {
  margin: 0;
}

.bsft-detail-header-subtitle {
  margin: calc(var(--bsft-spacing) / 2) 0 0;
  color: var(--bsft-color-muted);
}

/* Each grid cell remains one dt/dd pair. auto-fit chooses the column count from the minimum the
   component writes, so the same markup collapses naturally from a dashboard to a phone. */
.bsft-metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--bsft-metadata-min-column-width)), 1fr));
  gap: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  margin: 0;
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

.bsft-metadata-item {
  min-width: 0;
}

.bsft-metadata-item dt {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

.bsft-metadata-item dd {
  margin: calc(var(--bsft-spacing) / 2) 0 0;
  overflow-wrap: anywhere;
}

/* --- dialog -------------------------------------------------------------- */

.bsft-dialog {
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  padding: var(--bsft-spacing);
  font-family: var(--bsft-font);
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
}

.bsft-button-danger {
  background: var(--bsft-color-danger);
  border-color: var(--bsft-color-danger);
  color: var(--bsft-color-danger-contrast);
}

/* --- theme and locale switchers ------------------------------------------- */

/* Both groups are the same segmented control: buttons joined into one control, the active one
   marked by aria-pressed. Styling selects on that attribute rather than on an extra class,
   so a theme cannot style an option as active that assistive technology reads as inactive —
   the active surface itself is the shared .bsft-button-primary rule above. One set of rules
   for both switchers, because the two ask the same kind of question and must not drift. */
.bsft-locale-switcher,
.bsft-theme-switcher {
  display: inline-flex;
  font-family: var(--bsft-font);
}

.bsft-locale-option,
.bsft-theme-option {
  border-radius: 0;
}

.bsft-locale-option:first-child,
.bsft-theme-option:first-child {
  border-start-start-radius: var(--bsft-radius);
  border-end-start-radius: var(--bsft-radius);
}

.bsft-locale-option:last-child,
.bsft-theme-option:last-child {
  border-start-end-radius: var(--bsft-radius);
  border-end-end-radius: var(--bsft-radius);
}

.bsft-locale-option + .bsft-locale-option,
.bsft-theme-option + .bsft-theme-option {
  border-inline-start: none;
}

.bsft-locale-option:focus-visible,
.bsft-theme-option:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* --- popover, menu and user menu -------------------------------------------- */

/* Anchored popup: the trigger stays in flow, the panel floats off the corner the placement
   attribute names. One block for the plain popover, the dropdown menu and the user menu, since
   all three render the same markup. */
.bsft-popover {
  position: relative;
  display: inline-flex;
  font-family: var(--bsft-font);
}

.bsft-popover-trigger:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* The outside-click dismissal: an invisible layer under the popup and over the page, so a
   click anywhere else closes it without a document-level script. */
.bsft-popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--bsft-z-popup) - 1);
}

.bsft-popover-panel {
  position: absolute;
  min-width: 12rem;
  display: flex;
  flex-direction: column;
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  padding: calc(var(--bsft-spacing) / 2);
  gap: calc(var(--bsft-spacing) / 2);
  z-index: var(--bsft-z-popup);
}

/* The four placements, written as the tokens BsftPopover emits rather than as CSS-side names,
   so the two cannot drift. Logical properties throughout: "start" is the left edge in a
   left-to-right locale and the right edge in a right-to-left one. */
.bsft-popover[data-bsft-placement="bottom-start"] > .bsft-popover-panel {
  top: 100%;
  inset-inline-start: 0;
}

.bsft-popover[data-bsft-placement="bottom-end"] > .bsft-popover-panel {
  top: 100%;
  inset-inline-end: 0;
}

.bsft-popover[data-bsft-placement="top-start"] > .bsft-popover-panel {
  bottom: 100%;
  inset-inline-start: 0;
}

.bsft-popover[data-bsft-placement="top-end"] > .bsft-popover-panel {
  bottom: 100%;
  inset-inline-end: 0;
}

.bsft-menu-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.bsft-menu-item {
  appearance: none;
  background: none;
  border: 0;
  display: flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  inline-size: 100%;
  text-align: start;
  color: var(--bsft-color-text);
  font: inherit;
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border-radius: var(--bsft-radius);
  cursor: pointer;
}

/* A group is structure only: its items stack exactly like the menu's own. */
.bsft-menu-group {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.bsft-menu-separator {
  block-size: 0;
  margin: calc(var(--bsft-spacing) / 2) 0;
  border-block-start: 1px solid var(--bsft-color-border);
}

/* The checkmark's slot is reserved on every checkable item, checked or not, so a label does not
   move when its item becomes the chosen one. The icon slot holds whatever the host drew. */
.bsft-menu-item-check,
.bsft-menu-item-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  inline-size: 1rem;
}

.bsft-menu-item-label {
  flex: 1 1 auto;
  min-inline-size: 0;
}

/* A destructive command reads in the danger colour, the menu's counterpart of
   bsft-button-danger; the checkmark and an icon follow through currentColor. */
.bsft-menu-item-danger {
  color: var(--bsft-color-danger);
}

.bsft-menu-item:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* Refused rather than removed, so the menu keeps its shape: the pointer says so and the
   contrast drops, while aria-disabled says the same thing to assistive technology. */
.bsft-menu-item[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.6;
}

/* --- disclosure ------------------------------------------------------------- */

.bsft-disclosure {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
  font-family: var(--bsft-font);
}

.bsft-disclosure-heading {
  margin: 0;
  font-size: inherit;
}

.bsft-disclosure-trigger {
  appearance: none;
  width: 100%;
  text-align: start;
  background: none;
  border: 0;
  color: var(--bsft-color-text);
  font: inherit;
  font-weight: 600;
  padding: calc(var(--bsft-spacing) / 2) 0;
  cursor: pointer;
}

.bsft-disclosure-trigger:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-disclosure-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.bsft-disclosure-panel {
  padding-inline-start: var(--bsft-spacing);
}

/* --- breadcrumbs ------------------------------------------------------------ */

.bsft-breadcrumbs {
  font-family: var(--bsft-font);
}

.bsft-breadcrumbs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
}

/* The separator is drawn rather than written into the markup: a literal slash between two list
   items is read aloud once per step and adds nothing the ordered list has not already said. */
.bsft-breadcrumbs-step + .bsft-breadcrumbs-step::before {
  content: "/";
  margin-inline-end: calc(var(--bsft-spacing) / 2);
  color: var(--bsft-color-muted);
}

.bsft-breadcrumbs-label {
  color: var(--bsft-color-primary);
  text-decoration: none;
}

.bsft-breadcrumbs-label[aria-current="page"] {
  color: var(--bsft-color-text);
  font-weight: 600;
}

.bsft-breadcrumbs-label:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* --- shell ------------------------------------------------------------------- */

/* The shell fills the page through a chain of percentages and flex growth rather than a viewport
   unit: the document is the initial containing block's height, the body at least the document's,
   and the application root (the body's child holding the shell, whatever the host calls it) and
   the shell each grow into what is left. The initial containing block does not change height
   while a mobile URL bar collapses, so the shell neither reflows with the bar nor forces a
   scrollbar, which is what the former small-viewport height achieved — without a viewport unit that a
   sheet or a keyboard inset would have to be reconciled with. */
html {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

body > :has(> .bsft-shell) {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
}

.bsft-shell {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  gap: var(--bsft-spacing);
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

.bsft-shell-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--bsft-spacing);
}

.bsft-shell-page-title {
  min-width: 0;
  margin: 0;
  margin-inline-end: auto;
  overflow: hidden;
  font-size: var(--bsft-font-size-2xl);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bsft-shell-header-actions {
  display: flex;
  align-items: center;
  gap: var(--bsft-spacing);
}

.bsft-shell-nav {
  display: flex;
  flex-direction: column;
}

.bsft-shell-sidebar-footer {
  margin-top: auto;
  padding-top: var(--bsft-spacing);
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

.bsft-shell-main {
  flex: 1;
}

/* The drawer toggle. It sits first in the header and is pushed to the start edge, because the
   control that opens the navigation belongs where the navigation is. Above the shell breakpoint
   the responsive block takes it out of the document entirely — display:none rather than a
   visual hide, so a keyboard user is not handed a control for a drawer that is not there. */
.bsft-shell-nav-toggle {
  appearance: none;
  margin-inline-end: auto;
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

/* With a title, the title owns the header's one flexible spacer. Without one, the toggle keeps
   its original auto margin and therefore the exact pre-title mobile layout. */
.bsft-shell-header--titled .bsft-shell-nav-toggle {
  margin-inline-end: 0;
}

/* The glyph is drawn here rather than written into the markup, exactly as the list's sort
   markers are: the button carries an aria-label instead, so a re-skin swapping this for an icon
   font changes nothing about what the control is announced as. */
.bsft-shell-nav-toggle::before {
  content: "\2261";
}

.bsft-shell-nav-toggle:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* --- navigation ------------------------------------------------------------ */

.bsft-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bsft-spacing);
  font-family: var(--bsft-font);
}

.bsft-nav-item {
  color: var(--bsft-color-primary);
  text-decoration: none;
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border-radius: var(--bsft-radius);
  /* The room a current entry brought into view keeps to its scroll container's edge, so the
     overflow cue below never sits on its label. */
  scroll-margin-block: var(--bsft-scroll-cue-size);
}

.bsft-nav-item:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-nav-item:hover {
  background: color-mix(in srgb, var(--bsft-color-text) 8%, transparent);
}

/* The current location, marked by the same attribute that announces it: the primary surface with
   the text colour on it, a bar at the start edge so the mark does not rest on colour alone, and the
   heavier weight. (The page colour it used to take was invisible on the page.) */
.bsft-nav-item[aria-current="page"] {
  background: var(--bsft-color-primary-surface);
  color: var(--bsft-color-text);
  box-shadow: inset 3px 0 0 var(--bsft-color-primary);
  font-weight: 600;
}

.bsft-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
}

/* A nested level stacks and indents instead of wrapping: a group's children are a list under a
   heading, not more entries of the bar above them. */
.bsft-nav-group > .bsft-nav-list {
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
  padding-inline-start: var(--bsft-spacing);
}

.bsft-nav-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.bsft-nav-group-trigger {
  appearance: none;
  background: none;
  border: 0;
  color: var(--bsft-color-text);
  font: inherit;
  padding: calc(var(--bsft-spacing) / 2);
  cursor: pointer;
}

.bsft-nav-group-trigger:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-nav-group {
  flex-basis: 100%;
}

/* Inside the shell's navigation the list is a column at every width: the phone drawer and the wide
   sidebar alike. A navigation placed elsewhere (a header band) keeps the wrapping row above. Each
   item fills its row, so the hover and the current mark span the sidebar. */
.bsft-shell-nav .bsft-nav,
.bsft-shell-nav .bsft-nav-list {
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
}

.bsft-shell-nav .bsft-nav-entry > .bsft-nav-item {
  flex: 1 1 auto;
}

/* A navigation list taller than the room it is given scrolls, and its scroll container (the
   navigation itself or the drawer around it) is marked by bsft-navigation-scroll.js with the ends
   that hide entries. Each such end gets an inner shadow, so nothing has to be scrolled to learn the
   list goes on; an end with nothing beyond it gets none. The shadow does not move, so there is no
   motion for a reduced-motion preference to turn off. */
[data-bsft-nav-overflow="start"] {
  box-shadow: inset 0 var(--bsft-scroll-cue-size) var(--bsft-scroll-cue-size)
    calc(var(--bsft-scroll-cue-size) * -1) var(--bsft-scroll-cue-color);
}

[data-bsft-nav-overflow="end"] {
  box-shadow: inset 0 calc(var(--bsft-scroll-cue-size) * -1) var(--bsft-scroll-cue-size)
    calc(var(--bsft-scroll-cue-size) * -1) var(--bsft-scroll-cue-color);
}

[data-bsft-nav-overflow="both"] {
  box-shadow:
    inset 0 var(--bsft-scroll-cue-size) var(--bsft-scroll-cue-size)
      calc(var(--bsft-scroll-cue-size) * -1) var(--bsft-scroll-cue-color),
    inset 0 calc(var(--bsft-scroll-cue-size) * -1) var(--bsft-scroll-cue-size)
      calc(var(--bsft-scroll-cue-size) * -1) var(--bsft-scroll-cue-color);
}

/* --- org scope -------------------------------------------------------------- */

.bsft-scope-switcher {
  display: inline-flex;
  align-items: center;
  gap: var(--bsft-spacing);
  font-family: var(--bsft-font);
}

.bsft-scope-option:focus-visible,
.bsft-scope-leave:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

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

/* The stack is fixed to a corner so the host can live anywhere in the shell markup.
   Only the toasts themselves take pointer events — an empty stack never covers the
   screen it floats over. */
.bsft-toasts {
  position: fixed;
  inset-block-end: var(--bsft-spacing);
  inset-inline-end: var(--bsft-spacing);
  z-index: var(--bsft-z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  pointer-events: none;
  font-family: var(--bsft-font);
}

.bsft-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--bsft-spacing);
  max-width: 24rem;
  padding: var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
}

.bsft-toast-message {
  flex: 1;
}

.bsft-toast-dismiss {
  all: unset;
  cursor: pointer;
  line-height: 1;
  font-size: 1.25em;
  color: inherit;
}

/* `all: unset` drops the user agent's focus ring with everything else, so it is put back
   here: the dismiss button is reachable by keyboard and must show where the focus is. */
.bsft-toast-dismiss:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* The notice Blazor shows once an error ended the page's connection (BsftCircuitErrorNotice). Hidden
   until Blazor's script sets display: block on it as an inline style; then a bar across the bottom of
   the viewport, above the toasts, in the colours of an error: the text colour on the danger surface,
   under a danger rule. The end padding keeps the text clear of the dismiss button in its corner. */
.bsft-circuit-error {
  display: none;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: calc(var(--bsft-z-toast) + 1);
  box-sizing: border-box;
  padding-block: calc(var(--bsft-spacing) * 1.5);
  padding-inline: calc(var(--bsft-spacing) * 2) calc(var(--bsft-touch-target) + var(--bsft-spacing));
  border-top: 3px solid var(--bsft-color-danger);
  background: var(--bsft-color-danger-surface);
  box-shadow: var(--bsft-shadow-3);
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
}

/* In the text colour, underlined and heavier: a link in the primary colour would need its own contrast
   against every danger surface a brand picks. */
.bsft-circuit-error-reload {
  margin-inline-start: var(--bsft-spacing);
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.bsft-circuit-error-reload:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.bsft-circuit-error-dismiss {
  all: unset;
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  display: inline-grid;
  place-items: center;
  width: var(--bsft-touch-target);
  height: var(--bsft-touch-target);
  cursor: pointer;
  color: inherit;
  font-size: 1.25em;
  line-height: 1;
}

/* Drawn inside the button, which sits in the corner of a bar that ends at the viewport's edge. */
.bsft-circuit-error-dismiss:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -4px;
}

.bsft-toast-info {
  color: var(--bsft-color-info);
  background: var(--bsft-color-info-surface);
  border-color: var(--bsft-color-info);
}

.bsft-toast-success {
  color: var(--bsft-color-success);
  background: var(--bsft-color-success-surface);
  border-color: var(--bsft-color-success);
}

.bsft-toast-warning {
  color: var(--bsft-color-warning);
  background: var(--bsft-color-warning-surface);
  border-color: var(--bsft-color-warning);
}

.bsft-toast-error {
  color: var(--bsft-color-danger);
  background: var(--bsft-color-danger-surface);
  border-color: var(--bsft-color-danger);
}

/* --- tabs ----------------------------------------------------------------- */

/* A strip wider than its container scrolls inside itself instead of widening the page, and every label
   stays on one line (a wrapped label made the tabs uneven and still overflowed at 375px). The ends that
   hide tabs carry the inner shadow the navigation draws (--bsft-scroll-cue-size and -color), driven by
   the strip's own scroll position, so nothing has to be scrolled to learn the strip goes on; a strip
   that fits, or a browser without scroll-driven animations, draws none, and the thin scrollbar is the
   cue there. The shadow follows the scroll position and does not move by itself, so the reduced-motion
   guard leaves it in place. */
@property --bsft-tabs-cue-start {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --bsft-tabs-cue-end {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@keyframes bsft-tabs-cue {
  from {
    --bsft-tabs-cue-start: 0px;
    --bsft-tabs-cue-end: var(--bsft-scroll-cue-size);
  }

  5% {
    --bsft-tabs-cue-start: var(--bsft-scroll-cue-size);
  }

  95% {
    --bsft-tabs-cue-end: var(--bsft-scroll-cue-size);
  }

  to {
    --bsft-tabs-cue-start: var(--bsft-scroll-cue-size);
    --bsft-tabs-cue-end: 0px;
  }
}

.bsft-tabs-list {
  /* 1 where the strip's start is its left edge, -1 where it is its right edge. */
  --bsft-tabs-cue-direction: 1;
  display: flex;
  gap: var(--bsft-spacing);
  border-bottom: 1px solid var(--bsft-color-border);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  box-shadow:
    inset calc(var(--bsft-tabs-cue-start) * var(--bsft-tabs-cue-direction)) 0 var(--bsft-tabs-cue-start)
      calc(var(--bsft-tabs-cue-start) * -1) var(--bsft-scroll-cue-color),
    inset calc(var(--bsft-tabs-cue-end) * var(--bsft-tabs-cue-direction) * -1) 0 var(--bsft-tabs-cue-end)
      calc(var(--bsft-tabs-cue-end) * -1) var(--bsft-scroll-cue-color);
}

/* Only where the scroll position can drive it: without a scroll timeline the animation would run once
   by time and leave the start cue on every strip. */
@supports (animation-timeline: scroll()) {
  .bsft-tabs-list {
    animation: bsft-tabs-cue linear both;
    animation-timeline: scroll(self inline);
  }
}

.bsft-tabs-list:dir(rtl) {
  --bsft-tabs-cue-direction: -1;
}

.bsft-tab {
  all: unset;
  flex: none;
  white-space: nowrap;
  cursor: pointer;
  padding: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  color: var(--bsft-color-muted);
  border-bottom: 2px solid transparent;
  font-family: var(--bsft-font);
  /* The room a selected tab brought into view keeps to the strip's edge, so the overflow cue never
     sits on its label. */
  scroll-margin-inline: var(--bsft-scroll-cue-size);
}

/* Drawn inside the tab: the strip is a scroll container, which clips a ring drawn outside it. */
.bsft-tab:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: -2px;
}

.bsft-tab-active {
  color: var(--bsft-color-text);
  border-bottom-color: var(--bsft-color-primary);
}

.bsft-tabs-panel {
  padding: calc(var(--bsft-spacing) * 2) 0;
}

/* --- dialog overlay --------------------------------------------------------- */

.bsft-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--bsft-z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--bsft-spacing);
  background: rgb(0 0 0 / 50%);
  font-family: var(--bsft-font);
}

.bsft-dialog-panel {
  max-width: 32rem;
  width: 100%;
  max-height: 100%;
  overflow: auto;
  padding: calc(var(--bsft-spacing) * 2);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
}

/* A confirmation's overlay is declared next to the control that asks (BsftConfirmDialog inside a
   table cell, a card footer, a toolbar), so it inherits that place's text settings although it is
   drawn over the whole page. The ones a cell or a toolbar typically sets are put back, so the
   question wraps and reads like any other dialog. */
.bsft-confirm-overlay {
  font-size: var(--bsft-font-size-md);
  font-weight: normal;
  font-style: normal;
  line-height: var(--bsft-line-height-normal);
  letter-spacing: normal;
  text-align: start;
  text-transform: none;
  white-space: normal;
  cursor: default;
}

/* The stacked host's own content. Every overlay of a stack carries the same --bsft-z-dialog
   layer deliberately: the newest is painted last because it is rendered last, which is what
   puts it on top among equally-layered siblings. A z-index computed per stack entry would be
   the one way a dialog could eventually climb over a toast, and the three layers above are a
   contract, not a suggestion. */
.bsft-dialog-title {
  margin: 0 0 var(--bsft-spacing);
  font-size: 1.125em;
}

.bsft-dialog-message {
  margin: 0 0 calc(var(--bsft-spacing) * 2);
}

/* --- info hint -------------------------------------------------------------- */

/* BsftInfoHint: an (i) beside a page or card title. The icon is 1em of the font the hint inherits
   (the text of the row it sits in, not the heading's; a class on the button that sets font-size
   resizes it). The wrapper is a flex container with line-height 0, so it holds no line box and no
   strut of its own. Its baseline is the icon's bottom edge, and in a line or a baseline-aligned
   row it takes 0.75em above the baseline and nothing below: the negative top margin gives back
   the icon's top quarter. A line height of 1 still leaves any common font more than 0.8em of
   ascent, so text at least as large as the hint's own reaches higher, and the hint never makes
   its line or its row taller. It is drawn 0.125em lower than it sits, by a relative offset that
   takes no room, so the icon centres on the text.

   The hit target is the ::before box, at least --bsft-target-size-min (24 CSS px) wide and high
   and centred on the icon; an absolutely positioned pseudo-element takes no room. The button's
   inline margins are at least half the difference between that box and the icon, so the box never
   reaches into the heading before it or a control after it. It stays 24 px under a coarse pointer
   too: a 44 px box would cover the heading and the controls beside a title.

   `all: unset` drops the user agent's button chrome and focus ring, so the ring is put back on
   :focus-visible. */
.bsft-info-hint {
  position: relative;
  inset-block-start: 0.125em;
  display: inline-flex;
  margin-block-start: -0.25em;
  line-height: 0;
}

.bsft-info-hint-button {
  all: unset;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 1em;
  block-size: 1em;
  margin-inline: max(0.25em, (var(--bsft-target-size-min) - 1em) / 2);
  border-radius: var(--bsft-radius-full);
  color: var(--bsft-color-muted);
  cursor: pointer;
}

.bsft-info-hint-button::before {
  content: "";
  position: absolute;
  inset: min(0px, (100% - var(--bsft-target-size-min)) / 2);
}

/* A heading and what sits beside it, such as an info hint, on one row that wraps when it runs out
   of room. The items share their first baseline, so a heading's margins (asymmetric ones
   included) do not move the icon, and the hint sits on the heading's baseline as it would in a
   line of text. */
.bsft-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.bsft-info-hint-button:hover,
.bsft-info-hint-button:focus-visible {
  color: var(--bsft-color-primary);
}

.bsft-info-hint-button:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-info-hint-icon {
  inline-size: 100%;
  block-size: 100%;
}

/* The dialog is declared beside a title, perhaps inside a heading, so it would inherit that
   place's text settings although it is drawn over the page. They are put back here, as on the
   confirmation's overlay. */
.bsft-info-hint-dialog {
  font-family: var(--bsft-font);
  font-size: var(--bsft-font-size-md);
  font-weight: normal;
  font-style: normal;
  line-height: var(--bsft-line-height-normal);
  letter-spacing: normal;
  text-align: start;
  text-transform: none;
  white-space: normal;
  cursor: default;
}

.bsft-info-hint-content {
  margin: 0 0 calc(var(--bsft-spacing) * 2);
}

.bsft-info-hint-content > :first-child {
  margin-block-start: 0;
}

.bsft-info-hint-content > :last-child {
  margin-block-end: 0;
}

/* The static fallback: the browser's own popover takes the panel's look. The user agent centres it
   in the top layer and hides it while closed; its border, backdrop and the spacing gutter it keeps
   from the viewport's edges (the overlay's padding, for the modal) are the theme's. */
.bsft-info-hint-popover {
  box-sizing: border-box;
  width: calc(100% - 2 * var(--bsft-spacing));
  max-height: calc(100% - 2 * var(--bsft-spacing));
  border: 1px solid var(--bsft-color-border);
  box-shadow: var(--bsft-shadow-3);
}

.bsft-info-hint-popover::backdrop {
  background: rgb(0 0 0 / 50%);
}

/* Without the popover API the panel would render inline beside the title and push the row apart;
   it stays hidden there, and the interactive dialog is unaffected. */
@supports not selector(:popover-open) {
  .bsft-info-hint-popover {
    display: none;
  }
}

/* --- toggle ----------------------------------------------------------------- */

.bsft-toggle {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  width: 2.5rem;
  height: 1.5rem;
  padding: 2px;
  border-radius: 999px;
  background: var(--bsft-color-border);
  transition: background-color var(--bsft-motion-fast) ease;
}

.bsft-toggle:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-toggle[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

.bsft-toggle-on {
  background: var(--bsft-color-primary);
}

.bsft-toggle-thumb {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: var(--bsft-color-surface);
  transition: transform var(--bsft-motion-fast) ease;
}

.bsft-toggle-on .bsft-toggle-thumb {
  transform: translateX(1rem);
}

/* --- wizard ----------------------------------------------------------------- */

.bsft-wizard-steps {
  display: flex;
  gap: calc(var(--bsft-spacing) * 2);
  list-style: none;
  padding: 0;
  margin: 0 0 calc(var(--bsft-spacing) * 2);
  font-family: var(--bsft-font);
}

.bsft-wizard-step {
  color: var(--bsft-color-muted);
}

.bsft-wizard-step-current {
  color: var(--bsft-color-text);
  font-weight: 600;
}

.bsft-wizard-step-completed {
  color: var(--bsft-color-text);
}

.bsft-wizard-step-invalid {
  color: var(--bsft-color-danger);
}

/* The reachable markers are buttons; they are styled back down to reading as part of the
   step list rather than as a control, because what they say is where the user is in a
   sequence and only secondarily that it can be jumped to. */

.bsft-wizard-step-link {
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.bsft-wizard-content {
  margin-bottom: calc(var(--bsft-spacing) * 2);
}

/* --- badge ----------------------------------------------------------------- */

.bsft-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  max-width: 100%;
  height: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  font-family: var(--bsft-font);
  font-size: var(--bsft-font-size-xs);
  line-height: 1;
  color: var(--bsft-color-text);
  background: var(--bsft-color-border);
}

/* The label is its own element: the pill is a flex container, and text directly in it is an
   anonymous flex item that text-overflow never reaches. Its line is the font's own height
   (line-height: normal) rather than the pill's 1: overflow: hidden, which the ellipsis needs, clips
   at the label's box, and a line of exactly 1em cut off the descenders of g, j, p, q and y. The pill
   keeps its fixed height, which that line fits inside. */
.bsft-badge-label {
  min-width: 0;
  line-height: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A dot has no text to carry the severity, so it is filled with the variant's strong colour (the
   badge's own text colour), not the pale surface tint behind a label, which is about 1.05:1 against
   a white page and fails the 3:1 a graphic needs. The variant rules below only set the colour and a
   background this selector's specificity outranks. */
.bsft-badge:empty {
  min-width: 0.5rem;
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  background: currentColor;
}

.bsft-badge-info {
  color: var(--bsft-color-info);
  background: var(--bsft-color-info-surface);
}

.bsft-badge-success {
  color: var(--bsft-color-success);
  background: var(--bsft-color-success-surface);
}

.bsft-badge-warning {
  color: var(--bsft-color-warning);
  background: var(--bsft-color-warning-surface);
}

.bsft-badge-danger {
  color: var(--bsft-color-danger);
  background: var(--bsft-color-danger-surface);
}

@keyframes bsft-badge-pulse {
  50% {
    opacity: 0.35;
    transform: scale(1.35);
  }
}

.bsft-badge-running {
  gap: calc(var(--bsft-spacing) / 2);
}

.bsft-badge-running-dot {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  animation: bsft-badge-pulse var(--bsft-motion-pulse) ease-in-out infinite;
}

/* --- choice list ----------------------------------------------------------------- */

.bsft-choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  font-family: var(--bsft-font);
}

.bsft-choice {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bsft-spacing);
  width: 100%;
  /* A full-width card at comfortable touch-target height: the option list is the mobile
     replacement for a native select whose options cannot carry a badge. */
  min-height: var(--bsft-touch-target);
  padding: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
}

.bsft-choice:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-choice[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

.bsft-choice-selected {
  border-color: var(--bsft-color-primary);
  /* An inset ring rather than a wider border, so selecting an option does not change its
     size and shift the cards below it. */
  box-shadow: inset 0 0 0 1px var(--bsft-color-primary);
}

.bsft-choice-text {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
  text-align: left;
}

.bsft-choice-description {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

.bsft-choice-badge {
  flex-shrink: 0;
}

/* --- combobox -------------------------------------------------------------------- */

.bsft-combobox {
  /* The popup is positioned against this wrapper rather than the input, so the chip row above
     the input never shifts it out from under the control it belongs to. */
  position: relative;
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
  font-family: var(--bsft-font);
}

.bsft-combobox-input {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--bsft-touch-target);
  padding: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
}

.bsft-combobox-input:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-combobox-chips {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--bsft-spacing) / 2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.bsft-combobox-chip {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
}

.bsft-combobox-chip-remove {
  all: unset;
  cursor: pointer;
  color: var(--bsft-color-muted);
  line-height: 1;
}

.bsft-combobox-chip-remove:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-combobox-listbox {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  /* The popup floats over the content under it and must stay below a modal and the toasts —
     the one ordered contract the three layer tokens carry. */
  z-index: var(--bsft-z-popup);
  max-height: 16rem;
  overflow-y: auto;
  margin: calc(var(--bsft-spacing) / 2) 0 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
}

.bsft-combobox-option {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
  min-height: var(--bsft-touch-target);
  padding: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  cursor: pointer;
  color: var(--bsft-color-text);
}

.bsft-combobox-option-active {
  /* Where the keyboard is, not what is chosen: the two states are styled apart because they
     mean different things and can be true of two different rows at once. */
  background: var(--bsft-color-info-surface);
}

.bsft-combobox-option-selected {
  border-left: 2px solid var(--bsft-color-primary);
}

.bsft-combobox-option[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}

.bsft-combobox-option-description {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

.bsft-combobox-create {
  color: var(--bsft-color-primary);
}

/* --- picker -------------------------------------------------------------------- */

/* The picker is the combobox with a pin button beside each option, so it reads the combobox's own
   rules for the input, the popup and the options. A row holds the option and its pin side by side;
   the option takes the room, the pin keeps its touch target. */
.bsft-picker-row {
  display: flex;
  align-items: stretch;
}

.bsft-picker-row .bsft-combobox-option {
  flex: 1 1 auto;
  min-width: 0;
}

.bsft-picker-group {
  padding: var(--bsft-spacing) calc(var(--bsft-spacing) * 2) calc(var(--bsft-spacing) / 2);
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
}

.bsft-picker-group-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The pin is a pointer affordance, not a control: it is out of the tab order and hidden from
   assistive technology, since the keyboard pins with Alt+Enter on the active option. */
.bsft-picker-pin {
  box-sizing: border-box;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: var(--bsft-touch-target);
  min-height: var(--bsft-touch-target);
  cursor: pointer;
  color: var(--bsft-color-muted);
}

.bsft-picker-pin svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.bsft-picker-pin-active {
  color: var(--bsft-color-primary);
}

.bsft-picker-pin-active svg {
  fill: currentColor;
}

/* The clear button (AllowClear) sits over the right end of the input, where the input leaves room
   for it, and keeps the touch target. It is a real button in the tab order. */
.bsft-picker {
  position: relative;
}

.bsft-picker:has(.bsft-picker-clear) .bsft-combobox-input {
  padding-inline-end: var(--bsft-touch-target);
}

.bsft-picker-clear {
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--bsft-touch-target);
  min-height: var(--bsft-touch-target);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bsft-color-muted);
  font: inherit;
  cursor: pointer;
}

.bsft-picker-clear:hover {
  color: var(--bsft-color-text);
}

.bsft-picker-clear:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: -2px;
}

/* --- action button ------------------------------------------------------------------- */

.bsft-action {
  /* The containing block of .bsft-action-progress, which is absolutely positioned: without it the
     status region resolves against a distant ancestor, escapes any overflow scroller and widens the page. */
  position: relative;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bsft-spacing);
  font-family: var(--bsft-font);
}

.bsft-action-button {
  display: inline-flex;
  align-items: center;
  gap: var(--bsft-spacing);
  min-height: var(--bsft-button-height);
  padding: 0 calc(var(--bsft-spacing) * 2);
  border: 1px solid transparent;
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-success);
  color: var(--bsft-color-success-contrast);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.bsft-action-button:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* The Secondary and Danger variants restate the surfaces of .bsft-button and .bsft-button-danger from
   the same tokens instead of joining those rules: the action button's own rule above comes later in
   the file at the same specificity and would win over them. The tokens carry the dark theme. */
.bsft-action-button-secondary {
  background: var(--bsft-color-surface);
  border-color: var(--bsft-color-border);
  color: var(--bsft-color-text);
}

.bsft-action-button-danger {
  background: var(--bsft-color-danger);
  border-color: var(--bsft-color-danger);
  color: var(--bsft-color-danger-contrast);
}

/* The hover of .bsft-button and .bsft-button-danger, on an action that can be started. */
.bsft-action-button-secondary:hover:not([aria-disabled="true"]) {
  border-color: var(--bsft-color-primary);
}

.bsft-action-button-danger:hover:not([aria-disabled="true"]) {
  background: color-mix(in srgb, var(--bsft-color-danger) 85%, var(--bsft-color-text));
}

/* Stronger than a variant (two classes' worth), so every disabled action reads alike; the border goes
   too, or a disabled Danger action would keep a red outline. */
.bsft-action-button:is(:disabled, [aria-disabled="true"]) {
  border-color: transparent;
  background: var(--bsft-color-border);
  color: var(--bsft-color-action-disabled-text);
  cursor: not-allowed;
}

.bsft-action-icon {
  width: 0.8rem;
  height: 0.8rem;
  fill: currentColor;
}

/* The caller's glyph (BsftActionButton.Icon) is one flex item of the button, centred at the button's
   gap like the ▶ it replaces. An svg the host left unsized would otherwise take the 300 x 150 px
   default and stretch the button. Only a dimension the svg does not state itself is set, since a
   presentation attribute (width="20") loses to any rule; :where() keeps it at zero specificity, so a
   host rule on the icon wins too. */
.bsft-action-icon-slot {
  display: inline-flex;
  flex: none;
  align-items: center;
}

:where(.bsft-action-icon-slot > svg:not([width])) {
  width: 1em;
}

:where(.bsft-action-icon-slot > svg:not([height])) {
  height: 1em;
}

.bsft-action-note,
.bsft-action-progress,
.bsft-action-result,
.bsft-action-error {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: var(--bsft-font-size-sm);
}

.bsft-action-note {
  color: var(--bsft-color-muted);
}

.bsft-action-progress {
  display: inline-flex;
  align-items: center;
  gap: var(--bsft-spacing);
}

/* The status region is always in the DOM and in the accessibility tree so its text is announced; empty, it is
   visually hidden and takes no room. Never display:none: a region that appears already filled is not announced. */
.bsft-action-progress:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.bsft-action-error {
  color: var(--bsft-color-danger);
}

.bsft-action-command {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.bsft-action-detail {
  display: block;
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

/* --- freshness chip ------------------------------------------------------------------ */

.bsft-freshness {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  padding: calc(var(--bsft-spacing) / 4) var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius-full);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font-size: var(--bsft-font-size-xs);
  white-space: nowrap;
}

.bsft-freshness-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--bsft-radius-full);
  background: var(--bsft-color-muted);
}

.bsft-freshness-live .bsft-freshness-dot,
.bsft-freshness-fresh .bsft-freshness-dot {
  background: var(--bsft-color-success);
}

.bsft-freshness-stale {
  border-color: var(--bsft-color-warning);
  background: var(--bsft-color-warning-surface);
  color: var(--bsft-color-warning);
}

.bsft-freshness-stale .bsft-freshness-dot {
  background: var(--bsft-color-warning);
}

.bsft-freshness-flag {
  font-weight: 600;
}

/* --- ide link ------------------------------------------------------------------------ */

.bsft-ide-link {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--bsft-font-size-sm);
  overflow-wrap: anywhere;
}

/* --- empty state ----------------------------------------------------------------- */

.bsft-empty-state {
  padding: calc(var(--bsft-spacing) * 4) var(--bsft-spacing);
  text-align: center;
  color: var(--bsft-color-muted);
  font-family: var(--bsft-font);
}

.bsft-empty-state-title {
  margin: 0;
  color: var(--bsft-color-text);
  font-weight: 600;
}

.bsft-empty-state-description {
  margin: calc(var(--bsft-spacing) / 2) 0 0;
}

.bsft-empty-state-actions {
  margin-top: calc(var(--bsft-spacing) * 2);
}

/* --- scroll region ----------------------------------------------------------------- */

/* The transcript container. Its height is the surrounding layout's to give — a scroll region
   only scrolls once something bounds it — and overscroll containment keeps a reader flicking
   through the transcript from dragging the page behind it along. */
.bsft-scroll-region {
  overflow-y: auto;
  overscroll-behavior: contain;
  /* The region keeps the reading position itself, in its browser module, so it behaves the same
     in every browser. Chrome's own scroll anchoring would compensate a second time on top of
     that; iOS Safari has none at all. One mechanism, not two. */
  overflow-anchor: none;
}

/* --- file transfer ----------------------------------------------------------------- */

/* --- progress meter ---------------------------------------------------------------- */

.bsft-progress-meter-label {
  margin-bottom: calc(var(--bsft-spacing) / 2);
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
  font-size: var(--bsft-font-size-sm);
}

.bsft-progress-meter {
  height: 0.5rem;
  overflow: hidden;
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-border);
}

.bsft-progress-meter-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--bsft-color-primary);
  transition: width var(--bsft-motion-fast) ease;
}

.bsft-progress-meter-success .bsft-progress-meter-bar {
  background: var(--bsft-color-success);
}

.bsft-progress-meter-warning .bsft-progress-meter-bar {
  background: var(--bsft-color-warning);
}

.bsft-progress-meter-danger .bsft-progress-meter-bar {
  background: var(--bsft-color-danger);
}

.bsft-progress-meter-info .bsft-progress-meter-bar {
  background: var(--bsft-color-info);
}

@keyframes bsft-progress-indeterminate {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(250%);
  }
}

.bsft-progress-meter-indeterminate .bsft-progress-meter-bar {
  width: 40%;
  animation: bsft-progress-indeterminate var(--bsft-motion-pulse) ease-in-out infinite;
}

.bsft-file-upload {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
}

/* The track under the moving bar; the width of the bar is written inline per render,
   because it is state (the bytes sent), not style. */
.bsft-file-upload-progress {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--bsft-color-border);
  overflow: hidden;
}

.bsft-file-upload-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--bsft-color-primary);
  transition: width var(--bsft-motion-fast) ease;
}

.bsft-file-upload-cancel,
.bsft-file-download-button {
  align-self: flex-start;
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  cursor: pointer;
}

.bsft-file-upload-cancel:hover,
.bsft-file-download-button:hover {
  border-color: var(--bsft-color-primary);
}

.bsft-file-download-button[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

.bsft-file-download {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
}

/* --- dashboard --------------------------------------------------------------- */

.bsft-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: calc(var(--bsft-spacing) * 2);
  font-family: var(--bsft-font);
}

.bsft-dashboard-widget {
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  padding: calc(var(--bsft-spacing) * 2);
}

.bsft-dashboard-widget-title {
  margin: 0 0 var(--bsft-spacing);
  font-size: var(--bsft-font-size-md);
  color: var(--bsft-color-text);
}

/* --- metric tile ------------------------------------------------------------------- */

/* position: relative anchors the visually hidden description (absolutely positioned) to the tile, so it
   never lands against a distant positioned ancestor or widens a scrolling container. It sets no offset and
   no z-index, so the tile itself does not move and opens no stacking context. */
.bsft-metric-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  box-sizing: border-box;
  min-width: 0;
  padding: calc(var(--bsft-spacing) * 2);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
}

/* A tile that is a link: the anchor is the tile, so the link chrome is removed. */
a.bsft-metric-tile-link {
  color: var(--bsft-color-text);
  text-decoration: none;
}

/* The hover cue is a ring outside the border, so the status colour a variant gives the border stays
   visible while the pointer is over the tile. */
a.bsft-metric-tile-link:hover {
  box-shadow: 0 0 0 1px var(--bsft-color-primary);
}

a.bsft-metric-tile-link:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-metric-tile-label,
.bsft-metric-tile-subtext {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

.bsft-metric-tile-value {
  overflow-wrap: anywhere;
  font-size: var(--bsft-font-size-3xl);
  font-weight: 600;
  line-height: 1.1;
}

.bsft-metric-tile-primary {
  border-color: var(--bsft-color-primary);
}

.bsft-metric-tile-success {
  border-color: var(--bsft-color-success);
}

.bsft-metric-tile-warning {
  border-color: var(--bsft-color-warning);
}

.bsft-metric-tile-danger {
  border-color: var(--bsft-color-danger);
}

.bsft-metric-tile-info {
  border-color: var(--bsft-color-info);
}

.bsft-metric-tile-emphasized.bsft-metric-tile-primary {
  background: var(--bsft-color-primary-surface);
}

.bsft-metric-tile-emphasized.bsft-metric-tile-success {
  background: var(--bsft-color-success-surface);
}

.bsft-metric-tile-emphasized.bsft-metric-tile-warning {
  background: var(--bsft-color-warning-surface);
}

.bsft-metric-tile-emphasized.bsft-metric-tile-danger {
  background: var(--bsft-color-danger-surface);
}

.bsft-metric-tile-emphasized.bsft-metric-tile-info {
  background: var(--bsft-color-info-surface);
}

/* --- date and time pickers ------------------------------------------------------- */

/* The three pickers share a shape: a row holding the text input (or two of them) and the popup
   trigger, with the popup itself positioned by the popover rules above. Only the panel's
   contents differ — a month grid for the two date pickers, a listbox for the time picker — which
   is why the grid is styled once here and rendered by one component. */

.bsft-datepicker,
.bsft-daterangepicker,
.bsft-timepicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  font-family: var(--bsft-font);
}

.bsft-datepicker-input,
.bsft-daterangepicker-input,
.bsft-timepicker-input {
  box-sizing: border-box;
  min-height: var(--bsft-touch-target);
  padding: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
}

.bsft-datepicker-input:focus-visible,
.bsft-daterangepicker-input:focus-visible,
.bsft-timepicker-input:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* The refusal is the input's own border as well as the message under it: a colour alone would
   be the only thing distinguishing a rejected date, and the message carries the rest. */
.bsft-datepicker-input[aria-invalid="true"],
.bsft-daterangepicker-input[aria-invalid="true"],
.bsft-timepicker-input[aria-invalid="true"] {
  border-color: var(--bsft-color-danger);
}

.bsft-datepicker-error,
.bsft-daterangepicker-error,
.bsft-timepicker-error {
  flex-basis: 100%;
  color: var(--bsft-color-danger);
  font-size: var(--bsft-font-size-sm);
}

/* Each end of a range is a captioned field of its own, stacked so the caption sits above the
   input it names rather than beside it. */
.bsft-daterangepicker-field {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
}

.bsft-daterangepicker-field label {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

/* --- the month grid --------------------------------------------------------------- */

.bsft-calendar {
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  min-width: 18rem;
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

.bsft-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bsft-spacing);
}

.bsft-calendar-heading {
  font-weight: 600;
}

.bsft-calendar-page {
  all: unset;
  min-width: 2rem;
  padding: calc(var(--bsft-spacing) / 2);
  border-radius: var(--bsft-radius);
  cursor: pointer;
  text-align: center;
  color: var(--bsft-color-text);
}

.bsft-calendar-page:focus-visible {
  /* `all: unset` drops the user agent's focus ring, so the visible focus is stated here. */
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-calendar-grid {
  border-collapse: collapse;
  width: 100%;
}

.bsft-calendar-weekday {
  padding: calc(var(--bsft-spacing) / 2);
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
  font-weight: 500;
}

.bsft-calendar-day {
  padding: calc(var(--bsft-spacing) / 2);
  border-radius: var(--bsft-radius);
  cursor: pointer;
  text-align: center;
}

.bsft-calendar-day:focus-visible {
  /* The cell itself is the focusable element of the grid pattern, so the ring goes on the cell
     and not on a control inside it. */
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: -2px;
}

/* The leading and trailing days of the grid are real, selectable dates rather than padding, so
   they are dimmed rather than hidden. */
.bsft-calendar-day-outside {
  color: var(--bsft-color-muted);
}

/* Today is marked with a ring rather than a fill, so it stays legible under the selection fill
   when the two land on the same cell. */
.bsft-calendar-day-today {
  box-shadow: inset 0 0 0 1px var(--bsft-color-primary);
}

.bsft-calendar-day-selected {
  background: var(--bsft-color-primary);
  color: var(--bsft-color-primary-contrast);
}

/* The inset primary ring of a focused cell disappears into the selection fill (1:1). A second ring
   inside it, in the fill's contrast colour, carries the focus on the fill, while the primary ring
   keeps its edge against the surface around the cell: the two-tone ring a filled selection needs
   wherever an outward ring would be clipped. The tree's selected row draws the same. */
.bsft-calendar-day-selected:focus-visible {
  box-shadow: inset 0 0 0 4px var(--bsft-color-primary-contrast);
}

/* Everything between a range's ends, the ends themselves excluded — they carry the selection
   fill above, and this is the weaker surface that joins them up. It is also what the
   provisional span is painted with while the pointer is choosing the second end, so the user
   sees what the next click produces before making it. */
.bsft-calendar-day-inrange {
  background: var(--bsft-color-info-surface);
}

/* A cell outside the window is still announced and still a date; what it is not is choosable,
   and a td has no native disabled attribute to lean on. */
.bsft-calendar-day[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}

/* --- the time list ---------------------------------------------------------------- */

.bsft-timepicker-listbox {
  max-height: 16rem;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bsft-timepicker-option {
  min-height: var(--bsft-touch-target);
  display: flex;
  align-items: center;
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  cursor: pointer;
  color: var(--bsft-color-text);
}

.bsft-timepicker-option-active {
  /* Where the keyboard is, not what is chosen: the two states are styled apart because they
     mean different things and can be true of two different rows at once. */
  background: var(--bsft-color-info-surface);
}

.bsft-timepicker-option-selected {
  border-left: 2px solid var(--bsft-color-primary);
}

/* --- tree --------------------------------------------------------------------- */

.bsft-tree {
  /* How far one level indents, as a token of the tree's own. BsftTree writes only the level
     number onto a row (--bsft-tree-level); the length that number is multiplied by belongs to
     the theme, so a host restyles the whole hierarchy by overriding this one value instead of
     the markup carrying a computed padding no stylesheet can reach. */
  --bsft-tree-indent: calc(var(--bsft-spacing) * 1.5);
  display: flex;
  flex-direction: column;
  font-family: var(--bsft-font);
}

.bsft-tree-item {
  display: flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  /* Logical rather than left, so a right-to-left document indents from the side it reads from.
     It follows the shorthand above deliberately: the shorthand sets the block padding and the
     inline end, and this overrides the one side that carries the depth. */
  padding-inline-start: calc(var(--bsft-tree-level, 1) * var(--bsft-tree-indent));
  border-radius: var(--bsft-radius);
  color: var(--bsft-color-text);
  cursor: pointer;
}

.bsft-tree-item:focus-visible {
  /* Inset, because a row spans the tree's full width and an outward ring would be clipped by
     the container that scrolls it. */
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: -2px;
}

.bsft-tree-selected {
  background: var(--bsft-color-primary);
  color: var(--bsft-color-primary-contrast);
}

/* The two-tone ring of a focused selection, as on the calendar's selected day. */
.bsft-tree-selected:focus-visible {
  box-shadow: inset 0 0 0 4px var(--bsft-color-primary-contrast);
}

.bsft-tree-twisty {
  display: inline-block;
  flex: none;
  width: 1em;
  text-align: center;
  transition: transform var(--bsft-motion-fast) ease-in-out;
}

.bsft-tree-twisty::before {
  content: "\25B8";
}

.bsft-tree-item[aria-expanded="true"] > .bsft-tree-twisty {
  transform: rotate(90deg);
}

.bsft-tree-item[aria-busy="true"] > .bsft-tree-twisty {
  opacity: 0.5;
}

.bsft-tree-label {
  /* A flex item refuses to shrink below its content by default, which is what makes a long node
     name push the row wider than the tree instead of wrapping inside it. */
  min-width: 0;
  overflow-wrap: anywhere;
}

/* --- split panes ------------------------------------------------------------------ */

/* Positioned, because the surface a pointer drag runs on is an absolutely placed child of this
   element and has to cover exactly the split and nothing else. */
.bsft-split {
  position: relative;
  display: flex;
  align-items: stretch;
  min-height: 0;
}

/* A drag that crosses two panes would otherwise paint a text selection behind the divider, which
   reads as the page breaking rather than as a pane resizing. */
.bsft-split[data-bsft-split-drag="true"] {
  user-select: none;
}

/* The basis is the separator's announced value applied verbatim: no max-width, no percentage
   ceiling and no shrinking, because a divider whose aria-valuenow says something other than what
   is on screen is worse than a pane somebody made too narrow. The range is the caller's
   MinPosition/MaxPosition and is enforced there, once. */
.bsft-split-primary {
  flex: 0 0 var(--bsft-split-basis, 20rem);
  min-width: 0;
  overflow: auto;
}

.bsft-split-secondary {
  flex: 1 1 0;
  min-width: 0;
  overflow: auto;
}

/* touch-action is load-bearing rather than cosmetic: without it a touch pointer on the divider is
   claimed by the browser's own panning and the component never sees a pointermove at all. */
.bsft-split-divider {
  flex: 0 0 auto;
  inline-size: 0.375rem;
  cursor: col-resize;
  background: var(--bsft-color-border);
  touch-action: none;
}

.bsft-split-divider:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 1px;
}

/* Only on screen while a gesture is in flight. It sits above the panes so every move lands on one
   element, and below the floating layers so a dialog opened over a split still covers it. */
.bsft-split-drag-surface {
  position: absolute;
  inset: 0;
  z-index: calc(var(--bsft-z-popup) - 1);
  cursor: col-resize;
}

.bsft-split-swap {
  align-self: flex-start;
  padding: var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  cursor: pointer;
}

.bsft-split-swap:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* --- visualization primitives ---------------------------------------------------- */

.bsft-segmented-bar,
.bsft-phase-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
}

.bsft-segmented-bar-track,
.bsft-phase-timeline-track {
  display: flex;
  width: 100%;
  min-height: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
}

.bsft-segmented-bar-segment {
  flex: 0 0 auto;
  min-width: 0;
}

.bsft-visual-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
}

.bsft-visual-legend li {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
}

.bsft-visual-legend-swatch {
  width: 0.75rem;
  height: 0.75rem;
  flex: 0 0 auto;
  border-radius: calc(var(--bsft-radius) / 2);
}

.bsft-visual-legend-value {
  color: var(--bsft-color-muted);
}

.bsft-visual-neutral {
  background: var(--bsft-color-muted);
}

.bsft-visual-primary {
  background: var(--bsft-color-primary);
}

.bsft-visual-info {
  background: var(--bsft-color-info);
}

.bsft-visual-success {
  background: var(--bsft-color-success);
}

.bsft-visual-warning {
  background: var(--bsft-color-warning);
}

.bsft-visual-danger {
  background: var(--bsft-color-danger);
}

@keyframes bsft-visual-pulse {
  50% {
    opacity: 0.55;
  }
}

.bsft-phase-timeline-running {
  animation: bsft-visual-pulse var(--bsft-motion-pulse) ease-in-out infinite;
}

.bsft-sparkline {
  display: block;
  max-width: 100%;
  overflow: visible;
}

.bsft-sparkline-line {
  stroke: var(--bsft-color-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.bsft-sparkline-threshold {
  stroke: var(--bsft-color-warning);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

/* --- event timeline ---------------------------------------------------------------- */

.bsft-event-timeline {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
}

/* One column that never scrolls sideways: the marker has a fixed width, the body takes the rest and
   breaks long titles, and the connecting line is the item's own pseudo-element, so it follows the
   item's height however much the text wraps. */
.bsft-event-timeline-item {
  position: relative;
  display: flex;
  gap: calc(var(--bsft-spacing) * 1.5);
  padding-bottom: calc(var(--bsft-spacing) * 2);
  min-width: 0;
}

.bsft-event-timeline-item:last-child {
  padding-bottom: 0;
}

.bsft-event-timeline-item::before {
  content: "";
  position: absolute;
  inset-block: 1.125rem 0;
  inset-inline-start: calc(0.375rem - 1px);
  width: 2px;
  background: var(--bsft-color-border);
}

.bsft-event-timeline-item:last-child::before {
  display: none;
}

.bsft-event-timeline-marker {
  flex: 0 0 auto;
  width: 0.75rem;
  height: 0.75rem;
  margin-top: 0.25rem;
  border-radius: 50%;
}

.bsft-event-timeline-body {
  flex: 1 1 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.bsft-event-timeline-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
}

.bsft-event-timeline-time {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-xs);
}

.bsft-event-timeline-state {
  height: auto;
  min-height: 1.25rem;
  padding-block: 0.125rem;
  line-height: 1.2;
}

.bsft-event-timeline-title {
  margin-top: calc(var(--bsft-spacing) / 2);
  font-weight: 600;
}

.bsft-event-timeline-title a {
  color: var(--bsft-color-primary);
}

.bsft-event-timeline-title a:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-event-timeline-description {
  margin: calc(var(--bsft-spacing) / 2) 0 0;
  color: var(--bsft-color-muted);
}

/* --- status dot strip --------------------------------------------------------------- */

/* The strip is the positioning context of every tooltip, which hangs below it at its own width at
   most: a tooltip anchored to a dot near the right edge would run past a 375 px viewport and make
   the page scroll sideways. Dots wrap onto further lines instead of scrolling. */
.bsft-status-dot-strip {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  width: fit-content;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
}

.bsft-status-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--bsft-radius);
}

.bsft-status-dot:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: -2px;
}

.bsft-status-dot-glyph {
  display: block;
  width: 0.75rem;
  height: 0.75rem;
}

/* The shape carries the state next to the color, so a reader who cannot tell the colors apart still
   can tell a failure from a pass. The double class outweighs the shared color classes, which set a
   background. */
.bsft-status-dot-glyph.bsft-status-dot-shape-circle {
  border-radius: 50%;
}

.bsft-status-dot-glyph.bsft-status-dot-shape-ring {
  box-sizing: border-box;
  border: 2px solid var(--bsft-color-muted);
  border-radius: 50%;
  background: transparent;
}

.bsft-status-dot-glyph.bsft-status-dot-shape-diamond {
  transform: rotate(45deg) scale(0.85);
}

.bsft-status-dot-glyph.bsft-status-dot-shape-square {
  border-radius: 1px;
}

.bsft-status-dot-glyph.bsft-status-dot-shape-triangle {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.bsft-status-dot-tooltip {
  position: absolute;
  inset-block-start: 100%;
  inset-inline-start: 0;
  z-index: var(--bsft-z-popup);
  display: none;
  box-sizing: border-box;
  width: max-content;
  max-width: 100%;
  margin-top: calc(var(--bsft-spacing) / 2);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font-size: var(--bsft-font-size-xs);
  overflow-wrap: anywhere;
}

.bsft-status-dot-strip-item:hover > .bsft-status-dot-tooltip,
.bsft-status-dot-strip-item:focus-within > .bsft-status-dot-tooltip {
  display: block;
}

.bsft-status-dot-tooltip-detail {
  display: block;
  color: var(--bsft-color-muted);
}

/* --- charts ----------------------------------------------------------------------- */

.bsft-line-chart,
.bsft-day-bars,
.bsft-bar-table {
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  min-width: 0;
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
}

/* The series color of a chart: one custom property per series class, read by the line, the point,
   the bar segment and the legend swatch alike, so a series cannot be drawn in two colors. */
/* The fallback comes first: it and the palette classes share one element and one specificity. */
.bsft-line-chart-series {
  --bsft-chart-color: var(--bsft-color-muted);
}

.bsft-chart-series-1 { --bsft-chart-color: var(--bsft-chart-1); }
.bsft-chart-series-2 { --bsft-chart-color: var(--bsft-chart-2); }
.bsft-chart-series-3 { --bsft-chart-color: var(--bsft-chart-3); }
.bsft-chart-series-4 { --bsft-chart-color: var(--bsft-chart-4); }
.bsft-chart-series-5 { --bsft-chart-color: var(--bsft-chart-5); }
.bsft-chart-series-6 { --bsft-chart-color: var(--bsft-chart-6); }
.bsft-chart-series-7 { --bsft-chart-color: var(--bsft-chart-7); }
.bsft-chart-series-8 { --bsft-chart-color: var(--bsft-chart-8); }

.bsft-visual-legend-swatch[class*="bsft-chart-series-"],
.bsft-day-bars-segment[class*="bsft-chart-series-"],
.bsft-bar-table-fill[class*="bsft-chart-series-"] {
  background: var(--bsft-chart-color);
}

.bsft-line-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.bsft-line-chart-grid {
  stroke: var(--bsft-color-border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.bsft-line-chart-tick,
.bsft-line-chart-label {
  fill: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-2xs);
  font-family: var(--bsft-font);
}

/* Danger red is outside the categorical palette, so the limit never looks like a series. */
.bsft-line-chart-threshold {
  stroke: var(--bsft-color-danger);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.bsft-line-chart-series.bsft-visual-primary { --bsft-chart-color: var(--bsft-color-primary); }
.bsft-line-chart-series.bsft-visual-info { --bsft-chart-color: var(--bsft-color-info); }
.bsft-line-chart-series.bsft-visual-success { --bsft-chart-color: var(--bsft-color-success); }
.bsft-line-chart-series.bsft-visual-warning { --bsft-chart-color: var(--bsft-color-warning); }
.bsft-line-chart-series.bsft-visual-danger { --bsft-chart-color: var(--bsft-color-danger); }

.bsft-line-chart-line {
  stroke: var(--bsft-chart-color);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.bsft-chart-series-repeat .bsft-line-chart-line {
  stroke-dasharray: 6 3;
}

.bsft-line-chart-point {
  fill: var(--bsft-chart-color);
}

.bsft-day-bars-chart {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 10rem;
  overflow-x: auto;
  /* The baseline sits on top of the label strip, under the bars. */
  background: linear-gradient(var(--bsft-color-border), var(--bsft-color-border))
    0 calc(100% - 1.25rem) / 100% 1px no-repeat;
}

.bsft-day-bars-day {
  position: relative;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0 0 1.25rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
}

/* A touchable day is at least 24 px wide (WCAG 2.5.8); the chart scrolls when that does not fit. */
.bsft-day-bars-interactive .bsft-day-bars-day {
  flex: 1 0 1.5rem;
}

button.bsft-day-bars-day {
  cursor: pointer;
}

button.bsft-day-bars-day:hover .bsft-day-bars-track {
  background: var(--bsft-color-skeleton);
}

.bsft-day-bars-day:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 1px;
}

.bsft-day-bars-track {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
}

.bsft-day-bars-stack {
  display: flex;
  flex-direction: column-reverse;
}

.bsft-day-bars-segment {
  flex: 1 1 0;
  min-height: 1px;
}

.bsft-day-bars-label {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-2xs);
  white-space: nowrap;
}

.bsft-day-bars-label-start {
  left: 0;
  transform: none;
}

.bsft-day-bars-label-end {
  right: 0;
  left: auto;
  transform: none;
}

.bsft-chart-table {
  max-width: 100%;
  overflow-x: auto;
}

.bsft-chart-table > summary {
  cursor: pointer;
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-xs);
}

.bsft-chart-table table {
  border-collapse: collapse;
  font-size: var(--bsft-font-size-xs);
}

.bsft-chart-table th,
.bsft-chart-table td {
  padding: 0.125rem var(--bsft-spacing);
  border-bottom: 1px solid var(--bsft-color-border);
  text-align: right;
  white-space: nowrap;
}

.bsft-chart-table th:first-child {
  text-align: left;
}

.bsft-bar-table {
  overflow-x: auto;
}

.bsft-bar-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--bsft-font-size-sm);
}

.bsft-bar-table th,
.bsft-bar-table td {
  padding: 0.25rem var(--bsft-spacing);
  border-bottom: 1px solid var(--bsft-color-border);
  text-align: left;
  vertical-align: middle;
}

.bsft-bar-table thead th {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-xs);
  font-weight: 600;
}

.bsft-bar-table tbody th {
  font-weight: 400;
}

/* A width limit on a table cell is ignored by the automatic table layout, so the limit sits on
   the block inside the cell. */
.bsft-bar-table-label-text {
  display: block;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bsft-bar-table-bar {
  display: block;
  width: 8rem;
  height: 0.5rem;
  margin-bottom: 0.125rem;
  overflow: hidden;
  border-radius: var(--bsft-radius-full);
  background: var(--bsft-color-skeleton);
}

.bsft-bar-table-fill {
  display: block;
  height: 100%;
}

.bsft-bar-table-number {
  font-variant-numeric: tabular-nums;
}

.bsft-bar-table .bsft-bar-table-extra {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bsft-bar-table-more td {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-xs);
}

@media (max-width: 24rem) {
  .bsft-bar-table-label-text {
    max-width: 8rem;
  }

  .bsft-bar-table-bar {
    width: 4rem;
  }
}

/* --- graph ------------------------------------------------------------------------ */

/* The graph renderer's palette and surfaces. They are declared on the graph, not on :root, so a
   host that re-skins a region (its own --bsft-color-* on a container) reaches the graphs inside it
   as well; the dark theme comes through the tokens they name, so no dark twin is declared. A node
   is coloured by the five biggest groups, the rest share the muted "other" slot. The neutral
   outline and the edges are the muted text colour, which keeps them at 3:1 or better against the
   canvas in both themes (edges at 85 % opacity: 3.6:1 light, 5.4:1 dark). */
.bsft-graph {
  --bsft-graph-group-1: var(--bsft-chart-1);
  --bsft-graph-group-2: var(--bsft-chart-2);
  --bsft-graph-group-3: var(--bsft-chart-3);
  --bsft-graph-group-4: var(--bsft-chart-4);
  --bsft-graph-group-5: var(--bsft-chart-5);
  --bsft-graph-group-other: var(--bsft-color-muted);
  --bsft-graph-node-fill: var(--bsft-color-surface);
  --bsft-graph-node-stroke: var(--bsft-color-muted);
  --bsft-graph-edge: var(--bsft-color-muted);
  --bsft-graph-edge-highlight: var(--bsft-color-primary);
  --bsft-graph-edge-danger: var(--bsft-color-danger);
  --bsft-graph-canvas: var(--bsft-color-surface);
  --bsft-graph-edge-opacity: 0.85;
  --bsft-graph-dim-node-opacity: 0.25;
  --bsft-graph-dim-edge-opacity: 0.12;
}

.bsft-graph {
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  min-width: 0;
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
}

.bsft-graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
}

.bsft-graph-presentation-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  min-height: var(--bsft-touch-target);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: 999px;
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.bsft-graph-presentation-toggle:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* One column; the side panel stacks under the canvas. The column is minmax(0, 1fr) so a wide
   drawing scrolls inside its canvas instead of stretching the page. From 48rem a body with a side
   panel wraps instead; see the end of the graph section. */
.bsft-graph-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: calc(var(--bsft-spacing) * 2);
}


.bsft-graph-canvas {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-graph-canvas);
}

.bsft-graph-svg {
  display: block;
  width: 100%;
  height: auto;
}

.bsft-graph-backdrop {
  fill: transparent;
}

.bsft-graph-edge {
  fill: none;
  stroke: var(--bsft-graph-edge);
  opacity: var(--bsft-graph-edge-opacity);
  vector-effect: non-scaling-stroke;
  transition: opacity var(--bsft-motion-fast) ease;
}

.bsft-graph-edge-hl {
  stroke: var(--bsft-graph-edge-highlight);
  opacity: 1;
}

.bsft-graph-edge-danger {
  stroke: var(--bsft-graph-edge-danger);
  opacity: 1;
}

/* Dimming wins over emphasis: a danger edge away from the selection recedes like any other, and
   the doubled class lets it beat the danger rule above whatever the source order. */
.bsft-graph-edge.bsft-graph-edge-dim {
  opacity: var(--bsft-graph-dim-edge-opacity);
}

.bsft-graph-arrow {
  fill: var(--bsft-graph-edge);
}

.bsft-graph-arrow-hl {
  fill: var(--bsft-graph-edge-highlight);
}

.bsft-graph-arrow-danger {
  fill: var(--bsft-graph-edge-danger);
}

.bsft-graph-edge-label {
  fill: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-2xs);
  font-family: var(--bsft-font);
  paint-order: stroke;
  stroke: var(--bsft-graph-canvas);
  stroke-width: 3px;
}

.bsft-graph-edge-label-danger {
  fill: var(--bsft-graph-edge-danger);
  font-weight: 600;
}

.bsft-graph-edge-label.bsft-graph-edge-label-dim {
  opacity: var(--bsft-graph-dim-edge-opacity);
}

/* The colour of a group or tone, read by the node shape and the legend swatch alike. */
.bsft-graph-group-1 { --bsft-graph-color: var(--bsft-graph-group-1); }
.bsft-graph-group-2 { --bsft-graph-color: var(--bsft-graph-group-2); }
.bsft-graph-group-3 { --bsft-graph-color: var(--bsft-graph-group-3); }
.bsft-graph-group-4 { --bsft-graph-color: var(--bsft-graph-group-4); }
.bsft-graph-group-5 { --bsft-graph-color: var(--bsft-graph-group-5); }
.bsft-graph-group-other { --bsft-graph-color: var(--bsft-graph-group-other); }
/* A node without a group or tone that the legend names: drawn like a coloured one, in the grey of
   its legend swatch. */
.bsft-graph-neutral { --bsft-graph-color: var(--bsft-graph-group-other); }
.bsft-graph-tone-success { --bsft-graph-color: var(--bsft-color-success); }
.bsft-graph-tone-warning { --bsft-graph-color: var(--bsft-color-warning); }
.bsft-graph-tone-danger { --bsft-graph-color: var(--bsft-color-danger); }

.bsft-graph-node {
  outline: none;
  cursor: pointer;
  transition: opacity var(--bsft-motion-fast) ease;
}

.bsft-graph-node-shape {
  fill: var(--bsft-graph-node-fill);
  stroke: var(--bsft-graph-node-stroke);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

/* A box keeps the neutral fill so its label keeps text contrast on the surface colour, and takes
   the group or tone colour as its stroke. A circle is filled with it and keeps a halo in the canvas
   colour so neighbouring circles stay apart. */
.bsft-graph-node-box.bsft-graph-group-1 .bsft-graph-node-shape,
.bsft-graph-node-box.bsft-graph-group-2 .bsft-graph-node-shape,
.bsft-graph-node-box.bsft-graph-group-3 .bsft-graph-node-shape,
.bsft-graph-node-box.bsft-graph-group-4 .bsft-graph-node-shape,
.bsft-graph-node-box.bsft-graph-group-5 .bsft-graph-node-shape,
.bsft-graph-node-box.bsft-graph-group-other .bsft-graph-node-shape,
.bsft-graph-node-box.bsft-graph-neutral .bsft-graph-node-shape,
.bsft-graph-node-box.bsft-graph-tone-success .bsft-graph-node-shape,
.bsft-graph-node-box.bsft-graph-tone-warning .bsft-graph-node-shape,
.bsft-graph-node-box.bsft-graph-tone-danger .bsft-graph-node-shape {
  stroke: var(--bsft-graph-color);
  stroke-width: 2;
}

/* An uncoloured circle takes the neutral group colour: the surface fill would vanish in the dark
   theme, where the surface and the canvas are close. */
.bsft-graph-node-circle .bsft-graph-node-shape {
  fill: var(--bsft-graph-group-other);
  stroke: var(--bsft-graph-canvas);
  stroke-width: 2;
}

.bsft-graph-node-circle.bsft-graph-group-1 .bsft-graph-node-shape,
.bsft-graph-node-circle.bsft-graph-group-2 .bsft-graph-node-shape,
.bsft-graph-node-circle.bsft-graph-group-3 .bsft-graph-node-shape,
.bsft-graph-node-circle.bsft-graph-group-4 .bsft-graph-node-shape,
.bsft-graph-node-circle.bsft-graph-group-5 .bsft-graph-node-shape,
.bsft-graph-node-circle.bsft-graph-group-other .bsft-graph-node-shape,
.bsft-graph-node-circle.bsft-graph-neutral .bsft-graph-node-shape,
.bsft-graph-node-circle.bsft-graph-tone-success .bsft-graph-node-shape,
.bsft-graph-node-circle.bsft-graph-tone-warning .bsft-graph-node-shape,
.bsft-graph-node-circle.bsft-graph-tone-danger .bsft-graph-node-shape {
  fill: var(--bsft-graph-color);
  stroke: var(--bsft-graph-canvas);
  stroke-width: 2;
}

.bsft-graph-node.bsft-graph-node-centre .bsft-graph-node-shape {
  fill: var(--bsft-color-primary-surface);
  stroke: var(--bsft-color-primary);
  stroke-width: 2;
}

.bsft-graph-node.bsft-graph-node-selected .bsft-graph-node-shape {
  stroke: var(--bsft-color-primary);
  stroke-width: 2.4;
}

/* A selected node is told by its stroke; its label keeps the regular weight, because bold glyphs are
   wider than the estimate the layouts reserve room by. */

/* A dimmed node fades its shape and its texts, never the group: the focus ring is a child of the
   group, so it keeps full opacity and a dimmed node the keyboard is on stays visibly focused. */
.bsft-graph-node-dim .bsft-graph-node-shape,
.bsft-graph-node-dim .bsft-graph-node-label,
.bsft-graph-node-dim .bsft-graph-node-detail,
.bsft-graph-node-dim .bsft-graph-node-badge {
  opacity: var(--bsft-graph-dim-node-opacity);
}

/* The ring sits outside the shape, so focus and selection stay distinguishable without colour. */
.bsft-graph-focus-ring {
  fill: none;
  stroke: var(--bsft-color-primary);
  stroke-width: 2;
  visibility: hidden;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.bsft-graph-node:focus-visible .bsft-graph-focus-ring {
  visibility: visible;
}

.bsft-graph-node-label {
  fill: var(--bsft-color-text);
  font-size: var(--bsft-font-size-xs);
  font-family: var(--bsft-font);
}

.bsft-graph-node-detail {
  fill: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-2xs);
  font-family: var(--bsft-font);
  /* Haloed like the edge labels, so an edge that leaves a box downwards does not cross the detail line. */
  paint-order: stroke;
  stroke: var(--bsft-graph-canvas);
  stroke-width: 3px;
}

.bsft-graph-node-badge {
  fill: var(--bsft-color-danger);
  font-size: var(--bsft-font-size-2xs);
  font-family: var(--bsft-font);
  font-weight: 600;
}

.bsft-visual-legend-swatch.bsft-graph-group-1 { background: var(--bsft-graph-group-1); }
.bsft-visual-legend-swatch.bsft-graph-group-2 { background: var(--bsft-graph-group-2); }
.bsft-visual-legend-swatch.bsft-graph-group-3 { background: var(--bsft-graph-group-3); }
.bsft-visual-legend-swatch.bsft-graph-group-4 { background: var(--bsft-graph-group-4); }
.bsft-visual-legend-swatch.bsft-graph-group-5 { background: var(--bsft-graph-group-5); }
.bsft-visual-legend-swatch.bsft-graph-group-other { background: var(--bsft-graph-group-other); }
.bsft-visual-legend-swatch.bsft-graph-tone-success { background: var(--bsft-color-success); }
.bsft-visual-legend-swatch.bsft-graph-tone-warning { background: var(--bsft-color-warning); }
.bsft-visual-legend-swatch.bsft-graph-tone-danger { background: var(--bsft-color-danger); }
/* The nodes a colour mode leaves without a group or tone carry .bsft-graph-neutral once the legend
   names them: a circle is filled and a box stroked with the "other" grey, as for any legend colour. */
.bsft-visual-legend-swatch.bsft-graph-neutral { background: var(--bsft-graph-group-other); }

.bsft-graph-edge-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
}

.bsft-graph-edge-legend li {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
}

.bsft-graph-edge-legend .bsft-graph-edge {
  stroke-width: 2;
  opacity: 1;
}

.bsft-graph-tables {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) * 2);
  max-width: 100%;
  overflow-x: auto;
}

.bsft-graph-tables table {
  border-collapse: collapse;
  font-size: var(--bsft-font-size-xs);
}

.bsft-graph-tables caption {
  padding: 0 var(--bsft-spacing) calc(var(--bsft-spacing) / 2);
  color: var(--bsft-color-muted);
  font-weight: 600;
  text-align: left;
}

.bsft-graph-tables th,
.bsft-graph-tables td {
  padding: 0.125rem var(--bsft-spacing);
  border-bottom: 1px solid var(--bsft-color-border);
  text-align: left;
  white-space: nowrap;
}

.bsft-graph-row-selected {
  background: var(--bsft-color-primary-surface);
}

/* The name cell holds a toggle (the selection) and, for a node that can be opened, an open control. */
.bsft-graph-row-select,
.bsft-graph-row-open {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bsft-color-primary);
  font: inherit;
  cursor: pointer;
}

.bsft-graph-row-open {
  margin-left: var(--bsft-spacing);
  text-decoration: underline;
}

.bsft-graph-row-select[aria-pressed="true"] {
  font-weight: 600;
  text-decoration: underline;
}

.bsft-graph-row-select:focus-visible,
.bsft-graph-row-open:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-graph-aside {
  min-width: 0;
}

/* From 48rem (spelled with "screen and" so the shell and split-pane tests, which look for the first
   bare 48rem query, still find their own) a body with a side panel wraps instead: the canvas asks
   for the drawing's readable width (--bsft-graph-readable-width, set inline: three quarters of the
   drawing's width, below which its 12 unit labels would drop under 9 px) and the panel for 18rem.
   While both fit on one line they sit side by side and the canvas takes nearly all the spare room
   (flex-grow 999 against 1); when they do not, the panel wraps below and grows to the full width,
   so the drawing gets the whole width before it scrolls. A canvas alone on a line narrower than
   its readable width shrinks to the line (min-width: 0) and scrolls inside itself. The canvas is
   content-box, so its line takes the readable width plus its 2px border; the gap is 1rem (16px).

   Worked through for the browser suite's page (Fixtures/graph-aside.html): a radial type
   neighbourhood of 31 nodes (drawing 1168 wide, readable width ceil(1168 * 0.75) = 876) and a
   radial of three nodes (drawing 120, readable 90), each with a side panel:
   - 1280px desktop, 963px content column: 876 + 2 + 16 + 288 = 1182 > 963, so the panel wraps
     below. The canvas line is 963, the SVG 961 wide (961 >= 876: no scroll), scale
     961 / 1168 = 0.82, a label 9.9px high. The small one: 90 + 2 + 16 + 288 = 396 <= 963, so the
     panel stays beside; the canvas line gets 963 - 16 - 288 = 659 (less a fraction of a pixel for
     the panel's share of flex-grow) and the SVG stops at its own 120 (max-width), unscaled.
   - 375px phone, under 48rem: one grid column of 375 - 2 * 16 = 343, the SVG 341 wide. The
     31-node drawing scrolls inside its canvas from its 876 readable width, the page does not; the
     small one fits at full size (341 >= 120). */
@media screen and (min-width: 48rem) {
  .bsft-graph-has-aside .bsft-graph-body {
    display: flex;
    flex-wrap: wrap;
  }

  .bsft-graph-has-aside .bsft-graph-canvas {
    flex: 999 1 var(--bsft-graph-readable-width, 0px);
    min-width: 0;
  }

  .bsft-graph-has-aside .bsft-graph-tables {
    flex: 999 1 0%;
    min-width: 0;
  }

  .bsft-graph-has-aside .bsft-graph-aside {
    flex: 1 1 18rem;
  }
}

/* --- log viewer ------------------------------------------------------------------- */

/* One column as wide as the viewer, never wider: the implicit auto column grew to the toolbar's widest
   chip, so a long filter value widened the page at 375px instead of ending in its ellipsis. */
.bsft-log-viewer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bsft-spacing);
  min-width: 0;
  font-family: var(--bsft-font);
}

.bsft-log-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  flex-wrap: wrap;
}

.bsft-log-viewer-search {
  flex: 1 1 16rem;
  min-width: 10rem;
}

.bsft-log-viewer-search input {
  width: 100%;
}

.bsft-log-viewer-correlation {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 4);
  min-width: 0;
}

/* A block, not the chip's inline-flex: the text of a flex container sits in an anonymous flex item, which
   draws no ellipsis. The title carries the whole text. */
.bsft-log-viewer-correlation-value {
  display: block;
  min-width: 0;
  max-width: 24rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.bsft-log-viewer-scope {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: calc(var(--bsft-spacing) / 4);
  min-width: 0;
}

.bsft-log-viewer-scope-chip {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 4);
  min-width: 0;
}

.bsft-log-viewer-scope-value {
  display: block;
  min-width: 0;
  max-width: 24rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.bsft-log-viewer-scope-remove {
  min-block-size: 1.5rem;
  cursor: pointer;
}

.bsft-log-viewer-scope-remove:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-log-viewer .bsft-scroll-region {
  height: var(--bsft-log-viewer-height, 32rem);
  overflow-x: hidden;
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
}

.bsft-log-entry {
  display: grid;
  grid-template-columns: max-content max-content minmax(8rem, 14rem) minmax(0, 1fr);
  gap: calc(var(--bsft-spacing) / 4) calc(var(--bsft-spacing) / 2);
  align-items: start;
  padding: calc(var(--bsft-spacing) / 4) calc(var(--bsft-spacing) / 2);
  border-block-end: 1px solid var(--bsft-color-border);
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
  font-size: var(--bsft-font-size-sm);
  line-height: 1.45;
}

.bsft-log-entry time,
.bsft-log-entry-category {
  color: var(--bsft-color-muted);
}

.bsft-log-entry-level {
  min-width: 4.5rem;
  font-weight: 700;
}

.bsft-log-entry-information .bsft-log-entry-level {
  color: var(--bsft-color-primary);
}

.bsft-log-entry-warning .bsft-log-entry-level {
  color: var(--bsft-color-warning);
}

.bsft-log-entry-error .bsft-log-entry-level,
.bsft-log-entry-critical .bsft-log-entry-level {
  color: var(--bsft-color-danger);
}

.bsft-log-entry-message,
.bsft-log-entry details,
.bsft-log-entry pre {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.bsft-log-entry details {
  grid-column: 4;
}

/* The message and the id button share the message column: the button follows the text on the same line
   and wraps beneath it only when the line is full, so a correlated log does not double in height. */
.bsft-log-entry-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 calc(var(--bsft-spacing) / 2);
  min-width: 0;
}

.bsft-log-entry-correlation {
  appearance: none;
  min-width: 0;
  min-block-size: 1.5rem;
  max-width: 100%;
  padding: 0 calc(var(--bsft-spacing) / 4);
  overflow: hidden;
  border: 0;
  background: none;
  color: var(--bsft-color-muted);
  font: inherit;
  text-decoration: underline dotted;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.bsft-log-entry-correlation[aria-pressed="true"] {
  color: var(--bsft-color-primary);
  font-weight: 600;
}

.bsft-log-entry-correlation:hover {
  color: var(--bsft-color-primary);
}

.bsft-log-entry-correlation:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-list-row-live {
  background: color-mix(in srgb, var(--bsft-color-primary) 8%, transparent);
  box-shadow: inset 3px 0 0 var(--bsft-color-primary);
}

.bsft-log-entry-link {
  min-width: 0;
  min-block-size: 1.5rem;
  max-width: 100%;
  padding: 0 calc(var(--bsft-spacing) / 4);
  overflow: hidden;
  color: var(--bsft-color-primary);
  text-decoration: underline;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bsft-log-entry-link:hover {
  text-decoration-thickness: 2px;
}

.bsft-log-entry-link:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-log-entry-scope {
  grid-column: 4;
  min-width: 0;
}

.bsft-log-entry-scope summary {
  color: var(--bsft-color-muted);
  cursor: pointer;
}

.bsft-log-entry-scope-property {
  appearance: none;
  min-width: 0;
  min-block-size: 1.5rem;
  max-width: 100%;
  margin-inline-end: calc(var(--bsft-spacing) / 2);
  padding: 0 calc(var(--bsft-spacing) / 4);
  overflow: hidden;
  border: 0;
  background: none;
  color: var(--bsft-color-muted);
  font: inherit;
  text-decoration: underline dotted;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.bsft-log-entry-scope-property[aria-pressed="true"] {
  color: var(--bsft-color-primary);
  font-weight: 600;
}

.bsft-log-entry-scope-property:hover {
  color: var(--bsft-color-primary);
}

.bsft-log-entry-scope-property:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-log-entry-scope-truncated {
  margin: calc(var(--bsft-spacing) / 4) 0 0;
  color: var(--bsft-color-muted);
  font-style: italic;
}

.bsft-log-entry pre {
  max-height: 20rem;
  margin: calc(var(--bsft-spacing) / 4) 0 0;
  overflow: auto;
  color: var(--bsft-color-danger);
}

.bsft-log-viewer-load-older,
.bsft-log-viewer-jump {
  margin: calc(var(--bsft-spacing) / 2);
}

/* --- reduced motion --------------------------------------------------------------- */

/* The guard is deliberately universal rather than a list of the rules that animate today. A
   guard that enumerates what it knows about is the guard that misses the next transition
   somebody adds, and a half-covered reduced-motion story is worse than none: it reads as
   handled. Durations are collapsed rather than set to zero so that transitionend and
   animationend still fire — a rendering that waits for one would otherwise hang forever — and
   an infinite animation is cut to a single iteration, which is what leaves the spinner standing
   as the static ring it draws at rest.

   It applies to the host's own rules too, on purpose: the preference is the user's statement
   about the page, not about one stylesheet on it. A host that wants motion back for its own
   surfaces states that in its own reduced-motion block. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- shell switch ------------------------------------------------------------------ */

/* One breakpoint, at 48rem — the width below which a sidebar and a content column stop both
   being readable. It is written as a literal in both queries because a media query cannot read a
   custom property, which is a limitation of the cascade and not a token this file forgot to
   declare; the two halves are stated as a max/min pair around the same number so they can never
   both apply and never both fail to. */

@media (max-width: 47.999rem) {
  .bsft-log-entry {
    grid-template-columns: max-content max-content minmax(0, 1fr);
  }

  .bsft-log-entry-category {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bsft-log-entry-body,
  .bsft-log-entry details {
    grid-column: 1 / -1;
    overflow-wrap: anywhere;
  }

  .bsft-log-entry pre {
    overflow-wrap: anywhere;
  }

  /* A header with page-specific actions may carry more controls than one phone-width row can hold.
     It wraps instead of widening the shell. The action group moves visually after every other
     control, then takes a full-width scrollable row without changing the semantic DOM order.
     Titled headers without actions keep their existing wrapping behavior. */
  .bsft-shell-header--titled,
  .bsft-shell-header--with-actions {
    min-width: 0;
    flex-wrap: wrap;
  }

  .bsft-shell-header--with-actions .bsft-shell-header-actions {
    order: 1;
    flex-basis: 100%;
    max-width: 100%;
    overflow-x: auto;
  }

  /* Off-canvas: the navigation leaves the flow and becomes a drawer over the content, disclosed
     by the header's toggle. It is hidden with visibility rather than display, for two reasons
     that both matter — visibility takes it out of the accessibility tree exactly as display
     would, and unlike display it is a transitionable property, so the drawer slides instead of
     appearing. The transition is one of the ones the reduced-motion guard above collapses. */
  .bsft-shell-nav {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(18rem, 80vw);
    padding: var(--bsft-spacing);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bsft-color-surface);
    border-inline-end: 1px solid var(--bsft-color-border);
    /* Above the modal layer's backdrop and below the modal itself: a drawer is dismissed by the
       next thing the user does, so a dialog opened from it still has to cover it. */
    z-index: calc(var(--bsft-z-dialog) - 1);
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform var(--bsft-motion-fast) ease, visibility var(--bsft-motion-fast);
  }

  /* The state lives on the shell rather than on the drawer, because the backdrop is a sibling
     and has to react to the same fact. */
  .bsft-shell[data-bsft-nav="open"] .bsft-shell-nav {
    visibility: visible;
    transform: translateX(0);
  }

  .bsft-shell-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--bsft-z-dialog) - 2);
    background: rgb(0 0 0 / 50%);
  }

  /* The table scrolls sideways inside the list rather than squeezing every column to
     illegibility; the pager wraps onto a second line and gives up its far-end alignment, which
     only ever made sense on a row wide enough to have two ends. */
  .bsft-list {
    overflow-x: auto;
  }

  .bsft-list-pagesize {
    margin-left: 0;
  }

  .bsft-list-pager {
    flex-wrap: wrap;
  }

  /* A split pane on a phone is not a split pane. There is room for one column, so the column is
     the pane the caller nominated and the other is reached through the swap control — which is
     the same trade the navigation makes one breakpoint above: the second thing on screen becomes
     the second thing you ask for. */
  .bsft-split {
    flex-direction: column;
  }

  /* The pane that is not showing and the control that would resize it are both gone, which takes
     them out of the accessibility tree along with the pixels. */
  .bsft-split-divider,
  .bsft-split[data-bsft-split-pane="primary"] .bsft-split-secondary,
  .bsft-split[data-bsft-split-pane="secondary"] .bsft-split-primary {
    display: none;
  }

  /* Whatever basis the wide shape persisted means nothing in one column: the pane that is showing
     takes the height it is given. */
  .bsft-split-primary,
  .bsft-split-secondary {
    flex: 1 1 auto;
  }
}

@media (min-width: 48rem) {
  /* Wide: the navigation is a sidebar beside the content instead of a band above it. Grid
     rather than flex, because the shell's markup order — header, navigation, main — is the
     reading order and must not change to get a two-column layout. */
  .bsft-shell {
    display: grid;
    grid-template-columns: minmax(12rem, 16rem) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "header header"
      "nav main";
  }

  .bsft-shell-header {
    grid-area: header;
  }

  .bsft-shell-nav {
    grid-area: nav;
  }

  .bsft-shell-main {
    grid-area: main;
    min-width: 0;
  }

  /* There is no drawer up here, so there is no control for one and no layer over the page. */
  .bsft-shell-nav-toggle,
  .bsft-shell-nav-backdrop {
    display: none;
  }

  /* Both panes are on screen up here, so there is nothing to swap to and no control for it. */
  .bsft-split-swap {
    display: none;
  }

  /* --- sheet: wide variant --- */
}

/* --- drag and drop ------------------------------------------------------- */

/* A reorderable list is a list, not a table: the rows carry their own border and the container
   carries none, so a list dropped into a panel does not draw a second frame around it. */
.bsft-reorder {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

.bsft-reorder-item {
  display: flex;
  align-items: center;
  gap: var(--bsft-spacing);
  padding: var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  cursor: grab;
}

.bsft-reorder-item + .bsft-reorder-item {
  margin-top: calc(var(--bsft-spacing) / 2);
}

/* Every row is focusable, so the focus ring is the keyboard path's only affordance and is never
   removed — the visible half of "pick up, move, drop". */
.bsft-reorder-item:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* The held row, whether it was picked up by pointer or by key: one state, because the two
   gestures are one gesture with two inputs. */
.bsft-reorder-item.is-held {
  border-color: var(--bsft-color-primary);
  cursor: grabbing;
  opacity: 0.7;
}

/* The position the held row would take. Only ever set where the target actually accepts it, so
   the marker is a promise the drop keeps rather than a highlight under every pointer. */
.bsft-reorder-item.is-over {
  border-color: var(--bsft-color-primary);
  box-shadow: inset 0 2px 0 0 var(--bsft-color-primary);
}

.bsft-file-drop {
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  padding: calc(var(--bsft-spacing) * 2);
  border: 1px dashed var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  font-family: var(--bsft-font);
  color: var(--bsft-color-text);
}

/* A drag that will land and one that will not are told apart by colour *and* by the refusal the
   surface states after the drop, never by colour alone. */
.bsft-file-drop.is-over {
  border-style: solid;
  border-color: var(--bsft-color-primary);
  background: var(--bsft-color-info-surface);
}

.bsft-file-drop.is-over.is-refusing {
  border-color: var(--bsft-color-danger);
  background: var(--bsft-color-danger-surface);
}

.bsft-file-drop-statement {
  margin: 0;
  color: var(--bsft-color-muted);
}

.bsft-file-drop-rejections {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--bsft-color-danger);
}

.bsft-file-drop-progress {
  height: 0.5rem;
  overflow: hidden;
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-skeleton);
}

.bsft-file-drop-progress-bar {
  height: 100%;
  background: var(--bsft-color-primary);
  transition: width var(--bsft-motion-fast) linear;
}

/* The window-wide drop. The overlay covers the viewport only while a file drag is over the
   window and never takes the pointer, so it is not a drop target of its own and the drag's enter and
   leave events keep landing on the page beneath it. It sits under the toasts, so a refusal or an
   upload notice raised during a drag stays readable. The motion is a fade of the dim and a short
   zoom of the frame; the stylesheet's reduced-motion guard collapses both to their end state. */
.bsft-page-drop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--bsft-z-toast) - 1);
  display: flex;
  padding: calc(var(--bsft-spacing) * 2);
  background: color-mix(in srgb, var(--bsft-color-text) 35%, transparent);
  pointer-events: none;
  font-family: var(--bsft-font);
  animation: bsft-page-drop-dim var(--bsft-motion-entrance) var(--bsft-ease-out) both;
}

.bsft-page-drop-frame {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--bsft-spacing);
  border: 3px dashed var(--bsft-color-primary);
  border-radius: var(--bsft-radius-lg);
  background: color-mix(in srgb, var(--bsft-color-surface) 88%, transparent);
  color: var(--bsft-color-text);
  text-align: center;
  animation: bsft-page-drop-zoom var(--bsft-motion-entrance) var(--bsft-ease-out) both;
}

.bsft-page-drop-icon {
  inline-size: 3rem;
  block-size: 3rem;
  fill: none;
  stroke: var(--bsft-color-primary);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: bsft-page-drop-lift var(--bsft-motion-pulse) ease-in-out infinite alternate;
}

.bsft-page-drop-title {
  margin: 0;
  font-size: var(--bsft-font-size-xl);
  font-weight: 600;
}

.bsft-page-drop-detail {
  margin: 0;
  color: var(--bsft-color-muted);
}

/* A drag that will not land, or a drop that is paused, is told apart by the frame's colour and by
   the sentence the frame says — never by colour alone. */
.bsft-page-drop.is-refusing .bsft-page-drop-frame {
  border-color: var(--bsft-color-danger);
}

.bsft-page-drop.is-refusing .bsft-page-drop-icon {
  stroke: var(--bsft-color-danger);
}

.bsft-page-drop.is-disabled .bsft-page-drop-frame {
  border-color: var(--bsft-color-muted);
}

.bsft-page-drop.is-disabled .bsft-page-drop-icon {
  stroke: var(--bsft-color-muted);
  animation: none;
}

.bsft-page-drop-truncated {
  margin: 0;
  color: var(--bsft-color-warning);
}

@keyframes bsft-page-drop-dim {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bsft-page-drop-zoom {
  from { transform: scale(1.04); }
  to { transform: scale(1); }
}

@keyframes bsft-page-drop-lift {
  from { transform: translateY(0); }
  to { transform: translateY(-0.375rem); }
}

/* Files are dragged in from outside with a fine pointer only. A device that has none (a phone, a
   tablet without a trackpad) does not draw the overlay, whatever a browser reports about a drag;
   a tablet with a trackpad or a touch laptop with a mouse does. */
@media not all and (any-pointer: fine) {
  .bsft-page-drop {
    display: none;
  }
}

/* Forced colours drop the dim and the tinted frame; the frame's border and the text remain. */
@media (forced-colors: active) {
  .bsft-page-drop {
    background: Canvas;
  }

  .bsft-page-drop-frame {
    border-color: CanvasText;
  }

  .bsft-page-drop-icon {
    stroke: CanvasText;
  }
}

/* --- file preview ----------------------------------------------------------------- */

/* A figure, because that is what it is: a caption naming the file and one rendering of its
   contents beneath. Every payload below is bounded in height rather than left to grow — a preview
   that pushes the rest of the screen off it has stopped being a preview. */
.bsft-file-preview {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
  margin: 0;
  padding: var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
}

.bsft-file-preview-caption {
  display: flex;
  gap: var(--bsft-spacing);
  align-items: baseline;
  justify-content: space-between;
}

.bsft-file-preview-name {
  overflow-wrap: anywhere;
  font-weight: 600;
}

.bsft-file-preview-size {
  flex: none;
  color: var(--bsft-color-muted);
}

/* Contained rather than stretched: an image is shown at whatever size fits, and a portrait scan
   must not become a column of empty page. */
.bsft-file-preview-image {
  max-width: 100%;
  max-height: 32rem;
  object-fit: contain;
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-skeleton);
}

.bsft-file-preview-pdf {
  width: 100%;
  height: 32rem;
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
}

/* pre-wrap rather than pre: a text file's own line breaks are kept, and a line longer than the
   surface wraps instead of scrolling the whole page sideways. */
.bsft-file-preview-text {
  max-height: 24rem;
  margin: 0;
  overflow: auto;
  padding: var(--bsft-spacing);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-skeleton);
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The table scrolls inside its own box. A CSV with sixty columns is ordinary, and letting it set
   the width of the screen would break every layout it appears in. */
.bsft-file-preview-csv {
  display: block;
  max-height: 24rem;
  overflow: auto;
  border-collapse: collapse;
}

.bsft-file-preview-csv th,
.bsft-file-preview-csv td {
  padding: calc(var(--bsft-spacing) / 2);
  border: 1px solid var(--bsft-color-border);
  text-align: left;
  white-space: nowrap;
}

.bsft-file-preview-csv th {
  position: sticky;
  top: 0;
  background: var(--bsft-color-surface);
}

.bsft-file-preview-fallback {
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
}

/* --- command palette -------------------------------------------------------------- */

/* The armed wrapper is layout-neutral on purpose: it contains the whole application, so anything
   it drew — a box, a padding, a stacking context — would be a frame around every screen. It is
   here only to carry tabindex and the focus ring the ordinary rules would otherwise give a
   focusable element covering the viewport. */
.bsft-command-palette-root {
  display: contents;
}

.bsft-command-palette-root:focus,
.bsft-command-palette-root:focus-visible {
  outline: none;
}

.bsft-command-palette {
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  /* Wide enough to read a whole label, capped so the panel does not become the page on a large
     screen — the dialog centres whatever it is given. */
  width: min(36rem, 90vw);
  font-family: var(--bsft-font);
}

.bsft-command-palette-input {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--bsft-touch-target);
  padding: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
}

.bsft-command-palette-input:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-command-palette-list {
  /* Bounded and scrolled rather than paged: the ranking has already put the answer at the top,
     so what is below the fold is the long tail and never the thing being looked for. */
  max-height: 20rem;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
}

.bsft-command-palette-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bsft-spacing);
  min-height: var(--bsft-touch-target);
  padding: var(--bsft-spacing) calc(var(--bsft-spacing) * 2);
  cursor: pointer;
  color: var(--bsft-color-text);
}

.bsft-command-palette-option-active {
  /* Where the keyboard is — which in this control is also what Enter would run, since a palette
     binds no value of its own. */
  background: var(--bsft-color-info-surface);
}

.bsft-command-palette-option-kind {
  color: var(--bsft-color-muted);
  font-size: 0.875em;
  white-space: nowrap;
}

/* --- chat ------------------------------------------------------------------------- */

/* Mobile first: on a phone the list and the open conversation take turns — the list until a
   conversation is open, then the conversation with its way back. From the tablet width up both
   sit side by side and the way back is hidden. The transcript's height is the surrounding
   layout's to give; the panel fills what it is given. */
.bsft-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.bsft-chat-main {
  display: none;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.bsft-chat-open .bsft-chat-conversations {
  display: none;
}

.bsft-chat-open .bsft-chat-main {
  display: flex;
}

/* The icon-only controls of the chat: a square touch target of the phone's minimum, the glyph
   centred in it, no word to wrap. They are ordinary buttons otherwise — the theme's border,
   radius and focus ring, so a keyboard user sees the same ring here as everywhere. */
.bsft-chat-back,
.bsft-chat-send,
.bsft-chat-target-cancel,
.bsft-chat-message-retry,
.bsft-chat-message-actions .bsft-popover-trigger {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--bsft-touch-target);
  min-width: var(--bsft-touch-target);
  height: var(--bsft-touch-target);
  padding: 0;
}

.bsft-icon {
  display: block;
  flex: none;
}

.bsft-chat-conversations {
  display: flex;
  flex-direction: column;
  gap: var(--bsft-spacing);
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
}

/* The list scrolls inside the panel rather than scrolling the page: what grows the list is the
   reader coming within a viewport of the end of a bounded region, and an unbounded one has no
   end to come within reach of. Same shape as the transcript's region one screen over. */
.bsft-chat-conversations .bsft-scroll-region {
  flex: 1 1 auto;
  min-height: 0;
}

.bsft-chat-search {
  display: block;
}

.bsft-chat-search-input {
  width: 100%;
}

.bsft-chat-load-more {
  width: 100%;
  margin-top: var(--bsft-spacing);
}

.bsft-chat-conversation-group-title {
  margin: var(--bsft-spacing) 0 0;
  font-size: var(--bsft-font-size-sm);
  color: var(--bsft-color-muted);
}

.bsft-chat-conversation-list,
.bsft-chat-messages {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* A whole row is one touch target: at least 44px tall on a phone. */
.bsft-chat-conversation {
  display: flex;
  align-items: center;
  gap: var(--bsft-spacing);
  width: 100%;
  min-height: var(--bsft-touch-target);
  text-align: start;
}

.bsft-chat-conversation[aria-pressed="true"] {
  border-color: var(--bsft-color-primary);
}

.bsft-chat-conversation-waiting {
  opacity: 0.7;
}

.bsft-chat-conversation-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.bsft-chat-conversation-title {
  font-weight: 600;
}

.bsft-chat-conversation-title,
.bsft-chat-conversation-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bsft-chat-conversation-preview {
  display: flex;
  gap: calc(var(--bsft-spacing) / 2);
  font-size: var(--bsft-font-size-sm);
  color: var(--bsft-color-muted);
}

/* The time of the last message keeps its place at the row's end: it is short, it never shrinks,
   and the preview beside it truncates instead. */
.bsft-chat-conversation-time {
  flex: 0 0 auto;
  align-self: center;
  margin-inline-start: auto;
  font-size: var(--bsft-font-size-xs);
  color: var(--bsft-color-muted);
  white-space: nowrap;
}

.bsft-chat-conversation-preview-author::after {
  content: ":";
}

.bsft-chat-unread {
  flex: 0 0 auto;
  min-width: 1.5rem;
  padding: 0 calc(var(--bsft-spacing) / 2);
  border-radius: 999px;
  background: var(--bsft-color-primary);
  color: var(--bsft-color-primary-contrast);
  font-size: var(--bsft-font-size-xs);
  line-height: 1.5rem;
  text-align: center;
}

.bsft-chat-unread-mention {
  background: var(--bsft-color-danger);
  color: var(--bsft-color-danger-contrast);
}

/* The conversation's own bar: the way back, then what the reader is in. It stays at the top of
   the conversation while the transcript scrolls under it, because on a phone — where the host may
   have taken its own bottom navigation away for the conversation — this is the way out. */
.bsft-chat-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--bsft-spacing);
  padding: var(--bsft-spacing) 0;
  background: var(--bsft-color-surface);
}

.bsft-chat-header-text {
  min-width: 0;
}

.bsft-chat-title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--bsft-font-size-lg);
}

.bsft-chat-topic {
  margin: 0;
  color: var(--bsft-color-muted);
}

.bsft-chat-main .bsft-scroll-region {
  flex: 1 1 auto;
  min-height: 0;
}

.bsft-chat-day {
  margin: var(--bsft-spacing) 0;
  text-align: center;
  font-size: var(--bsft-font-size-xs);
  color: var(--bsft-color-muted);
}

.bsft-chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  margin: calc(var(--bsft-spacing) / 2) 0;
  padding: var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  overflow-wrap: anywhere;
}

.bsft-chat-message-own {
  margin-inline-start: auto;
  border-color: var(--bsft-color-primary);
  background: var(--bsft-color-primary-surface);
}

.bsft-chat-message-highlighted {
  outline: 2px solid var(--bsft-color-primary);
}

.bsft-chat-message-tombstone {
  color: var(--bsft-color-muted);
  font-style: italic;
}

.bsft-chat-system {
  max-width: none;
  border: none;
  text-align: center;
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

.bsft-chat-system-text,
.bsft-chat-message-text {
  margin: 0;
}

.bsft-chat-message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  font-size: var(--bsft-font-size-xs);
  color: var(--bsft-color-muted);
}

.bsft-chat-message-author {
  font-weight: 600;
  color: var(--bsft-color-text);
}

/* The initials mark of the message's author. The hue is the component's (one per actor), how
   saturated and how light it becomes is this theme's, so the same mark stays legible in both
   themes without the component knowing either. */
.bsft-chat-avatar {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: hsl(var(--bsft-chat-avatar-hue, 210) 70% 88%);
  color: hsl(var(--bsft-chat-avatar-hue, 210) 45% 25%);
  font-size: var(--bsft-font-size-2xs);
  font-weight: 600;
  line-height: 1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-bsft-theme="light"]) .bsft-chat-avatar {
    background: hsl(var(--bsft-chat-avatar-hue, 210) 45% 28%);
    color: hsl(var(--bsft-chat-avatar-hue, 210) 70% 88%);
  }
}

:root[data-bsft-theme="dark"] .bsft-chat-avatar {
  background: hsl(var(--bsft-chat-avatar-hue, 210) 45% 28%);
  color: hsl(var(--bsft-chat-avatar-hue, 210) 70% 88%);
}

.bsft-chat-quote {
  display: flex;
  flex-direction: column;
  margin-bottom: calc(var(--bsft-spacing) / 2);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: none;
  border-inline-start: 3px solid var(--bsft-color-primary);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.bsft-chat-quote-unavailable {
  border-inline-start-color: var(--bsft-color-border);
  color: var(--bsft-color-muted);
  font-style: italic;
  cursor: default;
}

.bsft-chat-quote-author {
  font-weight: 600;
  font-size: var(--bsft-font-size-xs);
}

.bsft-chat-quote-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The line under the body: the reactions take the room and wrap inside it, the menu keeps its
   place at the end of the first line, so neither many reactions nor none move it. The reaction
   chips and the trigger share one height, which is what puts them on one line. */
.bsft-chat-message-foot {
  display: flex;
  align-items: flex-start;
  gap: calc(var(--bsft-spacing) / 2);
  margin-top: calc(var(--bsft-spacing) / 2);
}

.bsft-chat-message-foot > .bsft-chat-reactions {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
}

/* The menu belongs to the message, not beside it: a quiet glyph at the end of the message's last
   line rather than a second button-shaped thing inside the bubble. It takes the theme's border
   and ring back as soon as it is hovered or focused, so it is still findable by keyboard. */
.bsft-chat-message-actions {
  flex: none;
  margin-inline-start: auto;
  margin-inline-end: calc(var(--bsft-spacing) / -2);
}

/* The menu's panel hangs off the bubble rather than off the small trigger: the popover gives up
   its own positioning, so the placement's start or end edge is the bubble's. An own message
   (bottom-end) grows back from the bubble's end, anybody else's (bottom-start) on from its start,
   so the panel stays inside the conversation whatever the bubble's width, and it never grows
   wider than the viewport. */
.bsft-chat-message {
  position: relative;
}

.bsft-chat-message-actions .bsft-popover {
  position: static;
}

.bsft-chat-message-actions .bsft-popover-panel {
  min-width: min(12rem, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
}

.bsft-chat-message-actions .bsft-popover-trigger {
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  border-color: transparent;
  background: transparent;
  color: var(--bsft-color-muted);
}

.bsft-chat-message-actions .bsft-popover-trigger:hover,
.bsft-chat-message-actions .bsft-popover-trigger:focus-visible,
.bsft-chat-message-actions .bsft-popover-trigger[aria-expanded="true"] {
  border-color: var(--bsft-color-border);
  color: var(--bsft-color-text);
}

/* A row on its way is dimmed rather than moved: it is already where the confirmed message will
   be, and the only thing that changes when the server answers is that the dimming stops. A
   refused one keeps its full weight — it is not on its way any more — and says so in the danger
   colour beside its retry. */
.bsft-chat-message-pending {
  opacity: 0.65;
}

.bsft-chat-message-failed {
  border-color: var(--bsft-color-danger);
}

.bsft-chat-message-state {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: calc(var(--bsft-spacing) / 2);
  margin: calc(var(--bsft-spacing) / 2) 0 0;
  font-size: var(--bsft-font-size-xs);
  color: var(--bsft-color-muted);
}

.bsft-chat-message-state-failed {
  color: var(--bsft-color-danger);
}

.bsft-chat-message-retry {
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
}

.bsft-chat-message-read {
  color: var(--bsft-color-primary);
}

/* The reaction bar under a message: chips that wrap rather than scroll sideways, each big enough
   to hit on a phone, the own reaction filled so it reads as pressed and not merely as coloured. */
.bsft-chat-reactions {
  margin-top: calc(var(--bsft-spacing) / 2);
}

.bsft-chat-reaction-bar,
.bsft-chat-reaction-picker,
.bsft-chat-reactor-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.bsft-chat-reaction,
.bsft-chat-reaction-add,
.bsft-chat-reaction-choice,
.bsft-chat-reactor-key {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 2rem;
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--bsft-color-border);
  border-radius: 999px;
  background: var(--bsft-color-surface);
  color: inherit;
  font: inherit;
  line-height: 1.5;
  cursor: pointer;
}

/* The theme's focus ring, outside the chip as on .bsft-chip, so it reads on the filled own reaction
   as well as on a plain one; the browser's own ring is not tuned to either theme. */
.bsft-chat-reaction:focus-visible,
.bsft-chat-reaction-add:focus-visible,
.bsft-chat-reaction-choice:focus-visible,
.bsft-chat-reactor-key:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

.bsft-chat-reaction-mine,
.bsft-chat-reactor-key-open {
  border-color: var(--bsft-color-primary);
  background: var(--bsft-color-primary);
  color: var(--bsft-color-primary-contrast);
}

.bsft-chat-reaction-count {
  font-size: var(--bsft-font-size-xs);
  font-variant-numeric: tabular-nums;
}

.bsft-chat-reaction-who {
  border: none;
  background: transparent;
  color: var(--bsft-color-muted);
  font: inherit;
  font-size: var(--bsft-font-size-xs);
  text-decoration: underline;
  cursor: pointer;
}

.bsft-chat-reaction-picker {
  margin-top: 0.25rem;
}

.bsft-chat-reactors {
  margin-top: calc(var(--bsft-spacing) / 2);
  padding-top: calc(var(--bsft-spacing) / 2);
  border-top: 1px solid var(--bsft-color-border);
  font-size: var(--bsft-font-size-sm);
}

.bsft-chat-reactors-title {
  margin: 0 0 0.25rem;
  color: var(--bsft-color-muted);
}

.bsft-chat-reactors-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
}

.bsft-chat-reactors-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: calc(var(--bsft-spacing) / 2);
  min-width: 0;
}

/* Who has read a message, under the message: names and read times wrap inside the bubble, so the
   list fits the narrowest phone bubble without scrolling sideways. */
.bsft-chat-readers {
  margin-top: calc(var(--bsft-spacing) / 2);
  padding-top: calc(var(--bsft-spacing) / 2);
  border-top: 1px solid var(--bsft-color-border);
  font-size: var(--bsft-font-size-sm);
}

.bsft-chat-readers-title {
  margin: 0;
  color: var(--bsft-color-muted);
}

.bsft-chat-readers-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bsft-chat-readers-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: calc(var(--bsft-spacing) / 2);
  min-width: 0;
}

.bsft-chat-readers-list time {
  color: var(--bsft-color-muted);
}

/* The composer owns the bottom edge of the conversation and stays there while the transcript
   scrolls past it. Two things it cannot know itself, and both are read from one custom property
   the host sets: how tall the host's own bottom bar is, and how much of the viewport the
   on-screen keyboard covers where the browser overlays it instead of shrinking the page. A host
   with neither leaves --bsft-chat-composer-offset unset and the composer sits on the bottom.
   The safe area is added here rather than by the host: every phone has one, whatever the host
   puts above it. */
.bsft-chat-composer {
  position: sticky;
  bottom: var(--bsft-chat-composer-offset, 0px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: calc(var(--bsft-spacing) / 2);
  padding-top: var(--bsft-spacing);
  padding-bottom: max(var(--bsft-spacing), env(safe-area-inset-bottom));
  background: var(--bsft-color-surface);
}

.bsft-chat-composer-row {
  display: flex;
  align-items: flex-end;
  gap: calc(var(--bsft-spacing) / 2);
}

/* The host's own affordances sit at the start of the row and keep the height of the smallest
   field, so the draft still owns the width it grows into. */
.bsft-chat-composer-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: calc(var(--bsft-spacing) / 4);
}

.bsft-chat-target {
  display: flex;
  align-items: center;
  gap: var(--bsft-spacing);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border-inline-start: 3px solid var(--bsft-color-primary);
  font-size: var(--bsft-font-size-sm);
}

.bsft-chat-target-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bsft-chat-target-text .bsft-chat-actor {
  margin-inline-end: calc(var(--bsft-spacing) / 2);
  font-weight: 600;
}

/* A field, not a bare textarea: the theme's own border, radius and focus ring, a placeholder in
   the muted colour, and one line to start with. It grows with what is written — field-sizing
   where the browser has it, and the one row plus vertical resize everywhere else — up to a
   third of the viewport, and scrolls inside from there rather than pushing the transcript off
   the screen. 16px keeps a phone browser from zooming in on focus. */
.bsft-chat-draft {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--bsft-touch-target);
  max-height: min(9rem, 30dvh);
  padding: 0.625rem var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
  font-size: var(--bsft-font-size-md);
  line-height: 1.4;
  overflow-y: auto;
  resize: vertical;
  field-sizing: content;
}

.bsft-chat-draft::placeholder {
  color: var(--bsft-color-muted);
  opacity: 1;
}

.bsft-chat-draft:focus-visible {
  border-color: var(--bsft-color-primary);
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: -1px;
}

.bsft-chat-draft:disabled {
  opacity: 0.6;
}

/* The typing line keeps its height while empty, so a writer starting does not push the transcript;
   the words are flex items with a gap, so the translation keys carry no surrounding spaces. */
.bsft-chat-typing {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em;
  min-height: 1.25rem;
  margin: 0;
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-sm);
}

.bsft-chat-mention {
  color: var(--bsft-color-primary);
  font-weight: 600;
}

/* The link's visible text is the address itself, so it can be long: it wraps inside the bubble
   rather than widening it. */
.bsft-chat-link {
  color: var(--bsft-color-primary);
  overflow-wrap: anywhere;
  text-decoration: underline;
}

.bsft-chat-link-prompt-question {
  margin: 0 0 calc(var(--bsft-spacing) / 2);
}

/* The host is what the reader decides on, so it is the loudest line of the prompt, and the whole
   address stands under it unshortened. */
.bsft-chat-link-prompt-host {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.bsft-chat-link-prompt-address {
  margin: 0;
  font-size: var(--bsft-font-size-sm);
  color: var(--bsft-color-muted);
  overflow-wrap: anywhere;
}

.bsft-chat-link-prompt-notice {
  margin: calc(var(--bsft-spacing) / 2) 0 0;
  font-size: var(--bsft-font-size-sm);
}

.bsft-chat-suggestions {
  flex: 1 1 100%;
  max-height: 12rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
}

.bsft-chat-suggestion {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: var(--bsft-touch-target);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: 0;
  background: transparent;
  color: inherit;
  text-align: start;
}

.bsft-chat-suggestion:hover:not(:disabled),
.bsft-chat-suggestion:focus-visible {
  background: var(--bsft-color-border);
}

.bsft-chat-suggestion:disabled {
  opacity: 0.6;
}

.bsft-chat-suggestion-note {
  color: var(--bsft-color-muted);
  font-size: var(--bsft-font-size-xs);
}

.bsft-chat-badge {
  display: inline-flex;
}

@media (min-width: 48rem) {
  .bsft-chat {
    display: grid;
    grid-template-columns: minmax(14rem, 20rem) 1fr;
    gap: var(--bsft-spacing);
  }

  .bsft-chat .bsft-chat-conversations,
  .bsft-chat .bsft-chat-main {
    display: flex;
  }

  /* Both sit side by side here, so the conversation is not a place one has to leave and the host
     keeps its own navigation: the way back has nothing to do and the composer sits on the bottom
     of its own column rather than above somebody else's bar. */
  .bsft-chat-back {
    display: none;
  }

  .bsft-chat-composer {
    bottom: 0;
  }

  .bsft-chat-message {
    max-width: 70%;
  }
}

/* --- top layer ----------------------------------------------------------------------- */

/* --- sheet --------------------------------------------------------------------------- */

/* --- card and data state ------------------------------------------------------------- */

/* --- inputs -------------------------------------------------------------------------- */

/* The field chrome of the theme's form controls (BsftTextField, BsftTextArea, BsftSelect) and of
   every other element that carries .bsft-input, wherever it sits: inside a .bsft-form-field, in a
   table header, in a toolbar. The selectors are wrapped in :where() so they weigh nothing, which
   lets a component's own input rule (the combobox, the pickers) and the form field's rule win
   whatever their place in this file. */
:where(.bsft-input) {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  min-height: var(--bsft-touch-target);
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
  font-family: var(--bsft-font);
}

/* The browser default placeholder is a light grey that falls below 4.5:1 on the dark surface. */
:where(.bsft-input)::placeholder {
  color: var(--bsft-color-muted);
  opacity: 1;
}

:where(.bsft-input):focus-visible {
  border-color: var(--bsft-color-primary);
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 1px;
}

:where(.bsft-input):disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* An invalid control says so by its border as well as by the field's error list, which is what
   assistive technology reads through aria-describedby. Unlike the chrome above this rule has
   weight: inside a field it has to outweigh the form field's own control rule. */
.bsft-input[aria-invalid="true"],
.bsft-form-field :is(input, select, textarea)[aria-invalid="true"]:not([type="checkbox"]):not([type="radio"]) {
  border-color: var(--bsft-color-danger);
}

.bsft-textarea {
  width: 100%;
  resize: vertical;
}

.bsft-select {
  cursor: pointer;
}

/* Checkboxes and radio buttons keep their native shape (and with it the platform's own focus and
   high-contrast rendering) in the accent colour. */
.bsft-check {
  flex: none;
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--bsft-color-primary);
}

.bsft-check:focus-visible {
  outline: 2px solid var(--bsft-color-primary);
  outline-offset: 2px;
}

/* The label around a check control is its touch target: the box and its text together. */
.bsft-check-label {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--bsft-spacing) / 2);
  min-height: var(--bsft-touch-target);
  color: var(--bsft-color-text);
  font-family: var(--bsft-font);
  cursor: pointer;
}

.bsft-check-label:has(> .bsft-check:disabled) {
  opacity: 0.6;
  cursor: default;
}

.bsft-radio-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
  margin: 0;
  padding: calc(var(--bsft-spacing) / 2) var(--bsft-spacing);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
  font-family: var(--bsft-font);
}

.bsft-radio-group-inline {
  flex-direction: row;
  flex-wrap: wrap;
  column-gap: calc(var(--bsft-spacing) * 2);
}

.bsft-radio-group-legend {
  padding: 0 calc(var(--bsft-spacing) / 2);
  font-size: 0.875em;
  font-weight: 500;
  color: var(--bsft-color-text);
}

/* --- page header --------------------------------------------------------------------- */

/* --- avatar -------------------------------------------------------------------------- */

/* --- segmented control --------------------------------------------------------------- */

/* --- tooltip ------------------------------------------------------------------------- */

/* --- highlighted text ---------------------------------------------------------------- */

/* --- mobile navigation --------------------------------------------------------------- */

/* --- dock ---------------------------------------------------------------------------- */

/* --- markdown ------------------------------------------------------------------------ */

/* --- code block ---------------------------------------------------------------------- */

/* --- streaming text ------------------------------------------------------------------ */

/* --- bff forms ----------------------------------------------------------------------- */

/* --- app update ---------------------------------------------------------------------- */

/* --- print ------------------------------------------------------------------------ */

/* What a printed page of a BSFT screen is: the record the detail or list layout holds, without
   any of the chrome that only means something to somebody who can click it. Nothing here sets a
   colour — the printer's own rendering of the theme's tokens is closer to right than a guess at
   what paper wants, and a literal here would be the one place in this file that is not a
   token. */
.bsft-local-settings {
  display: grid;
  gap: calc(var(--bsft-spacing) * 2);
}

.bsft-local-settings-group {
  display: grid;
  gap: var(--bsft-spacing);
  padding: calc(var(--bsft-spacing) * 2);
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
}

.bsft-local-settings-row {
  display: grid;
  gap: calc(var(--bsft-spacing) / 2);
}

.bsft-local-settings-description,
.bsft-local-settings-status {
  color: var(--bsft-color-muted);
}

.bsft-local-settings-actions {
  display: flex;
  gap: var(--bsft-spacing);
}

@media print {
  .bsft-shell-header,
  .bsft-shell-nav,
  .bsft-shell-nav-toggle,
  .bsft-shell-nav-backdrop,
  .bsft-toasts,
  .bsft-list-filterbar,
  .bsft-list-bulk,
  .bsft-list-pager,
  .bsft-file-drop,
  .bsft-page-drop {
    display: none;
  }

  /* The shell stops reserving a viewport's height: on paper that is a blank first sheet. */
  .bsft-shell {
    display: block;
    min-height: 0;
  }

  /* A scroll container prints only what was scrolled into view, so both layouts give up their
     overflow and let the content paginate instead. */
  .bsft-list,
  .bsft-detail,
  .bsft-scroll-region {
    overflow: visible;
  }

  /* A row split across a page break is a row the reader has to reassemble; the header repeats
     on every sheet so the columns stay named. */
  .bsft-list tr {
    break-inside: avoid;
  }

  .bsft-list thead {
    display: table-header-group;
  }
}

/* --- API key and personal-token console ------------------------------------ */
.bsft-apikeys {
  display: grid;
  gap: calc(2 * var(--bsft-spacing));
  min-width: 0;
}
.bsft-apikey-create, .bsft-apikey-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--bsft-spacing);
}
.bsft-apikey-create > .bsft-input {
  flex: 1 1 12rem;
  min-width: 0;
}
.bsft-apikey-list {
  display: grid;
  gap: var(--bsft-spacing);
  list-style: none;
  margin: 0;
  padding: 0;
}
.bsft-apikey {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: calc(2 * var(--bsft-spacing));
  padding: calc(2 * var(--bsft-spacing));
  border: 1px solid var(--bsft-color-border);
  border-radius: var(--bsft-radius);
}
.bsft-apikey-details {
  display: grid;
  flex: 1 1 14rem;
  min-width: 0;
  gap: calc(var(--bsft-spacing) / 2);
  overflow-wrap: anywhere;
}
.bsft-apikey-disclosure {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bsft-spacing);
  padding: calc(2 * var(--bsft-spacing));
  border: 1px solid var(--bsft-color-primary);
  border-radius: var(--bsft-radius);
  background: var(--bsft-color-surface);
}
.bsft-apikey-disclosure > h3, .bsft-apikey-disclosure > p, .bsft-apikey-secret {
  flex-basis: 100%;
  min-width: 0;
  margin: 0;
}
.bsft-apikey-secret {
  display: block;
  overflow-wrap: anywhere;
  user-select: all;
}
.bsft-apikey-revoked-toggle[aria-pressed="true"] {
  border-color: var(--bsft-color-primary);
  color: var(--bsft-color-primary);
}
