/**
 * Image Background Remover — app styles.
 * Design tokens only (see main.css :root). Prefix: `ibr-`.
 * Permitted literals: 44px touch-target minimum, icon SVG sizes,
 * 12px checkerboard cell (texture constant), color-mix percentages.
 */

/* Container (mandatory: margin: 0 auto) */
.ibr-container {
    width: 100%;
    max-width: var(--app-container-max);
    margin: 0 auto;
    padding: var(--space-4);
}

/* Sections share the site's vertical rhythm */
.ibr-container .use-cases,
.ibr-container .how-it-works,
.ibr-container .faq-section {
    margin-top: var(--space-8);
}

/* How It Works (mirrors the site use-cases block) */
.ibr-container .how-it-works {
    max-width: var(--app-container-max);
    width: 100%;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    padding: var(--space-8);
    background: var(--color-bg-alt);
    border-radius: var(--radius-lg);
}

.ibr-container .how-it-works h2 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 var(--space-4);
}

.ibr-container .how-it-works-intro {
    color: var(--color-text-muted);
    margin: 0 0 var(--space-6);
    line-height: var(--line-height-relaxed);
}

.ibr-container .how-it-works-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: var(--space-4);
}

.ibr-container .how-it-works-steps li {
    background: var(--color-bg-card);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.ibr-container .how-it-works-steps li strong {
    display: block;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-2);
}

.ibr-container .how-it-works-steps li p {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: var(--line-height-normal);
    margin: 0;
}

@media (min-width: 768px) {
    .ibr-container .how-it-works-steps {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Hide optional surfaces that CSS display rules would otherwise override */
.ibr-model-strip[hidden],
.ibr-tray[hidden],
.ibr-tray__zip-progress[hidden],
.ibr-toast[hidden] {
    display: none;
}

/* ========================================
   Drop zone
   ======================================== */
.ibr-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    min-height: 180px;
    padding: var(--space-4);
    margin-bottom: var(--space-2);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg-alt);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition-base), background var(--transition-base), min-height var(--transition-base);
}

.ibr-dropzone:hover {
    border-color: var(--color-border-dark);
}

.ibr-dropzone:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.ibr-dropzone__icon {
    color: var(--color-text-muted);
}

.ibr-dropzone__hint {
    font-weight: 600;
}

.ibr-dropzone__methods {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* Drag-over: non-color cue = border becomes solid + hint text swaps */
.ibr-dropzone--dragover {
    border-style: solid;
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 8%, var(--color-bg-alt));
}

/* Compact "add more" bar once the queue has items */
.ibr-dropzone--compact {
    min-height: 48px;
    flex-direction: row;
    gap: var(--space-3);
    padding: var(--space-3);
}

.ibr-dropzone--compact .ibr-dropzone__methods {
    display: none;
}

.ibr-privacy-note {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-2) 0 var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* ========================================
   Global "All images" settings row
   Global defaults (crop + export format + never-skip) for every current
   and future image. Reuses the card switch + segmented-control components.
   ======================================== */
.ibr-settings {
    margin: var(--space-3) 0 var(--space-2);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
}

.ibr-settings legend {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    padding: 0 var(--space-1);
    margin-inline-start: 0;
}

.ibr-settings__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
}

/* Compact the format segmented control in the settings row (the card
   variant's margin-inline-start: auto would push it right). */
.ibr-settings__format {
    margin-inline-start: 0;
}

.ibr-settings__neverskip {
    margin-inline-start: auto;
}

.ibr-settings__hint {
    display: block;
    margin-top: var(--space-2);
}

@media (max-width: 640px) {
    .ibr-settings__row {
        flex-direction: column;
        align-items: flex-start;
    }

    .ibr-settings__neverskip {
        margin-inline-start: 0;
    }
}

/* ========================================
   Model status strip
   ======================================== */
.ibr-model-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* message drops to its own line on narrow screens */
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-bg-alt);
    font-size: var(--font-size-sm);
}

/* Status message ("Downloading AI model (…)" / failure text). It must be
   fully visible in every locale: it shrinks and WRAPS instead of clipping. */
.ibr-model-strip__message {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
}

.ibr-model-strip--error {
    color: var(--color-error-text);
}

.ibr-model-strip__spinner {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: ibr-spin 0.9s linear infinite;
}

.ibr-model-strip__progress {
    flex: 1 1 auto;
    height: 8px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.ibr-model-strip__progress-bar {
    height: 100%;
    width: 0%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-fast);
}

/* Indeterminate variant when the loader reports no percentage */
.ibr-model-strip__progress-bar--indeterminate {
    width: 40%;
    animation: ibr-slide 1.2s ease-in-out infinite;
}

.ibr-model-strip__percent {
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    min-width: 4ch;
    text-align: right;
}

.ibr-model-strip__retry {
    flex: 0 0 auto;
    background: none;
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-3);
    font-family: var(--font-sans);
    font-size: var(--font-size-xs);
    color: var(--color-error-text);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.ibr-model-strip__retry:hover {
    border-color: var(--color-error);
}

.ibr-model-strip__retry:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

@keyframes ibr-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ibr-slide {
    0% {
        margin-left: -40%;
    }
    100% {
        margin-left: 100%;
    }
}

/* ========================================
   Queue tray
   ======================================== */
.ibr-tray {
    margin-top: var(--space-4);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    background: var(--color-bg-alt);
}

.ibr-tray__header {
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* at 375px the actions group may drop to a second row;
                        the counter itself never wraps (nowrap below) */
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.ibr-tray__title {
    margin: 0;
    font-size: var(--font-size-lg);
    line-height: var(--line-height-tight);
    color: var(--color-text);
}

/* Live "n of 500" queue counter (v1.4). Permanent while the tray is visible
   (never inserted/removed), so digit ticks only change text inside the
   fixed-width mono field — zero layout shift. min-width 8ch is a texture
   constant (exactly "500 / 500"), like the 12px checkerboard cell. */
.ibr-tray__counter {
    margin-inline-start: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    min-width: 8ch;
    text-align: left;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    padding: 0 var(--space-2);
}

/* Cap state (500 / 500): warning pill. The pill is the ONLY visual delta —
   the reached cap in the digits is the non-color cue and the overflow toast
   is the behavioral one. Same reserved width as the plain state. */
.ibr-tray__counter--cap {
    color: var(--color-warning-text);
    border-color: var(--color-warning);
}

/* Batch-ZIP progress row (v1.4): dedicated row between the tray header and
   the card grid, toggled with `hidden` (no reserved space when hidden — same
   pattern as the model strip). Determinate only; the track/bar values copy
   the model-strip progress visual language (8px, --color-border track,
   --color-primary fill). */
.ibr-tray__zip-progress {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

/* Count field: the zipProgress label. min-width 11ch (exactly "500 / 500"
   + separator) is a texture constant so per-image ticks never reflow the
   bar. */
.ibr-tray__zip-progress__count {
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    min-width: 11ch;
    text-align: left;
    white-space: nowrap;
}

.ibr-tray__zip-progress__track {
    flex: 1 1 auto;
    min-width: 0;
    height: 8px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.ibr-tray__zip-progress__bar {
    height: 100%;
    width: 0%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-fast);
}

.ibr-tray__header-actions {
    margin-inline-start: auto;
}

.ibr-tray__clear {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-bg-card);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

/* Disabled (Download all while the batch ZIP generates): attribute-only
   toggle, no size/label change. No hover/focus/active while disabled. */
.ibr-tray__clear:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.ibr-tray__clear:not(:disabled):hover {
    border-color: var(--color-border-dark);
    background: var(--color-bg-alt);
}

.ibr-tray__clear:not(:disabled):focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* minmax(0, 1fr) is mandatory: a bare 1fr track (minmax(auto, 1fr)) lets a
   card's intrinsic min-content (e.g. a long unwrapped filename) widen the
   whole grid and push the page into horizontal scroll on mobile. */
.ibr-tray__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
}

@media (min-width: 768px) {
    .ibr-tray__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ========================================
   Queue card
   ======================================== */
.ibr-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--color-border);
    border-inline-start: 3px solid transparent;
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

/* "Under the light" — the single active card */
.ibr-card--active {
    border-inline-start-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 4%, var(--color-bg-card));
}

.ibr-card--error {
    border-inline-start-color: var(--color-error);
}

.ibr-card__top {
    display: flex;
    gap: var(--space-3);
}

/* Original + result previews: 1 col on mobile, 2 cols on desktop
   (same breakpoint as .ibr-tray__grid). Sits beside .ibr-card__meta. */
.ibr-card__previews {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
    flex: 1 1 auto;
    min-width: 0;
}

@media (min-width: 768px) {
    .ibr-card__previews {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.ibr-card__preview-block {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

/* Visible label above each well (Original / Result) */
.ibr-card__preview-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-align: center;
}

/* Preview well: CSS-only theme-aware checkerboard (fills its grid cell) */
.ibr-card__preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    max-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-dark);
    background-color: var(--color-bg-alt);
    background-image: repeating-conic-gradient(
        var(--color-bg-alt) 0% 25%,
        var(--color-border) 25% 50%
    );
    background-size: 12px 12px;
    overflow: hidden;
    transition: background var(--transition-fast);
}

/* Original well: plain background, no checkerboard (it is the source, not
   the transparency reveal). */
.ibr-card__preview--original {
    background-image: none;
    background-color: var(--color-bg);
}

/* When a solid/gradient background is chosen the well shows the composited
   result and the checkerboard is replaced by that background. */
.ibr-card__preview--no-checker {
    background-image: none;
}

.ibr-card__preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Waiting: grayscale thumbnail */
.ibr-card__preview--waiting img {
    filter: grayscale(1);
}

.ibr-card__preview:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.ibr-card__meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
    flex: 1 1 auto;
}

.ibr-card__name {
    font-size: var(--font-size-sm);
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ibr-card__status {
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* a long status message or badge pill wraps to its own line */
    gap: var(--space-2);
    font-size: var(--font-size-sm);
}

.ibr-card__status-dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-border-dark);
}

.ibr-card__status--processing .ibr-card__status-dot {
    background: var(--color-primary);
}

.ibr-card__status--processing {
    color: var(--color-primary-text);
}

.ibr-card__status--done {
    color: var(--color-success-text);
}

.ibr-card__status--done .ibr-card__status-dot {
    background: var(--color-success);
}

.ibr-card__status--error {
    color: var(--color-error-text);
}

.ibr-card__status--error .ibr-card__status-dot {
    background: var(--color-error);
}

/* Status message: semantic text must never be clipped. It takes the rest of
   the line and WRAPS (multi-line) instead of ellipsizing — the es/pl
   translations are 20-40% longer than en and must stay fully readable. */
.ibr-card__status-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
}

/* Subtle status-area badge pills (alpha-skipped / saved). Muted, quiet —
   the status dot + text remain the primary cues. The pill may grow tall
   (wrapping) rather than clipping, since the badge label is semantic. */
.ibr-card__pill {
    flex: 0 1 auto;
    max-width: 100%;
    padding: 1px var(--space-2);
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius-full);
    background: var(--color-bg-alt);
    font-size: var(--font-size-xs);
    line-height: var(--line-height-tight);
    color: var(--color-text-muted);
    white-space: normal;
    overflow-wrap: break-word;
}

.ibr-card__pill--alpha {
    border-color: var(--color-success);
    color: var(--color-success-text);
}

.ibr-card__pill--saved {
    border-color: var(--color-primary);
    color: var(--color-primary-text);
}

.ibr-card__dims,
.ibr-card__position {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--color-text-light);
}

/* Thin progress bar across the preview while processing */
.ibr-card__preview {
    position: relative;
}

.ibr-card__progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--color-primary);
    width: 100%;
    opacity: 0.8;
}

/* ========================================
   Background-mode segmented control
   ======================================== */
.ibr-bgmode {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.ibr-bgmode:disabled,
.ibr-bgmode--disabled {
    opacity: 0.5;
    pointer-events: none;
}

.ibr-bgmode__segmented {
    display: flex;
    width: 100%;
    padding: 3px;
    gap: 2px;
    border-radius: var(--radius-full);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
}

.ibr-bgmode__segment {
    flex: 1 1 0;
    position: relative;
}

.ibr-bgmode__segment input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ibr-bgmode__segment span {
    display: block;
    min-height: 38px;
    line-height: var(--line-height-tight);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.ibr-bgmode__segment span:hover {
    background: var(--color-bg-card);
}

.ibr-bgmode__segment input:focus-visible + span {
    box-shadow: var(--focus-ring);
    outline: none;
}

.ibr-bgmode__segment input:checked + span {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}

/* Fixed-height picker row so mode switches never reflow the action row */
.ibr-bgmode__pickers {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0;
}

.ibr-bgmode__hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.ibr-color {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Hide pickers not matching the active bg mode. .ibr-color and the gradient
   wrapper set an explicit display (inline-flex / inline "contents"), which
   would otherwise override the UA [hidden] display:none — force it to win so
   solid shows 1 picker, gradient 2, transparent 0. */
.ibr-color[hidden],
.ibr-grad-wrap[hidden] {
    display: none !important;
}

.ibr-color input[type='color'] {
    inline-size: 40px;
    block-size: 40px;
    padding: 0;
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    cursor: pointer;
}

.ibr-color input[type='color']:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Live gradient strip between the two gradient pickers */
.ibr-grad-strip {
    flex: 1 1 60px;
    min-width: 40px;
    height: 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border-dark);
}

/* ========================================
   Options row (crop switch + format + ZIP)
   Sits between the bg-mode block and the actions row.
   ======================================== */
.ibr-card__options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
}

/* Crop-to-subject switch (native checkbox styled as a track + thumb). */
.ibr-card__crop-wrap {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.ibr-card__crop {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    flex: 0 0 auto;
    width: 40px;
    height: 24px;
    margin: 0;
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius-full);
    background: var(--color-bg-alt);
    position: relative;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.ibr-card__crop::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-text-muted);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.ibr-card__crop:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.ibr-card__crop:checked::before {
    transform: translateX(16px);
    background: var(--color-text-inverse);
}

.ibr-card__crop:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.ibr-card__crop:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.ibr-card__crop-wrap:has(.ibr-card__crop:disabled) {
    opacity: 0.5;
}

.ibr-card__crop-label {
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.ibr-card__crop-hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Format (PNG / WebP) — reuses the .ibr-bgmode__segmented pattern at a
   smaller, compact width so it fits the options row. */
.ibr-card__format {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-inline-start: auto;
}

.ibr-card__format-label {
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.ibr-card__format-seg {
    width: auto;
}

.ibr-card__format-seg-item span {
    min-height: 32px;
    padding: var(--space-1) var(--space-3);
}

/* Dim + block the format control until the item is done. */
.ibr-card__format-seg:has(input:disabled) {
    opacity: 0.5;
    pointer-events: none;
}

.ibr-card__options-hint {
    flex-basis: 100%;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* ========================================
   Card actions
   ======================================== */
.ibr-card__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.ibr-btn-primary {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.ibr-btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.ibr-btn-primary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.ibr-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.ibr-btn-secondary:hover:not(:disabled) {
    border-color: var(--color-border-dark);
    background: var(--color-bg-alt);
}

.ibr-btn-secondary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.ibr-btn-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 44px;
    block-size: 44px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.ibr-btn-icon:hover {
    border-color: var(--color-border-dark);
    color: var(--color-error-text);
    background: var(--color-bg-alt);
}

.ibr-btn-icon:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Disabled export controls (pre-Ready) */
.ibr-card__actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   Toast
   ======================================== */
.ibr-toast {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    max-width: min(90vw, 420px);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm);
    transition: opacity var(--transition-base);
    /* Long toast messages must WRAP, never clip: without this the text is an
       anonymous flex item whose min-width:auto lets it overflow the box. */
    white-space: normal;
    overflow-wrap: break-word;
}

.ibr-toast--success {
    color: var(--color-success-text);
}

.ibr-toast--error {
    color: var(--color-error-text);
}

/* Warning variant (v1.4 queue cap overflow): neither success (something was
   rejected) nor error (nothing failed — the accepted images are fine). */
.ibr-toast--warning {
    color: var(--color-warning-text);
}

/* Visually hidden live region */
.ibr-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   FAQ (shared section shell in main.css; question/answer
   typography lives here since main.css expects dt/dd)
   ======================================== */
.ibr-container .faq-question {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.ibr-container .faq-question:hover {
    color: var(--color-primary-text);
}

.ibr-container .faq-question:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

.ibr-container .faq-answer {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: var(--line-height-normal);
    margin: var(--space-3) 0 0;
}

/* ========================================
   Pressed (active) states
   ======================================== */
.ibr-dropzone:active,
.ibr-btn-primary:active:not(:disabled),
.ibr-btn-secondary:active:not(:disabled),
.ibr-btn-icon:active,
.ibr-tray__clear:active:not(:disabled),
.ibr-model-strip__retry:active {
    transform: scale(0.98);
}

/* ========================================
   Reduced motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .ibr-dropzone,
    .ibr-card,
    .ibr-card__preview,
    .ibr-btn-primary,
    .ibr-btn-secondary,
    .ibr-btn-icon,
    .ibr-model-strip__progress-bar,
    .ibr-tray__zip-progress__bar,
    .ibr-toast {
        transition: none;
    }

    .ibr-dropzone:active,
    .ibr-btn-primary:active:not(:disabled),
    .ibr-btn-secondary:active:not(:disabled),
    .ibr-btn-icon:active,
    .ibr-tray__clear:active:not(:disabled),
    .ibr-model-strip__retry:active {
        transform: none;
    }

    .ibr-model-strip__spinner {
        animation: none;
    }

    .ibr-model-strip__progress-bar--indeterminate {
        animation: none;
        width: 30%;
    }
}

/* ========================================
   Mobile
   ======================================== */
@media (max-width: 767px) {
    .ibr-container {
        padding: var(--space-3);
    }

    .ibr-dropzone {
        min-height: 140px;
    }

    .ibr-card__top {
        flex-direction: column;
    }

    /* Keep the two previews side by side on mobile (2-up grid) so the card
       stays compact; each well is full-width of its half. */
    .ibr-card__previews {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ibr-card__options {
        align-items: flex-start;
    }

    .ibr-card__format {
        margin-inline-start: 0;
    }

    .ibr-card__actions {
        flex-wrap: wrap;
    }

    .ibr-card__actions .ibr-btn-primary {
        flex-basis: 100%;
        order: 3;
    }
}
