/* ============================================================
   Remote media configuration — the entry section, the dialogs and the
   read-only file picker (docs/specs/2026-10-31-remote-media-config.md and
   docs/specs/2026-11-02-remote-media-list-buttons.md).

   Colours come from the theme tokens only (--color-*, --rc-*): the four
   index.html themes and the desktop console (which redefines --color-* on
   body.desktop-page) paint it without a rule of their own. Names from the
   scoreboard app are untrusted and unbounded, so every box that shows one
   wraps anywhere instead of growing the page sideways.
   ============================================================ */

/* Status inks for icons and short error lines: the status hue mixed half and
   half with the text colour. Pure amber, green or red on the surface (or on
   its own light tint) misses the WCAG floor in the light themes; the mix
   keeps the hue and clears 4.5:1 in all four. Declared on the media roots,
   not :root, so the desktop console's body-level --color-* feed it. */
.media-section,
.media-modal,
.media-picker-overlay {
    --media-ink-warning: color-mix(in srgb, var(--color-warning) 50%, var(--color-text));
    --media-ink-success: color-mix(in srgb, var(--color-success) 50%, var(--color-text));
    --media-ink-danger: color-mix(in srgb, var(--color-danger) 50%, var(--color-text));
}

/* ── Outline-primary buttons (Choose, Add, the banner speed segments, …) ─────────────────────────────────────────
   Bootstrap paints an outline button's hover, :focus-visible and :active states from the SAME variables
   (--bs-btn-hover-*, --bs-btn-active-*), whose defaults are the stock blue fill with white text. remote-control.css
   re-colours only the resting text and the border of the console's outline-primary buttons (and their :hover), and
   desktop.html gets none of that. So a keyboard-focused Choose button sat on #0d6efd with the theme's accent ink on it
   (below the AA floor that test_a_keyboard_focused_choose_button_stays_legible asserts), and on the desktop console
   even the resting text was the stock blue on the dark surface. Everything here is written in the page's own
   tokens, so the four console themes and the desktop console take the same rules: the resting look is accent ink
   on the surface, hover and pressed fill with that ink, and focus draws a
   ring instead of a fill. */
:is(.media-section, .media-modal, .media-picker-overlay) .btn-outline-primary {
    --bs-btn-color: var(--color-accent-ink);
    --bs-btn-border-color: var(--color-accent-ink);
    --bs-btn-hover-color: var(--color-accent-ink);
    --bs-btn-hover-bg: transparent;
    --bs-btn-hover-border-color: var(--color-accent-ink);
    --bs-btn-active-color: var(--color-accent-ink);
    --bs-btn-active-bg: color-mix(in srgb, var(--color-accent-ink) 16%, transparent);
    --bs-btn-active-border-color: var(--color-accent-ink);
    --bs-btn-disabled-color: var(--color-accent-ink);
    --bs-btn-disabled-border-color: var(--color-accent-ink);
}

:is(.media-section, .media-modal, .media-picker-overlay) .btn-outline-primary:hover:not(:disabled):not(.disabled) {
    background-color: var(--color-accent-ink);
    border-color: var(--color-accent-ink);
    color: var(--color-surface);
}

:is(.media-section, .media-modal, .media-picker-overlay) .btn-outline-primary:focus-visible,
:is(.media-section, .media-modal, .media-picker-overlay) .btn-check:focus-visible + .btn-outline-primary {
    outline: 3px solid var(--color-accent-ink);
    outline-offset: 2px;
}

/* ── Secondary, danger and link buttons (Clear, Undo, the notice actions, Restore, Remove, the picker's breadcrumb and
   Load more) ─────────────────────────────────────────────────────────────────────────────────────────────────────
   The same defect as the outline-primary buttons above, one rung quieter: Bootstrap's stock grey, red and blue on the
   themed surfaces missed the AA floor at rest in the dark and marine themes and on the desktop console. Resting text is
   the page's text colour (secondary), the status ink that already feeds the error lines (danger) or the accent ink
   (link); the border of a secondary button is the text colour half-mixed into the surface so the outline itself clears
   the 3:1 floor for a control. Hover and pressed states keep the text on its ink and only add a tint. */
:is(.media-section, .media-modal, .media-picker-overlay) .btn-outline-secondary {
    --bs-btn-color: var(--color-text);
    --bs-btn-border-color: color-mix(in srgb, var(--color-text) 55%, var(--color-surface));
    --bs-btn-hover-color: var(--color-text);
    --bs-btn-hover-bg: color-mix(in srgb, var(--color-text) 10%, transparent);
    --bs-btn-hover-border-color: var(--color-text);
    --bs-btn-active-color: var(--color-text);
    --bs-btn-active-bg: color-mix(in srgb, var(--color-text) 18%, transparent);
    --bs-btn-active-border-color: var(--color-text);
    --bs-btn-disabled-color: var(--color-text);
    --bs-btn-disabled-border-color: color-mix(in srgb, var(--color-text) 55%, var(--color-surface));
}

:is(.media-section, .media-modal, .media-picker-overlay) .btn-outline-danger {
    --bs-btn-color: var(--media-ink-danger);
    --bs-btn-border-color: var(--media-ink-danger);
    --bs-btn-hover-color: var(--media-ink-danger);
    --bs-btn-hover-bg: color-mix(in srgb, var(--media-ink-danger) 12%, transparent);
    --bs-btn-hover-border-color: var(--media-ink-danger);
    --bs-btn-active-color: var(--media-ink-danger);
    --bs-btn-active-bg: color-mix(in srgb, var(--media-ink-danger) 22%, transparent);
    --bs-btn-active-border-color: var(--media-ink-danger);
    --bs-btn-disabled-color: var(--media-ink-danger);
    --bs-btn-disabled-border-color: var(--media-ink-danger);
}

:is(.media-section, .media-modal, .media-picker-overlay) .btn-link {
    --bs-btn-color: var(--color-accent-ink);
    --bs-btn-hover-color: var(--color-accent-ink);
    --bs-btn-active-color: var(--color-accent-ink);
    --bs-btn-disabled-color: var(--color-accent-ink);
}

:is(.media-section, .media-modal, .media-picker-overlay) .btn-outline-secondary:focus-visible,
:is(.media-section, .media-modal, .media-picker-overlay) .btn-link:focus-visible {
    outline: 3px solid var(--color-accent-ink);
    outline-offset: 2px;
}

:is(.media-section, .media-modal, .media-picker-overlay) .btn-outline-danger:focus-visible {
    outline: 3px solid var(--media-ink-danger);
    outline-offset: 2px;
}

/* A button label wraps inside its button instead of running out of it: a larger root text size (browser zoom or the OS's
   font setting) makes "An Anzeige senden" or "Auswählen" wider than a phone, and a nowrap button cannot shrink below
   its full label; at 200 % even one word is wider than a slot's column, so it may break inside the word. */
:is(.media-modal, .media-picker-overlay) .btn {
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
}

/* ── Entry section ──────────────────────────────────────────── */

.media-section .media-lock {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    margin: 10px 4px 0;
    padding: 0.6rem 0.8rem;
    border: 1px solid color-mix(in srgb, var(--color-warning) 50%, transparent);
    border-radius: var(--radius-lg, 0.75rem);
    background: color-mix(in srgb, var(--color-warning) 10%, var(--color-surface));
    color: var(--color-text);
    font-size: 0.85rem;
    line-height: 1.45;
}

.media-section .media-lock[hidden],
.media-section .media-lock__link[hidden] {
    display: none;
}

.media-section .media-lock > .bi {
    flex: none;
    margin-top: 0.1em;
    color: var(--media-ink-warning);
}

.media-section .media-lock__text {
    flex: 1 1 12rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.media-section .media-lock.is-checking {
    border-color: var(--color-border);
    background: var(--color-surface);
}

.media-section .media-lock.is-checking > .bi {
    color: var(--color-text-light);
}

/* A full touch target, not a word-sized one. */
.media-section .media-lock__link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.25rem;
    font-weight: 600;
    color: var(--color-accent-ink, var(--color-primary));
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/* A click on a locked tile points at the reason. */
.media-section .media-lock.is-flash {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-warning) 70%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
    .media-section .media-lock.is-flash {
        animation: media-lock-nudge 0.45s var(--rc-easing, ease) 1;
    }
}

@keyframes media-lock-nudge {
    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    60% {
        transform: translateX(3px);
    }
}

/* Locked tiles stay focusable (aria-disabled), so they keep their focus ring and
   only lose the "press me" cues. */
.media-section .is-locked[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    filter: saturate(0.35);
    transform: none;
    box-shadow: none;
}

@media (hover: hover) {
    .media-section .action-button.is-locked[aria-disabled="true"]:hover,
    body.desktop-page .media-section .desktop-action.is-locked[aria-disabled="true"]:hover {
        transform: none;
        box-shadow: none;
    }
}

/* Remote console, four tile columns (from 1560 px): the six tasks are a row of four and the last two, each spanning
   two cells, so no row stops short. In two columns they are three full rows anyway. */
@media (min-width: 1560px) {
    body.rc-has-console .media-section .rc-tiles .media-tile-pair {
        grid-column: span 2;
    }
}

/* Desktop console: six tasks in one row on a wide dock, otherwise two rows of three (or three of two): a column count
   that divides six, so no row stops short. */
body.desktop-page .desktop-media__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 14px 0 12px;
}

@media (min-width: 560px) {
    body.desktop-page .desktop-media__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    body.desktop-page .desktop-media__grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

body.desktop-page .desktop-media .desktop-action span {
    overflow-wrap: anywhere;
}

/* ── Dialog frame ───────────────────────────────────────────── */

.media-modal .modal-container {
    max-height: 92vh;
}

@media (min-width: 768px) {
    body.rc-page .media-modal .modal-container.is-wide {
        max-width: min(820px, calc(100vw - 32px));
        max-height: 90vh;
    }
}

.media-dialog {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md, 1rem);
    min-width: 0;
    color: var(--color-text);
}

.media-dialog__intro,
.media-dialog__access {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-text-light);
}

.media-dialog__intro {
    overflow-wrap: anywhere;
}

.media-dialog__root {
    display: inline;
    white-space: normal;
    color: var(--color-text);
}

.media-dialog__access {
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-md, 0.5rem);
    border: 1px solid color-mix(in srgb, var(--color-warning) 50%, transparent);
    background: color-mix(in srgb, var(--color-warning) 10%, var(--color-surface));
    color: var(--color-text);
}

.media-dialog__access[hidden] {
    display: none;
}

.media-dialog__fields {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md, 1rem);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

/* The fields stay readable while a send is in flight; they just cannot change. */
.media-dialog__fields:disabled {
    opacity: 0.7;
}

/* ── Notice (loading / sending / error / stale / success) ───── */

.media-dialog__notice:empty {
    display: none;
}

.media-dialog__notice {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-lg, 0.75rem);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: 0.9rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.media-dialog__notice-text {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.media-dialog__notice-text > .bi {
    flex: none;
    margin-top: 0.1em;
}

.media-dialog__notice-detail {
    margin: 0;
    color: var(--color-text-light);
}

.media-dialog__notice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.media-dialog__notice-actions .btn {
    min-height: 44px;
}

.media-dialog__notice.is-error {
    border-color: color-mix(in srgb, var(--color-danger) 55%, transparent);
    background: color-mix(in srgb, var(--color-danger) 9%, var(--color-surface));
}

.media-dialog__notice.is-error .media-dialog__notice-text > .bi {
    color: var(--media-ink-danger);
}

.media-dialog__notice.is-stale {
    border-color: color-mix(in srgb, var(--color-warning) 55%, transparent);
    background: color-mix(in srgb, var(--color-warning) 10%, var(--color-surface));
}

.media-dialog__notice.is-stale .media-dialog__notice-text > .bi {
    color: var(--media-ink-warning);
}

.media-dialog__notice.is-success {
    border-color: color-mix(in srgb, var(--color-success) 55%, transparent);
    background: color-mix(in srgb, var(--color-success) 9%, var(--color-surface));
}

.media-dialog__notice.is-success .media-dialog__notice-text > .bi {
    color: var(--media-ink-success);
}

/* ── Footer: always in reach, however long the form ─────────── */

.media-dialog__footer {
    position: sticky;
    bottom: calc(-1 * var(--spacing-lg, 1.5rem));
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin: 0 calc(-1 * var(--spacing-lg, 1.5rem)) calc(-1 * var(--spacing-lg, 1.5rem));
    padding: 0.75rem var(--spacing-lg, 1.5rem) var(--spacing-lg, 1.5rem);
    border-top: 1px solid var(--rc-divider, var(--color-border));
    background: var(--rc-card-bg, var(--color-surface));
}

.media-dialog__dirty {
    flex: 1 1 10rem;
    min-width: 0;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.media-dialog__dirty.is-dirty {
    color: var(--color-text);
    font-weight: 600;
}

.media-dialog__buttons {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
}

.media-dialog__buttons .btn {
    min-height: 44px;
    min-width: 7rem;
}

@media (max-width: 479.98px) {
    .media-dialog__buttons .btn {
        flex: 1 1 8rem;
        min-width: 0;
    }
}

/* ── Skeleton ───────────────────────────────────────────────── */

.media-skeleton {
    display: block;
    height: 4.25rem;
    border-radius: var(--radius-lg, 0.75rem);
    background: color-mix(in srgb, var(--color-text) 7%, var(--color-surface));
    list-style: none;
}

@media (prefers-reduced-motion: no-preference) {
    .media-skeleton {
        background-image: linear-gradient(90deg,
                transparent 0%,
                color-mix(in srgb, var(--color-text) 6%, transparent) 50%,
                transparent 100%);
        background-size: 200% 100%;
        background-repeat: no-repeat;
        animation: media-skeleton-sweep 1.4s ease-in-out infinite;
    }
}

@keyframes media-skeleton-sweep {
    from {
        background-position: 150% 0;
    }

    to {
        background-position: -50% 0;
    }
}

/* ── Cards, hints, inline notes, empty states ───────────────── */

.media-card {
    min-width: 0;
    padding: 0.9rem 1rem 1rem;
    border: 1px solid var(--rc-card-border, var(--color-border));
    border-radius: var(--radius-lg, 0.75rem);
    background: var(--color-surface);
}

.media-card__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    min-width: 0;
    overflow-wrap: anywhere;
}

.media-card__title > .bi {
    color: var(--color-accent-ink, var(--color-primary));
}

.media-card__hint {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--color-text-light);
}

.media-inline-note {
    margin: 0;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-md, 0.5rem);
    border: 1px solid var(--color-border);
    font-size: 0.88rem;
    line-height: 1.45;
}

.media-inline-note.is-warning {
    border-color: color-mix(in srgb, var(--color-warning) 50%, transparent);
    background: color-mix(in srgb, var(--color-warning) 10%, var(--color-surface));
}

.media-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.25rem 0.75rem;
    text-align: center;
    color: var(--color-text-light);
}

.media-empty > .bi {
    font-size: 1.6rem;
}

.media-empty p {
    margin: 0;
}

.media-empty[hidden] {
    display: none;
}

/* ── Change marks and errors ────────────────────────────────── */

.media-changed {
    display: inline-block;
    padding: 0.05rem 0.45rem;
    border-radius: var(--rc-radius-pill, 999px);
    background: color-mix(in srgb, var(--color-primary) 16%, var(--color-surface));
    color: var(--color-text);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    vertical-align: middle;
}

.media-changed[hidden] {
    display: none;
}

.media-field-error {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--media-ink-danger);
    overflow-wrap: anywhere;
}

.media-field-error[hidden] {
    display: none;
}

.media-ref-field.is-changed,
.media-list-field.is-changed,
.media-check.is-changed,
.media-color.is-changed,
.media-text-field.is-changed,
.media-number.is-changed,
.media-select.is-changed {
    border-left-color: var(--color-primary);
}

.media-ref-field.is-invalid,
.media-list-field.is-invalid,
.media-check.is-invalid,
.media-color.is-invalid,
.media-text-field.is-invalid,
.media-number.is-invalid,
.media-select.is-invalid,
.media-speed.is-invalid {
    border-left-color: var(--color-danger);
}

/* ── One media reference (Choose / Clear / Undo) ────────────── */

.media-ref-field,
.media-list-field,
.media-check,
.media-color,
.media-text-field,
.media-number,
.media-select {
    min-width: 0;
    padding-left: 0.75rem;
    border-left: 3px solid transparent;
}

.media-ref-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.media-ref-field__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.media-ref-field__label {
    font-weight: 600;
    font-size: 0.9rem;
}

.media-ref-field__value {
    min-width: 0;
}

.media-ref {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.media-ref__primary {
    font-weight: 500;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.media-ref__secondary {
    font-size: 0.8rem;
    color: var(--color-text-light);
    overflow-wrap: anywhere;
}

.media-ref.is-empty .media-ref__primary {
    font-weight: 400;
    font-style: italic;
    color: var(--color-text-light);
}

.media-ref.is-extern .media-ref__secondary {
    color: var(--color-text);
}

.media-ref.is-extern .media-ref__secondary::before {
    content: "\2192\00a0";
}

.media-ref-field__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.media-ref-field__actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 44px;
}

.media-ref-field__actions .btn[hidden] {
    display: none;
}

/* ── Checkboxes and switches ────────────────────────────────── */

.media-check.form-check {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 0.6rem;
    align-items: center;
    min-height: 44px;
    margin: 0;
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
}

/* The box is never smaller than 24 CSS px (WCAG 2.5.8), whatever the
   inherited font size; the switch keeps its proportions. */
.media-check .form-check-input {
    float: none;
    margin: 0;
    width: max(24px, 1.35em);
    height: max(24px, 1.35em);
    cursor: pointer;
}

.media-check.form-switch .form-check-input {
    width: max(46px, 2.6em);
}

/* The label fills the row's full 44 px height, so the box and the label
   together are one tall target on a phone. Flex drops the space between
   the two spans; the gap stands in for it. */
.media-check .form-check-label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 0.4rem;
    min-height: 44px;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.media-check .form-check-label > span {
    min-width: 0;
}

.media-check__hint,
.media-check .media-field-error {
    grid-column: 2;
}

.media-check__hint {
    margin: 0.1rem 0 0;
    font-size: 0.8rem;
    color: var(--color-text-light);
}

/* ── Banner ─────────────────────────────────────────────────── */

.media-speed {
    min-width: 0;
    margin: 0.5rem 0;
    padding: 0 0 0 0.75rem;
    border: 0;
    border-left: 3px solid transparent;
}

.media-speed__legend {
    float: none;
    width: auto;
    margin: 0 0 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.media-segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.media-segmented .btn {
    flex: 1 1 6rem;
    min-height: 44px;
}

/* The selected segment. remote-control.css gives every outline-primary button on the console the AA text role
   (colour AND border), at a specificity that also beats Bootstrap's `.btn-check:checked + .btn` — so left alone a
   selected segment kept its unselected look, and on the sand theme there was no fill at all. This rule is the
   console's own hover treatment (filled with the text role) and wins by one more class; the check mark means the
   selection does not rest on colour alone. The desktop console (desktop.html) has no such console rule to outrank, so it
   takes the same fill through its own body class. */
:root[data-theme] body.rc-has-console .media-segmented .btn-check:checked + .btn-outline-primary,
body.desktop-page .media-segmented .btn-check:checked + .btn-outline-primary {
    background-color: var(--color-accent-ink);
    border-color: var(--color-accent-ink);
    color: var(--color-surface);
}

.media-segmented .btn-check:checked + .btn::before {
    content: "\2713\00a0";
}

.media-slot-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.9rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (min-width: 640px) {
    .media-slot-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.media-slot {
    min-width: 0;
}

/* ── Player & staff media ───────────────────────────────────── */

.media-tabs {
    display: flex;
    gap: 0.5rem;
    min-width: 0;
}

.media-tab {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    min-width: 0;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 0.75rem);
    background: var(--color-surface);
    color: var(--color-text);
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.media-tab[aria-selected="true"] {
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
    box-shadow: inset 0 -3px 0 var(--color-primary);
}

.media-tab__side {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-light);
}

.media-tab__team {
    max-width: 100%;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.media-tab__count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text);
}

.media-tab__count:empty {
    display: none;
}

.media-team-panel[hidden] {
    display: none;
}

.media-person-filter {
    margin-bottom: 0.75rem;
}

.media-person-filter .form-control {
    min-height: 44px;
}

.media-person-lists {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.media-person-section__title {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-light);
}

.media-person-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.media-person {
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 0.75rem);
    background: var(--color-surface);
}

.media-person[hidden] {
    display: none;
}

.media-person.is-changed {
    border-color: color-mix(in srgb, var(--color-primary) 60%, var(--color-border));
}

.media-person.is-invalid {
    border-color: var(--color-danger);
}

.media-person__toggle {
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 52px;
    padding: 0.45rem 0.75rem;
    border: 0;
    border-radius: inherit;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.media-person__number {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--rc-radius-pill, 999px);
    background: color-mix(in srgb, var(--color-text) 8%, var(--color-surface));
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
}

.media-person__toggle > .bi-person-badge {
    justify-self: center;
    font-size: 1.25rem;
    color: var(--color-text-light);
}

.media-person__who {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.media-person__name {
    font-weight: 600;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.media-person__role {
    font-size: 0.8rem;
    color: var(--color-text-light);
    overflow-wrap: anywhere;
}

.media-person__summary {
    font-size: 0.78rem;
    color: var(--color-text-light);
    text-align: right;
}

.media-person__toggle > .media-changed {
    grid-column: 2 / 4;
    grid-row: 2;
    justify-self: start;
}

.media-person__chevron {
    grid-column: 4;
    grid-row: 1;
    transition: transform 0.15s ease;
}

.media-person.is-open .media-person__chevron,
.media-person__toggle[aria-expanded="true"] .media-person__chevron {
    transform: rotate(180deg);
}

.media-person__body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0.25rem 0.75rem 0.9rem;
    border-top: 1px solid var(--rc-divider, var(--color-border));
}

.media-person__body[hidden] {
    display: none;
}

.media-person__body > :first-child {
    margin-top: 0.6rem;
}

@media (max-width: 479.98px) {
    .media-person__toggle {
        grid-template-columns: 2.25rem minmax(0, 1fr) auto;
    }

    .media-person__summary {
        grid-column: 2 / 3;
        grid-row: 2;
        text-align: left;
    }

    .media-person__toggle > .media-changed {
        grid-column: 2 / 3;
        grid-row: 3;
    }

    .media-person__chevron {
        grid-column: 3;
    }
}

/* ── Media buttons ──────────────────────────────────────────── */

.media-button-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.media-button-card.is-changed {
    border-color: color-mix(in srgb, var(--color-primary) 60%, var(--color-border));
}

.media-button-card.is-invalid {
    border-color: var(--color-danger);
}

.media-button-card__head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    margin-bottom: 0.75rem;
}

.media-button-card__head .media-card__title {
    flex: 1 1 auto;
    margin: 0;
}

.media-button-card__name {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* A swatch of the button as the operator will see it (colours set via CSSOM). */
.media-button-preview {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-md, 0.5rem);
    border: 1px solid var(--color-border);
    background: color-mix(in srgb, var(--color-text) 20%, var(--color-surface));
    color: var(--color-text);
    font-weight: 700;
    overflow: hidden;
    white-space: nowrap;
}

.media-button-remove {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 0.25rem;
    min-height: 44px;
}

.media-button-card__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.9rem;
}

@media (min-width: 640px) {
    .media-button-card__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .media-button-card__grid > .media-color-row {
        grid-column: 1 / -1;
    }
}

.media-text-field .form-control {
    min-height: 44px;
}

.media-text-field .form-label,
.media-color .form-label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.media-color-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.9rem;
    min-width: 0;
}

.media-color__row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.media-color .form-control-color {
    flex: none;
    width: 3.25rem;
    height: 44px;
    padding: 0.25rem;
}

.media-color__code {
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.media-button-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    align-self: flex-start;
    min-height: 44px;
}

.media-button-removed:empty {
    display: none;
}

.media-button-removed__list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.media-button-removed__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-width: 0;
    padding: 0.25rem 0.25rem 0.25rem 0.75rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md, 0.5rem);
}

.media-button-removed__name {
    min-width: 0;
    text-decoration: line-through;
    color: var(--color-text-light);
    overflow-wrap: anywhere;
}

.media-button-removed__item .btn {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 0.25rem;
    min-height: 44px;
}

.media-button-add:disabled {
    cursor: not-allowed;
}

.media-button-limit {
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.media-button-limit[hidden] {
    display: none;
}

/* ── File lists (image-list, video-list and audio buttons) ──── */

.media-button-card__grid > .media-list-field {
    grid-column: 1 / -1;
}

.media-list-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.media-list-field__items {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.media-list-field__items[hidden],
.media-list-field__empty[hidden],
.media-list-field__limit[hidden] {
    display: none;
}

.media-list-field__empty,
.media-list-field__limit {
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.media-list-field__empty {
    font-style: italic;
}

/* Number, name and actions on one row from 640 px; below that the actions take a row of their own under the name. */
.media-list-item {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr);
    align-items: center;
    gap: 0.35rem 0.6rem;
    min-width: 0;
    padding: 0.35rem 0.4rem 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 0.5rem);
    background: var(--color-surface);
}

.media-list-item.is-new {
    border-color: color-mix(in srgb, var(--color-primary) 60%, var(--color-border));
}

/* Outside the media folder: kept as it is, never picked again. */
.media-list-item.is-extern {
    border-style: dashed;
}

.media-list-item.is-invalid {
    border-color: var(--color-danger);
    box-shadow: inset 3px 0 0 var(--color-danger);
}

.media-list-item__pos {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--rc-radius-pill, 999px);
    background: color-mix(in srgb, var(--color-text) 8%, var(--color-surface));
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.media-list-item__actions {
    display: flex;
    flex-wrap: wrap;
    grid-column: 2;
    gap: 0.3rem;
    min-width: 0;
}

@media (min-width: 640px) {
    .media-list-item {
        grid-template-columns: 2rem minmax(0, 1fr) auto;
    }

    .media-list-item__actions {
        grid-column: 3;
        flex-wrap: nowrap;
    }
}

.media-list-item__action {
    display: inline-grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
}

/* ── Numbers and choices ────────────────────────────────────── */

.media-number .form-label,
.media-select .form-label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.media-number__row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.media-number__input {
    max-width: 9rem;
    min-height: 44px;
    font-variant-numeric: tabular-nums;
}

.media-number__unit {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.media-number__range,
.media-number .media-check__hint {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: var(--color-text-light);
}

.media-select .form-select {
    min-height: 44px;
}

/* ── The read-only file picker ──────────────────────────────── */

body.rc-page .modal-overlay.media-picker-overlay .modal-container.confirm-container {
    max-width: min(640px, calc(100vw - 32px));
    max-height: 90vh;
}

@media (max-width: 767.98px) {
    body.rc-page .modal-overlay.media-picker-overlay .modal-container.confirm-container {
        max-width: 100%;
    }
}

.media-picker {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
}

.media-picker__types,
.media-picker__root,
.media-picker__readonly {
    margin: 0;
    font-size: 0.8rem;
    color: var(--color-text-light);
    overflow-wrap: anywhere;
}

.media-picker__readonly {
    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
}

.media-picker__crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.1rem 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 0;
}

.media-picker__crumb {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
    max-width: 100%;
}

.media-picker__crumb + .media-picker__crumb::before {
    content: "/";
    color: var(--color-text-muted, var(--color-text-light));
}

.media-picker__crumb-btn {
    min-height: 44px;
    max-width: 100%;
    padding: 0 0.4rem;
    border: 0;
    border-radius: var(--radius-md, 0.5rem);
    background: transparent;
    color: var(--color-accent-ink, var(--color-primary));
    font: inherit;
    font-weight: 600;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.media-picker__crumb-current {
    padding: 0 0.4rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.media-picker__filter-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.media-picker__filter-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.media-picker__filter {
    min-height: 44px;
}

.media-picker__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: min(48vh, 26rem);
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 0.75rem);
    background: var(--color-surface);
    list-style: none;
}

.media-picker__list:empty {
    display: none;
}

.media-picker__item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    min-height: 44px;
    padding: 0.4rem 0.6rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md, 0.5rem);
    cursor: pointer;
}

.media-picker__item > .bi {
    flex: none;
    color: var(--color-text-light);
}

.media-picker__item.is-dir > .bi-folder-fill {
    color: var(--media-ink-warning);
}

.media-picker__item:hover {
    background: color-mix(in srgb, var(--color-text) 6%, var(--color-surface));
}

.media-picker__item.is-selected {
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 14%, var(--color-surface));
}

.media-picker__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.media-picker__meta-group {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 0.35rem;
}

.media-picker__meta {
    font-size: 0.78rem;
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
}

.media-picker__badge {
    padding: 0.05rem 0.45rem;
    border-radius: var(--rc-radius-pill, 999px);
    background: color-mix(in srgb, var(--color-primary) 18%, var(--color-surface));
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.media-picker__skeleton {
    height: 44px;
}

.media-picker__note {
    margin: 0;
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
    color: var(--color-text-light);
    list-style: none;
}

.media-picker__status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.media-picker__status:empty {
    display: none;
}

.media-picker__status.is-error {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-md, 0.5rem);
    border: 1px solid color-mix(in srgb, var(--color-danger) 55%, transparent);
    background: color-mix(in srgb, var(--color-danger) 9%, var(--color-surface));
    color: var(--color-text);
}

.media-picker__status-text {
    flex: 1 1 12rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.media-picker__status-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.media-picker__status-actions .btn,
.media-picker__more {
    min-height: 44px;
}

.media-picker__more {
    align-self: center;
}

.media-picker__more[hidden] {
    display: none;
}

.media-picker__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--rc-divider, var(--color-border));
}

.media-picker__selected {
    flex: 1 1 12rem;
    min-width: 0;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.media-picker__selected-name {
    font-weight: 600;
}

.media-picker__buttons {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
}

.media-picker__buttons .btn {
    min-height: 44px;
    max-width: 100%;
    white-space: normal;
}

@media (max-width: 479.98px) {
    /* Side by side while both labels fit; "Use this file" takes its own row
       on the narrowest phones rather than pushing past the edge. */
    .media-picker__buttons .btn {
        flex: 1 1 auto;
    }
}

/* ── Focus: every control shows where the keyboard is ──────── */

.media-dialog :focus-visible,
.media-picker :focus-visible,
.media-section .media-lock__link:focus-visible {
    outline: 2px solid var(--color-accent-ink, var(--color-primary));
    outline-offset: 2px;
}

.media-picker__item:focus-visible {
    outline-offset: -2px;
}

.media-section .is-locked[aria-disabled="true"]:focus-visible {
    opacity: 0.8;
    outline: 2px solid var(--color-accent-ink, var(--color-primary));
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .media-person__chevron {
        transition: none;
    }
}
