/* Leo Paint — layout and components. All colours come from theme.css. */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg-app);
    color: var(--text-primary);
    font: 12px/1.4 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; color: var(--text-disabled); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

.icon { flex: none; display: block; }
.muted { color: var(--text-secondary); }
.small { font-size: 11px; }
.mono { font-variant-numeric: tabular-nums; }
.hidden-input { display: none; }

.checkerboard {
    background-color: var(--canvas-checkerboard-a);
    background-image:
        linear-gradient(45deg, var(--canvas-checkerboard-b) 25%, transparent 25%, transparent 75%, var(--canvas-checkerboard-b) 75%),
        linear-gradient(45deg, var(--canvas-checkerboard-b) 25%, transparent 25%, transparent 75%, var(--canvas-checkerboard-b) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
}

/* ------------------------------------------------------------------ app frame */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.editor-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.workspace-host {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* ------------------------------------------------------------------ menu bar */

.menubar {
    display: flex;
    align-items: center;
    height: 32px;
    padding: 0 6px;
    background: var(--bg-menu);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 40;
    user-select: none;
}

.app-badge {
    display: grid;
    place-items: center;
    width: 26px;
    height: 22px;
}

.app-badge img { display: block; width: 18px; height: 18px; }

.menu { position: relative; }

.menu-title {
    height: 26px;
    padding: 0 9px;
    background: none;
    border: 0;
    border-radius: 4px;
}

.menu-title:hover, .menu.open .menu-title { background: var(--bg-menu-hover); }

.menu-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    min-width: 260px;
    padding: 4px;
    background: var(--bg-panel-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--panel-shadow);
    z-index: 60;
}

.menu-item {
    display: grid;
    white-space: nowrap;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: 28px;
    padding: 0 10px 0 6px;
    background: none;
    border: 0;
    border-radius: 4px;
    text-align: left;
}

.menu-item:not(:disabled):hover { background: var(--bg-menu-hover); }
.menu-icon { display: grid; place-items: center; color: var(--text-secondary); }
.menu-check { color: var(--accent); font-weight: 600; }
.menu-shortcut { color: var(--text-secondary); font-size: 11px; padding-left: 24px; }
.menu-separator { height: 1px; margin: 4px 6px; background: var(--border-color); }
.menu-backdrop { position: fixed; inset: 0; z-index: 30; }

/* Submenus (Effects > Blurs, …): open beside their item on hover, or on click/tap. */
.submenu-host { position: relative; }
.menu-arrow { display: grid; place-items: center end; color: var(--text-secondary); padding-left: 24px; }
.submenu {
    display: none;
    position: absolute;
    top: -5px;
    left: 100%;
    min-width: 220px;
    padding: 4px;
    background: var(--bg-panel-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--panel-shadow);
    z-index: 61;
}
.menu-dropdown .submenu-host:hover > .submenu, .submenu-host.open > .submenu { display: block; }
.submenu-host:hover > .menu-item, .submenu-host.open > .menu-item { background: var(--bg-menu-hover); }

/* The Help menu sits at the right end of the bar, as an icon. */
.menu.trailing .menu-dropdown { left: auto; right: 0; }
.menu-title.icon-btn { padding: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.menubar-spacer { flex: 1; }

.quickbar { display: flex; align-items: center; gap: 2px; }
.quickbar-sep, .toolbar-sep { width: 1px; height: 18px; margin: 0 6px; background: var(--border-color); }

.icon-btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 26px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 4px;
}

.icon-btn:not(:disabled):hover { background: var(--bg-hover); }
.icon-btn.active { color: var(--accent); background: var(--bg-active); }
.icon-btn.small { width: 22px; height: 20px; }

.text-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding: 0 8px;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
}

.text-btn:hover { background: var(--bg-hover); border-color: var(--border-color); }
.text-btn.small { height: 20px; padding: 0 6px; font-size: 11px; }

/* ------------------------------------------------------------------ tool options bar */

.tool-options {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 36px;
    padding: 0 10px;
    background: var(--bg-menu);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.toolbar-host { position: relative; }
.common-actions { display: flex; align-items: center; gap: 1px; margin-right: -8px; }
.opt-label { color: var(--text-secondary); margin-right: -8px; }
.tool-chooser {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 26px;
    padding: 0 5px 0 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}
.tool-chooser:hover, .tool-chooser.open { border-color: var(--accent); }
.tool-chooser-list { position: fixed; top: auto; overflow-y: auto; z-index: 60; }
.tool-chooser-list .menu-item.checked { background: var(--bg-active); color: var(--accent); }
.tool-options-current { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-left: -6px; }

.opt { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.opt > span:first-child { color: var(--text-secondary); }
.opt input[type="range"] { width: 120px; accent-color: var(--accent); }
.opt.check { gap: 4px; color: var(--text-primary); }
.opt.check input { accent-color: var(--accent); }
.opt-value { min-width: 34px; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.opt-hint { color: var(--text-secondary); }

select, input[type="number"], input[type="text"], .hex, .form-grid input {
    height: 24px;
    padding: 0 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

input.num { width: 56px; }

.seg { gap: 0; }
.seg > span:first-child { margin-right: 6px; }
.seg-btn {
    height: 24px;
    padding: 0 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    margin-left: -1px;
    color: var(--text-primary);
}
.seg-btn:nth-child(2) { border-radius: 4px 0 0 4px; margin-left: 0; }
.seg-btn:last-child { border-radius: 0 4px 4px 0; }
.seg-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); position: relative; }

/* ------------------------------------------------------------------ workspace & canvas */

.workspace {
    position: absolute;
    inset: 0;
    background: var(--bg-workspace);
    overflow: hidden;
    touch-action: none;
    outline: none;
    user-select: none;
}

.canvas-stack {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    box-shadow: var(--canvas-shadow);
    will-change: transform;
}

.canvas-stack canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.canvas-stack.pixelated canvas { image-rendering: pixelated; }

.layer-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.workspace.panning { cursor: grabbing !important; }

/* ------------------------------------------------------------------ floating panels */

.panel-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

.floating-panel {
    position: absolute;
    display: flex;
    flex-direction: column;
    max-height: calc(100% - 16px);
    background: var(--bg-panel);
    border-radius: 8px;
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: var(--panel-idle-opacity);
    transition: opacity 0.15s ease;
    pointer-events: auto;
    overflow: hidden;
}

/* Utility windows fade when the pointer is elsewhere so the image shows through. */
.floating-panel:hover, .floating-panel.dragging, .floating-panel:focus-within { opacity: 1; }
.floating-panel.dragging { transition: none; }

.panel-titlebar {
    display: flex;
    align-items: center;
    height: 26px;
    padding: 0 4px 0 10px;
    background: var(--bg-panel-title);
    border-bottom: 1px solid var(--border-color);
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.floating-panel.dragging .panel-titlebar { cursor: grabbing; }
.panel-title { flex: 1; font-weight: 600; font-size: 11px; letter-spacing: 0.02em; }

.panel-btn {
    display: grid;
    place-items: center;
    width: 22px;
    height: 20px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 4px;
    color: var(--text-secondary);
}

.panel-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.panel-body { display: flex; flex-direction: column; min-height: 0; overflow: auto; }

.panel-footer {
    display: flex;
    gap: 2px;
    padding: 3px 4px;
    border-top: 1px solid var(--border-color);
}

/* ------------------------------------------------------------------ tools window */

/* Two columns, like paint.net's Tools window. */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 32px);
    gap: 2px 6px;
    padding: 5px 6px;
    justify-content: center;
}

/* Rule before Leo Paint's retouching tools, which paint.net doesn't have. */
.tools-sep { grid-column: 1 / -1; height: 1px; margin: 2px; background: var(--border-color); }

/* Corner mark on buttons that hold more tools (right-click / long-press for the flyout). */
.tool-btn { position: relative; }
.more-mark { position: absolute; right: 2px; bottom: 2px; width: 0; height: 0;
    border-left: 4px solid transparent; border-bottom: 4px solid currentColor; opacity: 0.7; }

.tool-flyout-backdrop { position: fixed; inset: 0; z-index: 240; }
.tool-flyout { position: fixed; z-index: 241; min-width: 200px; padding: 4px; background: var(--bg-panel-solid);
    border: 1px solid var(--border-color); border-radius: 8px; box-shadow: var(--panel-shadow); outline: none; }
.tool-flyout .menu-item.checked { background: var(--bg-active); color: var(--accent); }

.tool-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 5px;
}

.tool-btn:hover { background: var(--bg-hover); }
.tool-btn.active { background: var(--bg-active); border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------------ history window */

.history-list { display: flex; flex-direction: column; padding: 3px; min-height: 96px; max-height: 168px; overflow-y: auto; }

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 24px;
    padding: 0 8px;
    background: none;
    border: 0;
    border-radius: 4px;
    text-align: left;
    flex: none;
}

.history-item:hover { background: var(--bg-hover); }
.history-item.current { background: var(--bg-selected); }
.history-item.redo { color: var(--text-disabled); }
.history-count { margin-left: auto; align-self: center; padding-right: 4px; color: var(--text-secondary); font-size: 11px; }

/* ------------------------------------------------------------------ layers window */

.layer-list { display: flex; flex-direction: column; gap: 2px; padding: 3px; min-height: 64px; max-height: 260px; overflow-y: auto; user-select: none; }

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px 3px 3px;
    border-radius: 4px;
    cursor: default;
    flex: none;
}

.layer-item:hover { background: var(--bg-hover); }
.layer-item.active { background: var(--bg-selected); }
.layer-item.selected { background: color-mix(in srgb, var(--bg-selected) 55%, transparent); }
.layer-multi { padding: 4px 8px; border-top: 1px solid var(--border-color); color: var(--text-secondary); font-size: 11px; }
.layer-item.hidden-layer .layer-thumb, .layer-item.hidden-layer .layer-name { opacity: 0.45; }

.layer-thumb {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    background-size: 8px 8px;
    background-position: 0 0, 4px 4px;
    border: 1px solid var(--border-strong);
}

.layer-thumb img { max-width: 100%; max-height: 100%; display: block; }
.layer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-visible { accent-color: var(--accent); width: 15px; height: 15px; }

.layer-props-section { margin-top: 16px; }
.export-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }

/* ------------------------------------------------------------------ colors window */

.colors-top { display: flex; align-items: center; gap: 12px; padding: 8px; }

.swatch-stack { position: relative; width: 58px; height: 58px; flex: none; }

.swatch {
    position: absolute;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    background: none;
    overflow: hidden;
}

.swatch > span { display: block; width: 100%; height: 100%; background-size: 8px 8px; background-position: 0 0, 4px 4px; }
.swatch > span > span { display: block; width: 100%; height: 100%; }
.swatch.primary { left: 0; top: 0; z-index: 2; }
.swatch.secondary { right: 0; bottom: 0; z-index: 1; }
.swatch.editing { outline: 2px solid var(--accent); outline-offset: 1px; }

.swatch-mini {
    position: absolute;
    display: grid;
    place-items: center;
    width: 16px;
    height: 16px;
    padding: 0;
    background: none;
    border: 0;
    color: var(--text-secondary);
}

.swatch-mini:hover { color: var(--text-primary); }
.swatch-mini.swap { right: 0; top: 0; }
.swatch-mini.reset { left: 0; bottom: 0; }

.colors-target { display: flex; flex-direction: column; gap: 2px; }
.colors-target .more { margin-left: -8px; margin-top: 2px; }

.color-editor { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 8px 8px; }

.wheel {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background:
        radial-gradient(circle closest-side, #fff, rgba(255, 255, 255, 0)),
        conic-gradient(from 0deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
    cursor: crosshair;
    touch-action: none;
    box-shadow: 0 0 0 1px var(--border-strong);
}

.wheel-dim { position: absolute; inset: 0; border-radius: 50%; background: #000; opacity: var(--v); pointer-events: none; }

.wheel-marker {
    position: absolute;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #000;
    pointer-events: none;
}

.color-fields { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.field { display: grid; grid-template-columns: 26px 1fr 52px; align-items: center; gap: 6px; color: var(--text-secondary); }
.field input[type="range"] { accent-color: var(--accent); min-width: 0; }
.field input.num { width: 52px; }
.field .hex { grid-column: span 2; font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; text-transform: uppercase; }
.field-sep { height: 1px; background: var(--border-color); margin: 3px 0; }

.palette { display: grid; grid-template-columns: repeat(16, 1fr); gap: 1px; padding: 6px 8px 8px; }

.palette-swatch {
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 2px;
}

.palette-swatch:hover { transform: scale(1.25); position: relative; z-index: 1; }

/* ------------------------------------------------------------------ status bar */

.statusbar {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 26px;
    padding: 0 8px;
    background: var(--bg-menu);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
}

.status-help { overflow: hidden; text-overflow: ellipsis; }
.status-spacer { flex: 1; }
.status-cell { display: flex; align-items: center; gap: 5px; }
.status-cell .mono { min-width: 64px; color: var(--text-primary); }
#status-coords.outside { color: var(--text-disabled); }
.zoom-cell .mono { min-width: 44px; text-align: center; }

/* ------------------------------------------------------------------ dialogs */

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--bg-modal-backdrop);
    z-index: 100;
}

/* Effect dialogs leave the canvas undimmed so the live preview is visible. */
.modal-backdrop.clear { background: transparent; }

.modal {
    max-width: calc(100vw - 32px);
    background: var(--bg-panel-solid);
    border-radius: 8px;
    box-shadow: var(--panel-shadow);
    overflow: hidden;
}

.modal-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 6px 0 12px;
    background: var(--bg-panel-title);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.modal.dragging .modal-titlebar { cursor: grabbing; }

.modal-titlebar span { flex: 1; }
.modal-body { padding: 14px 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border-color); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    min-width: 80px;
    height: 28px;
    padding: 0 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
}

.btn:hover { background: var(--bg-menu-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }

.form-grid { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 8px 10px; }
.section-title { margin: 0 0 8px; font-size: 12px; }

.effect-param { margin-bottom: 12px; }
.effect-param-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.effect-param-row { display: flex; align-items: center; gap: 8px; }
.effect-param-row input[type="range"] { flex: 1; accent-color: var(--accent); }

/* Export dialog. `.form-grid input` styles text fields, so undo it for the other input types. */
.export-grid input[type="checkbox"], .export-grid input[type="range"] { height: auto; padding: 0; border: 0; background: none; }
.export-grid input[type="color"] { width: 44px; padding: 1px 2px; cursor: pointer; }
.export-grid input.num { width: 72px; }
.export-name, .export-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.export-name input { flex: 1; min-width: 0; }
.export-estimate { margin: 14px 0 0; min-height: 1.5em; }
.seg-group { display: flex; }
.seg-group .seg-btn:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.text-btn.active { border-color: var(--accent); color: var(--accent); }

.text-input { width: 100%; min-height: 64px; padding: 6px 8px; resize: vertical; font: inherit; background: var(--bg-input);
    border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-primary); box-sizing: border-box; }
.text-options { margin-top: 10px; }
.font-select { flex: 1; min-width: 0; font-size: 13px; }
.style-btn { width: 28px; padding: 0; border-radius: 4px !important; margin-left: 2px !important; }
.text-swatch { width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border-strong); }

/* Layer masks & adjustment layers in the Layers window. The outlined thumbnail is what painting tools edit. */
.layer-thumb.editing { outline: 2px solid var(--accent); outline-offset: 1px; }
.mask-thumb { margin-left: 4px; background: #000; }
.mask-thumb.mask-disabled { opacity: 0.4; position: relative; }
.mask-thumb.mask-disabled::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent 47%, #e53935 47% 53%, transparent 53%); }
.adjustment-thumb { display: grid; place-items: center; color: var(--accent); background: var(--bg-input); }

/* Command palette (Ctrl/Cmd+K). */
.palette-backdrop { position: fixed; inset: 0; z-index: 110; background: var(--bg-modal-backdrop); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.palette-backdrop > .palette { display: block; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--bg-panel-solid); border-radius: 10px; box-shadow: var(--panel-shadow); overflow: hidden; }
.palette-input { width: 100%; box-sizing: border-box; height: 44px !important; padding: 0 14px !important; font-size: 15px; border: 0 !important; border-bottom: 1px solid var(--border-color) !important; border-radius: 0 !important; background: transparent !important; color: var(--text-primary); outline: none; }
.palette-results { max-height: min(420px, 60vh); overflow-y: auto; padding: 4px; }
.palette-item { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px; background: none; border: 0; border-radius: 6px; text-align: left; color: var(--text-primary); }
.palette-item.selected { background: var(--bg-menu-hover); }
.palette-item:disabled { color: var(--text-disabled); }
.palette-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-group { color: var(--text-secondary); font-size: 11px; }
.palette-empty { padding: 14px; }

/* Colors window: screen eyedropper / palette-from-image actions and the extracted palette row. */
.palette-actions { display: flex; gap: 4px; padding: 6px 8px 0; }
.image-palette { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; padding: 6px 8px 0; }
.image-palette .palette-swatch { width: 22px; height: 22px; border-radius: 4px; }
.palette-clear { width: 18px; height: 18px; display: grid; place-items: center; margin-left: 2px; background: none; border: 0; color: var(--text-secondary); border-radius: 4px; }
.palette-clear:hover { background: var(--bg-hover); }

/* Curves editor. */
.curves-channels { margin-bottom: 8px; }
.curves-graph { display: block; width: 100%; max-width: 300px; aspect-ratio: 1; margin: 0 auto; touch-action: none; user-select: none; }
.curves-bg { fill: var(--bg-input); stroke: var(--border-strong); stroke-width: 1; }
.curves-hist { fill: var(--text-secondary); opacity: 0.25; }
.curves-gridline { stroke: var(--border-color); stroke-width: 0.6; }
.curves-diagonal { stroke: var(--border-strong); stroke-width: 0.6; stroke-dasharray: 3 3; }
.curves-line { fill: none; stroke: var(--text-primary); stroke-width: 1.6; }
.curves-line.curves-1 { stroke: #e53935; } .curves-line.curves-2 { stroke: #43a047; } .curves-line.curves-3 { stroke: #1e88e5; }
.curves-point { fill: var(--bg-panel-solid); stroke: var(--accent); stroke-width: 2; cursor: grab; }
.curves-point.dragging, .curves-point:hover { fill: var(--accent); }
.curves-footer { text-align: center; min-height: 1.4em; margin-top: 4px; }
.curves-presets { justify-content: center; margin-top: 6px; }

/* Layer styles & clipping masks. */
.clip-arrow { color: var(--accent); margin-right: 3px; }
.fx-badge { flex: none; height: 16px; padding: 0 4px; margin-left: 4px; font-size: 10px; font-style: italic; font-weight: 600;
    background: none; border: 1px solid var(--border-strong); border-radius: 3px; color: var(--text-secondary); }
.fx-badge:hover { color: var(--accent); border-color: var(--accent); }
.style-section { border-bottom: 1px solid var(--border-color); padding: 8px 0; }
.style-section:first-child { padding-top: 0; }
.style-head { font-weight: 600; margin-bottom: 6px; }
.style-section .form-grid { margin-top: 6px; }

/* Layer groups: members are indented by depth; groups have a collapse toggle and a folder thumbnail. */
.layer-item { padding-left: calc(4px + var(--depth, 0) * 14px) !important; }
.layer-item.clipped { padding-left: calc(18px + var(--depth, 0) * 14px) !important; }
.group-toggle { flex: none; width: 16px; height: 20px; display: grid; place-items: center; padding: 0; background: none; border: 0; color: var(--text-secondary); }
.group-thumb { display: grid; place-items: center; color: var(--accent); background: var(--bg-input); }
.group-item .layer-name { font-weight: 600; }

/* Uninstall dialog. */
.uninstall-steps { margin: 6px 0 12px; padding-left: 20px; line-height: 1.5; }
.uninstall-steps li { margin-bottom: 4px; }
.uninstall-warning { padding: 6px 8px; border-radius: 4px; background: rgba(229, 57, 53, 0.12); color: var(--text-primary); }
.uninstall-note { padding: 6px 8px; border-radius: 4px; background: var(--bg-input); }
.uninstall-data { border-top: 1px solid var(--border-color); padding-top: 10px; }
.uninstall-data p { margin: 4px 0 8px; }
.btn.danger { background: #c62828; border-color: #c62828; color: #fff; font-weight: 600; }

/* AI Assistant panel. */
.assistant { display: flex; flex-direction: column; height: 380px; }
.assistant-bar { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--border-color); }
.assistant-spacer { flex: 1; }
.assistant-log { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.assistant-empty { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.assistant-empty p { margin: 0 0 4px; }
.assistant-example { text-align: left; padding: 5px 8px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); font-size: 12px; }
.assistant-example:hover { border-color: var(--accent); }
.chat-entry { padding: 6px 9px; border-radius: 8px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.chat-row { display: flex; align-items: flex-start; gap: 2px; }
.chat-row > .chat-entry { min-width: 0; }
.chat-row-user { align-self: flex-end; flex-direction: row-reverse; max-width: 92%; }
.chat-row-assistant { align-self: flex-start; max-width: 100%; }
.chat-row-error > .chat-entry { flex: 1; }
.chat-copy { flex: none; margin-top: 3px; color: var(--text-secondary); opacity: 0.45; }
.chat-row:hover .chat-copy, .chat-copy:focus-visible, .chat-copy.copied { opacity: 1; }
.chat-copy.copied { color: #43a047; }
.chat-user { background: var(--accent); color: var(--accent-text); }
.chat-assistant { background: var(--bg-input); }
.chat-error { background: rgba(229, 57, 53, 0.14); font-size: 12px; }
.chat-action { display: flex; gap: 6px; align-items: baseline; padding: 2px 4px; font-size: 12px; color: var(--text-secondary); }
.action-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--text-secondary); }
.action-running .action-dot { background: #a78bfa; animation: ghost-pulse 1s infinite; }
.action-done .action-dot { background: #43a047; }
.action-failed .action-dot { background: #e53935; }
.assistant-wait { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; background: rgba(167, 139, 250, 0.14);
    border: 1px solid rgba(167, 139, 250, 0.5); font-size: 12px; }
.wait-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.wait-seconds { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; color: #a78bfa; }
.wait-bar { height: 4px; border-radius: 2px; background: rgba(127, 127, 127, 0.25); overflow: hidden; }
.wait-bar > div { height: 100%; background: #a78bfa; transition: width 1s linear; }
.assistant-input { display: flex; gap: 6px; align-items: flex-end; padding: 6px 8px; border-top: 1px solid var(--border-color); }
.assistant-input textarea { flex: 1; resize: none; padding: 6px 8px; font: inherit; background: var(--bg-input); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: 6px; }
.key-input { flex: 1; font-family: ui-monospace, monospace; }
.ai-test { margin-top: 12px; }
.ai-ok { color: #43a047; } .ai-fail { color: #e53935; }
.ai-note { margin-top: 10px; }
.assistant-provider { flex: 1; min-width: 0; font-size: 12px; text-overflow: ellipsis; }

/* Local Model dialog (the assistant's on-device model). */
.llm-intro { margin-top: 0; line-height: 1.45; }
.llm-warning { padding: 10px 12px; border-radius: 6px; background: rgba(229, 57, 53, 0.12); line-height: 1.45; }
.llm-warning p { margin: 6px 0; }
.llm-models { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.llm-model { display: flex; align-items: flex-start; gap: 8px; padding: 7px 9px; border: 1px solid var(--border-color); border-radius: 6px; cursor: pointer; }
.llm-model.active { border-color: var(--accent); }
.llm-model input { margin-top: 2px; accent-color: var(--accent); }
.llm-model-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.llm-model-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.llm-facts { display: grid; grid-template-columns: 72px 1fr; gap: 6px 10px; margin: 10px 0 0; line-height: 1.45; }
.llm-facts dt { color: var(--text-secondary); }
.llm-facts dd { margin: 0; }
.llm-progress { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.llm-progress .wait-bar { height: 8px; border-radius: 4px; }
.llm-progress-row { display: flex; gap: 12px; align-items: baseline; font-variant-numeric: tabular-nums; }
.llm-percent { font-size: 18px; font-weight: 600; color: #a78bfa; }
.llm-error { margin: 10px 0 0; }

/* Clean up AI models dialog. */
.storage-head { margin: 14px 0 4px; font-size: 12px; }
.storage-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border-color); }
.storage-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.storage-total { margin: 12px 0 0; }
.storage-confirm { margin-right: auto; align-self: center; }
.storage-link { margin-top: 10px; }

/* Smart Stack panel and Local AI dialog. */
.smart-stack { display: flex; flex-direction: column; max-height: 420px; }
.smart-bar { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--border-color); }
.smart-summary { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smart-progress { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; font-size: 12px; border-bottom: 1px solid var(--border-color); }
.smart-error { padding: 6px 10px; background: rgba(229, 57, 53, 0.14); border-radius: 6px; margin: 6px 8px; }
.smart-tree { flex: 1; overflow-y: auto; padding: 4px; min-height: 60px; }
.smart-empty { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 6px; }
.smart-empty p { margin: 0; }
.smart-row { display: flex; align-items: center; gap: 5px; height: 26px; padding: 0 4px 0 calc(4px + var(--depth) * 14px);
    border-radius: 4px; cursor: default; }
.smart-row:hover { background: var(--bg-hover); }
.smart-row.active { background: var(--bg-selected); }
.smart-chevron { display: grid; place-items: center; width: 14px; height: 14px; padding: 0; background: none; border: 0; color: inherit; flex: none; }
.smart-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.smart-badge { font-size: 10px; padding: 0 5px; border-radius: 8px; background: rgba(167, 139, 250, 0.25); }
.smart-actions { display: none; gap: 1px; }
.smart-row:hover .smart-actions, .smart-row.active .smart-actions, .smart-row:focus-within .smart-actions { display: flex; }
.smart-hint { padding: 4px 8px 6px; border-top: 1px solid var(--border-color); }
.local-ai-intro { margin-top: 0; line-height: 1.45; }
.ai-pack { padding: 10px 0; border-top: 1px solid var(--border-color); }
.ai-pack-head { display: flex; align-items: center; gap: 8px; }
.ai-pack-spacer { flex: 1; }
.ai-pack-desc { margin: 4px 0 6px; }
.ai-licenses { margin: 4px 0 0; }
.ai-options { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border-color); }
.btn.small { flex: none; min-width: 0; height: 24px; padding: 0 10px; gap: 5px; font-size: 12px; }
.btn.small .icon { width: 14px; height: 14px; }

/* Ghost cursor (wwwroot/js/leo-ghost.js): the assistant's visible pointer. Never intercepts input. */
#ghost-layer { position: fixed; inset: 0; z-index: 260; pointer-events: none; opacity: 0; transition: opacity 0.25s; }
#ghost-layer.visible { opacity: 1; }
.ghost-trail { position: absolute; inset: 0; }
.ghost-trail polyline { fill: none; stroke: #a78bfa; stroke-width: 2; stroke-dasharray: 6 4; }
.ghost-cursor { position: absolute; left: 0; top: 0; display: flex; align-items: flex-start; gap: 4px; will-change: transform; }
.ghost-cursor svg path { fill: #a78bfa; stroke: #fff; stroke-width: 1.5; stroke-linejoin: round; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.ghost-cursor.flip-x .ghost-caption { position: absolute; right: 26px; top: 0; }
.ghost-cursor.flip-y .ghost-caption { position: absolute; top: -40px; }
.ghost-caption { margin-top: 16px; padding: 3px 8px; border-radius: 10px; background: #7c3aed; color: #fff; font-size: 11px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.ghost-ripple { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; border: 2px solid #a78bfa; animation: ghost-ripple 0.6s ease-out forwards; }
.ghost-target { outline: 2px solid #a78bfa !important; outline-offset: 2px; border-radius: 4px; transition: outline-color 0.2s; }
@keyframes ghost-ripple { to { transform: scale(4); opacity: 0; } }
@keyframes ghost-pulse { 50% { opacity: 0.35; } }

.anchor-grid { display: grid; grid-template-columns: repeat(3, 24px); gap: 3px; }
.anchor-cell { width: 24px; height: 24px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 3px; }
.anchor-cell:hover { border-color: var(--accent); }
.anchor-cell.active { background: var(--accent); border-color: var(--accent); }

.about-logo { display: block; width: 192px; height: 192px; margin: 4px auto 14px; }

.caf-check { display: flex; align-items: center; gap: 6px; margin: 12px 0 4px; }

.progress { height: 8px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.1s linear; }

.settings-section { margin-top: 16px; }

.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }

.theme-option {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: left;
}

.theme-option:hover { background: var(--bg-hover); }
.theme-option.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-label { display: flex; align-items: center; gap: 5px; font-weight: 600; }

/* Miniature editor: menu strip, workspace, panel. */
.theme-preview { position: relative; display: block; height: 52px; border-radius: 4px; overflow: hidden; border: 1px solid var(--border-strong); }
.theme-preview span { position: absolute; display: block; }
.theme-preview span:nth-child(1) { inset: 0 0 auto 0; height: 9px; }
.theme-preview span:nth-child(2) { inset: 9px 0 0 0; }
.theme-preview span:nth-child(3) { right: 5px; top: 15px; width: 22px; height: 30px; border-radius: 2px; }
.theme-preview.dark span:nth-child(1) { background: #2b2b2b; }
.theme-preview.dark span:nth-child(2) { background: #161616; }
.theme-preview.dark span:nth-child(3) { background: #333; }
.theme-preview.light span:nth-child(1) { background: #f9f9f9; }
.theme-preview.light span:nth-child(2) { background: #d9dde3; }
.theme-preview.light span:nth-child(3) { background: #fafafa; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    padding: 8px 14px;
    background: var(--bg-panel-solid);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    box-shadow: var(--panel-shadow);
    z-index: 120;
    cursor: pointer;
}

/* Shown while a file is dragged over the page; never intercepts the drop itself. */
body.file-drag::after {
    content: "Drop image to open";
    position: fixed;
    inset: 12px;
    display: grid;
    place-items: center;
    border: 3px dashed var(--accent);
    border-radius: 12px;
    background: var(--bg-modal-backdrop);
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    z-index: 200;
    pointer-events: none;
}

/* Shown by index.html when a newer published version has been downloaded. */
#update-banner {
    position: fixed; left: 50%; top: 8px; transform: translateX(-50%); z-index: 300;
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    background: var(--bg-panel-solid); color: var(--text-primary);
    border: 1px solid var(--accent); border-radius: 6px; box-shadow: var(--panel-shadow);
}
#update-banner[hidden] { display: none; }
#update-banner button { height: 26px; padding: 0 12px; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 4px; font-weight: 600; }

.not-found { padding: 40px; }

/* ------------------------------------------------------------------ boot screen & Blazor error UI */

.loading-progress {
    position: absolute;
    display: block;
    width: 6rem;
    height: 6rem;
    inset: 30vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    inset: calc(30vh + 2.4rem) 0 auto 0.2rem;
    color: var(--text-secondary);
}

.loading-progress-text::after { content: var(--blazor-load-percentage-text, "Loading"); }

#blazor-error-ui {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: none;
    padding: 0.6rem 1.25rem 0.7rem;
    background: #fff4ce;
    color: #3b2f00;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary { padding: 1rem; background: #b32121; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ------------------------------------------------------------------ histograms (Levels dialog) */

.histogram-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.histogram { margin: 0; min-width: 0; }
.histogram figcaption { margin-bottom: 3px; color: var(--text-secondary); font-size: 11px; }

.histogram-plot {
    position: relative;
    height: 84px;
    background: var(--histogram-bg);
    border: 1px solid var(--border-color);
    border-bottom: 0;
    overflow: hidden;
}

.histogram-plot svg { display: block; width: 100%; height: 100%; }
.histogram-plot path { mix-blend-mode: var(--histogram-blend); }
.histogram-plot .ch-r { fill: rgba(255, 64, 64, 0.65); }
.histogram-plot .ch-g { fill: rgba(48, 200, 96, 0.65); }
.histogram-plot .ch-b { fill: rgba(64, 128, 255, 0.65); }

.histogram-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed var(--text-secondary);
    pointer-events: none;
}

/* Black→white ramp under each plot, with a triangle handle at every marker. */
.histogram-ramp {
    position: relative;
    height: 8px;
    margin-bottom: 8px;
    background: linear-gradient(to right, #000, #fff);
    border: 1px solid var(--border-color);
}

.histogram-handle {
    position: absolute;
    top: 7px;
    width: 0;
    height: 0;
    margin-left: -5px;
    border: 5px solid transparent;
    border-bottom: 7px solid var(--text-primary);
    border-top: 0;
}

/* Help › Watch Demo: the control bar, its Info panel, and the shield that keeps clicks off the editor while it plays. */
.demo-shield { position: fixed; inset: 0; z-index: 250; cursor: pointer; }
.demo-bar {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    z-index: 270;
    display: flex;
    align-items: center;
    gap: 6px;
    width: min(560px, calc(100vw - 16px));
    padding: 6px 8px;
    background: var(--bg-panel-solid);
    border: 1px solid #a78bfa;
    border-radius: 10px;
    box-shadow: var(--panel-shadow);
}
.demo-bar .icon-btn { width: 34px; height: 32px; flex: none; }
.demo-play { background: #7c3aed; color: #fff; border-radius: 6px; }
.demo-play:not(:disabled):hover { background: #6d28d9; }
.demo-status { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.demo-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-status .wait-bar > div { transition: width 0.3s ease; }
.demo-count { flex: none; font-size: 11px; }
.demo-speed { display: flex; align-items: center; flex: none; border: 1px solid var(--border-color); border-radius: 6px; }
.demo-speed .icon-btn { width: 26px; height: 28px; font-size: 16px; }
.demo-speed span { min-width: 26px; text-align: center; font-size: 12px; }
.demo-key { display: inline-block; min-width: 16px; font-weight: 600; text-align: center; }
.demo-info {
    position: fixed;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    z-index: 270;
    width: min(520px, calc(100vw - 16px));
    max-height: 50vh;
    overflow-y: auto;
    padding: 10px 14px 12px;
    background: var(--bg-panel-solid);
    border: 1px solid #a78bfa;
    border-radius: 10px;
    box-shadow: var(--panel-shadow);
    line-height: 1.5;
}
.demo-info-head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #a78bfa; }
.demo-info-head span { flex: 1; }
.demo-info p { margin: 8px 0 0; color: var(--text-primary); }
.demo-intro { margin-top: 0; line-height: 1.5; }
.demo-keys { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.demo-keys li { display: flex; align-items: center; gap: 8px; }
.compact .demo-bar { bottom: 64px; }
.compact .demo-info { bottom: 120px; }

/* ------------------------------------------------------------------ compact (phone) layout */

/* `html.compact` is set by leo-ui.js watchCompact (and before first paint by index.html) for phone-sized windows.
   Panels become a bottom sheet opened from the tab bar, the menus move into a drawer, and targets grow for touch. */

.compact .panel-layer, .compact .statusbar { display: none; }

.compact .menubar { height: 44px; padding: 0 4px; }
.compact .icon-btn { width: 38px; height: 36px; }
.compact .quickbar-sep { margin: 0 3px; }
.compact .tool-options { height: 44px; gap: 12px; }
.compact .common-actions { display: none; } /* in the drawer, and Undo/Redo are on the menu bar */
.compact .opt input[type="range"] { width: 96px; }
.compact select, .compact input[type="number"], .compact input[type="text"] { height: 30px; font-size: 16px; } /* 16px stops iOS zooming on focus */
.compact .seg-btn { height: 30px; padding: 0 10px; }

.compact .menu-item { height: 40px; font-size: 13px; }
.compact .menu-shortcut { display: none; }

.drawer-backdrop { position: fixed; inset: 0; background: var(--bg-modal-backdrop); z-index: 90; }
.menu-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    padding: 8px 6px;
    background: var(--bg-panel-solid);
    box-shadow: var(--panel-shadow);
    overflow-y: auto;
    z-index: 91;
}
.drawer-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 44px;
    padding: 0 10px;
    background: none;
    border: 0;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
}
.drawer-heading[aria-expanded="true"] { background: var(--bg-menu-hover); }
.drawer-items { padding: 2px 0 6px 6px; }
.menu-drawer .submenu { position: static; min-width: 0; padding: 0 0 0 14px; border: 0; box-shadow: none; background: none; }
.menu-drawer .menu-arrow svg { transition: transform 0.15s; }
.menu-drawer .submenu-host.open .menu-arrow svg { transform: rotate(90deg); }

/* Bottom sheet: the one open panel, over the canvas so opening it doesn't re-fit the image. */
.sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    max-height: 62%;
    background: var(--bg-panel-solid);
    border-top: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    box-shadow: var(--panel-shadow);
}
.sheet-titlebar { display: flex; flex: none; align-items: center; height: 40px; padding: 0 4px 0 14px; border-bottom: 1px solid var(--border-color); }
.sheet-titlebar .panel-btn { width: 36px; height: 32px; }
.sheet-body { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }

.sheet .tools-grid { grid-template-columns: repeat(auto-fill, 44px); justify-content: center; gap: 4px; padding: 8px; }
.sheet .tools-sep { display: none; }
.sheet .tool-btn { width: 44px; height: 44px; }
.sheet .history-list, .sheet .layer-list { max-height: none; }
.sheet .history-item { height: 36px; }
.sheet .layer-visible { width: 20px; height: 20px; }
.sheet .panel-footer .icon-btn { width: 40px; height: 36px; }
.sheet.assistant-panel, .sheet.smart-stack-panel { height: 62%; }
.sheet .assistant, .sheet .smart-stack { flex: 1; height: auto; max-height: none; min-height: 0; }
.sheet .assistant-input textarea { font-size: 16px; }

.tabbar {
    display: flex;
    flex: none;
    height: 56px;
    background: var(--bg-menu);
    border-top: 1px solid var(--border-color);
    user-select: none;
}
.tab {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 0 2px;
    background: none;
    border: 0;
    color: var(--text-secondary);
    font-size: 10px;
}
.tab.active { color: var(--accent); }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A group's other tools: an action list above the tab bar rather than beside the button. */
.compact .tool-flyout { left: 8px !important; right: 8px; top: auto !important; bottom: 64px; }

.compact .modal { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); display: flex; flex-direction: column; }
.compact .modal-body { min-height: 0; overflow-y: auto; }
.compact .modal-footer { flex-wrap: wrap; }
.compact .btn { height: 36px; }
/* Effect dialogs sit at the bottom so the live preview stays visible above them. */
.compact .modal-backdrop.clear { place-items: end center; padding-bottom: 8px; }

.compact .toast { bottom: 72px; width: max-content; max-width: calc(100vw - 32px); }
