﻿/* ==========================================================================
   components.css
   OES Custom Tier-3 Component Styles (Driven by tokens.css)
   --------------------------------------------------------------------------
   Contents:
     1. Form field layout (.ds-field)
     2. Toggle card (.ds-toggle-card)
     3. Wizard stepper (.ds-stepper)
     4. Keyboard shortcut (.ds-kbd)
     5. Selection bar & Group heading (.ds-selection-bar, .ds-group-heading)
     6. Choice cards & Layout radio cards (.ds-choice-card, .ds-layout-card)
     7. Empty state (.ds-empty-state)
     8. Number stepper (.ds-number-stepper)
     9. Score strip (.ds-score-strip)
    10. Question row (.ds-question-row)
    11. Selected questions panel (.ds-selected-panel__list, .ds-selected-item)
    12. Drag card & move bar (.ds-drag-card, .ds-move-bar)
    13. Question editor parts (.ds-drawer__*, .ds-option-bar, .ds-collapsible-card, .ds-answer-row)
    14. Summary strip & overline (.ds-summary-strip, .ds-overline)
    15. Preview frame & choice layouts (.ds-preview-frame, .ds-preview-choices)
    16. Model item (.ds-model-item)
    17. TREE PICKER (.ds-tree-picker) 
    18. Summary list
    19. Menu item text & icon tiles (.ds-menu-item, .ds-menu-item__tile)
    20. List toolbar, filter popover & bulk action (.ds-list-toolbar, .ds-filter-btn, .ds-filter-popover, .ds-btn__count)
    21. Date & sort popover (.ds-date-popover, .ds-date-calendar, .ds-date-day)
    22. File upload zone, file row & file card (.ds-upload-zone, .ds-file-row, .ds-file-card)
    23. Toast (.ds-toast, OesToast via ISnackbar.ShowOes)
    24. Dialog breadcrumb & view switch (.ds-dialog-crumb, .ds-dialog-view)
    25. Setting group & setting row (.ds-setting-group, .ds-setting-row) 
    26. Meta grid (.ds-meta-grid)
    27. Activity list (.ds-activity-list, .ds-activity-item)
   ========================================================================== */

/* ==========================================================================
   1. FORM FIELD LAYOUT
   ========================================================================== */
.ds-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-inline-size: 0;
}

.ds-field__label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-field__label--required::after {
    content: "*";
    margin-inline-start: var(--space-1);
    color: var(--color-status-danger-solid);
}

/* Field hint with an icon (NmrField Hint + HintIcon): 11px muted text after a 14px icon.
   <p class="ds-field__hint" id="{InputId}-hint"><MudIcon Icon=".." aria-hidden="true" />..</p>
   Without HintIcon, NmrField keeps its plain u-text-xs hint. */
.ds-field__hint {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin: 0;
    font-size: var(--font-size-2xs);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
}

    .ds-field__hint .mud-icon-root {
        flex-shrink: 0;
        font-size: var(--size-icon-xs);
    }

/* Compact form switcher in a card header (Step 4, "نموذج 1 / نموذج 2") */
.ds-field.ds-form-switcher {
    inline-size: calc(var(--space-24) * 2);
}

/* Select-or-new field: a segmented MudToggleGroup at inline-start switches the
   input between a MudSelect (existing entry) and a MudTextField (new entry).
   The group takes the field height (--ds-field-height: 48px, 36px with ds-field--sm,
   44px on touch), so error text under the input never stretches it; the input takes
   the remaining width and wraps under the group below ~288px.
   Markup (inside NmrField or .ds-field, so the external label still applies):
     <div class="ds-field-switch">
       <MudToggleGroup T="bool" @bind-Value="_isNew" aria-label="..">
         <MudToggleItem Value="false" Text=".." />
         <MudToggleItem Value="true" Text=".." />
       </MudToggleGroup>
       <div class="ds-field-switch__input"> MudSelect or MudTextField (same InputId) </div>
     </div> */
.ds-field-switch {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-3);
}

    .ds-field-switch > .mud-toggle-group {
        box-sizing: border-box;
        flex: 0 0 auto;
        block-size: var(--ds-field-height, var(--size-control-lg));
        padding: calc(var(--space-1) - var(--border-width-thin));
    }

        /* Doubled class outranks the :first-child / :last-child item rules in mudblazor-overrides.css */
        .ds-field-switch > .mud-toggle-group.mud-toggle-group .mud-toggle-item {
            flex: 0 0 auto;
            block-size: 100%;
            min-block-size: 0;
            padding-inline: var(--space-4);
            font-size: var(--font-size-sm);
            line-height: var(--line-height-tight);
            white-space: nowrap;
        }

.ds-field-switch__input {
    flex: 1 1 var(--size-search-min);
    min-inline-size: 0;
}

/* ==========================================================================
   2. TOGGLE CARD (OesToggleCard.razor)
   "On" comes from .is-selected / aria-checked="true" set in markup, or from a
   checked MudSwitch inside the card (so it also works without the class).
   ========================================================================== */
.ds-toggle-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-lg);
    transition: background-color var(--duration-normal) var(--easing-standard), border-color var(--duration-normal) var(--easing-standard);
}

    .ds-toggle-card:is(.is-selected, [aria-checked="true"], :has(.mud-switch-input:checked)) {
        background-color: var(--color-bg-selected);
        border-color: var(--color-border-input-focus);
    }

    /* Toggle card icon tile: neutral when off (global outlined avatar), primary when on.
           Outranks the global outlined-avatar override, which loads later. The neutral
           variant is excluded so it keeps its gray tile when switched on. */
    .ds-toggle-card:not(.ds-toggle-card--neutral):is(.is-selected, [aria-checked="true"], :has(.mud-switch-input:checked)) .mud-avatar.mud-avatar-rounded.mud-avatar-outlined {
        border-color: var(--color-border-primary);
        color: var(--color-text-primary);
    }

    /* Neutral variant: keeps the gray fill when switched on (settings that are
   not a highlighted choice, e.g. "ترتيب عشوائي للاختيارات") */
    .ds-toggle-card.ds-toggle-card--neutral:is(.is-selected, [aria-checked="true"], :has(.mud-switch-input:checked)) {
        background-color: var(--color-bg-surface-subtle);
        border-color: var(--color-border-default);
    }

    .ds-toggle-card.ds-toggle-card--neutral .mud-avatar.mud-avatar-rounded.mud-avatar-outlined {
        background-color: var(--color-bg-surface);
        border-color: var(--color-border-default);
        color: var(--color-text-secondary);
    }

    /* Disabled switch: the card text steps back so the locked state reads at a glance */
    .ds-toggle-card:has(.mud-switch-input:disabled) :is(.ds-toggle-card__title, .ds-toggle-card__desc) {
        color: var(--color-text-muted);
    }

.ds-toggle-card__body {
    flex: 1 1 0%;
    min-inline-size: 0;
}

.ds-toggle-card__title {
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-toggle-card__desc {
    margin: var(--space-1) 0 0;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
}

/* ==========================================================================
   3. WIZARD STEPPER (OesWizardStepper.razor)
   ========================================================================== */
.ds-stepper-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.ds-stepper__compact-header {
    display: none;
    flex-direction: column;
    gap: var(--space-1);
}

.ds-stepper__compact-count {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
}

.ds-stepper__compact-title {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-stepper {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: var(--space-4) var(--space-6);
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: visible;
}

.ds-step {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-inline-size: 0;
    padding-block-end: var(--space-3);
}

    .ds-step::after {
        content: "";
        position: absolute;
        inset-inline: 0;
        inset-block-end: 0;
        block-size: var(--space-1);
        background-color: var(--color-border-default);
        border-radius: var(--radius-full);
        transition: background-color var(--duration-fast) var(--easing-standard);
    }

    .ds-step[aria-current="step"]::after,
    .ds-step.ds-step--completed::after {
        background-color: var(--color-bg-primary);
    }

    .ds-step .mud-avatar.ds-step__tile {
        inline-size: var(--space-10);
        block-size: var(--space-10);
        background-color: var(--color-bg-surface);
        border: var(--border-width-thin) solid var(--color-border-default);
        border-radius: var(--radius-md);
        color: var(--color-text-secondary);
    }

        .ds-step .mud-avatar.ds-step__tile .mud-icon-root {
            font-size: var(--size-icon-md);
        }

    .ds-step[aria-current="step"] .mud-avatar.ds-step__tile {
        background-color: var(--color-bg-primary);
        border-color: var(--color-bg-primary);
        color: var(--color-text-on-primary);
    }

    .ds-step.ds-step--completed .mud-avatar.ds-step__tile {
        background-color: var(--color-bg-primary-soft);
        border-color: var(--color-border-primary);
        color: var(--color-text-primary);
    }

/* Navigable step: a real <button> so keyboard, focus and semantics come free.
   Transparent and inherits everything, so the step looks identical either way.
   (The tile selectors above use descendant combinators for exactly this reason.) */
.ds-step__button {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: var(--space-3);
    min-inline-size: 0;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    font: inherit;
    text-align: start;
    color: inherit;
    cursor: pointer;
}

    .ds-step__button:focus-visible {
        outline: var(--focus-ring-width) solid var(--focus-ring-color);
        outline-offset: var(--focus-ring-offset);
    }

    .ds-step__button:disabled {
        cursor: default;
    }

.ds-step__text {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
}

.ds-step__label {
    font-size: var(--font-size-xs);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ds-step__title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
    white-space: normal;
    overflow-wrap: break-word;
}

.ds-step[aria-current="step"] .ds-step__label,
.ds-step.ds-step--completed .ds-step__label {
    color: var(--color-text-primary);
}

@media (max-width: 1199.98px) {
    .ds-stepper__compact-header {
        display: flex;
    }

    .ds-stepper {
        gap: var(--space-2);
    }

    .ds-step {
        padding-block-end: var(--space-2);
    }

        .ds-step .mud-avatar.ds-step__tile,
        .ds-step__text {
            display: none;
        }
}

/* ==========================================================================
   4. KBD
   ========================================================================== */
.ds-kbd {
    display: inline-flex;
    align-items: center;
    padding: var(--space-0-5) var(--space-2);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-xs);
    font-family: var(--font-family-mono);
    font-size: var(--font-size-xs);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
    direction: ltr;
    unicode-bidi: isolate;
}

/* ==========================================================================
   5. SELECTION BAR AND GROUP HEADING
   ========================================================================== */
.ds-selection-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-6);
    background-color: var(--color-bg-primary-soft);
    border-block: var(--border-width-thin) solid var(--color-border-primary);
}

.ds-selection-bar--boxed {
    border: var(--border-width-thin) solid var(--color-border-primary);
    border-radius: var(--radius-lg);
}

.ds-selection-bar__label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
}

.ds-selection-bar__clear {
    margin-inline-start: auto;
}

/* The neighbours already draw these lines inside a flush card:
   pane header above the bar, bar above the table. */
.ds-pane-header + .ds-selection-bar {
    border-block-start: 0;
}

.ds-card--flush > .ds-selection-bar + .mud-table {
    border-block-start: 0;
}

/* Group heading: small bold label with a primary stripe at inline-start */
.ds-group-heading {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

    .ds-group-heading::before {
        content: "";
        flex-shrink: 0;
        inline-size: var(--border-width-thick);
        block-size: var(--size-icon-sm);
        background-color: var(--color-bg-primary);
        border-radius: var(--radius-full);
    }

/* Muted item count next to a group heading: "أسئلة نصية (2)" */
.ds-group-heading__count {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-regular);
    color: var(--color-text-muted);
}

.ds-group-heading--section {
    margin-block-end: var(--space-6);
    font-size: var(--font-size-md);
}

    .ds-group-heading--section::before {
        content: none;
    }

/* ==========================================================================
   6. CHOICE CARDS (question type) AND LAYOUT RADIO CARDS (question layout)
   ========================================================================== */

/* ---- Shared interaction states (both are <button role="radio">) ---- */
.ds-choice-card,
.ds-layout-card {
    position: relative;
    display: flex;
    align-items: center;
    inline-size: 100%;
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-lg);
    font-family: inherit;
    text-align: start;
    color: var(--color-text-foreground);
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--easing-standard), border-color var(--duration-fast) var(--easing-standard), box-shadow var(--duration-fast) var(--easing-standard);
}

    .ds-choice-card:hover,
    .ds-layout-card:hover {
        border-color: var(--color-border-input-hover);
        background-color: var(--color-bg-surface-hover);
    }

    .ds-choice-card:focus-visible,
    .ds-layout-card:focus-visible {
        outline: var(--focus-ring-width) solid var(--focus-ring-color);
        outline-offset: var(--focus-ring-offset);
    }

    .ds-choice-card:is(.is-selected, [aria-checked="true"]),
    .ds-layout-card:is(.is-selected, [aria-checked="true"]) {
        background-color: var(--color-bg-selected);
        border-color: var(--color-bg-primary);
        box-shadow: 0 0 0 var(--border-width-thin) var(--color-bg-primary);
    }

    .ds-choice-card:disabled,
    .ds-layout-card:disabled {
        background-color: var(--color-bg-disabled);
        border-color: var(--color-border-disabled);
        color: var(--color-text-on-disabled);
        box-shadow: none;
        cursor: not-allowed;
    }

        /* Disabled: the parts that set their own color step back too */
        .ds-choice-card:disabled :is(.ds-choice-card__title, .ds-choice-card__subtitle),
        .ds-layout-card:disabled :is(.ds-layout-card__title, .ds-layout-card__desc) {
            color: var(--color-text-on-disabled);
        }

        .ds-choice-card:disabled .mud-avatar.ds-choice-card__icon {
            background-color: var(--color-bg-surface-active);
            color: var(--color-text-on-disabled);
        }

        .ds-layout-card:disabled .ds-layout-card__radio {
            background-color: var(--color-bg-disabled);
            border-color: var(--color-border-disabled);
        }

/* ---- Choice card: compact, 36px soft icon tile at inline-start, no check mark ---- */
.ds-choice-card {
    gap: var(--space-3);
    padding: var(--space-4);
}

    .ds-choice-card .mud-avatar.mud-avatar-rounded.ds-choice-card__icon {
        inline-size: var(--size-control-sm);
        block-size: var(--size-control-sm);
        border-radius: var(--radius-md);
    }

        .ds-choice-card .mud-avatar.mud-avatar-rounded.ds-choice-card__icon .mud-icon-root {
            font-size: var(--size-icon-md);
        }

    .ds-choice-card:is(.is-selected, [aria-checked="true"]) .mud-avatar.ds-choice-card__icon {
        background-color: var(--color-bg-primary-soft-hover);
        box-shadow: inset 0 0 0 var(--border-width-thin) var(--color-border-primary);
    }

.ds-choice-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--space-0-5);
    min-inline-size: 0;
}

.ds-choice-card__title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-choice-card__subtitle {
    font-size: var(--font-size-2xs);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
}

/* ---- Layout radio card: wireframe at inline-start, text, radio at inline-end ---- */
.ds-layout-card {
    gap: var(--space-5);
    padding: var(--space-3) var(--space-4);
}

.ds-layout-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--space-1);
    min-inline-size: 0;
}

.ds-layout-card__title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-layout-card__desc {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    color: var(--color-text-secondary);
}

.ds-layout-card__preview {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    justify-content: center;
    gap: var(--space-1);
    inline-size: var(--size-wireframe-inline);
    block-size: var(--size-wireframe-block);
    padding: var(--space-2);
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-md);
}

.ds-wireframe-stem {
    inline-size: 75%;
    block-size: var(--space-1);
    background-color: var(--color-border-strong);
    border-radius: var(--radius-full);
}

.ds-wireframe-options {
    display: grid;
    gap: var(--space-1);
}

.ds-wireframe-options--vertical {
    grid-template-columns: 1fr;
}

.ds-wireframe-options--horizontal {
    grid-template-columns: repeat(2, 1fr);
}

.ds-wireframe-options--compact {
    grid-template-columns: repeat(4, 1fr);
}

.ds-wireframe-pill {
    block-size: var(--space-2);
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-xs);
}

.ds-layout-card__radio {
    position: relative;
    flex-shrink: 0;
    inline-size: var(--size-icon-md);
    block-size: var(--size-icon-md);
    margin-inline: var(--space-4);
    background-color: var(--color-bg-surface);
    border: var(--border-width-medium) solid var(--color-border-input-hover);
    border-radius: var(--radius-full);
}

.ds-layout-card:is(.is-selected, [aria-checked="true"]) .ds-layout-card__radio {
    border-color: var(--color-bg-primary);
}

    .ds-layout-card:is(.is-selected, [aria-checked="true"]) .ds-layout-card__radio::after {
        content: "";
        position: absolute;
        inset: var(--space-1);
        background-color: var(--color-bg-primary);
        border-radius: var(--radius-full);
    }

/* ==========================================================================
   7. EMPTY STATE (OesEmptyState.razor)
   ========================================================================== */
.ds-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-10);
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
    text-align: center;
}

.ds-empty-state__icon {
    inline-size: var(--size-icon-xl);
    block-size: var(--size-icon-xl);
    color: var(--color-text-muted);
}

.ds-empty-state__title {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-empty-state__subtitle {
    margin: 0;
    max-inline-size: var(--size-empty-state-text-max);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-muted);
}

.ds-empty-state.ds-empty-state--plain,
.mud-table .ds-empty-state {
    padding: 0;
    background-color: transparent;
    border: 0;
    border-radius: 0;
}

    .mud-table .ds-empty-state .ds-empty-state__title {
        font-size: var(--font-size-md);
    }

/* Compact empty state for panels and drop zones (24px icon, 14px title,
   12px hint). Combine with --plain when the container already draws a frame. */
.ds-empty-state.ds-empty-state--sm {
    gap: var(--space-2);
    padding-block: var(--space-8);
    padding-inline: var(--space-6);
}

.ds-empty-state--sm .ds-empty-state__icon {
    inline-size: var(--size-icon-lg);
    block-size: var(--size-icon-lg);
}

.ds-empty-state--sm .ds-empty-state__title {
    font-size: var(--font-size-sm);
}

.ds-empty-state--sm .ds-empty-state__subtitle {
    font-size: var(--font-size-xs);
}

/* Full-page / wizard-step empty state: fills the remaining viewport height */
.ds-empty-state.ds-empty-state--page {
    justify-content: center;
    min-block-size: clamp(20rem, calc(100dvh - 24rem), 36rem);
}

/* =========================================================
   8. NUMBER STEPPER (OesNumberStepper.razor) (MudIconButton + MudNumericField + MudIconButton)
   36px tall: two 36px square buttons and a 56px white value cell.
   Buttons clip their own ripple (overflow: hidden).
   ========================================================= */
.ds-number-stepper {
    display: inline-flex;
    align-items: stretch;
    block-size: var(--size-control-sm);
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-md);
}

    .ds-number-stepper .mud-button-root.mud-icon-button.mud-icon-button-size-small {
        position: relative;
        overflow: hidden;
        flex-shrink: 0;
        inline-size: var(--size-control-sm);
        min-inline-size: var(--size-control-sm);
        block-size: 100%;
        min-block-size: 0;
        padding: 0;
        background-color: transparent;
        border-radius: 0;
        color: var(--color-text-secondary);
    }


        .ds-number-stepper .mud-button-root.mud-icon-button.mud-icon-button-size-small:hover {
            background-color: var(--color-bg-surface-hover);
        }

        .ds-number-stepper .mud-button-root.mud-icon-button.mud-icon-button-size-small .mud-icon-root {
            font-size: var(--size-icon-sm);
        }

    /* Value cell: 56px wide (48 + 8) */
    .ds-number-stepper .mud-input-control {
        flex: 0 0 calc(var(--space-12) + var(--space-2));
        inline-size: calc(var(--space-12) + var(--space-2));
        min-inline-size: 0;
        block-size: 100%;
        margin: 0;
    }

    .ds-number-stepper .mud-input-control-input-container {
        block-size: 100%;
    }

    .ds-number-stepper .mud-input {
        block-size: 100%;
        margin: 0;
        padding: 0;
        background-color: var(--color-bg-surface);
        border-inline: var(--border-width-thin) solid var(--color-border-default);
    }

        .ds-number-stepper .mud-input input.mud-input-slot {
            block-size: 100%;
            margin: 0;
            padding: 0;
            font-family: var(--font-family-base);
            font-size: var(--font-size-sm);
            font-weight: var(--font-weight-bold);
            line-height: var(--line-height-tight);
            text-align: center;
            color: var(--color-text-foreground);
        }

    /* Disabled stepper (Disabled="true", e.g. inside a .ds-row-muted table row):
   MudBlazor disables the buttons and the field; the value text fades too. */
    .ds-number-stepper:has(.mud-input-control.mud-disabled, input:disabled) .mud-input input.mud-input-slot {
        color: var(--color-text-disabled);
    }

/* ==========================================================================
   9. SCORE STRIP
   ========================================================================== */
/* Row 1: title + status badge (inline-start), totals (inline-end).
   Row 2: one full-width progress bar. */
.ds-score-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background-color: var(--color-bg-surface-subtle);
    border-block: var(--border-width-thin) solid var(--color-border-default);
}

.ds-score-strip__start {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    min-inline-size: 0;
}

.ds-score-strip__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

/* Status badge in the strip: slightly taller than table badges, 16px check-circle icon */
.ds-score-strip .mud-chip.mud-chip.ds-badge {
    min-block-size: var(--size-control-xs);
    padding-inline: var(--space-3);
    font-size: var(--font-size-xs);
}

    .ds-score-strip .mud-chip.mud-chip.ds-badge .mud-chip-icon {
        font-size: var(--size-icon-sm);
    }

.ds-score-strip__totals {
    font-size: var(--font-size-md);
    line-height: var(--line-height-tight);
    color: var(--color-text-muted);
}

    .ds-score-strip__totals strong {
        font-weight: var(--font-weight-bold);
        color: var(--color-text-foreground);
    }

/* The progress bar always takes its own full-width row */
.ds-score-strip > .mud-progress-linear {
    flex: 1 0 100%;
    margin: 0;
}

/* Inside a flush card the pane header above and the table below already draw
   the lines, so the strip does not add a second one. */
.ds-pane-header + .ds-score-strip {
    border-block-start: 0;
}

.ds-card--flush > .ds-score-strip + .mud-table {
    border-block-start: 0;
}

/* ==========================================================================
   10. QUESTION ROW (picker list) & FILTER STRIP
   ========================================================================== */
.ds-question-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background-color: var(--color-bg-surface);
    border-block-end: var(--border-width-thin) solid var(--color-border-divider);
    transition: background-color var(--duration-fast) var(--easing-standard);
}

    .ds-question-row:hover {
        background-color: var(--color-bg-surface-hover);
    }

.ds-question-row__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--space-1);
    min-inline-size: 0;
}

/* 12px bold, tight leading: one-line Arabic questions stay on one line */
.ds-question-row__title {
    margin: 0;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

/* ---- Toggle: 32px circle. Off = subtle gray + "+", on = solid primary + white check.
        State comes from the .is-selected class set in markup. ---- */
.ds-question-row .mud-button-root.mud-icon-button.ds-question-row__toggle {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    inline-size: var(--space-8);
    min-inline-size: var(--space-8);
    block-size: var(--space-8);
    min-block-size: var(--space-8);
    padding: 0;
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    transition: background-color var(--duration-fast) var(--easing-standard), border-color var(--duration-fast) var(--easing-standard), color var(--duration-fast) var(--easing-standard);
}


    .ds-question-row .mud-button-root.mud-icon-button.ds-question-row__toggle:hover {
        background-color: var(--color-bg-surface-hover);
    }

    .ds-question-row .mud-button-root.mud-icon-button.ds-question-row__toggle .mud-icon-root {
        font-size: var(--size-icon-sm);
    }

    .ds-question-row .mud-button-root.mud-icon-button.ds-question-row__toggle.is-selected {
        background-color: var(--color-bg-primary);
        border-color: var(--color-bg-primary);
        color: var(--color-text-on-primary);
    }

        .ds-question-row .mud-button-root.mud-icon-button.ds-question-row__toggle.is-selected:hover {
            background-color: var(--color-bg-primary-hover);
        }

        /* Pinned + selected: stays solid primary (no disabled fade) */
        .ds-question-row .mud-button-root.mud-icon-button.ds-question-row__toggle.is-selected:is(:disabled, .mud-disabled) {
            background-color: var(--color-bg-primary);
            border-color: var(--color-bg-primary);
            color: var(--color-text-on-primary);
            opacity: 1;
            cursor: default;
        }

/* ---- Head: code badge first, then the title, centered on one line ---- */
.ds-question-row__head {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 0;
}

    .ds-question-row__head > .mud-chip.mud-chip.ds-badge {
        flex-shrink: 0;
        border-radius: var(--radius-sm);
    }

    .ds-question-row__head .ds-question-row__title {
        flex: 1 1 auto;
        min-inline-size: 0;
        margin: 0;
    }

.ds-question-text {
    min-inline-size: 0;
    max-inline-size: none;
    overflow-wrap: anywhere;
}

    .ds-question-text :is(p, div) {
        max-inline-size: none;
        margin: 0;
    }

    .ds-question-text :is(img, video, audio) {
        max-inline-size: 100%;
        block-size: auto;
    }

/* ---- Meta line: items separated by centered dots ---- */
.ds-question-row__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    font-size: var(--font-size-xs);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
}

    .ds-question-row__meta > * + *::before {
        content: "\2022";
        margin-inline: var(--space-2);
        font-weight: var(--font-weight-regular);
        color: var(--color-text-muted);
    }

/* ---- Available-questions list (picker main pane): fixed height, scrolls inside.
        Same height as .ds-selected-panel__list so both picker cards line up. ---- */
.ds-question-list {
    flex: 0 0 auto;
    block-size: var(--size-picker-list);
    max-block-size: var(--size-picker-list);
    overflow-x: hidden;
    overflow-y: auto;
}

    .ds-question-list > .ds-question-row:last-child {
        border-block-end: 0;
    }

/* ---- Full-bleed filter strip under the picker header; selects sit on white ---- */
.ds-filter-strip {
    padding-block: var(--space-3);
    padding-inline: var(--space-4);
    background-color: var(--color-bg-surface-subtle);
    /* The pane header above already draws the top line */
    border-block-end: var(--border-width-thin) solid var(--color-border-divider);
}

    .ds-filter-strip .ds-field .mud-input.mud-input-outlined {
        background-color: var(--color-bg-surface);
    }

    .ds-filter-strip .ds-field {
        gap: var(--space-1);
    }

    .ds-filter-strip .ds-field__label {
        font-size: var(--font-size-xs);
        color: var(--color-text-secondary);
    }

.ds-filter-strip__choices {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    min-block-size: var(--size-control-sm);
}

.mud-card.ds-card--flush .ds-filter-strip {
    border-block-start: var(--border-width-thin) solid var(--color-border-divider);
    border-block-end: 0;
}

/* Stand-alone filter strip with no card or pane header around it (Blocks step) */
.ds-filter-strip.ds-filter-strip--boxed {
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-lg);
}

/* ==========================================================================
   11. SELECTED QUESTIONS PANEL (split-pane side column)
   Single source for .ds-selected-panel__* and .ds-selected-item
   (the duplicate rules that used to live in section 10 were removed).
   ========================================================================== */

/* Selected list: same fixed height as the available-questions list
   (--size-picker-list), scrolls vertically only, never horizontally */
.ds-selected-panel__list {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    block-size: var(--size-picker-list);
    max-block-size: var(--size-picker-list);
    overflow-x: hidden;
    overflow-y: auto;
}

/* Selected item: text at inline-start, remove / lock at inline-end */
.ds-selected-item {
    display: flex;
    flex-shrink: 0;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-block-end: var(--border-width-thin) solid var(--color-border-divider);
}

.ds-selected-item__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--space-1);
    min-inline-size: 0;
}

.ds-selected-item__title {
    margin: 0;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    overflow-wrap: anywhere;
    color: var(--color-text-foreground);
}

/* Compact 24px trailing slot (remove button or lock), 14px icon */
.ds-selected-item__lock {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    inline-size: var(--size-icon-lg);
    block-size: var(--size-icon-lg);
    color: var(--color-text-muted);
}

    .ds-selected-item__lock .mud-icon-root {
        font-size: var(--size-icon-xs);
    }

/* Compact 24px remove button, 14px icon; ripple clipped inside */
.ds-selected-item .mud-button-root.mud-icon-button.ds-selected-item__remove {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    inline-size: var(--size-icon-lg);
    min-inline-size: var(--size-icon-lg);
    block-size: var(--size-icon-lg);
    min-block-size: var(--size-icon-lg);
    padding: 0;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
}


    .ds-selected-item .mud-button-root.mud-icon-button.ds-selected-item__remove .mud-icon-root {
        font-size: var(--size-icon-xs);
    }

    .ds-selected-item .mud-button-root.mud-icon-button.ds-selected-item__remove:hover {
        background-color: var(--color-status-danger-soft);
        color: var(--color-status-danger-text);
    }

/* Footer: pinned to the bottom edge of the side card */
.ds-selected-panel__footer {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background-color: var(--color-bg-surface-subtle);
    border-block-start: var(--border-width-thin) solid var(--color-border-divider);
    border-end-start-radius: var(--radius-lg);
    border-end-end-radius: var(--radius-lg);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

    .ds-selected-panel__footer > * + *::before {
        content: "\2022";
        margin-inline-end: var(--space-2);
    }

/* =========================================================
   12. Drop lists (pool + exam-section zones), drag cards
       and the "select & move" bar
   ========================================================= */
.ds-drop-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-block-size: var(--space-24);
    max-block-size: var(--size-panel-scroll-max);
    overflow-x: hidden;
    overflow-y: auto;
}

    /* Tall variant for a full-height question pool (Step 4): ~576px before it scrolls */
    .ds-drop-list.ds-drop-list--tall {
        max-block-size: calc(var(--space-24) * 6);
    }

.ds-drag-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding-block: var(--space-3);
    padding-inline: var(--space-4);
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-md);
    cursor: grab;
    transition: background-color var(--duration-fast) var(--easing-standard), border-color var(--duration-fast) var(--easing-standard);
}

    .ds-drag-card:active {
        cursor: grabbing;
    }

    /* Select & move mode: checkbox-driven, so no grab cursor */
    .ds-drag-card.is-selectable {
        cursor: default;
    }

    /* Selected (checked) card: .is-selected is the system-wide state class;
       .is-checked is kept for existing select-and-move markup */
    .ds-drag-card:is(.is-selected, .is-checked) {
        background-color: var(--color-bg-selected);
        border-color: var(--color-border-primary);
    }

/* Handle (or checkbox) + code + difficulty at inline-start; remove pushed to inline-end */
.ds-drag-card__header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-block-size: var(--size-icon-lg);
}

.ds-drag-card__handle {
    display: inline-flex;
    color: var(--color-text-muted);
}

    .ds-drag-card__handle .mud-icon-root {
        font-size: var(--size-icon-sm);
    }

/* Checkbox slot (select & move mode). The checkbox itself is MudCheckBox with
   Class="ds-checkbox--sm" (mudblazor-overrides.css section 13). */
.ds-drag-card__check {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
}

/* Compact 24px remove button, 14px icon; ripple clipped inside */
.ds-drag-card__header .mud-button-root.mud-icon-button.ds-drag-card__remove {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    margin-inline-start: auto;
    inline-size: var(--size-icon-lg);
    min-inline-size: var(--size-icon-lg);
    block-size: var(--size-icon-lg);
    min-block-size: var(--size-icon-lg);
    padding: 0;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
}


    .ds-drag-card__header .mud-button-root.mud-icon-button.ds-drag-card__remove .mud-icon-root {
        font-size: var(--size-icon-xs);
    }

    .ds-drag-card__header .mud-button-root.mud-icon-button.ds-drag-card__remove:hover {
        background-color: var(--color-status-danger-soft);
        color: var(--color-status-danger-text);
    }

/* When the remove button is wrapped in MudTooltip, push the tooltip root instead */
.ds-drag-card__header > .mud-tooltip-root:last-child {
    margin-inline-start: auto;
}

/* 12px bold question text, tight leading */
.ds-drag-card__text {
    margin: 0;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-drag-card__subtitle {
    margin: 0;
    font-size: var(--font-size-2xs);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
}

/* Question body inside a drag card: rich HTML from the editor */
.ds-drag-card__text > :is(p, div):last-child {
    margin-block-end: 0;
}

/* Media in question bodies stay thumbnail-sized (replaces the legacy unscoped
   <style> block that resized media across the whole page) */
.ds-drag-card__text :is(img, video) {
    max-inline-size: calc(var(--space-24) + var(--space-3));
    max-block-size: var(--space-24);
    object-fit: contain;
}

.ds-drag-card__text audio {
    max-inline-size: 100%;
    max-block-size: var(--space-10);
}

/* "قراءة المزيد / أقل" toggle under a long question body (drag cards and table rows).
   A <span role="button"> on purpose: it must stop pointer events from starting a
   drag, which a MudButton cannot do. */
:is(.ds-drag-card__more, .ds-read-more) {
    align-self: flex-start;
    border-radius: var(--radius-xs);
    font-size: var(--font-size-2xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-link);
    cursor: pointer;
}

    :is(.ds-drag-card__more, .ds-read-more):hover {
        color: var(--color-text-link-hover);
    }

    :is(.ds-drag-card__more, .ds-read-more):focus-visible {
        outline: var(--focus-ring-width) solid var(--focus-ring-color);
        outline-offset: var(--focus-ring-offset);
    }

/* ---- Select & move: slim tools row under the pool search ----
   Only "تحديد الكل" and a muted hint; no colored background, so the mode
   reads as a quiet state change rather than a new panel. */
.ds-pool-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-inline-size: 0;
}

.ds-pool-tools__hint {
    font-size: var(--font-size-2xs);
    color: var(--color-text-muted);
}

/* ---- Select & move: one-line action bar pinned to the pool's bottom edge ----
   Rendered only while 1+ cards are checked:
   [× clear] [N محدد] ........ [target section select] [نقل] */
.ds-move-bar {
    display: flex;
    flex-shrink: 0;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--space-2);
    padding-block: var(--space-2);
    padding-inline: var(--space-3);
    background-color: var(--color-bg-primary-soft);
    border-block-start: var(--border-width-thin) solid var(--color-border-primary);
    animation: ds-move-bar-in var(--duration-normal) var(--easing-decelerate);
}

.ds-move-bar__count {
    flex-shrink: 0;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    white-space: nowrap;
    color: var(--color-text-primary);
}

.ds-move-bar .ds-field {
    flex: 1 1 auto;
    min-inline-size: 0;
    max-inline-size: calc(var(--space-24) * 2);
    margin-inline-start: auto;
}

    .ds-move-bar .ds-field .mud-input.mud-input-outlined {
        background-color: var(--color-bg-surface);
    }

        .ds-move-bar .ds-field .mud-input.mud-input-outlined .mud-input-slot {
            font-size: var(--font-size-xs);
        }

.ds-move-bar > .mud-button-root {
    flex-shrink: 0;
}

/* Clear-selection (×) button: 28px, primary tint */
.ds-move-bar .mud-button-root.mud-icon-button.ds-move-bar__clear {
    inline-size: var(--size-control-xs);
    min-inline-size: var(--size-control-xs);
    block-size: var(--size-control-xs);
    min-block-size: var(--size-control-xs);
    padding: 0;
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
}

    .ds-move-bar .mud-button-root.mud-icon-button.ds-move-bar__clear .mud-icon-root {
        font-size: var(--size-icon-sm);
    }

    .ds-move-bar .mud-button-root.mud-icon-button.ds-move-bar__clear:hover {
        background-color: var(--color-bg-primary-soft-hover);
    }

@keyframes ds-move-bar-in {
    from {
        opacity: 0;
        transform: translateY(var(--space-2));
    }
}

/* Drop states while a card is dragged. MudDropZone CanDropClass / NoDropClass,
   shown on every zone from drag start with ApplyDropClassesOnDragStarted="true". */
.ds-drop-list.ds-drop-zone--can-drop {
    background-color: var(--color-bg-primary-soft);
    outline: var(--border-width-medium) dashed var(--color-border-primary);
    outline-offset: var(--space-1);
    border-radius: var(--radius-md);
}

.ds-drop-list.ds-drop-zone--no-drop {
    background-color: var(--color-status-danger-soft);
    outline: var(--border-width-medium) dashed var(--color-status-danger-border);
    outline-offset: var(--space-1);
    border-radius: var(--radius-md);
    cursor: no-drop;
}

/* The card being dragged (MudDropContainer ItemDraggingClass) */
.ds-drag-card.ds-drag-card--dragging {
    opacity: var(--opacity-disabled);
    border-style: dashed;
}

/* Empty exam-section drop target */
.ds-drop-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding-block: var(--space-10);
    padding-inline: var(--space-6);
    border: var(--border-width-thin) dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
    text-align: center;
}

    .ds-drop-empty .mud-icon-root {
        font-size: var(--size-icon-lg);
        color: var(--color-text-secondary);
    }

.ds-drop-empty__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-foreground);
}

.ds-drop-empty__desc {
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* ==========================================================================
   13. QUESTION EDITOR PARTS
       Reused by the Question Wizard, language drawers and question banks:
       drawer shell, language/numeral bar, field label row with counter,
       collapsible option card, list header and answer rows.
   ========================================================================== */

/* ---- Drawer shell: fixed header / scrolling body / fixed footer ----
   <MudDrawer Variant="Temporary"> children:
     .ds-drawer__header | (optional MudToolBar strip) | .ds-drawer__body | .ds-drawer__footer */
.ds-drawer__header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    border-block-end: var(--border-width-thin) solid var(--color-border-default);
}

.ds-drawer__title {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-drawer__subtitle {
    margin: var(--space-1) 0 0;
    font-size: var(--font-size-xs);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
}

/* Title row (NmrDrawer TitleMeta): the title followed by inline badges (code, status) */
.ds-drawer__title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
}

.ds-drawer__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--space-5);
    min-block-size: 0;
    padding: var(--space-6);
    overflow-x: hidden;
    overflow-y: auto;
}

.ds-drawer__footer {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-block-start: var(--border-width-thin) solid var(--color-border-default);
}
/* ---- Subtle drawer (NmrDrawer Subtle): gray canvas so white cards stand out ---- */
.mud-drawer.ds-drawer--subtle .ds-drawer__body {
    background-color: var(--color-bg-surface-subtle);
}

/* ---- Tabs drawer (NmrDrawer Tabs): a MudTabs replaces .ds-drawer__body.
   The tab bar stays fixed under the header; only the active panel scrolls.
   <MudTabs Class="ds-tabs--fill" Elevation="0" ApplyEffectsToContainer="false">
   MudBlazor 8.7 internals targeted: .mud-tabs-tabbar and .mud-tabs-panels (re-check after upgrades). ---- */
.mud-drawer.ds-drawer--tabs .ds-drawer__header {
    padding-block-end: var(--space-3);
    border-block-end: 0;
}

.mud-drawer .mud-tabs.ds-tabs--fill {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-block-size: 0;
}

    .mud-drawer .mud-tabs.ds-tabs--fill .mud-tabs-tabbar {
        flex-shrink: 0;
        padding-inline: var(--space-6);
    }

    .mud-drawer .mud-tabs.ds-tabs--fill .mud-tabs-panels {
        flex: 1 1 auto;
        min-block-size: 0;
        padding: var(--space-6);
        overflow-x: hidden;
        overflow-y: auto;
    }

.mud-drawer.ds-drawer--subtle .mud-tabs.ds-tabs--fill .mud-tabs-panels {
    background-color: var(--color-bg-surface-subtle);
}

/* Panel content stack inside a tab: cards 20px apart */
.ds-drawer__panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}


/* ---- Option bar: subtle gray box with two labelled control groups
   (e.g. language select at inline-start, numeral format toggle at inline-end) ---- */
.ds-option-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-4);
    padding-block: calc(var(--space-2) + var(--space-0-5));
    padding-inline: var(--space-4);
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-md);
}

.ds-option-bar__group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 0;
    font-size: var(--font-size-xs);
    white-space: nowrap;
    color: var(--color-text-secondary);
}

    .ds-option-bar__group > .mud-icon-root {
        flex-shrink: 0;
        font-size: var(--size-icon-sm);
        color: var(--color-text-muted);
    }

    /* Controls sit on white inside the gray bar */
    .ds-option-bar__group .ds-field {
        inline-size: calc(var(--space-24) * 2);
    }

        .ds-option-bar__group .ds-field .mud-input.mud-input-outlined {
            background-color: var(--color-bg-surface);
        }

    .ds-option-bar__group .mud-toggle-group {
        background-color: var(--color-bg-surface);
    }

/* ---- Field label row: label at inline-start, live counter / hint at inline-end ---- */
.ds-field__label-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
}

.ds-field__counter {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* ---- Collapsible option card: header row with a switch; body revealed when on ---- */
.ds-collapsible-card {
    overflow: hidden;
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-lg);
}

.ds-collapsible-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding-block: var(--space-2);
    padding-inline: var(--space-5);
}

.ds-collapsible-card__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 0;
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-foreground);
}

    .ds-collapsible-card__title .mud-icon-root {
        flex-shrink: 0;
        font-size: var(--size-icon-sm);
        color: var(--color-text-secondary);
    }

.ds-collapsible-card__optional {
    font-weight: var(--font-weight-regular);
    color: var(--color-text-muted);
}

.ds-collapsible-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5) var(--space-5);
    border-block-start: var(--border-width-thin) solid var(--color-border-divider);
}

.ds-collapsible-card__body-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* ---- List header: title + muted hint at inline-start, count badge at inline-end ---- */
.ds-list-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.ds-list-header__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-foreground);
}

.ds-list-header__hint {
    font-weight: var(--font-weight-regular);
    color: var(--color-text-muted);
}

/* ---- Answer row: [correct mark] [#١] [text field] ........ [image] [delete] ---- */
.ds-answer-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-lg);
    transition: background-color var(--duration-fast) var(--easing-standard), border-color var(--duration-fast) var(--easing-standard);
}

    .ds-answer-row.is-correct {
        background-color: var(--color-status-success-soft);
        border-color: var(--color-status-success-solid);
    }

    /* The text field stays white on the tinted correct row */
    .ds-answer-row .ds-field .mud-input.mud-input-outlined {
        background-color: var(--color-bg-surface);
    }

/* Correct-answer radio: empty gray ring, or a solid green disc with a white check.
   <button type="button" role="radio" aria-checked="..." class="ds-answer-row__mark"> */
.ds-answer-row__mark {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    inline-size: var(--size-icon-lg);
    block-size: var(--size-icon-lg);
    padding: 0;
    background-color: var(--color-bg-surface);
    border: var(--border-width-medium) solid var(--color-border-input);
    border-radius: var(--radius-full);
    color: transparent;
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--easing-standard), border-color var(--duration-fast) var(--easing-standard);
}

    .ds-answer-row__mark:hover {
        border-color: var(--color-status-success-solid);
    }

    .ds-answer-row__mark:focus-visible {
        outline: var(--focus-ring-width) solid var(--focus-ring-color);
        outline-offset: var(--focus-ring-offset);
    }

    .ds-answer-row__mark .mud-icon-root {
        font-size: var(--size-icon-sm);
    }

    .ds-answer-row__mark[aria-checked="true"] {
        background-color: var(--color-status-success-solid);
        border-color: var(--color-status-success-solid);
        color: var(--color-status-success-on-solid);
    }

/* Answer index pill (#١ / #1): soft gray, follows the numeral-format setting */
.ds-answer-row__index {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    min-inline-size: var(--size-icon-xl);
    block-size: var(--size-icon-lg);
    padding-inline: var(--space-2);
    background-color: var(--color-bg-surface-active);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-2xs);
    font-weight: var(--font-weight-bold);
    line-height: 1;
    color: var(--color-text-secondary);
}

/* Trailing actions: 32px icon buttons, 16px icons */
.ds-answer-row__actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: var(--space-1);
}

    .ds-answer-row__actions .mud-button-root.mud-icon-button {
        position: relative;
        overflow: hidden;
        inline-size: var(--space-8);
        min-inline-size: var(--space-8);
        block-size: var(--space-8);
        min-block-size: var(--space-8);
        padding: 0;
        border-radius: var(--radius-sm);
    }

        .ds-answer-row__actions .mud-button-root.mud-icon-button .mud-icon-root {
            font-size: var(--size-icon-sm);
        }

        .ds-answer-row__actions .mud-button-root.mud-icon-button:hover {
            background-color: var(--color-bg-surface-hover);
        }

        .ds-answer-row__actions .mud-button-root.mud-icon-button.mud-error-text:hover {
            background-color: var(--color-status-danger-soft);
        }

/* ---- Read-only answer list (NmrAnswerList): question review and details drawer ----
   Not interactive: no inputs and nothing in the Tab order. The correct option gets a
   green ring and dot plus visually hidden text, so correctness never relies on color. */
.ds-question-stem {
    margin-block: 0 var(--space-4);
    margin-inline: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-normal);
    color: var(--color-text-foreground);
    overflow-wrap: anywhere;
}

.ds-answer-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    margin: 0;
    padding: 0;
    list-style: none;
}

.ds-answer-list__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-block-size: var(--size-touch-target-min);
    padding-inline: var(--space-3);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    color: var(--color-text-foreground);
}

.ds-answer-list__mark {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    inline-size: var(--size-icon-md);
    block-size: var(--size-icon-md);
    background-color: var(--color-bg-surface);
    border: var(--border-width-medium) solid var(--color-border-input);
    border-radius: var(--radius-full);
}

    .ds-answer-list__mark::after {
        content: "";
        inline-size: calc(var(--size-icon-md) / 2);
        block-size: calc(var(--size-icon-md) / 2);
        border-radius: var(--radius-full);
    }

.ds-answer-list__item.is-correct .ds-answer-list__mark {
    border-color: var(--color-status-success-solid);
}

    .ds-answer-list__item.is-correct .ds-answer-list__mark::after {
        background-color: var(--color-status-success-solid);
    }

.ds-answer-list__text {
    flex: 1 1 auto;
    min-inline-size: 0;
    overflow-wrap: anywhere;
}

/* ==========================================================================
   14. SUMMARY STRIP (exam review card)
   Flush row of stats inside a card, separated by short centered hairlines.
   Value = bold number/word; unit = regular, smaller ("100 دقيقة").
   ========================================================================== */
.ds-summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(calc(var(--space-20) * 2), 1fr));
    row-gap: var(--space-2);
    padding-block: var(--space-2);
}

.ds-summary-strip__item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-inline-size: 0;
    padding-block: var(--space-4);
    padding-inline: var(--space-6);
}

    /* Short hairline, inset from top and bottom, between neighbours */
    .ds-summary-strip__item + .ds-summary-strip__item::before {
        content: "";
        position: absolute;
        inset-block: var(--space-4);
        inset-inline-start: 0;
        border-inline-start: var(--border-width-thin) solid var(--color-border-default);
    }

.ds-summary-strip__label {
    font-size: var(--font-size-xs);
    line-height: var(--line-height-snug);
    color: var(--color-text-muted);
}

.ds-summary-strip__value {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-tight);
    color: var(--color-text-secondary);
}

    .ds-summary-strip__value strong {
        font-size: var(--font-size-lg);
        font-weight: var(--font-weight-bold);
        color: var(--color-text-foreground);
    }

.ds-summary-strip.ds-summary-strip--compact {
    padding-block: 0;
}

.ds-summary-strip--compact .ds-summary-strip__item {
    padding-block: var(--space-1);
}

    .ds-summary-strip--compact .ds-summary-strip__item + .ds-summary-strip__item::before {
        inset-block: var(--space-1);
    }

/* Card header overline above the review title ("مراجعة الاختبار") */
.ds-overline {
    display: block;
    margin-block-end: var(--space-1);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-snug);
    color: var(--color-text-primary);
}

/* ==========================================================================
   15. PREVIEW FRAME (student preview of the question layout)
   Toolbar: title | device toggle | language select. Gray canvas holds a white
   question card whose width follows the device and whose choice layout
   follows the selected layout radio card (vertical / horizontal / compact).
   ========================================================================== */
.ds-preview-frame {
    overflow: hidden;
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-lg);
}

.ds-preview-frame__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-block-end: var(--border-width-thin) solid var(--color-border-default);
}

.ds-preview-frame__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    white-space: nowrap;
    color: var(--color-text-foreground);
}

/* Language label + compact select, pushed to inline-end */
.ds-preview-frame__lang {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-inline-start: auto;
    font-size: var(--font-size-xs);
    white-space: nowrap;
    color: var(--color-text-secondary);
}

    .ds-preview-frame__lang .ds-field {
        inline-size: calc(var(--space-24) + var(--space-2));
    }

        .ds-preview-frame__lang .ds-field .mud-input.mud-input-outlined .mud-input-slot {
            font-size: var(--font-size-xs);
        }

.ds-preview-frame__canvas {
    padding: var(--space-4);
    background-color: var(--color-bg-surface-active);
}

.ds-preview-frame__card {
    inline-size: 100%;
    max-inline-size: 100%;
    margin-inline: auto;
    padding: var(--space-5);
    background-color: var(--color-bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: max-inline-size var(--duration-slow) var(--easing-standard);
}

    .ds-preview-frame__card.ds-preview-frame__card--tablet {
        max-inline-size: calc(var(--space-24) * 4);
    }

    .ds-preview-frame__card.ds-preview-frame__card--phone {
        max-inline-size: calc(var(--space-16) * 5);
    }

.ds-preview-frame__meta {
    margin: 0 0 var(--space-2);
    font-size: var(--font-size-2xs);
    color: var(--color-text-muted);
}

.ds-preview-frame__question {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-normal);
    color: var(--color-text-foreground);
}

.ds-preview-frame__hint {
    margin: var(--space-1) 0 var(--space-3);
    font-size: var(--font-size-2xs);
    color: var(--color-text-muted);
}

/* Choice layouts (class follows the selected layout radio card) */
.ds-preview-choices {
    display: grid;
    gap: var(--space-1);
}

.ds-preview-choices--vertical {
    grid-template-columns: minmax(0, 1fr);
}

.ds-preview-choices--horizontal {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
}

.ds-preview-choices--compact {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
}

.ds-preview-choice {
    min-inline-size: 0;
}

    .ds-preview-choice .mud-typography {
        font-size: var(--font-size-xs);
        font-weight: var(--font-weight-semibold);
        color: var(--color-text-foreground);
    }

.ds-preview-choices--horizontal .ds-preview-choice {
    padding-inline: var(--space-2);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-md);
}

/* ==========================================================================
   16. MODEL ITEM (exam review master column: نموذج 1 / نموذج 2)
   <button role="radio">: name at inline-start, section count at inline-end.
   ========================================================================== */


.ds-model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    inline-size: 100%;
    min-block-size: var(--size-touch-target-min);
    padding-block: var(--space-2);
    padding-inline: var(--space-4);
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-md);
    font-family: inherit;
    text-align: start;
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--easing-standard), border-color var(--duration-fast) var(--easing-standard);
}

    .ds-model-item:hover {
        background-color: var(--color-bg-surface-hover);
    }

    .ds-model-item:focus-visible {
        outline: var(--focus-ring-width) solid var(--focus-ring-color);
        outline-offset: var(--focus-ring-offset);
    }

    .ds-model-item:is(.is-selected, [aria-checked="true"]) {
        background-color: var(--color-bg-selected);
        border-color: var(--color-border-primary);
    }

.ds-model-item__name {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-foreground);
}

.ds-model-item:is(.is-selected, [aria-checked="true"]) .ds-model-item__name {
    color: var(--color-text-primary);
}

.ds-model-item__count {
    font-size: var(--font-size-2xs);
    color: var(--color-text-muted);
}

/* ==========================================================================
   17. TREE PICKER (.ds-tree-picker)
   Skin for the shared GrpcTreeViewTemplate / TreeNodeComponent markup, applied
   only inside <div class="ds-tree-picker">, so other pages keep their look.

   One flat card per node. Row order, inline-start -> inline-end:
     chevron | checkbox | title ........ status chip
   - .tree-node (legacy outer box) is reset to a plain wrapper; the card is its
     inner ".d-flex" row.
   - MudText is flattened (display: contents) so arrow, title and chip join
     the row's flex layout next to the checkbox (.menu-container).
   - The legacy filled triangle is hidden and replaced by a CSS stroke chevron
     (two borders of a rotated square) drawn in currentColor.
   - Root (bank) rows stay neutral even when checked; only child rows take
     the selected tint.
   !important appears only where a Bootstrap utility class carries it
   (justify-content-between, mt-3).
   ========================================================================== */

.ds-tree-picker {
    /* Chevron rotation sign: +1 in LTR, -1 in RTL (physical transform) */
    --ds-tree-chevron-dir: 1;
}

[dir="rtl"] .ds-tree-picker,
.rtl .ds-tree-picker {
    --ds-tree-chevron-dir: -1;
}

/* ---- Container + toolbar strip ----
   The shared template renders: ExpandAll, CollapseAll, [SelectAll], div.tree.
   The container becomes a wrapping flex row: the buttons form the strip,
   the tree takes the next full row. The strip runs edge-to-edge by pulling
   the container out over the dialog content padding (space-5 / space-6). */
.ds-tree-picker .tree-container {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-block: calc(var(--space-5) * -1) 0;
    margin-inline: calc(var(--space-6) * -1);
    padding-block: calc(var(--space-2) + var(--space-0-5)) 0;
    padding-inline: var(--space-6);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

    /* Strip background + bottom divider, behind the button row only */
    .ds-tree-picker .tree-container::before {
        content: "";
        position: absolute;
        z-index: -1;
        inset-block-start: 0;
        inset-inline: 0;
        block-size: calc(var(--size-control-sm) + (var(--space-2) + var(--space-0-5)) * 2);
        background-color: var(--color-bg-surface-subtle);
        border-block-end: var(--border-width-thin) solid var(--color-border-divider);
    }

    /* ExpandAll / CollapseAll: compact outlined surface buttons at inline-end */
    .ds-tree-picker .tree-container > .mud-button-root.ExpandCollapseStyling,
    .ds-tree-picker .tree-container > .mud-button-root.ExpandCollapseStyling .mud-button-label {
        color: var(--color-text-secondary);
    }

    .ds-tree-picker .tree-container > .mud-button-root.ExpandCollapseStyling {
        min-block-size: var(--size-control-sm);
        margin: 0;
        padding-block: 0;
        padding-inline: var(--space-3);
        background-color: var(--color-bg-surface);
        border: var(--border-width-thin) solid var(--color-border-default);
        border-radius: var(--radius-md);
        font-size: var(--font-size-xs);
        font-weight: var(--font-weight-medium);
        box-shadow: none;
    }

        .ds-tree-picker .tree-container > .mud-button-root.ExpandCollapseStyling:hover {
            background-color: var(--color-bg-surface-hover);
        }

            .ds-tree-picker .tree-container > .mud-button-root.ExpandCollapseStyling:hover,
            .ds-tree-picker .tree-container > .mud-button-root.ExpandCollapseStyling:hover .mud-button-label {
                color: var(--color-text-foreground);
            }

        /* First button (ExpandAll) pushes itself and CollapseAll to the inline-end */
        .ds-tree-picker .tree-container > .mud-button-root.ExpandCollapseStyling:nth-of-type(1) {
            margin-inline-start: auto;
        }

        /* SelectAll (3rd button, only on multi-select trees): same outlined button, placed at inline-start */
        .ds-tree-picker .tree-container > .mud-button-root.ExpandCollapseStyling:nth-of-type(3) {
            order: -1;
        }

    /* Tree: full row under the strip */
    .ds-tree-picker .tree-container > .tree {
        flex: 1 0 100%;
        margin-block-start: calc(var(--space-2) + var(--space-0-5) + var(--space-5)) !important;
        padding: 0;
    }

/* ---- Legacy node wrapper: plain block, no second box ---- */
.ds-tree-picker .tree .tree-node {
    position: relative;
    margin-block: 0 var(--space-3);
    margin-inline: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

    .ds-tree-picker .tree .tree-node::after,
    .ds-tree-picker .tree > .tree-node::before {
        content: none;
    }

    /* ---- The card (one per node). Default = unchecked child branch ---- */
    .ds-tree-picker .tree .tree-node > .d-flex {
        /* Set here, not left to Bootstrap's .d-flex: without it the order / gap / flex rules below do nothing */
        position: relative;
        display: flex;
        align-items: center;
        justify-content: flex-start !important;
        gap: var(--space-3);
        box-sizing: border-box;
        padding-block: var(--space-3);
        padding-inline: var(--space-4);
        background-color: var(--color-bg-surface-subtle);
        border: var(--border-width-thin) solid var(--color-border-default);
        border-radius: var(--radius-md);
        transition: background-color var(--duration-fast) var(--easing-standard), border-color var(--duration-fast) var(--easing-standard);
    }

        .ds-tree-picker .tree .tree-node > .d-flex > .mud-typography {
            display: contents;
        }

            /* 1. Chevron slot (24px; empty spacer on leaf nodes) */
            /* 24 x 24 box at inline-start; leaf nodes render an empty span and keep the same space */
            .ds-tree-picker .tree .tree-node > .d-flex > .mud-typography > span:first-child {
                position: relative;
                order: 0;
                display: inline-flex !important;
                flex-shrink: 0;
                align-items: center;
                justify-content: center;
                align-self: center;
                inline-size: var(--size-icon-lg);
                block-size: var(--size-icon-lg);
                margin: 0 !important;
                padding: 0 !important;
                line-height: 1;
                color: var(--color-text-secondary);
            }

                /* Hide the legacy filled triangle ... */
                .ds-tree-picker .tree .tree-node > .d-flex > .mud-typography > span:first-child > * {
                    display: none !important;
                }

                /* ... and draw a stroke chevron: down when expanded, toward inline-end when collapsed */
                .ds-tree-picker .tree .tree-node > .d-flex > .mud-typography > span:first-child:not(:empty)::before {
                    content: "";
                    position: absolute;
                    inset: 0;
                    margin: auto;
                    display: block;
                    box-sizing: border-box;
                    inline-size: var(--space-2);
                    block-size: var(--space-2);
                    border: 0 solid currentColor;
                    border-block-end-width: var(--border-width-medium);
                    border-inline-end-width: var(--border-width-medium);
                    transform: rotate(calc(-45deg * var(--ds-tree-chevron-dir)));
                    transition: transform var(--duration-normal) var(--easing-standard);
                }

            .ds-tree-picker .tree .tree-node > .d-flex > .mud-typography.expanded > span:first-child:not(:empty)::before {
                transform: translateY(calc(var(--space-0-5) * -1)) rotate(calc(45deg * var(--ds-tree-chevron-dir)));
            }

        /* 2. Checkbox, pulled from the far end to sit beside the chevron */
        .ds-tree-picker .tree .tree-node > .d-flex > .menu-container {
            order: 1;
            display: inline-flex;
            flex-shrink: 0;
            align-items: center;
        }

        /* 3. Title */
        .ds-tree-picker .tree .tree-node > .d-flex > .mud-typography > span:nth-child(2) {
            order: 2;
            flex: 1 1 auto;
            min-inline-size: 0;
            font-family: var(--font-family-base);
            font-size: var(--font-size-sm);
            font-weight: var(--font-weight-medium);
            line-height: var(--line-height-snug);
            letter-spacing: var(--letter-spacing-normal);
            color: var(--color-text-secondary);
        }

    /* 4. "غير نشط" chip: compact danger badge at the end of the row */
    .ds-tree-picker .tree .tree-node .mud-chip.mud-chip {
        order: 3;
        min-block-size: var(--size-badge-sm);
        padding-block: 0;
        padding-inline: var(--space-2);
        background-color: var(--color-status-danger-fill);
        border: var(--border-width-thin) solid var(--color-status-danger-border);
        border-radius: var(--radius-sm);
        font-size: var(--font-size-2xs);
        color: var(--color-status-danger-text);
    }

/* Checked child branch: soft primary card, primary title */
.ds-tree-picker .tree ul .tree-node > .d-flex:has(.form-check-input:checked) {
    background-color: var(--color-bg-primary-soft);
    border-color: var(--color-border-primary);
}

    .ds-tree-picker .tree ul .tree-node > .d-flex:has(.form-check-input:checked) > .mud-typography > span:nth-child(2) {
        color: var(--color-text-primary);
    }

/* Root (bank) row: always neutral, bold dark title, checked or not */
.ds-tree-picker .tree > .tree-node > .d-flex {
    background-color: var(--color-bg-surface-subtle);
    border-color: var(--color-border-default);
}

    .ds-tree-picker .tree > .tree-node > .d-flex > .mud-typography > span:nth-child(2) {
        font-weight: var(--font-weight-bold);
        color: var(--color-text-foreground);
    }

/* ---- Checkbox (Bootstrap .form-check-input). Bootstrap's check-mark image is
        kept; size and colors come from tokens. accent-color covers builds that
        show the native checkbox. ---- */
.ds-tree-picker .tree .tree-node .form-check-input {
    flex-shrink: 0;
    float: none;
    inline-size: calc(var(--size-icon-sm) + var(--space-0-5));
    block-size: calc(var(--size-icon-sm) + var(--space-0-5));
    margin: 0;
    background-color: var(--color-bg-surface);
    border: var(--border-width-medium) solid var(--color-border-input);
    border-radius: var(--radius-xs);
    box-shadow: none;
    opacity: 1;
    accent-color: var(--color-bg-primary);
    cursor: pointer;
}

    /* Enabled + checked: solid primary */
    .ds-tree-picker .tree .tree-node .form-check-input:checked:not(:disabled) {
        background-color: var(--color-bg-primary);
        border-color: var(--color-bg-primary);
    }

    .ds-tree-picker .tree .tree-node .form-check-input:focus {
        box-shadow: none;
    }

    .ds-tree-picker .tree .tree-node .form-check-input:focus-visible {
        outline: var(--focus-ring-width) solid var(--focus-ring-color);
        outline-offset: var(--focus-ring-offset);
    }

    /* Locked selections (OldSelectedItemsDisabled): pale and not editable */
    .ds-tree-picker .tree .tree-node .form-check-input:disabled {
        background-color: var(--color-bg-disabled);
        border-color: var(--color-border-disabled);
        cursor: not-allowed;
    }

        .ds-tree-picker .tree .tree-node .form-check-input:disabled:checked {
            background-color: var(--color-bg-primary-disabled);
            border-color: transparent;
        }

/* ---- Children: guide line just inside the parent's inline-start edge;
        each connector runs from that line to the child card's edge ---- */
.ds-tree-picker .tree ul {
    position: relative;
    margin-block: 0 var(--space-3);
    margin-inline: var(--space-2) 0;
    padding-block: 0;
    padding-inline: var(--space-3) 0;
    list-style: none;
    border-inline-start: var(--border-width-medium) solid var(--color-border-default);
}

/* Child list rendered inside its parent node: gap under the parent card */
.ds-tree-picker .tree .tree-node > ul {
    margin-block-start: var(--space-2);
}

/* Nested levels: same breathing room under the parent card as top-level branches */
.ds-tree-picker .tree ul ul {
    margin-block: var(--space-2) var(--space-3);
}

.ds-tree-picker .tree ul::before,
.ds-tree-picker .tree ul::after {
    content: none;
}

/* The guide line stops at the last child card instead of running past it */
.ds-tree-picker .tree ul > .tree-node:last-of-type {
    margin-block-end: 0;
}

/* Connector is drawn from the node's own row, not the whole node, so a branch's
       connector stays on its row when its children are expanded below it */
.ds-tree-picker .tree ul > .tree-node > .d-flex::before {
    content: "";
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: calc(var(--space-3) * -1 - var(--border-width-thin));
    inline-size: var(--space-3);
    block-size: var(--border-width-medium);
    background-color: var(--color-border-default);
}

/* -------------------------------------------------------------------------
   18. SUMMARY LIST
   ------------------------------------------------------------------------- */

.ds-summary-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.ds-summary-list__row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-block-size: var(--size-control-sm);
    padding-block: var(--space-2);
    padding-inline: var(--space-3);
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) solid var(--color-border-subtle);
    border-radius: var(--radius-md);
}

.ds-summary-list__icon.mud-icon-root {
    flex-shrink: 0;
    font-size: var(--size-icon-sm);
    color: var(--color-text-primary);
}

.ds-summary-list__name {
    flex: 1 1 auto;
    min-inline-size: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
    overflow-wrap: anywhere;
}

/* The overline above the list sits closer to it than to the panel edge */
.mud-expand-panel .ds-overline + .ds-summary-list {
    margin-block-start: var(--space-2);
}

/* ==========================================================================
   19. MENU ITEM TEXT (row actions menu)
   <MudMenuItem><div class="ds-menu-item"> icon, then text block </div></MudMenuItem>
   16px icon at inline-start, vertically centered against the two-line
   title + description. Disabled = all muted. Danger = red icon and title;
   the description stays muted.
   ========================================================================== */
.ds-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 0;
}

.ds-menu-item__icon.mud-icon-root {
    flex-shrink: 0;
    inline-size: var(--size-icon-sm);
    block-size: var(--size-icon-sm);
    font-size: var(--size-icon-sm);
    color: var(--color-text-foreground);
}

.ds-menu-item__text {
    display: flex;
    flex-direction: column;
    gap: var(--space-0-5);
    min-inline-size: 0;
}

.ds-menu-item__title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-menu-item__desc {
    font-size: var(--font-size-2xs);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-snug);
    color: var(--color-text-muted);
}

/* Unavailable action */
.ds-menu-item--disabled :is(.ds-menu-item__icon.mud-icon-root, .ds-menu-item__title, .ds-menu-item__desc) {
    color: var(--color-text-subtle);
}

/* Destructive action (Delete): the description keeps the muted color */
.ds-menu-item--danger :is(.ds-menu-item__icon.mud-icon-root, .ds-menu-item__title) {
    color: var(--color-status-danger-text);
}

/* Tinted icon tile (import / template menus): a 36px rounded square holding
   the item icon, used instead of the bare 20px .ds-menu-item__icon.
   <span class="ds-menu-item__tile ds-menu-item__tile--success" aria-hidden="true"><MudIcon /></span>
   --success: download / template actions. --primary: upload actions. */
.ds-menu-item__tile {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    inline-size: var(--size-control-sm);
    block-size: var(--size-control-sm);
    background-color: var(--color-bg-surface-subtle);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
}

    .ds-menu-item__tile .mud-icon-root {
        inline-size: var(--size-icon-md);
        block-size: var(--size-icon-md);
        font-size: var(--size-icon-md);
        color: inherit;
    }

.ds-menu-item__tile--success {
    background-color: var(--color-status-success-soft);
    color: var(--color-status-success-text);
}

.ds-menu-item__tile--primary {
    background-color: var(--color-bg-primary-soft);
    color: var(--color-text-primary);
}

/* ==========================================================================
   20. LIST TOOLBAR, FILTER POPOVER & BULK ACTION
   Toolbar (OesListToolbar): [44px search] [Date] [Filters (n)] ...... end group
   [bulk action (n)] | [Import menu]. Under it: the active filter chips row and
   the status line (selection hint, or "n selected" + Clear selection).
   The Filters button opens .ds-filter-popover in a MudPopover: header (title +
   Clear all), a 1- or 2-column grid of 36px OesField selects, footer (match
   count + small Cancel / Apply).
   ========================================================================== */
.ds-list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

    /* Toolbar search (OesSearchBox default, 44px): grows from 288px up to 448px.
       The flex basis is scoped to the row so a search in a column never grows tall. */
    .ds-list-toolbar .ds-search-box {
        flex: 1 1 var(--size-search-min);
    }

/* End group: bulk action, .ds-vsep, import menu. Pushed to inline-end. */
.ds-list-toolbar__end {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-inline-start: auto;
}

    .ds-list-toolbar__end .ds-vsep {
        block-size: var(--size-control-sm);
        margin-inline: var(--space-1);
    }

/* Anchor for a popover opened from a toolbar button */
.ds-list-toolbar__anchor {
    position: relative;
    display: inline-flex;
}

/* Active filter chips under the toolbar */
.ds-list-toolbar__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-block-start: var(--space-3);
}

/* Status line under the toolbar: the muted selection hint while nothing is
   selected, or the bold count followed by the Clear selection text button. */
.ds-list-toolbar__status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    min-block-size: var(--size-icon-lg);
    margin-block-start: var(--space-3);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-snug);
    color: var(--color-text-muted);
}

/* The wrappers render from RenderFragments; an empty one takes no space */
:is(.ds-list-toolbar__chips, .ds-list-toolbar__status):empty {
    display: none;
}

.ds-list-toolbar__status-count {
    font-weight: var(--font-weight-bold);
    color: var(--color-text-foreground);
}

/* Clear selection: inline text button (24px visual height on fine pointers;
   responsive-rtl.css restores 44px under pointer: coarse) */
.ds-list-toolbar__status .mud-button-root.mud-button {
    min-block-size: var(--size-icon-lg);
    padding-block: 0;
    padding-inline: var(--space-1);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
}

/* Count pill inside a filled primary button (bulk action, e.g. Needs edit):
   on-primary circle with the primary number. Rendered only while count > 0. */
.ds-btn__count {
    /* The count is a number inside Arabic text: always an LTR island */
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    min-inline-size: var(--size-icon-md);
    block-size: var(--size-icon-md);
    padding-inline: var(--space-1);
    background-color: var(--color-text-on-primary);
    border-radius: var(--radius-full);
    font-size: var(--font-size-2xs);
    font-weight: var(--font-weight-bold);
    line-height: 1;
    color: var(--color-bg-primary);
}

/* Filters / Date trigger: a plain outlined default button at rest (surface fill,
   default border, foreground text). .is-active only while its popover is open or
   1+ filters / a date apply; .ds-filter-btn__count renders only while count > 0. */
.mud-button-root.mud-button.ds-filter-btn.is-active {
    background-color: var(--color-bg-primary-soft);
    border-color: var(--color-border-primary);
    color: var(--color-text-primary);
}

    .mud-button-root.mud-button.ds-filter-btn.is-active:hover {
        background-color: var(--color-bg-primary-soft-hover);
    }

/* 20px count badge after the label */
.ds-filter-btn__count {
    /* The count is a number inside Arabic text: always an LTR island */
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    min-inline-size: var(--size-icon-md);
    block-size: var(--size-icon-md);
    padding-inline: var(--space-1);
    background-color: var(--color-bg-primary);
    border-radius: var(--radius-full);
    font-size: var(--font-size-2xs);
    font-weight: var(--font-weight-bold);
    line-height: 1;
    color: var(--color-text-on-primary);
}

.ds-filter-popover {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    inline-size: min(var(--size-filter-popover), calc(100vw - var(--space-8)));
    max-block-size: calc(100dvh - var(--size-header-height) - var(--space-8));
    overflow: hidden;
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

    .ds-filter-popover.ds-filter-popover--cols-1 {
        inline-size: min(var(--size-filter-popover-sm), calc(100vw - var(--space-8)));
    }

.ds-filter-popover__header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding-block: var(--space-3);
    padding-inline: var(--space-4);
    border-block-end: var(--border-width-thin) solid var(--color-border-divider);
}

.ds-filter-popover__section {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    border-block-end: var(--border-width-thin) solid var(--color-border-divider);
}

.ds-filter-popover__section-label {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-filter-popover__title {
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

/* Clear all: compact text button, primary color */
.ds-filter-popover__header .mud-button-root.mud-button {
    min-block-size: var(--size-control-sm);
    padding-inline: var(--space-2);
    font-weight: var(--font-weight-semibold);
}

.ds-filter-popover__body {
    display: grid;
    grid-template-columns: repeat(var(--ds-filter-columns, 2), minmax(0, 1fr));
    gap: var(--space-3) var(--space-4);
    padding: var(--space-4);
    overflow-y: auto;
}

.ds-filter-popover--cols-1 .ds-filter-popover__body {
    --ds-filter-columns: 1;
}

@media (max-width: 599.98px) {
    .ds-filter-popover__body {
        --ds-filter-columns: 1;
    }
}

.ds-filter-popover__footer {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding-block: var(--space-3);
    padding-inline: var(--space-4);
    border-block-start: var(--border-width-thin) solid var(--color-border-divider);
}

.ds-filter-popover__count {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
}

.ds-filter-popover__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Selects sit on white inside the card; a disabled dependent select keeps its gray fill */
.ds-filter-popover .ds-field .mud-input.mud-input-outlined:not(.mud-disabled) {
    background-color: var(--color-bg-surface);
}

/* Selected value reads bold. Explicit modifier set from markup while the select
   has a value (Class on MudSelect or on the OesField wrapper), so the rule does
   not depend on MudBlazor internals; .mud-shrink is not used because MudBlazor
   also sets it when only a Placeholder is shown. */
.ds-filter-popover .ds-field--selected .mud-input-slot {
    font-weight: var(--font-weight-bold);
}

/* Clear (x) button before the chevron: muted, compact. Matches the 8.7 class
   and the generic adornment icon button. */
.ds-filter-popover .ds-field .mud-input-adornment :is(.mud-input-clear-button, .mud-icon-button) {
    color: var(--color-text-muted);
}

    .ds-filter-popover .ds-field .mud-input-adornment :is(.mud-input-clear-button, .mud-icon-button):hover {
        color: var(--color-text-foreground);
    }

/* ==========================================================================
   21. DATE & SORT POPOVER (OesDateFilterPopover)
   [Sort by] segmented control / month calendar / footer: summary + Clear + Apply.
   Day states: .is-today (2px focus-blue outline), .is-range-start / .is-range-end
   (solid primary), .is-in-range (continuous soft band), :disabled (future days).
   ========================================================================== */
.ds-date-popover {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    inline-size: min(var(--size-date-popover), calc(100vw - var(--space-8)));
    overflow: hidden;
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.ds-date-popover__section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
}

    .ds-date-popover__section + .ds-date-popover__section {
        border-block-start: var(--border-width-thin) solid var(--color-border-divider);
    }

.ds-date-popover__label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
}

/* Full-width two-item sort control: a compact 36px ds-toggle-group--sm whose
       two items share the width (the --sm rules size the items to their text) */
.ds-date-popover__section .mud-toggle-group.ds-toggle-group--sm {
    display: flex;
    inline-size: 100%;
}

    .ds-date-popover__section .mud-toggle-group.ds-toggle-group--sm .mud-toggle-item {
        flex: 1 1 0;
        min-inline-size: 0;
        gap: var(--space-1-5);
        padding-inline: var(--space-2);
        white-space: nowrap;
    }

        .ds-date-popover__section .mud-toggle-group.ds-toggle-group--sm .mud-toggle-item .mud-icon-root {
            inline-size: var(--size-icon-xs);
            block-size: var(--size-icon-xs);
        }

.ds-date-calendar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.ds-date-calendar__title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-foreground);
}

.ds-date-calendar__head .mud-button-root.mud-icon-button {
    inline-size: var(--space-8);
    min-inline-size: var(--space-8);
    block-size: var(--space-8);
    min-block-size: var(--space-8);
    border-radius: var(--radius-md);
}

/* 7 equal columns, no column gap so the range band stays continuous */
.ds-date-calendar__grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    row-gap: var(--space-1);
    margin-block-start: var(--space-1);
}

.ds-date-calendar__weekday {
    display: flex;
    align-items: center;
    justify-content: center;
    block-size: var(--space-6);
    font-size: var(--font-size-2xs);
    color: var(--color-text-muted);
}

.ds-date-day {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    block-size: var(--space-8);
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    font-family: inherit;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-foreground);
    cursor: pointer;
}

.ds-date-day__num {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: var(--space-8);
    block-size: var(--space-8);
    box-sizing: border-box;
    border: var(--border-width-medium) solid transparent;
    border-radius: var(--radius-md);
}

.ds-date-day:hover:not(:disabled) .ds-date-day__num {
    background-color: var(--color-bg-surface-hover);
}

.ds-date-day:focus-visible {
    outline: none;
}

    .ds-date-day:focus-visible .ds-date-day__num {
        outline: var(--focus-ring-width) solid var(--focus-ring-color);
        outline-offset: var(--focus-ring-offset);
    }

.ds-date-day.is-today .ds-date-day__num {
    border-color: var(--color-border-input-focus);
}

/* Continuous band: full cell for days inside the range, half cell toward the
   range on its first and last day (logical insets, so it follows RTL) */
.ds-date-day.is-in-range {
    background-color: var(--color-bg-primary-soft);
}

.ds-date-day:is(.is-range-start, .is-range-end)::before {
    content: "";
    position: absolute;
    inset-block: 0;
    background-color: var(--color-bg-primary-soft);
}

.ds-date-day.is-range-start::before {
    inset-inline: 50% 0;
}

.ds-date-day.is-range-end::before {
    inset-inline: 0 50%;
}

.ds-date-day.is-range-start.is-range-end::before {
    content: none;
}

.ds-date-day:is(.is-range-start, .is-range-end) .ds-date-day__num,
.ds-date-day:is(.is-range-start, .is-range-end):hover .ds-date-day__num {
    background-color: var(--color-bg-primary);
    border-color: var(--color-bg-primary);
    color: var(--color-text-on-primary);
}

.ds-date-day:disabled {
    color: var(--color-text-subtle);
    cursor: default;
}

.ds-date-popover__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-block-start: var(--border-width-thin) solid var(--color-border-divider);
}

.ds-date-popover__summary {
    min-inline-size: 0;
    font-size: var(--font-size-xs);
    line-height: var(--line-height-snug);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
}

.ds-date-popover__actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: var(--space-2);
}

/* ==========================================================================
   22. FILE UPLOAD ZONE, FILE ROW & FILE CARD (MudFileUpload)
   <MudFileUpload Hidden="false" InputClass="ds-upload-zone__input"> with the
   zone as ActivatorContent: the native input is stretched over the zone, so
   clicking and dropping files both reach it. .is-dragging is set from markup
   while files are dragged over the zone.
   ========================================================================== */
.mud-file-upload:has(.ds-upload-zone) {
    position: relative;
}

.ds-upload-zone__input {
    position: absolute;
    inset: 0;
    z-index: 1;
    inline-size: 100%;
    block-size: 100%;
    opacity: 0;
    cursor: pointer;
}

.ds-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding-block: var(--space-8);
    padding-inline: var(--space-6);
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
    text-align: center;
    transition: background-color var(--duration-fast) var(--easing-standard), border-color var(--duration-fast) var(--easing-standard);
}

    .ds-upload-zone:hover,
    .ds-upload-zone.is-dragging,
    .mud-file-upload:has(.ds-upload-zone__input:hover) .ds-upload-zone {
        background-color: var(--color-bg-primary-soft);
        border-color: var(--color-border-primary);
    }

.mud-file-upload:has(.ds-upload-zone__input:focus-visible) .ds-upload-zone {
    outline: var(--focus-ring-width) solid var(--focus-ring-color);
    outline-offset: var(--focus-ring-offset);
}

.ds-upload-zone__icon.mud-icon-root {
    font-size: var(--size-icon-xl);
    color: var(--color-text-primary);
}

.ds-upload-zone__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-foreground);
}

.ds-upload-zone__hint {
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Attached file: [type icon] name ......... size [remove] */
.ds-file-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-block: var(--space-2);
    padding-inline: var(--space-3) var(--space-2);
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-md);
}

.ds-file-row__icon.mud-icon-root {
    flex-shrink: 0;
    font-size: var(--size-icon-md);
    color: var(--color-text-primary);
}

.ds-file-row__name {
    flex: 1 1 auto;
    min-inline-size: 0;
    overflow: hidden;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-foreground);
}

.ds-file-row__size {
    flex-shrink: 0;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.ds-file-row .mud-button-root.mud-icon-button {
    flex-shrink: 0;
    inline-size: var(--size-control-sm);
    min-inline-size: var(--size-control-sm);
    block-size: var(--size-control-sm);
    min-block-size: var(--size-control-sm);
    border-radius: var(--radius-sm);
}

/* File card (import dialogs): [format badge] name / status line [remove].
   Scanning: the status line reads "Scanning file..." and an indeterminate
   MudProgressLinear (.ds-file-card__progress) runs under it; no remove button.
   Ready: the status line shows the file size and the 24px remove (x) appears. */
.ds-file-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5);
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-xl);
}

/* 48px format tile: XLSX / DOCX / CSV text, success-tinted */
.ds-file-card__badge {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    inline-size: var(--size-control-lg);
    block-size: var(--size-control-lg);
    background-color: var(--color-status-success-soft);
    border: var(--border-width-thin) solid var(--color-status-success-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    line-height: 1;
    color: var(--color-status-success-text);
}

.ds-file-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--space-1);
    min-inline-size: 0;
}

/* The name is an LTR island: align-self keeps it at inline-start of the card
   in RTL while its own text runs left to right */
.ds-file-card__name {
    display: block;
    align-self: flex-start;
    max-inline-size: 100%;
    overflow: hidden;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-foreground);
}

.ds-file-card__meta {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-snug);
    color: var(--color-text-muted);
}

.ds-file-card__progress.mud-progress-linear {
    margin-block-start: var(--space-2);
}

.ds-file-card .mud-button-root.mud-icon-button.ds-file-card__remove {
    flex-shrink: 0;
    inline-size: var(--size-icon-lg);
    min-inline-size: var(--size-icon-lg);
    block-size: var(--size-icon-lg);
    min-block-size: var(--size-icon-lg);
    padding: 0;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
}

    .ds-file-card .mud-button-root.mud-icon-button.ds-file-card__remove:hover {
        color: var(--color-text-foreground);
    }

/* ==========================================================================
   23. TOAST (NmrToast, shown through ISnackbar.ShowNmr)
   Status bar toast: the whole card takes the variant's soft tint and border, so the
   state reads at a glance. [20px status icon] [bold title in the status color /
   secondary description] [optional text action + 28px close, both in the status color].
   Primary is tinted too; Neutral stays a plain surface card.
   The tint is layered over --color-bg-surface, so translucent dark-theme tints stay opaque
   above page content.
   Markup:
     <div class="ds-toast ds-toast--success" role="status">
       <span class="ds-toast__icon" aria-hidden="true"><MudIcon Icon="@NmrIcons.CheckCircle" /></span>
       <div class="ds-toast__body">
         <p class="ds-toast__title">..</p>
         <p class="ds-toast__desc">..</p>
       </div>
       <div class="ds-toast__trail">
         <MudButton Variant="Variant.Text" Color="Color.Primary" Size="Size.Small" Class="ds-toast__action" />
         <MudIconButton Icon="@NmrIcons.Close" Size="Size.Small" Class="ds-toast__close" aria-label=".." />
       </div>
     </div>
   ========================================================================== */
.ds-toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-sizing: border-box;
    inline-size: min(var(--size-search-toolbar), calc(100vw - var(--space-8)));
    padding: var(--space-3) var(--space-4);
    background: linear-gradient(var(--ds-toast-bg), var(--ds-toast-bg)), var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--ds-toast-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-family-base);
    letter-spacing: var(--letter-spacing-normal);
    color: var(--ds-toast-fg);
    text-align: start;
    /* Neutral defaults; each variant below overrides them */
    --ds-toast-bg: var(--color-bg-surface);
    --ds-toast-border: var(--color-border-default);
    --ds-toast-fg: var(--color-text-foreground);
    --ds-toast-icon: var(--color-text-secondary);
    --ds-toast-hover: var(--color-bg-surface-hover);
}

/* Variant colors: soft tint + status border, status text for title, icon and controls */
.ds-toast--primary {
    --ds-toast-bg: var(--color-bg-primary-soft);
    --ds-toast-border: var(--color-border-primary);
    --ds-toast-fg: var(--color-text-primary);
    --ds-toast-icon: var(--color-text-primary);
    --ds-toast-hover: var(--color-bg-primary-soft-hover);
}

.ds-toast--neutral {
    --ds-toast-bg: var(--color-bg-surface);
    --ds-toast-border: var(--color-border-default);
    --ds-toast-fg: var(--color-text-foreground);
    --ds-toast-icon: var(--color-text-secondary);
    --ds-toast-hover: var(--color-bg-surface-hover);
    --ds-toast-action: var(--color-text-primary);
}

.ds-toast--info {
    --ds-toast-bg: var(--color-status-info-soft);
    --ds-toast-border: var(--color-status-info-border);
    --ds-toast-fg: var(--color-status-info-text);
    --ds-toast-icon: var(--color-status-info-text);
    --ds-toast-hover: var(--color-status-info-fill);
}

.ds-toast--success {
    --ds-toast-bg: var(--color-status-success-soft);
    --ds-toast-border: var(--color-status-success-border);
    --ds-toast-fg: var(--color-status-success-text);
    --ds-toast-icon: var(--color-status-success-text);
    --ds-toast-hover: var(--color-status-success-fill);
}

.ds-toast--warning {
    --ds-toast-bg: var(--color-status-warning-soft);
    --ds-toast-border: var(--color-status-warning-border);
    --ds-toast-fg: var(--color-status-warning-text);
    --ds-toast-icon: var(--color-status-warning-text);
    --ds-toast-hover: var(--color-status-warning-fill);
}

.ds-toast--danger {
    --ds-toast-bg: var(--color-status-danger-soft);
    --ds-toast-border: var(--color-status-danger-border);
    --ds-toast-fg: var(--color-status-danger-text);
    --ds-toast-icon: var(--color-status-danger-text);
    --ds-toast-hover: var(--color-status-danger-fill);
}

/* Bare status icon: no tile, the card tint carries the state */
.ds-toast__icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    color: var(--ds-toast-icon);
}

    .ds-toast__icon .mud-icon-root {
        inline-size: var(--size-icon-md);
        block-size: var(--size-icon-md);
    }

/* Text block, icon and trailing actions are all centered on the card's
   block axis, so one- and two-line toasts stay balanced */
.ds-toast__body {
    flex: 1 1 auto;
    min-inline-size: 0;
}

.ds-toast__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--ds-toast-fg);
    overflow-wrap: anywhere;
}

.ds-toast__desc {
    margin-block: var(--space-0-5) 0;
    margin-inline: 0;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-normal);
    color: var(--color-text-secondary);
    overflow-wrap: anywhere;
}

.ds-toast__trail {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: var(--space-1);
}

    /* The action takes the status color, so a red toast never shows a blue button;
       Neutral keeps a primary action */
    .ds-toast__trail .mud-button-root.mud-button.ds-toast__action {
        min-block-size: var(--size-control-xs);
        padding-inline: var(--space-2);
        font-size: var(--font-size-xs);
        font-weight: var(--font-weight-bold);
        color: var(--ds-toast-action, var(--ds-toast-fg));
    }

        .ds-toast__trail .mud-button-root.mud-button.ds-toast__action:hover {
            background-color: var(--ds-toast-hover);
        }

    /* 28px on fine pointers; responsive-rtl.css restores 44px on touch */
    .ds-toast__trail .mud-button-root.mud-icon-button.ds-toast__close {
        inline-size: var(--size-control-xs);
        min-inline-size: var(--size-control-xs);
        block-size: var(--size-control-xs);
        min-block-size: var(--size-control-xs);
        border-radius: var(--radius-md);
        color: var(--ds-toast-fg);
    }

        .ds-toast__trail .mud-button-root.mud-icon-button.ds-toast__close:hover {
            background-color: var(--ds-toast-hover);
            color: var(--ds-toast-fg);
        }


/* ==========================================================================
   24. DIALOG BREADCRUMB (NmrDialog ParentTitle)
   Sub-view title: [muted parent button] [chevron] [bold current title], both 16px,
   plus .ds-dialog-view, the fade-in used when the dialog switches views.
   The parent is a button (not a link): it switches the dialog view.
   Markup (rendered by NmrDialog when ParentTitle is set):
     <nav class="ds-dialog-crumb" aria-label="..">
       <button type="button" class="ds-dialog-crumb__parent">..</button>
       <MudIcon Icon="@NmrIcons.ChevronRight" Class="ds-dialog-crumb__sep u-flip-rtl" aria-hidden="true" />
       <MudText Typo="Typo.h6" HtmlTag="h2" aria-current="page">..</MudText>
     </nav>
   ========================================================================== */
.ds-dialog-crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 0;
}

.ds-dialog-crumb__parent {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-snug);
    letter-spacing: var(--letter-spacing-normal);
    color: var(--color-text-muted);
    text-align: start;
    cursor: pointer;
    transition: color var(--duration-fast) var(--easing-standard);
}

    .ds-dialog-crumb__parent:hover {
        color: var(--color-text-link);
    }

    .ds-dialog-crumb__parent:focus-visible {
        outline: var(--focus-ring-width) solid var(--focus-ring-color);
        outline-offset: var(--focus-ring-offset);
    }

.ds-dialog-crumb__sep {
    flex-shrink: 0;
    font-size: var(--size-icon-sm);
    color: var(--color-text-subtle);
}

/* Current title matches the parent's 16px (the global dialog title is 20px);
   four classes outrank .mud-dialog .mud-dialog-title .mud-typography-h6 */
.mud-dialog .mud-dialog-title .ds-dialog-crumb .mud-typography-h6 {
    font-size: var(--font-size-md);
}

/* View switch inside one dialog: the new view fades and settles in.
   <div class="ds-dialog-view" @key="_view"> .. </div>
   @key makes Blazor re-create the element on every view change, so the
   animation replays; reduced motion turns it off (responsive-rtl.css). */
.ds-dialog-view {
    animation: ds-dialog-view-in var(--duration-normal) var(--easing-decelerate);
}

@keyframes ds-dialog-view-in {
    from {
        opacity: 0;
        transform: translateY(var(--space-1));
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ==========================================================================
   25. SETTING GROUP & SETTING ROW (NmrSettingGroup / NmrSettingRow)
   Panel: gray head (optional icon + title), then rows separated by hairlines.
   Row: [title / muted description ........ control at inline-end]; the control
   is a MudSwitch, NmrNumberStepper, a compact picker or field.
   ds-setting-row--subtle: a standalone gray rounded row (e.g. inside a card).
   ========================================================================== */
.ds-setting-group {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
    overflow: hidden;
    background-color: var(--color-bg-surface);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-lg);
}

.ds-setting-group__head {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-block-size: var(--size-control-lg);
    padding-block: var(--space-3);
    padding-inline: var(--space-5);
    background-color: var(--color-bg-surface-subtle);
    border-block-end: var(--border-width-thin) solid var(--color-border-default);
}

.ds-setting-group__icon {
    flex-shrink: 0;
    font-size: var(--size-icon-md);
    color: var(--color-text-secondary);
}

.ds-setting-group__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-setting-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding-block: var(--space-4);
    padding-inline: var(--space-5);
}

    .ds-setting-row + .ds-setting-row {
        border-block-start: var(--border-width-thin) solid var(--color-border-divider);
    }

    /* Standalone gray row (sync time inside the auto-sync card) */
    .ds-setting-row.ds-setting-row--subtle {
        background-color: var(--color-bg-surface-subtle);
        border-radius: var(--radius-md);
    }

.ds-setting-row__text {
    flex: 1 1 auto;
    min-inline-size: 0;
}

.ds-setting-row__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-setting-row__desc {
    margin-block: var(--space-0-5) 0;
    margin-inline: 0;
    font-size: var(--font-size-xs);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
}

.ds-setting-row__control {
    display: flex;
    flex-shrink: 0;
    align-items: center;
}

    /* A field as the control (compact time picker): fixed 160px, not full width */
    .ds-setting-row__control > .ds-field {
        inline-size: calc(var(--space-20) * 2);
    }

/* ==========================================================================
   ListItem: media previews inside table cells (SunEditor HTML in Body columns)
   Scoped to .ds-list-item; the old <style> block resized media on the whole page.
   ========================================================================== */
.ds-list-item .mud-table :is(audio, img, video, figure) {
    display: inline-block;
    max-inline-size: var(--size-media-thumb);
    max-block-size: var(--size-media-thumb);
    margin-block: var(--space-1);
    object-fit: contain;
}

.ds-list-item .mud-table figure {
    padding: 0;
    overflow: hidden;
}

    .ds-list-item .mud-table figure video {
        inline-size: 100%;
        block-size: 100%;
    }
/* ==========================================================================
   26. META GRID (NmrMetaGrid / NmrMetaItem)
   Read-only label / value pairs in a description list. Columns: 1 below 600px,
   2 from 600px; --cols-3 adds a third from 960px. Tone colors the value only.
   LTR values go in an inline <bdi class="u-ltr-isolate">, never on the dd itself:
   on a block, text-align: start resolves to the left edge inside an Arabic cell.
   ========================================================================== */
.ds-meta-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    margin: 0;
    padding: 0;
}

@media (min-width: 600px) {
    .ds-meta-grid:is(.ds-meta-grid--cols-2, .ds-meta-grid--cols-3) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 960px) {
    .ds-meta-grid.ds-meta-grid--cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.ds-meta-grid__item {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-inline-size: 0;
}

    .ds-meta-grid__item.ds-meta-grid__item--full {
        grid-column: 1 / -1;
    }

.ds-meta-grid__label {
    margin: 0;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-normal);
    color: var(--color-text-muted);
}

.ds-meta-grid__value {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-normal);
    color: var(--color-text-foreground);
    overflow-wrap: anywhere;
}

    .ds-meta-grid__value.ds-meta-grid__value--success {
        color: var(--color-status-success-text);
    }

    .ds-meta-grid__value.ds-meta-grid__value--warning {
        color: var(--color-status-warning-text);
    }

    .ds-meta-grid__value.ds-meta-grid__value--danger {
        color: var(--color-status-danger-text);
    }

    .ds-meta-grid__value.ds-meta-grid__value--primary {
        color: var(--color-text-primary);
    }

    .ds-meta-grid__value.ds-meta-grid__value--neutral {
        color: var(--color-text-muted);
    }

/* ==========================================================================
   27. ACTIVITY LIST (NmrActivityList / NmrActivityItem)
   Status dot + label at inline-start, date at inline-end, actor, optional comment.
   Gray items by default (inside a white card); --surface items are white (gray canvas).
   .ds-activity-scroll is a focusable region capped at --size-panel-scroll-max.
   ========================================================================== */
.ds-activity-scroll {
    max-block-size: var(--size-panel-scroll-max);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-inline-end: var(--space-2);
    border-radius: var(--radius-md);
}

    .ds-activity-scroll:focus-visible {
        outline: var(--focus-ring-width) solid var(--focus-ring-color);
        outline-offset: var(--focus-ring-offset);
    }

.ds-activity-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.ds-activity-item {
    --ds-activity-tone: var(--color-text-secondary);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4);
    background-color: var(--color-bg-surface-subtle);
    border: var(--border-width-thin) solid var(--color-border-default);
    border-radius: var(--radius-md);
}

.ds-activity-list.ds-activity-list--surface .ds-activity-item {
    background-color: var(--color-bg-surface);
}

.ds-activity-item.ds-activity-item--success {
    --ds-activity-tone: var(--color-status-success-text);
}

.ds-activity-item.ds-activity-item--warning {
    --ds-activity-tone: var(--color-status-warning-text);
}

.ds-activity-item.ds-activity-item--danger {
    --ds-activity-tone: var(--color-status-danger-text);
}

.ds-activity-item.ds-activity-item--primary {
    --ds-activity-tone: var(--color-text-primary);
}

.ds-activity-item__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-1) var(--space-3);
}

.ds-activity-item__status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 0;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-snug);
    color: var(--ds-activity-tone);
}

    .ds-activity-item__status::before {
        content: "";
        flex-shrink: 0;
        inline-size: var(--space-2);
        block-size: var(--space-2);
        background-color: currentColor;
        border-radius: var(--radius-full);
    }

.ds-activity-item__date {
    flex-shrink: 0;
    font-size: var(--font-size-2xs);
    line-height: var(--line-height-snug);
    white-space: nowrap;
    color: var(--color-text-muted);
}

.ds-activity-item__actor {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-snug);
    color: var(--color-text-foreground);
}

.ds-activity-item__comment {
    margin: 0;
    font-size: var(--font-size-xs);
    line-height: var(--line-height-normal);
    color: var(--color-text-secondary);
    overflow-wrap: anywhere;
}