/* ── Shared modal shell (visuals + info dialogs) ── */
.app-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100001;
    background: transparent;
    align-items: center;
    justify-content: center;
}
.app-modal-overlay.modal-open { display: flex; }
/* The darkening half of the backdrop (one window at a time; its blur is in overlays.css).
   Never the popover: dimming the page for a small panel reads wrong. */
:root[data-modal-backdrop] .app-modal-overlay:not(.modal-popover) {
    background: rgba(0,0,0,0.5);
}
/* Multiple windows switched off: the window kept takes its dim and blur only once the others have
   closed (shell.js holdBackdrop), so their motes never fly over the dark; then both fade in. */
:root[data-modal-backdrop] :is(.app-modal-overlay, #settings-modal-overlay).modal-open.backdrop-wait {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
:is(.app-modal-overlay, #settings-modal-overlay).modal-open {
    transition: background-color 0.22s ease, backdrop-filter 0.22s ease, -webkit-backdrop-filter 0.22s ease;
}
/* Multiple windows (motionPrefs multiWindow): no scrim, and the page under the windows stays live. A
   confirm still holds its question; shell.js stamps each window's z-index in raise order. */
:root[data-multi-window] :is(.app-modal-overlay, #settings-modal-overlay):not(.modal-popover, #confirm-modal-overlay) {
    background: transparent;
    pointer-events: none;
}
:root[data-multi-window] .app-modal-overlay:not(.modal-popover, #confirm-modal-overlay) .app-modal,
:root[data-multi-window] #settings-modal-overlay:not(.modal-popover) #settings-modal { pointer-events: auto; }
/* The header is the grab handle (ui/modal/drag.js); the popover, placed inline, is not draggable. */
:is(.app-modal-overlay, #settings-modal-overlay):not(.modal-popover) .settings-header { cursor: grab; }
:is(.app-modal, #settings-modal).modal-dragging .settings-header { cursor: grabbing; }
/* No transition while dragging, or the box lags the pointer by the flight's easing. */
.app-modal.modal-dragging { transition: none !important; }
/* The edges are the window's resize handles (ui/modal/resize.js), as a desktop window's frame
   is: the box names the edge under the pointer, and the header's grab hand yields to it. */
[data-edge], [data-edge] .settings-header { cursor: var(--edge-cursor); }
.modal-resizing { transition: none !important; }
/* `modal-closing` keeps the overlay up for the shrink-back only; the modal counts as closed at once. */
.app-modal-overlay.modal-closing { display: flex; }
/* The confirm dialog is always spawned from another modal, so it stacks above every app modal. */
#confirm-modal-overlay.modal-open { z-index: 100003; }
/* …and keeps that place while it leaves, or it would read as the wrong dialog coming apart. */
#confirm-modal-overlay.modal-closing { z-index: 100003; }
.app-modal {
    background: var(--bg-container);
    color: var(--text-main);
    /* The hairline the desktop's #modalShell wears on every dialog (theme.cpp, same
       --border-main): over a dark canvas the shadow alone left no edge at all. */
    border: 1px solid var(--border-main);
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.45);
    width: 560px;
    max-width: calc(100vw - 40px);
    max-height: min(82vh, 760px);   /* the shared ceiling — see #settings-modal */
    /* Content adapts to the window's own width, which a phone, the popover or a resize may narrow. */
    container: modal / inline-size;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* Modal popover: the compact anchored shape of any app modal (ui/tip/popover.js). The overlay
   still covers the page, transparent, and the box is capped small with a scrolling body. */
.app-modal-overlay.modal-popover,
#settings-modal-overlay.modal-popover {
    background: transparent;
    align-items: flex-start;
    justify-content: flex-start;
    /* Pointer-transparent, so an Alt glide reaches the other toolbar icons; the box keeps its events. */
    pointer-events: none;
}
.modal-popover .app-modal,
#settings-modal-overlay.modal-popover #settings-modal { pointer-events: auto; }
.modal-popover .app-modal,
#settings-modal-overlay.modal-popover #settings-modal {
    position: fixed;
    width: 420px;
    max-width: calc(100vw - 16px);
    max-height: min(560px, 78vh);
    box-shadow: 0 10px 34px rgba(0,0,0,0.5);
    animation: popover-in 0.12s ease-out;
}
@keyframes popover-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}

.app-modal-close {
    background: transparent;
    border: 1px solid var(--border-main) !important;
    color: var(--text-main);
    font-size: 13px;
    padding: 3px 10px;
    border-radius: 12px;
    cursor: pointer;
}
/* The accent on hover, like the desktop's #modalClosePill; `!important` on the border only
   because the resting rule sets it. */
.app-modal-close:hover {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent) !important;
}
.vs-section {
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 14px 0 6px;
}
.vs-section:first-child { margin-top: 0; }
.vs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 4px;
    border-bottom: 1px solid var(--border-coord);
    font-size: 13px;
}
.vs-row label { font-weight: normal; }
/* A caption tied to its check toggles it, so it takes the hand the box does. */
.vs-row label[for] { cursor: pointer; user-select: none; }
/* A row another setting overrides (Dim and blur, under Multiple windows) reads as idle. */
.vs-row.vs-row-idle label { opacity: .5; cursor: default; }
.vs-row input[type="color"] { width: 46px; height: 24px; padding: 2px; cursor: pointer; }
.vs-row input[type="number"], .vs-row select { width: 90px; }
/* One control column, flush right, so the rows read as a table (desktop settingsDialog parity).
   The Assistant modal shares it, wider: a base URL or API key clips at 180px. */
stencil-visuals-modal, stencil-llm-settings-modal { --vs-ctrl-h: 30px; }
/* --vs-ctrl-pct is the column's share of the default 522px row, so a widened window grows the
   controls with it (desktop settingsDialog's CTRL_SHARE twin) instead of leaving a gap. */
stencil-visuals-modal { --vs-ctrl-w: 180px; --vs-ctrl-pct: 34%; }
stencil-llm-settings-modal { --vs-ctrl-w: 320px; --vs-ctrl-pct: 61%; }
stencil-visuals-modal .vs-row > .vs-ctrl,
stencil-llm-settings-modal .vs-row > .vs-ctrl {
    flex: 0 0 max(var(--vs-ctrl-w), var(--vs-ctrl-pct));
    width: max(var(--vs-ctrl-w), var(--vs-ctrl-pct));
    min-width: 0;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}
/* A styled dropdown wraps its native select in .accent-dd/.cs-dd, so a bare `> select`
   never reaches the ones the Assistant rows use — both hosts list every wrapper. */
stencil-visuals-modal .vs-ctrl > input,
stencil-visuals-modal .vs-ctrl > select,
stencil-visuals-modal .vs-ctrl > .accent-dd,
stencil-visuals-modal .vs-ctrl > .cs-dd,
stencil-visuals-modal .vs-ctrl .accent-dd-trigger,
stencil-llm-settings-modal .vs-ctrl > input,
stencil-llm-settings-modal .vs-ctrl > select,
stencil-llm-settings-modal .vs-ctrl > .accent-dd,
stencil-llm-settings-modal .vs-ctrl > .cs-dd,
stencil-llm-settings-modal .vs-ctrl .accent-dd-trigger {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
stencil-visuals-modal .vs-ctrl > input,
stencil-visuals-modal .vs-ctrl > select,
stencil-visuals-modal .vs-ctrl .accent-dd-trigger,
stencil-llm-settings-modal .vs-ctrl > input,
stencil-llm-settings-modal .vs-ctrl > select,
stencil-llm-settings-modal .vs-ctrl .accent-dd-trigger {
    height: var(--vs-ctrl-h);
    padding: 0 10px;
    font-size: 13px;
    border-radius: 6px;
}
/* A row's title resets its control on a double-click (ui/control/reset/dblReset.js), so it selects no text. */
.vs-row > label:first-child { user-select: none; -webkit-user-select: none; }
/* The Animation speed: its number box, then the frame scrub's bar (.vs-range, components/openImage.css). */
stencil-visuals-modal .vs-ctrl.vs-speed { gap: 10px; height: var(--vs-ctrl-h); }
stencil-visuals-modal .vs-ctrl.vs-speed > .vs-speed-num { flex: 0 0 64px; width: 64px; }
stencil-visuals-modal .vs-ctrl.vs-speed > .vs-range { flex: 1 1 auto; width: auto; height: 13px; padding: 0; border-radius: 0; }
stencil-visuals-modal .vs-ctrl.vs-color {
    gap: 8px;
    height: var(--vs-ctrl-h);
    padding: 0 10px;
    background: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--border-main);
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Menlo','Consolas',monospace;
    font-size: 12px;
    font-weight: normal;
}
stencil-visuals-modal .vs-ctrl.vs-color:hover { border-color: var(--accent); }
stencil-visuals-modal .vs-ctrl.vs-color input[type="color"] {
    flex: 0 0 auto;
    width: 32px;
    height: 18px;
    padding: 0;
    border: none;
    background: transparent;
}
stencil-visuals-modal .vs-hex { flex: 1 1 auto; letter-spacing: 0.02em; }
/* A checkbox keeps its 15px box, flush right — the desktop's `column=false` rows
   (SettingsDialog.cpp). */
stencil-visuals-modal .vs-ctrl.vs-ctrl-check { justify-content: flex-end; }
stencil-visuals-modal .vs-ctrl.vs-ctrl-check > input[type="checkbox"] {
    width: 15px;
    height: 15px;
    padding: 0;
    border-radius: 3px;
}
/* Labeled text-field rows: an equal label column; min-width, so a long label never clips. */
.vs-row.vs-field > label { flex: 0 0 auto; min-width: var(--vs-label-w, 48px); }
/* Image-links modal labels are longer ("Image / video URL") — widen its column. */
stencil-links-modal { --vs-label-w: 118px; }
/* "Save to" target selects hold longer option labels ("Local (this browser)",
   server URLs) — let them size to content instead of clipping at 90px. */
.vs-row select[id$="-target"] { width: auto; min-width: 150px; max-width: 240px; }
.links-quickcrop-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.links-inline-check, .vs-inline-check { display: inline-flex; align-items: center; gap: 5px; font-weight: normal; white-space: nowrap; cursor: pointer; }
/* Checkbox option groups share one row while they fit, wrapping to further
   lines (each option as a unit) only when the modal is too narrow. */
.vs-row.vs-checks { justify-content: flex-start; flex-wrap: wrap; gap: 7px 26px; }
.oi-replace { display: flex; flex-wrap: wrap; gap: 7px 18px; }