/*
 * ClarkConnect shared element base — common h1-h5 / p / label / a / input styling built
 * from the design tokens in cc-tokens.css (bare Figma names, e.g. colorPrimary), mirrored
 * from the "Clark Connect Design
 * System" Figma file (mDGx1lwPIPlQv6kYZkrapN), Overview page, plus the Figma component
 * classes, element-qualified so a non-control using the same word is untouched; an
 * un-classed <button> renders as the Default Button. Each component block below opens with
 * its Figma node id:
 *   Typography   .text with secondary/success/warning/danger/disabled, sm/lg/xl; a.underline
 *   Input        statuses .danger/.warning, sizes .lg/.sm, aria-busy Loading; the opt-in
 *                .input (prefix/suffix box, adds .success) and .inputnumber (step handler)
 *   Select       native <select>, .select trigger, .multiple
 *   Button       .primary/.secondary/.default/.dashed/.link, .danger, .lg/.sm, .icon, aria-busy Loading
 *   Dropdown     .dropdown          Menu        .menu (listbox or menu)
 *   Picker       .picker, .time     Checkbox / Radio  native inputs, .radio-group, .horizontal
 *   Switch       .switch, .sm       Segmented   .segmented, .solid, .sm/.lg (Figma RadioButtonGroup)
 *   Tag          .tag, success/warning/danger/processing (Figma Tag / Status)
 *   Tabs         .tabs, .sm/.lg; processing/danger/success/warning/neutral
 *   Overlays     .popover, .tooltip, .popconfirm, .notification
 *   Modal        dialog.modal, info/success/warning/danger
 *   Progress     native <progress>, .progress.circle; .sm, .success/.danger, .square
 *   Upload       .upload, .upload-item, .card, .danger
 *
 * Served at _content/ClarkConnect.Styles/css/cc-base.css. Linked directly (plain,
 * unlayered) by Host's App.razor for the static-SSR shell and by VendorAdmin.Client's
 * index.html, and imported into the `cc-base` cascade layer by MfeDocumentRenderer for
 * the /{view} MFE-document pipeline (`@layer cc-chrome, cc-base, cc-mfe`) — only
 * that pipeline actually declares the layer. cc-base sits BETWEEN
 * cc-chrome (unlayered, always wins) and cc-mfe (each MFE's own stylesheets)
 * — so this file gives every MFE the same baseline look, but an MFE that
 * styles its own h1/button/input still wins for its own content. See
 * docs/host-chrome.md → "Cascade-layer isolation".
 *
 * Scoped to :where(main): every scope root is already a <main> — Host's MainLayout /
 * HeaderOnlyLayout / BareLayout and MfeDocumentRenderer, VendorAdmin.Client's standalone
 * layout, and the Identity login shells — while the chrome header/sidebar and the VendorAdmin
 * topbar/sider sit outside it, so a new surface gets the base with no markup change. NEVER
 * bare element selectors: cc-chrome.css resets `.cc-header`/`.cc-sidebar` typography and is
 * NOT reset here, so an unscoped `button {}`/`input {}` would repaint the chrome's icon-only
 * buttons with a body/border they never had.
 *
 * Every selector is wrapped in :where(...) so it contributes ZERO specificity
 * beyond the element itself. In the static-SSR shell app.css/cc-base.css/a
 * page's own <style> block are all unlayered — normal specificity decides —
 * so an existing single-class page rule (e.g. Home.razor's .splash-heading)
 * must keep winning over this baseline without needing !important or a
 * rewrite; :where() is what makes that automatic.
 *
 * Links: the bare `a[href]` rule applies --colorLink, 4.58:1 on white (AA for normal text;
 * hover --colorLinkHover is darker, 5.95:1). It still falls under AA on the shell (4.25:1)
 * and offwhite (4.39:1) surfaces, so a link placed there needs the `underline` class, as does
 * one in muted copy. Editor-authored body copy is the opt-in cc-rich-text.css.
 *
 * NOT loaded by Admin.Client or the AdminPortal embed (index.html and
 * AdminPortalEmbedEndpoints link tokens-only, plus admin-spot.css for spot's look)
 * — so the Clark Connect Management page is unaffected by design, not by override.
 */

:where(main) {
    /* Carries the opsz pin (see h1) to text no base rule below covers. */
    font-variation-settings: var(--fontVariationSettings);
}

:where(main) h1 {
    margin: 0;
    /* The `font` shorthand resets the variation axes, so DM Sans auto-sizes opsz; Figma pins it at 14. */
    font: var(--fontWeightStrong) var(--fontSizeHeading1) / var(--lineHeightHeading1) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    color: var(--colorText);
}

:where(main) h2 {
    margin: 0;
    font: var(--fontWeightStrong) var(--fontSizeHeading2) / var(--lineHeightHeading2) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    color: var(--colorText);
}

:where(main) h3 {
    margin: 0;
    font: var(--fontWeightStrong) var(--fontSizeHeading3) / var(--lineHeightHeading3) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    color: var(--colorText);
}

:where(main) h4 {
    margin: 0;
    font: var(--fontWeightStrong) var(--fontSizeHeading4) / var(--lineHeightHeading4) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    color: var(--colorText);
}

:where(main) h5 {
    margin: 0;
    font: var(--fontWeightStrong) var(--fontSizeHeading5) / var(--lineHeightLG) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    color: var(--colorText);
}

:where(main) p {
    margin: 0;
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    color: var(--colorText);
}

/* Figma Components/Form/colorText. */
:where(main) label {
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    color: var(--colorTextForm);
}

/* Typography — Figma "Clark Connect Design System", Title (node 1233:44542), Text (5437:56205),
   Link (5437:56490) and Code (5437:56486). Title needs no rule: the h1-h5 base above already matches
   every level. Text: the bare p is Type=Default Size=Base; the Style axis rides the native elements
   (strong/b, em/i, u, s/del, mark); Type and Size are classes composed with the `text` marker on a
   <p> or <span>, so a span.danger elsewhere is untouched. The marker itself sets nothing, so an
   un-sized span.text inherits its surrounding size. */

/* Style=Strong — Figma fontWeightStrong (SemiBold); the UA default `bolder` is 700. */
:where(main) :where(strong, b) {
    font-weight: var(--fontWeightStrong);
}

/* Style=Underline / Delete — Figma draws both decorations through descenders. */
:where(main) :where(u, s, del) {
    text-decoration-skip-ink: none;
}

/* Type=Mark — Colors/Brand/Primary/colorPrimaryBg behind colorText, replacing the UA yellow. */
:where(main) mark {
    background: var(--colorPrimaryBg);
    color: var(--colorText);
}

:where(main) :where(p.text, span.text).secondary {
    color: var(--colorTextDescription);
}

:where(main) :where(p.text, span.text).success {
    color: var(--colorSuccess);
}

/* Figma colorWarning is ~1.9:1 on white; --colorWarningText is the AA-safe ink if design agrees. */
:where(main) :where(p.text, span.text).warning {
    color: var(--colorWarning);
}

:where(main) :where(p.text, span.text).danger {
    color: var(--colorDanger);
}

/* A span has no :disabled, so Type=Disabled is a class; say so to assistive tech with aria-disabled. */
:where(main) :where(p.text, span.text).disabled {
    color: var(--colorTextDisabled);
}

/* Size axis — Base is the p default; XL's fontSizeXL has the same value as fontSizeHeading4. */
:where(main) :where(p.text, span.text).sm {
    font-size: var(--fontSizeSM);
    line-height: var(--lineHeightSM);
}

:where(main) :where(p.text, span.text).lg {
    font-size: var(--fontSizeLG);
    line-height: var(--lineHeightLG);
}

:where(main) :where(p.text, span.text).xl {
    font-size: var(--fontSizeHeading4);
    line-height: var(--lineHeightXL);
}

/* Link — Typography Link, colorLink (#0078CF, 4.6:1 on white). Every selector weighs one element, so
   any classed anchor (.primary, .link, .tag) keeps its own look; anchors without href stay unstyled.
   Figma's default is Underlined=No; hover/focus add the underline so the link is not colour-only. */
:where(main) a:where([href]) {
    color: var(--colorLink);
    text-decoration: none;
}

:where(main) a:where([href]:hover) {
    color: var(--colorLinkHover);
    text-decoration: underline;
}

/* Underlined=Yes — for links in secondary/muted copy, where colour alone does not reach 3:1 against it. */
:where(main) a:where([href].underline) {
    text-decoration: underline;
}

/* Pseudo-class weight kept so the ring always shows; the Button .link focus rule (two classes) still wins on its own anchors. */
:where(main) a:where([href]):focus-visible {
    outline: 3px solid var(--colorLinkActive);
    outline-offset: 2px;
    text-decoration: underline;
}

/* Code — a neutral chip on inline code; a <pre> block keeps its own box. Figma's raw translucent fill
   and border composite to #F4F4F4 / #D7D7D7 on white, one step from these tokens. */
:where(main) code:where(:not(pre > code)) {
    padding: calc(var(--spacingXXS) / 2) calc(var(--spacingXXS) * 1.5);
    background: var(--colorBgPage);
    border: 1px solid var(--colorBorder);
    border-radius: var(--borderRadiusSM);
    color: var(--colorText);
    font-family: var(--fontFamilyCode);
    font-size: var(--fontSizeSM);
}

/* Text-shaped controls — Figma "Clark Connect Design System", Input / Basic (node 2672:112497),
   Size=Default Status=None, and Input / Textarea (node 2722:81362). Form controls include their own
   border/padding in their width (a width:100% input otherwise renders wider than its container).
   Checkbox/radio are redrawn by the Checkbox block below; range/color/file keep their native size. */
/* The type exclusions sit inside :where() so this weighs (0,0,1) and a page's single-class rule
   still wins; state pseudo-classes stay outside it so a state rule outranks any rest rule. */
:where(main) input:where(:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"])),
:where(main) select,
:where(main) textarea {
    box-sizing: border-box;
    height: var(--controlHeight);
    /* Figma strokes sit inside the box, so its 12px padding is measured from the outer edge. */
    padding: 0 calc(var(--spacingSM) - 1px);
    background: var(--colorFill);
    border: 1px solid var(--colorBorderInput);
    border-radius: var(--borderRadius);
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
}

/* One row (the size's control height) at minimum. */
:where(main) textarea {
    height: auto;
    min-height: var(--controlHeight);
    padding: var(--spacingXXS) calc(var(--spacingSM) - 1px);
}

:where(main) input::placeholder,
:where(main) textarea::placeholder {
    color: var(--colorTextPlaceholder);
}

:where(main) input:where(:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"])):where(:not(:disabled)):hover,
:where(main) select:where(:not(:disabled)):hover,
:where(main) textarea:where(:not(:disabled)):hover {
    border-color: var(--colorPrimaryHover);
}

/* Figma "Pressed" (the active, typing state) — brand border plus the 2px focusPrimary ring. */
:where(main) input:where(:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"])):focus,
:where(main) select:focus,
:where(main) textarea:focus {
    outline: none;
    border-color: var(--colorPrimary);
    box-shadow: var(--shadowFocusPrimary);
}

/* Figma keeps colorText on a disabled value (only the fill changes), unlike the Button's grey text. */
:where(main) input:where(:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"])):disabled,
:where(main) select:disabled,
:where(main) textarea:disabled {
    background: var(--colorFillDisabled);
    border-color: var(--colorBorderInput);
    color: var(--colorText);
    cursor: not-allowed;
}

/* InputNumber (node 14868:34065) at rest is the Basic box; the native spinner cannot be restyled, so it is hidden (arrow keys still step). */
:where(main) input[type="number"] {
    appearance: textfield;
}

:where(main) input[type="number"]::-webkit-inner-spin-button,
:where(main) input[type="number"]::-webkit-outer-spin-button {
    appearance: none;
    margin: 0;
}

/* Input variants — Figma "Clark Connect Design System", Input / Basic (node 2672:112497). Opt-in
   classes placed on the <input>/<select>/<textarea> itself, composing a status (.danger/.warning)
   with a size (.lg/.sm). Every status draws a suffix icon in its colour (CheckCircleFilled,
   CloseCircleFilled, ExclamationCircleFilled), but only Danger and Warning also recolour the border
   and ring, so a bare control has no success rule. Icons are the consumer's (the .input wrapper
   below colours them); "Filled" is just value vs placeholder. */

:where(main) :where(input, select, textarea).danger {
    border-color: var(--colorDanger);
}

:where(main) :where(input, select, textarea).danger:where(:not(:disabled)):hover {
    border-color: var(--colorDangerHover);
}

:where(main) :where(input, select, textarea).danger:focus {
    border-color: var(--colorDanger);
    box-shadow: var(--shadowFocusDanger);
}

:where(main) :where(input, select, textarea).warning {
    border-color: var(--colorWarning);
}

:where(main) :where(input, select, textarea).warning:where(:not(:disabled)):hover {
    border-color: var(--colorWarningHover);
}

:where(main) :where(input, select, textarea).warning:focus {
    border-color: var(--colorWarning);
    box-shadow: var(--shadowFocusWarning);
}

/* Figma "Loading" is the Pressed look held while a value resolves (aria-busy); the spinner glyph is the consumer's. */
:where(main) :where(input, select, textarea)[aria-busy="true"] {
    border-color: var(--colorPrimary);
    box-shadow: var(--shadowFocusPrimary);
}

:where(main) :where(input, select, textarea).danger[aria-busy="true"] {
    border-color: var(--colorDanger);
    box-shadow: var(--shadowFocusDanger);
}

:where(main) :where(input, select, textarea).warning[aria-busy="true"] {
    border-color: var(--colorWarning);
    box-shadow: var(--shadowFocusWarning);
}

/* Sizes — Large steps up to the LG type scale; Small keeps base type with the SM radius/padding.
   Figma binds borderRadiusLG (8px) on Textarea and Select Large; Input / Basic Large's 6px is stale. */
:where(main) :where(input, select, textarea).lg {
    height: var(--controlHeightLG);
    border-radius: var(--borderRadiusLG);
    font-size: var(--fontSizeLG);
    line-height: var(--lineHeightLG);
}

:where(main) :where(input, select, textarea).sm {
    height: var(--controlHeightSM);
    padding: 0 calc(var(--spacingXS) - 1px);
    border-radius: var(--borderRadiusSM);
}

:where(main) textarea.lg {
    height: auto;
    min-height: var(--controlHeightLG);
    padding: calc(var(--spacingXS) - 1px) calc(var(--spacingSM) - 1px);
}

:where(main) textarea.sm {
    height: auto;
    min-height: var(--controlHeightSM);
    padding: 0 calc(var(--spacingXS) - 1px);
}

/* Affix box — Figma Input / Basic (node 2672:112497) prefix/suffix slots. <span class="input"> owns the Basic box around a naked <input> plus prefix/suffix glyphs
   (status, loading, clear, search: 16px, 8px apart). Glyphs drawn in currentColor take the wrapper
   colour: Figma colorIcon at rest, the status colour with .danger/.warning/.success. */
:where(main) :where(span, div).input {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: var(--spacingXS);
    height: var(--controlHeight);
    padding: 0 calc(var(--spacingSM) - 1px);
    background: var(--colorFill);
    border: 1px solid var(--colorBorderInput);
    border-radius: var(--borderRadius);
    color: var(--colorTextPlaceholder);
    vertical-align: middle;
}

:where(main) :where(span, div).input > :where(svg, img) {
    flex: none;
    width: var(--controlIconSize);
    height: var(--controlIconSize);
}

/* Weighs the same as the bare input state rules and follows them, so the wrapper alone paints the box. */
:where(main) :where(span, div).input > input {
    flex: 1 1 auto;
    min-width: 0;
    height: auto;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    outline: none;
}

:where(main) :where(span, div).input:hover:not(:has(> :disabled)) {
    border-color: var(--colorPrimaryHover);
}

:where(main) :where(span, div).input:focus-within:not(:has(> :disabled)),
:where(main) :where(span, div).input[aria-busy="true"] {
    border-color: var(--colorPrimary);
    box-shadow: var(--shadowFocusPrimary);
}

:where(main) :where(span, div).input[aria-busy="true"] {
    color: var(--colorPrimary);
}

:where(main) :where(span, div).input:has(> input:focus-visible) {
    outline: 3px solid var(--colorLinkActive);
    outline-offset: 2px;
}

:where(main) :where(span, div).input:has(> input:disabled) {
    background: var(--colorFillDisabled);
    border-color: var(--colorBorderInput);
    cursor: not-allowed;
}

:where(main) :where(span, div).input.danger {
    border-color: var(--colorDanger);
    color: var(--colorDanger);
}

:where(main) :where(span, div).input.danger:hover:not(:has(> :disabled)) {
    border-color: var(--colorDangerHover);
}

:where(main) :where(span, div).input.danger:focus-within:not(:has(> :disabled)),
:where(main) :where(span, div).input.danger[aria-busy="true"] {
    border-color: var(--colorDanger);
    box-shadow: var(--shadowFocusDanger);
}

:where(main) :where(span, div).input.warning {
    border-color: var(--colorWarning);
    color: var(--colorWarning);
}

:where(main) :where(span, div).input.warning:hover:not(:has(> :disabled)) {
    border-color: var(--colorWarningHover);
}

:where(main) :where(span, div).input.warning:focus-within:not(:has(> :disabled)),
:where(main) :where(span, div).input.warning[aria-busy="true"] {
    border-color: var(--colorWarning);
    box-shadow: var(--shadowFocusWarning);
}

/* Success changes only the glyph (Components/Input/colorSuccess); the box keeps the None status. */
:where(main) :where(span, div).input.success {
    color: var(--colorSuccess);
}

:where(main) :where(span, div).input.lg {
    height: var(--controlHeightLG);
    border-radius: var(--borderRadiusLG);
}

:where(main) :where(span, div).input.lg > input {
    font-size: var(--fontSizeLG);
    line-height: var(--lineHeightLG);
}

:where(main) :where(span, div).input.sm {
    height: var(--controlHeightSM);
    padding: 0 calc(var(--spacingXS) - 1px);
    border-radius: var(--borderRadiusSM);
}

/* InputNumber handler — Figma Input / InputNumber (node 14868:34065). <span class="inputnumber"> wraps
   <input type="number"> and two tabindex="-1" <button>s (increment first); wiring stepUp()/stepDown()
   is the consumer's. Figma shows the column on hover only; the chevrons are drawn here because the
   control has no meaning without them. */
:where(main) :where(span, div).inputnumber {
    /* Handler column 6px + 8px chevron + 6px; no Figma variable. */
    --handler-width: 20px;
    --handler-icon: 8px;
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}

:where(main) :where(span, div).inputnumber:has(> input.sm) {
    --handler-width: 16px;
}

:where(main) :where(span, div).inputnumber:has(> input.lg) {
    --handler-width: 26px;
    --handler-icon: 10px;
}

:where(main) :where(span, div).inputnumber > input {
    flex: 1 1 auto;
    min-width: 0;
}

:where(main) :where(span, div).inputnumber > button {
    position: absolute;
    inset-inline-end: 1px;
    box-sizing: border-box;
    width: calc(var(--handler-width) - 1px);
    height: calc(50% - 1px);
    padding: 0;
    background: var(--colorFill);
    border: none;
    border-inline-start: 1px solid var(--colorBorderInput);
    border-radius: 0;
    color: var(--colorTextPlaceholder);
    opacity: 0;
}

:where(main) :where(span, div).inputnumber > button:first-of-type {
    top: 1px;
    border-bottom: 1px solid var(--colorBorderInput);
    border-start-end-radius: var(--borderRadiusSM);
}

:where(main) :where(span, div).inputnumber > button:last-of-type {
    bottom: 1px;
    border-end-end-radius: var(--borderRadiusSM);
}

:where(main) :where(span, div).inputnumber > button::before {
    content: "";
    width: calc(var(--handler-icon) / 2);
    height: calc(var(--handler-icon) / 2);
    border-top: 1px solid currentColor;
    border-left: 1px solid currentColor;
    transform: translateY(calc(var(--handler-icon) / 8)) rotate(45deg);
}

:where(main) :where(span, div).inputnumber > button:last-of-type::before {
    transform: translateY(calc(var(--handler-icon) / -8)) rotate(225deg);
}

:where(main) :where(span, div).inputnumber:hover > button {
    opacity: 1;
}

/* No Figma state for a hovered handle; AntD's handleHoverColor is the primary. */
:where(main) :where(span, div).inputnumber > button:hover {
    color: var(--colorPrimary);
}

:where(main) :where(span, div).inputnumber:hover > input:not(:disabled) {
    padding-inline-end: calc(var(--handler-width) + var(--spacingXS) - 1px);
}

/* Small keeps a 4px gap between the value and the handler, not 8px. */
:where(main) :where(span, div).inputnumber:hover:has(> input.sm) > input:not(:disabled) {
    padding-inline-end: calc(var(--handler-width) + var(--spacingXXS) - 1px);
}

:where(main) :where(span, div).inputnumber:has(> input:disabled) > button {
    display: none;
}

@media (hover: none) {
    :where(main) :where(span, div).inputnumber > button {
        opacity: 1;
    }
}

/* Select — Figma "Clark Connect Design System", Input / Single Select (node 2722:71744), Input / Search
   Select (2728:29806) and Input / Multi Select (2733:34251). The trigger is Input / Basic's box plus a
   16px DownOutlined chevron (8px gap, 12px end padding, colorTextPlaceholder ink) that does not rotate
   when open. A native <select> gets the chevron on top of the input rule above; a custom trigger is a
   <button class="select"> (or a <div class="select"> holding a search <input> or chips) whose
   aria-expanded="true" is Figma's Pressed state. Compose with .danger/.warning, .lg/.sm, and .multiple
   for a chip trigger; the chips are <span class="tag">. Search, clear and status icons are the
   consumer's. The list is <ul class="menu" role="listbox"> (Select Menu, nodes 6538:16333/6538:77041). */

/* The chevron: two half-diagonals of one 12x8 V, drawn in token ink because a <select> takes no
   pseudo-elements. The :disabled line re-applies it after the input rule's `background` shorthand. */
:where(main) select:where(:not([multiple]):not([size])),
:where(main) select:where(:not([multiple]):not([size])):disabled,
:where(main) :where(button, div).select {
    appearance: none;
    padding-inline-end: calc(var(--spacingSM) + var(--spacingMD) + var(--spacingXS));
    background-image:
        linear-gradient(to top right, transparent calc(50% - 0.75px), var(--colorTextPlaceholder) calc(50% - 0.75px), var(--colorTextPlaceholder) calc(50% + 0.75px), transparent calc(50% + 0.75px)),
        linear-gradient(to top left, transparent calc(50% - 0.75px), var(--colorTextPlaceholder) calc(50% - 0.75px), var(--colorTextPlaceholder) calc(50% + 0.75px), transparent calc(50% + 0.75px));
    background-repeat: no-repeat;
    background-size: 6px 8px;
    background-position: right calc(var(--spacingSM) + 8px) center, right calc(var(--spacingSM) + 2px) center;
}

/* Filled=No: the empty-value option is the placeholder; options keep body ink in the open list. */
:where(main) select:where(:has(option[value=""]:checked)) {
    color: var(--colorTextPlaceholder);
}

:where(main) select option {
    color: var(--colorText);
}

/* Custom trigger — Input / Basic's box, restated because a <button> otherwise takes the pill button. */
:where(main) :where(button, div).select {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--spacingXS);
    box-sizing: border-box;
    height: var(--controlHeight);
    padding-block: 0;
    padding-inline-start: calc(var(--spacingSM) - 1px);
    background-color: var(--colorFill);
    border: 1px solid var(--colorBorderInput);
    border-radius: var(--borderRadius);
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    text-align: start;
    cursor: pointer;
}

:where(main) :where(button, div).select:hover:where(:not(:disabled):not([aria-disabled="true"])) {
    border-color: var(--colorPrimaryHover);
}

/* Figma "Pressed" — the open list: brand border plus the 2px focusPrimary ring. */
:where(main) :where(button, div).select[aria-expanded="true"] {
    border-color: var(--colorPrimary);
    box-shadow: var(--shadowFocusPrimary);
}

/* A <div> trigger is focused through its inner search <input>, so it shows the highlight via :has(). */
:where(main) :where(button, div).select:focus-visible,
:where(main) :where(button, div).select:has(:focus-visible) {
    outline: 3px solid var(--colorLinkActive);
    outline-offset: 2px;
}

:where(main) :where(button, div).select input {
    flex: 1;
    min-width: 0;
    height: auto;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    outline: none;
}

/* Figma keeps colorText on a disabled value, as Input / Basic does. */
:where(main) :where(button, div).select:disabled,
:where(main) :where(button, div).select[aria-disabled="true"] {
    background-color: var(--colorFillDisabled);
    border-color: var(--colorBorderInput);
    color: var(--colorText);
    cursor: not-allowed;
}

:where(main) :where(button, div).select.danger {
    border-color: var(--colorDanger);
}

:where(main) :where(button, div).select.danger:hover:where(:not(:disabled):not([aria-disabled="true"])) {
    border-color: var(--colorDangerHover);
}

:where(main) :where(button, div).select.danger[aria-expanded="true"] {
    border-color: var(--colorDanger);
    box-shadow: var(--shadowFocusDanger);
}

:where(main) :where(button, div).select.warning {
    border-color: var(--colorWarning);
}

:where(main) :where(button, div).select.warning:hover:where(:not(:disabled):not([aria-disabled="true"])) {
    border-color: var(--colorWarningHover);
}

:where(main) :where(button, div).select.warning[aria-expanded="true"] {
    border-color: var(--colorWarning);
    box-shadow: var(--shadowFocusWarning);
}

/* Sizes — the native <select> takes the Input .lg/.sm rules; the custom trigger restates them. */
:where(main) :where(button, div).select.lg {
    height: var(--controlHeightLG);
    border-radius: var(--borderRadiusLG);
    font-size: var(--fontSizeLG);
    line-height: var(--lineHeightLG);
}

:where(main) select.sm,
:where(main) :where(button, div).select.sm {
    height: var(--controlHeightSM);
    padding-inline: calc(var(--spacingXS) - 1px) calc(var(--spacingXS) + var(--spacingMD) + var(--spacingXS));
    border-radius: var(--borderRadiusSM);
    background-position: right calc(var(--spacingXS) + 8px) center, right calc(var(--spacingXS) + 2px) center;
}

/* Multi Select — the chips wrap inside a box that grows past the control height; 4px start padding
   (2px at Small) lines the first chip up with the box edge. */
:where(main) :where(div).select.multiple {
    flex-wrap: wrap;
    gap: var(--spacingXXS);
    height: auto;
    min-height: var(--controlHeight);
    padding-block: calc(var(--spacingXXS) / 2);
    padding-inline-start: var(--spacingXXS);
}

:where(main) :where(div).select.multiple.lg {
    min-height: var(--controlHeightLG);
}

:where(main) :where(div).select.multiple.sm {
    min-height: var(--controlHeightSM);
    padding-block: 0;
    padding-inline-start: calc(var(--spacingXXS) / 2);
}

/* Button variants — Figma "Clark Connect Design System", Button component (node 253:1448). An
   un-classed <button> renders as the Default type; the classes opt into the other types, and an <a>
   needs a type class to be a button. Compose a type (.primary/.secondary/.default/.dashed/.link) with
   .danger (Primary/Secondary/Link only, matches Figma), .lg/.sm, and .icon for icon-only (a square
   box + the pill radius renders a circle). :where(button, a) adds no weight, so each class rule
   stays at one class. aria-busy="true" is Loading: the base draws the spinner and hides the
   consumer's glyphs, which otherwise render at 16px. */

:where(main) :where(button, a).primary,
:where(main) :where(button, a).secondary,
:where(main) :where(button, a).default,
:where(main) :where(button, a).dashed,
:where(main) :where(button, a).link,
:where(main) button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacingXS);
    border-radius: var(--borderRadiusRound);
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    /* An <a> wearing these classes would otherwise keep the UA underline; Figma buttons have none. */
    text-decoration: none;
    cursor: pointer;
}

:where(main) :where(button, a).primary,
:where(main) :where(button, a).secondary,
:where(main) :where(button, a).default,
:where(main) :where(button, a).dashed,
:where(main) button {
    height: var(--controlHeight);
    padding: 0 var(--spacingMD);
    border: 1px solid transparent;
}

/* Figma draws Link as a text-sized box (the 22px line, no padding) at every size, so it sits in
   running text or a table row without growing it; its brand-teal ink (Figma colorLink) lives here too,
   since every other type gets its look from its own section below but Link's is this one rule. */
:where(main) :where(button, a).link {
    height: auto;
    padding: 0;
    background: none;
    border: none;
    color: var(--colorLink);
}

/* Sizes — Link ignores size in Figma (same text-sized box at Default/Large/Small). An un-classed button is
   Default, so the size words alone size it too, at zero weight so .link's text box still wins. */
:where(main) button:where(.lg),
:where(main) :where(button, a).primary.lg,
:where(main) :where(button, a).secondary.lg,
:where(main) :where(button, a).default.lg,
:where(main) :where(button, a).dashed.lg {
    height: var(--controlHeightLG);
}

:where(main) button:where(.sm),
:where(main) :where(button, a).primary.sm,
:where(main) :where(button, a).secondary.sm,
:where(main) :where(button, a).default.sm,
:where(main) :where(button, a).dashed.sm {
    height: var(--controlHeightSM);
    padding: 0 var(--spacingXS);
}

/* Icon-only is square: width = the size's control height, no padding (the flex base centres the
   glyph); padding + borders made it 34px wide, a stadium rather than a circle. */
:where(main) button:where(.icon),
:where(main) :where(button, a).primary.icon,
:where(main) :where(button, a).secondary.icon,
:where(main) :where(button, a).default.icon,
:where(main) :where(button, a).dashed.icon {
    width: var(--controlHeight);
    padding: 0;
}

:where(main) button:where(.icon.lg),
:where(main) :where(button, a).primary.icon.lg,
:where(main) :where(button, a).secondary.icon.lg,
:where(main) :where(button, a).default.icon.lg,
:where(main) :where(button, a).dashed.icon.lg {
    width: var(--controlHeightLG);
}

:where(main) button:where(.icon.sm),
:where(main) :where(button, a).primary.icon.sm,
:where(main) :where(button, a).secondary.icon.sm,
:where(main) :where(button, a).default.icon.sm,
:where(main) :where(button, a).dashed.icon.sm {
    width: var(--controlHeightSM);
}

/* Figma's icon-only Link is a square of the text line: 22px, 24px at Large. */
:where(main) :where(button, a).link.icon {
    width: var(--lineHeight);
    height: var(--lineHeight);
    padding: 0;
}

:where(main) :where(button, a).link.icon.lg {
    width: var(--lineHeightLG);
    height: var(--lineHeightLG);
}

/* Primary — solid brand fill. */
:where(main) :where(button, a).primary {
    background: var(--colorPrimary);
    border-color: var(--colorPrimary);
    color: var(--colorTextLight);
}

:where(main) :where(button, a).primary:hover:not(:disabled) {
    background: var(--colorPrimaryHover);
    border-color: var(--colorPrimaryHover);
    color: var(--colorTextLight);
}

:where(main) :where(button, a).primary:active:not(:disabled) {
    background: var(--colorPrimaryActive);
    border-color: var(--colorPrimaryActive);
    color: var(--colorTextLight);
}

:where(main) :where(button, a).primary.danger {
    background: var(--colorDanger);
    border-color: var(--colorDanger);
}

:where(main) :where(button, a).primary.danger:hover:not(:disabled) {
    background: var(--colorDangerHover);
    border-color: var(--colorDangerHover);
}

:where(main) :where(button, a).primary.danger:active:not(:disabled) {
    background: var(--colorDangerActive);
    border-color: var(--colorDangerActive);
}

/* Secondary — brand-outlined, filled wash on hover/pressed. */
:where(main) :where(button, a).secondary {
    background: var(--colorFill);
    border-color: var(--colorPrimary);
    color: var(--colorPrimary);
}

:where(main) :where(button, a).secondary:hover:not(:disabled) {
    background: var(--colorPrimaryBg);
    border-color: var(--colorPrimaryHover);
    color: var(--colorPrimaryHover);
}

:where(main) :where(button, a).secondary:active:not(:disabled) {
    background: var(--colorPrimaryBgHover);
    border-color: var(--colorPrimaryActive);
    color: var(--colorPrimaryActive);
}

:where(main) :where(button, a).secondary.danger {
    border-color: var(--colorDanger);
    color: var(--colorDanger);
}

:where(main) :where(button, a).secondary.danger:hover:not(:disabled) {
    background: var(--colorDangerBg);
    border-color: var(--colorDangerHover);
    color: var(--colorDangerHover);
}

:where(main) :where(button, a).secondary.danger:active:not(:disabled) {
    /* Figma binds the Pressed wash to colorDangerBgHover. */
    background: var(--colorDangerBgHover);
    border-color: var(--colorDangerActive);
    color: var(--colorDangerActive);
}

/* Default — neutral bordered button, and the look of an un-classed <button>. The bare states weigh
   one element so a class-styled button keeps its own look; :focus-visible stays heavier on purpose.
   Figma keeps colorBorder on hover and pressed; only the wash and the ink change. */
:where(main) :where(button, a).default,
:where(main) button {
    background: var(--colorFill);
    border-color: var(--colorBorderButton);
    color: var(--colorText);
}

:where(main) :where(button, a).default:hover:not(:disabled),
:where(main) button:where(:not(:disabled):hover) {
    background: var(--colorPrimaryBg);
    color: var(--colorPrimaryHover);
}

:where(main) :where(button, a).default:active:not(:disabled),
:where(main) button:where(:not(:disabled):active) {
    background: var(--colorPrimaryBgHover);
    color: var(--colorPrimaryActive);
}

/* Toggle kept-selected (aria-pressed); no Figma state yet. Source order wins the bare-hover tie; the
   heavier classed hover still shows its own look on a selected chip, which is intended. */
:where(main) :where(button, a).default[aria-pressed="true"],
:where(main) button:where([aria-pressed="true"]) {
    background: var(--colorPrimaryBg);
    border-color: var(--colorPrimary);
    color: var(--colorPrimary);
}

/* Dashed — Default's neutral look with a dashed border; reserved for add/create actions. */
:where(main) :where(button, a).dashed {
    background: var(--colorFill);
    border-style: dashed;
    border-color: var(--colorBorderButton);
    color: var(--colorText);
}

:where(main) :where(button, a).dashed:hover:not(:disabled) {
    background: var(--colorPrimaryBg);
    color: var(--colorPrimaryHover);
}

:where(main) :where(button, a).dashed:active:not(:disabled) {
    background: var(--colorPrimaryBgHover);
    color: var(--colorPrimaryActive);
}

/* Link states — text-only, for inline/table-row actions; Figma underlines on hover only, pressed drops it. */
:where(main) :where(button, a).link:hover:not(:disabled) {
    color: var(--colorLinkHover);
    text-decoration: underline;
}

:where(main) :where(button, a).link:active:not(:disabled) {
    color: var(--colorLinkActive);
    text-decoration: none;
}

:where(main) :where(button, a).link.danger {
    color: var(--colorDanger);
}

:where(main) :where(button, a).link.danger:hover:not(:disabled) {
    color: var(--colorDangerHover);
}

:where(main) :where(button, a).link.danger:active:not(:disabled) {
    color: var(--colorDangerActive);
}

/* Figma "Focused" Focus Highlight: a 3px band sits 2px clear of every button's own border, all types alike. */
:where(main) :where(button, a).primary:focus-visible,
:where(main) :where(button, a).secondary:focus-visible,
:where(main) :where(button, a).default:focus-visible,
:where(main) :where(button, a).dashed:focus-visible,
:where(main) :where(button, a).link:focus-visible,
:where(main) button:focus-visible {
    outline: 3px solid var(--colorLinkActive);
    outline-offset: 2px;
}

/* Figma binds the non-danger Link's highlight to colorLink and its text to colorLinkHover; a danger
   Link keeps the colorLinkActive band and its red label. */
:where(main) :where(button, a).link:where(:not(.danger)):focus-visible {
    outline-color: var(--colorLink);
    color: var(--colorLinkHover);
}

/* Disabled — Figma's flat fill/text swap. */
:where(main) :where(button, a).primary:disabled,
:where(main) :where(button, a).secondary:disabled,
:where(main) :where(button, a).default:disabled,
:where(main) :where(button, a).dashed:disabled,
:where(main) button:where(:disabled) {
    background: var(--colorFillDisabled);
    border-color: var(--colorBorderButton);
    color: var(--colorTextDisabled);
    cursor: not-allowed;
}

:where(main) :where(button, a).link:disabled {
    color: var(--colorTextDisabled);
    cursor: not-allowed;
}

/* Figma draws every button glyph (leading, trailing, icon-only) at 16px, 8px from the label. */
:where(main) :where(button, a.primary, a.secondary, a.default, a.dashed, a.link) > :where(svg, img) {
    flex: none;
    width: var(--controlIconSize);
    height: var(--controlIconSize);
}

/* Figma "Loading": 65% opacity and a 16px three-quarter spinner in the leading slot;
   Figma forbids a leading icon here, so the consumer's glyphs hide. aria-busy is the only ARIA
   state for it. */
:where(main) :where(button, a)[aria-busy="true"] {
    opacity: 0.65;
    cursor: progress;
}

:where(main) :where(button, a)[aria-busy="true"]::before {
    content: "";
    flex: none;
    box-sizing: border-box;
    width: var(--controlIconSize);
    height: var(--controlIconSize);
    /* Half the smallest spacing step; the scale has no 2px value. */
    border: calc(var(--spacingXXS) / 2) solid currentColor;
    border-inline-end-color: transparent;
    border-radius: var(--borderRadiusRound);
    animation: cc-button-spin 1s linear infinite;
}

:where(main) :where(button, a)[aria-busy="true"] > :where(svg, img) {
    display: none;
}

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

@media (prefers-reduced-motion: reduce) {
    :where(main) :where(button, a)[aria-busy="true"]::before {
        animation-duration: 3s;
    }
}

/* Dropdown — Figma "Clark Connect Design System", Dropdown / Basic (node 3983:1402), Dropdown / Button
   (node 3991:2022) and Dropdown / Button Twofold (node 3991:2050). A `.dropdown` container holds the
   trigger(s) and a `.menu`: a `link` button is the Basic text trigger, a `default` (or un-classed) button
   the Button trigger, and two adjacent buttons the Twofold split. The Button component is the source of
   truth for the trigger box (pill, wash on hover). `aria-expanded="true"` is Figma's Pressed (menu open)
   state; the chevron is drawn here on any `[aria-haspopup]` trigger that is not `.icon`. Showing/hiding
   the menu (`hidden`) and its placement past the viewport edge are the consumer's. */

:where(main) :where(span, div).dropdown {
    position: relative;
    display: inline-flex;
    vertical-align: top;
}

/* An open menu holds the Default button's pressed colours. */
:where(main) .dropdown > :where(button:not([class]), .default)[aria-expanded="true"]:not(:disabled) {
    background: var(--colorPrimaryBgHover);
    color: var(--colorPrimaryActive);
}

/* Basic — the text-sized Link box in brand teal, never underlined. */
:where(main) .dropdown > :where(button, a).link:not(:disabled) {
    color: var(--colorPrimary);
}

:where(main) .dropdown > :where(button, a).link:hover:not(:disabled),
:where(main) .dropdown > :where(button, a).link:focus-visible:not(:disabled) {
    color: var(--colorPrimaryHover);
    text-decoration: none;
}

:where(main) .dropdown > :where(button, a).link:active:not(:disabled),
:where(main) .dropdown > :where(button, a).link[aria-expanded="true"]:not(:disabled) {
    color: var(--colorPrimaryActive);
    text-decoration: none;
}

/* Icon / DownOutlined as a colourless mask so it tracks the trigger's text colour in every state;
   Figma does not rotate it when open. */
:where(main) .dropdown > :where(button, a)[aria-haspopup]:not(.icon)::after {
    content: "";
    flex: none;
    width: var(--controlIconSize);
    height: var(--controlIconSize);
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M13.8125 4H12.6406C12.561 4 12.486 4.03906 12.4391 4.10313L8 10.2219L3.56096 4.10313C3.51408 4.03906 3.43908 4 3.35939 4H2.18752C2.08596 4 2.02658 4.11563 2.08596 4.19844L7.59533 11.7937C7.79533 12.0687 8.20471 12.0687 8.40315 11.7937L13.9125 4.19844C13.9735 4.11563 13.9141 4 13.8125 4Z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M13.8125 4H12.6406C12.561 4 12.486 4.03906 12.4391 4.10313L8 10.2219L3.56096 4.10313C3.51408 4.03906 3.43908 4 3.35939 4H2.18752C2.08596 4 2.02658 4.11563 2.08596 4.19844L7.59533 11.7937C7.79533 12.0687 8.20471 12.0687 8.40315 11.7937L13.9125 4.19844C13.9735 4.11563 13.9141 4 13.8125 4Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

:where(main) .dropdown > :where(button, a).link[aria-haspopup]::after {
    width: var(--controlIconSizeSM);
    height: var(--controlIconSizeSM);
}

/* Twofold — two buttons share one box: only the outer corners round, the second overlaps the first by
   its border so the divider is one line, and the hovered/focused/pressed half is lifted so its full
   border (including the shared edge) paints on top, as Figma draws each half's own outline. */
:where(main) .dropdown > button:not(:last-of-type) {
    border-start-end-radius: 0;
    border-end-end-radius: 0;
}

:where(main) .dropdown > button + button {
    margin-inline-start: -1px;
    border-start-start-radius: 0;
    border-end-start-radius: 0;
}

:where(main) .dropdown > button:where(:hover, :focus-visible, :active, [aria-expanded="true"]):not(:disabled) {
    position: relative;
    z-index: 1;
}

/* Menu — Figma Select Menu / Single Select (6538:16333) and / Multi Select (6538:77041), the same panel
   the Dropdown frames open (4000:44989): a 4px padded panel with the Elevation shadow and no border.
   <ul class="menu" role="listbox"> of <li role="option"> for a Select, <ul class="menu" role="menu"> of
   <li role="menuitem"> for a Dropdown; each item is a 32px row. Selection is aria-selected (primary
   wash + strong weight), multi-select adds aria-multiselectable on the list and a brand check. Hover
   has no Figma state; it takes the page grey. Outside a .dropdown, position the panel yourself (Figma
   opens it 2px below the trigger). */
:where(main) :where(ul, div).menu {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    /* Eight rows plus the panel padding; Figma draws no scroll limit. */
    max-height: calc(var(--controlHeight) * 8 + var(--spacingXS));
    margin: 0;
    padding: var(--spacingXXS);
    overflow-y: auto;
    list-style: none;
    background: var(--colorFill);
    border-radius: var(--borderRadius);
    box-shadow: var(--shadowElevation);
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
}

/* Author display beats the UA's [hidden] { display: none }, and a closed Dropdown menu is hidden. */
:where(main) :where(ul, div).menu[hidden] {
    display: none;
}

:where(main) .menu > [role="option"],
:where(main) .menu > [role="menuitem"],
:where(main) .menu > [role="group"] > :where(ul) > [role="option"] {
    display: flex;
    align-items: center;
    gap: var(--spacingXS);
    box-sizing: border-box;
    min-height: var(--controlHeight);
    padding: calc((var(--controlHeight) - var(--lineHeight)) / 2) var(--spacingSM);
    border-radius: var(--borderRadiusSM);
    cursor: pointer;
}

:where(main) .menu [role="option"]:hover:where(:not([aria-disabled="true"])),
:where(main) .menu [role="menuitem"]:hover:where(:not([aria-disabled="true"])) {
    background: var(--colorBgPage);
}

:where(main) .menu [role="option"][aria-selected="true"] {
    background: var(--colorPrimaryBg);
    font-weight: var(--fontWeightStrong);
}

:where(main) .menu [role="option"]:focus-visible,
:where(main) .menu [role="menuitem"]:focus-visible {
    outline: 3px solid var(--colorLinkActive);
    outline-offset: 2px;
}

:where(main) .menu [role="option"][aria-disabled="true"],
:where(main) .menu [role="menuitem"][aria-disabled="true"] {
    color: var(--colorTextDisabled);
    cursor: not-allowed;
}

/* Consecutive selected rows read as one block (Figma's Selected Position Top/Bottom). */
:where(main) .menu [role="option"][aria-selected="true"] + [aria-selected="true"] {
    border-start-start-radius: 0;
    border-start-end-radius: 0;
}

:where(main) .menu [role="option"][aria-selected="true"]:has(+ [aria-selected="true"]) {
    border-end-start-radius: 0;
    border-end-end-radius: 0;
}

/* Multi-select CheckOutlined in Select Menu/colorPrimary, drawn as a rotated corner in a 20px slot. */
:where(main) .menu[aria-multiselectable="true"] [role="option"][aria-selected="true"]::after {
    content: "";
    flex: none;
    box-sizing: border-box;
    width: 6px;
    height: 11px;
    margin: 0 7px 3px auto;
    border: solid var(--colorPrimary);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

/* Group — <li role="group" aria-labelledby> holding a <span role="presentation"> title and a
   <ul role="none"> of options, which Figma indents by its 4px Group Title Space plus the 8px gap. */
:where(main) .menu > [role="group"] > [role="presentation"] {
    display: flex;
    align-items: center;
    min-height: var(--controlHeight);
    padding: 0 var(--spacingSM);
    color: var(--colorTextDescription);
    font-size: var(--fontSizeSM);
    line-height: var(--lineHeightSM);
}

:where(main) .menu > [role="group"] > :where(ul) {
    margin: 0;
    padding: 0;
    list-style: none;
}

:where(main) .menu > [role="group"] > :where(ul) > [role="option"] {
    padding-inline-start: calc(var(--spacingSM) + var(--spacingXXS) + var(--spacingXS));
}

/* Empty — Figma Empty State: centred secondary text under the consumer's 64px illustration. */
:where(main) .menu > :where(li).empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacingXS);
    padding: var(--spacingMD) var(--spacingLG);
    color: var(--colorTextDescription);
    text-align: center;
}

/* Dropdown-only placement: 2px below the trigger's border edge, at least the trigger's width; nowrap
   because an absolute panel otherwise wraps its items at the narrow container's width. */
:where(main) .dropdown > .menu {
    position: absolute;
    top: calc(100% + var(--spacingXXS) / 2);
    left: 0;
    z-index: 1000;
    min-width: 100%;
    white-space: nowrap;
}

/* Picker panel — Figma "Clark Connect Design System", the popups of Input / DatePicker (node 2722:75146),
   Input / DatePicker (Ranged) (2722:82769), Input / TimePicker (2722:79955) and Input / TimePicker
   (Ranged) (14868:34841): Calendar / Card, the preset list and the TimePicker columns. The trigger is the
   Input / Basic box (an <input> already gets it); this styles only the open panel, and opening,
   positioning, focus and keyboard are the consumer's. A <div class="picker"> is a wrapping flex row of:
   <menu> (presets), one <section> per month (<header> of <select class="sm"> + a <table> of <button>
   day cells), <ul role="listbox"> time columns of <li role="option">, and a full-width <footer> of
   <button class="link"> + <button class="primary sm">. Add .time for a time-only panel. Cell state:
   aria-selected on the <td> (the gridcell), aria-current="date" and :disabled on its <button>. */

:where(main) :where(div).picker {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: flex-start;
    /* A popup sizes to its months/columns; wrapping them under a narrow trigger would break the grid. */
    width: max-content;
    background: var(--colorFill);
    border: 1px solid var(--colorBorderSecondary);
    border-radius: var(--borderRadiusLG);
    box-shadow: var(--shadowElevation);
    overflow: hidden;
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
}

/* Figma's TimePicker popup is borderless with the base radius, unlike Calendar / Card. */
:where(main) :where(div).picker.time {
    padding-top: var(--spacingXXS);
    border-width: 0;
    border-radius: var(--borderRadius);
}

/* Presets — Select Menu Item rows down the left edge of the ranged panel. */
:where(main) :where(div).picker > menu {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    gap: var(--spacingXS);
    margin: 0;
    padding: var(--spacingXS);
    list-style: none;
    border-inline-end: 1px solid var(--colorBorderSecondary);
}

:where(main) :where(div).picker > menu button {
    justify-content: flex-start;
    width: 100%;
    padding: 0 var(--spacingSM);
    background: transparent;
    border-color: transparent;
    border-radius: var(--borderRadiusSM);
    color: var(--colorText);
}

/* No Figma hover for picker rows or cells; the neutral page tint keeps the brand wash for selection. */
:where(main) :where(div).picker > menu button:hover:not(:disabled) {
    background: var(--colorBgPage);
    border-color: transparent;
    color: var(--colorText);
}

:where(main) :where(div).picker > section + section {
    border-inline-start: 1px solid var(--colorBorderSecondary);
}

:where(main) :where(div).picker > section > header {
    display: flex;
    align-items: center;
    gap: var(--spacingXS);
    padding: var(--spacingSM) var(--spacingXS);
    border-bottom: 1px solid var(--colorBorderSecondary);
}

:where(main) :where(div).picker table {
    margin: var(--spacingXXS);
    border-collapse: collapse;
}

/* Figma draws no weekday row; the table keeps one for column headers, muted so the grid leads. */
:where(main) :where(div).picker th {
    padding: 0;
    color: var(--colorTextDescription);
    font-size: var(--fontSizeSM);
    font-weight: var(--fontWeightRegular);
    line-height: var(--lineHeightSM);
    text-align: center;
}

:where(main) :where(div).picker td {
    position: relative;
    padding: var(--spacingXXS) var(--spacingXS);
    text-align: center;
}

:where(main) :where(div).picker td > button {
    min-width: var(--controlHeightSM);
    height: var(--controlHeightSM);
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--borderRadiusSM);
    color: var(--colorText);
}

:where(main) :where(div).picker td:not([aria-selected="true"]) > button:hover:not(:disabled) {
    background: var(--colorBgPage);
    border-color: transparent;
    color: var(--colorText);
}

/* Today — Figma's 1px colorPrimary ring. */
:where(main) :where(div).picker td > button[aria-current="date"] {
    border-color: var(--colorPrimary);
}

:where(main) :where(div).picker td[aria-selected="true"] > button {
    background: var(--colorPrimary);
    border-color: var(--colorPrimary);
    color: var(--colorTextLight);
}

/* Adjacent-month days: no ARIA state exists, hence data-outside. Figma colorTextDisabled (1.8:1). */
:where(main) :where(div).picker td[data-outside] > button,
:where(main) :where(div).picker td > button:disabled {
    color: var(--colorTextDisabled);
}

:where(main) :where(div).picker td > button:disabled {
    background: transparent;
    border-color: transparent;
    cursor: not-allowed;
}

/* Range band — ARIA has no range-position state, hence data-range="start|in|end" on the <td>. The band
   is the button's 24px height, full cell width; endpoints tint only their inner half. */
:where(main) :where(div).picker td[data-range]::before {
    content: "";
    position: absolute;
    inset: var(--spacingXXS) 0;
    background: var(--colorPrimaryBg);
}

:where(main) :where(div).picker td[data-range="start"]::before {
    inset-inline-start: 50%;
}

:where(main) :where(div).picker td[data-range="end"]::before {
    inset-inline-end: 50%;
}

/* position lifts the button above the ::before band. */
:where(main) :where(div).picker td[data-range] > button {
    position: relative;
}

/* Figma squares an endpoint's inner edge and rounds its outer edge at DatePicker/borderRadius. */
:where(main) :where(div).picker td[data-range="start"] > button {
    border-radius: var(--borderRadius) 0 0 var(--borderRadius);
}

:where(main) :where(div).picker td[data-range="end"] > button {
    border-radius: 0 var(--borderRadius) var(--borderRadius) 0;
}

/* Time columns — eight 28px rows visible, the rest scroll. */
:where(main) :where(div).picker > ul {
    /* Figma's TimePicker Item draws a raw 28px row; no Figma variable. */
    --item-height: 28px;
    display: flex;
    flex-direction: column;
    height: calc(var(--item-height) * 8);
    margin: 0;
    padding: 0 var(--spacingXXS);
    list-style: none;
    overflow-y: auto;
    scrollbar-width: thin;
}

:where(main) :where(div).picker > ul + ul {
    border-inline-start: 1px solid var(--colorBorderSecondary);
}

:where(main) :where(div).picker > ul > li {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    min-width: var(--controlHeight);
    height: var(--item-height);
    border-radius: var(--borderRadiusSM);
    cursor: pointer;
}

:where(main) :where(div).picker > ul > li:hover {
    background: var(--colorBgPage);
}

/* Figma Components/SelectMenu/controlItemBgActive; source order keeps it over the hover tint. */
:where(main) :where(div).picker > ul > li[aria-selected="true"] {
    background: var(--colorPrimaryBg);
}

:where(main) :where(div).picker > ul > li[aria-disabled="true"] {
    background: transparent;
    color: var(--colorTextDisabled);
    cursor: not-allowed;
}

:where(main) :where(div).picker > footer {
    display: flex;
    flex-basis: 100%;
    /* Keeps the footer's own content out of the panel's max-content width; flex-basis still fills the row. */
    width: 0;
    align-items: center;
    gap: var(--spacingXS);
    padding: var(--spacingXS) var(--spacingSM);
    border-top: 1px solid var(--colorBorderSecondary);
}

/* The confirm button stays pinned to the end whether or not a Now/Today link precedes it. */
:where(main) :where(div).picker > footer > :last-child {
    margin-inline-start: auto;
}

/* Checkbox (node 767:47990) and Radio / Basic (node 395:11370) — native <input type="checkbox|radio">
   redrawn with appearance:none so the box, radius and mark follow Figma in every browser. The mark
   (check, indeterminate square, radio dot) is ::before painted in currentColor, so each state only
   sets `color`. :where() keeps every rest selector at one element, like the text-input rule above. */
:where(main) input:where([type="checkbox"], [type="radio"]) {
    appearance: none;
    position: relative;
    flex: none;
    box-sizing: border-box;
    width: var(--controlInteractiveSize);
    height: var(--controlInteractiveSize);
    margin: 0;
    background: var(--colorFill);
    border: 1px solid var(--colorBorderInput);
    border-radius: var(--borderRadiusSM);
    color: var(--colorPrimary);
    vertical-align: middle;
    cursor: pointer;
}

:where(main) input:where([type="radio"]) {
    border-radius: var(--borderRadiusRound);
}

:where(main) input:where([type="checkbox"], [type="radio"])::before {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    box-sizing: border-box;
}

:where(main) input:where([type="checkbox"]):checked {
    background: var(--colorPrimary);
    border-color: var(--colorPrimary);
    color: var(--colorWhite);
}

/* The antd check glyph as two 2px borders of a rotated box; the 1px lift re-centres the L's visual mass. */
:where(main) input:where([type="checkbox"]):checked::before {
    width: 5.7px;
    height: 9.1px;
    border: 2px solid currentColor;
    border-block-start: 0;
    border-inline-start: 0;
    transform: translateY(-1px) rotate(45deg);
}

/* Figma's mixed state keeps the unchecked box with a centred 8px square, even when also :checked. */
:where(main) input:where([type="checkbox"]):indeterminate {
    background: var(--colorFill);
    border-color: var(--colorBorderInput);
    color: var(--colorPrimary);
}

:where(main) input:where([type="checkbox"]):indeterminate::before,
:where(main) input:where([type="radio"]):checked::before {
    width: calc(var(--controlInteractiveSize) / 2);
    height: calc(var(--controlInteractiveSize) / 2);
    border: 0;
    background: currentColor;
    transform: none;
}

:where(main) input:where([type="radio"]):checked {
    border-color: var(--colorPrimary);
}

:where(main) input:where([type="radio"]):checked::before {
    border-radius: var(--borderRadiusRound);
}

/* Hovered and Focused share one look in Figma: colorPrimaryHover border, fill and mark. The label:hover
   form lights the box when the text is hovered, as Figma's Hovered variant covers the whole row. */
:where(main) input:where([type="checkbox"]):where(:not(:disabled)):is(:hover, :focus-visible),
:where(main) label:hover > input:where([type="checkbox"]):where(:not(:disabled)) {
    border-color: var(--colorPrimaryHover);
}

:where(main) input:where([type="checkbox"]):checked:where(:not(:disabled)):is(:hover, :focus-visible),
:where(main) label:hover > input:where([type="checkbox"]):checked:where(:not(:disabled)) {
    background: var(--colorPrimaryHover);
}

:where(main) input:where([type="checkbox"]):indeterminate:where(:not(:disabled)):is(:hover, :focus-visible),
:where(main) label:hover > input:where([type="checkbox"]):indeterminate:where(:not(:disabled)) {
    background: var(--colorFill);
    color: var(--colorPrimaryHover);
}

/* Figma's Checkbox focus band is 3px colorPrimaryHover (not the link-active Focus Highlight), 2px
   clear of the box, drawn around the box and its label together; a label-less box carries it alone. */
:where(main) input:where([type="checkbox"]):focus-visible {
    outline: 3px solid var(--colorPrimaryHover);
    outline-offset: 2px;
}

:where(main) label > input:where([type="checkbox"]):focus-visible {
    outline: none;
}

:where(main) label:where(:has(> input[type="checkbox"]:focus-visible)) {
    outline: 3px solid var(--colorPrimaryHover);
    outline-offset: 2px;
    border-radius: var(--borderRadius);
}

/* Radio hover is colorPrimary (not -hover); focus is the brand border plus Light/focusPrimary, as drawn. */
:where(main) input:where([type="radio"]):where(:not(:disabled)):hover,
:where(main) label:hover > input:where([type="radio"]):where(:not(:disabled)) {
    border-color: var(--colorPrimary);
}

:where(main) input:where([type="radio"]):focus-visible {
    outline: none;
    border-color: var(--colorPrimary);
    box-shadow: var(--shadowFocusPrimary);
}

:where(main) input:where([type="checkbox"], [type="radio"]):disabled {
    background: var(--colorFillDisabled);
    border-color: var(--colorBorderInput);
    color: var(--colorTextDisabled);
    cursor: not-allowed;
}

/* A label wrapping a checkbox, radio or switch is one row, Checkbox/Radio marginXS apart, in colorText
   (#262626) rather than the Form/colorText of the plain label rule. */
:where(main) label:where(:has(> input[type="checkbox"], > input[type="radio"], > .switch)) {
    display: inline-flex;
    align-items: center;
    gap: var(--spacingXS);
    color: var(--colorText);
    cursor: pointer;
}

/* Switch keeps colorText on a disabled label in Figma; only Checkbox/Radio grey theirs. */
:where(main) label:where(:has(> input[type="checkbox"]:disabled, > input[type="radio"]:disabled)) {
    color: var(--colorTextDisabled);
    cursor: not-allowed;
}

/* RadioBasicGroup (node 3331:1423) — a <fieldset> or role="radiogroup" <div> of choice labels:
   vertical by default, .horizontal for a wrapping row. Serves a checkbox list too. */
:where(main) :where(fieldset, div).radio-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacingMD);
    min-inline-size: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

:where(main) :where(fieldset, div).radio-group.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacingLG);
}

/* Switch — Figma "Clark Connect Design System", Switch (node 4425:28830). <button type="button"
   role="switch" aria-checked="true|false" class="switch">, named by a wrapping <label> or aria-label.
   The handle is ::after (the pseudo the WASM app.css switch uses, so a page loading both never draws
   two handles); an Icon-type glyph (check/close) is the consumer's child, laid in the free side of the
   track. Compose .sm; aria-busy="true" is Loading. Focus is the bare button's Focus Highlight: Figma
   draws no focused switch. */
:where(main) :where(button).switch {
    /* Figma's raw track and handle sizes (no variables); .sm re-declares them. */
    --track-width: 44px;
    --track-height: 22px;
    --handle: 18px;
    --handle-pressed: 24px;
    position: relative;
    flex: none;
    box-sizing: border-box;
    min-width: var(--track-width);
    height: var(--track-height);
    padding-block: 0;
    padding-inline: calc(var(--spacingXXS) / 2 + var(--handle) + var(--spacingXS)) calc(var(--spacingXXS) / 2);
    background: var(--colorBorderInput);
    border: none;
    border-radius: var(--borderRadiusRound);
    color: var(--colorTextLight);
}

:where(main) :where(button).switch::after {
    content: "";
    position: absolute;
    inset-block-start: calc(var(--spacingXXS) / 2);
    inset-inline-start: calc(var(--spacingXXS) / 2);
    width: var(--handle);
    height: var(--handle);
    background: var(--colorTextLight);
    border-radius: var(--borderRadiusRound);
    box-shadow: var(--shadowSwitchHandle);
}

:where(main) :where(button).switch[aria-checked="true"] {
    padding-inline: calc(var(--spacingXXS) / 2) calc(var(--spacingXXS) / 2 + var(--handle) + var(--spacingXS));
    background: var(--colorPrimary);
}

:where(main) :where(button).switch[aria-checked="true"]::after {
    inset-inline-start: calc(100% - var(--spacingXXS) / 2 - var(--handle));
}

/* No Figma hover state; darkens each track one step, as antd does. */
:where(main) :where(button).switch:hover:not(:disabled) {
    background: var(--colorTextDescription);
}

:where(main) :where(button).switch[aria-checked="true"]:hover:not(:disabled) {
    background: var(--colorPrimaryHover);
}

/* Figma "Pressed" stretches the handle toward the track centre. */
:where(main) :where(button).switch:active:not(:disabled)::after {
    width: var(--handle-pressed);
}

:where(main) :where(button).switch[aria-checked="true"]:active:not(:disabled)::after {
    inset-inline-start: calc(100% - var(--spacingXXS) / 2 - var(--handle-pressed));
}

/* Figma Disabled and Loading both fade the whole track to 65% and drop the handle shadow. */
:where(main) :where(button).switch:disabled,
:where(main) :where(button).switch[aria-busy="true"] {
    opacity: 0.65;
    cursor: not-allowed;
}

:where(main) :where(button).switch:disabled::after,
:where(main) :where(button).switch[aria-busy="true"]::after {
    box-shadow: none;
}

/* Loading: a quarter arc (LoadingOutlined) inside the handle, in the track colour; outweighs the
   Button Loading spinner, which shares the ::before. */
:where(main) :where(button).switch[aria-busy="true"]::before {
    content: "";
    position: absolute;
    z-index: 1;
    inset-block-start: var(--spacingXXS);
    inset-inline-start: var(--spacingXXS);
    box-sizing: border-box;
    width: calc(var(--handle) - var(--spacingXXS));
    height: calc(var(--handle) - var(--spacingXXS));
    border: 1px solid transparent;
    border-block-start-color: var(--colorBorderInput);
    border-radius: var(--borderRadiusRound);
    animation: cc-switch-spin 1s linear infinite;
}

:where(main) :where(button).switch[aria-busy="true"][aria-checked="true"]::before {
    inset-inline-start: calc(100% - var(--handle));
    border-block-start-color: var(--colorPrimary);
}

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

@media (prefers-reduced-motion: reduce) {
    :where(main) :where(button).switch[aria-busy="true"]::before {
        animation: none;
    }
}

/* Small: 28x16 track, 12px handle, and a 2px glyph gap (Figma Switch Content gap). */
:where(main) :where(button).switch.sm {
    --track-width: 28px;
    --track-height: 16px;
    --handle: 12px;
    --handle-pressed: 16px;
    padding-inline: calc(var(--spacingXXS) + var(--handle)) calc(var(--spacingXXS) / 2);
}

:where(main) :where(button).switch.sm[aria-checked="true"] {
    padding-inline: calc(var(--spacingXXS) / 2) calc(var(--spacingXXS) + var(--handle));
}

/* Segmented — Figma "Clark Connect Design System", RadioButtonGroup (node 3289:52860), not the MFE:
   joined bordered options, one selected. Children are <button aria-pressed="true|false"> or a <label>
   wrapping a visually hidden <input type="radio">. Compose .solid (filled selection), .sm, .lg.
   `.segmented > button` weighs (0,1,1), so it beats the bare button rules by design. */
:where(main) .segmented {
    display: inline-flex;
    align-items: center;
    isolation: isolate;
}

:where(main) .segmented > button,
:where(main) .segmented > label {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: var(--controlHeight);
    padding: 0 var(--spacingMD);
    background: var(--colorFill);
    border: 1px solid var(--colorBorderInput);
    border-radius: 0;
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    white-space: nowrap;
    cursor: pointer;
}

/* Neighbours share one 1px border, as Figma strokes each segment on three sides. */
:where(main) .segmented > :where(button, label) + :where(button, label) {
    margin-inline-start: -1px;
}

:where(main) .segmented > :first-child {
    border-start-start-radius: var(--borderRadius);
    border-end-start-radius: var(--borderRadius);
}

:where(main) .segmented > :last-child {
    border-start-end-radius: var(--borderRadius);
    border-end-end-radius: var(--borderRadius);
}

:where(main) .segmented > label > input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: inherit;
}

/* No Figma hover state; the Button's hover ink without its wash, so the selected fill stays distinct. */
:where(main) .segmented > button:where(:not(:disabled):hover),
:where(main) .segmented > label:where(:not(:has(> input:disabled)):hover) {
    background: var(--colorFill);
    color: var(--colorPrimaryHover);
}

/* Selected is raised so all four of its borders show over the shared neighbour edges. */
:where(main) .segmented > button[aria-pressed="true"],
:where(main) .segmented > label:has(> input:checked) {
    z-index: 1;
    background: var(--colorPrimaryBg);
    border-color: var(--colorPrimary);
    color: var(--colorPrimary);
}

:where(main) .segmented.solid > button[aria-pressed="true"],
:where(main) .segmented.solid > label:has(> input:checked) {
    background: var(--colorPrimary);
    border-color: var(--colorPrimary);
    color: var(--colorTextLight);
}

:where(main) .segmented > :focus-visible,
:where(main) .segmented > label:has(> input:focus-visible) {
    z-index: 2;
}

:where(main) .segmented > label:has(> input:focus-visible) {
    outline: 3px solid var(--colorLinkActive);
    outline-offset: 2px;
}

/* No Figma disabled state; the Button's flat disabled swap. */
:where(main) .segmented > button:disabled,
:where(main) .segmented > label:has(> input:disabled) {
    background: var(--colorFillDisabled);
    border-color: var(--colorBorderInput);
    color: var(--colorTextDisabled);
    cursor: not-allowed;
}

:where(main) .segmented.sm > button,
:where(main) .segmented.sm > label {
    height: var(--controlHeightSM);
    padding: 0 var(--spacingXS);
}

:where(main) .segmented.lg > button,
:where(main) .segmented.lg > label {
    height: var(--controlHeightLG);
    font-size: var(--fontSizeLG);
    line-height: var(--lineHeightLG);
}

/* Large takes the LG radius like every other .lg control. */
:where(main) .segmented.lg > :first-child {
    border-start-start-radius: var(--borderRadiusLG);
    border-end-start-radius: var(--borderRadiusLG);
}

:where(main) .segmented.lg > :last-child {
    border-start-end-radius: var(--borderRadiusLG);
    border-end-end-radius: var(--borderRadiusLG);
}

/* Tag — Figma "Clark Connect Design System", Tag / Status (node 2866:5570), not the MFE. A bordered, filled chip (1px outline on a wash, 4px radius, 12/20 text, 22px tall)
   with an optional 12px leading status icon, the consumer's, drawn in currentColor 4px from the
   label. Bare .tag is Figma Default; compose success, warning, danger (Figma Error), processing. */
:where(main) :where(span, a).tag {
    display: inline-flex;
    align-items: center;
    gap: var(--spacingXXS);
    padding: 0 var(--spacingXS);
    background: var(--colorFillSecondary);
    border: 1px solid var(--colorBorder);
    border-radius: var(--borderRadiusSM);
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSizeSM) / var(--lineHeightSM) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    text-decoration: none;
    white-space: nowrap;
}

/* Figma's status icons are 12px, the tag's font size. */
:where(main) :where(span, a).tag > :where(svg, img) {
    flex: none;
    width: var(--fontSizeSM);
    height: var(--fontSizeSM);
}

:where(main) :where(span, a).tag.success {
    background: var(--colorSuccessBg);
    border-color: var(--colorSuccessHover);
    color: var(--colorSuccessText);
}

:where(main) :where(span, a).tag.warning {
    background: var(--colorWarningBg);
    border-color: var(--colorWarningActive);
    color: var(--colorWarningText);
}

/* Figma binds the Error ink to Red/7 (danger-hover): 6.4:1 on the wash, where danger is 4.2:1. */
:where(main) :where(span, a).tag.danger {
    background: var(--colorDangerBg);
    border-color: var(--colorDangerBorderActive);
    color: var(--colorDangerHover);
}

:where(main) :where(span, a).tag.processing {
    background: var(--colorInfoBg);
    border-color: var(--colorInfo);
    color: var(--colorLinkHover);
}

/* Select / Multi Select chip — the Tag at body type (Figma binds Components/Tag fill and border); Small keeps the tag's 12px. */
:where(main) .select.multiple :where(span).tag {
    font-size: var(--fontSize);
    line-height: var(--lineHeight);
}

:where(main) .select.multiple.lg :where(span).tag {
    padding-block: var(--spacingXXS);
}

:where(main) .select.multiple.sm :where(span).tag {
    font-size: var(--fontSizeSM);
    line-height: var(--lineHeightSM);
}

/* The chip's remove control: a 12px CloseOutlined slot, not a Default button. */
:where(main) .select.multiple :where(span).tag > button {
    width: var(--fontSizeSM);
    height: var(--fontSizeSM);
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--colorTextDescription);
    font-size: var(--fontSizeSM);
    line-height: 1;
}

/* A consumer glyph fills the 12px slot rather than the Button's 16px. */
:where(main) .select.multiple :where(span).tag > button > :where(svg, img) {
    width: 100%;
    height: 100%;
}

:where(main) .select.multiple :where(span).tag > button:hover:not(:disabled) {
    background: none;
    color: var(--colorText);
}

:where(main) .select.multiple[aria-disabled="true"] :where(span).tag,
:where(main) .select.multiple[aria-disabled="true"] :where(span).tag > button {
    background: var(--colorFillDisabled);
    color: var(--colorTextDisabled);
}

/* Tabs — Figma "Clark Connect Design System", Tab / Color (node 634:30366), "use for page level
   tabs". <div class="tabs" role="tablist"> of <button role="tab" aria-selected>. Card-style: each
   tab is a top-rounded box bordered on three sides; the selected one takes a 2px top bar, its
   Color's fill and semi-bold text. Colour words compose on the tab (processing, danger, success,
   warning, neutral); sizes on the list (sm, lg). No bottom rule: the table or card below the
   strip supplies it. `.tabs > button` weighs (0,1,1), so it beats the bare button rules. */
:where(main) .tabs {
    display: flex;
    align-items: flex-end;
    /* No Figma value for the strip gutter; AntD card tabs use 2px. */
    gap: calc(var(--spacingXXS) / 2);
}

:where(main) .tabs > button {
    height: auto;
    /* Figma's inside strokes overlap its 8px/16px padding; CSS borders add to it, hence the -1px. */
    padding: calc(var(--spacingXS) - 1px) calc(var(--spacingMD) - 1px) var(--spacingXS);
    background: var(--colorFill);
    border: solid var(--colorBorder);
    border-width: 1px 1px 0;
    border-radius: var(--borderRadius) var(--borderRadius) 0 0;
    color: var(--colorText);
}

:where(main) .tabs.sm > button {
    padding: calc(var(--spacingXXS) - 1px) calc(var(--spacingSM) - 1px) var(--spacingXXS);
}

:where(main) .tabs.lg > button {
    font-size: var(--fontSizeLG);
    line-height: var(--lineHeightLG);
}

/* Hover/pressed/disabled have no Figma state; they borrow the Default button's inks. */
:where(main) .tabs > button:where(:not(:disabled):hover) {
    color: var(--colorPrimaryHover);
}

:where(main) .tabs > button:where(:not(:disabled):active) {
    color: var(--colorPrimaryActive);
}

:where(main) .tabs > button:where(:disabled) {
    color: var(--colorTextDisabled);
    cursor: not-allowed;
}

/* Top border plus a 1px inset shadow make Figma's 2px bar, clipped to the 6px corners as Figma clips it. */
:where(main) .tabs > button[aria-selected="true"] {
    border-top-color: var(--colorInfo);
    box-shadow: inset 0 1px 0 var(--colorInfo);
    color: var(--colorText);
    font-weight: var(--fontWeightStrong);
}

:where(main) .tabs > button.processing[aria-selected="true"] {
    background: var(--colorInfoBg);
}

:where(main) .tabs > button.danger[aria-selected="true"] {
    background: var(--colorDangerBg);
    border-top-color: var(--colorDanger);
    box-shadow: inset 0 1px 0 var(--colorDanger);
}

:where(main) .tabs > button.success[aria-selected="true"] {
    background: var(--colorSuccessBg);
    border-top-color: var(--colorSuccess);
    box-shadow: inset 0 1px 0 var(--colorSuccess);
}

/* Figma's Yellow tab draws a lighter yellow; the warning ramp stands in so no second yellow token exists. */
:where(main) .tabs > button.warning[aria-selected="true"] {
    background: var(--colorWarningBg);
    border-top-color: var(--colorWarning);
    box-shadow: inset 0 1px 0 var(--colorWarning);
}

:where(main) .tabs > button.neutral[aria-selected="true"] {
    background: var(--colorFillSecondary);
    border-top-color: var(--colorBorderHover);
    box-shadow: inset 0 1px 0 var(--colorBorderHover);
}

/* Floating overlays — Figma "Clark Connect Design System", Popover (node 411:0), Tooltip / Basic
   (node 413:13162), Popconfirm (node 422:13986) and Notification (node 422:13716). Opt-in classes on
   a generic container: .popover (role="dialog"), .popover.popconfirm (role="alertdialog", compose
   .danger for the red variant), .tooltip (role="tooltip"), .notification with .info/.success/
   .warning/.danger (role="status" or "alert"). Opening, closing and positioning against the trigger
   are the consumer's — Figma places the panel 4px from the trigger plus the 8px arrow. The arrow is
   the panel's ::before, drawn only when a data-placement is set. Glyphs (status icons, close x) are
   the consumer's inline <svg>, coloured through currentColor. */

/* border/overflow clear the UA [popover] defaults (a solid border; overflow:auto would clip the
   arrow) for a consumer using the native popover attribute. isolation keeps the z-index:-1 arrow
   above the panel's own fill but inside the panel, not behind an ancestor's background. */
:where(main) .popover,
:where(main) .tooltip {
    /* Figma Components/Tooltip/sizePopupArrow: the arrow's visible base; the height is half of it. */
    --arrow: 16px;
    position: relative;
    isolation: isolate;
    box-sizing: border-box;
    overflow: visible;
    border: none;
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
}

/* filter, not box-shadow, so the arrow shares the panel's shadow silhouette as Figma draws it. */
:where(main) .popover {
    padding: var(--spacingSM) var(--spacingMD);
    background: var(--colorFill);
    border-radius: var(--borderRadiusLG);
    color: var(--colorText);
    filter: var(--shadowElevationFilter);
}

/* Title bar and footer bleed to the panel edge over its padding. Put the title text directly in the
   <header>: an <h5> would bring the 16px heading scale, Figma's title is 14px strong. */
:where(main) .popover > header {
    margin: calc(-1 * var(--spacingSM)) calc(-1 * var(--spacingMD)) var(--spacingSM);
    padding: var(--spacingXS) var(--spacingMD);
    border-bottom: 1px solid var(--colorBorderSecondary);
    font-weight: var(--fontWeightStrong);
}

:where(main) .popover > footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacingXS);
    margin: var(--spacingSM) calc(-1 * var(--spacingMD)) calc(-1 * var(--spacingSM));
    padding: var(--spacingXS) var(--spacingMD);
    border-top: 1px solid var(--colorBorderSecondary);
}

/* Figma's dark tooltip chip draws no shadow. */
:where(main) .tooltip {
    padding: var(--spacingXXS) var(--spacingXS);
    background: var(--colorBgSpotlight);
    border-radius: var(--borderRadius);
    color: var(--colorTextLight);
}

/* Arrow — a square rotated 45deg whose diagonal is the 16px base, centred on the panel edge so 8px
   shows. Placement has no ARIA or native state, so data-placement drives it, in the Floating UI /
   AntD vocabulary (the side of the TRIGGER the panel sits on: "top" puts the arrow on the panel's
   bottom edge). z-index -1 keeps its inner half under the panel's text. */
:where(main) :is(.popover, .tooltip)[data-placement]::before {
    content: "";
    position: absolute;
    z-index: -1;
    width: calc(var(--arrow) / 1.4142);
    height: calc(var(--arrow) / 1.4142);
    background: inherit;
    transform: rotate(45deg);
}

/* Sides — each rounds the one corner the rotation points outward (Figma's arrow tip is rounded). */
:where(main) :is(.popover, .tooltip)[data-placement^="top"]::before {
    bottom: calc(var(--arrow) / -2.8284);
    border-bottom-right-radius: var(--borderRadiusXS);
}

:where(main) :is(.popover, .tooltip)[data-placement^="bottom"]::before {
    top: calc(var(--arrow) / -2.8284);
    border-top-left-radius: var(--borderRadiusXS);
}

:where(main) :is(.popover, .tooltip)[data-placement^="left"]::before {
    right: calc(var(--arrow) / -2.8284);
    border-top-right-radius: var(--borderRadiusXS);
}

:where(main) :is(.popover, .tooltip)[data-placement^="right"]::before {
    left: calc(var(--arrow) / -2.8284);
    border-bottom-left-radius: var(--borderRadiusXS);
}

/* Alignments — centred, or the arrow's centre 24px in from the start/end edge (Figma: 16px + half
   the base); horizontal on top/bottom panels, vertical on left/right ones. */
:where(main) :is(.popover, .tooltip):is([data-placement="top"], [data-placement="bottom"])::before {
    left: calc(50% - var(--arrow) / 2.8284);
}

:where(main) :is(.popover, .tooltip):is([data-placement="top-start"], [data-placement="bottom-start"])::before {
    left: calc(var(--spacingLG) - var(--arrow) / 2.8284);
}

:where(main) :is(.popover, .tooltip):is([data-placement="top-end"], [data-placement="bottom-end"])::before {
    right: calc(var(--spacingLG) - var(--arrow) / 2.8284);
}

:where(main) :is(.popover, .tooltip):is([data-placement="left"], [data-placement="right"])::before {
    top: calc(50% - var(--arrow) / 2.8284);
}

:where(main) :is(.popover, .tooltip):is([data-placement="left-start"], [data-placement="right-start"])::before {
    top: calc(var(--spacingLG) - var(--arrow) / 2.8284);
}

:where(main) :is(.popover, .tooltip):is([data-placement="left-end"], [data-placement="right-end"])::before {
    bottom: calc(var(--spacingLG) - var(--arrow) / 2.8284);
}

/* Popconfirm — a .popover holding an icon <svg>, the question <p> and a <footer> with two buttons
   (.default.sm + .primary.sm; .primary.danger.sm with .danger). */
:where(main) .popconfirm {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--spacingSM) var(--spacingXS);
}

/* Centres the 16px glyph on the first 22px text line. */
:where(main) .popconfirm > svg {
    width: var(--controlIconSize);
    height: var(--controlIconSize);
    margin-top: calc((var(--lineHeight) - var(--controlIconSize)) / 2);
    color: var(--colorWarning);
}

:where(main) .popconfirm.danger > svg {
    color: var(--colorDanger);
}

/* Figma keeps the popconfirm's buttons inside the content, not in a bled footer bar. */
:where(main) .popconfirm > footer {
    grid-column: 1 / -1;
    justify-self: end;
    margin: 0;
    padding: 0;
    border-top: none;
}

/* Notification — icon <svg> (typed variants only) beside one wrapper <div> holding a <header> (title
   text + close <button>), an optional description <p> and an optional <footer> of .sm buttons. */
:where(main) .notification {
    display: flex;
    align-items: flex-start;
    gap: var(--spacingMD);
    box-sizing: border-box;
    /* Figma's panel width (the 400px frame less its 24px screen margin); no Figma variable. */
    width: 376px;
    max-width: 100%;
    padding: var(--spacingMD) var(--spacingLG);
    background: var(--colorFill);
    border-radius: var(--borderRadiusLG);
    box-shadow: var(--shadowElevation);
    color: var(--colorText);
}

:where(main) .notification > svg {
    flex: none;
    width: var(--controlIconSizeLG);
    height: var(--controlIconSizeLG);
}

:where(main) .notification.info > svg {
    color: var(--colorInfo);
}

:where(main) .notification.success > svg {
    color: var(--colorSuccess);
}

:where(main) .notification.warning > svg {
    color: var(--colorWarning);
}

:where(main) .notification.danger > svg {
    color: var(--colorDanger);
}

:where(main) .notification > div {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--spacingXXS);
    min-width: 0;
}

:where(main) .notification > div > header {
    display: flex;
    align-items: center;
    gap: var(--spacingXXS);
    font: var(--fontWeightRegular) var(--fontSizeLG) / var(--lineHeightLG) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    overflow-wrap: anywhere;
}

/* A bare 14px glyph button, so it undoes the base button box; the base focus ring still applies. */
:where(main) .notification > div > header > button {
    flex: none;
    width: var(--controlIconSizeSM);
    height: var(--controlIconSizeSM);
    margin-inline-start: auto;
    padding: 0;
    background: none;
    border: none;
    color: var(--colorTextPlaceholder);
}

:where(main) .notification > div > header > button > :where(svg, img) {
    width: 100%;
    height: 100%;
}

:where(main) .notification > div > header > button:hover {
    background: none;
    color: var(--colorText);
}

:where(main) .notification > div > footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacingXS);
    padding-top: var(--spacingSM);
}

/* Modal — Figma "Clark Connect Design System", Modal / Basic (node 422:13512), Modal / Footer
   (node 9304:43848), Modal / Information (node 422:13525) and Modal / With Overlay (node 422:13456).
   The hook is a native <dialog class="modal"> opened with showModal(): focus trap, inert page,
   Escape and the ::backdrop mask come from the platform. Direct children (or children of one
   direct-child <form method="dialog">) are the parts: <header> (a heading plus an optional close
   <button>), one body element, and <footer> (Default/Primary buttons, an optional left-content
   element first). An empty close <button> draws Figma's CloseOutlined glyph. Width is the local
   --modal-width; widen one dialog with style="--modal-width: 720px". Compose .info/.success/
   .warning/.danger for the Information layout: 400px, status icon beside the title, no dividers. */

:where(main) :where(dialog).modal {
    /* Figma's raw frame sizes (no variables): Basic width, max height, and AntD's 100px top offset. */
    --modal-width: 520px;
    --modal-max-height: 720px;
    --modal-offset-top: 100px;
    box-sizing: border-box;
    width: var(--modal-width);
    max-width: calc(100vw - 2 * var(--spacingMD));
    max-height: min(var(--modal-max-height), calc(100vh - var(--modal-offset-top) - var(--spacingMD)));
    /* Figma pins the modal 100px from the top rather than centring it vertically. */
    margin: var(--modal-offset-top) auto auto;
    padding: 0;
    background: var(--colorFill);
    border: none;
    border-radius: var(--borderRadiusLG);
    box-shadow: var(--shadowElevation);
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    overflow: hidden;
}

/* Author display beats the UA's dialog:not([open]) { display: none }, so layout is gated on [open]. */
:where(main) :where(dialog[open]).modal {
    display: flex;
    flex-direction: column;
}

/* showModal() focuses the dialog box itself in Chromium; it is a container, not a control, and Figma draws no ring on it. */
:where(main) :where(dialog).modal:focus {
    outline: none;
}

:where(main) :where(dialog).modal::backdrop {
    background: var(--colorBgMask);
}

/* A <form method="dialog"> wrapper must not become a box between the dialog and its parts. */
:where(main) :where(dialog).modal :where(dialog > form) {
    display: contents;
}

:where(main) :where(dialog).modal :where(dialog > header, dialog > form > header) {
    display: flex;
    align-items: center;
    gap: var(--spacingMD);
    padding: var(--spacingMD) var(--spacingLG);
    border-bottom: 1px solid var(--colorBorderSecondary);
}

/* The title renders as H5 whatever heading level the page outline needs. */
:where(main) :where(dialog).modal :where(dialog > header, dialog > form > header) > :where(h1, h2, h3, h4, h5, h6) {
    flex: 1 1 auto;
    margin: 0;
    font: var(--fontWeightStrong) var(--fontSizeHeading5) / var(--lineHeightLG) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    color: var(--colorText);
}

/* Close — Figma draws a bare 14px Components/Modal/colorIcon glyph, not a Button instance; the 22px
   box is the link-icon square, pulled 4px right so the glyph keeps Figma's 24px inset. */
:where(main) :where(dialog).modal :where(dialog > header, dialog > form > header) > :where(button) {
    flex: none;
    width: var(--lineHeight);
    height: var(--lineHeight);
    margin-inline-end: calc(-1 * var(--spacingXXS));
    padding: 0;
    background: transparent;
    border: none;
    color: var(--colorTextPlaceholder);
}

:where(main) :where(dialog).modal :where(dialog > header, dialog > form > header) > :where(button):hover {
    background: transparent;
    color: var(--colorText);
}

:where(main) :where(dialog).modal :where(dialog > header, dialog > form > header) > :where(button) > :where(svg, img) {
    width: var(--controlIconSizeSM);
    height: var(--controlIconSizeSM);
}

:where(main) :where(dialog).modal :where(dialog > header, dialog > form > header) > :where(button:empty)::before {
    content: "";
    width: var(--fontSize);
    height: var(--fontSize);
    background-color: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896'%3E%3Cpath d='M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Body — the one element between header and footer; it scrolls so the head and footer stay pinned. */
:where(main) :where(dialog).modal :where(dialog > :not(header, footer, form), dialog > form > :not(header, footer)) {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: var(--spacingLG);
}

:where(main) :where(dialog).modal :where(dialog > footer, dialog > form > footer) {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--spacingSM);
    padding: var(--spacingMD);
    border-top: 1px solid var(--colorBorderSecondary);
}

/* Figma's Left Content slot: fills the row and sits 16px from the button group (buttons are 12px apart). */
:where(main) :where(dialog).modal :where(dialog > footer, dialog > form > footer) > :where(:not(button, a)) {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: var(--spacingMD);
    margin-inline-end: calc(var(--spacingMD) - var(--spacingSM));
}

/* Information — an icon column beside a text column; the parts drop their dividers and padding. */
:where(main) :where(dialog).modal:where(.info, .success, .warning, .danger) {
    --modal-width: 400px;
    padding: var(--spacingXL) var(--spacingXL) var(--spacingLG);
}

:where(main) :where(dialog[open]).modal:where(.info, .success, .warning, .danger) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-content: start;
    gap: var(--spacingXS) var(--spacingMD);
}

/* The status glyph IS the variant, so the base draws it (a mask over currentColor); the status word picks glyph and colour. */
:where(main) :where(dialog).modal:where(.info, .success, .warning, .danger)::before {
    content: "";
    grid-row: 1 / span 3;
    width: var(--lineHeightLG);
    height: var(--lineHeightLG);
    background-color: currentColor;
    mask-position: center;
    mask-size: contain;
    mask-repeat: no-repeat;
}

:where(main) :where(dialog).modal:where(.info, .success, .warning, .danger) :where(dialog > *, dialog > form > *) {
    grid-column: 2;
}

:where(main) :where(dialog).modal:where(.info, .success, .warning, .danger) :where(dialog > header, dialog > form > header) {
    padding: 0;
    border-bottom: none;
}

:where(main) :where(dialog).modal:where(.info, .success, .warning, .danger) :where(dialog > :not(header, footer, form), dialog > form > :not(header, footer)) {
    padding: 0;
}

/* Figma's Buttons row carries 16px top padding on top of the 8px text gap. */
:where(main) :where(dialog).modal:where(.info, .success, .warning, .danger) :where(dialog > footer, dialog > form > footer) {
    padding: var(--spacingMD) 0 0;
    border-top: none;
}

/* Glyphs are AntD's *CircleFilled icons (Figma Icon / InfoCircleFilled etc.); colours bind Components/Modal/color{Info,Success,Warning,Danger}. */
:where(main) :where(dialog).modal.info::before {
    color: var(--colorInfo);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896'%3E%3Cpath d='M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z'/%3E%3C/svg%3E");
}

:where(main) :where(dialog).modal.success::before {
    color: var(--colorSuccess);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896'%3E%3Cpath d='M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z'/%3E%3C/svg%3E");
}

:where(main) :where(dialog).modal.warning::before {
    color: var(--colorWarning);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896'%3E%3Cpath d='M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z'/%3E%3C/svg%3E");
}

:where(main) :where(dialog).modal.danger::before {
    color: var(--colorDanger);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='64 64 896 896'%3E%3Cpath d='M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z'/%3E%3C/svg%3E");
}

/* Progress — Figma "Clark Connect Design System", Progress / Standard (node 2210:61699). The native
   <progress> is the hook, so an un-classed one renders as Size=Default Status=Normal; compose .sm,
   .success/.danger and .square (strokeLinecap=Square; Round is the default). The bar paints in
   currentColor, so a status only swaps `color`. An adjacent <output> is the percentage label (or the
   consumer's 16px status icon). Figma draws no Active status and no indeterminate state. */
:where(main) progress {
    /* Figma's raw stroke-width (8px, 6px at Small); no variable. */
    --track: 8px;
    appearance: none;
    box-sizing: border-box;
    height: var(--track);
    vertical-align: middle;
    background: var(--colorBorderSecondary);
    border: 0;
    border-radius: var(--borderRadiusRound);
    color: var(--colorInfo);
}

/* Each engine's pseudo-element needs its own rule: an unknown one in a selector list drops the whole list. */
:where(main) progress::-webkit-progress-bar {
    background: var(--colorBorderSecondary);
    border-radius: inherit;
}

:where(main) progress::-webkit-progress-value {
    background: currentColor;
    border-radius: inherit;
}

:where(main) progress::-moz-progress-bar {
    background: currentColor;
    border-radius: inherit;
}

:where(main) :where(progress).sm {
    --track: 6px;
}

:where(main) :where(progress).success {
    color: var(--colorSuccess);
}

:where(main) :where(progress).danger {
    color: var(--colorDanger);
}

:where(main) :where(progress).square {
    border-radius: 0;
}

:where(main) :where(progress) + output {
    margin-inline-start: var(--spacingSM);
    vertical-align: middle;
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
}

:where(main) :where(progress.success) + output {
    color: var(--colorSuccess);
}

:where(main) :where(progress.danger) + output {
    color: var(--colorDanger);
}

/* Progress circle — Figma Progress / Circle (node 422:14630). <progress> cannot be a ring, so this is a
   <div role="progressbar" aria-valuenow="40" style="--value: 40">; --value (0-100, unitless) is the one
   input and must match aria-valuenow. The ring is a conic-gradient masked to the stroke on ::before, the
   Round linecap two stroke-sized dots (start on ::before, end on ::after rotated to the value). The
   centre is the consumer's text or glyph. Figma's Custom size = override --size and --stroke. */
:where(main) :where(div, span).progress.circle {
    --value: 0;
    --bar: var(--colorInfo);
    /* Figma's raw diameter and stroke-width (120/6, 80/4 at Small); no variables. */
    --size: 120px;
    --stroke: 6px;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: var(--size);
    height: var(--size);
    border-radius: var(--borderRadiusRound);
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSizeHeading3) / var(--lineHeightHeading3) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
}

:where(main) :where(div, span).progress.circle::before,
:where(main) :where(div, span).progress.circle::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
}

:where(main) :where(div, span).progress.circle::before {
    background:
        radial-gradient(circle calc(var(--stroke) / 2) at 50% calc(var(--stroke) / 2), var(--bar) 95%, transparent),
        conic-gradient(var(--bar) calc(var(--value) * 1%), var(--colorBorderSecondary) 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--stroke) - 0.5px), var(--colorBlack) calc(100% - var(--stroke)));
    mask: radial-gradient(farthest-side, transparent calc(100% - var(--stroke) - 0.5px), var(--colorBlack) calc(100% - var(--stroke)));
}

:where(main) :where(div, span).progress.circle::after {
    background: radial-gradient(circle calc(var(--stroke) / 2) at 50% calc(var(--stroke) / 2), var(--bar) 95%, transparent);
    transform: rotate(calc(var(--value) * 3.6deg));
}

:where(main) :where(div, span).progress.circle.sm {
    --size: 80px;
    --stroke: 4px;
    font-size: var(--fontSizeLG);
    line-height: var(--lineHeightLG);
}

/* Status recolours the centre too: Figma swaps the percentage for a status-coloured check / cross. */
:where(main) :where(div, span).progress.circle.success {
    --bar: var(--colorSuccess);
    color: var(--colorSuccess);
}

:where(main) :where(div, span).progress.circle.danger {
    --bar: var(--colorDanger);
    color: var(--colorDanger);
}

:where(main) :where(div, span).progress.circle.square::before {
    background: conic-gradient(var(--bar) calc(var(--value) * 1%), var(--colorBorderSecondary) 0);
}

:where(main) :where(div, span).progress.circle.square::after {
    content: none;
}

/* Upload — Figma Upload (node 5454:25179), the drag-and-drop zone. A <label class="upload"> wrapping an
   <input type="file">, the consumer's icon <svg>, the title text and a <small> hint. The input is
   stretched invisibly over the zone, so click and drop both land on it natively. Dragging has no ARIA or
   native state: the consumer toggles [data-dragging] on dragenter/dragleave. Error is .danger or an
   aria-invalid input. */
:where(main) :where(label, div).upload {
    position: relative;
    display: block;
    box-sizing: border-box;
    padding: var(--spacingMD);
    background: var(--colorFillSecondary);
    border: 1px dashed var(--colorBorder);
    border-radius: var(--borderRadiusLG);
    color: var(--colorText);
    font: var(--fontWeightRegular) var(--fontSizeLG) / var(--lineHeightLG) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    text-align: center;
    cursor: pointer;
}

:where(main) .upload > input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: inherit;
}

:where(main) .upload > svg {
    display: block;
    width: var(--controlIconSizeXL);
    height: var(--controlIconSizeXL);
    margin: 0 auto var(--spacingMD);
    color: var(--colorPrimary);
    fill: currentColor;
}

:where(main) .upload > small {
    display: block;
    margin-top: var(--spacingXXS);
    color: var(--colorTextDescription);
    font-size: var(--fontSize);
    line-height: var(--lineHeight);
}

/* Figma draws Dragging with Hovered's border; the file chips beside the cursor are the OS drag image. */
:where(main) :where(label, div).upload:hover,
:where(main) :where(label, div).upload[data-dragging] {
    border-color: var(--colorPrimaryHover);
}

:where(main) :where(label, div).upload:has(> input:focus-visible) {
    outline: 3px solid var(--colorLinkActive);
    outline-offset: 2px;
}

:where(main) :where(label, div).upload.danger,
:where(main) :where(label, div).upload:has(> input[aria-invalid="true"]) {
    border-color: var(--colorDanger);
}

:where(main) .upload.danger > svg,
:where(main) .upload:has(> input[aria-invalid="true"]) > svg {
    color: var(--colorDanger);
}

/* No Figma Disabled state: keep the rest border and drop the pointer. */
:where(main) :where(label, div).upload:has(> input:disabled) {
    border-color: var(--colorBorder);
    cursor: not-allowed;
}

/* Upload list item — Figma Upload List Item (node 397:12041). An <li class="upload-item"> holding the
   consumer's 16px icon <svg> (paperclip, or the spinner while busy), the name in a <span> or <a>, and an
   icon-only remove <button>; a <progress> child wraps onto its own line under the row. Compose .card
   (bordered row with a 32px <img> thumbnail) and .danger (Error); aria-busy="true" is Loading. */
:where(main) :where(li, div).upload-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacingXXS) var(--spacingXS);
    color: var(--colorTextDescription);
    font: var(--fontWeightRegular) var(--fontSize) / var(--lineHeight) var(--fontFamily);
    font-variation-settings: var(--fontVariationSettings);
    list-style: none;
}

:where(main) .upload-item > svg {
    flex: none;
    width: var(--controlIconSize);
    height: var(--controlIconSize);
    fill: currentColor;
}

:where(main) .upload-item > img {
    flex: none;
    box-sizing: border-box;
    width: var(--controlHeight);
    height: var(--controlHeight);
    border: 1px solid var(--colorBorder);
    border-radius: var(--borderRadius);
    object-fit: cover;
}

:where(main) .upload-item > :where(span, a) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: var(--colorPrimary);
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A square of the text line, like the icon-only Link; outweighs the bare Default button look. Hidden
   with opacity, not visibility, so it stays keyboard-reachable. */
:where(main) .upload-item > button {
    flex: none;
    width: var(--lineHeight);
    height: var(--lineHeight);
    padding: 0;
    background: transparent;
    border: none;
    color: var(--colorDanger);
    opacity: 0;
}

:where(main) .upload-item:hover > button,
:where(main) .upload-item > button:focus-visible,
:where(main) .upload-item.danger > button,
:where(main) .upload-item.card > button {
    opacity: 1;
}

@media (hover: none) {
    :where(main) .upload-item > button {
        opacity: 1;
    }
}

/* Figma's raw 2px Load Bar. */
:where(main) .upload-item > progress {
    --track: 2px;
    flex-basis: 100%;
    background: var(--colorTextDisabled);
    color: var(--colorPrimary);
}

:where(main) .upload-item > progress::-webkit-progress-bar {
    background: var(--colorTextDisabled);
}

:where(main) :where(li, div).upload-item.card {
    padding: var(--spacingXS) var(--spacingMD);
    background: var(--colorFill);
    border: 1px solid var(--colorBorder);
    border-radius: var(--borderRadius);
}

/* Figma's busy Card swaps the thumbnail for a 32px spinner. */
:where(main) .upload-item.card[aria-busy="true"] > svg {
    width: var(--controlHeight);
    height: var(--controlHeight);
}

:where(main) :where(li, div).upload-item:hover {
    background: var(--colorFillSecondary);
}

:where(main) .upload-item:hover > :where(span, a) {
    color: var(--colorPrimaryHover);
}

:where(main) :where(li, div).upload-item.danger,
:where(main) .upload-item.danger > :where(span, a) {
    color: var(--colorDanger);
}
