/* controls.css — the low-level UI primitives Prism components are assembled from.
 *
 * A grid toolbar button, a chart legend toggle and a filter popover are the same
 * control wearing different labels. They live here so components inherit them
 * instead of each inventing a slightly different button.
 *
 * SCOPING. Every selector is a `.prism-*` class. Nothing here styles a bare
 * element selector, so dropping this file into an app cannot restyle that app's
 * own buttons and inputs. Requires tokens.css.
 *
 * THE CASCADE (docs/data-grid/DECISIONS.md D59). This file is `@layer
 * prism.primitives`; every component stylesheet is `@layer prism`. A layer's own
 * rules beat its nested sublayers, so:
 *
 *   host's unlayered CSS  >  @layer prism (components)  >  @layer prism.primitives
 *
 * — and that holds whatever order the <link>s are in, because it is the nesting
 * that decides and not source order. So a component overriding a primitive wins
 * by writing the rule, a host overriding either wins by writing the rule, and
 * neither needs `!important` or a specificity fight.
 *
 * Until v0.4.1 this file was *unlayered*, which put it above every component:
 * `.prism-data-grid__editor { height: 100%; border-radius: 0 }` computed to 24px
 * and 5px because `.prism-input--sm` won, silently. Do not "simplify" this back.
 *
 * The three `!important`s below are the deliberate exception, and the only ones
 * in the library: importance reverses layer order, so they beat even a host's
 * `!important`. They are scoped to Prism's own classes and subtree, and they
 * defend a semantic (`hidden` means hidden; screen-reader-only text stays out of
 * the layout) rather than an appearance. Nothing else here may use one.
 */

@layer prism.primitives {
  /* Box-sizing is applied to Prism's own subtree only — never globally. A library
   * that resets the host page's box model is a library that gets removed. */
  [data-prism-component],
  [data-prism-component] *,
  [data-prism-component] *::before,
  [data-prism-component] *::after {
    box-sizing: border-box;
  }

  [data-prism-component] {
    font-family: var(--prism-font-sans);
    font-size: var(--prism-text-md);
    line-height: var(--prism-leading-normal);
    color: var(--prism-ink-primary);
  }

  /* The `hidden` attribute means hidden, even on a control.
   *
   * The browser's own `[hidden] { display: none }` is a user-agent rule, so any
   * author `display` outranks it: `.prism-button`'s `display: inline-flex`
   * leaves a button a component believes it has hidden on screen, and clickable.
   * One rule here restores the attribute's meaning for every component at once
   * rather than each writing its own — and `!important` is what keeps it true
   * from the bottom layer, since a component's `display` in `@layer prism`
   * outranks a plain declaration here. Scoped to `[data-prism-component]` so it
   * can never touch the host page. */
  [data-prism-component] [hidden] {
    display: none !important;
  }

  /* ---------------------------------------------------------------- *
   * Focus
   * One ring, everywhere. :focus-visible only, so a mouse click never
   * paints a ring but a keyboard tab always does.
   * ---------------------------------------------------------------- */

  .prism-focusable:focus-visible,
  [data-prism-component] :focus-visible {
    outline: var(--prism-focus-ring-width) solid var(--prism-focus-ring);
    outline-offset: var(--prism-focus-ring-offset);
    border-radius: var(--prism-radius-sm);
  }

  /* ---------------------------------------------------------------- *
   * Screen-reader-only text
   * ---------------------------------------------------------------- */

  .prism-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  /* ---------------------------------------------------------------- *
   * Button
   * ---------------------------------------------------------------- */

  .prism-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--prism-space-2);
    height: var(--prism-control-height-md);
    padding: 0 var(--prism-control-padding-x);
    border: 1px solid var(--prism-border-strong);
    border-radius: var(--prism-radius-md);
    background: var(--prism-surface-1);
    color: var(--prism-ink-primary);
    font: inherit;
    font-weight: var(--prism-weight-medium);
    white-space: nowrap;
    cursor: pointer;
    /* The ink moves with the background, so a theme switch never shows the
       new ink on the old background (Phixly request 116). */
    transition:
      background-color var(--prism-duration-fast) var(--prism-ease),
      border-color var(--prism-duration-fast) var(--prism-ease),
      color var(--prism-duration-fast) var(--prism-ease);
  }

  .prism-button:hover:not(:disabled) {
    background: var(--prism-surface-2);
  }

  .prism-button:active:not(:disabled) {
    background: var(--prism-surface-active);
  }

  .prism-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .prism-button--primary {
    background: var(--prism-accent);
    border-color: var(--prism-accent);
    color: var(--prism-ink-on-accent);
  }

  .prism-button--primary:hover:not(:disabled) {
    background: var(--prism-accent-hover);
    border-color: var(--prism-accent-hover);
  }

  /* Toolbar/icon buttons: no chrome until interacted with, so a row of them
   * does not out-shout the data they sit above. */
  .prism-button--ghost {
    border-color: transparent;
    background: transparent;
  }

  .prism-button--ghost:hover:not(:disabled) {
    background: var(--prism-surface-hover);
  }

  .prism-button--icon {
    width: var(--prism-control-height-md);
    padding: 0;
  }

  .prism-button--sm {
    height: var(--prism-control-height-sm);
    padding: 0 var(--prism-space-3);
    font-size: var(--prism-text-sm);
  }

  .prism-button[aria-pressed="true"] {
    background: var(--prism-accent-subtle);
    border-color: var(--prism-accent);
  }

  /* ---------------------------------------------------------------- *
   * Text input / select
   * ---------------------------------------------------------------- */

  .prism-input,
  .prism-select {
    height: var(--prism-control-height-md);
    padding: 0 var(--prism-space-3);
    border: 1px solid var(--prism-border-strong);
    border-radius: var(--prism-radius-md);
    background: var(--prism-surface-1);
    color: var(--prism-ink-primary);
    font: inherit;
    min-width: 0;
  }

  .prism-input::placeholder {
    color: var(--prism-ink-muted);
  }

  .prism-input:focus,
  .prism-select:focus {
    border-color: var(--prism-accent);
  }

  .prism-input:disabled,
  .prism-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .prism-input--sm,
  .prism-select--sm {
    height: var(--prism-control-height-sm);
    font-size: var(--prism-text-sm);
  }

  /* ---------------------------------------------------------------- *
   * Checkbox and radio
   * The native controls, resized and tinted. Custom ones lose
   * indeterminate state and forced-colors support for no real gain —
   * and a radio's tick is the one thing a picker in single-select mode
   * cannot afford to have vanish under `forced-colors: active`.
   * One rule, because the difference is the browser's glyph and
   * nothing this file has an opinion about.
   * ---------------------------------------------------------------- */

  .prism-checkbox,
  .prism-radio {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--prism-accent);
    cursor: pointer;
    flex: none;
  }

  /* ---------------------------------------------------------------- *
   * Menu / popover
   * ---------------------------------------------------------------- */

  .prism-menu {
    position: absolute;
    z-index: var(--prism-z-dropdown);
    min-width: 180px;
    padding: var(--prism-space-2);
    border: 1px solid var(--prism-border);
    border-radius: var(--prism-radius-lg);
    background: var(--prism-surface-1);
    box-shadow: var(--prism-shadow-2);
  }

  .prism-menu__item {
    display: flex;
    align-items: center;
    gap: var(--prism-space-3);
    width: 100%;
    padding: var(--prism-space-2) var(--prism-space-3);
    border: 0;
    border-radius: var(--prism-radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
  }

  .prism-menu__item:hover,
  .prism-menu__item:focus-visible {
    background: var(--prism-surface-hover);
  }

  .prism-menu__item[aria-disabled="true"] {
    color: var(--prism-ink-muted);
    cursor: not-allowed;
  }

  /* A listbox's active option while focus stays elsewhere (the typing
     surface's `{` picker names it through aria-activedescendant). */
  .prism-menu__item[role="option"][aria-selected="true"] {
    background: var(--prism-surface-hover);
  }

  /* An option that opens a list of its own (the typing picker's branch). */
  .prism-menu__item[role="option"][data-prism-branch]::after {
    content: "A";
    margin-inline-start: auto;
    padding-inline-start: var(--prism-space-4);
    color: var(--prism-ink-muted);
  }

  .prism-menu__separator {
    height: 1px;
    margin: var(--prism-space-2) 0;
    background: var(--prism-border-hairline);
    border: 0;
  }

  /* An on/off item (Phixly 181): a tick box at its start, ticked or empty. */
  .prism-menu__tick {
    display: inline-flex;
    flex: none;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--prism-border-strong);
    border-radius: 3px;
    background: var(--prism-surface-1);
    color: var(--prism-surface-1);
  }

  .prism-menu__toggle[aria-checked="true"] .prism-menu__tick {
    border-color: var(--prism-accent);
    background: var(--prism-accent);
  }

  .prism-menu__toggle-words {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    text-align: start;
  }

  /* A greyed toggle (Phixly 182): its reason a muted line under its label. */
  .prism-menu__toggle[aria-disabled="true"] .prism-menu__toggle-label {
    color: var(--prism-ink-muted);
  }

  .prism-menu__toggle[aria-disabled="true"] .prism-menu__tick {
    opacity: 0.55;
  }

  .prism-menu__toggle-reason {
    color: var(--prism-ink-muted);
    font-size: var(--prism-text-xs);
    white-space: normal;
  }

  /* An item's trailing value (a price), muted at its right (Phixly 173). */
  .prism-menu__value {
    margin-inline-start: auto;
    padding-inline-start: var(--prism-space-4);
    color: var(--prism-ink-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* ---------------------------------------------------------------- *
   * Split button — core/split-button.js. The button and its chevron are
   * one unit: one border, one hover; the chevron narrow, a hairline
   * between the two only while the pair is lit.
   * ---------------------------------------------------------------- */

  .prism-split-button {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid transparent;
    border-radius: var(--prism-radius-md);
    color: var(--prism-ink-secondary);
  }

  .prism-split-button:hover,
  .prism-split-button:focus-within,
  .prism-split-button[data-open] {
    border-color: var(--prism-accent);
    color: var(--prism-ink-primary);
  }

  .prism-split-button__main,
  .prism-split-button__chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
  }

  .prism-split-button__main {
    gap: var(--prism-space-2);
    min-width: 26px;
    height: 26px;
    padding: 0 var(--prism-space-2);
    border-radius: var(--prism-radius-md) 0 0 var(--prism-radius-md);
  }

  .prism-split-button__chevron {
    width: 14px;
    padding: 0;
    border-inline-start: 1px solid transparent;
    border-radius: 0 var(--prism-radius-md) var(--prism-radius-md) 0;
  }

  .prism-split-button__chevron svg {
    width: 10px;
    height: 10px;
  }

  .prism-split-button:hover .prism-split-button__chevron,
  .prism-split-button:focus-within .prism-split-button__chevron,
  .prism-split-button[data-open] .prism-split-button__chevron {
    border-inline-start-color: var(--prism-border-hairline);
  }

  .prism-split-button__main:hover,
  .prism-split-button__chevron:hover,
  .prism-split-button[data-open] .prism-split-button__chevron {
    background: var(--prism-surface-hover);
  }

  .prism-split-button__main:focus-visible {
    outline: 2px solid var(--prism-focus-ring);
    outline-offset: -2px;
  }

  .prism-split-button__main[aria-pressed="true"] {
    background: var(--prism-accent-tint);
  }

  .prism-split-button__glyph,
  .prism-split-button__label {
    display: inline-flex;
  }

  .prism-split-button__glyph[hidden],
  .prism-split-button__label[hidden] {
    display: none;
  }

  /* The compact row: a set of choices as icons, each still a menu item. */
  .prism-split-button__row {
    display: flex;
    gap: var(--prism-space-1);
  }

  .prism-split-button__choice {
    width: auto;
    padding: var(--prism-space-2);
  }

  /* A long list (a table's columns) scrolls inside the menu, never off the screen. */
  .prism-split-button__menu {
    max-height: min(420px, 70vh);
    overflow-y: auto;
  }

  .prism-split-button__menu .prism-menu__item[aria-checked="true"]:not([role="menuitemcheckbox"]) {
    background: var(--prism-accent-tint);
    color: var(--prism-ink-primary);
  }

  .prism-split-button__menu .prism-menu__item[data-danger] {
    color: var(--prism-status-critical);
  }

  /* ---------------------------------------------------------------- *
   * Zoom — core/zoom-control.js. Small and discreet: it shares a status
   * row with other words, so at rest it is a 12px glyph, and the
   * percentage only when it is not 100%.
   * ---------------------------------------------------------------- */

  .prism-zoom {
    display: inline-flex;
    align-items: center;
    gap: var(--prism-space-1);
    height: 20px;
    padding: 0 var(--prism-space-2);
    border: 1px solid transparent;
    border-radius: var(--prism-radius-sm);
    background: transparent;
    color: var(--prism-ink-muted);
    font: inherit;
    font-size: var(--prism-text-xs);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
  }

  .prism-zoom:hover,
  .prism-zoom[aria-expanded="true"] {
    border-color: var(--prism-border-hairline);
    color: var(--prism-ink-primary);
  }

  .prism-zoom:focus-visible {
    outline: 2px solid var(--prism-focus-ring);
    outline-offset: 1px;
  }

  .prism-zoom__percent[hidden] {
    display: none;
  }

  .prism-zoom__panel {
    display: flex;
    align-items: center;
    gap: var(--prism-space-2);
    padding: var(--prism-space-2) var(--prism-space-3);
  }

  .prism-zoom__step,
  .prism-zoom__reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    min-width: 22px;
    padding: 0 var(--prism-space-1);
    border: 1px solid transparent;
    border-radius: var(--prism-radius-sm);
    background: transparent;
    color: var(--prism-ink-secondary);
    font: inherit;
    font-size: var(--prism-text-xs);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
  }

  .prism-zoom__reset {
    min-width: 40px;
  }

  .prism-zoom__step:hover:not(:disabled),
  .prism-zoom__reset:hover {
    border-color: var(--prism-border-hairline);
    color: var(--prism-ink-primary);
  }

  .prism-zoom__step:disabled {
    color: var(--prism-ink-muted);
    cursor: default;
  }

  .prism-zoom__slider {
    width: 96px;
    accent-color: var(--prism-accent);
  }

  /* ---------------------------------------------------------------- *
   * Anchored surfaces — core/surface.js writes the position, this
   * writes the chrome. Fixed, not absolute, so a surface escapes a
   * scroller that clips its own overflow (the grid does).
   *
   * After .prism-menu on purpose: a role="menu" surface is usually a
   * .prism-menu, and the two set the same properties, so the later
   * one has to be the one that carries `position: fixed`.
   * ---------------------------------------------------------------- */

  .prism-surface {
    position: fixed;
    top: 0;
    left: 0;
    z-index: var(--prism-z-dropdown, 100);
    border: 1px solid var(--prism-border-hairline, #e1e0d9);
    border-radius: var(--prism-radius-lg, 8px);
    background: var(--prism-surface-1, #fcfcfb);
    box-shadow: var(--prism-shadow-2, 0 2px 8px rgba(11, 11, 11, 0.12));
  }

  /* CH15's rule again, and it needs its own: a surface is appended to <body>,
   * so `[data-prism-component] [hidden]` never matches it. The `display` that
   * would otherwise win is the component's own on the panel it hands over —
   * `.prism-data-grid__popout { display: flex }`, in `@layer prism`, above this
   * file — so a closed surface would stay on screen, fixed-positioned. */
  .prism-surface[hidden] {
    display: none !important;
  }

  /* A centred dialog (placement "centre") stands over its scrim, and both
   * over every menu. The blur is the page's, not the dialog's: the scrim
   * is the surface's sibling, so nothing inside the dialog is softened. */
  .prism-surface--centre {
    z-index: var(--prism-z-modal, 300);
    box-shadow: var(--prism-shadow-3, 0 8px 28px rgba(11, 11, 11, 0.22));
  }

  .prism-surface-backdrop {
    position: fixed;
    z-index: var(--prism-z-overlay, 200);
    background: var(--prism-surface-overlay, rgba(11, 11, 11, 0.32));
  }

  .prism-surface-backdrop--blur {
    background: color-mix(in srgb, var(--prism-surface-overlay, rgba(11, 11, 11, 0.32)) 50%, transparent);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }

  /* core/dialog.js: a title, the question, and the two answers at its foot. */
  .prism-dialog {
    display: flex;
    flex-direction: column;
    gap: var(--prism-space-3, 8px);
    width: min(420px, calc(100vw - 32px));
    padding: var(--prism-space-4, 12px) var(--prism-space-5, 16px);
    color: var(--prism-ink-primary);
  }

  .prism-dialog__title {
    margin: 0;
    font-size: var(--prism-text-md, 14px);
    font-weight: 600;
  }

  .prism-dialog__body {
    margin: 0;
    color: var(--prism-ink-secondary);
    font-size: var(--prism-text-sm, 12px);
  }

  .prism-dialog__buttons {
    display: flex;
    justify-content: flex-end;
    gap: var(--prism-space-2, 4px);
    margin-top: var(--prism-space-2, 4px);
  }

  /* Not --primary: an answer that cannot be taken back is red, hovered too. */
  .prism-dialog__go--danger,
  .prism-dialog__go--danger:hover:not(:disabled) {
    border-color: var(--prism-status-critical);
    background: var(--prism-status-critical);
    color: var(--prism-ink-on-accent);
  }

  /* A .prism-menu inside brings its own padding; a plain div does not. */
  .prism-surface--menu {
    padding: var(--prism-space-2, 4px);
  }

  .prism-surface--tooltip {
    z-index: var(--prism-z-tooltip, 400);
    max-width: 34ch;
    padding: var(--prism-space-2, 4px) var(--prism-space-3, 8px);
    color: var(--prism-ink-secondary, #52514e);
    font-size: var(--prism-text-sm, 12px);
    box-shadow: var(--prism-shadow-3, 0 8px 24px rgba(11, 11, 11, 0.16));
  }
  /* A tip the keyboard opened is never in the pointer's way (tooltip.js). */
  .prism-surface--tooltip-keyboard {
    pointer-events: none;
  }

  /* ---------------------------------------------------------------- *
   * Tips — core/tips.js. A surface with a pointer on the side facing
   * its anchor; tips.js writes the side and where along it the pointer
   * sits. Narrower than the viewport by a gutter, so a phone keeps it.
   * ---------------------------------------------------------------- */

  .prism-tip {
    z-index: var(--prism-z-overlay);
    width: max-content;
    max-width: min(300px, calc(100vw - 2 * var(--prism-space-5)));
    padding: var(--prism-space-4) var(--prism-space-4) var(--prism-space-3);
    color: var(--prism-ink-primary);
    font-size: var(--prism-text-md);
    box-shadow: var(--prism-shadow-3);
    animation: prism-tip-in var(--prism-duration-base) var(--prism-ease);
  }

  @keyframes prism-tip-in {
    from { opacity: 0; transform: translateY(2px); }
  }

  .prism-tip__title {
    font-weight: var(--prism-weight-bold);
  }

  .prism-tip__body {
    margin: var(--prism-space-2) 0 0;
    color: var(--prism-ink-secondary);
    line-height: 1.45;
  }

  .prism-tip__body[hidden],
  .prism-tip__skip[hidden] {
    display: none;
  }

  .prism-tip__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--prism-space-3);
    margin-top: var(--prism-space-4);
  }

  .prism-tip__count {
    color: var(--prism-ink-muted);
    font-size: var(--prism-text-sm);
    font-variant-numeric: tabular-nums;
  }

  .prism-tip__actions {
    display: flex;
    gap: var(--prism-space-2);
    margin-inline-start: auto;
  }

  .prism-tip .prism-button:focus-visible {
    outline: 2px solid var(--prism-focus-ring);
    outline-offset: 1px;
  }

  /* A square turned 45°, wearing the surface's fill and two of its edges. */
  .prism-tip__pointer {
    position: absolute;
    width: 10px;
    height: 10px;
    background: inherit;
    border: inherit;
    border-width: 0;
    transform: rotate(45deg);
  }

  .prism-tip[data-side="bottom"] .prism-tip__pointer {
    top: -6px;
    left: calc(var(--prism-tip-pointer, 20px) - 5px);
    border-top-width: 1px;
    border-left-width: 1px;
  }

  .prism-tip[data-side="top"] .prism-tip__pointer {
    bottom: -6px;
    left: calc(var(--prism-tip-pointer, 20px) - 5px);
    border-bottom-width: 1px;
    border-right-width: 1px;
  }

  .prism-tip[data-side="right"] .prism-tip__pointer {
    left: -6px;
    top: calc(var(--prism-tip-pointer, 20px) - 5px);
    border-bottom-width: 1px;
    border-left-width: 1px;
  }

  .prism-tip[data-side="left"] .prism-tip__pointer {
    right: -6px;
    top: calc(var(--prism-tip-pointer, 20px) - 5px);
    border-top-width: 1px;
    border-right-width: 1px;
  }

  @media (prefers-reduced-motion: reduce) {
    .prism-tip {
      animation: none;
    }
  }

  /* ---------------------------------------------------------------- *
   * Badge / tag
   * ---------------------------------------------------------------- */

  .prism-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--prism-space-2);
    padding: 1px var(--prism-space-3);
    border-radius: var(--prism-radius-pill);
    background: var(--prism-surface-2);
    color: var(--prism-ink-secondary);
    font-size: var(--prism-text-sm);
    font-weight: var(--prism-weight-medium);
    white-space: nowrap;
  }

  /* Status badges pair a colour with a dot AND keep their label — colour never
   * carries the meaning on its own. */
  .prism-badge--good { color: var(--prism-status-good); }
  .prism-badge--warning { color: var(--prism-status-warning); }
  .prism-badge--serious { color: var(--prism-status-serious); }
  .prism-badge--critical { color: var(--prism-status-critical); }

  .prism-badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
  }

  /* ---------------------------------------------------------------- *
   * Toolbar — the strip a component puts its controls in
   * ---------------------------------------------------------------- */

  .prism-toolbar {
    display: flex;
    align-items: center;
    gap: var(--prism-space-3);
    padding: var(--prism-space-3);
    background: var(--prism-surface-2);
    border-bottom: 1px solid var(--prism-border);
  }

  .prism-toolbar__spacer {
    flex: 1 1 auto;
  }

  /* ---------------------------------------------------------------- *
   * States — empty, loading, error
   * Every component that loads data shows all three. Defining them once
   * is what stops each component inventing its own empty state.
   * ---------------------------------------------------------------- */

  .prism-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--prism-space-3);
    padding: var(--prism-space-8) var(--prism-space-5);
    text-align: center;
    color: var(--prism-ink-secondary);
  }

  .prism-state__title {
    font-size: var(--prism-text-lg);
    font-weight: var(--prism-weight-medium);
    color: var(--prism-ink-primary);
  }

  .prism-state__detail {
    max-width: 42ch;
    color: var(--prism-ink-muted);
  }

  .prism-state--error .prism-state__title {
    color: var(--prism-status-critical);
  }

  .prism-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--prism-border-strong);
    border-top-color: var(--prism-accent);
    border-radius: 50%;
    animation: prism-spin 700ms linear infinite;
  }

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

  @media (prefers-reduced-motion: reduce) {
    .prism-spinner {
      animation-duration: 2s;
    }
  }


  /* ---------------------------------------------------------------- *
   * The option row — a setting is a labelled row, not a scatter of pills
   *
   * Ported from notes/archive/report-studio/prototypes/css/04-rail.css (round 8,
   * lines 600-843). Round 1 drew every choice as free-floating pills:
   * four rows of them is twenty round objects with no relationship drawn
   * between any of them, and the eye has to find the groups before it
   * can read one. So:
   *
   *   - the label sits in its OWN COLUMN, sentence case, not shouted in
   *     uppercase - one column of labels is one thing to scan
   *   - a set of choices is drawn JOINED, as one control with N options,
   *     instead of N controls that happen to be adjacent
   *   - and the KIND of control is derived from the shape of the choice
   *     (controls.js `controlKind()`), so a long or crowded set becomes
   *     a dropdown rather than a wrapped row nobody can parse
   *
   * These are primitives rather than a component's own because BOTH the
   * report studio's rail and doc-editor's option editor draw them, and a
   * control styled twice is a control that will one day be styled two
   * different ways.
   * ---------------------------------------------------------------- */

  .prism-optrow {
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr);
    gap: 0 14px;
    align-items: start;
    margin-bottom: 15px;
  }
  .prism-optrow:last-child {
    margin-bottom: 0;
  }
  .prism-optrow--stack {
    grid-template-columns: minmax(0, 1fr);
  }
  .prism-optrow__label {
    font-size: var(--prism-text-md);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--prism-ink-secondary);
    padding-top: 7px;
    line-height: 1.32;
  }
  .prism-optrow--stack .prism-optrow__label {
    padding-top: 0;
    margin-bottom: 6px;
  }

  /* A grid item's min-width is `auto`, and a <select>'s min-content width
     is its WIDEST OPTION - so `width: 100%` does not stop it forcing the
     column open. This is what made the write pop-out 430px wide inside a
     343px panel. */
  .prism-optrow__cell {
    min-width: 0;
  }
  .prism-optselect {
    min-width: 0;
  }

  /* A narrow rail: the label column stops paying for itself. The query is
     on the container and not the viewport because the same row is drawn
     in a 500px rail and a 360px pop-out on one screen. The panel that
     holds these sets `container-type: inline-size`. */
  @container (max-width: 410px) {
    .prism-optrow {
      grid-template-columns: minmax(0, 1fr);
    }
    .prism-optrow__label {
      padding-top: 0;
      margin-bottom: 6px;
    }
  }

  /* Pick one, of two or three short options - one control, N options.
   *
   * NO ellipsis, deliberately. Round 2's first pass clipped an option to
   * `Write "None recorde...`, and the truncation check passed, because a
   * clipped flex item has scrollWidth == clientWidth - so the CSS hid the
   * bug from the eye AND from the check at the same time. A control label
   * that has been cut in half is never the right answer, so this control
   * is allowed to overflow instead: then it is visible, and measurable,
   * and `controlKind()` is what has to be right. */
  .prism-optset {
    display: flex;
    width: fit-content;
    border: 1px solid var(--prism-border-strong);
    border-radius: var(--prism-radius-md);
    background: var(--prism-surface-page);
  }
  /* **The UA chrome is reset here, on the class.** The prototype resets `button`
     globally; a library may not (CONTRACT: never style a bare element selector,
     or dropping this file into an app restyles the app's own buttons). So every
     button class has to spell it out — and a class that forgets shows as a
     **2px `outset` border on three sides** and a grey button face, because
     `border-right` overrides only the fourth. That is exactly what this control
     shipped as. */
  .prism-optset__opt {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--prism-ink-muted);
    cursor: pointer;

    /* **4px 10px, not the prototype's 6px 12px** — a deliberate divergence, at
       the owner's request after using it. The type is the prototype's size; it
       is the air around it that made a two-word answer read as a bigger object
       than the setting it answers. `PAD` in `controls.js` is the horizontal
       pair and moves with it, or the width budget starts over-estimating every
       row and pushing sets into dropdowns that fit. */
    padding: 4px 10px;
    font-size: var(--prism-text-md);
    border-right: 1px solid var(--prism-border-strong);
    white-space: nowrap;
    flex: 0 0 auto;
  }
  .prism-optset__opt:first-child {
    border-radius: var(--prism-radius-md) 0 0 var(--prism-radius-md);
  }
  .prism-optset__opt:last-child {
    border-radius: 0 var(--prism-radius-md) var(--prism-radius-md) 0;
    border-right: 0;
  }
  .prism-optset__opt:hover {
    background: var(--prism-surface-hover);
    color: var(--prism-ink-primary);
  }
  .prism-optset__opt[aria-pressed="true"] {
    background: color-mix(in srgb, var(--prism-accent) 17%, var(--prism-surface-1));
    color: var(--prism-ink-primary);
    font-weight: 600;
  }

  /* A choice about shape, drawn. An icon at rest is quieter than a word
     at rest, or the row reads as four equally-loud pictures with no
     answer among them. */
  .prism-optset--icons .prism-optset__opt {
    padding: 4px 9px;
    display: grid;
    place-items: center;
    color: var(--prism-ink-secondary);
    opacity: 0.68;
  }
  .prism-optset--icons .prism-optset__opt svg {
    display: block;
  }
  .prism-optset--icons .prism-optset__opt:hover {
    opacity: 1;
  }
  .prism-optset--icons .prism-optset__opt[aria-pressed="true"] {
    opacity: 1;
    color: var(--prism-ink-primary);
  }

  /* Pick one, of many or of long ones. */
  .prism-optselect {
    width: 100%;
    max-width: 340px;
    padding: 6px 9px;
    font: inherit;
    font-size: var(--prism-text-md);
    color: var(--prism-ink-primary);
    background: var(--prism-surface-page);
    border: 1px solid var(--prism-border-strong);
    border-radius: var(--prism-radius-md);
  }
  .prism-optselect:hover {
    border-color: var(--prism-ink-muted);
  }

  /* Pick any - a different shape, because it is a different question,
     and telling pick-one from pick-many at a glance is worth a control
     kind of its own. */
  /* **A yes/no is one box and one word** — "a small badge saying Show with a
     checkbox", not two buttons. The label is a real `<label>` wrapping a real
     `<input type="checkbox">`, so the word is part of the hit target and the
     control is a checkbox to a screen reader without this file saying so. */
  .prism-optcheck {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    color: var(--prism-ink-secondary);
    font-size: var(--prism-text-md);
    cursor: pointer;
    user-select: none;
  }
  .prism-optcheck__box {
    inline-size: 13px;
    block-size: 13px;
    margin: 0;
    flex: none;
    accent-color: var(--prism-accent);
    cursor: pointer;
  }

  .prism-optmulti {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
    gap: 1px 12px;
  }
  .prism-optmulti__pick {
    /* The same reset, for the same reason as `.prism-optset__opt` above. */
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;

    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 2px;
    font-size: var(--prism-text-md);
    color: var(--prism-ink-secondary);
    text-align: left;
  }
  .prism-optmulti__pick:hover {
    color: var(--prism-ink-primary);
  }
  .prism-optmulti__box {
    width: 15px;
    height: 15px;
    flex: none;
    display: grid;
    place-items: center;
    border: 1px solid var(--prism-border-strong);
    border-radius: var(--prism-radius-sm);
    font-size: 10px;
    line-height: 1;
    color: transparent;
  }
  .prism-optmulti__pick[aria-pressed="true"] {
    color: var(--prism-ink-primary);
  }
  .prism-optmulti__pick[aria-pressed="true"] .prism-optmulti__box {
    background: var(--prism-accent);
    border-color: var(--prism-accent);
    color: var(--prism-ink-on-accent);
  }
  /* ---------------------------------------------------------------- *
   * Outcome button (core/outcome-button.js, Phixly 163) — one width
   * whatever it says, tinted in its state's hue, always with its symbol;
   * its panel a title, plain words and the actions.
   * ---------------------------------------------------------------- */

  .prism-outcome {
    --prism-outcome-hue: var(--prism-border-strong);
    display: inline-flex;
    box-sizing: border-box;
    align-items: center;
    gap: var(--prism-space-3, 8px);
    width: var(--prism-outcome-width, 230px);
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid color-mix(in srgb, var(--prism-outcome-hue) 55%, transparent);
    border-radius: var(--prism-radius-md, 6px);
    background: color-mix(in srgb, var(--prism-outcome-hue) 10%, var(--prism-surface-1));
    color: color-mix(in srgb, var(--prism-outcome-hue) 80%, var(--prism-ink-primary));
    font: inherit;
    font-size: var(--prism-text-sm);
    text-align: left;
    cursor: pointer;
  }
  .prism-outcome:hover {
    background: color-mix(in srgb, var(--prism-outcome-hue) 18%, var(--prism-surface-1));
  }
  .prism-outcome:focus-visible {
    outline: var(--prism-focus-ring-width) solid var(--prism-focus-ring);
    outline-offset: 1px;
  }
  .prism-outcome[aria-expanded="true"] {
    background: color-mix(in srgb, var(--prism-outcome-hue) 22%, var(--prism-surface-1));
  }
  .prism-outcome__symbol {
    display: inline-flex;
    flex: none;
    align-items: center;
  }
  .prism-outcome__ring,
  .prism-outcome__dot {
    box-sizing: border-box;
    width: 8px;
    height: 8px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
  }
  .prism-outcome__dot {
    background: currentColor;
  }
  .prism-outcome__char {
    font-weight: var(--prism-weight-bold);
    line-height: 1;
  }
  .prism-outcome__words {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .prism-outcome__chevron {
    flex: none;
    font-size: 10px;
    opacity: 0.75;
  }
  /* Compact (Phixly 167): the symbol and ▾ only, for a narrow row; the words are in its title. */
  .prism-outcome--compact {
    width: auto;
    gap: 4px;
    padding: 4px 8px;
  }
  .prism-outcome--compact .prism-outcome__words {
    display: none;
  }
  .prism-outcome__said {
    margin-top: 4px;
    color: var(--prism-ink-primary);
  }
  .prism-outcome__panel {
    box-sizing: border-box;
    width: max-content;
    max-width: min(380px, calc(100vw - 32px));
    padding: 12px 14px;
  }
  .prism-outcome__title {
    color: var(--prism-ink-primary);
    font-weight: var(--prism-weight-bold);
  }
  .prism-outcome__body {
    margin-top: 4px;
    color: var(--prism-ink-secondary);
    line-height: var(--prism-leading-normal, 1.45);
  }
  .prism-outcome__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--prism-space-3, 8px);
    margin-top: 12px;
  }
  .prism-outcome__action--primary {
    border-color: var(--prism-accent);
    background: var(--prism-accent-tint, color-mix(in srgb, var(--prism-accent) 12%, transparent));
    color: var(--prism-accent);
  }

  /* ---------------------------------------------------------------- *
   * Step button (core/step-button.js, Phixly 173) — the symbol · the
   * name · the ▾, one unit in one tint, a 1.5 px divider before the ▾.
   * The name and ▾ are the split button's, its own border and hover
   * given over to the unit.
   * ---------------------------------------------------------------- */

  .prism-step-button {
    --prism-step-button-hue: var(--prism-border-strong);
    --prism-step-button-border: 1.5px;
    --prism-step-button-radius: var(--prism-radius-md, 6px);
    --prism-step-button-wash: var(--prism-ink-muted);
    display: inline-flex;
    flex: none;
    box-sizing: border-box;
    align-items: stretch;
    min-width: 0;
    height: 32px;
    border: var(--prism-step-button-border) solid var(--prism-border-strong);
    border-radius: var(--prism-step-button-radius);
    background: var(--prism-surface-1);
    color: var(--prism-ink-primary);
    font-size: var(--prism-text-sm);
  }

  .prism-step-button.is-tinted {
    --prism-step-button-wash: var(--prism-step-button-hue);
    border-color: color-mix(in srgb, var(--prism-step-button-hue) 85%, transparent);
    background: color-mix(in srgb, var(--prism-step-button-hue) 9%, var(--prism-surface-1));
  }

  /* The step on show: a stronger ring, in its hue (the ink's on a plain one). */
  /* Drawn INSIDE its edge (Phixly 180): a ring outside was clipped top and
     bottom by a scrolling row, leaving only its sides. An outline paints over
     the parts' washes and is never cut by a scroller, at any zoom. */
  .prism-step-button.is-selected {
    outline: 2.5px solid var(--prism-step-button-ring, var(--prism-ink-secondary));
    outline-offset: -2.5px;
  }

  .prism-step-button.is-tinted.is-selected {
    --prism-step-button-ring: var(--prism-step-button-hue);
  }

  .prism-step-button__go {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 3px;
    margin: 0;
    padding: 0 6px 0 10px;
    border: 0;
    border-radius: var(--prism-step-button-radius) 0 0 var(--prism-step-button-radius);
    background: transparent;
    color: var(--prism-ink-secondary);
    font: inherit;
    font-weight: var(--prism-weight-bold);
    cursor: pointer;
  }

  .prism-step-button.is-tinted .prism-step-button__go {
    color: var(--prism-step-button-hue);
  }

  .prism-step-button__go:empty {
    padding: 0 0 0 4px;
  }

  .prism-step-button__go[aria-disabled="true"] {
    cursor: default;
  }

  .prism-step-button__char {
    width: 12px;
    font-size: 15px;
    line-height: 1;
    text-align: center;
  }

  .prism-step-button__ring,
  .prism-step-button__dot {
    box-sizing: border-box;
    width: 9px;
    height: 9px;
    border-radius: 50%;
  }

  .prism-step-button__ring {
    border: 1.5px solid currentColor;
  }

  .prism-step-button__dot {
    background: currentColor;
  }

  .prism-step-button__dot.is-running {
    animation: prism-step-button-pulse 1s ease-in-out infinite;
  }

  @keyframes prism-step-button-pulse {
    50% {
      opacity: 0.35;
    }
  }

  /* A running step the host can stop (Phixly 185): the Stop square, in a
     ring that pulses — still running, and pressable. */
  .prism-step-button__stop {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
  }

  .prism-step-button__stop::after {
    content: "";
    position: absolute;
    inset: -3px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    animation: prism-step-button-pulse 1s ease-in-out infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    .prism-step-button__dot.is-running,
    .prism-step-button__stop::after {
      animation: none;
    }
  }

  /* The name and ▾: the split button's, on the unit's tint — the ▾ the SAME
     tint as the body (Paul, 21 Oct), a divider in the hue before it. */
  .prism-step-button__split.prism-split-button {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    border-radius: 0 var(--prism-step-button-radius) var(--prism-step-button-radius) 0;
    color: inherit;
  }

  .prism-step-button__split .prism-split-button__main {
    flex: 1 1 auto;
    min-width: 0;
    height: auto;
    padding: 0 10px 0 4px;
    border-radius: 0;
    font-weight: var(--prism-weight-medium, 500);
  }

  .prism-step-button__split .prism-split-button__label {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .prism-step-button__split .prism-split-button__chevron,
  .prism-step-button__split:hover .prism-split-button__chevron,
  .prism-step-button__split:focus-within .prism-split-button__chevron,
  .prism-step-button__split[data-open] .prism-split-button__chevron {
    flex: none; /* the ▾ never gives way: only the name does (Phixly 175) */
    width: 24px;
    border-inline-start: 1.5px solid color-mix(in srgb, var(--prism-step-button-wash) 60%, var(--prism-border));
    border-radius: 0 var(--prism-step-button-radius) var(--prism-step-button-radius) 0;
    background: transparent;
  }

  /* Hover, press, focus: the same in every state — the part under the
     pointer washes in the state's hue, a step more while pressed. */
  .prism-step-button__go:hover:not([aria-disabled="true"]),
  .prism-step-button__split .prism-split-button__main:hover,
  .prism-step-button__split .prism-split-button__chevron:hover,
  .prism-step-button__split[data-open] .prism-split-button__chevron {
    background: color-mix(in srgb, var(--prism-step-button-wash) 16%, transparent);
  }

  .prism-step-button__go:active:not([aria-disabled="true"]),
  .prism-step-button__split .prism-split-button__main:active,
  .prism-step-button__split .prism-split-button__chevron:active {
    background: color-mix(in srgb, var(--prism-step-button-wash) 26%, transparent);
  }

  .prism-step-button__go:focus-visible,
  .prism-step-button__split .prism-split-button__main:focus-visible {
    outline: var(--prism-focus-ring-width, 2px) solid var(--prism-focus-ring);
    outline-offset: -2px;
  }

  .prism-step-button-probe {
    position: absolute;
    top: 0;
    left: -9999px;
    display: flex;
    visibility: hidden;
  }

  /* ---------------------------------------------------------------- *
   * Linked row (core/linked-row.js, Phixly 173) — one line edge to edge,
   * its segments sharing the room; flush, the first and last items sit
   * against the edges with a flat outer side.
   * ---------------------------------------------------------------- */

  .prism-linked-row {
    --prism-linked-row-line: 1.5px;
    display: flex;
    align-items: center;
    min-width: 0;
  }

  .prism-linked-row__line {
    flex: 1 1 24px;
    min-width: 16px;
    height: var(--prism-linked-row-line);
    background: var(--prism-border-strong);
  }

  .prism-linked-row__item {
    flex: none;
  }

  /* SHRINK (Phixly 174): on a narrow row every item gives way alike from its
     one width — a step button's name ending in …, the whole of it in its
     tooltip — so they stay one width. */
  .prism-linked-row--shrink > .prism-linked-row__item {
    flex: 0 1 auto;
    min-width: 0;
  }

  /* A FLOOR (Phixly 175): the items give way down to it, one width still;
     past it the row scrolls sideways inside its scroll shadow. */
  .prism-linked-row--floored > .prism-linked-row__item {
    min-width: var(--prism-linked-row-floor, 0);
  }

  .prism-linked-row--flush > .prism-linked-row__item:first-child {
    border-inline-start-width: 0;
    border-start-start-radius: 0;
    border-end-start-radius: 0;
  }

  .prism-linked-row--flush > .prism-linked-row__item:last-child {
    border-inline-end-width: 0;
    border-start-end-radius: 0;
    border-end-end-radius: 0;
  }

  .prism-linked-row--flush > .prism-step-button:first-child .prism-step-button__go {
    border-radius: 0;
    padding-inline-start: 14px;
  }

  .prism-linked-row--flush > .prism-step-button:last-child .prism-step-button__split,
  .prism-linked-row--flush > .prism-step-button:last-child .prism-split-button__chevron {
    border-start-end-radius: 0;
    border-end-end-radius: 0;
  }

  /* ---------------------------------------------------------------- *
   * Scroll shadow (core/scroll-shadow.js, Phixly 173) — a strip that
   * scrolls sideways, a shadow only on a side that hides something.
   * ---------------------------------------------------------------- */

  .prism-scroll-shadow {
    position: relative;
    min-width: 0;
  }

  .prism-scroll-shadow::before,
  .prism-scroll-shadow::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 1;
    width: 22px;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--prism-duration-fast, 150ms);
  }

  .prism-scroll-shadow::before {
    left: 0;
    background: linear-gradient(to right, var(--prism-shadow-color, rgba(11, 11, 11, 0.25)), transparent);
  }

  .prism-scroll-shadow::after {
    right: 0;
    background: linear-gradient(to left, var(--prism-shadow-color, rgba(11, 11, 11, 0.25)), transparent);
  }

  .prism-scroll-shadow[data-hides-start]::before,
  .prism-scroll-shadow[data-hides-end]::after {
    opacity: 1;
  }

  .prism-scroll-shadow__strip {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .prism-scroll-shadow__strip::-webkit-scrollbar {
    display: none;
  }

  /* ---------------------------------------------------------------- *
   * Sectioned menu (core/sectioned-menu.js, Phixly 173) — a list, an
   * action zone a shade darker, the Log a shade darker again. No header.
   * ---------------------------------------------------------------- */

  .prism-menu.prism-sectioned-menu {
    --prism-sectioned-menu-row: 27px;
    display: flex;
    flex-direction: column;
    width: var(--prism-sectioned-menu-width, 340px);
    max-width: calc(100vw - 32px);
    padding: 0;
    /* Under any max-height (a split button's 420 px), it scrolls — nothing is
       cut off unseen — with the Log pinned at its foot (Phixly 184). */
    overflow-x: hidden;
    overflow-y: auto;
  }

  .prism-sectioned-menu__list {
    position: relative;
    padding: 6px 0;
  }

  .prism-sectioned-menu__caption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 22px;
    padding: 0 12px 2px;
    color: var(--prism-ink-muted);
    font-size: var(--prism-text-xs);
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .prism-sectioned-menu__show-all.prism-menu__item {
    width: auto;
    padding: 1px 4px;
    color: var(--prism-accent);
    letter-spacing: normal;
    text-transform: none;
  }

  .prism-sectioned-menu__rows {
    max-height: calc(var(--prism-sectioned-menu-max, 5) * var(--prism-sectioned-menu-row));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .prism-sectioned-menu__list[data-all] .prism-sectioned-menu__rows {
    max-height: min(60vh, 420px);
  }

  /* A fade at the list's foot while more is below. */
  .prism-sectioned-menu__list[data-more] .prism-sectioned-menu__rows {
    mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
  }

  .prism-sectioned-menu__row,
  .prism-sectioned-menu__warning,
  .prism-sectioned-menu__action,
  .prism-sectioned-menu__log-toggle {
    display: flex;
    box-sizing: border-box;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: var(--prism-sectioned-menu-row);
    padding: 3px 12px;
    border-radius: 0;
  }

  .prism-sectioned-menu__warning {
    --prism-sectioned-menu-tone: var(--prism-status-attention);
    background: color-mix(in srgb, var(--prism-sectioned-menu-tone) 14%, var(--prism-surface-1));
    color: color-mix(in srgb, var(--prism-sectioned-menu-tone) 80%, var(--prism-ink-primary));
  }

  /* A warning that blocks (Phixly 186): red with ✕, as its step is. */
  .prism-sectioned-menu__warning.is-conflict {
    --prism-sectioned-menu-tone: var(--prism-status-critical);
  }

  .prism-sectioned-menu__symbol,
  .prism-sectioned-menu__mark {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    min-width: 14px;
  }

  .prism-sectioned-menu__mark {
    min-width: 18px;
    color: var(--prism-accent);
  }

  .prism-sectioned-menu__char {
    font-weight: var(--prism-weight-bold);
    line-height: 1;
  }

  .prism-sectioned-menu__ring,
  .prism-sectioned-menu__dot {
    box-sizing: border-box;
    width: 9px;
    height: 9px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
  }

  .prism-sectioned-menu__dot {
    background: currentColor;
  }

  /* A row in the running state: the step button's pulsing dot, in the ready blue. */
  .prism-sectioned-menu__dot.is-running {
    border: 0;
    color: var(--prism-accent);
    animation: prism-step-button-pulse 1s ease-in-out infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    .prism-sectioned-menu__dot.is-running {
      animation: none;
    }
  }

  .prism-sectioned-menu__row.is-loading .prism-sectioned-menu__text {
    color: var(--prism-ink-muted);
  }

  .prism-sectioned-menu__text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .prism-sectioned-menu__text.is-strong {
    font-weight: var(--prism-weight-bold);
  }

  /* The action zone: a shade darker, growing as it needs. */
  .prism-sectioned-menu__actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    border-top: 1px solid var(--prism-border-hairline);
    background: color-mix(in srgb, var(--prism-ink-primary) 4%, var(--prism-surface-1));
  }

  .prism-sectioned-menu__segments {
    display: inline-flex;
    align-self: flex-start;
    margin: 2px 12px 4px;
    border: 1px solid var(--prism-border);
    border-radius: var(--prism-radius-sm);
    background: var(--prism-surface-1);
  }

  .prism-sectioned-menu__segment.prism-menu__item {
    width: auto;
    padding: 2px 12px;
    border-radius: 0;
    color: var(--prism-ink-secondary);
  }

  .prism-sectioned-menu__segment + .prism-sectioned-menu__segment {
    border-inline-start: 1px solid var(--prism-border-hairline);
  }

  .prism-sectioned-menu__segment[aria-checked="true"] {
    background: var(--prism-surface-hover);
    color: var(--prism-ink-primary);
    font-weight: var(--prism-weight-bold);
  }

  .prism-sectioned-menu__action .prism-menu__value {
    color: var(--prism-accent);
  }

  .prism-sectioned-menu__action[aria-disabled="true"] .prism-sectioned-menu__text {
    color: var(--prism-ink-muted);
  }

  /* A greyed action's reason: a muted line under its label (Phixly 178). */
  .prism-sectioned-menu__reason {
    display: block;
    color: var(--prism-ink-muted);
    font-size: var(--prism-text-xs);
    white-space: normal;
  }

  /* "auto": as wide as it needs, from 340 px to its max, inside the window. */
  .prism-menu.prism-sectioned-menu--auto {
    width: max-content;
    min-width: min(340px, calc(100vw - 32px));
    max-width: min(var(--prism-sectioned-menu-max-width, 480px), calc(100vw - 32px));
  }

  /* NOTHING THAT MATTERS IS CUT SHORT (Phixly 178): a warning and an action's
     label wrap in full; the words stack over a body or a reason. */
  .prism-sectioned-menu__words {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
  }

  .prism-sectioned-menu__warning .prism-sectioned-menu__text,
  .prism-sectioned-menu__action .prism-sectioned-menu__text {
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .prism-sectioned-menu__warning,
  .prism-sectioned-menu__action {
    align-items: flex-start;
    padding-block: 5px;
  }

  .prism-sectioned-menu__warning .prism-sectioned-menu__symbol,
  .prism-sectioned-menu__action .prism-sectioned-menu__mark,
  .prism-sectioned-menu__action .prism-menu__value {
    line-height: inherit;
    min-height: 1.4em;
  }

  /* A warning's links (Phixly 179): one a line, underlined in its colour. */
  .prism-sectioned-menu__about {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin: 2px 0;
  }

  .prism-sectioned-menu__about-link.prism-menu__item,
  .prism-sectioned-menu__warning-text.prism-menu__item {
    display: block;
    width: auto;
    max-width: 100%;
    margin-inline-start: -4px;
    padding: 0 4px;
    overflow: hidden;
    color: inherit;
    text-align: start;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 60%, transparent);
    text-overflow: ellipsis;
    text-underline-offset: 2px;
    white-space: nowrap;
  }

  .prism-sectioned-menu__warning-text.prism-menu__item {
    white-space: normal;
  }

  .prism-sectioned-menu__about-link.prism-menu__item:hover,
  .prism-sectioned-menu__warning-text.prism-menu__item:hover {
    background: color-mix(in srgb, currentColor 12%, transparent);
  }

  .prism-sectioned-menu__body {
    color: color-mix(in srgb, currentColor 80%, var(--prism-ink-secondary));
    font-size: var(--prism-text-xs);
    line-height: 1.4;
  }

  /* The Log: a shade darker again, its entries opening in place. */
  .prism-sectioned-menu__log {
    position: sticky;
    bottom: 0;
    z-index: 1;
    border-top: 1px solid var(--prism-border-hairline);
    background: color-mix(in srgb, var(--prism-ink-primary) 8%, var(--prism-surface-1));
  }

  .prism-sectioned-menu__log-toggle {
    color: var(--prism-ink-secondary);
  }

  .prism-sectioned-menu__log-chevron {
    display: inline-flex;
    margin-inline-start: auto;
    color: var(--prism-ink-muted);
    transition: transform var(--prism-duration-fast, 100ms);
  }

  .prism-sectioned-menu__log-toggle[aria-expanded="true"] .prism-sectioned-menu__log-chevron {
    transform: rotate(90deg);
  }

  .prism-sectioned-menu__log-entries {
    /* Pinned, an opened Log scrolls its own entries rather than outgrow the menu. */
    max-height: min(200px, 35vh);
    overflow-y: auto;
    padding: 0 12px 8px 38px;
    color: var(--prism-ink-secondary);
    font-size: var(--prism-text-xs);
    line-height: 1.6;
  }

  .prism-sectioned-menu__log-entries > .prism-sectioned-menu__row {
    min-height: 0;
    padding: 2px 0;
  }

  .prism-sectioned-menu__log-entry {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .prism-sectioned-menu__log-pick {
    display: flex;
    flex: 1 1 auto;
    align-items: baseline;
    min-width: 0;
  }

  .prism-sectioned-menu__log-pick.prism-menu__item {
    gap: 0;
    padding: 1px 4px;
    margin-inline-start: -4px;
    font-size: inherit;
  }

  .prism-sectioned-menu__log-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .prism-sectioned-menu__log-text.is-strong {
    color: var(--prism-ink-primary);
    font-weight: var(--prism-weight-bold);
  }

  .prism-sectioned-menu__log-action.prism-menu__item {
    flex: none;
    width: auto;
    padding: 1px 6px;
    color: var(--prism-accent);
    font-size: inherit;
  }

  .prism-sectioned-menu__log-time {
    margin-inline-end: 6px;
    font-variant-numeric: tabular-nums;
  }

  /* ---------------------------------------------------------------- *
   * Tab strip (core/tab-strip.js, Phixly 154) — plain text tabs on a
   * hairline, the active one underlined in the accent. One row: what does
   * not fit scrolls, and only a side that hides tabs fades — the mask's two
   * ends are custom properties the script flips per side. A marked tab out
   * of sight shows as a dot on its edge.
   * ---------------------------------------------------------------- */

  .prism-tab-strip {
    position: relative;
    min-width: 0;
    --prism-tab-strip-fade: 24px;
    --prism-tab-strip-mark: var(--prism-accent);
    --prism-tab-strip-start: #000;
    --prism-tab-strip-end: #000;
  }
  .prism-tab-strip[data-more-start] {
    --prism-tab-strip-start: transparent;
  }
  .prism-tab-strip[data-more-end] {
    --prism-tab-strip-end: transparent;
  }
  .prism-tab-strip__list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    /* The hairline the tabs stand on: inset, so a tab's underline paints over it. */
    box-shadow: inset 0 -1px 0 var(--prism-border-hairline);
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(
      to right,
      var(--prism-tab-strip-start) 0,
      #000 var(--prism-tab-strip-fade),
      #000 calc(100% - var(--prism-tab-strip-fade)),
      var(--prism-tab-strip-end) 100%
    );
    mask-image: linear-gradient(
      to right,
      var(--prism-tab-strip-start) 0,
      #000 var(--prism-tab-strip-fade),
      #000 calc(100% - var(--prism-tab-strip-fade)),
      var(--prism-tab-strip-end) 100%
    );
  }
  .prism-tab-strip__list::-webkit-scrollbar {
    display: none;
  }
  .prism-tab-strip__tab {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 10px 7px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--prism-ink-muted);
    font: inherit;
    font-size: var(--prism-text-sm);
    white-space: nowrap;
    cursor: pointer;
  }
  .prism-tab-strip--fill .prism-tab-strip__tab {
    flex: 1 1 0;
    min-width: max-content;
  }
  .prism-tab-strip__tab:hover {
    background: var(--prism-surface-hover);
    color: var(--prism-ink-primary);
  }
  .prism-tab-strip__tab:focus-visible {
    outline: var(--prism-focus-ring-width) solid var(--prism-focus-ring);
    outline-offset: -2px;
  }
  .prism-tab-strip__tab[aria-selected="true"] {
    border-bottom-color: var(--prism-accent);
    color: var(--prism-ink-primary);
    font-weight: var(--prism-weight-bold);
  }
  .prism-tab-strip__tab[aria-disabled="true"] {
    cursor: default;
    opacity: 0.55;
  }
  .prism-tab-strip__tab[aria-disabled="true"]:hover {
    background: transparent;
  }
  .prism-tab-strip__count {
    min-width: 15px;
    padding: 0 4px;
    border-radius: var(--prism-radius-pill);
    background: var(--prism-surface-sunken);
    color: var(--prism-ink-secondary);
    font-size: var(--prism-text-xs);
    font-weight: var(--prism-weight-bold);
    text-align: center;
  }
  .prism-tab-strip__mark,
  .prism-tab-strip__edge {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--prism-tab-strip-mark);
  }
  .prism-tab-strip__mark {
    flex: 0 0 auto;
    align-self: flex-start;
    margin-top: 2px;
  }
  .prism-tab-strip__edge {
    position: absolute;
    top: calc(50% - 3px);
    display: none;
    pointer-events: none;
  }
  .prism-tab-strip__edge--start {
    left: 2px;
  }
  .prism-tab-strip__edge--end {
    right: 2px;
  }
  .prism-tab-strip[data-mark-start] .prism-tab-strip__edge--start,
  .prism-tab-strip[data-mark-end] .prism-tab-strip__edge--end {
    display: block;
  }

  /* ---------------------------------------------------------------- *
   * Forced colours (Windows high contrast)
   * Token colours are dropped by the OS here, so the pieces that were
   * carrying meaning through colour need a system colour instead.
   * ---------------------------------------------------------------- */

  @media (forced-colors: active) {
    .prism-button,
    .prism-input,
    .prism-select,
    .prism-menu,
    .prism-surface {
      border-color: ButtonBorder;
    }
    .prism-button[aria-pressed="true"] {
      background: Highlight;
      color: HighlightText;
    }
    .prism-badge__dot {
      outline: 1px solid CanvasText;
    }
    /* `color-mix` and `opacity` are what carry "this is the chosen one" in
       the option set, and the OS drops both. The system colours say it
       instead, and the iconic set stops leaning on opacity. */
    .prism-optset,
    .prism-optselect,
    .prism-optmulti__box {
      border-color: ButtonBorder;
    }
    .prism-optset__opt {
      border-right-color: ButtonBorder;
    }
    .prism-optset__opt[aria-pressed="true"],
    .prism-optmulti__pick[aria-pressed="true"] .prism-optmulti__box {
      background: Highlight;
      color: HighlightText;
    }
    .prism-optset--icons .prism-optset__opt {
      opacity: 1;
    }
    .prism-tab-strip__tab[aria-selected="true"] {
      border-bottom-color: Highlight;
    }
    .prism-tab-strip__mark,
    .prism-tab-strip__edge {
      background: CanvasText;
    }
  }
}
