/* ============================================================================================
   Novalie Pharma — component library
   Buttons, cards, forms, tables, badges, dialogs, skeletons, toasts, pagination.
   Everything is built from the tokens in tokens.css; no component invents its own colour.
   ============================================================================================ */

/* ============================================================================================
   Buttons
   ============================================================================================ */

.btn {
    --btn-bg: transparent;
    --btn-fg: var(--text);
    --btn-border: transparent;
    --btn-shadow: none;

    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: .8125rem 1.375rem;
    min-height: 2.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-fg);
    box-shadow: var(--btn-shadow);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    line-height: 1;
    letter-spacing: -.005em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    isolation: isolate;
    transition:
        transform var(--duration-fast) var(--ease-out),
        box-shadow var(--duration) var(--ease-out),
        background-color var(--duration-fast) var(--ease-out),
        border-color var(--duration-fast) var(--ease-out),
        color var(--duration-fast) var(--ease-out);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); transition-duration: 60ms; }

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: .55;
    pointer-events: none;
    transform: none;
}

.btn-primary {
    --btn-bg: var(--primary);
    --btn-fg: var(--on-primary);
    --btn-shadow: 0 6px 18px -6px color-mix(in srgb, var(--primary) 65%, transparent);
}
.btn-primary:hover {
    --btn-bg: var(--primary-600);
    --btn-shadow: 0 12px 28px -8px color-mix(in srgb, var(--primary) 70%, transparent);
    color: var(--on-primary);
}

.btn-accent {
    --btn-bg: var(--accent);
    --btn-fg: var(--on-accent);
    --btn-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 60%, transparent);
}
.btn-accent:hover { --btn-bg: var(--accent-600); color: var(--on-accent); }

.btn-outline {
    --btn-fg: var(--primary);
    --btn-border: var(--border-strong);
    --btn-bg: var(--surface);
}
.btn-outline:hover {
    --btn-border: var(--primary);
    --btn-bg: var(--primary-050);
    color: var(--primary);
}

.btn-ghost { --btn-fg: var(--text); }
.btn-ghost:hover { --btn-bg: var(--background-alt); color: var(--text); }

.btn-danger {
    --btn-bg: var(--danger);
    --btn-fg: #fff;
    --btn-shadow: 0 6px 18px -6px color-mix(in srgb, var(--danger) 60%, transparent);
}
.btn-danger:hover { --btn-bg: color-mix(in srgb, var(--danger) 88%, black); color: #fff; }

.btn-subtle-danger { --btn-fg: var(--danger); --btn-bg: var(--danger-050); }
.btn-subtle-danger:hover { --btn-bg: color-mix(in srgb, var(--danger) 16%, transparent); }

/* Reversed-out button for dark hero and CTA panels. */
.btn-invert { --btn-bg: #fff; --btn-fg: var(--primary); }
.btn-invert:hover { --btn-bg: rgba(255,255,255,.9); color: var(--primary); }

.btn-invert-outline {
    --btn-fg: #fff;
    --btn-border: rgba(255,255,255,.42);
    --btn-bg: rgba(255,255,255,.06);
    backdrop-filter: blur(8px);
}
.btn-invert-outline:hover { --btn-bg: rgba(255,255,255,.16); --btn-border: rgba(255,255,255,.7); color: #fff; }

.btn-sm { padding: .5rem .875rem; min-height: 2.25rem; font-size: var(--text-sm); border-radius: var(--radius-xs); }
.btn-lg { padding: 1rem 1.875rem; min-height: 3.375rem; font-size: var(--text-md); border-radius: var(--radius); }
.btn-block { width: 100%; }

.btn-icon {
    padding: 0;
    width: 2.5rem;
    min-height: 2.5rem;
    border-radius: var(--radius-sm);
}
.btn-icon.btn-sm { width: 2.125rem; min-height: 2.125rem; }

/* The arrow on "read more" style links slides on hover. */
.btn .icon-shift { transition: transform var(--duration) var(--ease-spring); }
.btn:hover .icon-shift { transform: translateX(3px); }
html[dir="rtl"] .btn:hover .icon-shift { transform: translateX(-3px); }

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-weight: var(--weight-semibold);
    font-size: var(--text-base);
    color: var(--primary);
    text-decoration: none;
}
.btn-link:hover { color: var(--accent); }
.btn-link svg { transition: transform var(--duration) var(--ease-spring); }
.btn-link:hover svg { transform: translateX(3px); }
html[dir="rtl"] .btn-link:hover svg { transform: translateX(-3px); }

/* ============================================================================================
   Cards
   ============================================================================================ */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition:
        transform var(--duration) var(--ease-out),
        box-shadow var(--duration) var(--ease-out),
        border-color var(--duration) var(--ease-out);
}

.card-body { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-3); flex: 1; }
.card-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); }

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.card-flat { border-radius: var(--radius); box-shadow: none; }
.card-raised { box-shadow: var(--shadow); border-color: transparent; }

/* Glass panel — used sparingly, over imagery only. */
.card-glass {
    background: color-mix(in srgb, var(--surface) 72%, transparent);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-color: color-mix(in srgb, var(--border) 60%, transparent);
}

/* ============================================================================================
   Badges and chips
   ============================================================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .3125rem .625rem;
    border-radius: var(--radius-pill);
    background: var(--background-alt);
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    line-height: 1.2;
    white-space: nowrap;
}

.badge-primary { background: var(--primary-050); color: var(--primary); }
.badge-accent { background: var(--accent-050); color: var(--accent-600); }
.badge-brand { background: var(--brand-050); color: var(--brand); }
.badge-success { background: var(--success-050); color: var(--success); }
.badge-warning { background: var(--warning-050); color: var(--warning); }
.badge-danger { background: var(--danger-050); color: var(--danger); }
.badge-info { background: var(--info-050); color: var(--info); }

.badge-dot::before {
    content: "";
    width: .4375rem;
    height: .4375rem;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: .5rem 1rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-050); }

.chip[aria-pressed="true"], .chip.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

.chip-count {
    font-size: var(--text-2xs);
    font-variant-numeric: tabular-nums;
    opacity: .75;
}

/* ============================================================================================
   Forms
   ============================================================================================ */

.field { display: flex; flex-direction: column; gap: var(--space-2); }

.field-label {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text);
}

.field-label .req { color: var(--danger); margin-inline-start: .125rem; }

.field-hint { font-size: var(--text-xs); color: var(--muted-soft); }
.field-error { font-size: var(--text-xs); color: var(--danger); font-weight: var(--weight-medium); }

.input, .textarea, .select {
    width: 100%;
    padding: .75rem .9375rem;
    min-height: 2.875rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--text-base);
    line-height: 1.4;
    transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.input::placeholder, .textarea::placeholder { color: var(--muted-soft); }

.input:hover, .textarea:hover, .select:hover { border-color: var(--muted-soft); }

.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}

.input:disabled, .textarea:disabled, .select:disabled {
    background: var(--surface-sunken);
    color: var(--muted-soft);
    cursor: not-allowed;
}

.input.invalid, .textarea.invalid, .select.invalid,
.input.modified.invalid, .textarea.modified.invalid {
    border-color: var(--danger);
}

.input.invalid:focus, .textarea.invalid:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}

.textarea { min-height: 8rem; resize: vertical; }

.select {
    appearance: none;
    padding-inline-end: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B6B80' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .875rem center;
    background-size: 1rem;
}

html[dir="rtl"] .select { background-position: left .875rem center; }

.input-group { position: relative; display: flex; align-items: center; }

.input-group .input { padding-inline-start: 2.75rem; }

.input-group .input-icon {
    position: absolute;
    inset-inline-start: .9375rem;
    color: var(--muted-soft);
    pointer-events: none;
    display: flex;
}

/* Checkboxes and switches */
.check {
    display: inline-flex;
    align-items: flex-start;
    gap: var(--space-3);
    cursor: pointer;
    font-size: var(--text-base);
    line-height: 1.45;
}

.check input[type="checkbox"], .check input[type="radio"] {
    appearance: none;
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: .125rem;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.check input[type="radio"] { border-radius: 50%; }

.check input:checked {
    background: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.check input[type="radio"]:checked { background-image: none; box-shadow: inset 0 0 0 4px var(--surface); }

.check input:focus-visible { box-shadow: var(--shadow-focus); outline: none; }

.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; }

.switch input {
    appearance: none;
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    flex: none;
    border-radius: var(--radius-pill);
    background: var(--border-strong);
    cursor: pointer;
    transition: background-color var(--duration) var(--ease-out);
}

.switch input::after {
    content: "";
    position: absolute;
    top: .1875rem;
    inset-inline-start: .1875rem;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-xs);
    transition: transform var(--duration) var(--ease-spring);
}

.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(1.25rem); }
html[dir="rtl"] .switch input:checked::after { transform: translateX(-1.25rem); }
.switch input:focus-visible { box-shadow: var(--shadow-focus); outline: none; }

.form-grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }

.validation-message { color: var(--danger); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.validation-errors { list-style: none; }

/* ============================================================================================
   Alerts
   ============================================================================================ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: var(--text-base);
}

.alert svg { flex: none; margin-top: .125rem; }

.alert-success { background: var(--success-050); border-color: color-mix(in srgb, var(--success) 25%, transparent); color: var(--success); }
.alert-warning { background: var(--warning-050); border-color: color-mix(in srgb, var(--warning) 25%, transparent); color: var(--warning); }
.alert-danger { background: var(--danger-050); border-color: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger); }
.alert-info { background: var(--info-050); border-color: color-mix(in srgb, var(--info) 25%, transparent); color: var(--info); }

/* ============================================================================================
   Tables
   ============================================================================================ */

.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table { width: 100%; font-size: var(--text-base); }

.table th {
    padding: var(--space-3) var(--space-4);
    text-align: start;
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color var(--duration-fast) var(--ease-out); }
.table tbody tr:hover { background: var(--surface-sunken); }
.table tbody tr.is-selected { background: var(--primary-050); }

.table .col-actions { width: 1%; white-space: nowrap; text-align: end; }
.table .col-check { width: 1%; }

.th-sort {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}
.th-sort:hover { color: var(--primary); }
.th-sort .sort-arrow { opacity: .35; transition: opacity var(--duration-fast); }
.th-sort[aria-sort]:not([aria-sort="none"]) .sort-arrow { opacity: 1; color: var(--primary); }

/* On narrow screens the table becomes a stack of labelled rows. */
@media (max-width: 48rem) {
    .table-responsive thead { display: none; }
    .table-responsive tr {
        display: grid;
        gap: var(--space-2);
        padding: var(--space-4);
        border-bottom: 1px solid var(--border);
    }
    .table-responsive td {
        display: grid;
        grid-template-columns: 8rem 1fr;
        gap: var(--space-3);
        padding: 0;
        border: none;
    }
    .table-responsive td::before {
        content: attr(data-label);
        font-size: var(--text-xs);
        font-weight: var(--weight-bold);
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--muted);
    }
    .table-responsive .col-actions { justify-items: start; }
    .table-responsive .col-actions::before { content: none; }
}

/* ============================================================================================
   Pagination
   ============================================================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    list-style: none;
}

.pagination button, .pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding-inline: .625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-out);
}

.pagination button:hover:not(:disabled), .pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-050);
}

.pagination .is-current {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
    pointer-events: none;
}

.pagination button:disabled { opacity: .4; pointer-events: none; }
.pagination .ellipsis { color: var(--muted-soft); padding-inline: .25rem; }

/* ============================================================================================
   Modal and drawer
   ============================================================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: grid;
    place-items: center;
    padding: var(--gutter);
    background: var(--overlay);
    backdrop-filter: blur(4px);
    animation: fade-in var(--duration) var(--ease-out);
}

.modal {
    width: 100%;
    max-width: 34rem;
    max-height: min(85vh, 48rem);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modal-in var(--duration-slow) var(--ease-spring);
}

.modal-lg { max-width: 56rem; }
.modal-xl { max-width: 72rem; }

.modal-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-6);
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: var(--text-xl); }
.modal-body { padding: var(--space-6); overflow-y: auto; flex: 1; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--border);
    background: var(--surface-sunken);
    flex-wrap: wrap;
}

@media (max-width: 32rem) {
    .modal-footer { flex-direction: column-reverse; }
    .modal-footer .btn { width: 100%; }
}

/* ============================================================================================
   Toasts
   ============================================================================================ */

.toast-host {
    position: fixed;
    inset-block-end: var(--space-6);
    inset-inline-end: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: min(24rem, calc(100vw - 2 * var(--space-6)));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-inline-start: 3px solid var(--muted);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in var(--duration-slow) var(--ease-spring);
}

.toast.is-leaving { animation: toast-out var(--duration) var(--ease-in-out) forwards; }

.toast-success { border-inline-start-color: var(--success); }
.toast-info { border-inline-start-color: var(--info); }
.toast-warning { border-inline-start-color: var(--warning); }
.toast-error { border-inline-start-color: var(--danger); }

.toast-icon { flex: none; margin-top: .0625rem; }
.toast-success .toast-icon { color: var(--success); }
.toast-info .toast-icon { color: var(--info); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-error .toast-icon { color: var(--danger); }

.toast-content { flex: 1; min-width: 0; }
.toast-title { font-family: var(--font-sans); font-weight: var(--weight-semibold); font-size: var(--text-base); }
.toast-text { font-size: var(--text-sm); color: var(--muted); overflow-wrap: anywhere; }
.toast-close { color: var(--muted-soft); flex: none; }
.toast-close:hover { color: var(--text); }

@media (max-width: 40rem) {
    .toast-host {
        inset-inline: var(--space-4);
        inset-block-end: var(--space-4);
        width: auto;
    }
}

/* ============================================================================================
   Skeletons and empty states
   ============================================================================================ */

.skeleton {
    position: relative;
    overflow: hidden;
    background: color-mix(in srgb, var(--border) 55%, transparent);
    border-radius: var(--radius-xs);
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg,
        transparent,
        color-mix(in srgb, var(--surface) 65%, transparent),
        transparent);
    animation: shimmer 1.6s infinite;
}

html[dir="rtl"] .skeleton::after { animation-name: shimmer-rtl; }

.skeleton-text { height: .75rem; border-radius: var(--radius-pill); }
.skeleton-title { height: 1.25rem; border-radius: var(--radius-pill); }
.skeleton-image { aspect-ratio: 4 / 3; border-radius: var(--radius); }
.skeleton-avatar { width: 2.75rem; height: 2.75rem; border-radius: 50%; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    padding: clamp(2.5rem, 8vw, 5rem) var(--space-6);
    text-align: center;
}

.empty-state-icon {
    display: grid;
    place-items: center;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: var(--radius-lg);
    background: var(--background-alt);
    color: var(--muted-soft);
}

.empty-state-title { font-size: var(--text-xl); }
.empty-state-body { color: var(--muted); max-width: 30rem; }

/* ============================================================================================
   Spinner
   ============================================================================================ */

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex: none;
}

.spinner-lg { width: 2.25rem; height: 2.25rem; border-width: 3px; }

.loading-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-16) var(--space-6);
    color: var(--muted);
}

/* ============================================================================================
   Breadcrumb
   ============================================================================================ */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    list-style: none;
    color: var(--muted);
}

.breadcrumb li { display: inline-flex; align-items: center; gap: var(--space-2); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: var(--weight-medium); }
.breadcrumb .sep { color: var(--muted-soft); display: inline-flex; }

/* ============================================================================================
   Prose — rendered rich text from the CMS
   ============================================================================================ */

.prose { color: var(--text); font-size: var(--text-md); line-height: var(--leading-relaxed); }
.prose > * + * { margin-top: var(--space-5); }
.prose h2 { font-size: var(--text-2xl); margin-top: var(--space-12); }
.prose h3 { font-size: var(--text-xl); margin-top: var(--space-10); }
.prose h4 { font-size: var(--text-lg); margin-top: var(--space-8); }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-inline-start: var(--space-6); display: grid; gap: var(--space-2); }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li::marker { color: var(--accent); }
.prose a { font-weight: var(--weight-medium); }

.prose blockquote {
    margin: var(--space-8) 0;
    padding: var(--space-5) var(--space-6);
    border-inline-start: 3px solid var(--accent);
    background: var(--background-alt);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: var(--text-lg);
}

.prose img { border-radius: var(--radius); box-shadow: var(--shadow-sm); }

.prose table { display: block; overflow-x: auto; white-space: nowrap; }
.prose th, .prose td { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); text-align: start; }
.prose th { background: var(--surface-sunken); font-weight: var(--weight-semibold); }

.prose code {
    font-family: var(--font-mono);
    font-size: .9em;
    padding: .125em .375em;
    background: var(--background-alt);
    border-radius: var(--radius-xs);
}

.prose pre {
    padding: var(--space-5);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.prose pre code { background: none; padding: 0; }

/* ============================================================================================
   Tabs
   ============================================================================================ */

.tabs {
    display: flex;
    gap: var(--space-1);
    padding: .3125rem;
    background: var(--background-alt);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: .5625rem 1rem;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    transition: all var(--duration-fast) var(--ease-out);
}

.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }
.tab .tab-flag { font-size: var(--text-xs); opacity: .8; }
.tab .tab-warn { width: .5rem; height: .5rem; border-radius: 50%; background: var(--warning); }

/* ============================================================================================
   Progress
   ============================================================================================ */

.progress { height: .375rem; border-radius: var(--radius-pill); background: var(--border); overflow: hidden; }
.progress-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width var(--duration-slow) var(--ease-out);
}

/* ============================================================================================
   Dropdown
   ============================================================================================ */

.dropdown { position: relative; }

.dropdown-menu {
    position: absolute;
    inset-block-start: calc(100% + .5rem);
    inset-inline-end: 0;
    min-width: 12rem;
    padding: var(--space-2);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-drawer);
    animation: dropdown-in var(--duration) var(--ease-out);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: .625rem .75rem;
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: var(--text-base);
    text-align: start;
    text-decoration: none;
    transition: background-color var(--duration-fast) var(--ease-out);
}

.dropdown-item:hover { background: var(--background-alt); color: var(--text); }
.dropdown-item.is-active { background: var(--primary-050); color: var(--primary); font-weight: var(--weight-semibold); }
.dropdown-item.is-danger { color: var(--danger); }
.dropdown-item.is-danger:hover { background: var(--danger-050); }
.dropdown-divider { height: 1px; margin: var(--space-2) 0; background: var(--border); }

/* ============================================================================================
   Blazor's circuit error banner
   The framework reveals this by setting display:block inline, so it must default to hidden.
   Styled to match the design system rather than the framework's default yellow bar.
   ============================================================================================ */

.blazor-error-ui {
    display: none;
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: calc(var(--z-toast) + 10);
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--gutter);
    background: var(--danger);
    color: #fff;
    font-size: var(--text-base);
    box-shadow: 0 -8px 24px rgba(9, 30, 55, .18);
}

.blazor-error-ui .reload {
    color: #fff;
    font-weight: var(--weight-semibold);
    text-underline-offset: .2em;
}

.blazor-error-ui .dismiss {
    margin-inline-start: auto;
    cursor: pointer;
    opacity: .8;
    line-height: 1;
}

.blazor-error-ui .dismiss:hover { opacity: 1; }

/* The framework toggles display, so the flex layout only applies once it is shown. */
.blazor-error-ui[style*="display: block"],
.blazor-error-ui[style*="display:block"] { display: flex !important; }

/* ============================================================================================
   Lightbox
   Created by site.js on demand, so it has no Blazor markup of its own.
   ============================================================================================ */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-modal) + 20);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-4);
    padding: clamp(1rem, 4vw, 3rem);
    background: rgba(6, 12, 20, .93);
    backdrop-filter: blur(8px);
    animation: fade-in var(--duration) var(--ease-out);
}

.lightbox-figure {
    grid-column: 2;
    display: grid;
    justify-items: center;
    gap: var(--space-4);
    margin: 0;
    min-width: 0;
}

.lightbox-figure img {
    max-width: 100%;
    max-height: 78vh;
    object-fit: contain;
    border-radius: var(--radius);
    animation: scale-in var(--duration-slow) var(--ease-out);
}

.lightbox-figure figcaption {
    color: rgba(255, 255, 255, .82);
    font-size: var(--text-base);
    text-align: center;
    max-width: 48rem;
}

.lightbox-nav,
.lightbox-close {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
    border: none;
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-out);
}

.lightbox-nav:hover,
.lightbox-close:hover { background: rgba(255, 255, 255, .24); }
.lightbox-nav[hidden] { visibility: hidden; }

.lightbox-close {
    position: absolute;
    inset-block-start: var(--space-5);
    inset-inline-end: var(--space-5);
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.125rem;
}

.lightbox-counter {
    position: absolute;
    inset-block-end: var(--space-6);
    inset-inline: 0;
    text-align: center;
    color: rgba(255, 255, 255, .6);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 40rem) {
    .lightbox { grid-template-columns: 1fr; }
    .lightbox-figure { grid-column: 1; }
    .lightbox-nav {
        position: absolute;
        inset-block-end: var(--space-16);
    }
    .lightbox-prev { inset-inline-start: var(--space-4); }
    .lightbox-next { inset-inline-end: var(--space-4); }
}
