﻿/* ============================================================
   The demo's own styles - the look of its live samples - on top of the
   site kit (Server/wwwroot/app.css), which draws everything around them:
   the header, the docs shell, the typography, the code blocks.
   The bit Bheadless library ships ZERO CSS: everything below is
   consumer-authored, and the CSS tab of each example shows its part.
   ============================================================ */

/* Establish layer order so Tailwind's utility layer (declared in
   wwwroot/tailwind.css) wins against this reset on the /tw pages.
   Specific component rules below remain unlayered and still beat
   utilities by specificity on the CSS pages. Tailwind's own "properties"
   layer goes first, as tailwind.css means it to: left out, it would be
   appended last - the strongest layer - and the --tw-* defaults it sets on
   every element in browsers without @property (Safari before 16.4, Firefox
   before 128) would override every ring, shadow, translate and content
   utility. */
@layer properties, base, theme, components, utilities;

@layer base {

    *,
    *::before,
    *::after {
        box-sizing: border-box;
        margin: 0;
    }
}

/* ---- Theme tokens ----
   The kit's theme.js sets <html bit-theme="light|dark"> before the first
   paint, and app.css gives the root the matching color-scheme. Each token is
   written as light-dark(<light>, <dark>), resolved by that color-scheme, so
   the samples follow the site's theme with no rule of their own. */

:root {
    /* Neutrals */
    --color-bg: light-dark(#fafafa, #09090b);
    --color-surface: light-dark(#fff, #18181b);
    --color-subtle: light-dark(#fafafa, #1f1f23);
    --color-fill: light-dark(#f4f4f5, #27272a);
    --color-fill-strong: light-dark(#e4e4e7, #3f3f46);
    --color-border: light-dark(#e4e4e7, #27272a);
    --color-border-subtle: light-dark(#f4f4f5, #1f1f23);
    --color-border-strong: light-dark(#d4d4d8, #3f3f46);
    /* The edge of an unchecked box or radio: it alone shows the control is there (3:1, WCAG 1.4.11). */
    --color-border-control: light-dark(#71717a, #71717a);
    --color-border-control-hover: light-dark(#52525b, #a1a1aa);
    --color-border-hover: light-dark(#a1a1aa, #52525b);
    --color-text: light-dark(#18181b, #fafafa);
    --color-text-secondary: light-dark(#3f3f46, #d4d4d8);
    --color-text-tertiary: light-dark(#52525b, #b4b4bc);
    --color-muted: light-dark(#71717a, #a1a1aa);
    --color-faint: light-dark(#a1a1aa, #71717a);
    --color-disabled: light-dark(#d4d4d8, #52525b);
    /* Dark chips and tooltips: lifted to zinc-700 in the dark theme rather than
       inverted, so the white text on them works in both themes. */
    --color-inverse: light-dark(#18181b, #3f3f46);
    --color-on-inverse: #fafafa;
    --color-code-bg: light-dark(#18181b, #09090b);

    /* Brand. Solid fills keep white text readable in both themes; text and
       focus rings get a lighter blue on dark surfaces. */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-text: light-dark(#2563eb, #60a5fa);
    --color-focus: light-dark(#2563eb, #60a5fa);
    --color-accent-subtle: light-dark(#eff6ff, #1c2b4a);
    --color-accent-muted: light-dark(#dbeafe, #1e3a8a);
    --color-accent-text: light-dark(#1d4ed8, #93c5fd);

    /* Status */
    --color-danger: #dc2626;
    --color-danger-text: light-dark(#b91c1c, #fca5a5);
    --color-danger-subtle: light-dark(#fef2f2, #3a1717);
    --color-danger-border: light-dark(#fecaca, #7f1d1d);
    --color-success-text: light-dark(#15803d, #86efac);
    --color-success-subtle: light-dark(#f0fdf4, #0f2a1a);
    --color-success-muted: light-dark(#dcfce7, #14532d);
    --color-success-border: light-dark(#bbf7d0, #166534);
    --color-warning-subtle: light-dark(#fef3c7, #3d2e0a);
    --color-warning-text: light-dark(#854d0e, #fde68a);
    --color-violet-subtle: light-dark(#faf5ff, #2a1d4a);
    --color-violet-muted: light-dark(#ede9fe, #3b2a6b);
    --color-violet-text: light-dark(#6d28d9, #c4b5fd);

    --radius: 0.5rem;
    --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

/* ---- Sample layout ---- */

.demo-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.demo-output {
    font-size: 0.875rem;
    color: var(--color-muted);
}

.demo-output strong {
    color: var(--color-text);
}

/* ============================================================
   Button styles — purely consumer-defined

   The site kit has a .btn and a .btn-primary of its own - the
   calls to action on the landing page and in the docs - so the
   samples' are scoped to where samples render: the example frame
   (.bb-demo) and the portal outlet that dialogs, popovers and
   menus render into. Every rule of the .btn family carries the
   scope, the variants further down too: the scope's class is what
   outranks the kit's button.btn and button.btn-primary on a
   <button>, so a sample looks the way its CSS tab says, and the
   family keeps its own order among itself.
   ============================================================ */

:is(.bb-demo, [data-bit-bh-portal-root]) .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, opacity 150ms ease;
    text-decoration: none;
    user-select: none;
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn:hover {
    background: var(--color-fill);
    border-color: var(--color-border-strong);
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn:active {
    background: var(--color-fill-strong);
}

/* Data-attribute styling hooks from bit Bheadless */
:is(.bb-demo, [data-bit-bh-portal-root]) .btn[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn[data-loading] {
    opacity: 0.7;
    cursor: wait;
}

/* ---- Variants (all consumer-defined) ---- */

:is(.bb-demo, [data-bit-bh-portal-root]) .btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn-link {
    background: transparent;
    border-color: transparent;
    color: var(--color-primary-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn-link:hover {
    color: var(--color-accent-text);
    background: var(--color-accent-subtle);
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn-toggle {
    min-width: 4rem;
    justify-content: center;
    background: var(--color-surface);
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn-toggle.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* ---- Data-attribute-only styling demo ---- */

.btn-data {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.25rem;
    border: none;
    border-radius: var(--radius);
    background: var(--color-inverse);
    color: white;
    cursor: pointer;
    transition: opacity 150ms ease, transform 150ms ease;
}

.btn-data:hover {
    opacity: 0.9;
}

.btn-data:active {
    transform: scale(0.98);
}

.btn-data[data-disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-data[data-loading] {
    opacity: 0.7;
    cursor: wait;
}

/* ---- Spinner ---- */

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================================
   Accordion styles — purely consumer-defined
   ============================================================ */

/* ---- Accordion root ---- */

.accordion {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

/* ---- Accordion item ---- */

.accordion-item {
    border-bottom: 1px solid var(--color-border);
}

.accordion-item:last-child {
    border-bottom: none;
}

/* ---- Accordion trigger ---- */

/* The heading around each trigger: the trigger carries the look, the heading only the outline level */
.accordion-header {
    margin: 0;
    font: inherit;
    letter-spacing: inherit;
    color: inherit;
}

.accordion-trigger {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-surface);
    cursor: pointer;
    transition: background 150ms ease;
    box-sizing: border-box;
}

.accordion-trigger:hover {
    background: var(--color-fill);
}

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

/* Data-attribute hooks — open / closed state */
.accordion-trigger[data-state="open"] {
    background: var(--color-fill);
}

.accordion-trigger[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---- Chevron indicator ---- */

.accordion-chevron {
    display: inline-block;
    font-size: 1.1rem;
    transition: transform 200ms ease;
    color: var(--color-muted);
    flex-shrink: 0;
}

.accordion-chevron.open {
    transform: rotate(180deg);
}

/* ---- Accordion content panel ---- */

.accordion-content {
    /* hidden attribute handles display:none when closed.
       Override this block when you want CSS-driven height animations:
       remove the hidden attribute approach and use data-state transitions. */
}

.accordion-body {
    padding: 0.875rem 1.25rem 1.125rem;
    font-size: 0.9rem;
    color: var(--color-muted);
    line-height: 1.7;
    border-top: 1px solid var(--color-border);
}

.accordion-body code {
    background: var(--color-fill);
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
    font-size: 0.85em;
    color: var(--color-text);
}

/* ============================================================
   Disclosure styles — purely consumer-defined
   ============================================================ */

.disclosure {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--color-surface);
}

.disclosure-button {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.875rem 1.125rem;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-surface);
    cursor: pointer;
    transition: background 150ms ease;
    box-sizing: border-box;
}

.disclosure-button:hover {
    background: var(--color-fill);
}

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

.disclosure-button[data-state="open"] {
    background: var(--color-fill);
}

.disclosure-button[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.disclosure-chevron {
    display: inline-block;
    font-size: 1.05rem;
    color: var(--color-muted);
    transition: transform 200ms ease;
    flex-shrink: 0;
}

.disclosure-chevron.open {
    transform: rotate(180deg);
}

.disclosure-body {
    padding: 0.875rem 1.125rem 1rem;
    font-size: 0.9rem;
    color: var(--color-muted);
    line-height: 1.7;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
}

/* ============================================================
   Collapsible styles — purely consumer-defined
   ============================================================ */

.collapsible {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--color-surface);
}

.collapsible[data-disabled],
.disclosure[data-disabled],
.accordion-item[data-disabled] {
    background: var(--color-subtle);
}

.disclosure[data-disabled] .disclosure-button,
.accordion-item[data-disabled] .accordion-trigger {
    background: transparent;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.125rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
}

.collapsible-trigger {
    all: unset;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.375rem;
    color: var(--color-muted);
    cursor: pointer;
    transition: background 150ms ease;
    box-sizing: border-box;
    flex-shrink: 0;
}

.collapsible-trigger:hover {
    background: var(--color-fill);
}

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

.collapsible-trigger[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.collapsible-chevron {
    display: inline-block;
    font-size: 1.05rem;
    transition: transform 200ms ease;
}

.collapsible-chevron.open {
    transform: rotate(180deg);
}

.collapsible-row {
    padding: 0.75rem 1.125rem;
    font-size: 0.9rem;
    color: var(--color-muted);
    line-height: 1.7;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

/* ============================================================
   Switch styles — purely consumer-defined
   ============================================================ */

.switch {
    /* Reset native button */
    all: unset;
    box-sizing: border-box;

    /* Track */
    position: relative;
    display: inline-block;
    width: 2.5rem;
    height: 1.4rem;
    border-radius: 999px;
    background: var(--color-border);
    cursor: pointer;
    transition: background 150ms ease;
    flex-shrink: 0;
}

.switch:focus-visible {
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-primary);
}

/* Hooks emitted by HSwitch */
.switch[data-state="checked"] {
    background: var(--color-primary);
}

.switch[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Thumb — driven by data-state on the inner element */
.switch-thumb {
    position: absolute;
    top: 50%;
    left: 0.15rem;
    width: 1.1rem;
    height: 1.1rem;
    background: #fff;
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%);
    transition: left 150ms ease;
}

.switch-thumb[data-state="checked"] {
    left: calc(100% - 1.1rem - 0.15rem);
}

/* ---- Label wrapper ---- */

.switch-label {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}

/* ============================================================
   Tabs styles — purely consumer-defined
   ============================================================ */

.tabs {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.tab-list {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    gap: 0.25rem;
}

/* ---- Tab ---- */

.tab {
    all: unset;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 150ms ease, border-color 150ms ease;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.tab:hover {
    color: var(--color-text);
}

.tab:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: -2px;
    border-radius: 0.25rem;
}

/* Hooks emitted by HTab */
.tab[data-state="active"] {
    color: var(--color-primary-text);
    border-bottom-color: var(--color-primary);
}

.tab[data-disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Tab panel ---- */

.tab-panels {
    width: 100%;
}

.tab-panel {
    padding: 0.25rem 0 0.5rem;
    color: var(--color-text);
}

.tab-panel:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.tab-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.tab-panel p {
    color: var(--color-muted);
    font-size: 0.9rem;
}

/* ---- Vertical orientation ---- */

.tabs[data-orientation="vertical"] {
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
}

.tabs[data-orientation="vertical"] .tab-list {
    flex-direction: column;
    border-bottom: none;
    border-right: 1px solid var(--color-border);
    min-width: 12rem;
    gap: 0;
}

.tabs[data-orientation="vertical"] .tab {
    border-bottom: none;
    border-right: 2px solid transparent;
    justify-content: flex-start;
}

.tabs[data-orientation="vertical"] .tab[data-state="active"] {
    border-right-color: var(--color-primary);
    border-bottom-color: transparent;
}

.tabs[data-orientation="vertical"] .tab-panels {
    flex: 1 1 auto;
}

/* ---- Badge inside a tab (used by the render-context demo) ---- */

.badge {
    padding: 0.05rem 0.4rem;
    background: var(--color-border);
    color: var(--color-text-tertiary);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-active {
    background: var(--color-primary);
    color: #fff;
}

/* ============================================================
   Checkbox styles — purely consumer-defined
   ============================================================ */

.checkbox {
    /* Reset native button */
    all: unset;
    box-sizing: border-box;

    /* Box */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    border: 1px solid var(--color-border-control);
    border-radius: 0.25rem;
    background: var(--color-surface);
    color: #fff;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
    flex-shrink: 0;
}

.checkbox:hover {
    border-color: var(--color-border-control-hover);
}

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

/* Hooks emitted by HCheckbox */
.checkbox[data-state="checked"],
.checkbox[data-state="indeterminate"] {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.checkbox[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Glyphs rendered inside the box ---- */

.checkbox-tick {
    font-size: 0.85rem;
    line-height: 1;
}

.checkbox-dash {
    font-size: 1rem;
    font-weight: 700;
    line-height: 0;
}

/* ---- Label wrapper ---- */

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}

/* ============================================================
   Radio Group styles — purely consumer-defined
   ============================================================ */

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.radio-group[data-orientation="horizontal"] {
    flex-direction: row;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}

.radio {
    /* Reset native button */
    all: unset;
    box-sizing: border-box;

    /* Outer ring */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    border: 1px solid var(--color-border-control);
    border-radius: 999px;
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color 120ms ease;
    flex-shrink: 0;
}

.radio:hover {
    border-color: var(--color-border-control-hover);
}

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

/* Hooks emitted by HRadio */
.radio[data-state="checked"] {
    border-color: var(--color-primary);
}

.radio[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Inner dot */
.radio-dot {
    width: 0.55rem;
    height: 0.55rem;
    background: var(--color-primary);
    border-radius: 999px;
}

/* ---- Card-style group (used by the demo) ---- */

.plan-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
}

.plan-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease;
    box-sizing: border-box;
}

.plan-card:has(.radio[data-state="checked"]) {
    border-color: var(--color-primary);
    background: var(--color-accent-subtle);
}

.plan-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.plan-info strong {
    font-size: 0.95rem;
    color: var(--color-text);
}

.plan-info span {
    font-size: 0.8rem;
    color: var(--color-text-tertiary);
}

/* ============================================================
   Listbox styles — purely consumer-defined
   ============================================================ */

.listbox {
    position: relative;
    display: inline-block;
    min-width: 14rem;
}

/* ---- Listbox button (the trigger) ---- */

.listbox-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color 120ms ease;
}

.listbox-button:hover {
    border-color: var(--color-border-hover);
}

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

.listbox-button[data-state="open"] {
    border-color: var(--color-primary);
}

.listbox-button[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.listbox-chevron {
    transition: transform 200ms ease;
    color: var(--color-muted);
    flex-shrink: 0;
}

.listbox-chevron.open {
    transform: rotate(180deg);
}

/* ---- Options panel ----
   Sits above the click-outside overlay (which uses z-index: 30 inline). */

.listbox-options {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    z-index: 31;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    max-height: 14rem;
    overflow-y: auto;
}

/* ---- Option ---- */

/* BitBhOptionGroupLabel: the heading of a section of options */
.listbox-group-label {
    padding: 0.5rem 0.65rem 0.25rem;
    color: var(--color-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.listbox-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 0.35rem;
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
}

/* Hooks emitted by HListboxOption */
.listbox-option[data-active] {
    background: var(--color-accent-subtle);
}

.listbox-option[data-selected] {
    font-weight: 600;
}

.listbox-option[data-disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Multi-select check-mark ---- */

.check-mark {
    display: inline-block;
    width: 1rem;
    color: var(--color-primary-text);
    font-weight: 700;
}

/* ---- Custom country option ---- */

.country-flag {
    font-size: 1.05rem;
}

.country-name {
    flex: 1 1 auto;
}

.country-code {
    font-size: 0.7rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Anchored listbox ---- */

.listbox-anchored {
    display: inline-block;
    min-width: 14rem;
}

.listbox-options-anchored {
    z-index: 9999;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    max-height: 14rem;
    overflow-y: auto;
    width: var(--button-width);
}

.listbox-options-anchored[hidden] {
    display: none;
}

/* ============================================================
   Dialog styles — purely consumer-defined
   ============================================================ */

/* The dialog root (no class) keeps the library's default position:fixed;
   inset:0 layer. The backdrop and panel have a class, which turns their
   defaults off, so they place themselves inside that layer. */

.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.dialog-panel {
    /* Positioned, so it paints above the backdrop. */
    position: relative;
    margin: 4rem auto;
    max-width: 28rem;
    width: calc(100% - 2rem);
    background: var(--color-surface);
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.dialog-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.dialog-description {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin: 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ---- Danger button variant used by the confirm demo ---- */

:is(.bb-demo, [data-bit-bh-portal-root]) .btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

/* ---- Form fields inside a dialog ---- */

.dialog-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--color-text);
}

.dialog-input {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 0.4rem;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.dialog-input:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
}

/* ============================================================
   Alert Dialog styles — purely consumer-defined
   ============================================================ */

/* The library centres the content and stretches the overlay over the
   viewport only for parts without a class or style: these have a class, so
   they position themselves. */

.alert-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.5);
}

.alert-content {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 51;
    transform: translate(-50%, -50%);
    width: calc(100vw - 2rem);
    max-width: 28rem;
    background: var(--color-surface);
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.alert-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.alert-description {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin: 0;
}

.alert-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ============================================================
   Combobox styles — purely consumer-defined
   ============================================================ */

.combobox {
    position: relative;
    display: inline-block;
    min-width: 18rem;
}

.combobox-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    transition: border-color 120ms ease;
}

.combobox-input-wrapper:focus-within {
    border-color: var(--color-primary);
}

.combobox-input {
    flex: 1 1 auto;
    padding: 0.5rem 0.85rem;
    border: 0;
    background: transparent;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--color-text);
    outline: none;
    width: 100%;
    min-width: 0;
}

.combobox-button {
    all: unset;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.65rem;
    cursor: pointer;
    color: var(--color-muted);
}

.combobox-chevron {
    transition: transform 200ms ease;
}

.combobox-chevron.open {
    transform: rotate(180deg);
}

/* ---- Options panel ----
   Sits above the click-outside overlay (which uses z-index: 30 inline). */

.combobox-options {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    z-index: 31;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    max-height: 16rem;
    overflow-y: auto;
}

/* ---- Option ---- */

.combobox-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 0.35rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--color-text);
}

.combobox-option[data-active] {
    background: var(--color-accent-subtle);
}

.combobox-option[data-selected] {
    font-weight: 600;
}

.combobox-option[data-disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.combobox-empty {
    padding: 0.6rem 0.65rem;
    font-size: 0.85rem;
    color: var(--color-muted);
    font-style: italic;
}

.combobox-tick {
    color: var(--color-primary-text);
    font-weight: 700;
}

/* ---- Multi-select chips ---- */

.combobox-input-wrapper-multi {
    flex-wrap: wrap;
    padding: 0.25rem 0.35rem;
    gap: 0.25rem;
}

.combobox-input-inline {
    width: auto;
    min-width: 6rem;
    padding: 0.25rem 0.4rem;
}

.combobox-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    background: var(--color-accent-subtle);
    color: var(--color-accent-text);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.combobox-chip-remove {
    all: unset;
    cursor: pointer;
    font-size: 1rem;
    line-height: 0.7;
    padding: 0 0.1rem;
    border-radius: 999px;
}

.combobox-chip-remove:hover {
    background: var(--color-accent-muted);
}

/* ---- Person row used by the object-values demo ---- */

.person-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}

.person-avatar {
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: light-dark(#e0e7ff, #1e3a8a);
    color: var(--color-accent-text);
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.person-info {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.person-info strong {
    font-size: 0.85rem;
    color: var(--color-text);
}

.person-info span {
    font-size: 0.75rem;
    color: var(--color-muted);
}

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

.combobox-anchored {
    display: inline-block;
    min-width: 18rem;
}

.combobox-options-anchored {
    z-index: 9999;
    min-width: 18rem;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    max-height: 16rem;
    overflow-y: auto;
}

.combobox-options-anchored[hidden] {
    display: none;
}

/* ============================================================
   Menu styles — purely consumer-defined
   ============================================================ */

.menu {
    position: relative;
    display: inline-block;
}

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

.menu-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color 120ms ease;
}

.menu-button:hover {
    border-color: var(--color-border-hover);
}

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

.menu-button[data-state="open"] {
    border-color: var(--color-primary);
}

.menu-button[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.menu-chevron {
    transition: transform 200ms ease;
    color: var(--color-muted);
}

.menu-chevron.open {
    transform: rotate(180deg);
}

/* ---- Items panel ----
   Sits above the click-outside overlay (z-index: 30 inline). */

.menu-items {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    z-index: 31;
    min-width: 10rem;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    outline: none;
}

.menu-items-wide {
    min-width: 16rem;
}

/* ---- Anchored items panel ----
   When using the Anchor prop, position:fixed is applied by JS.
   No position:absolute or top/left needed here. */

.menu-items-anchored {
    z-index: 9999;
    min-width: 10rem;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    outline: none;
}

.menu-items-anchored.menu-items-wide {
    min-width: 16rem;
}

.menu-items-match-width {
    min-width: unset;
    width: var(--button-width);
}

.menu-items-anchored[hidden] {
    display: none;
}

/* ---- Menu item ---- */

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 0.35rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--color-text);
    list-style: none;
    text-decoration: none;
}

/* Hooks emitted by HMenuItem */
.menu-item[data-active] {
    background: var(--color-accent-subtle);
    color: var(--color-accent-text);
}

.menu-item[data-disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Rich item layout ---- */

.menu-item-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.menu-item-shortcut {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--color-muted);
}

.menu-item-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    line-height: 1.25;
}

.menu-item-body strong {
    font-size: 0.875rem;
}

.menu-item-body span {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.menu-item[data-active] .menu-item-body span {
    color: var(--color-primary-text);
}

/* ---- Section labels and dividers ---- */

.menu-section-label {
    padding: 0.35rem 0.65rem 0.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    list-style: none;
}

.menu-divider {
    height: 1px;
    background: var(--color-border);
    margin: 0.25rem 0;
    list-style: none;
}

/* ============================================================
   Context Menu styles — purely consumer-defined
   ============================================================ */

.cm-trigger {
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 9rem;
    padding: 2rem;
    border: 2px dashed var(--color-border-strong);
    border-radius: 0.75rem;
    color: var(--color-muted);
    font-size: 0.95rem;
    user-select: none;
    cursor: context-menu;
    transition: border-color 120ms ease, color 120ms ease;
}

.cm {
    flex: 1 1 18rem;
    min-width: 0;
}

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

.cm-trigger[data-state="open"] {
    border-color: var(--color-primary);
    color: var(--color-accent-text);
}

.cm-trigger-disabled {
    cursor: default;
}

/* The content panel is positioned at the pointer with fixed positioning by the
   JS engine, so it needs a high z-index and no manual top/left. */
.cm-content {
    z-index: 9999;
    min-width: 11rem;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.cm-content:focus-visible {
    outline: none;
}

.cm-content[hidden] {
    display: none;
}

.cm-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 0.35rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--color-text);
    list-style: none;
}

/* Hooks emitted by BitBhContextMenuItem */
.cm-item[data-active] {
    background: var(--color-accent-subtle);
    color: var(--color-accent-text);
}

.cm-item[data-disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.cm-label {
    padding: 0.35rem 0.65rem 0.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    list-style: none;
}

.cm-group {
    list-style: none;
}

.cm-separator {
    display: block;
    height: 1px;
    background: var(--color-border);
    margin: 0.25rem 0;
    list-style: none;
}

.cm-shortcut {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--color-muted);
}

.cm-item-danger {
    color: light-dark(#dc2626, #fca5a5);
}

.cm-item-danger[data-active] {
    background: var(--color-danger-subtle);
    color: var(--color-danger-text);
}

/* ============================================================
   Popover styles — purely consumer-defined
   ============================================================ */

.popover {
    position: relative;
    display: inline-block;
}

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

.popover-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color 120ms ease;
}

.popover-button:hover {
    border-color: var(--color-border-hover);
}

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

.popover-button[data-state="open"] {
    border-color: var(--color-primary);
}

.popover-chevron {
    transition: transform 200ms ease;
    color: var(--color-muted);
}

.popover-chevron.open {
    transform: rotate(180deg);
}

/* ---- Popover panel ----
   Sits above the click-outside overlay (z-index: 30 inline). */

.popover-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    z-index: 31;
    min-width: 16rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* The hidden attribute is overridden by display:flex above, so we need
   an explicit rule to hide the panel when closed. */
.popover-panel[hidden] {
    display: none;
}

.popover-panel-wide {
    min-width: 22rem;
    padding: 0;
    overflow: hidden;
}

/* ---- Anchored popover ---- */

.popover-anchored {
    display: inline-block;
}

.popover-panel-anchored {
    z-index: 9999;
    min-width: 16rem;
    max-width: 24rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.popover-panel-anchored[hidden] {
    display: none;
}

.popover-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.popover-body {
    font-size: 0.875rem;
    color: var(--color-muted);
    margin: 0;
}

.popover-link {
    font-size: 0.875rem;
    color: var(--color-primary-text);
    text-decoration: none;
}

.popover-link:hover {
    text-decoration: underline;
}

.popover-close-btn {
    all: unset;
    font-size: 0.8rem;
    color: var(--color-muted);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.popover-close-btn:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
    border-radius: 0.2rem;
}

/* ---- Group layout ---- */

.popover-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ---- Nav list inside a popover ---- */

.popover-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.popover-nav-link {
    display: block;
    padding: 0.35rem 0.5rem;
    border-radius: 0.35rem;
    font-size: 0.875rem;
    color: var(--color-text);
    text-decoration: none;
    transition: background 120ms ease;
}

.popover-nav-link:hover {
    background: var(--color-fill);
    color: var(--color-primary-text);
}

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

.popover-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.1rem 0.45rem;
    background: var(--color-primary);
    color: #fff;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* ---- Notification panel ---- */

.popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.notification-list {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.6rem 1rem;
    transition: background 120ms ease;
}

.notification-item:hover {
    background: var(--color-fill);
}

.notification-dot {
    width: 0.5rem;
    height: 0.5rem;
    background: var(--color-primary);
    border-radius: 999px;
    flex-shrink: 0;
    margin-top: 0.3rem;
}

.notification-item div {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.notification-item strong {
    font-size: 0.85rem;
    color: var(--color-text);
}

.notification-item span {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.popover-footer-link {
    display: block;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    color: var(--color-primary-text);
    text-decoration: none;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.popover-footer-link:hover {
    background: var(--color-fill);
}

/* ============================================================
   CloseButton demo styles
   ============================================================ */

.popover-divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 0.25rem 0;
}

.popover-dismiss {
    all: unset;
    display: block;
    width: 100%;
    font-size: 0.8rem;
    font-family: inherit;
    color: var(--color-muted);
    cursor: pointer;
    text-align: center;
    padding: 0.4rem;
    border-radius: 0.35rem;
    box-sizing: border-box;
}

.popover-dismiss:hover {
    color: var(--color-text);
    background: var(--color-fill);
}

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

.close-variants {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.close-div {
    padding: 0.4rem 0.7rem;
    background: var(--color-fill);
    border-radius: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: center;
}

.close-div:hover {
    background: var(--color-fill-strong);
}

.close-div:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

:is(.bb-demo, [data-bit-bh-portal-root]) .btn-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.7rem;
}

/* ============================================================
   Transition demo styles — utility classes for the demos
   ============================================================ */

.transition-demo-box {
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 20rem;
}

.transition-demo-box p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text);
}

/* ---- Utility classes used by the transition demos ---- */

.transition-opacity {
    transition-property: opacity;
}

.transition-all {
    transition-property: all;
}

.duration-200 {
    transition-duration: 200ms;
}

.duration-300 {
    transition-duration: 300ms;
}

.duration-500 {
    transition-duration: 500ms;
}

.ease-out {
    transition-timing-function: ease-out;
}

.ease-in {
    transition-timing-function: ease-in;
}

.opacity-0 {
    opacity: 0;
}

.opacity-100 {
    opacity: 1;
}

/* The individual scale / translate properties, not transform: tailwind.css is on every page and its
   utilities of these names set those properties, which a transform here would add to (0.95 x 0.95). */
.scale-95 {
    scale: 0.95;
}

.scale-100 {
    scale: 1;
}

.translate-y-4 {
    translate: 0 1rem;
}

.translate-y-0 {
    translate: 0 0;
}

/* ---- Slide-down transition ---- */

.slide-box {
    overflow: hidden;
}

.slide-enter {
    transition: max-height 300ms ease-out, opacity 300ms ease-out;
}

.slide-enter-from {
    max-height: 0;
    opacity: 0;
}

.slide-enter-to {
    max-height: 10rem;
    opacity: 1;
}

.slide-leave {
    transition: max-height 200ms ease-in, opacity 200ms ease-in;
}

.slide-leave-from {
    max-height: 10rem;
    opacity: 1;
}

.slide-leave-to {
    max-height: 0;
    opacity: 0;
}

/* ============================================================
   Field / Input styles — purely consumer-defined
   ============================================================ */

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
    max-width: 24rem;
}

.field[data-disabled] .field-input {
    opacity: 0.6;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
}

.field-label[data-disabled] {
    opacity: 0.5;
}

.field-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 0.4rem;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 120ms ease;
    width: 100%;
    box-sizing: border-box;
}

.field-input:hover {
    border-color: var(--color-border-hover);
}

.field-input:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
}

/* Hooks emitted by HInput / HTextarea / HSelect */
.field-input[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--color-subtle);
}

.field-input[data-invalid] {
    border-color: var(--color-danger);
}

.field-input[data-invalid]:focus-visible {
    outline-color: var(--color-danger);
}

.field-description {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin: 0;
}

.field-error {
    color: var(--color-danger-text);
}

.field-textarea {
    resize: vertical;
    min-height: 4rem;
}

.field-select {
    appearance: none;
    padding-right: 2rem;
}

/* appearance: none takes the arrow away with the native look: the wrapper draws it back. */
.field-select-wrap {
    position: relative;
}

.field-select-wrap .field-select {
    width: 100%;
}

.field-select-chevron {
    position: absolute;
    top: 50%;
    right: 0.625rem;
    width: 1rem;
    height: 1rem;
    translate: 0 -50%;
    color: var(--color-muted);
    pointer-events: none;
}

.field-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 24rem;
}

/* The submit button keeps its own width instead of the form's. */
.field-form > .btn {
    align-self: flex-start;
}

/* ============================================================
   Fieldset styles — purely consumer-defined
   ============================================================ */

.fieldset {
    /* Reset native <fieldset> defaults and re-style as a card */
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 0;
    background: var(--color-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 28rem;
    transition: opacity 150ms ease, background 150ms ease;
}

/* Hook cascaded from HFieldset Disabled="true" */
.fieldset[data-disabled] {
    background: var(--color-subtle);
    box-shadow: none;
}

.fieldset[data-disabled] .field-input,
.fieldset[data-disabled] .field-input:disabled {
    background: var(--color-fill);
    color: var(--color-muted);
    cursor: not-allowed;
}

.fieldset-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--color-border-subtle);
}

.fieldset-legend {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.005em;
}

.fieldset-legend[data-disabled] {
    color: var(--color-muted);
}

.fieldset-hint {
    font-size: 0.85rem;
    color: var(--color-muted);
    line-height: 1.5;
    margin: 0;
}

/* Fields inside a fieldset shouldn't have the 24rem cap */
.fieldset .field {
    max-width: none;
}

/* Toolbar above the runtime-toggle demo */
.fieldset-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    max-width: 28rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.85rem;
    background: light-dark(#f9fafb, #1f1f23);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.fieldset-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-muted);
}

.fieldset-status[data-active] {
    color: var(--color-success-text);
}

.fieldset-status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: var(--color-border-hover);
}

.fieldset-status[data-active] .fieldset-status-dot {
    background: #22c55e;
}

/* ============================================================
   DataInteractive styles — purely consumer-defined
   ============================================================ */

.interactive-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: all 150ms ease;
}

/* Style via data attributes instead of :hover/:active/:focus */
.interactive-btn[data-hover] {
    background: light-dark(#f0f9ff, #082f49);
    border-color: light-dark(#7dd3fc, #0369a1);
    color: light-dark(#0369a1, #7dd3fc);
}

.interactive-btn[data-active] {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #fff;
    transform: scale(0.97);
}

.interactive-btn[data-focus] {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.interactive-btn[data-disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---- Link wrapper ---- */

.interactive-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--color-primary-text);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: all 150ms ease;
}

.interactive-link[data-hover] {
    background: var(--color-accent-subtle);
    color: var(--color-accent-text);
}

.interactive-link[data-active] {
    background: var(--color-accent-muted);
    color: light-dark(#1e40af, #93c5fd);
}

.interactive-link[data-focus] {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ---- Render context card ---- */

.interactive-card {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border: 2px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
    cursor: pointer;
    transition: all 200ms ease;
    font-size: 1rem;
    font-family: inherit;
}

.interactive-card[data-hover] {
    border-color: #a78bfa;
    background: var(--color-violet-subtle);
}

.interactive-card[data-active] {
    border-color: #7c3aed;
    background: var(--color-violet-muted);
    transform: scale(0.96);
}

.interactive-card[data-focus] {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
}

.card-icon {
    font-size: 1.5rem;
}

/* ---- Card grid ---- */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    width: 100%;
}

.card {
    padding: 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
    cursor: pointer;
    transition: all 150ms ease;
}

.card[data-hover] {
    border-color: #a78bfa;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
    transform: translateY(-2px);
}

.card[data-active] {
    border-color: #7c3aed;
    background: var(--color-violet-subtle);
    transform: translateY(0);
    box-shadow: none;
}

.card[data-focus] {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
}

.card-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.card-desc {
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* ---- State inspector ---- */

.inspector-target {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 2rem;
    border: 2px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-subtle);
    cursor: pointer;
    transition: all 150ms ease;
    min-width: 280px;
    font-family: inherit;
}

.inspector-target[data-hover] {
    border-color: #60a5fa;
    background: var(--color-accent-subtle);
}

.inspector-target[data-active] {
    border-color: var(--color-primary);
    background: var(--color-accent-muted);
}

.inspector-target[data-focus] {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.inspector-label {
    font-weight: 500;
}

.inspector-states {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.state-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-family: monospace;
    border-radius: 0.25rem;
    background: var(--color-fill);
    color: var(--color-text-tertiary);
    border: 1px solid var(--color-border);
}

.state-badge.state-on {
    background: var(--color-success-muted);
    color: light-dark(#166534, #86efac);
    border-color: light-dark(#86efac, #15803d);
}

/* ============================================================
   FocusTrap styles — purely consumer-defined
   ============================================================ */

.focus-trap-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    border: 2px dashed var(--color-border-strong);
    border-radius: var(--radius);
    margin-top: 1rem;
    transition: border-color 200ms ease, background 200ms ease;
}

/* Active state via data-state attribute emitted by BitBhFocusTrap */
.focus-trap-container[data-state="active"] {
    border-color: var(--color-primary);
    background: var(--color-accent-subtle);
}

.focus-trap-label {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0;
}

.focus-trap-input {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 0.4rem;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.focus-trap-input:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
}

/* ---- Slide-over panel ---- */

.slide-over-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 40;
}

.slide-over-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 22rem;
    max-width: 90vw;
    background: var(--color-surface);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    padding: 1.5rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slide-over-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.slide-over-description {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0;
}

.slide-over-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--color-text);
}

.slide-over-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: auto;
}

/* ---- Multiple regions demo ---- */

.multi-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.multi-regions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
    width: 100%;
}

@media (max-width: 640px) {
    .multi-regions {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Portal styles — purely consumer-defined
   ============================================================ */

.portal-overflow-box {
    overflow: hidden;
    height: 8rem;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    position: relative;
}

.portal-label {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0 0 0.5rem;
}

.portal-label code {
    background: var(--color-fill);
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
    font-size: 0.85em;
}

.portal-content {
    background: var(--color-accent-subtle);
    border: 1px solid var(--color-primary);
    border-radius: 0.4rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.portal-content p {
    margin: 0 0 0.25rem;
}

.portal-content p:last-child {
    margin-bottom: 0;
}

/* While portalled: pinned to a corner of the window, where the reader can see it */
.portal-content-floating {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 50;
    max-width: min(20rem, calc(100vw - 2rem));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.portal-content-floating.portal-content-alt {
    right: auto;
    left: 1rem;
}

.portal-hint {
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* ---- Tooltip demo ---- */

.portal-stacking-parent {
    overflow: hidden;
    position: relative;
    z-index: 1;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 0.5rem;
}

.portal-stacking-parent>p {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0 0 0.75rem;
}

.portal-stacking-parent>p code {
    background: var(--color-fill);
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
    font-size: 0.85em;
}

.portal-tooltip-trigger {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease;
}

.portal-tooltip-trigger:hover {
    background: var(--color-fill);
}

.portal-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-inverse);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 0.4rem;
    font-size: 0.85rem;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    pointer-events: none;
}

/* ---- Portal Group demo ---- */

.portal-group-target {
    border: 2px solid #a78bfa;
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    min-height: 6rem;
    background: var(--color-violet-subtle);
}

.portal-group-label {
    font-size: 0.85rem;
    color: var(--color-violet-text);
    margin: 0;
    font-weight: 500;
}

.portal-group-item {
    padding: 0.5rem 0.75rem;
    border-radius: 0.4rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.portal-group-item-a {
    background: var(--color-accent-muted);
    border: 1px solid #3b82f6;
}

.portal-group-item-b {
    background: var(--color-success-muted);
    border: 1px solid #22c55e;
}

/* ---- Disabled portal demo ---- */

.portal-toggle-demo {
    width: 100%;
}

.portal-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.portal-content-alt {
    background: var(--color-warning-subtle);
    border-color: #f59e0b;
}

/* ============================================================
   Responsive — tablets and below (≤ 768px)
   ============================================================ */

@media (max-width: 768px) {
    /* Combobox / Listbox — their desktop widths, capped by the screen (a percentage of the shrink-to-fit
       boxes around them would follow their content instead, and leave a wider panel hanging off them) */
    .combobox,
    .combobox-anchored {
        min-width: min(18rem, calc(100vw - 4rem));
    }

    .listbox,
    .listbox-anchored {
        min-width: min(14rem, calc(100vw - 4rem));
    }

    .combobox-options-anchored {
        min-width: min(18rem, calc(100vw - 2rem));
    }

    /* Popover panels — constrain to viewport */
    .popover-panel,
    .popover-panel-wide,
    .popover-panel-anchored {
        min-width: 0;
        max-width: calc(100vw - 2rem);
    }

    /* Menu items — constrain to viewport */
    .menu-items,
    .menu-items-wide,
    .menu-items-anchored {
        min-width: 0;
        max-width: calc(100vw - 2rem);
    }

    /* A sample's row stacks its parts; rows inside a sample keep their own layout */
    .bh-example-panel > .demo-row:not(.bh-tw-sample) {
        flex-direction: column;
        align-items: stretch;
    }

    /* Inspector target — allow shrinking on mobile */
    .inspector-target {
        min-width: 0;
        width: 100%;
    }
}

/* ============================================================
   Responsive — small phones (≤ 480px)
   ============================================================ */

@media (max-width: 480px) {
    /* Accordion — tighter padding */
    .accordion-trigger {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .accordion-body {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    /* Buttons — allow wrapping */
    :is(.bb-demo, [data-bit-bh-portal-root]) .btn {
        font-size: 0.8125rem;
        padding: 0.4rem 0.75rem;
    }
}

/* ============================================================
   Tooltip demo styles
   ============================================================ */

.tooltip {
    display: inline-block;
}

.tooltip-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 120ms ease;
}

.tooltip-trigger:hover {
    border-color: var(--color-border-hover);
}

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

.tooltip-content {
    position: relative;
    z-index: 50;
    padding: 0.4rem 0.6rem;
    background: var(--color-inverse);
    color: var(--color-on-inverse);
    font-size: 0.8rem;
    line-height: 1.2;
    border-radius: 0.35rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    pointer-events: auto;
}

.tooltip-content[hidden] {
    display: none;
}

/* The positioning engine places and rotates the arrow; only its look is ours. */
.tooltip-arrow {
    fill: var(--color-inverse);
    display: block;
}

.tooltip-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ============================================================
   Aspect Ratio styles — purely consumer-defined
   ============================================================ */

.ratio-frame {
    width: 100%;
    max-width: 28rem;
}

.ratio-frame-sm {
    max-width: 12rem;
}

.ratio-box {
    overflow: hidden;
    border-radius: 0.75rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

/* Make the media fill the ratio box */
.ratio-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Non-image content demo — the inner element fills the ratio box */
.ratio-card {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* ============================================================
   Avatar styles — purely consumer-defined
   ============================================================ */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    overflow: hidden;
    user-select: none;
    width: 3rem;
    height: 3rem;
    border-radius: 100%;
    background: var(--color-fill-strong);
    flex-shrink: 0;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    background: var(--color-fill-strong);
}

.avatar-fallback-icon {
    color: var(--color-muted);
    background: var(--color-fill);
}

/* ---- Size & shape modifiers ---- */

.avatar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar-sm {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.8rem;
}

.avatar-lg {
    width: 4rem;
    height: 4rem;
    font-size: 1.1rem;
}

.avatar-square {
    border-radius: 0.6rem;
}

/* ============================================================
   Hover Card styles — purely consumer-defined
   ============================================================ */

.hover-card {
    display: inline-block;
}

.hover-card-trigger {
    color: var(--color-primary-text);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border-radius: 0.25rem;
}

.hover-card-trigger:hover {
    text-decoration: underline;
}

.hover-card-trigger:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.hover-card-content {
    position: relative;
    z-index: 50;
    width: 20rem;
    max-width: calc(100vw - 1rem);
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.6rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.hover-card-content[hidden] {
    display: none;
}

.hover-card-content[data-state="open"] {
    animation: hc-fade 150ms ease;
}

@keyframes hc-fade {
    from {
        opacity: 0;
        transform: translateY(2px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Arrow - the positioning engine places it on the resolved side and rotates it
   to face the trigger (data-side); only its look is ours. */
.hover-card-arrow {
    fill: var(--color-border);
    filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.25));
}

/* Profile card content */
.hc-profile {
    display: flex;
    gap: 0.85rem;
}

.hc-avatar {
    flex-shrink: 0;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 100%;
    background: var(--color-inverse);
    color: #fff;
    font-weight: 700;
}

.hc-name {
    font-weight: 700;
}

.hc-handle {
    color: var(--color-muted);
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.hc-bio {
    font-size: 0.875rem;
    line-height: 1.4;
    margin: 0 0 0.5rem;
}

.hc-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--color-text-tertiary);
}

.hc-meta strong {
    color: var(--color-text);
}

.hover-card-row {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ============================================================
   Checkbox group with "select all" — purely consumer-defined
   (Checkbox page → "Group with select all")
   ============================================================ */

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-group-items {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-left: 1.6rem;
}

/* The checkbox button holds the box and the label text (its accessible name) */
.checkbox-row {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 0.55rem;
    border-radius: 0.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-row:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.checkbox-row-all {
    font-weight: 600;
}

.checkbox-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
    border: 1px solid var(--color-border-control);
    border-radius: 0.25rem;
    background: var(--color-surface);
    color: #fff;
    transition: background 120ms ease, border-color 120ms ease;
}

.checkbox-row:hover .checkbox-box {
    border-color: var(--color-border-control-hover);
}

.checkbox-row[data-state="checked"] .checkbox-box,
.checkbox-row[data-state="indeterminate"] .checkbox-box {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

/* BitBhCheckboxIndicator mirrors the checkbox's data-state, so CSS picks the glyph */
.checkbox-indicator {
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
}

.checkbox-indicator[data-state="checked"]::before {
    content: "\2713";
}

.checkbox-indicator[data-state="indeterminate"]::before {
    content: "\2013";
}

/* ============================================================
   Virtualized Listbox — purely consumer-defined
   (Listbox page → "Large lists (virtualized)")
   ============================================================ */

/* BitBhListboxButton without content: chevron via CSS, muted placeholder */
.listbox-button-auto::after {
    content: "\25BE";
    color: var(--color-muted);
}

.listbox-button-auto[data-placeholder] {
    color: var(--color-muted);
}

/* Fixed-height scroll container, positioned by Anchor (position: fixed) */
.listbox-virtual {
    z-index: 9999;
    width: var(--button-width);
    height: 16rem;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.listbox-virtual[hidden] {
    display: none;
}

/* Data-driven options carry no class — target the role.
   Each option must be exactly ItemSize (36px) tall. */
.listbox-virtual > [role="option"] {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 36px;
    box-sizing: border-box;
    padding: 0 0.65rem;
    border-radius: 0.35rem;
    font-size: 0.9rem;
    color: var(--color-text);
    white-space: nowrap;
    cursor: pointer;
}

.listbox-virtual > [role="option"][data-active] {
    background: var(--color-accent-subtle);
}

.listbox-virtual > [role="option"][data-selected] {
    font-weight: 600;
}

.listbox-virtual-check {
    width: 1rem;
    color: var(--color-primary-text);
    font-weight: 700;
}

/* ============================================================
   Virtualized Combobox — purely consumer-defined
   (Combobox page → "Large lists (virtualized)")
   ============================================================ */

.combobox-virtual {
    z-index: 9999;
    width: 18rem;
    max-height: 16rem;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.combobox-virtual[hidden] {
    display: none;
}

.combobox-virtual > [role="option"] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    height: 36px;
    box-sizing: border-box;
    padding: 0 0.65rem;
    border-radius: 0.35rem;
    font-size: 0.9rem;
    color: var(--color-text);
    white-space: nowrap;
    cursor: pointer;
}

.combobox-virtual > [role="option"][data-active] {
    background: var(--color-accent-subtle);
}

.combobox-virtual > [role="option"][data-selected] {
    font-weight: 600;
}

/* ============================================================
   Virtualized options of different heights — purely consumer-defined
   (Listbox and Combobox pages → "Options of different heights (virtualized)")
   ============================================================ */

/* Scroll containers positioned by Anchor (position: fixed) */
.listbox-variable,
.combobox-variable {
    z-index: 9999;
    width: 20rem;
    max-width: calc(100vw - 2rem);
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.listbox-variable {
    height: 18rem;
}

.combobox-variable {
    max-height: 18rem;
}

.listbox-variable[hidden],
.combobox-variable[hidden] {
    display: none;
}

/* No height: every option is as tall as its content (VariableItemSize measures them). */
.listbox-variable > [role="option"],
.combobox-variable > [role="option"] {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.65rem;
    border-radius: 0.35rem;
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
}

.listbox-variable > [role="option"][data-active],
.combobox-variable > [role="option"][data-active] {
    background: var(--color-accent-subtle);
}

.listbox-variable > [role="option"][data-selected] .listbox-variable-title,
.combobox-variable > [role="option"][data-selected] .combobox-variable-title {
    color: var(--color-accent-text);
}

.listbox-variable-title,
.combobox-variable-title {
    font-weight: 600;
}

.listbox-variable-details,
.combobox-variable-excerpt {
    color: var(--color-text-tertiary);
    font-size: 0.8rem;
    line-height: 1.35;
}

/* ============================================================
   EditForm validation — purely consumer-defined
   (Field page → "EditForm validation")
   ============================================================ */

.validation-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 24rem;
}

/* BitBhLabel emits data-required / data-invalid from its field */
.validation-form .field-label[data-required]::after {
    content: " *";
    color: var(--color-danger-text);
}

.validation-form .field-label[data-invalid] {
    color: var(--color-danger-text);
}

/* BitBhErrorMessage: rendered only while the field is invalid */
.validation-message {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    color: var(--color-danger-text);
    font-size: 0.8rem;
    font-weight: 500;
}

.validation-message::before {
    content: "!";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.95rem;
    height: 0.95rem;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
}

/* Radio group rendered as pills — the radio's text is its accessible name */
.validation-radios {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.validation-radio {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease;
}

.validation-radio:hover {
    border-color: var(--color-border-hover);
}

.validation-radio:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.validation-radio[data-state="checked"] {
    border-color: var(--color-primary);
    background: var(--color-accent-subtle);
}

.validation-radios[aria-invalid="true"] .validation-radio {
    border-color: light-dark(#fca5a5, #991b1b);
}

.validation-radio-dot {
    width: 0.9rem;
    height: 0.9rem;
    box-sizing: border-box;
    border: 1px solid var(--color-border-hover);
    border-radius: 999px;
    background: var(--color-surface);
}

.validation-radio[data-state="checked"] .validation-radio-dot {
    border: 4px solid var(--color-primary);
}

/* Checkbox + label row */
.validation-check {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.validation-check-label {
    font-size: 0.875rem;
    cursor: pointer;
}

.validation-form .checkbox[data-invalid] {
    border-color: var(--color-danger);
}

.validation-actions {
    display: flex;
    gap: 0.5rem;
}

/* The live region stays rendered; style it only when it has content */
.validation-success:not(:empty) {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--color-success-border);
    border-radius: var(--radius);
    background: var(--color-success-subtle);
    color: light-dark(#166534, #86efac);
    font-size: 0.875rem;
}

/* ============================================================
   Code: SyntaxHighlighter's tokens on the kit's code surface

   CodeBlock colours every Razor and CSS tab with tok-* spans. The
   kit styles four kinds (keyword, string, comment, parameter); the
   highlighter tells more apart, so the extra ones get colours of
   their own here, light and dark, picked to hold their contrast on
   --bb-code-bg in both themes. The same rules as the Bdnd, Blow and
   Balette demos, which share the highlighter.
   ============================================================ */

:root {
    --demo-code-type: #8250DF;
    --demo-code-fn: #795E26;
    --demo-code-number: #CF222E;
    --demo-code-razor: #A21CAF;
}

:root[bit-theme="dark"] {
    --demo-code-type: #D2A8FF;
    --demo-code-fn: #DCDCAA;
    --demo-code-number: #FF7B72;
    --demo-code-razor: #F0ABFC;
}

.bb-code .tok-com { color: var(--bb-code-comment); font-style: italic; }
.bb-code .tok-pun { color: var(--bb-code-comment); }
.bb-code .tok-tag,
.bb-code .tok-key { color: var(--bb-code-keyword); }
.bb-code .tok-str { color: var(--bb-code-string); }
.bb-code .tok-attr { color: var(--bb-code-param); }
.bb-code .tok-type { color: var(--demo-code-type); }
.bb-code .tok-fn { color: var(--demo-code-fn); }
.bb-code .tok-num { color: var(--demo-code-number); }
.bb-code .tok-raz { color: var(--demo-code-razor); }

/* ============================================================
   Examples (Shared/DemoBlock.razor)

   One example: its h2 (which the "on this page" rail lists), the
   paragraph explaining it, and the kit's sample surface (.bb-demo)
   holding the Preview / Razor / CSS tabs. The tab list is drawn as
   the surface's title bar, the way .bb-demo-bar is.
   ============================================================ */

.bh-example {
    margin: 0 0 2.5rem;
}

.bh-example:last-child {
    margin-bottom: 0;
}

.bh-example > h2 {
    margin-bottom: .375rem;
}

.bh-example-desc {
    max-width: var(--bb-measure);
    margin: 0 0 1rem;
    color: var(--bb-text-muted);
}

.bh-example-frame {
    margin-bottom: 0;
}

.bh-example-tabs {
    margin: -1.25rem -1.25rem 1.25rem;
    padding: 0 .5rem;
    background: var(--bb-surface-sunken);
    border-radius: calc(var(--bb-radius-xl) - 1px) calc(var(--bb-radius-xl) - 1px) 0 0;
}

/* A panel is a tab stop of its own (the library makes it focusable, so a
   panel with nothing focusable in it is still reachable); the radius lets
   the kit's focus ring hug it. */
.bh-example-panel {
    min-width: 0;
    border-radius: var(--bb-radius);
}

.bh-example-panel > .bb-code {
    margin: 0;
}

/* ============================================================
   Styling switch (Shared/SectionSwitcher.razor)

   Moves between a component's CSS and Tailwind pages, drawn as the
   kit's segmented control. The kit styles a segmented control's
   <button> children; these two are links - each styling is a page
   of its own - so the same look is given to <a> here.

   It sticks under the header, so the other styling stays one click
   away however far down the page the reader is. Sticky holds only
   inside the parent, so the switch is a child of the page column
   (.bb-docs-content) rather than of the short page intro, and it
   takes the header's frosted surface so the examples scroll under
   both alike.
   ============================================================ */

.bh-styling-switch {
    position: sticky;
    top: var(--bb-header-height);
    /* Over the examples' in-flow stacking (z-index 1 and 10), under every floating layer they
       open - dropdowns and their click-outside overlays (30, 31), tooltips, hover cards and
       slide-overs (40, 50) - so an open popup is never cut by the bar. */
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
    padding-block: .5rem;
    margin-bottom: 2rem;
    background: color-mix(in srgb, var(--bb-bg) 80%, transparent);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* The switch's own padding is the gap under the subtitle it belongs to, so the intro gives up most
   of its bottom margin; the switch's margin carries the rest down to the first example. */
.bb-intro:has(+ .bh-styling-switch) {
    margin-bottom: .5rem;
}

/* A heading scrolled to has to clear the switch as well as the header: app.css leaves it the
   header's height plus 1.5rem, and the switch is about 3.25rem tall. site.js reads this margin to
   decide which section the rail marks as current. The link site.js hangs off each heading takes the
   same margin: Shift+Tab scrolls it into view by itself, and would leave it under the bar (WCAG 2.4.11). */
.bb-docs-content:has(> .bh-styling-switch) :is([id], .bb-anchor) {
    scroll-margin-top: calc(var(--bb-header-height) + 4.75rem);
}

.bh-styling-switch-label {
    font-size: var(--fl-font-size-200);
    color: var(--bb-text-muted);
}

.bb-segmented > a {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    padding: .1875rem .75rem;
    border-radius: calc(var(--bb-radius) - 1px);
    color: var(--bb-text-muted);
    font-size: var(--fl-font-size-200);
    font-weight: var(--fl-weight-medium);
    text-decoration: none;
    transition: background var(--bb-motion-duration-short) var(--bb-motion-easing),
                color var(--bb-motion-duration-short) var(--bb-motion-easing);
}

.bb-segmented > a:hover {
    color: var(--bb-text);
    background: var(--bb-surface-hover);
    text-decoration: none;
}

.bb-segmented > a.active {
    background: var(--bb-surface);
    color: var(--bb-primary);
    font-weight: var(--fl-weight-semibold);
    box-shadow: var(--bb-shadow-card);
}

/* ============================================================
   Tailwind samples

   The kit's element rules - h1-h6, p, a, code, kbd, the form fields
   - are written outside any cascade layer, and an unlayered rule
   beats every layered one, Tailwind's utilities and preflight
   included: a sample's text-lg, mb-4 or rounded-lg would lose to
   them. Inside a Tailwind sample (DemoBlock's .bh-tw-sample, the
   Tailwind home page) every declaration of this layer is rolled
   back with revert-layer, so an element looks the way its utility
   classes say - the classes its Razor tab shows. The same goes for
   what such a page renders into the portal outlet - its dialogs and
   menus - and for its toast viewports, which render in place.

   Last in the file, so it also outranks this file's own rules of
   the same weight - the transition demo's .transition-all and
   friends share their names with Tailwind utilities. a:hover is
   named on its own because the kit's rule for it outweighs a lone
   class. The anchor link site.js hangs off a heading (.bb-anchor)
   is the site's, not the sample's, so it keeps the kit's look;
   :where() keeps that exception from adding weight.
   ============================================================ */

.bh-tw-sample :not(:where(.bb-anchor, .bb-anchor *)),
.bh-tw-sample a:not(:where(.bb-anchor)):hover,
:root:has(.bh-tw-sample) [data-bit-bh-portal-root] *,
:root:has(.bh-tw-sample) [data-bit-bh-toast-region] * {
    all: revert-layer;
}

/* The portal outlet is one layer over the site chrome: the kit's sticky header is z-index 1000 in the
   root stacking context, and the modals and floating panels portalled here (z-index 50 and the like,
   inside the outlet) would otherwise sit under it - the header left undimmed and clickable over a
   dialog's backdrop. position: relative leaves the fixed-positioned layers in it placed against the
   viewport. */
[data-bit-bh-portal-root] {
    position: relative;
    z-index: 1001;
}

.bh-tw-sample ::placeholder,
:root:has(.bh-tw-sample) [data-bit-bh-portal-root] ::placeholder,
:root:has(.bh-tw-sample) [data-bit-bh-toast-region] ::placeholder {
    color: revert-layer;
}
