/*
 * Unlimited Sourcing — UI kit (design tokens + components).
 *
 * Everything lives under a `.us-ui` root, so nothing leaks into the theme.
 *
 * Conflict policy (WordPress / Elementor / Hello Elementor):
 *  - Base element normalisation uses `.us-ui.us-ui el` (0,2,1): beats theme
 *    element rules and Elementor kit `.elementor-kit-N el` (0,1,1).
 *  - Components use `.us-ui:not(#_) .us-x` (1,2,0): the `:not(#_)` adds ID
 *    weight without needing an id, so kit form rules like
 *    `.elementor-kit-N input:not([type=button]):not([type=submit])` (0,3,1)
 *    can never restyle our controls — no !important required.
 */

/* ------------------------------------------------------------------ */
/* Tokens                                                              */
/* ------------------------------------------------------------------ */

.us-ui {
    --us-font: "Sahel", "Vazirmatn", "Vazir", Tahoma, sans-serif;

    /* Brand (docs/DESIGN.md §3): primary blue, secondary orange. */
    --us-primary: #0f3bd1;
    --us-primary-600: #1445ee; /* hover fill */
    --us-primary-active: #0d32b2; /* pressed fill */
    --us-primary-700: #0c2fa7; /* emphasis text on tints */
    --us-primary-text: #0f3bd1; /* links, inlined / outlined labels */
    --us-primary-focus: #0f3bd1; /* keyboard focus ring */
    --us-primary-50: color-mix(in srgb, var(--us-primary-text) 8%, transparent);
    --us-primary-100: color-mix(in srgb, var(--us-primary-text) 12%, transparent);
    --us-primary-200: color-mix(in srgb, var(--us-primary-text) 24%, transparent);
    --us-on-primary: #ffffff;
    --us-accent: #ff8a00;
    --us-accent-text: #8a4a00; /* orange text on light surfaces */
    --us-accent-50: color-mix(in srgb, var(--us-accent) 8%, transparent);
    --us-on-accent: #212121; /* never white on orange */

    /* Neutrals (flip in dark theme, so surface = gray-0 and text = gray-900 keep working). */
    --us-gray-0: #ffffff;
    --us-gray-25: #fafafa;
    --us-gray-50: #f5f5f5;
    --us-gray-100: #f0f0f0;
    --us-gray-200: #e6e6e6;
    --us-gray-300: #c4c4c4;
    --us-gray-400: #adadad;
    --us-gray-500: #707070;
    --us-gray-600: #5c5c5c;
    --us-gray-700: #424242;
    --us-gray-800: #2b2b2b;
    --us-gray-900: #212121;

    /* Semantic: fills / dots use the base colour, text uses the -text colour (>= 4.5:1). */
    --us-success: #119229;
    --us-success-text: #106520;
    --us-success-50: color-mix(in srgb, var(--us-success) 8%, transparent);
    --us-warning: #ec6a13;
    --us-warning-text: #c05711;
    --us-warning-50: color-mix(in srgb, var(--us-warning) 8%, transparent);
    --us-danger: #ec1313;
    --us-danger-text: #c01111;
    --us-danger-50: color-mix(in srgb, var(--us-danger) 8%, transparent);
    --us-info: #116fc0;

    --us-text: var(--us-gray-900);
    --us-text-2: var(--us-gray-500);
    --us-text-3: var(--us-gray-500);
    --us-hint: #8f8f8f; /* placeholder only */
    --us-surface: #ffffff;
    --us-canvas: #ffffff;
    --us-tile: #fafafa; /* container fill: sidebar, stat tiles, alerts, summary */
    --us-field: rgba(0, 0, 0, 0.04); /* filled text field */
    --us-field-h: rgba(0, 0, 0, 0.08);
    --us-hover: rgba(0, 0, 0, 0.04);
    --us-pressed: rgba(0, 0, 0, 0.12);
    --us-divider: rgba(0, 0, 0, 0.08);
    --us-border: var(--us-divider);

    /* Radius preset B: controls 8, containers 12, small parts 4. */
    --us-r-xs: 4px;
    --us-r-sm: 8px;
    --us-r-md: 8px;
    --us-r-lg: 12px;
    --us-r-xl: 16px;
    --us-r-2xl: 16px;
    --us-r-pill: 1024px;

    /* Quiet UI: no shadows on surfaces; only overlays float. */
    --us-shadow-xs: none;
    --us-shadow-sm: none;
    --us-shadow-md: 0 1px 6px 0 rgba(0, 0, 0, 0.04), 0 -8px 32px -4px rgba(0, 0, 0, 0.08), 0 16px 24px -6px rgba(0, 0, 0, 0.04);
    --us-shadow-lg: 0 1px 32px 0 rgba(0, 0, 0, 0.08), 0 12px 16px 0 rgba(0, 0, 0, 0.12), 0 8px 12px -6px rgba(0, 0, 0, 0.16);
    --us-ring: 0 0 0 2px var(--us-surface), 0 0 0 4px var(--us-primary-focus);
    --us-ring-danger: 0 0 0 2px var(--us-surface), 0 0 0 4px var(--us-danger);

    --us-ease: ease;
    --us-ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
    --us-dur-1: 200ms;
    --us-dur-2: 360ms;
    --us-dur-3: 400ms;

    /* Type scale (Sonnat): caption 12 / bodySmall 14 / body 16 / h6 18 / h4 24. */
    --us-fs-xs: 12px;
    --us-fs-sm: 12px;
    --us-fs-base: 14px;
    --us-fs-md: 14px;
    --us-fs-lg: 16px;
    --us-fs-xl: 18px;
    --us-fs-2xl: 24px;

    /* Spacing (8-based). */
    --us-space-1: 4px;
    --us-space-2: 8px;
    --us-space-3: 12px;
    --us-space-4: 16px;
    --us-space-5: 24px;
    --us-space-6: 32px;
    --us-space-7: 48px;
    --us-space-8: 64px;

    --us-control-h: 40px;
    --us-control-h-sm: 32px;
    --us-control-h-lg: 48px;

    font-family: var(--us-font);
    font-size: var(--us-fs-base);
    line-height: 1.5714;
    color: var(--us-text);
    direction: rtl;
    text-align: right;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    font-feature-settings: "ss01";
}

/* Dark theme: Sonnat uses the .light brand variants and lifts surfaces instead of shadowing. */
.us-ui[data-theme="dark"],
[data-theme="dark"] .us-ui {
    --us-primary: #1e4def;
    --us-primary-600: #446bf2;
    --us-primary-active: #0f3cd5;
    --us-primary-700: #9db1f3;
    --us-primary-text: #6d8aee;
    --us-primary-focus: #6d8aee;
    --us-accent: #ffa133;
    --us-accent-text: #ffa133;

    --us-gray-0: #121212;
    --us-gray-25: #1c1c1c;
    --us-gray-50: #222222;
    --us-gray-100: #292929;
    --us-gray-200: #333333;
    --us-gray-300: #4a4a4a;
    --us-gray-400: #767676;
    --us-gray-500: #aaaaaa;
    --us-gray-600: #bdbdbd;
    --us-gray-700: #d6d6d6;
    --us-gray-800: #ebebeb;
    --us-gray-900: #ffffff;

    --us-success: #11c031;
    --us-success-text: #11c031;
    --us-warning: #ee853f;
    --us-warning-text: #ee853f;
    --us-danger: #ee3f3f;
    --us-danger-text: #ee3f3f;
    --us-info: #1387ec;

    --us-hint: #8a8a8a;
    --us-surface: #121212;
    --us-canvas: #121212;
    --us-tile: #292929;
    --us-field: rgba(255, 255, 255, 0.06);
    --us-field-h: rgba(255, 255, 255, 0.1);
    --us-hover: rgba(255, 255, 255, 0.04);
    --us-pressed: rgba(255, 255, 255, 0.12);
    --us-divider: rgba(255, 255, 255, 0.16);

    --us-shadow-md: 0 4px 4px -4px rgba(0, 0, 0, 0.12), 0 8px 10px 1px rgba(0, 0, 0, 0.08), 0 4px 8px 2px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.12);
    --us-shadow-lg: var(--us-shadow-md);
    color-scheme: dark;
}

@media (pointer: coarse) {
    .us-ui {
        --us-control-h: 46px;
        --us-control-h-sm: 38px;
        --us-control-h-lg: 50px;
    }
}

/* ------------------------------------------------------------------ */
/* Base normalisation (beats theme + Elementor kit element rules)      */
/* Skipped when a theme puts .us-ui on <body> (Rava): it styles its  */
/* own content and only borrows the tokens and components.             */
/* ------------------------------------------------------------------ */

.us-ui.us-ui *,
.us-ui.us-ui *::before,
.us-ui.us-ui *::after {
    box-sizing: border-box;
}

.us-ui.us-ui:not(body) :is(h1, h2, h3, h4, h5, h6) {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-weight: 500;
    line-height: 1.6;
    letter-spacing: 0;
    text-transform: none;
    color: inherit;
}

.us-ui.us-ui:not(body) :is(p, dl, dd, figure, blockquote) {
    margin: 0;
}

.us-ui.us-ui:not(body) :is(ul, ol) {
    margin: 0;
    padding: 0;
    list-style: none;
}

.us-ui.us-ui:not(body) label {
    display: inline;
    line-height: inherit;
    vertical-align: baseline;
    font-weight: inherit;
    color: inherit;
    margin: 0;
}

.us-ui.us-ui:not(body) :is(a, a:hover, a:focus, a:visited) {
    color: inherit;
    text-decoration: none;
    box-shadow: none;
}

.us-ui.us-ui:not(body) :is(img, svg) {
    max-width: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    vertical-align: middle;
}

.us-ui.us-ui:not(body) :is(button, input, select, textarea) {
    font-family: inherit;
    letter-spacing: 0;
    text-transform: none;
}

.us-ui.us-ui:not(body) small {
    font-size: inherit;
}

.us-ui.us-ui:not(body) :is(table, th, td) {
    border: 0;
    background: transparent;
}

.us-ui.us-ui [hidden] {
    display: none !important; /* [hidden] must always win. */
}

.us-ui.us-ui :focus-visible {
    outline: 2px solid var(--us-primary-focus);
    outline-offset: 2px;
}

.us-ui:not(#_) .us-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.us-ui:not(#_) .us-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.us-ui:not(#_) .us-ltr {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Overlay surface: white in light theme, lifted tile in dark theme. */
.us-ui:not(#_) {
    --us-overlay: var(--us-surface);
}

.us-ui[data-theme="dark"]:not(#_),
[data-theme="dark"] .us-ui:not(#_) {
    --us-overlay: var(--us-tile);
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

/* Default = outlined: 1px border at 56% primary, text-only tint on hover / active. */
.us-ui:not(#_) .us-btn {
    --_bg: transparent;
    --_fg: var(--us-primary-text);
    --_bd: color-mix(in srgb, var(--us-primary-text) 56%, transparent);
    --_bg-h: color-mix(in srgb, var(--us-primary-text) 4%, transparent);
    --_fg-h: var(--us-primary-text);
    --_bd-h: var(--us-primary-text);
    --_bg-a: color-mix(in srgb, var(--us-primary-text) 12%, transparent);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: var(--us-control-h);
    min-width: 0;
    margin: 0;
    padding: 0 16px;
    border: 1px solid var(--_bd);
    border-radius: var(--us-r-sm);
    background: var(--_bg);
    color: var(--_fg);
    font: inherit;
    font-size: var(--us-fs-base);
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    text-transform: none;
    cursor: pointer;
    box-shadow: none;
    transition: background-color var(--us-dur-1) ease, border-color var(--us-dur-1) ease, color var(--us-dur-1) ease, box-shadow var(--us-dur-1) ease;
    user-select: none;
    -webkit-user-select: none;
}

.us-ui:not(#_) .us-btn:hover {
    background: var(--_bg-h);
    color: var(--_fg-h);
    border-color: var(--_bd-h);
}

.us-ui:not(#_) .us-btn:active {
    background: var(--_bg-a);
}

.us-ui:not(#_) .us-btn:focus-visible {
    outline: none;
    box-shadow: var(--us-ring);
}

.us-ui:not(#_) .us-btn:disabled,
.us-ui:not(#_) .us-btn.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.us-ui:not(#_) .us-btn .us-icon {
    width: 18px;
    height: 18px;
}

/* Filled: the single high-emphasis action of a view. */
.us-ui:not(#_) :is(.us-btn--primary, .us-btn-primary) {
    --_bg: var(--us-primary);
    --_fg: var(--us-on-primary);
    --_bd: var(--us-primary);
    --_bg-h: var(--us-primary-600);
    --_fg-h: var(--us-on-primary);
    --_bd-h: var(--us-primary-600);
    --_bg-a: var(--us-primary-active);
}

.us-ui:not(#_) :is(.us-btn--primary, .us-btn-primary):active {
    border-color: var(--us-primary-active);
}

/* Secondary filled (orange): dark label, never white. */
.us-ui:not(#_) .us-btn--accent {
    --_bg: var(--us-accent);
    --_fg: var(--us-on-accent);
    --_bd: var(--us-accent);
    --_bg-h: color-mix(in srgb, var(--us-accent) 88%, var(--us-gray-0));
    --_fg-h: var(--us-on-accent);
    --_bd-h: transparent;
    --_bg-a: color-mix(in srgb, var(--us-accent) 84%, var(--us-gray-900));
}

/* Soft: text-only on a quiet tint. */
.us-ui:not(#_) .us-btn--soft {
    --_bg: var(--us-primary-50);
    --_fg: var(--us-primary-text);
    --_bd: transparent;
    --_bg-h: var(--us-primary-100);
    --_fg-h: var(--us-primary-text);
    --_bd-h: transparent;
    --_bg-a: var(--us-primary-200);
}

/* Inlined / ghost: text only. */
.us-ui:not(#_) :is(.us-btn--ghost, .us-btn-ghost) {
    --_bg: transparent;
    --_fg: var(--us-text-2);
    --_bd: transparent;
    --_bg-h: var(--us-hover);
    --_fg-h: var(--us-text);
    --_bd-h: transparent;
    --_bg-a: var(--us-pressed);
}

.us-ui:not(#_) .us-btn--danger {
    --_bg: transparent;
    --_fg: var(--us-danger-text);
    --_bd: color-mix(in srgb, var(--us-danger) 56%, transparent);
    --_bg-h: color-mix(in srgb, var(--us-danger) 4%, transparent);
    --_fg-h: var(--us-danger-text);
    --_bd-h: var(--us-danger);
    --_bg-a: color-mix(in srgb, var(--us-danger) 12%, transparent);
}

.us-ui:not(#_) .us-btn--link {
    --_bg: transparent;
    --_fg: var(--us-primary-text);
    --_bd: transparent;
    --_bg-h: transparent;
    --_fg-h: var(--us-primary-700);
    --_bd-h: transparent;
    --_bg-a: transparent;
    height: auto;
    padding: 0;
}

.us-ui:not(#_) :is(.us-btn--sm, .us-btn-sm) {
    height: var(--us-control-h-sm);
    padding: 0 12px;
    gap: 6px;
    font-size: var(--us-fs-sm);
    border-radius: var(--us-r-sm);
}

.us-ui:not(#_) .us-btn--lg {
    height: var(--us-control-h-lg);
    padding: 0 24px;
    font-size: var(--us-fs-lg);
    border-radius: var(--us-r-sm);
}

.us-ui:not(#_) .us-btn--block {
    display: flex;
    width: 100%;
}

.us-ui:not(#_) .us-btn--icon {
    width: var(--us-control-h);
    padding: 0;
}

.us-ui:not(#_) .us-btn--icon.us-btn--sm {
    width: var(--us-control-h-sm);
}

/* Legacy aliases used by widgets / shortcodes. */
.us-ui:not(#_) .us-btn-outline {
    --_bg: transparent;
}

/* Loading: keeps width, swaps content for a spinner. */
.us-ui:not(#_) .us-btn.is-loading {
    color: transparent;
    pointer-events: none;
}

.us-ui:not(#_) .us-btn.is-loading > * {
    visibility: hidden;
}

.us-ui:not(#_) .us-btn.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-color: var(--_fg) var(--_fg) var(--_fg) transparent;
    border-radius: 50%;
    animation: us-spin 0.7s linear infinite;
}

/* Icon-only button (toolbars, headers). */
.us-ui:not(#_) .us-iconbtn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--us-r-sm);
    background: transparent;
    color: var(--us-text-2);
    cursor: pointer;
    box-shadow: none;
    transition: background-color var(--us-dur-1) ease, color var(--us-dur-1) ease;
}

.us-ui:not(#_) .us-iconbtn:hover {
    background: var(--us-hover);
    color: var(--us-text);
}

.us-ui:not(#_) .us-iconbtn:active {
    background: var(--us-pressed);
}

.us-ui:not(#_) .us-iconbtn:focus-visible {
    outline: none;
    box-shadow: var(--us-ring);
}

.us-ui:not(#_) .us-iconbtn .us-icon {
    width: 20px;
    height: 20px;
}

.us-ui:not(#_) .us-iconbtn--danger:hover {
    background: var(--us-danger-50);
    color: var(--us-danger-text);
}

/* Counter bubble on icon buttons / nav items (primary, not orange). */
.us-ui:not(#_) .us-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--us-r-pill);
    background: var(--us-primary);
    color: var(--us-on-primary);
    font-size: var(--us-fs-xs);
    font-weight: 700;
    line-height: 1;
}

.us-ui:not(#_) .us-count.hidden,
.us-ui:not(#_) .us-count[data-count="0"] {
    display: none;
}

.us-ui:not(#_) .us-iconbtn > .us-count {
    position: absolute;
    top: 3px;
    inset-inline-end: 3px;
    box-shadow: 0 0 0 2px var(--us-surface);
}

/* ------------------------------------------------------------------ */
/* Form fields (filled type: tinted background, no border)             */
/* ------------------------------------------------------------------ */

.us-ui:not(#_) .us-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.us-ui:not(#_) .us-label {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: var(--us-fs-sm);
    font-weight: 500;
    color: var(--us-text-2);
    line-height: 1.67;
}

.us-ui:not(#_) .us-label .us-req {
    color: var(--us-danger-text);
}

.us-ui:not(#_) .us-label .us-opt {
    color: var(--us-hint);
    font-weight: 400;
    font-size: var(--us-fs-xs);
}

.us-ui:not(#_) .us-input {
    display: block;
    width: 100%;
    height: var(--us-control-h);
    min-height: 0;
    margin: 0;
    padding: 0 12px;
    border: 0;
    border-radius: var(--us-r-sm);
    background-color: var(--us-field);
    color: var(--us-text);
    font: inherit;
    font-size: var(--us-fs-base);
    font-weight: 400;
    line-height: 1.5;
    box-shadow: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: box-shadow var(--us-dur-1) ease, background-color var(--us-dur-1) ease;
}

.us-ui:not(#_) textarea.us-input {
    height: auto;
    min-height: 96px;
    padding: 10px 12px;
    line-height: 1.85;
    resize: vertical;
}

.us-ui:not(#_) select.us-input {
    padding-left: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23909090' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 10px center;
    background-size: 16px;
}

.us-ui:not(#_) .us-input::placeholder {
    color: var(--us-hint);
    opacity: 1;
}

.us-ui:not(#_) .us-input:hover {
    background-color: var(--us-field-h);
}

.us-ui:not(#_) .us-input:focus {
    box-shadow: var(--us-ring);
}

.us-ui:not(#_) .us-input:disabled,
.us-ui:not(#_) .us-input[readonly] {
    background-color: var(--us-field);
    color: var(--us-text-2);
    cursor: not-allowed;
}

.us-ui:not(#_) .us-input:disabled {
    opacity: 0.6;
}

.us-ui:not(#_) .us-field.has-error .us-input,
.us-ui:not(#_) .us-input.has-error {
    box-shadow: var(--us-ring-danger);
}

.us-ui:not(#_) .us-hint {
    font-size: var(--us-fs-xs);
    color: var(--us-text-2);
    line-height: 1.67;
}

.us-ui:not(#_) .us-error {
    font-size: var(--us-fs-xs);
    font-weight: 500;
    color: var(--us-danger-text);
    line-height: 1.67;
}

/* Input with an icon / affix. */
.us-ui:not(#_) .us-affix {
    position: relative;
    display: flex;
    align-items: center;
}

.us-ui:not(#_) .us-affix > .us-icon {
    position: absolute;
    inset-inline-start: 12px;
    width: 18px;
    height: 18px;
    color: var(--us-text-2);
    pointer-events: none;
}

.us-ui:not(#_) .us-affix > .us-icon ~ .us-input {
    padding-inline-start: 40px;
}

.us-ui:not(#_) .us-affix__end {
    position: absolute;
    inset-inline-end: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.us-ui:not(#_) .us-grid {
    display: grid;
    gap: 24px 16px;
}

.us-ui:not(#_) .us-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.us-ui:not(#_) .us-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.us-ui:not(#_) .us-span-2 {
    grid-column: 1 / -1;
}

@media (max-width: 640px) {
    .us-ui:not(#_) .us-grid--2,
    .us-ui:not(#_) .us-grid--3 {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Segmented control. */
.us-ui:not(#_) .us-segmented {
    display: inline-flex;
    padding: 4px;
    gap: 4px;
    border-radius: var(--us-r-sm);
    background: var(--us-field);
}

.us-ui:not(#_) .us-segmented > label {
    position: relative;
    cursor: pointer;
}

.us-ui:not(#_) .us-segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.us-ui:not(#_) .us-segmented span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 16px;
    border-radius: var(--us-r-xs);
    font-size: var(--us-fs-base);
    font-weight: 500;
    color: var(--us-text-2);
    transition: background-color var(--us-dur-2) var(--us-ease), color var(--us-dur-2) var(--us-ease), box-shadow var(--us-dur-2) var(--us-ease);
}

.us-ui:not(#_) .us-segmented > label:hover span {
    background: var(--us-hover);
}

.us-ui:not(#_) .us-segmented input:checked + span {
    background: var(--us-primary-50);
    color: var(--us-primary-text);
}

.us-ui:not(#_) .us-segmented input:focus-visible + span {
    box-shadow: var(--us-ring);
}

/* Selectable chip (checkbox). */
.us-ui:not(#_) .us-chip {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}

.us-ui:not(#_) .us-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.us-ui:not(#_) .us-chip span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--us-r-xs);
    background: var(--us-field);
    font-size: var(--us-fs-sm);
    font-weight: 400;
    color: var(--us-text);
    transition: background-color var(--us-dur-1) ease, color var(--us-dur-1) ease;
}

.us-ui:not(#_) .us-chip:hover span {
    background: var(--us-field-h);
}

.us-ui:not(#_) .us-chip input:checked + span {
    background: var(--us-primary-100);
    color: var(--us-primary-text);
}

.us-ui:not(#_) .us-chip input:focus-visible + span {
    box-shadow: var(--us-ring);
}

@media (pointer: coarse) {
    .us-ui:not(#_) .us-chip span {
        height: 40px;
    }
}

.us-ui:not(#_) .us-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.us-ui:not(#_) .us-chips:empty {
    display: none;
}

/* Choice card (radio): flat tile, tint when selected. */
.us-ui:not(#_) .us-choice {
    position: relative;
    display: block;
    cursor: pointer;
}

.us-ui:not(#_) .us-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.us-ui:not(#_) .us-choice__box {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 100%;
    padding: 16px;
    border: 0;
    border-radius: var(--us-r-lg);
    background: var(--us-tile);
    transition: background-color var(--us-dur-2) var(--us-ease), box-shadow var(--us-dur-2) var(--us-ease);
}

.us-ui:not(#_) .us-choice:hover .us-choice__box {
    background: var(--us-field);
}

.us-ui:not(#_) .us-choice__icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: var(--us-r-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--us-field);
    color: var(--us-text-2);
    transition: inherit;
}

.us-ui:not(#_) .us-choice__text strong {
    display: block;
    font-size: var(--us-fs-base);
    font-weight: 500;
}

.us-ui:not(#_) .us-choice__text small {
    display: block;
    font-size: var(--us-fs-xs);
    color: var(--us-text-2);
}

.us-ui:not(#_) .us-choice__check {
    width: 20px;
    height: 20px;
    margin-inline-start: auto;
    border: 1.5px solid var(--us-gray-400);
    border-radius: 50%;
    flex: 0 0 auto;
    transition: inherit;
}

.us-ui:not(#_) .us-choice input:checked + .us-choice__box {
    background: var(--us-primary-50);
}

.us-ui:not(#_) .us-choice input:checked + .us-choice__box .us-choice__icon {
    background: var(--us-primary-100);
    color: var(--us-primary-text);
}

.us-ui:not(#_) .us-choice input:checked + .us-choice__box .us-choice__check {
    border: 6px solid var(--us-primary);
}

.us-ui:not(#_) .us-choice input:focus-visible + .us-choice__box {
    box-shadow: var(--us-ring);
}

/* Quantity stepper (filled). */
.us-ui:not(#_) .us-qty {
    display: inline-flex;
    align-items: stretch;
    width: 100%;
    max-width: 220px;
    height: var(--us-control-h);
    border: 0;
    border-radius: var(--us-r-sm);
    background: var(--us-field);
    overflow: hidden;
    box-shadow: none;
    transition: box-shadow var(--us-dur-1) ease, background-color var(--us-dur-1) ease;
}

.us-ui:not(#_) .us-qty:hover {
    background: var(--us-field-h);
}

.us-ui:not(#_) .us-qty:focus-within {
    box-shadow: var(--us-ring);
}

.us-ui:not(#_) .us-qty.has-error {
    box-shadow: var(--us-ring-danger);
}

.us-ui:not(#_) .us-qty__btn {
    width: var(--us-control-h);
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--us-text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transition: background-color var(--us-dur-1) ease, color var(--us-dur-1) ease;
}

.us-ui:not(#_) .us-qty__btn:hover {
    background: var(--us-primary-50);
    color: var(--us-primary-text);
}

.us-ui:not(#_) .us-qty__btn:active {
    background: var(--us-primary-100);
}

.us-ui:not(#_) .us-qty__btn .us-icon {
    width: 16px;
    height: 16px;
}

.us-ui:not(#_) .us-qty__input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: auto;
    margin: 0;
    padding: 0 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--us-text);
    font: inherit;
    font-size: var(--us-fs-base);
    font-weight: 700;
    text-align: center;
    box-shadow: none;
    outline: none;
}

.us-ui:not(#_) .us-qty__input::placeholder {
    color: var(--us-hint);
    font-weight: 400;
}

/* ------------------------------------------------------------------ */
/* Surfaces (flat tile fill + whitespace, no borders or shadows)       */
/* ------------------------------------------------------------------ */

.us-ui:not(#_) .us-card {
    position: relative;
    border: 0;
    border-radius: var(--us-r-lg);
    background: var(--us-tile);
    box-shadow: none;
}

.us-ui:not(#_) .us-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 24px 0;
}

.us-ui:not(#_) .us-card__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--us-fs-lg);
    font-weight: 500;
    line-height: 1.75;
    color: var(--us-text);
}

.us-ui:not(#_) .us-card__title .us-icon {
    color: var(--us-text-2);
}

.us-ui:not(#_) .us-card__body {
    padding: 24px;
}

.us-ui:not(#_) .us-card__head + .us-card__body {
    padding-top: 16px;
}

.us-ui:not(#_) .us-card__foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 0 24px 24px;
}

.us-ui:not(#_) .us-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.us-ui:not(#_) .us-stack--sm {
    gap: 8px;
}

.us-ui:not(#_) .us-stack--lg {
    gap: 24px;
}

.us-ui:not(#_) .us-row-flex {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.us-ui:not(#_) .us-divider {
    height: 1px;
    margin: 4px 0;
    border: 0;
    background: var(--us-divider);
}

/* Section title inside forms. */
.us-ui:not(#_) .us-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--us-fs-lg);
    font-weight: 500;
    line-height: 1.75;
    color: var(--us-text);
}

/* Status badge: 6px semantic dot + quiet label, no pill, no tint. */
.us-ui:not(#_) .us-badge {
    --_c: var(--us-gray-400);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 24px;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--us-text-2);
    font-size: var(--us-fs-sm);
    font-weight: 400;
    line-height: 1.67;
    white-space: nowrap;
}

.us-ui:not(#_) .us-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    border-radius: 50%;
    background: var(--_c);
}

/* The dot is drawn by ::before; the optional element stays for markup compatibility. */
.us-ui:not(#_) .us-badge__dot {
    display: none;
}

.us-ui:not(#_) .us-badge--primary { --_c: var(--us-primary); }
.us-ui:not(#_) .us-badge--success { --_c: var(--us-success); }
.us-ui:not(#_) .us-badge--warning { --_c: var(--us-warning); }
.us-ui:not(#_) .us-badge--danger { --_c: var(--us-danger); }
.us-ui:not(#_) .us-badge--accent { --_c: var(--us-accent); }

/* Tag: quiet neutral label, 4px radius. */
.us-ui:not(#_) .us-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--us-r-xs);
    background: var(--us-field);
    color: var(--us-text-2);
    font-size: var(--us-fs-xs);
    font-weight: 400;
    line-height: 1.67;
}

/* Key / value list. */
.us-ui:not(#_) .us-kv {
    display: grid;
    gap: 12px;
}

.us-ui:not(#_) .us-kv > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    font-size: var(--us-fs-base);
    line-height: 1.57;
}

.us-ui:not(#_) .us-kv dt {
    color: var(--us-text-2);
    flex: 0 0 auto;
}

.us-ui:not(#_) .us-kv dd {
    margin: 0;
    font-weight: 500;
    color: var(--us-text);
    text-align: left;
    min-width: 0;
    overflow-wrap: anywhere;
}

.us-ui:not(#_) .us-kv--stack > div {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
}

.us-ui:not(#_) .us-kv--stack dd {
    text-align: right;
    font-weight: 500;
}

/* Money. */
.us-ui:not(#_) .us-money {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-weight: 700;
    font-feature-settings: "tnum";
}

.us-ui:not(#_) .us-money small {
    font-size: var(--us-fs-xs);
    font-weight: 400;
    color: var(--us-text-2);
}

/* Alerts: flat tile, neutral text; the icon alone carries the semantic hue. */
.us-ui:not(#_) .us-alert {
    --_ic: var(--us-primary-text);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border: 0;
    border-radius: var(--us-r-lg);
    background: var(--us-tile);
    color: var(--us-text);
    font-size: var(--us-fs-base);
    font-weight: 400;
    line-height: 1.71;
}

.us-ui:not(#_) .us-alert .us-icon {
    margin-top: 3px;
    color: var(--_ic);
}

.us-ui:not(#_) .us-alert--success { --_ic: var(--us-success-text); }
.us-ui:not(#_) .us-alert--warning { --_ic: var(--us-warning-text); }
.us-ui:not(#_) .us-alert--danger { --_ic: var(--us-danger-text); }
.us-ui:not(#_) .us-alert--neutral { --_ic: var(--us-text-2); }

/* Empty state. */
.us-ui:not(#_) .us-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 48px 24px;
    border: 0;
    border-radius: var(--us-r-lg);
    background: var(--us-tile);
}

.us-ui:not(#_) .us-empty__icon {
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
    border-radius: var(--us-r-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--us-field);
    color: var(--us-text-2);
    box-shadow: none;
}

.us-ui:not(#_) .us-empty__icon .us-icon {
    width: 24px;
    height: 24px;
}

.us-ui:not(#_) .us-empty__title {
    font-size: var(--us-fs-lg);
    font-weight: 500;
    line-height: 1.75;
    color: var(--us-text);
}

.us-ui:not(#_) .us-empty__text {
    max-width: 380px;
    font-size: var(--us-fs-base);
    line-height: 1.71;
    color: var(--us-text-2);
}

.us-ui:not(#_) .us-empty__action {
    margin-top: 16px;
}

/* Avatar. */
.us-ui:not(#_) .us-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 50%;
    object-fit: cover;
    background: var(--us-field);
}

/* Skeleton. */
.us-ui:not(#_) .us-skel {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: var(--us-r-sm);
    background: var(--us-field-h);
}

.us-ui:not(#_) .us-skel::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--us-surface) 60%, transparent), transparent);
    transform: translateX(100%);
    animation: us-shimmer 1.2s ease-in-out infinite;
}

.us-ui:not(#_) .us-skel--text {
    height: 12px;
    border-radius: var(--us-r-pill);
}

.us-ui:not(#_) .us-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--us-divider);
    border-top-color: var(--us-primary-text);
    border-radius: 50%;
    animation: us-spin 0.7s linear infinite;
}

/* Search box (filled field). */
.us-ui:not(#_) .us-search {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.us-ui:not(#_) .us-search > .us-icon {
    position: absolute;
    inset-inline-start: 12px;
    color: var(--us-text-2);
    pointer-events: none;
}

.us-ui:not(#_) .us-search .us-input {
    padding-inline-start: 40px;
    padding-inline-end: 40px;
}

.us-ui:not(#_) .us-search .us-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.us-ui:not(#_) .us-search__clear {
    position: absolute;
    inset-inline-end: 4px;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--us-r-sm);
    background: transparent;
    color: var(--us-text-2);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
}

.us-ui:not(#_) .us-search.has-value .us-search__clear {
    display: inline-flex;
}

.us-ui:not(#_) .us-search__clear:hover {
    background: var(--us-hover);
    color: var(--us-text);
}

/* Data table (desktop): flat, hairline between rows → stacked rows on phones. */
.us-ui:not(#_) .us-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 0;
    border-radius: var(--us-r-lg);
    background: transparent;
}

.us-ui:not(#_) .us-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: var(--us-fs-base);
    line-height: 1.57;
}

.us-ui:not(#_) .us-table :is(th, td) {
    padding: 16px;
    border: 0;
    border-bottom: 1px solid var(--us-divider);
    background: transparent;
    text-align: right;
    vertical-align: middle;
}

.us-ui:not(#_) .us-table th {
    padding-top: 12px;
    padding-bottom: 12px;
    color: var(--us-text-2);
    font-size: var(--us-fs-sm);
    font-weight: 500;
    white-space: nowrap;
}

.us-ui:not(#_) .us-table tbody tr:last-child td {
    border-bottom: 0;
}

.us-ui:not(#_) .us-table tbody tr:hover td {
    background: var(--us-hover);
}

.us-ui:not(#_) .us-table tfoot td {
    background: transparent;
    border-top: 1px solid var(--us-divider);
    border-bottom: 0;
    font-weight: 700;
}

.us-ui:not(#_) .us-table .is-num {
    text-align: left;
    font-feature-settings: "tnum";
    white-space: nowrap;
}

@media (max-width: 640px) {
    .us-ui:not(#_) .us-table--stack thead {
        display: none;
    }

    .us-ui:not(#_) .us-table--stack :is(tbody, tr, td) {
        display: block;
        width: 100%;
    }

    .us-ui:not(#_) .us-table--stack tr {
        padding: 12px 0;
        border-bottom: 1px solid var(--us-divider);
    }

    .us-ui:not(#_) .us-table--stack tbody tr:hover td {
        background: transparent;
    }

    .us-ui:not(#_) .us-table--stack td {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding: 4px 0;
        border: 0;
    }

    .us-ui:not(#_) .us-table--stack td[data-label]::before {
        content: attr(data-label);
        color: var(--us-text-2);
        font-weight: 400;
    }

    .us-ui:not(#_) .us-table--stack tfoot :is(tr, td) {
        display: flex;
    }
}

/* Dropdown menu (overlay: the only surface that floats). */
.us-ui:not(#_) .us-menu {
    position: absolute;
    z-index: 30;
    min-width: 220px;
    padding: 8px;
    border: 0;
    border-radius: var(--us-r-lg);
    background: var(--us-overlay);
    box-shadow: var(--us-shadow-md);
    transform-origin: top left;
    animation: us-pop-in var(--us-dur-2) var(--us-ease);
}

.us-ui:not(#_) .us-menu__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    margin: 0;
    padding: 0 12px;
    border: 0;
    border-radius: var(--us-r-sm);
    background: transparent;
    color: var(--us-text);
    font: inherit;
    font-size: var(--us-fs-base);
    font-weight: 400;
    text-align: right;
    cursor: pointer;
    box-shadow: none;
}

.us-ui:not(#_) .us-menu__item .us-icon {
    color: var(--us-text-2);
}

.us-ui:not(#_) .us-menu__item:hover,
.us-ui:not(#_) .us-menu__item:focus-visible {
    background: var(--us-hover);
    color: var(--us-text);
    outline: none;
}

.us-ui:not(#_) .us-menu__item:active {
    background: var(--us-pressed);
}

.us-ui:not(#_) .us-menu__item--danger,
.us-ui:not(#_) .us-menu__item--danger .us-icon {
    color: var(--us-danger-text);
}

.us-ui:not(#_) .us-menu__item--danger:hover {
    background: var(--us-danger-50);
    color: var(--us-danger-text);
}

.us-ui:not(#_) .us-menu__sep {
    height: 1px;
    margin: 8px 4px;
    background: var(--us-divider);
}

/* ------------------------------------------------------------------ */
/* Modal & bottom sheet                                                */
/* ------------------------------------------------------------------ */

.us-ui:not(#_).us-modal,
.us-ui:not(#_) .us-modal {
    --us-modal-w: 560px;
    position: fixed;
    inset: 0;
    z-index: 2147482500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    visibility: hidden;
    pointer-events: none;
}

.us-ui:not(#_).us-modal.is-open,
.us-ui:not(#_) .us-modal.is-open {
    visibility: visible;
    pointer-events: auto;
}

.us-ui:not(#_).us-modal--sm,
.us-ui:not(#_) .us-modal--sm { --us-modal-w: 460px; }
.us-ui:not(#_).us-modal--md,
.us-ui:not(#_) .us-modal--md { --us-modal-w: 640px; }
.us-ui:not(#_).us-modal--lg,
.us-ui:not(#_) .us-modal--lg { --us-modal-w: 860px; }

.us-ui:not(#_) .us-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4); /* black scrim reads the same in both themes */
    opacity: 0;
    transition: opacity var(--us-dur-3) var(--us-ease);
}

.us-ui:not(#_) .us-modal.is-open .us-modal__backdrop,
.us-ui:not(#_).us-modal.is-open .us-modal__backdrop {
    opacity: 1;
}

.us-ui:not(#_) .us-modal__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(var(--us-modal-w), 100%);
    max-height: min(86dvh, 820px);
    overflow: hidden;
    border-radius: var(--us-r-lg);
    background: var(--us-overlay);
    box-shadow: var(--us-shadow-lg);
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transition: transform var(--us-dur-3) var(--us-ease-sheet), opacity var(--us-dur-2) ease;
    will-change: transform;
}

.us-ui:not(#_) .us-modal.is-open .us-modal__panel,
.us-ui:not(#_).us-modal.is-open .us-modal__panel {
    opacity: 1;
    transform: none;
}

.us-ui:not(#_) .us-modal__handle {
    display: none;
}

.us-ui:not(#_) .us-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 24px 8px;
}

.us-ui:not(#_) .us-modal__header-main {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.us-ui:not(#_) .us-modal__title-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: var(--us-r-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--us-tile);
    color: var(--us-text-2);
}

.us-ui:not(#_) .us-modal__title-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.us-ui:not(#_) .us-modal__title {
    font-size: var(--us-fs-xl);
    font-weight: 500;
    line-height: 1.78;
}

.us-ui:not(#_) .us-modal__subtitle {
    margin-top: 2px;
    font-size: var(--us-fs-sm);
    color: var(--us-text-2);
    line-height: 1.67;
}

.us-ui:not(#_) .us-modal__close {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    margin: -8px 0 0 -8px;
    padding: 0;
    border: 0;
    border-radius: var(--us-r-sm);
    background: transparent;
    color: var(--us-text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transition: background-color var(--us-dur-1) ease, color var(--us-dur-1) ease;
}

.us-ui:not(#_) .us-modal__close:hover {
    background: var(--us-hover);
    color: var(--us-text);
}

.us-ui:not(#_) .us-modal__close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.us-ui:not(#_) .us-modal__content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.us-ui:not(#_) .us-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 24px;
    -webkit-overflow-scrolling: touch;
}

.us-ui:not(#_) .us-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px calc(24px + env(safe-area-inset-bottom));
    border: 0;
    background: transparent;
}

.us-ui:not(#_) .us-modal__footer-note {
    font-size: var(--us-fs-xs);
    color: var(--us-text-2);
}

.us-ui:not(#_) .us-modal__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-inline-start: auto;
}

/* Phones: every modal becomes a bottom sheet (drag the handle to dismiss). */
@media (max-width: 640px) {
    .us-ui:not(#_).us-modal,
    .us-ui:not(#_) .us-modal {
        align-items: flex-end;
        padding: 0;
    }

    .us-ui:not(#_) .us-modal__panel {
        width: 100%;
        max-height: 92dvh;
        border-radius: var(--us-r-xl) var(--us-r-xl) 0 0;
        transform: translateY(100%);
        opacity: 1;
        transition: transform 380ms var(--us-ease-sheet);
    }

    .us-ui:not(#_) .us-modal.is-dragging .us-modal__panel,
    .us-ui:not(#_).us-modal.is-dragging .us-modal__panel {
        transition: none;
    }

    .us-ui:not(#_) .us-modal__handle {
        display: block;
        flex: 0 0 auto;
        width: 100%;
        height: 24px;
        position: relative;
        touch-action: none;
        cursor: grab;
    }

    .us-ui:not(#_) .us-modal__handle::before {
        content: "";
        position: absolute;
        top: 10px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;
        border-radius: var(--us-r-pill);
        background: var(--us-gray-300);
    }

    .us-ui:not(#_) .us-modal__header {
        padding: 2px 16px 8px;
        touch-action: none;
    }

    .us-ui:not(#_) .us-modal__title-icon {
        display: none;
    }

    .us-ui:not(#_) .us-modal__body {
        padding: 16px;
    }

    .us-ui:not(#_) .us-modal__footer {
        padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
        flex-wrap: wrap;
    }

    .us-ui:not(#_) .us-modal__footer-note {
        width: 100%;
    }

    .us-ui:not(#_) .us-modal__actions {
        width: 100%;
    }

    .us-ui:not(#_) .us-modal__actions > .us-btn {
        flex: 1 1 0;
    }
}

html.us-scroll-locked,
html.us-scroll-locked body {
    overflow: hidden;
}

html.us-scroll-locked body {
    padding-right: var(--us-scrollbar-w, 0px);
}

/* ------------------------------------------------------------------ */
/* Toasts (snackbar: inverse surface, the only floating notice)        */
/* ------------------------------------------------------------------ */

.us-ui:not(#_).us-toasts {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 2147483000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.us-ui:not(#_) .us-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 48px;
    padding: 12px 12px 12px 16px;
    border: 0;
    border-radius: var(--us-r-lg);
    background: var(--us-gray-900);
    color: var(--us-gray-0);
    box-shadow: var(--us-shadow-lg);
    pointer-events: auto;
    animation: us-toast-in 360ms var(--us-ease-sheet);
}

.us-ui:not(#_) .us-toast.is-leaving {
    animation: us-toast-out 220ms ease forwards;
}

.us-ui:not(#_) .us-toast__icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    margin-top: 1px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--_c, var(--us-success));
    color: var(--us-on-primary);
}

.us-ui:not(#_) .us-toast__icon .us-icon {
    width: 14px;
    height: 14px;
    stroke-width: 2.6;
}

.us-ui:not(#_) .us-toast--error { --_c: var(--us-danger); }
.us-ui:not(#_) .us-toast--warning { --_c: var(--us-warning); }
.us-ui:not(#_) .us-toast--info { --_c: var(--us-info); }

.us-ui:not(#_) .us-toast__text {
    flex: 1 1 auto;
    min-width: 0;
    font-size: var(--us-fs-base);
    font-weight: 400;
    line-height: 1.71;
    overflow-wrap: anywhere;
}

.us-ui:not(#_) .us-toast__close {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--us-r-xs);
    background: transparent;
    color: color-mix(in srgb, var(--us-gray-0) 60%, transparent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
}

.us-ui:not(#_) .us-toast__close:hover {
    color: var(--us-gray-0);
    background: color-mix(in srgb, var(--us-gray-0) 12%, transparent);
}

.us-ui:not(#_) .us-toast__close .us-icon {
    width: 14px;
    height: 14px;
}

@media (max-width: 640px) {
    .us-ui:not(#_).us-toasts {
        left: 12px;
        right: 12px;
        bottom: auto;
        top: calc(10px + env(safe-area-inset-top));
        width: auto;
        flex-direction: column;
    }

    .us-ui:not(#_) .us-toast {
        animation-name: us-toast-in-top;
    }

    .us-ui:not(#_) .us-toast.is-leaving {
        animation-name: us-toast-out-top;
    }
}

/* ------------------------------------------------------------------ */
/* Animations                                                          */
/* ------------------------------------------------------------------ */

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

@keyframes us-shimmer {
    to { transform: translateX(-100%); }
}

@keyframes us-pop-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
}

@keyframes us-fade-up {
    from { opacity: 0; transform: translateY(8px); }
}

@keyframes us-toast-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
}

@keyframes us-toast-out {
    to { opacity: 0; transform: translateY(8px) scale(0.98); }
}

@keyframes us-toast-in-top {
    from { opacity: 0; transform: translateY(-16px) scale(0.98); }
}

@keyframes us-toast-out-top {
    to { opacity: 0; transform: translateY(-10px) scale(0.98); }
}

@media (prefers-reduced-motion: reduce) {
    .us-ui *,
    .us-ui *::before,
    .us-ui *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}
