/* ── PRIMITIVES ─────────────────────────────────────────────── */
:root {
    /* Orange ramp */
    --sd-orange-10: color(srgb 1 0.99 0.98);
    /* #fffcfa */
    --sd-orange-20: color(srgb 1 0.98 0.96);
    /* #fffaf5 */
    --sd-orange-50: color(srgb 1 0.95 0.9);
    /* #fff2e6 */
    --sd-orange-100: color(srgb 1 0.9 0.8);
    /* #ffe6cc */
    --sd-orange-200: color(srgb 1 0.8 0.6);
    /* #ffcc99 */
    --sd-orange-300: color(srgb 0.964 0.7 0.436);
    /* #f6b36f */
    --sd-orange-400: color(srgb 0.904 0.6 0.296);
    /* #e7994b */
    --sd-orange-500: color(srgb 0.81 0.5 0.19);
    /* #cf8030 */
    --sd-orange-600: color(srgb 0.652 0.4 0.148);
    /* #a66626 */
    --sd-orange-800: color(srgb 0.336 0.2 0.064);
    /* #563310 */
    --sd-orange-950: color(srgb 0.084 0.05 0.016);
    /* #150d04 */

    /* Purple ramp */
    --sd-purple-10: color(srgb 0.9867 0.98 1);
    /* #fcfaff */
    --sd-purple-20: color(srgb 0.9733 0.96 1);
    /* #f8f5ff */
    --sd-purple-50: color(srgb 0.9333 0.9 1);
    /* #eee6ff */
    --sd-purple-100: color(srgb 0.8667 0.8 1);
    /* #ddccff */
    --sd-purple-200: color(srgb 0.7333 0.6 1);
    /* #bb99ff */
    --sd-purple-300: color(srgb 0.612 0.436 0.964);
    /* #9c6ff6 */
    --sd-purple-400: color(srgb 0.4987 0.296 0.904);
    /* #7f4be7 */
    --sd-purple-500: color(srgb 0.3967 0.19 0.81);
    /* #6530cf */
    --sd-purple-600: color(srgb 0.316 0.148 0.652);
    /* #5126a6 */
    --sd-purple-700: color(srgb 0.232 0.096 0.504);
    /* #3b1881 */
    --sd-purple-950: color(srgb 0.0387 0.016 0.084);
    /* #0a0415 */

    /* Neutral ramp */
    --sd-neutral-10: color(srgb 0.9925 0.99 0.9875);
    /* #fdfcfc */
    --sd-neutral-20: color(srgb 0.985 0.98 0.975);
    /* #fbfaf9 */
    --sd-neutral-40: color(srgb 0.968 0.96 0.952);
    /* #f7f5f3 */
    --sd-neutral-50: color(srgb 0.9575 0.95 0.9425);
    /* #f4f2f0 */
    --sd-neutral-80: color(srgb 0.932 0.9196 0.908);
    /* #f4f2f0 */
    --sd-neutral-100: color(srgb 0.91 0.9 0.89);
    /* #e8e6e3 */
    --sd-neutral-200: color(srgb 0.82 0.8 0.78);
    /* #d1ccc7 */
    --sd-neutral-300: color(srgb 0.73 0.7 0.67);
    /* #bab3ab */
    --sd-neutral-400: color(srgb 0.64 0.6 0.56);
    /* #a3998f */
    --sd-neutral-500: color(srgb 0.55 0.5 0.45);
    /* #8c8073 */
    --sd-neutral-600: color(srgb 0.44 0.4 0.36);
    /* #70665c */
    --sd-neutral-700: color(srgb 0.33 0.3 0.27);
    /* #544d45 */
    --sd-neutral-800: color(srgb 0.22 0.2 0.18);
    /* #38332e */
    --sd-neutral-850: color(srgb 0.165 0.15 0.135);
    /* #2a2622 */
    --sd-neutral-900: color(srgb 0.11 0.1 0.09);
    /* #1c1a17 */
    --sd-neutral-920: color(srgb 0.088 0.08 0.072);
    /* #161412 */
    --sd-neutral-950: color(srgb 0.055 0.05 0.045);
    /* #0e0d0b */
    --sd-neutral-980: color(srgb 0.022 0.02 0.018);
    /* #060505 */
    --sd-neutral-990: color(srgb 0.011 0.01 0.009);
    /* #030302 */

    /* Red ramp */
    --sd-red-25: color(srgb 1 0.98 0.98);
    /* #fffafa */
    --sd-red-50: color(srgb 1 0.92 0.92);
    /* #ffebeb */
    --sd-red-100: color(srgb 1 0.84 0.84);
    /* #ffd6d6 */
    --sd-red-200: color(srgb 1 0.68 0.68);
    /* #ffadad */
    --sd-red-300: color(srgb 0.9676 0.4924 0.4924);
    /* #f77e7e */
    --sd-red-400: color(srgb 0.9468 0.2932 0.2932);
    /* #f14b4b */
    --sd-red-500: color(srgb 0.8176 0.2224 0.2224);
    /* #d03939 */
    --sd-red-600: color(srgb 0.652 0.148 0.148);
    /* #a62626 */
    --sd-red-700: color(srgb 0.504 0.096 0.096);
    /* #811818 */

    /* Green ramp */
    --sd-green-400: color(srgb 0.24 0.96 0.636);
    /* #3df5a2 */
    --sd-green-500: color(srgb 0.05 0.95 0.545);
    /* #0df28b */
    --sd-green-600: color(srgb 0.06 0.74 0.434);
    /* #0fbd6f */
    --sd-green-700: color(srgb 0.06 0.54 0.324);
    /* #0f8a53 */

    /* Blue ramp */
    --sd-blue-400: color(srgb 0 0.5333 0.8);
    /* #0088cc */
    --sd-blue-500: color(srgb 0.05 0.65 0.95);
    /* #0da6f2 */
    --sd-blue-600: color(srgb 0.04 0.52 0.76);
    /* #0a85c2 */

    /* Semantic status */
    --sd-primary: var(--sd-purple-400);
    --sd-primary-trans: color-mix(in srgb, var(--sd-primary) 15%, transparent);

    --sd-success: var(--sd-green-700);
    --sd-success-trans: color-mix(in srgb, var(--sd-green-500) 15%, transparent);

    --sd-warning: var(--sd-orange-500);
    --sd-warning-trans: color-mix(in srgb, var(--sd-warning) 15%, transparent);

    --sd-danger: var(--sd-red-400);
    --sd-danger-trans: color-mix(in srgb, var(--sd-danger) 15%, transparent);

    --sd-info: var(--sd-blue-600);
    --sd-info-trans: color-mix(in srgb, var(--sd-blue-500) 15%, transparent);

    --sd-neutral: var(--sd-neutral-500);
    --sd-neutral-trans: color-mix(in srgb, var(--sd-neutral) 15%, transparent);

    /* Shape */
    --sd-radius-xs: 3px;
    --sd-radius-sm: 6px;
    --sd-radius: 10px;
    --sd-radius-lg: 16px;
    --sd-radius-full: 9999px;

    /* Motion */
    --sd-ease: 140ms ease;
    --sd-ease-out: 200ms ease-out;

    /* Typography */
    --sd-font: 'IBM Plex Sans VF', sans-serif;
    --sd-serif: Charter, 'Bitstream Charter', Georgia, serif;
    --sd-mono: 'IBM Plex Mono VF', 'IBM Plex Mono', ui-monospace, monospace;
    --sd-mono-serif: 'Monaspace Xenon VF', monospace;
    --sd-font-size: 16px;
    --sd-line-height: 1.5;
    --sidebar-width: 300px;
}


/* ── SEMANTIC ALIASES ────────────────────────────────────────── */
/* Light default when no data-theme is set */
:root {
    color-scheme: light;
    /* Backgrounds */
    --bg: var(--sd-neutral-40);
    --bg-tinted: var(--sd-purple-20);
    --bg-raised: var(--sd-neutral-10);
    --bg-sunken: var(--sd-neutral-80);
    --bg-strong: white;

    /* Borders */
    --border: color-mix(in srgb, var(--sd-neutral-600) 30%, transparent);

    --border-focus: var(--sd-orange-800);
    --border-strong: var(--sd-neutral-600);

    /* Text */
    --text: var(--sd-neutral-900);
    --text-muted: var(--sd-neutral-700);
    --text-faint: var(--sd-neutral-500);
    --text-invert: #ffffff;
    --text-strong: #000;

    --primary: var(--sd-purple-400);
    --primary-hover: var(--sd-purple-600);
    --primary-active: var(--sd-purple-700);
    --primary-subtle: var(--sd-purple-100);
    --primary-text: var(--sd-purple-600);

    --shadow-sm: 0 1px 4px color-mix(in srgb, var(--sd-neutral) 40%, transparent);
    --shadow: 0 4px 14px color-mix(in srgb, var(--sd-neutral) 35%, transparent);
    --shadow-lg: 0 10px 36px color-mix(in srgb, var(--sd-neutral) 30%, transparent);
}


/* ── AUTO MODE — follows OS preference when no data-theme is set ─ */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        /* Backgrounds */
        --bg: var(--sd-neutral-900);
        --bg-tinted: var(--sd-purple-950);
        --bg-raised: var(--sd-neutral-950);
        --bg-sunken: var(--sd-neutral-850);
        --bg-strong: black;

        /* Text */
        --text: var(--sd-neutral-100);
        --text-muted: var(--sd-neutral-200);
        --text-faint: var(--sd-neutral-400);
        --text-strong: #fff;

        /* shift to lighter ramp steps for contrast on dark bg */
        --primary: var(--sd-purple-400);
        --primary-hover: var(--sd-purple-500);
        --primary-active: var(--sd-purple-600);
        --primary-subtle: var(--sd-primary-trans);
        --primary-text: var(--sd-purple-300);

        --sd-danger: var(--sd-red-500);

        --shadow-sm: 0 1px 4px black;
        --shadow: 0 4px 14px black;
        --shadow-lg: 0 10px 36px black;
    }
}


/* ── EXPLICIT OVERRIDES — win over the media query ───────────── */
/* Same specificity as :root, later in source, so data-theme wins */
[data-theme="light"] {
    color-scheme: light;
    /* Backgrounds */
    --bg: var(--sd-neutral-40);
    --bg-tinted: var(--sd-purple-20);
    --bg-raised: var(--sd-neutral-10);
    --bg-sunken: var(--sd-neutral-80);
    --bg-strong: white;

    /* Borders */
    --border: color-mix(in srgb, var(--sd-neutral-600) 30%, transparent);

    --border-focus: var(--sd-orange-800);
    --border-strong: var(--sd-neutral-600);

    /* Text */
    --text: var(--sd-neutral-900);
    --text-muted: var(--sd-neutral-700);
    --text-faint: var(--sd-neutral-500);
    --text-invert: #ffffff;
    --text-strong: #000;

    --primary: var(--sd-purple-400);
    --primary-hover: var(--sd-purple-600);
    --primary-active: var(--sd-purple-700);
    --primary-subtle: var(--sd-purple-100);
    --primary-text: var(--sd-purple-600);

    --shadow-sm: 0 1px 4px color-mix(in srgb, var(--sd-neutral) 40%, transparent);
    --shadow: 0 4px 14px color-mix(in srgb, var(--sd-neutral) 35%, transparent);
    --shadow-lg: 0 10px 36px color-mix(in srgb, var(--sd-neutral) 30%, transparent);
}

[data-theme="dark"] {
    color-scheme: dark;
    /* Backgrounds */
    --bg: var(--sd-neutral-900);
    --bg-tinted: var(--sd-purple-950);
    --bg-raised: var(--sd-neutral-950);
    --bg-sunken: var(--sd-neutral-850);
    --bg-strong: black;

    /* Text */
    --text: var(--sd-neutral-100);
    --text-muted: var(--sd-neutral-200);
    --text-faint: var(--sd-neutral-400);
    --text-strong: #fff;

    /* shift to lighter ramp steps for contrast on dark bg */
    --primary: var(--sd-purple-400);
    --primary-hover: var(--sd-purple-500);
    --primary-active: var(--sd-purple-600);
    --primary-subtle: var(--sd-primary-trans);
    --primary-text: var(--sd-purple-300);

    --sd-danger: var(--sd-red-500);

    --shadow-sm: 0 1px 4px black;
    --shadow: 0 4px 14px black;
    --shadow-lg: 0 10px 36px black;
}


/* ── COMPONENT TOKENS (derived, no raw values) ───────────────── */
:root {
    /* Sidebar */
    --sd-sidebar-bg: var(--bg-sunken);
    --sd-sidebar-text: var(--text);
    --sd-sidebar-hover-bg: var(--sd-primary-trans);
    --sd-sidebar-hover-text: var(--primary-text);
    --sd-sidebar-active-bg: var(--primary);
    --sd-sidebar-active-text: var(--text-invert);
    --sd-sidebar-border: var(--border);

    /* Badge / Pill */
    --sd-badge-radius: var(--sd-radius-sm);
    --sd-pill-radius: var(--sd-radius-full);
}

/* ── RESET & BASE ────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

*:focus {
    outline: 1.5px solid var(--sd-info);
}

html {
    font-size: var(--sd-font-size);
    font-size-adjust: 0.5;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    height: 100%;
}

body {
    font-family: var(--sd-font);
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    transition: background var(--sd-ease), color var(--sd-ease);

    &.sidebar-layout {
        display: flex;
        flex-direction: row;
        min-height: 100dvh;
    }

    &.topbar-layout {
        display: flex;
        flex-direction: column;
        min-height: 100dvh;
    }

    >main {
        max-width: 900px;
        width: 100%;
        margin: 0 auto;
        padding: 16px;
    }
}

/* ── TYPOGRAPHY ──────────────────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    margin-top: 1em;
    margin-bottom: .5em;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 1.75rem;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1rem;
}

p {
    color: var(--text);

    & +p {
        margin-top: 1rem;
    }
}

small {
    font-size: .875em;
    color: var(--text-muted);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

strong {
    font-weight: 700;
}

em {
    font-style: italic;
}

del {
    text-decoration: line-through;
    color: var(--text-muted);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
}

code {
    font-family: var(--sd-mono);
    font-size: .875em;
    padding: .125em .5em;
    border-radius: var(--sd-radius-xs);
    background: var(--bg-sunken);
}

pre {
    font-family: var(--sd-mono);
    font-size: .875rem;
    padding: .5rem .5rem 1.25rem;
    border-radius: var(--sd-radius);
    background: var(--bg-sunken);
    color: var(--text);
    overflow-x: auto;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

pre code {
    font-size: 1em;
    background: none;
    padding: 0;
    color: inherit;
}

blockquote {
    border-left: 8px solid var(--primary);
    background: var(--sd-neutral-trans);
    padding: .5rem 1rem;
    margin: 1rem 0;
    border-radius: 0 var(--sd-radius-sm) var(--sd-radius-sm) 0;
    color: var(--text-muted);
    font-style: italic;
}

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

.text-muted {
    color: var(--text-muted);
}

.text-faint {
    color: var(--text-faint);
}

.font-serif {
    font-family: var(--sd-serif);
}

.font-mono {
    font-family: var(--sd-mono);
}

/* ── LISTS ───────────────────────────────────────────────────── */
ul,
ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

li {
    margin-bottom: .3rem;
}

dl {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

dt {
    font-weight: 500;
}


/* ── TABLE ───────────────────────────────────────────────────── */

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: .5rem 1rem;
}

th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: .75em;
    letter-spacing: .06em;
}

tbody>tr {
    border-top: 1px solid var(--border);
}

tbody>tr:hover {
    background: color-mix(in srgb, var(--sd-primary) 5%, transparent);
    transition: background var(--sd-ease);
}

/* 
These classes may be used in table containers
to decorate tables, example:

<div class="sd-table-wrap decorated-table-wrap">
    <table>
        <thead>...</thead>
        <tbody>...</tbody>
    </table>
</div> 
*/

.sd-table-wrap {
    overflow-x: auto;
    border-radius: var(--sd-radius);
}

.decorated-table-wrap {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--sd-radius);

    >table>thead {
        background: var(--bg-sunken);
    }

    >table>tbody {
        background: var(--bg-strong);
    }
}

/* ── FORMS ───────────────────────────────────────────────────── */
.sd-form-group {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-bottom: 1rem;
}

label {
    font-size: .875em;
    font-weight: 600;
    color: var(--text-muted);
}

input,
select,
textarea {
    font-size: 1rem;
    font-family: var(--sd-font);
    padding: .5rem .75rem;
    border-radius: var(--sd-radius-sm);
    border: 1.5px solid var(--border);
    background: var(--bg-strong);
    color: var(--text);
    outline: none;
    transition: border-color var(--sd-ease), box-shadow var(--sd-ease);
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--border-focus);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--border-focus);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

input[type="range"] {
    padding: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    accent-color: var(--primary);
    cursor: pointer;
}


/* 
.input-group expects HTML like the following,
the prefix or suffix elements may be omited:

<label class="input-group">
    <span>Rate</span>
    <input type="number" placeholder="0.00">
    <span>($/h)</span>
</label>
*/
.input-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: .5rem .75rem;
    border-radius: var(--sd-radius-sm);
    border: 1.5px solid var(--border);
    background: var(--bg-strong);
    outline: none;
    transition: border-color var(--sd-ease), box-shadow var(--sd-ease);
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 400;

    >span {
        flex-shrink: 0;
        color: var(--text-faint);
    }

    >input {
        background: none;
        border: none;
        border-radius: 0;
        outline: none;
        box-shadow: none;
        padding: 0;
        color: var(--text-strong);
        font-weight: 500;

        appearance: textfield;
        -moz-appearance: textfield;

        &::-webkit-outer-spin-button,
        &::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }

        &::placeholder {
            color: var(--text-faint);
            font-weight: 400;
        }
    }

    > input:nth-child(2) {
        text-align: left;
    }

    > input:nth-last-child(2) {
        text-align: right;
    }


    &:hover {
        border-color: var(--border-focus);

    }

    &:focus-within {
        border-color: var(--border-focus);
        outline: none;
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
    }
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-family: var(--sd-font);
    font-size: .875rem;
    font-weight: 600;
    padding: .5rem 1rem;
    border-radius: var(--sd-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--sd-ease), color var(--sd-ease), border-color var(--sd-ease), box-shadow var(--sd-ease), transform 80ms ease;
    white-space: nowrap;
    line-height: 1.4;

    &.btn--fw {
        text-align: center;
        justify-content: center;
        width: 100%;
    }
}

.btn:active {
    transform: scale(.97);
}

.btn--primary {
    background: var(--primary);
    color: var(--text-invert);
}

.btn--primary:hover {
    background: var(--primary-hover);
    text-decoration: none;
    color: var(--text-invert);
}

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

.btn--outline:hover {
    background: var(--primary);
    color: var(--text-invert);
    text-decoration: none;
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn--ghost:hover {
    background: var(--bg-sunken);
    color: var(--text);
    text-decoration: none;
}

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

.btn--danger:hover {
    background: var(--sd-red-600);
    text-decoration: none;
    color: #fff;
}

.btn--sm {
    font-size: .75rem;
    padding: .25rem .75rem;
}

.btn--link {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
}

.btn--link:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

.btn--lg {
    font-size: 1.125rem;
    padding: .75rem 1.5rem;
}

.btn:disabled {
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: repeating-linear-gradient(45deg,
            var(--bg-raised),
            var(--bg-raised) 8px,
            var(--bg-sunken) 8px,
            var(--bg-sunken) 9px);
}

.btn-icon {
    color: inherit;
    appearance: none;
    background: none;
    border: none;
    display: block;
    padding: 4px;
    border-radius: 6px;

    >svg {
        display: block;
        height: 1.25rem;
        width: 1.25rem;
    }

    &:hover {
        background-color: var(--sd-neutral-trans);
    }

    &.btn-icon--danger {
        color: var(--sd-danger);

        &:hover {
            background-color: var(--sd-danger-trans);
        }
    }

    &.btn-icon--info {
        color: var(--sd-info);

        &:hover {
            background-color: var(--sd-info-trans);
        }
    }

    &.btn-icon--success {
        color: var(--sd-success);

        &:hover {
            background-color: var(--sd-success-trans);
        }
    }
}


/* ──. BADGES ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: .75em;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: .125rem .5rem;
    border-radius: var(--sd-radius-xs);
    line-height: 1.2;
    white-space: nowrap;
}

.badge-primary {
    background: var(--sd-primary-trans);
    color: var(--sd-primary);
}

.badge-success {
    background: var(--sd-success-trans);
    color: var(--sd-success);
}

.badge-warning {
    background: var(--sd-warning-trans);
    color: var(--sd-warning);
}

.badge-danger {
    background: var(--sd-danger-trans);
    color: var(--sd-danger);
}

.badge-info {
    background: var(--sd-info-trans);
    color: var(--sd-info);
}

.badge-neutral {
    background: var(--sd-neutral-trans);
    color: var(--sd-neutral);
}

/* ──. PILLS ──────────────────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    font-size: .875em;
    font-weight: 500;
    padding: .25em 1em;
    border-radius: var(--sd-radius-full);
    border: 1.5px solid var(--border);
    background: var(--bg-strong);
    color: var(--text-muted);
    cursor: default;
    transition: background var(--sd-ease), color var(--sd-ease), border-color var(--sd-ease);
    white-space: nowrap;
}

.pill.active,
.pill:hover {
    background: var(--sd-primary-trans);
    border-color: var(--sd-primary);
}

.pill-dot::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: .7;
    flex-shrink: 0;
}

.pill-removable {
    cursor: pointer;
}

.pill-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    opacity: .55;
    transition: opacity var(--sd-ease);
    line-height: 1;
    cursor: pointer;
}

.pill-remove:hover {
    opacity: 1;
}

/* ──. CARDS ──────────────────────────────────────────────────── */
.card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--sd-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: .5rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-body {
    padding: .5rem 1rem;
    flex: 1;
}

.card-footer {
    padding: .5rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-sunken);
    font-size: .88em;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

/* ──. ALERTS ─────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--sd-radius-sm);
    margin-bottom: .75rem;
    display: flex;
    gap: .5rem;
    align-items: flex-start;
}

.alert--icon {
    font-size: 1.1em;
    flex-shrink: 0;
    line-height: 1.5;
}

.alert--primary {
    background: var(--sd-primary-trans);
    color: var(--sd-primary);
}

.alert--success {
    background: var(--sd-success-trans);
    color: var(--sd-success);
}

.alert--warning {
    background: var(--sd-warning-trans);
    color: var(--sd-warning);
}

.alert--danger {
    background: var(--sd-danger-trans);
    color: var(--sd-danger);
}

.alert--info {
    background: var(--sd-info-trans);
    color: var(--sd-info);
}

.alert--neutral {
    background: var(--sd-neutral-trans);
    color: var(--sd-neutral);
}

/* ──. SIDEBAR ────────────────────────────────────────────────── */
.sd-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sd-sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    padding-bottom: 0.375rem;
    height: 100dvh;
    position: sticky;
    top: 0;
    max-height: 100dvh;
    overflow: auto;
}

.sd-sidebar-brand {
    padding: 1rem;
    font-size: 1.25rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    margin-bottom: .5rem;
}

.sd-nav-section {
    padding: .625rem 1rem .25rem;
    font-size: .875em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-faint);
}

.sd-nav-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1rem;
    margin: .125rem .5rem;
    border-radius: var(--sd-radius-sm);
    font-weight: 500;
    color: var(--sd-sidebar-text);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--sd-ease), color var(--sd-ease);

    >* {
        min-width: 1rem;
        text-align: center;
    }
}

.sd-nav-item:hover {
    background: var(--sd-sidebar-hover-bg);
    text-decoration: none;
    color: var(--text);
}

.sd-nav-item.active {
    background: var(--sd-sidebar-active-bg);
    color: var(--sd-sidebar-active-text);
    font-weight: 700;
}

.sd-nav-item .nav-badge {
    margin-left: auto;
    font-size: .75em;
    background: var(--sd-primary-trans);
    color: var(--sd-primary);
    padding: .125em .75em;
    border-radius: var(--sd-radius-full);
    font-weight: 700;
}

.sd-nav-item.active .nav-badge {
    background: rgba(255, 255, 255, .25);
    color: #fff;
}

/* align a ghost button's text with nav-items */
.sd-sidebar .btn-ghost.sd-nav-item {
    border-width: 0;
}

.sd-sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
}

/* ── TOPBAR ───────────────────────────────────────────── */

.sd-topbar {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    height: 48px;
    padding: .25rem 1rem;
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border);

    >h1 {
        margin: 0;
        font-size: 1.25rem;
        font-weight: 500;

        >a {
            color: var(--text-muted);
        }
    }
}

/* ──. MAIN CONTENT ───────────────────────────────────────────── */
.sd-main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sd-content {
    flex: 1;
    max-width: 900px;
    width: 100%;
}

.section-title {
    font-size: .875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-faint);
    margin: 2rem 0 .75rem;
    padding-bottom: .25rem;
    border-bottom: 1px solid var(--border);
}

.section-title:first-child {
    margin-top: 0;
}

/* ──. DROPDOWN ───────────────────────────────────────────────── */
.sd-dropdown {
    position: relative;
    display: inline-block;
}

.sd-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 160px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--sd-radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    padding: .25rem;
    display: none;
    animation: ddFadeIn 120ms ease forwards;
    margin: 0 .5rem;

    &.top {
        top: unset;
        bottom: calc(100% + 6px);
    }

    &.full-width {
        left: 0;
        right: 0;
    }

}

.sd-dropdown.open .sd-dropdown-menu {
    display: block;
}

@keyframes ddFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

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

.sd-dropdown-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    border-radius: var(--sd-radius-sm);
    font-size: 1rem;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--sd-ease);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    &.active {
        background: var(--sd-primary-trans);
        color: var(--sd-primary);
    }
}

.sd-dropdown-item:hover {
    background: var(--sd-neutral-trans);
    text-decoration: none;
}

.sd-dropdown-item.danger {
    color: var(--sd-danger);
}

.sd-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: .25rem .2rem;
}

.sd-dropdown-label {
    padding: .25rem .875rem .125rem;
    font-size: .875em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-faint);
}

.sd-sidebar>.sd-dropdown {
    display: flex;

    >button {
        flex: 1;
    }
}

/* ──. TOGGLE / THEME SWITCH ──────────────────────────────────── */
.sd-toggle {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.sd-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.sd-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--sd-neutral-600);
    border-radius: var(--sd-radius-full);
    cursor: pointer;
    transition: background var(--sd-ease);
}

.sd-toggle input:checked+.sd-toggle-track {
    background: var(--primary);
}

.sd-toggle-track::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--sd-ease);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

.sd-toggle input:checked+.sd-toggle-track::before {
    transform: translateX(18px);
}

/* ──. PROGRESS ───────────────────────────────────────────────── */
.sd-progress {
    height: 8px;
    border-radius: var(--sd-radius-full);
    background: var(--bg-sunken);
    overflow: hidden;
}

.sd-progress-bar {
    height: 100%;
    border-radius: var(--sd-radius-full);
    background: linear-gradient(90deg, var(--sd-orange-400), var(--sd-purple-400));
    transition: width .5s ease;
}


/* ──. DIALOG ───────────────────────────────────────────── */

dialog:not([open]) {
    display: none;
}

dialog {
    display: initial;
    margin: auto;
    background: none;
    border: none;
    outline: none;
    touch-action: none;
    pointer-events: none;

    >* {
        pointer-events: all;
    }
}

dialog.blur::backdrop {
    background: rgba(255, 255, 255, .05);
    backdrop-filter: blur(4px);
}

dialog::backdrop {
    background-color: transparent;
    transition: background-color 0.2s ease-out;
    transition-behavior: allow-discrete;
}

dialog[open]::backdrop {
    background-color: var(--sd-neutral-trans);
}

@starting-style {
    dialog[open]::backdrop {
        background-color: transparent;
    }
}

/* ──. FLEX HELPERS ───────────────────────────────────────────── */
.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-row {
    display: flex;
    flex-direction: row;
}

.space-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.gap-05 {
    gap: .5rem;
}

.gap-075 {
    gap: .75rem;
}

.gap-1 {
    gap: 1rem;
}

.gap-2 {
    gap: 2rem;
}

.mb-2 {
    margin-bottom: .5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mt-2 {
    margin-top: .5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.spacing-v-05 {
    >*+* {
        margin-top: .5rem;
    }
}