/* ===========================
   INPAINTING EDITOR STYLES
   =========================== */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    --edit-surface-bg: var(--app-panel, linear-gradient(160deg, rgba(255, 255, 255, 0.88), rgba(239, 244, 247, 0.78)));
    --edit-surface-strong: var(--app-panel-accent, linear-gradient(160deg, rgba(255, 255, 255, 0.94), rgba(230, 243, 247, 0.82)));
    --edit-surface-border: var(--app-border, rgba(0, 0, 0, 0.08));
    --edit-surface-border-strong: var(--app-border-strong, rgba(0, 0, 0, 0.15));
    --edit-surface-shadow: var(--app-shadow-glass, 0 1px 3px rgba(0, 0, 0, 0.08));
    --edit-surface-shadow-float: var(--app-shadow-float, 0 8px 24px rgba(0, 0, 0, 0.12));
    --edit-btn-bg: var(--app-btn-secondary-bg, rgba(0, 0, 0, 0.05));
    --edit-btn-border: var(--app-btn-secondary-border, rgba(0, 0, 0, 0.08));
    --edit-btn-hover: var(--app-hover-bg, rgba(0, 0, 0, 0.04));
    --edit-btn-hover-strong: var(--app-hover-bg-strong, rgba(0, 0, 0, 0.08));
    --edit-btn-text: var(--app-text, #1d1d1f);
    --edit-btn-muted: var(--app-muted, #86868b);
    --edit-btn-selected-bg: var(--app-selected-bg, linear-gradient(165deg, rgba(244, 246, 248, 0.98), rgba(232, 236, 240, 0.98)));
    --edit-btn-selected-border: var(--app-selected-border, rgba(34, 211, 238, 0.92));
    --edit-btn-selected-text: var(--app-selected-text, #1d1d1f);
    --edit-primary-bg: var(--app-cta, rgba(238, 242, 245, 0.98));
    --edit-primary-hover: var(--app-cta-hover, rgba(230, 235, 239, 1));
    --edit-primary-border: var(--app-cta-border, rgba(34, 211, 238, 0.3));
    --edit-primary-text: var(--app-cta-text, #1d1d1f);
    --edit-focus: var(--app-focus, 0 0 0 4px rgba(34, 211, 238, 0.22));
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
}

.lightbox-overlay .lightbox-workspace {
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    gap: 16px;
    width: min(1680px, calc(100vw - 12px));
    min-height: 100vh;
    max-height: 100vh;
    margin: 0 auto;
    padding: 0 6px 12px;
    box-sizing: border-box;
}

.lightbox-overlay .lightbox-stage {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    min-height: 100vh;
    padding: 56px 0 12px;
    box-sizing: border-box;
}

.lightbox-overlay .edit-toolbar-panel {
    flex: 0 0 296px;
    width: 296px;
    display: flex;
    align-self: stretch;
    align-items: flex-start;
    justify-content: flex-end;
    margin-left: auto;
    max-height: 100vh;
    padding-top: 0;
    padding-bottom: 16px;
    padding-right: 2px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}
.lightbox-overlay .edit-toolbar-panel::-webkit-scrollbar {
    width: 8px;
}
.lightbox-overlay .edit-toolbar-panel::-webkit-scrollbar-track {
    background: transparent;
}
.lightbox-overlay .edit-toolbar-panel::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 4px;
}
.lightbox-overlay .edit-toolbar-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.65);
}

/* === HEADER BAR === */
.lightbox-overlay .lightbox-header {
    position: fixed;
    top: 12px;
    left: 20px;
    right: 32px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    z-index: 1010;
}

.lightbox-overlay .icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #c4c7c5;
    border-radius: 9999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    padding: 8px;
    transition: background 0.15s;
}

.lightbox-overlay .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lightbox-overlay .icon-btn:disabled {
    opacity: 0.38;
    cursor: default;
}

.lightbox-overlay .lightbox-header .icon-btn,
.lightbox-overlay .lightbox-header .icon-btn .material-symbols-outlined {
    color: #ffffff !important;
}

/* === IMAGE VIEWPORT === */
.lightbox-overlay .image-viewport {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: calc(100vh - 84px);
    max-width: min(100%, 1380px);
    overflow: visible;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.lightbox-overlay .edit-canvas-board {
    position: relative;
    width: 480px;
    height: 480px;
    max-width: 100%;
    max-height: calc(100vh - 84px);
    overflow: hidden;
    border-radius: 0;
    border: 1px solid rgba(18, 22, 28, 0.14);
    background:
        linear-gradient(135deg, #f4f5f7, #edf1f4),
        linear-gradient(90deg, rgba(140, 152, 168, 0.18) 1px, transparent 1px),
        linear-gradient(rgba(140, 152, 168, 0.18) 1px, transparent 1px),
        #f0f2f5;
    background-size: auto, 24px 24px, 24px 24px, auto;
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.34);
    isolation: isolate;
}

.lightbox-overlay .edit-canvas-board::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.lightbox-overlay .edit-base-image {
    position: absolute;
    top: 50%;
    left: 50%;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    object-fit: fill;
    border-radius: 0;
    display: block;
    user-select: none;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.lightbox-overlay .inpaint-result .image-viewport img {
    max-height: calc(100vh - 136px);
    max-width: min(74vw, 920px);
    object-fit: contain;
    display: block;
    border-radius: 20px;
}

.lightbox-overlay #mask-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: none;
    /* Must sit above .edit-base-image (z-index: 1) so the red brush strokes
       are visible. Without this the base image covers the mask and the user
       sees no paint. */
    z-index: 2;
}

.lightbox-overlay .edit-overlay-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1004;
}

.lightbox-overlay .edit-overlay-item {
    position: absolute;
    pointer-events: auto;
    user-select: none;
    touch-action: none;
    cursor: grab;
    transform: translate(-50%, -50%);
}

.lightbox-overlay .edit-overlay-item.is-selected {
    outline: 2px dashed rgba(168, 199, 250, 0.95);
    outline-offset: 6px;
}

.lightbox-overlay .edit-overlay-item.is-resizing {
    cursor: nwse-resize;
}

.lightbox-overlay .edit-overlay-item.is-dragging {
    cursor: grabbing;
}

.lightbox-overlay .edit-overlay-item img {
    display: block;
    max-width: none;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.lightbox-overlay .edit-overlay-item.edit-overlay-text {
    min-width: 48px;
    padding: 0.1em 0.18em;
    color: #ffffff;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.03em;
    text-align: center;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
    white-space: pre-wrap;
    background: rgba(17, 24, 39, 0.12);
    border-radius: 6px;
}

.lightbox-overlay .edit-overlay-item.edit-overlay-text:empty::before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.45em;
    font-weight: 500;
    letter-spacing: 0;
}

.lightbox-overlay .edit-overlay-item.edit-overlay-text.is-editing {
    background: rgba(17, 24, 39, 0.35);
    outline: 2px solid rgba(168, 199, 250, 0.95) !important;
    outline-offset: 2px;
}

.lightbox-overlay .edit-overlay-resize-handle {
    position: absolute;
    right: -12px;
    bottom: -12px;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 9999px;
    background: rgba(29, 29, 31, 0.88);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    cursor: nwse-resize;
    z-index: 2;
}

.lightbox-overlay .edit-overlay-resize-handle .material-symbols-outlined {
    font-size: 16px !important;
    color: #ffffff !important;
}

.lightbox-overlay .edit-overlay-intent-toggle {
    position: absolute;
    top: -14px;
    right: -8px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
    border: 1px solid rgba(255, 255, 255, 0.82);
    background: rgba(29, 29, 31, 0.9);
    color: #ffffff;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
    z-index: 3;
}
.lightbox-overlay .edit-overlay-intent-toggle[data-intent="literal"] {
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    border-color: rgba(0, 0, 0, 0.12);
}

.lightbox-overlay #fillCanvasBtn.is-ready {
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.95) 0%, rgba(34, 211, 238, 0.95) 100%);
    color: #ffffff;
    border-color: var(--edit-btn-selected-border);
    box-shadow: 0 10px 28px rgba(34, 211, 238, 0.28);
    animation: fill-canvas-pulse 1.8s ease-in-out infinite;
}
.lightbox-overlay #fillCanvasBtn.is-ready .material-symbols-outlined {
    color: #ffffff !important;
}
@keyframes fill-canvas-pulse {
    0%, 100% { box-shadow: 0 10px 28px rgba(34, 211, 238, 0.28); }
    50% { box-shadow: 0 10px 34px rgba(34, 211, 238, 0.55); }
}

.lightbox-overlay .outpaint-gate-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.95), rgba(34, 211, 238, 0.9));
    border: 1px solid var(--edit-btn-selected-border);
    color: #ffffff;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
}
.lightbox-overlay .outpaint-gate-banner[hidden] { display: none; }
.lightbox-overlay .outpaint-gate-banner .material-symbols-outlined {
    color: #ffffff !important;
    font-size: 22px !important;
    flex-shrink: 0;
}
.lightbox-overlay .outpaint-gate-banner-text { flex: 1; color: #ffffff; }
.lightbox-overlay .outpaint-gate-banner-text strong {
    font-weight: 700;
    color: #ffffff;
}
.lightbox-overlay .outpaint-gate-banner-text em {
    font-style: normal;
    font-weight: 700;
    color: #ecfeff;
    text-decoration: underline;
    text-decoration-color: rgba(236, 254, 255, 0.6);
    text-underline-offset: 2px;
}

/* === Expand canvas toggle (in Aspect Ratio accordion header) === */
.lightbox-overlay .edit-expand-canvas-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
    cursor: pointer;
    user-select: none;
    justify-self: end;
}
.lightbox-overlay .edit-expand-canvas-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.lightbox-overlay .edit-expand-canvas-switch {
    position: relative;
    width: 28px;
    height: 16px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.45);
    transition: background 160ms ease;
    flex-shrink: 0;
}
.lightbox-overlay .edit-expand-canvas-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
    transition: transform 160ms ease;
}
.lightbox-overlay .edit-expand-canvas-toggle input:checked + .edit-expand-canvas-switch {
    background: var(--edit-btn-selected-border);
}
.lightbox-overlay .edit-expand-canvas-toggle input:checked + .edit-expand-canvas-switch::after {
    transform: translateX(12px);
}
.lightbox-overlay .edit-expand-canvas-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--edit-btn-text, inherit);
    opacity: 0.78;
}
.lightbox-overlay #fillCanvasBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Brush cursor preview */
.lightbox-overlay .brush-cursor {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    pointer-events: none;
    display: none;
    z-index: 1005;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
}

/* === EDIT TOOLBAR === */
.lightbox-overlay .edit-toolbar {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    z-index: 1010;
    width: 100%;
    max-width: 296px;
    pointer-events: none;
}

.lightbox-overlay .edit-toolbar.is-floating {
    position: fixed;
    width: min(296px, calc(100vw - 24px));
}

.lightbox-overlay .edit-toolbar > * {
    pointer-events: auto;
}

.lightbox-overlay .edit-settings-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--edit-surface-border);
    background: var(--edit-surface-bg);
    box-shadow: var(--edit-surface-shadow-float);
    backdrop-filter: blur(12px);
}

.lightbox-overlay .edit-settings-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.lightbox-overlay .edit-settings-heading {
    color: var(--edit-btn-text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.lightbox-overlay .edit-settings-meta {
    color: var(--edit-btn-muted);
    font-size: 11px;
    line-height: 1.25;
    text-align: right;
}

.lightbox-overlay .edit-settings-options {
    display: grid;
    gap: 6px;
}

.lightbox-overlay .edit-settings-options--triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lightbox-overlay .edit-settings-options--quad {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.lightbox-overlay .edit-settings-options--aspect {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lightbox-overlay .edit-settings-card--accordion {
    padding: 8px 10px 10px;
}

.lightbox-overlay .edit-settings-toggle {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    padding: 4px 2px 8px;
    border: 0;
    background: transparent;
    color: var(--edit-btn-text);
    text-align: left;
}

.lightbox-overlay .edit-settings-toggle > span:first-child {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.lightbox-overlay .edit-settings-toggle .accordion-chevron {
    font-size: 17px !important;
    color: var(--edit-btn-muted) !important;
    transition: transform 180ms ease, color 180ms ease;
}

.lightbox-overlay .edit-settings-toggle.open .accordion-chevron {
    transform: rotate(180deg);
    color: var(--edit-btn-selected-border) !important;
}

.lightbox-overlay .edit-settings-card--accordion #editAspectRatioOptions.hidden {
    display: none;
}

.lightbox-overlay .edit-setting-btn {
    min-height: 34px;
    padding: 7px 8px;
    border: 1px solid var(--edit-btn-border);
    border-radius: 8px;
    background: var(--edit-btn-bg);
    color: var(--edit-btn-text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.02em;
    box-shadow: var(--edit-surface-shadow);
    transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.lightbox-overlay .edit-setting-btn:hover:not(:disabled) {
    background: var(--edit-btn-hover);
    border-color: var(--edit-surface-border-strong);
}

.lightbox-overlay .edit-setting-btn.active {
    background: var(--edit-btn-selected-bg);
    border-color: var(--edit-btn-selected-border);
    color: var(--edit-btn-selected-text);
}

.lightbox-overlay .edit-setting-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.lightbox-overlay .resolution-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
}

.lightbox-overlay .edit-setting-btn-label {
    display: block;
    line-height: 1.1;
}

.lightbox-overlay .edit-setting-btn-meta {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: inherit;
    opacity: 0.72;
    line-height: 1.1;
}

.lightbox-overlay .aspect-ratio-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
}

.lightbox-overlay .edit-aspect-ratio-shape {
    display: inline-flex;
    flex: 0 0 auto;
    border: 1.5px solid currentColor;
    border-radius: 4px;
    opacity: 0.78;
}

.lightbox-overlay .edit-toolbar-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    align-self: stretch;
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--edit-btn-selected-border);
    background: var(--edit-btn-selected-bg);
    color: var(--edit-btn-text);
    box-shadow: var(--edit-surface-shadow-float);
    backdrop-filter: blur(14px);
    cursor: grab;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: -0.02em;
    transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.lightbox-overlay .edit-toolbar-handle:hover {
    background: var(--edit-surface-strong);
    border-color: var(--edit-btn-selected-border);
    box-shadow: var(--edit-surface-shadow-float);
}

.lightbox-overlay .edit-toolbar-handle:active,
.lightbox-overlay .edit-toolbar.is-dragging .edit-toolbar-handle {
    cursor: grabbing;
    transform: none;
}

.lightbox-overlay .edit-toolbar-handle .material-symbols-outlined {
    font-size: 18px;
    color: var(--edit-btn-selected-border) !important;
}

.lightbox-overlay .edit-toolbar-handle-text {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Brush Size Bar */
.lightbox-overlay .brush-size-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    background: var(--edit-surface-bg);
    border: 1px solid var(--edit-surface-border);
    box-shadow: var(--edit-surface-shadow-float);
    border-radius: 12px;
    padding: 6px 10px;
    backdrop-filter: blur(12px);
}

.lightbox-overlay .edit-toolbar-icon-sm {
    font-size: 15px !important;
    color: var(--edit-btn-muted) !important;
}

.lightbox-overlay .edit-toolbar-icon-lg {
    font-size: 20px !important;
    color: var(--edit-btn-muted) !important;
}

.lightbox-overlay .brush-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--edit-btn-hover-strong);
    outline: none;
}

.lightbox-overlay .brush-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--edit-btn-selected-border);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.95);
}

.lightbox-overlay .brush-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--edit-btn-selected-border);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.95);
}

/* Tool Container */
.lightbox-overlay .tool-container {
    display: flex;
    width: fit-content;
    background: var(--edit-surface-bg);
    border: 1px solid var(--edit-surface-border);
    box-shadow: var(--edit-surface-shadow-float);
    border-radius: 12px;
    padding: 4px;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(12px);
}

.lightbox-overlay .tool-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--edit-btn-border);
    background: var(--edit-btn-bg);
    color: var(--edit-btn-text);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--edit-surface-shadow);
    transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.lightbox-overlay .tool-btn.active {
    background: var(--edit-btn-selected-bg);
    border-color: var(--edit-btn-selected-border);
    color: var(--edit-btn-selected-text);
    box-shadow: var(--edit-surface-shadow);
}

.lightbox-overlay .tool-btn.is-attached {
    background: rgba(8, 145, 178, 0.18);
    border-color: var(--edit-btn-selected-border);
    color: var(--edit-btn-selected-text);
}

.lightbox-overlay .tool-btn:hover:not(.active) {
    background: var(--edit-btn-hover);
    border-color: var(--edit-surface-border-strong);
}

.lightbox-overlay .zoom-control-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid var(--edit-surface-border);
    background: var(--edit-surface-bg);
    box-shadow: var(--edit-surface-shadow-float);
    backdrop-filter: blur(12px);
}

.lightbox-overlay .zoom-control-btn {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--edit-btn-border);
    background: var(--edit-btn-bg);
    color: var(--edit-btn-text);
    box-shadow: var(--edit-surface-shadow);
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.lightbox-overlay .zoom-control-btn:hover {
    background: var(--edit-btn-hover);
    border-color: var(--edit-surface-border-strong);
}

.lightbox-overlay .zoom-control-btn .material-symbols-outlined {
    font-size: 18px !important;
}

.lightbox-overlay .zoom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--edit-btn-hover-strong);
    outline: none;
}

.lightbox-overlay .zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--edit-btn-selected-border);
    border: 2px solid rgba(255, 255, 255, 0.95);
    cursor: pointer;
}

.lightbox-overlay .zoom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--edit-btn-selected-border);
    border: 2px solid rgba(255, 255, 255, 0.95);
    cursor: pointer;
}

.lightbox-overlay .zoom-value {
    min-width: 3.25rem;
    text-align: right;
    color: var(--edit-btn-text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.lightbox-overlay .insert-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px;
    background: var(--edit-surface-bg);
    border: 1px solid var(--edit-surface-border);
    box-shadow: var(--edit-surface-shadow-float);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    justify-content: flex-start;
}

.lightbox-overlay .insert-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: 34px;
    padding: 8px 12px;
    border: 1px solid var(--edit-btn-border);
    border-radius: 8px;
    background: var(--edit-btn-bg);
    color: var(--edit-btn-text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--edit-surface-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: -0.02em;
    transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.lightbox-overlay .insert-btn .material-symbols-outlined,
.lightbox-overlay .tool-btn .material-symbols-outlined,
.lightbox-overlay .generate-btn .material-symbols-outlined {
    font-size: 18px !important;
}

.lightbox-overlay .insert-btn:hover:not(:disabled) {
    background: var(--edit-btn-hover);
    border-color: var(--edit-surface-border-strong);
    box-shadow: var(--edit-surface-shadow);
}

.lightbox-overlay .insert-btn:disabled {
    opacity: 0.42;
    cursor: default;
}

.lightbox-overlay .edit-toolbar-note {
    margin: 0;
    padding: 0 4px;
    color: var(--edit-btn-muted);
    font-size: 11px;
    line-height: 1.45;
    text-align: left;
}

/* === PROMPT BAR === */
.lightbox-overlay .prompt-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 296px;
    gap: 8px;
}

.lightbox-overlay .prompt-bar {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--edit-surface-strong);
    border-radius: 12px;
    padding: 8px;
    align-items: stretch;
    gap: 8px;
    backdrop-filter: blur(12px);
    border: 1px solid var(--edit-surface-border);
    box-shadow: var(--edit-surface-shadow-float);
}

.lightbox-overlay .prompt-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--edit-btn-text);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.45;
    min-width: 0;
    min-height: 4.35em;
    padding: 6px 8px;
    resize: none;
}

.lightbox-overlay .prompt-input::placeholder {
    color: var(--edit-btn-muted);
}

.lightbox-overlay .prompt-input.shake {
    animation: inpaint-shake 0.4s ease;
}

@keyframes inpaint-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.lightbox-overlay .generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    background: var(--edit-primary-bg);
    color: var(--edit-primary-text);
    border: 1px solid var(--edit-primary-border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--edit-surface-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: -0.02em;
    transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, opacity 180ms ease;
    align-self: stretch;
}

.lightbox-overlay .generate-btn:hover {
    background: var(--edit-primary-hover);
    border-color: var(--edit-primary-border);
    box-shadow: var(--edit-surface-shadow);
}

/* Credit cost badge inside the main Edit button. */
.lightbox-overlay .edit-submit-cost {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

/* Credit cost badge inside the Fill Canvas button. */
.lightbox-overlay .insert-btn-label {
    display: inline-block;
}
.lightbox-overlay .insert-btn-meta {
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.14);
    color: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.3;
    display: inline-block;
}
.lightbox-overlay #fillCanvasBtn.is-ready .insert-btn-meta {
    background: rgba(255, 255, 255, 0.26);
    color: #ffffff;
}

/* === MASK BRUSH PROMPT (describes the red-painted area specifically) === */
.lightbox-overlay .mask-prompt-shell {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-radius: 12px;
    background: var(--edit-surface-strong);
    border: 1px solid var(--edit-surface-border);
    box-shadow: var(--edit-surface-shadow);
}
.lightbox-overlay .mask-prompt-shell[hidden] {
    display: none !important;
}
.lightbox-overlay .mask-prompt-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--edit-btn-muted);
}
.lightbox-overlay .mask-prompt-label .material-symbols-outlined {
    font-size: 14px !important;
    color: rgba(255, 60, 60, 0.85);
}
.lightbox-overlay .mask-prompt-input {
    width: 100%;
    resize: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--edit-surface-border);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--edit-btn-text);
    font-size: 13px;
    line-height: 1.4;
    font-family: inherit;
    outline: none;
    min-height: 48px;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 180ms ease, background 180ms ease;
}
.lightbox-overlay .mask-prompt-input:focus {
    border-color: rgba(255, 60, 60, 0.6);
    background: rgba(255, 60, 60, 0.04);
}
.lightbox-overlay .mask-prompt-input::placeholder {
    color: var(--edit-btn-muted);
}
.lightbox-overlay .mask-prompt-hint {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    color: var(--edit-btn-muted);
}
.lightbox-overlay .mask-prompt-hint.is-active {
    color: rgba(255, 60, 60, 0.9);
}

.lightbox-overlay .attached-reference-shell {
    gap: 10px;
}

.lightbox-overlay .attached-reference-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.lightbox-overlay .attached-reference-preview-wrap {
    width: 56px;
    height: 56px;
    flex: 0 0 auto;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--edit-surface-border);
    box-shadow: var(--edit-surface-shadow);
}

.lightbox-overlay .attached-reference-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lightbox-overlay .attached-reference-copy {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lightbox-overlay .attached-reference-file {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    color: var(--edit-btn-muted);
    word-break: break-word;
}

.lightbox-overlay .attached-reference-remove {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--edit-btn-border);
    background: var(--edit-btn-bg);
    color: var(--edit-btn-text);
    cursor: pointer;
    box-shadow: var(--edit-surface-shadow);
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.lightbox-overlay .attached-reference-remove:hover {
    background: var(--edit-btn-hover);
    border-color: var(--edit-surface-border-strong);
}

.lightbox-overlay .attached-reference-remove .material-symbols-outlined {
    font-size: 16px !important;
}

.lightbox-overlay .attached-reference-input {
    min-height: 58px;
}

.lightbox-overlay .section-approval-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.lightbox-overlay .section-approval-row--final {
    justify-content: flex-start;
}

.lightbox-overlay .section-approval-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 7px 12px;
    border-radius: 9px;
    border: 1px solid var(--edit-surface-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--edit-btn-text);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
    font-family: inherit;
}

.lightbox-overlay .section-approval-btn:hover:not(:disabled) {
    border-color: var(--edit-btn-selected-border);
    background: rgba(34, 211, 238, 0.08);
}

.lightbox-overlay .section-approval-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lightbox-overlay .section-approval-btn--primary {
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.92) 0%, rgba(34, 211, 238, 0.92) 100%);
    border-color: rgba(34, 211, 238, 0.46);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(34, 211, 238, 0.18);
}

.lightbox-overlay .section-approval-btn--primary:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(8, 145, 178, 1) 0%, rgba(34, 211, 238, 1) 100%);
    color: #ffffff;
}

.lightbox-overlay .section-approval-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 9999px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(148, 163, 184, 0.12);
    color: var(--edit-btn-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
}

.lightbox-overlay .section-approval-badge.is-pending {
    border-color: rgba(245, 158, 11, 0.32);
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

.lightbox-overlay .section-approval-badge.is-approved {
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.14);
    color: #10b981;
}

.lightbox-overlay .section-approval-hint {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    color: var(--edit-btn-muted);
}

/* === CONFIRM CHANGES (AI prompt generator from overlays) === */
.lightbox-overlay .edit-confirm-changes-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--edit-surface-border);
    background: var(--edit-surface-strong);
    color: var(--edit-btn-text);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
    font-family: inherit;
}
.lightbox-overlay .edit-confirm-changes-btn:hover:not(:disabled) {
    border-color: var(--edit-btn-selected-border);
    background: rgba(34, 211, 238, 0.08);
}
.lightbox-overlay .edit-confirm-changes-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.lightbox-overlay .edit-confirm-changes-btn .material-symbols-outlined {
    font-size: 18px !important;
    color: var(--edit-btn-selected-border);
    flex: 0 0 auto;
}
.lightbox-overlay .edit-confirm-changes-btn.is-confirmed {
    border-color: var(--edit-btn-selected-border);
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.18) 0%, rgba(34, 211, 238, 0.18) 100%);
}
.lightbox-overlay .edit-confirm-changes-label {
    flex: 0 0 auto;
}
.lightbox-overlay .edit-confirm-changes-btn .section-approval-badge {
    flex: 0 0 auto;
}
.lightbox-overlay .edit-confirm-changes-hint {
    flex: 1 1 auto;
    font-weight: 400;
    font-size: 11px;
    color: var(--edit-btn-muted);
    line-height: 1.3;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === EXTRA PROMPT INPUT (stitch.html style) === */
.lightbox-overlay .edit-extra-prompt-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    border: 1px solid var(--edit-surface-border);
    border-radius: 10px;
    background: var(--edit-surface-strong);
    padding: 6px;
}
.lightbox-overlay .edit-extra-prompt-input {
    flex: 1;
    resize: none;
    background: transparent;
    border: none;
    outline: none;
    color: var(--edit-btn-text);
    font-size: 12px;
    line-height: 1.45;
    padding: 4px 6px;
    min-height: 28px;
    max-height: 72px;
    overflow-y: auto;
    font-family: inherit;
}
.lightbox-overlay .edit-extra-prompt-input::placeholder {
    color: var(--edit-btn-muted);
}

.lightbox-overlay .final-prompt-review-shell {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
    background: var(--edit-surface-strong);
    border: 1px solid var(--edit-surface-border);
    box-shadow: var(--edit-surface-shadow);
}

.lightbox-overlay .final-prompt-review-shell[hidden] {
    display: none !important;
}

.lightbox-overlay .final-prompt-review-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.lightbox-overlay .final-prompt-review-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--edit-btn-muted);
}

.lightbox-overlay .final-prompt-approval-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 9999px;
    border: 1px solid rgba(245, 158, 11, 0.32);
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
}

.lightbox-overlay .final-prompt-approval-badge.is-approved {
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.14);
    color: #6ee7b7;
}

.lightbox-overlay .final-prompt-preview {
    width: 100%;
    min-height: 132px;
    resize: vertical;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--edit-surface-border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--edit-btn-text);
    font-size: 12px;
    line-height: 1.5;
    font-family: inherit;
    outline: none;
}

.lightbox-overlay .final-prompt-preview::placeholder {
    color: var(--edit-btn-muted);
}

.lightbox-overlay .final-prompt-review-note {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--edit-btn-muted);
}

.lightbox-overlay .generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}
.lightbox-overlay .edit-extra-prompt-send {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--edit-surface-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--edit-btn-text);
    cursor: pointer;
    transition: background 180ms ease, color 180ms ease;
}
.lightbox-overlay .edit-extra-prompt-send:hover:not(:disabled) {
    background: rgba(34, 211, 238, 0.15);
    color: var(--edit-btn-selected-border);
}
.lightbox-overlay .edit-extra-prompt-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.lightbox-overlay .edit-extra-prompt-send .material-symbols-outlined {
    font-size: 16px !important;
}

/* === LOADING OVERLAY === */
.lightbox-overlay .inpaint-loading {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1020;
    backdrop-filter: blur(4px);
}

.lightbox-overlay .loading-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.lightbox-overlay .loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(168, 199, 250, 0.2);
    border-top-color: #a8c7fa;
    border-radius: 50%;
    animation: inpaint-spin 0.8s linear infinite;
}

@keyframes inpaint-spin {
    to { transform: rotate(360deg); }
}

.lightbox-overlay .loading-text {
    color: #e8eaed;
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

.lightbox-overlay .loading-subtext {
    color: #888;
    font-size: 13px;
    margin: 0;
}

/* === RESULT OVERLAY === */
.lightbox-overlay .inpaint-result {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1020;
}

.lightbox-overlay .result-toolbar {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.lightbox-overlay .result-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #a8c7fa;
    color: #062e6f;
    border: none;
    border-radius: 9999px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.lightbox-overlay .result-btn:hover {
    background: #93b8f5;
}

.lightbox-overlay .result-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #c4c7c5;
}

.lightbox-overlay .result-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.18);
}

.lightbox-overlay .result-credits {
    margin-top: 12px;
    color: #888;
    font-size: 13px;
}

.lightbox-overlay .credits-value {
    color: #a8c7fa;
    font-weight: 700;
}

/* === ERROR OVERLAY === */
.lightbox-overlay .inpaint-error {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1020;
}

.lightbox-overlay .error-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.lightbox-overlay .error-icon {
    color: #f44336;
    font-size: 48px;
}

.lightbox-overlay .error-title {
    color: #f44336;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.lightbox-overlay .error-message {
    color: #ef9a9a;
    font-size: 13px;
    margin: 0;
    max-width: 300px;
}

@media (max-width: 640px) {
    .lightbox-overlay .lightbox-workspace {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        width: calc(100vw - 20px);
        min-height: 100vh;
        max-height: none;
        padding: 0 8px 16px;
    }

    .lightbox-overlay .lightbox-stage,
    .lightbox-overlay .edit-toolbar-panel {
        width: 100%;
        flex: 1 1 auto;
    }

    .lightbox-overlay .lightbox-stage {
        min-height: auto;
        padding-top: 64px;
    }

    .lightbox-overlay .edit-toolbar-panel {
        min-height: 0;
        position: static;
        top: auto;
        margin-left: 0;
    }

    .lightbox-overlay .image-viewport {
        max-width: 100%;
        max-height: 52vh;
    }

    .lightbox-overlay .edit-canvas-board {
        max-width: 100%;
        max-height: 52vh;
        width: 100%;
    }

    .lightbox-overlay .edit-toolbar {
        gap: 8px;
        width: 100%;
        max-width: 100%;
    }

    .lightbox-overlay .edit-toolbar.is-floating {
        width: min(296px, calc(100vw - 24px));
    }

    .lightbox-overlay .insert-toolbar,
    .lightbox-overlay .edit-settings-card,
    .lightbox-overlay .prompt-shell,
    .lightbox-overlay .prompt-bar {
        width: 100%;
        max-width: 100%;
    }

    .lightbox-overlay .insert-btn {
        justify-content: flex-start;
    }
}
