.sharpsplat-tab-root {
    --sharpsplat-accent: #56a8d8;
    --sharpsplat-panel: #181b1e;
    --sharpsplat-panel-raised: #22262a;
    --sharpsplat-border: #394047;
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #101214;
}

.sharpsplat-sidebar {
    width: 280px;
    min-width: 210px;
    max-width: min(46vw, 520px);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--sharpsplat-panel);
    overflow-y: auto;
    overflow-x: hidden;
}

.sharpsplat-sidebar-resizer {
    position: relative;
    width: 6px;
    flex: 0 0 6px;
    cursor: col-resize;
    background: #15181a;
    touch-action: none;
    z-index: 5;
}

.sharpsplat-sidebar-resizer::after {
    content: '';
    position: absolute;
    inset: 0 2px;
    background: var(--sharpsplat-border);
    transition: background 0.15s ease, inset 0.15s ease;
}

.sharpsplat-sidebar-resizer:hover::after,
.sharpsplat-sidebar-resizer:focus-visible::after,
.sharpsplat-sidebar-resizer.dragging::after {
    inset: 0 1px;
    background: var(--sharpsplat-accent);
}

/* Tooltips render under body, outside the SharpSplat root and its theme variables. */
.tooltip.sharpsplat-tooltip {
    --bs-tooltip-bg: #20252a;
    --bs-tooltip-color: #f4f7f8;
    --bs-tooltip-opacity: 1;
}

.tooltip.sharpsplat-tooltip .tooltip-inner {
    color: #f4f7f8;
    background-color: #20252a;
    border: 1px solid #56616b;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* Bootstrap's secondary outline palette is too muted against some SwarmUI themes. */
.sharpsplat-sidebar .btn-outline-secondary {
    --bs-btn-color: var(--button-text);
    --bs-btn-border-color: var(--button-border);
    --bs-btn-hover-color: var(--button-foreground-hover);
    --bs-btn-hover-bg: var(--button-background-hover);
    --bs-btn-hover-border-color: var(--emphasis);
    --bs-btn-focus-shadow-rgb: 86, 168, 216;
    --bs-btn-active-color: var(--emphasis-text);
    --bs-btn-active-bg: var(--emphasis);
    --bs-btn-active-border-color: var(--emphasis);
    color: var(--button-text);
    background-color: var(--button-background);
    border-color: var(--button-border);
    font-weight: 600;
}

.sharpsplat-sidebar .btn-outline-secondary:hover,
.sharpsplat-sidebar .btn-outline-secondary:focus-visible {
    color: var(--button-foreground-hover);
    background-color: var(--button-background-hover);
    border-color: var(--emphasis);
}

.sharpsplat-sidebar .btn-outline-secondary:disabled {
    color: color-mix(in srgb, var(--button-text) 55%, transparent);
    background-color: color-mix(in srgb, var(--button-background) 55%, transparent);
    border-color: color-mix(in srgb, var(--button-border) 55%, transparent);
    opacity: 0.65;
}

/* Accordion */
.sharpsplat-accordion {
    flex-shrink: 0;
    border-bottom: 1px solid var(--sharpsplat-border);
}

.sharpsplat-accordion-flex {
    flex-shrink: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.sharpsplat-accordion-header {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    background: none;
    border: none;
    color: #b8c0c7;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0;
    cursor: pointer;
    text-align: left;
    gap: 6px;
    user-select: none;
}

.sharpsplat-accordion-header:hover {
    color: #f1f5f7;
    background: var(--sharpsplat-panel-raised);
}

.sharpsplat-accordion-header:focus-visible {
    outline: 2px solid var(--sharpsplat-accent);
    outline-offset: -2px;
}

.sharpsplat-accordion-arrow {
    font-size: 9px;
    display: inline-block;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.sharpsplat-accordion.open > .sharpsplat-accordion-header .sharpsplat-accordion-arrow {
    transform: rotate(90deg);
}

.sharpsplat-accordion-body {
    overflow: hidden;
}

.sharpsplat-accordion-body-flex {
    flex: 1;
    min-height: 0;
    flex-direction: column;
}

.sharpsplat-accordion-body-flex .sharpsplat-file-list {
    flex: 1;
    min-height: 0;
}

.sharpsplat-accordion-flex.open > .sharpsplat-accordion-body {
    display: flex;
}

.sharpsplat-acc-action-btn {
    margin-left: auto;
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

/* Camera section (legacy class kept for camera-controls/group/row/label/input/btns) */
.sharpsplat-camera-section {
    flex-shrink: 0;
    border-bottom: 1px solid #444;
}

.sharpsplat-sidebar-header {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #444;
    flex-shrink: 0;
}


.sharpsplat-camera-controls {
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 14px;
}

.sharpsplat-camera-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sharpsplat-camera-group-label {
    color: #aaa;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.sharpsplat-camera-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sharpsplat-camera-label {
    color: #888;
    font-size: 12px;
    width: 14px;
    flex-shrink: 0;
}

.sharpsplat-camera-input {
    flex: 1;
    font-size: 12px;
    min-width: 0;
}

.sharpsplat-camera-btns {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sharpsplat-camera-btns .btn {
    width: 100%;
}

.sharpsplat-file-list {
    overflow-y: auto;
    padding: 4px 0;
}

.sharpsplat-hint {
    color: #888;
    font-size: 12px;
    padding: 8px 10px;
    display: block;
}

.sharpsplat-file-entry {
    flex: 1;
    min-width: 0;
    padding: 7px 6px 7px 10px;
    font-size: 12px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sharpsplat-file-row {
    width: 100%;
    border-left: 0;
    border-right: 0;
}

.sharpsplat-file-row.active .sharpsplat-file-entry {
    color: inherit;
}

.sharpsplat-icon-btn {
    flex-shrink: 0;
    padding: 4px 7px;
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
}

.sharpsplat-viewer-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #111;
    position: relative;
}

.sharpsplat-viewer-status {
    min-height: 38px;
    padding: 9px 14px;
    font-size: 13px;
    color: #aaa;
    background: var(--sharpsplat-panel);
    border-bottom: 1px solid var(--sharpsplat-border);
    flex-shrink: 0;
}

.sharpsplat-canvas-wrap {
    flex: 1;
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100%;
}

.sharpsplat-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.sharpsplat-viewer-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #101214;
}

/* Settings panel */
.sharpsplat-settings-panel {
    flex-shrink: 0;
    padding: 10px;
    background: #1a1a1a;
}


.sharpsplat-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 28px;
    padding: 4px 10px;
}

.sharpsplat-settings-label {
    color: #bbb;
    font-size: 12px;
    flex: 1;
    min-width: 0;
}

/* Bootstrap switch layout */
.sharpsplat-switch {
    min-height: 0;
    margin: 0;
    padding-left: 2.5em;
    flex-shrink: 0;
}

.sharpsplat-switch .form-check-input {
    margin-top: 0;
    cursor: pointer;
}

.sharpsplat-settings-select {
    width: auto;
    max-width: 55%;
    font-size: 12px;
    flex-shrink: 0;
    cursor: pointer;
}

/* Input image section */
.sharpsplat-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
}

.sharpsplat-dropzone {
    border: 1px dashed #555;
    border-radius: 4px;
    background: #202020;
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.sharpsplat-dropzone:hover {
    border-color: #7bb3f0;
    background: #252d36;
}

.sharpsplat-dropzone.drag-active {
    border-color: #7bb3f0;
    background: #1f344a;
}

.sharpsplat-dropzone-main {
    color: #c7d7ea;
    font-size: 12px;
}

.sharpsplat-dropzone-sub {
    color: #8f9aab;
    font-size: 11px;
    margin-top: 4px;
}

.sharpsplat-input-controls {
    display: flex;
    gap: 6px;
}

.sharpsplat-input-controls .btn {
    flex: 1;
}

.sharpsplat-input-preview {
    display: none;
    border: 1px solid #555;
    border-radius: 4px;
    background: #171717;
    padding: 4px;
}

.sharpsplat-input-preview.active {
    display: block;
}

.sharpsplat-input-preview-image {
    display: block;
    width: 100%;
    max-height: 140px;
    object-fit: contain;
    border-radius: 3px;
}

.sharpsplat-input-name {
    color: #aaa;
    font-size: 11px;
    line-height: 1.2;
    word-break: break-all;
}

/* Multi-image thumbnail strip (VGGT mode) */
.sharpsplat-multi-preview-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 2px 0;
}

.sharpsplat-multi-thumb {
    position: relative;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #555;
    background: #171717;
}

.sharpsplat-multi-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sharpsplat-multi-thumb-remove {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 16px;
    height: 16px;
    background: rgba(0, 0, 0, 0.65);
    border: none;
    border-radius: 50%;
    color: #ccc;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sharpsplat-multi-thumb-remove:hover {
    background: rgba(180, 60, 60, 0.85);
    color: #fff;
}

#sharpsplat_generate_btn {
    width: 100%;
    font-size: 12px;
    padding: 6px 8px;
}

#sharpsplat_generate_btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Sidebar footer (no longer used, kept for safety) */
.sharpsplat-sidebar-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 4px 6px;
    border-top: 1px solid #444;
}

.sharpsplat-gear-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    border-radius: 3px;
    transition: color 0.15s;
}

.sharpsplat-gear-btn:hover,
.sharpsplat-gear-btn.active {
    color: #bbb;
}

/* Export Canvas sidebar section */
.sharpsplat-export-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
}

.sharpsplat-export-custom {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 0 0 4px;
}

#sharpsplat_export_btn {
    width: 100%;
    font-size: 12px;
    padding: 6px 8px;
}

/* Export canvas crop indicator — covers only the canvas area */
.sharpsplat-export-overlay {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.sharpsplat-export-viewport {
    flex: 1;
    width: 100%;
    position: relative;
    overflow: hidden;
    clip-path: inset(0);
}

/* The viewport box — transparent window showing the capture region.
   box-shadow with a huge spread darkens everything outside the box. */
.sharpsplat-export-viewport-box {
    position: absolute;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    border: 2px solid rgba(120, 180, 255, 0.9);
    outline: 1px solid rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    pointer-events: none;
}

/* Corner resize handles — purely decorative */
.sharpsplat-export-viewport-box::before,
.sharpsplat-export-viewport-box::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-color: rgba(120, 180, 255, 1);
    border-style: solid;
}

.sharpsplat-export-viewport-box::before {
    top: -2px;
    left: -2px;
    border-width: 3px 0 0 3px;
}

.sharpsplat-export-viewport-box::after {
    bottom: -2px;
    right: -2px;
    border-width: 0 3px 3px 0;
}

#sharpsplat_export_actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#sharpsplat_export_actions .btn {
    width: 100%;
}

/* Repair Prompt button */
.sharpsplat-repair-prompt-btn {
    margin-top: 6px;
    width: 100%;
}

/* Toast notifications */
.sharpsplat-toast-container {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
    z-index: 200;
}

.sharpsplat-toast {
    background: #2a2a2a;
    color: #ddd;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.sharpsplat-toast.visible {
    opacity: 1;
}

@media (max-width: 720px) {
    .sharpsplat-tab-root {
        flex-direction: column;
    }

    .sharpsplat-sidebar {
        width: 100% !important;
        min-width: 0;
        max-width: none;
        height: 42%;
        min-height: 180px;
        max-height: 70%;
    }

    .sharpsplat-sidebar-resizer {
        width: 100%;
        height: 6px;
        flex-basis: 6px;
        cursor: row-resize;
    }

    .sharpsplat-sidebar-resizer::after {
        inset: 2px 0;
    }

    .sharpsplat-sidebar-resizer:hover::after,
    .sharpsplat-sidebar-resizer:focus-visible::after,
    .sharpsplat-sidebar-resizer.dragging::after {
        inset: 1px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sharpsplat-accordion-arrow,
    .sharpsplat-sidebar-resizer::after,
    .sharpsplat-toast {
        transition: none;
    }
}
