/* =========================================================================
   runevents.Multimedia — shared component bundle.
   Single bundle (RCL convention). Host overrides any --mm-* variable to rebrand.

   Visual language mirrors EIC's flyout system (flyout-base / edit-media / atoms):
   50% slide-in panel, full-bleed sticky header + circular rotating close button,
   sticky footer bar, branded buttons, uppercase section labels, custom radios /
   checkboxes, a styled dropzone that hides the native file input.
   Atomic-design ordering preserved as comment-delimited sections (EIC convention).
   ========================================================================= */

/* ===== 00-design-tokens (host-overridable; library defaults via var(--mm-…, default)) ===== */
/* Library default tokens at ZERO specificity (:where) so any host :root override wins.
   NEVER write `--mm-x: var(--mm-x, default)` scoped to .mm-root — that self-reference is a
   CSS cycle, which makes the property guaranteed-invalid (→ transparent surfaces, no brand
   color) on every component element. Defaults here; host (EIC colors.css :root) overrides. */
:where(:root) {
    --mm-primary: #6A4A9E;
    --mm-secondary: #EE265A;
    --mm-surface: #FFFFFF;
    --mm-surface-alt: #F7F8FA;
    --mm-border: #E1E4E8;
    --mm-text: #1F2937;
    --mm-text-muted: #6B7280;
    --mm-accent: #7BCED7;
    --mm-danger: #EE265A;
}

.mm-root,
.mm-uploader,
.mm-picker,
.mm-library-grid,
.mm-detail-flyout,
.mm-cropper,
.mm-modal {
    --mm-radius: 8px;
    --mm-radius-lg: 12px;
    --mm-gap: 12px;
    color: var(--mm-text);
}

/* ===== 02-atoms : buttons ===== */
.mm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-width: 110px;
    padding: .75rem 1.25rem;
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius);
    background: var(--mm-surface);
    color: var(--mm-text);
    font: inherit;
    font-size: .9rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all .25s ease;
}
.mm-btn:hover:not(:disabled) {
    background: var(--mm-surface-alt);
    border-color: var(--mm-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .10);
}
.mm-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mm-primary) 28%, transparent);
}
.mm-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.mm-btn--primary { background: var(--mm-primary); color: #fff; border-color: var(--mm-primary); }
.mm-btn--primary:hover:not(:disabled) {
    background: var(--mm-primary);
    filter: brightness(1.08);
    border-color: var(--mm-primary);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--mm-primary) 28%, transparent);
}
.mm-btn--primary:disabled { background: var(--mm-border); border-color: var(--mm-border); color: var(--mm-text-muted); opacity: 1; }

.mm-btn--ghost { background: var(--mm-surface); color: var(--mm-text-muted); border-color: var(--mm-border); }
.mm-btn--ghost:hover:not(:disabled) { color: var(--mm-text); border-color: var(--mm-text-muted); }

.mm-btn--danger { background: var(--mm-danger); color: #fff; border-color: var(--mm-danger); }
.mm-btn--danger:hover:not(:disabled) {
    background: var(--mm-danger);   /* re-assert: otherwise the generic .mm-btn:hover surface-alt wins -> white-on-white */
    filter: brightness(1.05);
    border-color: var(--mm-danger);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--mm-danger) 28%, transparent);
}

/* light, icon-led toolbar buttons — match the host Site-Manager chrome (Add New / Deploy / …).
   Standalone atom (NOT combined with .mm-btn): no min-width, transparent until hover.
   Used by the library-grid toolbar (Upload media + Delete). */
.mm-btn--toolbar {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .75rem;
    border: 1px solid transparent;
    border-radius: var(--mm-radius);
    background: transparent;
    color: var(--mm-text-muted);
    font: inherit;
    font-size: .85rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.mm-btn--toolbar:hover:not(:disabled) {
    background: var(--mm-surface-alt);
    color: var(--mm-text);
    border-color: var(--mm-border);
}
.mm-btn--toolbar:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mm-primary) 28%, transparent);
}
.mm-btn--toolbar:disabled { opacity: .45; cursor: not-allowed; }
.mm-btn--toolbar svg { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; }

/* danger flavour — the Delete button: muted red while idle, red tint on hover */
.mm-btn--toolbar-danger { color: var(--mm-danger); }
.mm-btn--toolbar-danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--mm-danger) 10%, transparent);
    color: var(--mm-danger);
    border-color: color-mix(in srgb, var(--mm-danger) 30%, var(--mm-border));
}

/* ===== 02-atoms : inputs / textarea / select ===== */
.mm-input,
.mm-textarea,
.mm-select {
    width: 100%;
    box-sizing: border-box;
    padding: .75rem 1rem;
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius);
    background: var(--mm-surface-alt);
    color: var(--mm-text);
    font: inherit;
    font-size: 1rem;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.mm-input::placeholder,
.mm-textarea::placeholder { color: var(--mm-text-muted); }
.mm-input:focus,
.mm-textarea:focus,
.mm-select:focus {
    outline: none;
    border-color: var(--mm-primary);
    background: var(--mm-surface);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mm-primary) 12%, transparent);
}
.mm-textarea { min-height: 110px; resize: vertical; }
.mm-select {
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 1.2rem;
}

/* custom radio/checkbox appearance (uploader). NOTE: the old `.mm-uploader fieldset`,
   `fieldset > label` and `.mm-wizard__body > label` layout rules were removed (plan 326
   follow-up) — they were more specific than the new .mm-source-card / .mm-dropzone /
   .mm-webp-card rules and forced inline-flex + zero left padding + zero fieldset margin. */
.mm-uploader input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin: 0;
    border: 2px solid var(--mm-border);
    border-radius: 50%;
    background: var(--mm-surface);
    cursor: pointer;
    position: relative;
    transition: border-color .2s ease;
}
.mm-uploader input[type="radio"]:hover { border-color: var(--mm-primary); }
.mm-uploader input[type="radio"]:checked { border-color: var(--mm-primary); }
.mm-uploader input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--mm-primary);
}

/* custom checkbox (uploader edit step) */
.mm-uploader input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin: 0;
    border: 2px solid var(--mm-border);
    border-radius: 5px;
    background: var(--mm-surface);
    cursor: pointer;
    position: relative;
    transition: all .2s ease;
}
.mm-uploader input[type="checkbox"]:checked { border-color: var(--mm-accent); background: var(--mm-accent); }
.mm-uploader input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ===== 02-atoms : badges ===== */
.mm-badge {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    background: var(--mm-surface-alt);
    color: var(--mm-text-muted);
    border: 1px solid var(--mm-border);
}
.mm-badge--flagged { background: var(--mm-danger); color: #fff; border-color: transparent; }

/* ===== 03-molecules : fields, labels, chips, status ===== */
.mm-field { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.5rem; }
.mm-field__label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--mm-text-muted);
}

.mm-searchbox { position: relative; margin-bottom: var(--mm-gap); }

/* search field with an inline magnifier glyph. Implemented as a pseudo-element on the
   (position:relative) wrapper, NOT the input's background — the input uses a `background`
   shorthand on :focus which would otherwise wipe a background-image. */
.mm-searchbox--icon .mm-input { padding: .45rem 1rem .45rem 2.5rem; font-size: .875rem; }
.mm-searchbox--icon::before {
    content: '';
    position: absolute;
    left: .85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.05rem;
    height: 1.05rem;
    opacity: .5;
    pointer-events: none;
    background: center / contain no-repeat url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='11' cy='11' r='7'/%3e%3cpath d='M21 21l-4.3-4.3'/%3e%3c/svg%3e");
}

.mm-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .65rem; }
/* tag/label pills — visual match to the Community Articles/Videos label control
   (rounded-rect, ~36px, gray surface; active filter = brand fill). */
.mm-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .7rem;
    min-height: 34px;
    border-radius: 6px;
    border: 1px solid var(--mm-border);
    background: var(--mm-surface-alt);
    font-size: .85rem;
    font-weight: 500;
    color: var(--mm-text);
    transition: border-color .15s ease, background-color .15s ease;
}
.mm-chip:hover { border-color: var(--mm-primary); }
.mm-chip--active { background: var(--mm-primary); color: #fff; border-color: var(--mm-primary); cursor: pointer; }
.mm-chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--mm-text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: color .15s ease, background-color .15s ease;
}
.mm-chip__remove:hover { color: var(--mm-danger); background: color-mix(in srgb, var(--mm-danger) 12%, transparent); }

/* free-form tag input — visual match to EIC's .attendee-info-tag control
   (brand-tinted pills + a pill-shaped input with a primary "Add" button). */
.mm-tags { display: flex; flex-direction: column; gap: .75rem; }
.mm-tags__list { display: flex; flex-wrap: wrap; gap: .5rem; min-height: 32px; }
.mm-tag {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .5rem .4rem .75rem;
    background: color-mix(in srgb, var(--mm-primary) 10%, transparent);
    color: var(--mm-primary);
    border: 1px solid color-mix(in srgb, var(--mm-primary) 22%, transparent);
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 500;
}
.mm-tag__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: inherit;
    opacity: .65;
    cursor: pointer;
    font-size: .9rem;
    line-height: 1;
    transition: opacity .15s ease, background-color .15s ease;
}
.mm-tag__remove:hover { opacity: 1; background: color-mix(in srgb, var(--mm-primary) 20%, transparent); }
.mm-tags__input { display: flex; gap: .5rem; }
.mm-tag-input {
    flex: 1;
    padding: .5rem 1rem;
    border: 1px solid var(--mm-border);
    border-radius: 20px;
    background: var(--mm-surface);
    color: var(--mm-text);
    font: inherit;
    font-size: .9rem;
    transition: border-color .15s ease;
}
.mm-tag-input:focus { outline: none; border-color: var(--mm-primary); }
.mm-tag-input::placeholder { color: var(--mm-text-muted); }
.mm-tag-add {
    padding: .5rem 1.1rem;
    border: none;
    border-radius: 20px;
    background: var(--mm-primary);
    color: #fff;
    font: inherit;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: filter .15s ease, transform .15s ease, opacity .15s ease;
}
.mm-tag-add:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.mm-tag-add:disabled { opacity: .5; cursor: not-allowed; }

.mm-error {
    color: var(--mm-danger);
    background: color-mix(in srgb, var(--mm-danger) 8%, transparent);
    border: 1px solid var(--mm-danger);
    border-radius: var(--mm-radius);
    padding: .75rem 1rem;
    margin-bottom: 1.25rem;
}
.mm-status { color: var(--mm-text-muted); padding: .5rem 0; }

/* content-type / dimensions row + "Ask Amal" (detail flyout) */
.mm-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1.1rem;
    margin-bottom: 1.5rem;
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-lg);
}
.mm-meta-row__info { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.mm-meta-row__value { font-size: .9rem; color: var(--mm-text); }
.mm-meta-row__dims { margin-left: .5rem; font-size: .8rem; color: var(--mm-text-muted); }
.mm-ask-amal {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    flex: 0 0 auto;
    padding: .6rem 1.1rem;
    border: none;
    border-radius: var(--mm-radius);
    background: linear-gradient(135deg, var(--mm-danger) 0%, color-mix(in srgb, var(--mm-danger) 65%, #000) 100%);
    color: #fff;
    font: inherit;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--mm-danger) 30%, transparent);
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.mm-ask-amal:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 16px color-mix(in srgb, var(--mm-danger) 40%, transparent); }
.mm-ask-amal:disabled { opacity: .6; cursor: not-allowed; }

/* ===== 04-organisms : flyout shell (shared by uploader + detail flyout) ===== */
.mm-flyout__backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 1040; cursor: pointer; }

.mm-detail-flyout {
    position: fixed;
    inset: 0 0 0 auto;
    width: 50%;
    min-width: 460px;
    max-width: 920px;
    display: flex;
    flex-direction: column;
    padding: 0 2rem;                 /* horizontal inset for content; header/footer break out */
    background: var(--mm-surface);
    border-left: 1px solid var(--mm-border);
    box-shadow: -10px 0 40px rgba(0, 0, 0, .18);
    overflow-y: auto;
    z-index: 1050;
    animation: mm-flyout-slide-in .35s cubic-bezier(.4, 0, .2, 1);
}
@keyframes mm-flyout-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

/* full-bleed sticky header bar */
.mm-detail-flyout__header {
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 -2rem;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--mm-surface-alt);
    border-bottom: 1px solid var(--mm-border);
}
.mm-detail-flyout__header h2 { margin: 0; font-size: 1.5rem; font-weight: 600; color: var(--mm-text); }

/* circular close button (the header's ghost button) */
.mm-detail-flyout__header .mm-btn {
    min-width: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    color: var(--mm-text);
    font-size: 1.25rem;
    line-height: 1;
}
.mm-detail-flyout__header .mm-btn:hover:not(:disabled) {
    background: var(--mm-danger);
    color: #fff;
    border-color: var(--mm-danger);
    transform: rotate(90deg);
    box-shadow: none;
}

/* first content block after the header gets breathing room */
.mm-detail-flyout__header + * { margin-top: 1.5rem; }

/* full-bleed sticky footer bar */
.mm-wizard__footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: auto -2rem 0;            /* push to the bottom + break out full width */
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: var(--mm-surface-alt);
    border-top: 1px solid var(--mm-border);
}

/* wizard stepper — numbered circles with connectors (active=purple, done=teal, upcoming=grey) */
.mm-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 1.25rem 0;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--mm-border);
}
.mm-stepper__item {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--mm-text-muted);
    font-size: .95rem;
    font-weight: 500;
    background: none;
    border: none;
    padding: 0;
}
.mm-stepper__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--mm-surface-alt);
    border: 1px solid var(--mm-border);
    color: var(--mm-text-muted);
    font-size: .85rem;
    font-weight: 600;
    flex: 0 0 auto;
}
.mm-stepper__item--active { color: var(--mm-primary); font-weight: 700; }
.mm-stepper__item--active .mm-stepper__num { background: var(--mm-primary); border-color: var(--mm-primary); color: #fff; }
.mm-stepper__item--done { color: var(--mm-accent); cursor: pointer; }
.mm-stepper__item--done .mm-stepper__num { background: var(--mm-accent); border-color: var(--mm-accent); color: #fff; }
.mm-stepper__bar { width: 48px; height: 2px; border-radius: 2px; background: var(--mm-border); flex: 0 0 auto; }
.mm-stepper__bar--done { background: var(--mm-accent); }

/* ===== uploader source-choice cards (step 1) ===== */
.mm-source-choice { border: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.mm-source-choice legend { padding: 0; margin-bottom: .25rem; }
.mm-source-card {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1.1rem;
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-lg);
    background: var(--mm-surface);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}
.mm-source-card:hover { border-color: var(--mm-primary); }
.mm-source-card--active { border-color: var(--mm-primary); background: color-mix(in srgb, var(--mm-primary) 6%, var(--mm-surface)); }
.mm-source-card__text { font-size: .95rem; color: var(--mm-text); }

/* ===== uploader dropzone (step 1, upload mode) ===== */
.mm-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .65rem;
    padding: 2.25rem 1.5rem;
    border: 2px dashed var(--mm-border);
    border-radius: var(--mm-radius-lg);
    background: var(--mm-surface-alt);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}
.mm-dropzone:hover { border-color: var(--mm-primary); background: color-mix(in srgb, var(--mm-primary) 4%, var(--mm-surface-alt)); }
/* the native file input fills the whole box: click anywhere browses; native drop works incidentally */
.mm-dropzone__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.mm-dropzone__icon { color: var(--mm-text-muted); }
.mm-dropzone__icon svg { width: 44px; height: 44px; }
.mm-dropzone__text { color: var(--mm-text); font-size: .95rem; }
.mm-dropzone__or { color: var(--mm-text-muted); font-size: .85rem; }
.mm-dropzone__btn { position: relative; z-index: 1; pointer-events: none; } /* visual only; the input handles the click */
.mm-dropzone__formats { color: var(--mm-text-muted); font-size: .8rem; }

/* ===== framed preview + size/dimensions meta bar (steps 1-after-select, 2, 3) ===== */
.mm-preview-frame {
    border: 1px dashed var(--mm-border);
    border-radius: var(--mm-radius-lg);
    background: var(--mm-surface-alt);
    padding: 1.25rem;
    margin: 1.5rem 0;
}
.mm-preview-frame__img {
    display: block;
    max-width: 100%;
    max-height: 360px;
    margin: 0 auto;
    border-radius: var(--mm-radius);
}
.mm-preview-frame__meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    margin-top: 1rem;
    color: var(--mm-text-muted);
    font-size: .85rem;
}
.mm-preview-frame__sep { opacity: .5; }

/* ===== resize radio-cards (step 2) ===== */
.mm-resize-cards { display: flex; flex-direction: column; gap: .65rem; }
.mm-resize-card {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding: .85rem 1.1rem;
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-lg);
    background: var(--mm-surface);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}
.mm-resize-card:hover { border-color: var(--mm-primary); }
.mm-resize-card--active { border-color: var(--mm-primary); background: color-mix(in srgb, var(--mm-primary) 6%, var(--mm-surface)); }
.mm-resize-card input[type="radio"] { margin-top: .1rem; }
.mm-resize-card__body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.mm-resize-card__title { font-size: .95rem; font-weight: 500; color: var(--mm-text); }
.mm-resize-card__help { font-size: .82rem; color: var(--mm-text-muted); }

/* ===== convert-to-WEBP card (step 2) ===== */
.mm-webp-card {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1.1rem;
    margin-top: 1.25rem;
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-lg);
    background: var(--mm-surface);
    cursor: pointer;
}
.mm-webp-card__text { font-size: .95rem; color: var(--mm-text); }

/* ===== describe metadata card + mascot (step 3) ===== */
.mm-describe-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-lg);
    background: var(--mm-surface);
}
.mm-describe-meta__fields { display: flex; flex-direction: column; gap: .85rem; min-width: 0; }
.mm-meta-pill {
    display: inline-block;
    align-self: flex-start;
    padding: .35rem .75rem;
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius);
    background: var(--mm-surface);
    color: var(--mm-text);
    font-size: .9rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.mm-describe-meta__mascot { width: 84px; height: 84px; flex: 0 0 auto; object-fit: contain; }

/* ===== batch (multi-image) upload (step 1/2) ===== */
.mm-batch { margin-bottom: 1.5rem; }
.mm-batch__count { font-size: .9rem; font-weight: 600; color: var(--mm-text); margin-bottom: .75rem; }
.mm-batch__strip { display: flex; flex-wrap: wrap; gap: .5rem; }
.mm-batch__thumb {
    width: 76px;
    height: 76px;
    border-radius: var(--mm-radius);
    overflow: hidden;
    border: 1px solid var(--mm-border);
    background: var(--mm-surface-alt);
    flex: 0 0 auto;
}
.mm-batch__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* batch result summary (after upload) */
.mm-batch-summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 2.5rem 1.5rem;
    text-align: center;
}
.mm-batch-summary__ok { font-size: 1.1rem; font-weight: 600; color: var(--mm-text); }
.mm-batch-summary__skipped { font-size: .9rem; color: var(--mm-text-muted); }

/* batch upload in-progress — the "Amal at work" moment (donut takes the panel) */
.mm-batch-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.75rem 1.5rem;
    text-align: center;
}
.mm-batch-progress__gif { width: 130px; height: 130px; object-fit: contain; }
.mm-batch-progress__gif--static { display: none; }
.mm-batch-progress__title { font-size: 1.15rem; font-weight: 600; color: var(--mm-text); margin: 0; }
.mm-batch-progress__count { font-size: .95rem; color: var(--mm-text-muted); margin: 0; font-variant-numeric: tabular-nums; }
.mm-batch-progress__bar {
    width: min(280px, 80%);
    height: 6px;
    border-radius: 999px;
    background: var(--mm-surface-alt);
    overflow: hidden;
}
.mm-batch-progress__bar span {
    display: block;
    height: 100%;
    background: var(--mm-primary);
    border-radius: 999px;
    transition: width .3s ease;
}
/* brand spinner fallback for hosts without a busy-mascot URL (e.g. Community) */
.mm-spinner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 5px solid var(--mm-surface-alt);
    border-top-color: var(--mm-primary);
    animation: mm-spin .8s linear infinite;
}
@keyframes mm-spin { to { transform: rotate(360deg); } }
/* reduced motion: swap the animated donut for the static one; slow the spinner */
@media (prefers-reduced-motion: reduce) {
    .mm-batch-progress__gif--motion { display: none; }
    .mm-batch-progress__gif--static { display: block; }
    .mm-spinner { animation-duration: 2.4s; }
}
.mm-wizard__body { padding-bottom: 1.5rem; }
.mm-wizard__body h3 { margin: 0 0 1rem; font-size: 1.05rem; font-weight: 600; color: var(--mm-text); }

/* file-select button (wraps the native file input, which is visually hidden but clickable) */
.mm-file-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: .75rem;
}
.mm-file-button input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    overflow: hidden;
    opacity: 0;
}
.mm-file-name {
    display: block;
    font-size: .9rem;
    color: var(--mm-text-muted);
    margin-bottom: 1.25rem;
    word-break: break-all;
}

.mm-preview {
    display: block;
    max-width: 100%;
    max-height: 340px;
    margin: 1.5rem auto 1.25rem;
    border-radius: var(--mm-radius-lg);
    border: 1px solid var(--mm-border);
    object-fit: contain;
    background: var(--mm-surface-alt);
}

/* a field whose input shares a row with a trailing action (e.g. Name + "Ask Amal") */
.mm-field__row { display: flex; gap: .75rem; align-items: stretch; }
.mm-field__row .mm-input { flex: 1 1 auto; min-width: 0; }
.mm-field__row .mm-ask-amal { flex: 0 0 auto; }

/* grid / picker cards — tight square mosaic (Reference B): edge-to-edge, no border/radius,
   centre-cropped squares; controls melt onto the image on hover. */
.mm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--mm-grid-size, 220px), 1fr)); gap: 1px; }
.mm-card {
    position: relative;
    overflow: hidden;
    background: var(--mm-surface-alt);
    cursor: pointer;
}
.mm-card:focus-visible { outline: 3px solid var(--mm-primary); outline-offset: -3px; }
.mm-card__media { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: var(--mm-surface-alt); }

/* bottom gradient overlay: title (left) + optional action(s) (right), revealed on hover.
   The container is click-through (pointer-events:none) so clicking the image still fires the
   card's own action (edit in the grid / select in the picker); interactive children opt back in. */
.mm-card__overlay {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .55rem;
    background: linear-gradient(to top, rgba(0, 0, 0, .72) 0%, rgba(0, 0, 0, .32) 55%, transparent 100%);
    opacity: 0;
    transition: opacity .15s ease;
    pointer-events: none;
}
.mm-card:hover .mm-card__overlay,
.mm-card:focus-within .mm-card__overlay { opacity: 1; }
.mm-card__overlay-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    color: #fff;
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}
.mm-card__overlay-action {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    cursor: pointer;
    transition: background-color .15s ease;
}
.mm-card__overlay-action:hover { background: var(--mm-danger); }
.mm-card__overlay-action:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, #fff 50%, transparent); }
.mm-card__overlay-action svg { width: 1rem; height: 1rem; }

/* flagged-moderation badge — small corner overlay, always visible */
.mm-card__flag { position: absolute; top: .4rem; right: .4rem; z-index: 2; }
/* (per-card pill actions removed — plan 325: single-item delete now lives in .mm-card__overlay) */

/* per-card multi-select checkbox — revealed on hover / kept when selected (plan 325) */
.mm-card__select {
    position: absolute;
    top: .5rem; left: .5rem;
    z-index: 2;
    display: inline-flex;
    opacity: 0;
    transition: opacity .15s ease;
}
.mm-card:hover .mm-card__select,
.mm-card:focus-within .mm-card__select,
.mm-card--selected .mm-card__select { opacity: 1; }
.mm-card__select input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    margin: 0;
    border: 2px solid #fff;
    border-radius: 6px;
    background: rgba(0, 0, 0, .3);
    cursor: pointer;
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
    transition: background-color .15s ease, border-color .15s ease;
}
.mm-card__select input[type="checkbox"]:checked { background: var(--mm-primary); border-color: var(--mm-primary); }
.mm-card__select input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 7px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
/* Selected card: draw the ring ON TOP of the image via ::after (z-index above the full-bleed
   <img>). An inset box-shadow on .mm-card is painted UNDER child content, so the object-fit:cover
   image occludes it — which is why selection was invisible. Double-stroke (2px brand + 1px light
   separator) stays legible on light AND dark photos; inset-only (no outer glow) so it never
   overlaps neighbours in the tight mosaic and causes zero layout shift. */
.mm-card--selected::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    box-shadow:
        inset 0 0 0 2px var(--mm-secondary),
        inset 0 0 0 3px color-mix(in srgb, #fff 75%, transparent);
}

/* the library browser sits on its own white surface in every host (EIC + Community) */
.mm-library-grid { background: var(--mm-surface); }

/* library toolbar: zoom (left) · compact search · spacer · upload · delete */
.mm-library-grid__toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.mm-library-grid__toolbar .mm-searchbox { flex: 0 0 260px; margin-bottom: 0; }
.mm-toolbar__spacer { flex: 1 1 auto; }
.mm-zoom { display: inline-flex; align-items: center; gap: .5rem; flex: 0 0 auto; cursor: pointer; }
.mm-zoom input[type="range"] { width: 120px; accent-color: var(--mm-primary); cursor: pointer; }
.mm-zoom__icon {
    display: block;
    opacity: .55;
    background: center / contain no-repeat url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='3' y='3' width='18' height='18' rx='2'/%3e%3ccircle cx='8.5' cy='8.5' r='1.5'/%3e%3cpath d='M21 15l-5-5L5 21'/%3e%3c/svg%3e");
}
.mm-zoom__icon--sm { width: 13px; height: 13px; }
.mm-zoom__icon--lg { width: 19px; height: 19px; }

/* (bulk-delete bar removed — plan 325: Delete now lives in the library toolbar) */

/* picker modal — centered selector dialog (replaces the legacy MediaSelectorComponent).
   z-index sits above EIC's flyout stack (.flyout-overlay 1999 / .flyout-container 2000 /
   page-manager 2100) so the picker is usable from inside the "Design with Amal" flyout. */
.mm-picker__backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.mm-picker__modal {
    display: flex;
    flex-direction: column;
    width: min(960px, 100%);
    height: 88vh;                 /* fixed size — constant box regardless of thumbnail count (body scrolls) */
    background: var(--mm-surface);
    border-radius: var(--mm-radius-lg);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
    overflow: hidden;
}
.mm-picker__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--mm-border);
}
.mm-picker__header h2 { margin: 0; font-size: 1.3rem; font-weight: 600; color: var(--mm-text); flex: 0 0 auto; }
.mm-picker__tools { display: flex; align-items: center; gap: 1rem; flex: 1 1 auto; justify-content: flex-end; flex-wrap: wrap; }
.mm-picker__tools .mm-searchbox { margin-bottom: 0; flex: 1 1 220px; max-width: 320px; }
.mm-picker__body { flex: 1 1 auto; overflow-y: auto; padding: 1.5rem; }
.mm-picker__footer {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--mm-border);
    background: var(--mm-surface-alt);
}

/* internal "Add New" uploader hosted by the picker — must sit ABOVE the picker modal (z 3000) */
.mm-picker__uploader-host .mm-flyout__backdrop { z-index: 3100; }
.mm-picker__uploader-host .mm-detail-flyout { z-index: 3110; }

/* selection checkbox visual on picker cards (multi-select mode) */
.mm-card__checkbox {
    display: block;
    width: 22px;
    height: 22px;
    border: 2px solid #fff;
    border-radius: 6px;
    background: rgba(0, 0, 0, .3);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
    position: relative;
    transition: background-color .15s ease, border-color .15s ease;
}
.mm-card__checkbox--checked { background: var(--mm-primary); border-color: var(--mm-primary); }
.mm-card__checkbox--checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 7px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.mm-loadmore { display: flex; justify-content: center; margin-top: 1.25rem; }

/* modal (confirm dialog) — must sit above flyouts */
.mm-modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}
.mm-modal {
    background: var(--mm-surface);
    border-radius: var(--mm-radius-lg);
    padding: 1.75rem;
    width: min(440px, 92vw);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.mm-modal__title { margin: 0 0 .5rem; font-size: 1.2rem; font-weight: 600; color: var(--mm-text); }
.mm-modal__message { color: var(--mm-text-muted); margin: 0 0 1.5rem; line-height: 1.5; }
.mm-modal__footer { display: flex; justify-content: flex-end; gap: .75rem; }

/* cropper host */
.mm-cropper { padding: 1.5rem 0; }
.mm-cropper__stage { max-width: 100%; max-height: 60vh; }
.mm-cropper__img { max-width: 100%; display: block; }
.mm-cropper__footer { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.25rem; }

/* ===== 07-utilities ===== */
.mm-visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ===== responsive ===== */
@media (max-width: 768px) {
    .mm-detail-flyout { width: 100%; min-width: 0; padding: 0 1.25rem; }
    .mm-detail-flyout__header { margin: 0 -1.25rem; padding: 1.25rem; }
    .mm-wizard__footer { margin: auto -1.25rem 0; padding: 1rem 1.25rem; }
}

/* Respect reduced-motion preference for all transitions/animation above. */
@media (prefers-reduced-motion: reduce) {
    .mm-btn,
    .mm-card,
    .mm-detail-flyout,
    .mm-detail-flyout__header .mm-btn { transition: none; animation: none; }
}

/* ===== folders: breadcrumb + folder tiles ===== */
.mm-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-bottom: 1rem; font-size: .9rem; }
.mm-breadcrumb__crumb { background: none; border: none; padding: .15rem .35rem; color: var(--mm-text-muted); cursor: pointer; border-radius: var(--mm-radius); }
.mm-breadcrumb__crumb:hover:not(:disabled) { color: var(--mm-primary); background: var(--mm-surface-alt); }
.mm-breadcrumb__crumb--current { color: var(--mm-text); font-weight: 600; cursor: default; }
.mm-breadcrumb__sep { color: var(--mm-text-muted); opacity: .6; }

.mm-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.mm-folder-tile {
    display: flex; align-items: center; gap: .65rem;
    padding: .75rem .9rem; border: 1px solid var(--mm-border); border-radius: var(--mm-radius-lg);
    background: var(--mm-surface); cursor: pointer; text-align: left;
    transition: border-color .15s ease, background-color .15s ease;
}
.mm-folder-tile:hover { border-color: var(--mm-primary); background: color-mix(in srgb, var(--mm-primary) 4%, var(--mm-surface)); }
.mm-folder-tile__icon { color: var(--mm-primary); flex: 0 0 auto; }
.mm-folder-tile__icon svg { width: 1.4rem; height: 1.4rem; }
.mm-folder-tile__name { font-size: .9rem; color: var(--mm-text); flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-folder-tile__menu { flex: 0 0 auto; border: none; background: none; color: var(--mm-text-muted); cursor: pointer; padding: .2rem; border-radius: var(--mm-radius); }
.mm-folder-tile__menu:hover { color: var(--mm-text); background: var(--mm-surface-alt); }
/* visible keyboard focus (WCAG 2.4.7) — mirrors .mm-card:focus-visible in the bundle */
.mm-folder-tile:focus-visible { outline: 3px solid var(--mm-primary); outline-offset: -3px; }

/* folder ⋯ action menu (Rename / Delete) — anchored to the tile */
.mm-folder-tile { position: relative; }
.mm-foldermenu__backdrop { position: fixed; inset: 0; z-index: 4; background: none; border: none; cursor: default; }
.mm-foldermenu { position: absolute; top: 2.4rem; right: .4rem; z-index: 5; min-width: 9.5rem;
    display: flex; flex-direction: column; padding: .25rem;
    background: var(--mm-surface); border: 1px solid var(--mm-border); border-radius: var(--mm-radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.mm-foldermenu__item { background: none; border: none; text-align: left; padding: .45rem .6rem;
    font-size: .85rem; color: var(--mm-text); cursor: pointer; border-radius: var(--mm-radius); }
.mm-foldermenu__item:hover { background: var(--mm-surface-alt); }

/* folder-tree chooser dialog (move-to / new folder) */
.mm-foldertree { max-height: 320px; overflow-y: auto; border: 1px solid var(--mm-border); border-radius: var(--mm-radius); padding: .5rem; }
.mm-foldertree__node { display: flex; align-items: center; gap: .4rem; padding: .35rem .5rem; border-radius: var(--mm-radius); cursor: pointer; background: none; border: none; width: 100%; text-align: left; color: var(--mm-text); font-size: .9rem; }
.mm-foldertree__node:hover { background: var(--mm-surface-alt); }
.mm-foldertree__node--selected { background: color-mix(in srgb, var(--mm-primary) 12%, transparent); color: var(--mm-primary); font-weight: 600; }

/* inline "new folder" sub-form inside the move-to dialog */
.mm-foldertree__new { display: flex; align-items: center; gap: .4rem; margin-top: .5rem; padding: .5rem .6rem; width: 100%;
    background: none; border: 1px dashed var(--mm-border); border-radius: var(--mm-radius); cursor: pointer;
    color: var(--mm-primary); font-size: .9rem; font-weight: 600; }
.mm-foldertree__new:hover { background: var(--mm-surface-alt); border-color: var(--mm-primary); }
.mm-newfolder { margin-top: .6rem; }
.mm-newfolder__hint { margin: 0 0 .4rem; font-size: .8rem; color: var(--mm-text-muted); }
.mm-newfolder__row { display: flex; align-items: center; gap: .5rem; }
.mm-newfolder__row .mm-input { flex: 1 1 auto; }
.mm-newfolder__close { flex: 0 0 auto; width: 2.6rem; align-self: stretch; display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--mm-border); border-radius: var(--mm-radius); color: var(--mm-text-muted); cursor: pointer; }
.mm-newfolder__close:hover { color: var(--mm-text); border-color: var(--mm-text-muted); }
/* extra gap above the action row (used by the move-to dialog so the footer clears the "+ New folder" block) */
.mm-modal__footer--spaced { margin-top: 1.25rem; }
