body {
  /* BoardUI's font variable comes from its Next.js starter; here it is the app's own font. */
  --bui-font-sans: var(--font-sans, var(--exfinix-font-sans)), sans-serif;
  --bui-font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --ex-font-weight-normal: var(--exfinix-weight-text);
  --ex-text-body-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-body-medium--font-weight: var(--exfinix-weight-text);
  --ex-text-body-2-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-body-2-medium--font-weight: var(--exfinix-weight-text);
  --ex-text-caption-1-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-caption-1-medium--font-weight: var(--exfinix-weight-text);
  --ex-text-caption-2-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-caption-2-medium--font-weight: var(--exfinix-weight-text);
  --ex-text-headline-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-headline-medium--font-weight: var(--exfinix-weight-title);
  --ex-text-title-1-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-title-1-medium--font-weight: var(--exfinix-weight-title);
  --ex-text-title-2-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-title-2-medium--font-weight: var(--exfinix-weight-title);
  --ex-text-title-3-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-title-3-medium--font-weight: var(--exfinix-weight-title);
  --ex-text-display-1-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-display-1-medium--font-weight: var(--exfinix-weight-title);
  --ex-text-display-2-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-display-2-medium--font-weight: var(--exfinix-weight-title);
  --ex-text-display-3-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-display-3-medium--font-weight: var(--exfinix-weight-title);
  --ex-text-display-4-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-display-4-medium--font-weight: var(--exfinix-weight-title);
  --ex-text-large-title-regular--font-weight: var(--exfinix-weight-text);
  --ex-text-large-title-medium--font-weight: var(--exfinix-weight-title);
  --bui-radius-2lg: var(--exfinix-radius-field);
  --ex-radius-2xl: var(--exfinix-radius-card);
  --ex-radius-3xl: var(--exfinix-radius-dialog);
  --bui-color-text-unselected: color-mix(in srgb, var(--bui-color-text-primary) var(--exfinix-ink-option), transparent);
  --bui-color-card-title: color-mix(in srgb, var(--bui-color-text-primary) var(--exfinix-ink-card-title), transparent);
  --bui-color-card-text: color-mix(in srgb, var(--bui-color-text-primary) var(--exfinix-ink-card-text), transparent);
  --bui-color-text-subtitle: color-mix(in srgb, var(--bui-color-text-primary) var(--exfinix-ink-subtitle), transparent);
  --bui-color-accent-50: #fafafa;
  --bui-color-accent-100: #f3f3f3;
  --bui-color-accent-200: #e8e8e8;
  --bui-color-accent-300: #d4d4d4;
  --bui-color-accent-400: #4a4a4a;
  --bui-color-accent-500: #2c2c2c;
  --bui-color-accent-600: #111111;
  --bui-color-accent-700: #000000;
  --bui-color-accent-800: #000000;
  --bui-color-accent-900: #000000;
  --bui-color-accent-950: #000000;
  --bui-color-link: var(--bui-color-accent-600);
  /* BoardUI writes white on the accent; in Exfinix these turn with the ink. */
  --bui-color-on-accent: #ffffff;
  --bui-color-switch-on-thumb: #ffffff;
  --bui-color-switch-on-thumb-subtle: #f7f7f7;
  /* BoardUI paints its buttons with a gradient; each here is one solid step of its ramp. */
  --bui-gradient-button-primary-default: linear-gradient(var(--bui-color-accent-600) 0 0);
  --bui-gradient-button-primary-hover: linear-gradient(var(--bui-color-accent-500) 0 0);
  --bui-gradient-button-primary-active: linear-gradient(var(--bui-color-accent-700) 0 0);
  --bui-gradient-button-primary-disabled: linear-gradient(var(--bui-color-neutral-200) 0 0);
  --bui-gradient-button-danger-default: linear-gradient(var(--bui-color-red-600) 0 0);
  --bui-gradient-button-danger-hover: linear-gradient(var(--bui-color-red-500) 0 0);
  --bui-gradient-button-danger-active: linear-gradient(var(--bui-color-red-700) 0 0);
  --bui-gradient-button-danger-disabled: linear-gradient(var(--bui-color-red-100) 0 0);
  /* BoardUI tints ghost buttons at rest; here fills appear only on hover and press. */
  --bui-color-button-ghost-background: transparent;
  --bui-color-button-ghost-disabled: transparent;
  /* Hover and selected fills are ink traces, so they read the same on page, card and menu. */
  --bui-color-fill-hover: var(--exfinix-fill-hover);
  --bui-color-fill-selected: var(--exfinix-fill-selected);
  --bui-color-card-hover: var(--exfinix-fill-card-hover);
  /* A border can't take a gradient, so a card's fill and edge are drawn as two backgrounds. */
  --bui-color-card-background: var(--exfinix-card-fill);
  --bui-color-card-border: var(--exfinix-card-border);
  --bui-color-card-background-hover: color-mix(in srgb, #000 5%, var(--bui-color-white));
  --bui-card-edge: var(--exfinix-card-edge);
  --bui-card-edge-color: transparent;
  --bui-card-ground: linear-gradient(var(--bui-color-card-background) 0 0) padding-box, var(--bui-card-edge) border-box;
  /* The same ground as images and where each stops, for the pointer's light to be drawn over (design.css, --exfinix-glow-under). */
  --bui-card-ground-images: linear-gradient(var(--bui-color-card-background) 0 0), var(--bui-card-edge);
  --bui-card-ground-clips: padding-box, border-box;
  --bui-card-edge-hover: linear-gradient(var(--exfinix-edge-hover) 0 0);
  --bui-card-edge-color-hover: transparent;
  --bui-card-ground-hover: linear-gradient(var(--bui-color-card-background) 0 0) padding-box, var(--bui-card-edge-hover) border-box;
  --bui-card-shadow: 0 0 #0000;
  --bui-color-control-background: var(--exfinix-control-fill);
  --bui-color-control-border: var(--exfinix-button-border);
  /* A checked checkbox's (and the large switch's) inner edge is design.css's width, not BoardUI's 1px. */
  --bui-shadow-checkbox-selected: inset 0 2px 0 0 rgb(255 255 255 / 0.25), inset 0 0 0 var(--exfinix-border-width) var(--bui-color-accent-500);
  --bui-color-text-placeholder: color-mix(in srgb, var(--bui-color-text-primary) var(--exfinix-ink-placeholder), transparent);
  /* Pointed at, a control takes the hover fill like any option; pressed, the selected one (`background-primary-active`). */
  --bui-color-control-background-hover: var(--bui-color-fill-hover);
}

/* Set for both palettes because BoardUI re-sets each of them for dark. */
body,
.dark body,
body[data-ds-dark-theme] {
  --bui-color-button-ghost-hover: var(--bui-color-fill-hover);
  --bui-color-button-ghost-active: var(--bui-color-fill-selected);
  --bui-color-background-primary-hover: var(--bui-color-fill-hover);
  --bui-color-background-primary-active: var(--bui-color-fill-selected);
  --bui-color-dropdown-item-hover-background: var(--bui-color-fill-hover);
  --bui-color-pill-tab-blue-hover-background: var(--bui-color-fill-hover);
  --bui-color-pill-tab-blue-selected-background: var(--bui-color-fill-selected);
  --bui-color-tab-count-selected-background: var(--bui-color-fill-selected);
  --bui-color-ai-chat-composer-add-hover-background: var(--bui-color-fill-hover);
  --bui-color-composer-panel-add-hover-background: var(--bui-color-fill-hover);
  --bui-color-questionnaire-key-hover-background: var(--bui-color-fill-hover);
  /* A segmented control has no track in either mode: the chosen segment is the selected fill like any chosen option. */
  --bui-color-segmented-control-background: transparent;
  --bui-color-segmented-control-selected-background: var(--bui-color-fill-selected);
  /* Every edge and line is design.css's one edge colour, whatever grey BoardUI gives it. */
  --bui-color-separator-border: var(--exfinix-edge);
  --bui-color-separator-border-strong: var(--exfinix-edge);
  --bui-color-border-button-default: var(--exfinix-edge);
  --bui-color-border-button-group: var(--exfinix-edge);
  --bui-color-border-checkbox-default: var(--exfinix-edge);
  --bui-color-border-table: var(--exfinix-edge);
  --bui-color-border-button-active: var(--exfinix-control-border-focus);
  --bui-shadow-dropdown: var(--exfinix-float-shadow);
  /* A disabled outlined button, select, field or text box draws its edge and no ground, as it does at rest; its words
     fade instead. BoardUI greys these two grounds only there. */
  --bui-color-background-primary-disabled: var(--exfinix-control-fill);
  --bui-color-input-disabled-background: var(--exfinix-control-fill);
}

.dark body,
body[data-ds-dark-theme] {
  /* In dark the ink is near-white, so what sits on the accent is dark. */
  --bui-color-accent-300: #d4d4d4;
  --bui-color-accent-400: #ffffff;
  --bui-color-accent-500: #fafafa;
  --bui-color-accent-600: #e0e0e0;
  --bui-color-accent-700: #c9c9c9;
  --bui-color-accent-800: #b5b5b5;
  --bui-color-accent-900: #a0a0a0;
  --bui-color-accent-950: #8a8a8a;
  --bui-color-accent-50: rgb(255 255 255 / 0.04);
  --bui-color-accent-100: rgb(255 255 255 / 0.08);
  --bui-color-accent-200: rgb(255 255 255 / 0.12);
  --bui-color-link: var(--bui-color-accent-400);
  --bui-color-on-accent: #111111;
  --bui-color-switch-on-thumb: #111111;
  --bui-color-switch-on-thumb-subtle: #121212;
  /* Hover goes a step darker because a step lighter than near-white would not show. */
  --bui-gradient-button-primary-default: linear-gradient(var(--bui-color-accent-500) 0 0);
  --bui-gradient-button-primary-hover: linear-gradient(var(--bui-color-accent-600) 0 0);
  --bui-gradient-button-primary-active: linear-gradient(var(--bui-color-accent-700) 0 0);
  --bui-gradient-button-primary-disabled: linear-gradient(var(--bui-color-neutral-700) 0 0);
  --bui-gradient-button-danger-disabled: linear-gradient(var(--bui-color-red-900) 0 0);
  --bui-color-button-primary-disabled-foreground: var(--bui-color-neutral-500);
  /* A trace fill would reveal the gradient under it, so dark cards use a border. */
  --bui-color-card-background-hover: var(--bui-color-fill-selected);
  --bui-card-edge-color: var(--bui-color-card-border);
  --bui-card-edge-hover: linear-gradient(transparent 0 0);
  --bui-card-edge-color-hover: var(--exfinix-edge-hover);
  --bui-card-shadow: var(--bui-shadow-xs), var(--exfinix-glow-rest);
  /* Tints BoardUI takes from the dark end of its ramp, which is light in Exfinix. */
  --bui-color-button-ghost-background: transparent;
  --bui-color-button-ghost-disabled: transparent;
  --bui-color-button-ghost-foreground: #fafafa;
  --bui-color-button-ghost-disabled-foreground: var(--bui-color-neutral-600);
  --bui-color-badge-new-background: rgb(255 255 255 / 0.1);
  --bui-color-badge-new-text: #fafafa;
  --bui-color-date-range-background: rgb(255 255 255 / 0.08);
  --bui-color-date-range-edge-background: rgb(255 255 255 / 0.2);
  /* BoardUI's dark tertiary matches its panel surface; one step lighter so fields show. */
  --bui-color-background-tertiary-default: oklch(31.5% 0 none);
  /* BoardUI's dark disabled words are its panel's own grey, so a disabled menu row showed blank. This step stands off the
     panel as light's does off white, and stays fainter than the shortcut beside it. */
  --bui-color-text-disabled: var(--bui-color-neutral-700);
  /* Highlights inside a filled control are white here, for a dark fill. */
  --bui-shadow-checkbox-selected: inset 0 0 0 var(--exfinix-border-width) var(--bui-color-accent-600);
}

/* Unchosen options use the ink at --exfinix-ink-option, overriding BoardUI's own greys. */
.bui[data-rac][role="radio"]:not([data-selected], [data-hovered], [data-disabled]),
.bui[data-rac][role="tab"]:not([data-selected], [data-hovered], [data-disabled]) > .bui:first-child,
.bui[data-pill-variant]:not([data-pill-selected], :hover) > .bui:last-child,
.bui:is([role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"], [role="option"]):not(
    [data-focused], [data-hovered], [data-selected], [aria-current="true"], [aria-checked="true"],
    [data-disabled], :hover, :focus-visible, :disabled, [class*="text-destructive"]
  ) {
  color: var(--bui-color-text-unselected);
}

.bui[data-rac][role="radiogroup"] > span[aria-hidden] {
  box-shadow: none;
}

/* BoardUI writes 1px rules; every edge here is 0.5px, so `table` outweighs it. */
table.bui-table th {
  border-top-width: var(--exfinix-border-width);
  border-bottom-width: var(--exfinix-border-width);
}
table.bui-table tbody tr:not(:last-child) {
  border-bottom-width: var(--exfinix-border-width);
}

.bui[data-rac][data-placement]:not([role="tooltip"]) {
  border-radius: var(--exfinix-radius-card);
  border-color: var(--exfinix-surface-edge);
  box-shadow: var(--exfinix-float-shadow);
}
/* A tooltip is the kernel's (the shell theme's default one, design.css's --exfinix-tooltip-*): round at the ends, 14px words
   at 90% ink, a 5% edge, 6px by 12px inside, coming in as it does (负责人 2026-12-02「所有只有图标的按钮都需要 tool tips 和最左侧
   导航图标一样」; it was 8px corners, 12px words in 500 and a caret). */
.bui[data-rac][role="tooltip"] {
  border-radius: var(--exfinix-radius-tooltip);
  border-color: var(--exfinix-tooltip-edge);
  box-shadow: var(--exfinix-float-cast);
  padding: var(--exfinix-tooltip-padding-block) var(--exfinix-tooltip-padding-inline);
  color: color-mix(in srgb, var(--exfinix-ink-color) var(--exfinix-ink-tooltip), transparent);
  font-size: var(--exfinix-tooltip-text);
  line-height: var(--exfinix-tooltip-leading);
  font-weight: var(--exfinix-weight-tooltip);
  &:is([data-entering], [data-exiting]) {
    scale: 0.98;
    filter: none;
  }
}

/* Floating panels are the panel ground the kernel's menus have too: white 90% over a blur in light, one solid ground in
   dark (负责人 2026-11-29「组件层面，各种下拉面板在深色模式下要保持一致的背景色」; BoardUI's was a step lighter). In dark
   whatever a panel paints in BoardUI's surface colour takes that ground as well: a tooltip (which keeps BoardUI's white
   in light), the caret of a tooltip or popover, the fade over a scrolled select or context menu. */
.bui[data-rac][data-placement]:not([role="tooltip"]) {
  background-color: var(--exfinix-panel-ground);
}
:is(.dark, [data-ds-dark-theme]) .bui[data-rac][data-placement] {
  --bui-color-background-primary-default: var(--exfinix-panel-ground);
}
.bui[data-rac][data-placement]:not([role="tooltip"], .dark *, [data-ds-dark-theme] *) {
  -webkit-backdrop-filter: blur(var(--exfinix-panel-blur));
  backdrop-filter: blur(var(--exfinix-panel-blur));
}

/* Dialogs take the kernel's edge and shadow. A submenu's popover is a dialog to React Aria too, but it is a panel: it
   keeps the panels' ground and shadow. */
.bui:is([role="dialog"], [role="alertdialog"]):not([data-placement], [data-placement] > *) {
  border-color: var(--exfinix-surface-edge);
  box-shadow: var(--exfinix-dialog-shadow);
}
/* In dark a dialog stands on the panels' ground (负责人 2026-11-29「深色模式所有的面板，tooltips，下拉，叠加 3% 的 white
   背景色」, dialogs included when asked), and so does whatever inside paints the dialog's ground (a sticky bar, a fade).
   It was BoardUI's darkest ground with a white 2% lift drawn over it as an inset shadow. */
:is(.dark, [data-ds-dark-theme]) .bui:is([role="dialog"], [role="alertdialog"]):not([data-placement], [data-placement] > *) {
  --bui-color-background-full: var(--exfinix-panel-ground);
}

/* What the pointer lights in dark (design.css, --exfinix-glow-*): the floating panels and the dialogs. A tooltip is none:
   the pointer never rests on one. */
.bui[data-rac][data-placement]:not([role="tooltip"]),
.bui:is([role="dialog"], [role="alertdialog"]):not([data-placement], [data-placement] > *) {
  --exfinix-glow-surface: var(--exfinix-glow);
}

/* A dialog's close cross is drawn at one width whatever size its glyph is drawn at. */
[data-exfinix-dialog-close] svg * {
  stroke-width: var(--exfinix-dialog-close-stroke);
  vector-effect: non-scaling-stroke;
}
