﻿/* ============================================================
   Demo site styles — demonstrating how to style headless components.
   The bit Bheadless library ships ZERO CSS.
   Everything here is consumer-authored.
   ============================================================ */

/* 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. */
@layer base, theme, components, utilities;

@layer base {

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

/* ---- Theme tokens ----
   wwwroot/theme.js sets <html data-theme="light|dark"> before the first paint.
   Each token is written as light-dark(<light>, <dark>), resolved by the
   color-scheme below, so the dark theme is a single switch on the root. */

:root {
    color-scheme: light;

    /* 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);
    --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;
}

:root[data-theme="dark"] {
    color-scheme: dark;
}

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ---- Page layout ---- */

.demo-page {
    max-width: 52rem;
    margin: 0 auto;
    padding: 3rem 1.5rem 6rem;
}

.demo-header {
    margin-bottom: 3rem;
}

.demo-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.demo-header p {
    color: var(--color-muted);
    margin-top: 0.5rem;
    font-size: 1.05rem;
}

.demo-section {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.demo-section h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.demo-section>p {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.demo-section>p code {
    /* Darker than the muted paragraph text: keeps 4.5:1 on the tinted background. */
    color: var(--color-text-secondary);
    background: var(--color-fill);
    padding: 0.15em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.85em;
}

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

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

.demo-attributes {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--color-muted);
}

.demo-attributes code {
    background: var(--color-fill);
    padding: 0.1em 0.35em;
    border-radius: 0.2rem;
    font-size: 0.9em;
}

.demo-code {
    margin-top: 1rem;
    background: var(--color-code-bg);
    color: #a1a1aa;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    overflow-x: auto;
}

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

.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;
}

.btn:hover {
    background: var(--color-fill);
    border-color: var(--color-border-strong);
}

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

.btn:active {
    background: var(--color-fill-strong);
}

/* Data-attribute styling hooks from bit Bheadless */
.btn[data-disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

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

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

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn-link {
    background: transparent;
    border-color: transparent;
    color: var(--color-primary-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-link:hover {
    color: var(--color-accent-text);
    background: var(--color-accent-subtle);
}

.btn-toggle {
    min-width: 4rem;
    justify-content: center;
    background: var(--color-surface);
}

.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
   ============================================================ */

/* ---- Section divider between component demos ---- */

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

.demo-component-heading {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

/* ---- 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 ---- */

.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);
}


/* ============================================================
   Page layout — sidebar + content
   ============================================================ */

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    flex: 0 0 16rem;
    border-right: 1px solid var(--color-border);
    background: var(--color-surface);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
}

.content {
    flex: 1 1 auto;
    min-width: 0;
}

.demo-page {
    max-width: 52rem;
    margin: 0 auto;
    padding: 3rem 1.5rem 6rem;
}

/* ---- Sidebar nav ---- */

.nav-menu {
    padding: 0 1rem;
    font-size: 0.9rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 0 1rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}

/* ---- Theme switch (ThemeToggle.razor) ---- */

.theme-toggle {
    all: unset;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.375rem;
    color: var(--color-muted);
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}

.theme-toggle:hover {
    background: var(--color-fill);
    color: var(--color-text);
}

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

.theme-toggle-icon {
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Sun in light, moon in dark. Keyed off <html data-theme>, not the toggle's
   own state, so it is right before the circuit is interactive. */
.theme-toggle-moon,
:root[data-theme="dark"] .theme-toggle-sun {
    display: none;
}

:root[data-theme="dark"] .theme-toggle-moon {
    display: block;
}

.nav-brand a {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
    transition: background 120ms ease, color 120ms ease;
}

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

.nav-link.active {
    background: var(--color-primary);
    color: white;
}

/* ---- Component list on the home page ---- */

.component-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.component-list li {
    font-size: 0.95rem;
    color: var(--color-muted);
}

.component-list a {
    color: var(--color-primary-text);
    font-weight: 600;
    text-decoration: none;
}

.component-list a:hover {
    text-decoration: underline;
}

/* ============================================================
   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] {
    background: var(--color-subtle);
}

.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;
}

/* ============================================================
   Code-block labelling (Razor / CSS) inside DemoBlock
   ============================================================ */

.demo-codeblock {
    margin-top: 1rem;
}

.demo-codeblock-label {
    display: inline-block;
    background: #27272a;
    color: #d4d4d8;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius) var(--radius) 0 0;
}

.demo-codeblock-label+.demo-code {
    margin-top: 0;
    border-top-left-radius: 0;
}

/* ============================================================
   DemoBlock tabbed layout — dogfoods HTabGroup
   ============================================================ */

.demo-tabs {
    width: 100%;
    display: flex;
    flex-direction: column;
}

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

.demo-tab {
    all: unset;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 150ms ease, border-color 150ms ease;
    box-sizing: border-box;
}

.demo-tab:hover {
    color: var(--color-text, #18181b);
}

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

.demo-tab[data-state="active"] {
    color: var(--color-primary-text);
    border-bottom-color: var(--color-primary);
}

.demo-tab-panels {
    margin-top: 1rem;
}

.demo-tab-panel {
    min-height: 0;
}

.demo-tab-panel .demo-code {
    margin-top: 0;
}

/* ============================================================
   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-strong);
    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-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-strong);
    border-radius: 999px;
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color 120ms ease;
    flex-shrink: 0;
}

.radio:hover {
    border-color: var(--color-border-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 ---- */

.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;
    min-width: 14rem;
    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
   ============================================================ */

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

.dialog-panel {
    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 ---- */

.btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}

.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
   ============================================================ */

.alert-overlay {
    background: rgba(0, 0, 0, 0.5);
}

.alert-content {
    /* The library centres the content in the viewport by default
       (position:fixed). These rules just give it a surface. */
    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);
}

.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);
}

.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: #93c5fd;
}

/* ---- 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-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;
    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;
}

/* ---- 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;
}

.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;
}

.scale-95 {
    transform: scale(0.95);
}

.scale-100 {
    transform: scale(1);
}

.translate-y-4 {
    transform: translateY(1rem);
}

.translate-y-0 {
    transform: translateY(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;
}

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

/* ============================================================
   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="true"] {
    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="true"] .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;
}

.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;
}

/* ---- 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;
}

/* ============================================================
   Mobile header — visible only on small screens
   ============================================================ */

.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 40;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.mobile-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.mobile-header .theme-toggle {
    margin-left: auto;
}

.mobile-menu-toggle {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 120ms ease;
}

.mobile-menu-toggle:hover {
    background: var(--color-fill);
}

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

.hamburger-icon {
    display: block;
    width: 1.25rem;
    height: 2px;
    background: var(--color-text);
    position: relative;
    border-radius: 1px;
}

.hamburger-icon::before,
.hamburger-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--color-text);
    border-radius: 1px;
}

.hamburger-icon::before {
    top: -6px;
}

.hamburger-icon::after {
    top: 6px;
}

/* ---- Sidebar backdrop (mobile overlay) ---- */

.sidebar-backdrop {
    display: none;
}

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

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 50;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 250ms ease;
        box-shadow: none;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 45;
        background: rgba(0, 0, 0, 0.3);
    }

    .page {
        flex-direction: column;
    }

    .content {
        min-height: 0;
    }

    /* Reduce page padding on mobile */
    .demo-page {
        padding: 1.5rem 1rem 4rem;
    }

    .demo-header h1 {
        font-size: 1.5rem;
    }

    .demo-header p {
        font-size: 0.95rem;
    }

    .demo-section {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    .demo-component-heading {
        font-size: 1.25rem;
    }

    /* Demo code blocks — allow horizontal scroll */
    .demo-code {
        padding: 0.75rem 1rem;
        font-size: 0.75rem;
    }

    /* Vertical tabs — stack on mobile */
    .tabs[data-orientation="vertical"] {
        flex-direction: column;
        gap: 0;
    }

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

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

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

    /* Combobox / Listbox — full width on mobile */
    .combobox,
    .combobox-anchored,
    .listbox,
    .listbox-anchored {
        min-width: 0;
        width: 100%;
    }

    /* 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);
    }

    /* Demo row — stack items vertically when needed */
    .demo-row {
        flex-direction: column;
        align-items: stretch;
    }

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

    /* Component list on home page */
    .component-list li {
        font-size: 0.875rem;
    }
}

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

@media (max-width: 480px) {
    .demo-page {
        padding: 1rem 0.75rem 3rem;
    }

    .demo-header {
        margin-bottom: 2rem;
    }

    .demo-header h1 {
        font-size: 1.35rem;
    }

    .demo-section {
        padding: 0.75rem;
        border-radius: 0.375rem;
    }

    .demo-tab {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    /* 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 */
    .btn {
        font-size: 0.8125rem;
        padding: 0.4rem 0.75rem;
    }

    /* Radio group cards */
    .radio-card {
        min-width: 0;
    }
}


/* ============================================================
   Section switcher (header toggle between CSS / Tailwind pages)
   ============================================================ */
.section-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    font-size: 0.78rem;
}

.section-switcher-label {
    color: var(--color-muted);
    font-weight: 500;
    padding: 0 0.35rem 0 0.5rem;
}

.section-switcher-link {
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    color: var(--color-muted);
    text-decoration: none;
    font-weight: 600;
    transition: background 120ms ease, color 120ms ease;
}

.section-switcher-link:hover {
    color: var(--color-text);
    background: var(--color-fill);
}

.section-switcher-link-active {
    background: var(--color-primary);
    color: #fff;
}

.section-switcher-link-active:hover {
    color: #fff;
    background: var(--color-primary-hover);
}

/* ---- Sticky behaviour ----
   Keep the implementation toggle reachable while scrolling long demo pages.
   The page header is collapsed with display:contents (only when it actually
   holds a switcher) so the sticky element's containing block becomes the
   full-height page wrapper instead of the short header — otherwise it would
   unstick the moment the title scrolled out of view. */
.demo-header:has(.section-switcher-sticky),
header:has(.section-switcher-sticky) {
    display: contents;
}

.section-switcher-sticky {
    position: sticky;
    top: 0.75rem;
    z-index: 20;
    margin-bottom: 2rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {

    /* Sit just below the sticky mobile header. */
    .section-switcher-sticky {
        top: 4rem;
    }
}

/* ============================================================
   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;
}

.tooltip-arrow {
    fill: var(--color-text);
    display: block;
}

.tooltip-content[data-anchor^="top"] .tooltip-arrow {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
}

.tooltip-content[data-anchor^="bottom"] .tooltip-arrow {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
}

.tooltip-content[data-anchor^="left"] .tooltip-arrow {
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
}

.tooltip-content[data-anchor^="right"] .tooltip-arrow {
    position: absolute;
    left: -7px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

.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 — positioned from the resolved data-anchor side */
.hover-card-arrow {
    fill: var(--color-border);
    filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.25));
}

.hover-card-content[data-anchor^="top"] .hover-card-arrow {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
}

.hover-card-content[data-anchor^="bottom"] .hover-card-arrow {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
}

.hover-card-content[data-anchor^="left"] .hover-card-arrow {
    position: absolute;
    right: -9px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
}

.hover-card-content[data-anchor^="right"] .hover-card-arrow {
    position: absolute;
    left: -9px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

/* 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-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-strong);
    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-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;
}

/* ============================================================
   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;
}
/* Inline code inside live demos (not code blocks): readable on tinted panels. */
.demo-page :not(pre) > code { color: var(--color-text-secondary); }
