/* Asset editor: scan-first two-pane workflow */

body.tools-editor {
    background: #eceae6;
}

body.tools-editor .tools-nav {
    background: #fff;
    border-bottom: 1px solid #ccc;
    backdrop-filter: none;
}

.editor-app {
    max-width: none;
    /* Room for the fixed saved-assets strip at the bottom */
    padding: 0.75rem 1rem 7.5rem;
}

.editor-top {
    margin-bottom: 0.75rem;
}

.editor-title {
    font-size: 1.2rem;
    margin: 0 0 0.25rem;
    font-weight: 700;
}

.editor-top-flow {
    margin: 0;
    color: #555;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.75rem;
}

.editor-top-flow .box-count {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    background: #e3f2ec;
    color: #0b6e4f;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.editor-top-flow .box-count.warn {
    background: #f6e8e2;
    color: #8a3418;
}

.box-visibility {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.1rem;
    margin-top: 0.45rem;
    font-size: 0.86rem;
    color: #333;
}

.box-vis-opt {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    user-select: none;
}

.box-vis-opt input {
    margin: 0;
}

.box-vis-opt .swatch {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 2px;
    border: 1px solid transparent;
    flex: 0 0 auto;
}

.swatch-green {
    background: rgba(0, 200, 0, 0.35);
    border-color: rgba(0, 140, 0, 0.9);
}

.swatch-blue {
    background: rgba(0, 0, 255, 0.35);
    border-color: rgba(0, 0, 220, 0.9);
}

.swatch-red {
    background: rgba(183, 28, 28, 0.35);
    border-color: rgba(183, 28, 28, 0.95);
}

.saved-assets-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    margin: 0;
    background: rgba(255, 255, 255, 0.97);
    border: none;
    border-top: 1px solid #bbb;
    border-radius: 0;
    padding: 0.4rem 1rem 0.5rem;
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.08);
}

.saved-assets-bar .filmstrip-head {
    margin-bottom: 0.3rem;
}

/* Single-row filmstrip: fixed thumb size, scroll for the rest */
.saved-assets-bar #existing-asset-list-container {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.saved-assets-bar #existing-asset-list {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.45rem;
    list-style: none;
    margin: 0;
    padding: 0.2rem 0.15rem 0.35rem;
    width: max-content;
    min-height: 80px;
}

.saved-assets-bar #existing-asset-list li,
.saved-assets-bar .saved-asset-item {
    position: relative;
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    min-width: 72px;
    max-width: 72px;
    margin: 0;
    padding: 3px;
    background: #fff;
    border: 1px solid #ccc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: border-box;
}

.saved-assets-bar #existing-asset-list li img,
.saved-assets-bar .saved-asset-item img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.saved-asset-item.is-just-saved {
    outline: 3px solid #0b6e4f;
    box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.25);
    animation: saved-pulse 1.1s ease-out 1;
}

@keyframes saved-pulse {
    0% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.saved-asset-delete {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid #8a3418;
    border-radius: 50%;
    background: #fff;
    color: #8a3418;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

.saved-asset-delete:hover {
    background: #8a3418;
    color: #fff;
}

.despeckle-strength-label span {
    display: none;
}

.editor-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: 0.85rem;
    align-items: start;
}

.editor-scan-pane,
.editor-work-pane {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    min-width: 0;
}

.pane-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #ddd;
    font-size: 0.92rem;
    font-weight: 600;
    background: #f7f6f4;
    border-radius: 8px 8px 0 0;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    height: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 4px;
    background: #0b6e4f;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.editor-scan-pane {
    overflow: auto;
    max-height: calc(100vh - 12rem);
}

.editor-scan-pane #scan-canvas-container {
    position: relative;
    margin: 0.5rem;
    overflow: hidden;
    max-height: none;
}

.editor-empty {
    padding: 1.25rem 1rem;
    color: #333;
}

.editor-empty p {
    margin: 0 0 0.5rem;
}

.editor-empty .muted {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}

.editor-active.is-hidden,
.is-hidden {
    display: none !important;
}

.editor-work-pane {
    position: sticky;
    top: calc(var(--tools-nav-h, 52px) + 0.5rem);
    max-height: calc(100vh - 11rem);
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.editor-modal-head {
    flex: 0 0 auto;
    gap: 0.5rem;
}

.editor-modal-title {
    font-size: 0.92rem;
    font-weight: 600;
}

.editor-expand-btn,
.editor-close-btn {
    background: #fff !important;
    border: 1px solid #888 !important;
    border-radius: 4px !important;
    padding: 0.25rem 0.55rem !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    margin: 0 0 0 auto !important;
}

.editor-expand-btn:hover,
.editor-close-btn:hover {
    background: #f0f7f3 !important;
    border-color: #0b6e4f !important;
}

.editor-modal-note {
    margin-left: auto;
    font-size: 0.78rem;
    font-weight: 400;
    color: #777;
}

/* Docked side-pane: stacked canvas + tools */
.editor-modal-layout {
    display: flex;
    flex-direction: column;
}

.expand-only {
    display: none !important;
}

/* Optional full-screen workspace (Expand button) */
body.editor-modal-open {
    overflow: hidden;
}

body.editor-modal-open .editor-work-pane {
    position: fixed;
    inset: 0;
    z-index: 90;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border: none;
    background: #eceae6;
}

body.editor-modal-open .tools-nav,
body.editor-modal-open .editor-top,
body.editor-modal-open .editor-scan-pane,
body.editor-modal-open .saved-assets-bar {
    visibility: hidden;
}

body.editor-modal-open .expand-only {
    display: inline-flex !important;
}

body.editor-modal-open .dock-only {
    display: none !important;
}

body.editor-modal-open .editor-modal-head {
    background: #fff;
    border-bottom: 1px solid #bbb;
    border-radius: 0;
    padding: 0.65rem 1rem;
}

body.editor-modal-open .editor-close-btn {
    margin-left: 0 !important;
}

body.editor-modal-open .editor-active {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.editor-modal-open .editor-active > .editor-tools {
    flex: 0 0 auto;
    background: #fff;
    border-bottom: 1px solid #ddd;
}

body.editor-modal-open .editor-modal-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: 0;
    overflow: hidden;
}

body.editor-modal-open .editor-modal-stage {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    background: #ddd;
    padding: 1rem 1.1rem;
    border-right: 1px solid #bbb;
}

body.editor-modal-open .editor-modal-sidebar {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    background: #fff;
}

body.editor-modal-open .compare-block .asset-container {
    max-height: none;
    min-height: calc(100vh - 8rem);
    padding: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.editor-modal-open #asset-canvas.asset-content {
    max-width: 100%;
    max-height: calc(100vh - 9rem);
    width: auto;
    height: auto;
}

@media (max-width: 900px) {
    body.editor-modal-open .editor-modal-layout {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(40vh, 1fr) auto;
    }

    body.editor-modal-open .editor-modal-stage {
        border-right: none;
        border-bottom: 1px solid #bbb;
    }

    body.editor-modal-open .compare-block .asset-container {
        min-height: 40vh;
    }
}

.editor-tools {
    display: flex;
    flex-direction: column;
}

.tool-bar {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem 0.55rem;
    border-bottom: 1px solid #e5e5e5;
    background: #f7f6f4;
}

.tool-bar-primary {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    background: #eceae6;
    padding: 0.55rem 0.75rem;
}

.tool-bar-end {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
}

.tool-bar .toolbar-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
}

.icon-btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.tool-cluster {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid #aaa;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.tool-cluster .icon-btn {
    border: none;
    border-radius: 0;
    border-right: 1px solid #ddd;
}

.tool-cluster .despeckle-strength-label {
    margin: 0;
    padding: 0 0.35rem;
    display: inline-flex;
    align-items: center;
    background: #fff;
}

.tool-cluster .despeckle-strength-label select {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 0.72rem;
    max-width: 4.5rem;
}

.tool-divider {
    width: 1px;
    align-self: stretch;
    min-height: 2rem;
    background: #ccc;
    margin: 0 0.15rem;
}

.editor-tools .primary-btn {
    min-height: 2.55rem;
    padding: 0.5rem 1.1rem !important;
    font-size: 0.95rem !important;
}

.icon-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    min-width: 3.1rem;
    padding: 0.35rem 0.4rem;
    background: #fff;
    border: 1px solid #aaa;
    border-radius: 6px;
    cursor: pointer;
    color: #222;
    line-height: 1.1;
}

.icon-btn:hover {
    background: #f0f7f3;
    border-color: #0b6e4f;
}

.icon-btn.is-active,
.icon-btn.btn-primary {
    background: #0b6e4f !important;
    border-color: #0b6e4f !important;
    color: #fff !important;
}

.icon-btn .icon-glyph {
    font-size: 1.05rem;
    line-height: 1;
}

.icon-btn .icon-name {
    font-size: 0.65rem;
    font-weight: 600;
}

.brush-dot {
    display: inline-block;
    border-radius: 50%;
    background: #222;
    margin: 0.15rem 0;
}

.brush-dot-7 {
    width: 6px;
    height: 6px;
}

.brush-dot-14 {
    width: 10px;
    height: 10px;
}

.brush-dot-28 {
    width: 16px;
    height: 16px;
}

.icon-btn.is-active .brush-dot,
.icon-btn.btn-primary .brush-dot {
    background: #fff;
}

.editor-tools .primary-btn,
#asset-create.primary-btn {
    background: #0b6e4f !important;
    border-color: #0b6e4f !important;
    color: #fff !important;
    font-weight: 700;
}

.editor-tools .btn,
.editor-tools .menu-btn,
.more-tools .btn,
.more-tools .menu-btn {
    background: #fff;
    border: 1px solid #aaa;
    border-radius: 3px;
    padding: 0.35rem 0.65rem;
    font-size: 0.82rem;
    cursor: pointer;
    margin: 0;
}

.editor-tools .btn:hover,
.more-tools .btn:hover {
    background: #f5f5f5;
}

.editor-tools .compare-stack {
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
}

.auto-isolate-label.visually-assist {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.compare-stack {
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.compare-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #444;
    margin-bottom: 0.3rem;
}

.compare-label span {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #777;
}

.compare-block .asset-container {
    display: block;
    width: 100%;
    max-height: 280px;
    overflow: auto;
    background: #e8e8e8;
    border: 1px solid #bbb;
    padding: 12px;
}

#asset-canvas-container {
    position: relative;
    /* Checkerboard so transparent / trimmed areas read clearly */
    background-color: #d0d0d0;
    background-image:
        linear-gradient(45deg, #bcbcbc 25%, transparent 25%),
        linear-gradient(-45deg, #bcbcbc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #bcbcbc 75%),
        linear-gradient(-45deg, transparent 75%, #bcbcbc 75%);
    background-size: 14px 14px;
    background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}

.editor-status {
    min-height: 1.1rem;
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    color: #0b6e4f;
    font-weight: 600;
}

.despeckle-strength-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: #444;
    margin-left: 0.15rem;
}

.despeckle-strength-label select {
    font-size: 0.78rem;
    padding: 0.2rem 0.3rem;
    border: 1px solid #aaa;
    border-radius: 3px;
    background: #fff;
}

.asset-bounds {
    position: absolute;
    z-index: 4;
    pointer-events: none;
    border: 2px dashed #d81b60;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
    box-sizing: border-box;
}

.editor-busy {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.55);
    color: #222;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.editor-busy.is-hidden {
    display: none !important;
}

.compare-ref-details {
    margin: 0;
    font-size: 0.85rem;
}

.compare-ref-details > summary {
    cursor: pointer;
    color: #666;
    padding: 0.15rem 0;
    user-select: none;
}

.compare-ref-details[open] > summary {
    margin-bottom: 0.35rem;
}

.brush-cursor {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    border: 2px solid #111;
    border-radius: 2px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.25);
    mix-blend-mode: difference;
}

.brush-cursor[data-mode="clear"] {
    border-color: #ff2d2d;
    background: rgba(255, 45, 45, 0.2);
    mix-blend-mode: normal;
    border-radius: 50%;
}

.brush-cursor[data-mode="white"] {
    border-color: #222;
    background: rgba(255, 255, 255, 0.55);
}

.brush-cursor[data-mode="black"] {
    border-color: #fff;
    background: rgba(0, 0, 0, 0.45);
}

#asset-canvas {
    cursor: none;
}

.compare-block .asset-content,
#asset-canvas,
#asset-image-original {
    max-width: 100%;
    height: auto;
    border: none !important;
}

.compare-ref .asset-container {
    max-height: 160px;
    opacity: 0.95;
}

.more-tools {
    margin: 0 0.75rem 0.5rem;
    font-size: 0.88rem;
}

.more-tools summary {
    cursor: pointer;
    color: #666;
    padding: 0.25rem 0;
}

.tools-grid-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.35rem 0 0.5rem;
}

.tool-group-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #555;
    margin-bottom: 0.25rem;
}

.filmstrip-block {
    border-top: 1px solid #e5e5e5;
    padding: 0.5rem 0.75rem 0.65rem;
}

.session-queue-details > summary.filmstrip-head {
    cursor: pointer;
    list-style: none;
    user-select: none;
    margin-bottom: 0;
}

.session-queue-details > summary.filmstrip-head::-webkit-details-marker {
    display: none;
}

.session-queue-details > summary.filmstrip-head::before {
    content: '▸';
    display: inline-block;
    margin-right: 0.35rem;
    color: #888;
}

.session-queue-details[open] > summary.filmstrip-head {
    margin-bottom: 0.3rem;
}

.session-queue-details[open] > summary.filmstrip-head::before {
    content: '▾';
}

.session-queue-details:not([open]) .queue-actions,
.session-queue-details:not([open]) #image-list-container {
    display: none;
}

.queue-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
}

.queue-actions .btn {
    background: #fff;
    border: 1px solid #aaa;
    border-radius: 3px;
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
    cursor: pointer;
    margin: 0;
}

.queue-actions .btn:hover {
    background: #f5f5f5;
}

.filmstrip-head {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #555;
    margin-bottom: 0.3rem;
}

.section-note {
    margin-left: 0.35rem;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #888;
}

.empty-hint {
    color: #888;
    font-size: 0.82rem;
    margin: 0.15rem 0 0;
}

#image-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

#image-list li {
    width: 64px;
    height: 64px;
    padding: 3px;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: none;
    cursor: pointer;
}

#image-list li img {
    max-width: 100%;
    max-height: 100%;
}

@media (max-width: 960px) {
    .editor-main {
        grid-template-columns: 1fr;
    }

    .editor-scan-pane #scan-canvas-container {
        max-height: 55vh;
    }
}
