body {
    margin: 0;
    overflow: hidden;
    font-family: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #0b0f19;
    color: #f3f4f6;
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#controls {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 24px;
    border-radius: 16px;
    z-index: 10;
    width: 320px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}


#controls {
    box-sizing: border-box;
    transform: translateX(0);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

#controls.sidebar-collapsed {
    transform: translateX(calc(-100% - 20px));
}

#sidebar-toggle {
    position: fixed;
    top: 34px;
    left: 340px;
    z-index: 12;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 0;
    border-radius: 0 10px 10px 0;
    background: rgba(15, 23, 42, 0.9);
    color: #cbd5e1;
    cursor: pointer;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(12px);
    transition: left 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        background 0.15s ease,
        color 0.15s ease;
}

#sidebar-toggle:hover {
    background: rgba(30, 41, 59, 0.96);
    color: #fff;
}

#sidebar-toggle svg {
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

body.sidebar-is-collapsed #sidebar-toggle {
    left: 0;
}

body.sidebar-is-collapsed #sidebar-toggle svg {
    transform: rotate(180deg);
}

/* 
#qr-ar-button {
    display: none !important;
} */

body.capture-mode #sidebar-toggle,
.ar-mode #sidebar-toggle {
    display: none !important;
}

@media (max-width: 760px) {
    #controls {
        top: 12px;
        left: 12px;
        width: min(320px, calc(100vw - 56px));
        max-height: calc(100vh - 24px);
    }

    #controls.sidebar-collapsed {
        transform: translateX(calc(-100% - 12px));
    }

    #sidebar-toggle {
        top: 26px;
        left: min(332px, calc(100vw - 44px));
    }

    body.sidebar-is-collapsed #sidebar-toggle {
        left: 0;
    }
}

#controls::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

h1 {
    font-size: 20px;
    font-weight: 800;
    margin: 0 0 4px 0;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

h2 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #94a3b8;
    margin: 0 0 20px 0;
    font-weight: 600;
}

label {
    font-weight: 600;
    font-size: 13px;
    color: #cbd5e1;
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

label span {
    color: #60a5fa;
}

.control-group {
    margin-bottom: 18px;
}

.window-size-control {
    transition: opacity 0.15s ease;
}

.window-size-control.is-disabled {
    opacity: 0.42;
}

.window-size-control.is-disabled input,
.window-size-control.is-disabled button {
    cursor: not-allowed !important;
}

.finish-mode-row {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.finish-mode-toggle {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    padding: 4px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.finish-mode-btn {
    min-width: 0;
    height: 38px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 7px 8px;
    background: transparent;
    color: #94a3b8;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.finish-mode-row .finish-debug-btn {
    width: 38px;
    height: 38px;
}

.finish-mode-btn.active {
    color: #eff6ff;
    border-color: rgba(96, 165, 250, 0.35);
    background: rgba(59, 130, 246, 0.18);
}

.finish-side-card {
    padding: 10px;
    margin-top: 8px;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.finish-side-card[hidden] {
    display: none;
}

.finish-side-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 700;
}

.finish-side-note {
    color: #64748b;
    font-size: 10px;
    font-weight: 500;
}

.finish-type-toggle {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 5px;
    margin-bottom: 9px;
    padding: 4px;
    border-radius: 9px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.finish-type-btn {
    min-width: 0;
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 6px 5px;
    background: transparent;
    color: #94a3b8;
    font-family: inherit;
    font-size: 10px;
    line-height: 1.15;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.finish-type-btn:hover {
    color: #cbd5e1;
}

.finish-type-btn.active {
    color: #eff6ff;
    border-color: rgba(96, 165, 250, 0.35);
    background: rgba(59, 130, 246, 0.18);
}

.finish-swatches {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px;
}

.finish-swatch {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    border-radius: 7px;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: var(--swatch-color);
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.finish-swatch:hover {
    transform: translateY(-1px);
}

.finish-swatch.active {
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.28), inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.finish-swatches[hidden] {
    display: none;
}

.finish-selected-name {
    margin-top: 7px;
    color: #94a3b8;
    font-size: 10px;
    line-height: 1.35;
}

select,
input[type="number"] {
    width: 100%;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    box-sizing: border-box;
    font-size: 14px;
    transition: all 0.3s ease;
}

select:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

input[type="range"] {
    width: 100%;
    margin: 8px 0;
    -webkit-appearance: none;
    background: rgba(30, 41, 59, 0.7);
    height: 6px;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.mode-select {
    margin-bottom: 18px;
    padding: 14px;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.mode-options {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.mode-options label {
    margin: 0;
    cursor: pointer;
    font-weight: 400;
}

.action-box {
    margin-bottom: 18px;
    padding: 14px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.action-box label {
    margin: 0;
    font-weight: 600;
    color: #93c5fd;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.part-toggles {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 16px;
    margin-top: 16px;
}

.part-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.part-color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.group-dropdown {
    margin-bottom: 12px;
    background: rgba(30, 41, 59, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
}

.group-dropdown[open] {
    border-color: rgba(59, 130, 246, 0.2);
}

.group-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #cbd5e1;
    cursor: pointer;
    list-style: none;
    user-select: none;
    background: rgba(30, 41, 59, 0.5);
    transition: background 0.2s, color 0.2s;
}

.group-dropdown-header:hover {
    background: rgba(30, 41, 59, 0.8);
    color: #ffffff;
}

.group-dropdown-header::-webkit-details-marker {
    display: none;
}

.group-dropdown-header .caret {
    font-size: 8px;
    transition: transform 0.2s ease;
    color: #64748b;
}

.group-dropdown[open] .group-dropdown-header .caret {
    transform: rotate(180deg);
}

.group-dropdown-content {
    padding: 8px 12px 2px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.group-dropdown-content .part-toggle-item {
    margin-bottom: 6px;
}

.btn-toggle-all-group {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #60a5fa;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-toggle-all-group:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
    color: #ffffff;
    transform: scale(1.05);
}

/* Switch/Toggle styles */
.switch {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 10px;
    width: 10px;
    left: 2px;
    bottom: 2px;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 50%;
}

.switch input:checked+.switch-slider {
    background-color: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
}

.switch input:checked+.switch-slider:before {
    transform: translateX(12px);
    background-color: #60a5fa;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    background: rgba(15, 23, 42, 0.9);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    -webkit-user-select: none;
    user-select: none;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #3b82f6;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

body.capture-mode #controls,
body.capture-mode #loading {
    display: none !important;
}

body.capture-mode #canvas-container {
    width: 100vw;
    height: 100vh;
}

/* QR-to-AR controls */
#ar-publish-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 20;
    width: 214px;
    display: grid;
    gap: 8px;
}

.ar-platform-switch {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 4px;
    border: 1px solid rgba(96, 165, 250, 0.42);
    border-radius: 13px;
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(12px);
    isolation: isolate;
}

.ar-platform-highlight {
    position: absolute;
    z-index: 0;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    border-radius: 9px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.96), rgba(14, 165, 233, 0.88));
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.32);
    transform: translateX(0);
    transition: transform 0.22s ease;
    pointer-events: none;
}

.ar-platform-switch[data-platform="ios"] .ar-platform-highlight {
    transform: translateX(100%);
}

.ar-platform-option {
    position: relative;
    z-index: 1;
    min-width: 0;
    border: 0;
    border-radius: 9px;
    padding: 8px 10px;
    background: transparent;
    color: #94a3b8;
    font: 600 12px 'Outfit', sans-serif;
    cursor: pointer;
    transition: color 0.18s ease;
}

.ar-platform-option[aria-pressed="true"] {
    color: #eff6ff;
}

.ar-platform-option:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

#qr-ar-button {
    width: 100%;
    border: 1px solid rgba(96, 165, 250, 0.55);
    border-radius: 10px;
    padding: 12px 18px;
    background: rgba(15, 23, 42, 0.9);
    color: #eff6ff;
    font: 600 14px 'Outfit', sans-serif;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

#qr-ar-button:hover {
    transform: translateY(-1px);
    border-color: #60a5fa;
    background: rgba(30, 64, 175, 0.88);
}

#qr-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(8px);
}

#qr-modal.open {
    display: flex;
}

.qr-dialog {
    position: relative;
    width: min(460px, calc(100vw - 40px));
    box-sizing: border-box;
    padding: 26px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    background: #0f172a;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    text-align: center;
}

.qr-dialog h3 {
    margin: 0 30px 8px;
    font-size: 20px;
}

.qr-dialog p {
    margin: 0 0 18px;
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.45;
}

#qr-status {
    min-height: 22px;
    margin: 0 0 12px;
    color: #bfdbfe;
    font-size: 13px;
    line-height: 1.45;
}

#qr-code {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    padding: 14px;
    border-radius: 14px;
    background: #fff;
    color: #0f172a;
    overflow: hidden;
}

#qr-code svg {
    display: block;
    width: min(260px, 70vw);
    height: auto;
}

#qr-error {
    display: none;
    min-height: 0;
    padding: 16px;
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: 12px;
    background: rgba(127, 29, 29, 0.2);
    color: #fecaca;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
}


#qr-export-stats {
    display: none;
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.8);
    color: #cbd5e1;
    font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-align: left;
    white-space: pre-wrap;
}

#qr-launch-link {
    display: none;
    margin: 12px 0 0;
    color: #93c5fd;
    font-size: 12px;
    overflow-wrap: anywhere;
}

#qr-download-model,
#qr-check-published {
    width: 100%;
    margin-top: 12px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    font: 600 12px 'Outfit', system-ui, sans-serif;
    cursor: pointer;
}

#qr-check-published {
    display: none;
}

#qr-download-model:disabled,
#qr-check-published:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

#qr-publish-help {
    display: none;
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid rgba(96, 165, 250, 0.35);
    border-radius: 10px;
    background: rgba(30, 64, 175, 0.16);
    color: #dbeafe;
    font-size: 12px;
    line-height: 1.5;
    text-align: left;
    overflow-wrap: anywhere;
}

#qr-publish-help code {
    color: #bfdbfe;
}

#qr-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

#ar-launch {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at center, #172554 0%, #020617 72%);
    text-align: center;
}

.ar-mode #controls,
.ar-mode #ar-publish-controls,
.ar-mode #qr-modal {
    display: none !important;
}

.ar-mode #ar-launch {
    display: flex;
}

.ar-launch-card {
    width: min(360px, 100%);
}

.ar-launch-card h1 {
    margin-bottom: 10px;
    font-size: 27px;
}

.ar-launch-card p {
    margin: 0 0 20px;
    color: #cbd5e1;
    line-height: 1.5;
}

#ar-start-button {
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 15px 18px;
    background: #2563eb;
    color: white;
    font: 700 16px 'Outfit', sans-serif;
    cursor: pointer;
}

#ar-start-button:disabled {
    cursor: wait;
    opacity: 0.55;
}

#ar-status {
    min-height: 40px;
    margin-top: 14px;
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.45;
}


#cad-reference-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid rgba(96, 165, 250, 0.45);
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.12);
    color: #bfdbfe;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    padding: 0;
    box-sizing: border-box;
}

#cad-reference-button:hover:not(:disabled) {
    background: rgba(37, 99, 235, 0.25);
    border-color: #60a5fa;
}

#cad-reference-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.square-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.5);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    box-sizing: border-box;
}

.square-toggle-btn:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
    color: #f3f4f6;
}

.square-toggle-btn.active {
    border-color: rgba(96, 165, 250, 0.45);
    background: rgba(37, 99, 235, 0.12);
    color: #60a5fa;
}

.square-toggle-btn.active:hover {
    background: rgba(37, 99, 235, 0.25);
    border-color: #60a5fa;
    color: #93c5fd;
}

#cad-reference-modal {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(8px);
}

#cad-reference-modal.open {
    display: flex;
}

.cad-reference-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(1100px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    padding: 22px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    background: #0f172a;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.cad-reference-header {
    padding-right: 44px;
    margin-bottom: 14px;
}

.cad-reference-header h3 {
    margin: 0 0 4px;
    font-size: 20px;
}

#cad-reference-subtitle {
    margin: 0;
    color: #94a3b8;
    font-size: 13px;
}

#cad-reference-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

#cad-reference-close:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(248, 113, 113, 0.55);
    color: #fca5a5;
    transform: none;
}

#cad-reference-close:active {
    transform: scale(0.95);
}

#cad-reference-close:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

.cad-reference-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 16px;
    min-height: 0;
    overflow: hidden;
}

#cad-reference-main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 360px;
    padding: 12px;
    border-radius: 12px;
    background: #020617;
    overflow: auto;
}

#cad-reference-main img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 180px);
    object-fit: contain;
}

#cad-reference-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 32px 4px 0 0;
    box-sizing: border-box;
}

.cad-reference-thumb {
    display: block;
    width: 100%;
    padding: 5px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9px;
    background: rgba(15, 23, 42, 0.8);
    cursor: pointer;
    text-align: left;
}

.cad-reference-thumb.active {
    border-color: #60a5fa;
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.35);
}

.cad-reference-thumb img {
    display: block;
    width: 100%;
    height: 95px;
    object-fit: contain;
    border-radius: 5px;
    background: #020617;
}

.cad-reference-thumb span {
    display: block;
    margin-top: 5px;
    color: #cbd5e1;
    font: 500 11px 'Outfit', sans-serif;
    overflow-wrap: anywhere;
}

#cad-reference-status {
    padding: 28px;
    color: #94a3b8;
    text-align: center;
}

body.capture-mode #cad-reference-modal,
body.capture-mode #cad-reference-button {
    display: none !important;
}

@media (max-width: 760px) {
    .cad-reference-content {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    #cad-reference-main {
        min-height: 260px;
    }

    #cad-reference-thumbnails {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
        padding-top: 0;
    }
}

@media (max-width: 760px) {
    #ar-publish-controls {
        top: 12px;
        right: 12px;
        width: 184px;
    }

    #qr-ar-button {
        padding: 10px 13px;
        font-size: 12px;
    }

    .ar-platform-option {
        padding: 7px 8px;
        font-size: 11px;
    }
}

.clean-dropdown {
    margin-bottom: 18px;
}

.clean-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    cursor: pointer;
    list-style: none;
    user-select: none;
    padding-bottom: 12px;
    transition: color 0.15s ease;
}

.clean-dropdown-header:hover {
    color: #cbd5e1;
}

.clean-dropdown-header::-webkit-details-marker {
    display: none;
}

.clean-dropdown-header .caret {
    transition: transform 0.2s ease;
    color: #64748b;
    flex-shrink: 0;
}

.clean-dropdown[open] > .clean-dropdown-header .caret {
    transform: rotate(180deg);
}

.handle-side-btn {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    height: 38px;
    padding: 0 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.handle-side-btn:hover:not(.active) {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.handle-side-btn.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #60a5fa;
}

.layout-selector-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.layout-categories-container {
    display: flex;
    flex-direction: column;
}

.layout-category-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

.layout-category-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    padding: 8px 4px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 4px;
    min-height: 58px;
    text-align: center;
    box-sizing: border-box;
}

.layout-category-btn svg.layout-cat-svg {
    width: 20px;
    height: 30px;
    color: #94a3b8;
    transition: color 0.2s ease, transform 0.2s ease;
}

.layout-category-btn:hover:not(.active) {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.layout-category-btn:hover:not(.active) svg.layout-cat-svg {
    color: #fff;
}

.layout-category-btn.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #60a5fa;
}

.layout-category-btn.active svg.layout-cat-svg {
    color: #60a5fa;
}

/* Submenu container styles */
.layout-submenu-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom scrollbar for submenu container */
.layout-submenu-container::-webkit-scrollbar {
    width: 4px;
}

.layout-submenu-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.layout-submenu-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.layout-submenu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 6px 2px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 9px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 4px;
    min-height: 52px;
    text-align: center;
    box-sizing: border-box;
}

.layout-submenu-btn svg {
    width: 18px;
    height: 26px;
    color: #94a3b8;
    transition: color 0.2s ease;
}

.layout-submenu-btn:hover:not(.active) {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.layout-submenu-btn:hover:not(.active) svg {
    color: #fff;
}

.layout-submenu-btn.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #60a5fa;
}

.layout-submenu-btn.active svg {
    color: #60a5fa;
}

/* Premium Component Bubbles Section */

.component-bubble-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 10px;
    box-sizing: border-box;
    text-align: center;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05), 0 4px 20px rgba(0, 0, 0, 0.25);
}

.component-bubble-label {
    font-size: 13px;
    font-weight: 700;
    color: #cbd5e1;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.component-svg-wrapper {
    position: relative;
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 8px;
    border: none;
    overflow: hidden;
    box-shadow: none;
}

.component-svg-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    transition: opacity 0.2s ease;
}

#component-selection-popup {
    position: fixed;
    left: 364px;
    bottom: 24px;
    z-index: 18;
    width: min(280px, calc(100vw - 48px));
    box-sizing: border-box;
    padding: 16px 48px 16px 18px;
    border: 1px solid rgba(96, 165, 250, 0.5);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(12px);
    transition: left 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.15s ease;
}

#component-selection-popup[hidden] {
    display: none;
}

body.sidebar-is-collapsed #component-selection-popup {
    left: 24px;
}

.component-selection-kicker {
    margin-bottom: 3px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#component-selection-name {
    color: #60a5fa;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.1;
}

.component-selection-source {
    margin-top: 7px;
    color: #cbd5e1;
    font-size: 13px;
}

#component-selection-close {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    font: inherit;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
}

#component-selection-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

body.capture-mode #component-selection-popup,
.ar-mode #component-selection-popup {
    display: none !important;
}

@media (max-width: 760px) {

    #component-selection-popup,
    body.sidebar-is-collapsed #component-selection-popup {
        left: 12px;
        bottom: 12px;
        width: min(280px, calc(100vw - 24px));
    }
}

/* Prevent text selection inside the left sidebar */
#controls {
    user-select: none;
    -webkit-user-select: none;
}

/* Keep editable fields selectable */
#controls input[type="text"],
#controls input[type="number"],
#controls textarea {
    user-select: text;
    -webkit-user-select: text;
}
/* Catalog-driven frame, sash, mullion and trans profile selection */
.profile-selection-group {
    padding-bottom: 14px;
}

.profile-selection-toolbar {
    display: grid;
    gap: 10px;
    min-width: 0;
}

/* Keep both square actions on the same baseline as the CAD assembly select.
   The label lives only above the middle column. */
.profile-selection-primary-row {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    align-items: end;
    gap: 10px;
    min-width: 0;
}

.profile-cad-field,
.profile-selection-field {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.profile-cad-field label,
.profile-selection-fields label {
    margin: 0;
    font-size: 11px;
    color: #64748b;
}

.profile-cad-field select,
.profile-selection-fields select {
    width: 100%;
    min-width: 0;
    margin: 0;
}

/* The profile rows span the entire menu width underneath the two square
   buttons: frame + sash on the first row, mullion + trans on the second. */
.profile-selection-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    min-width: 0;
}

/* Accessory selection */
.accessory-selection-group > select {
    width: 100%;
    margin-top: 6px;
}

.accessory-preset-description {
    margin-top: 7px;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.35;
}

.accessory-options {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 10px;
}

.accessory-option-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 9px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.38);
}

.accessory-option-text {
    min-width: 0;
    flex: 1;
}

.accessory-option-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
}

.accessory-option-label {
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 600;
}

.accessory-option-profile {
    color: #38bdf8;
    font-size: 10px;
    font-weight: 600;
}

.accessory-option-description,
.accessory-option-status,
.accessory-availability-note {
    color: #94a3b8;
    font-size: 10px;
    line-height: 1.35;
}

.accessory-option-status {
    color: #fbbf24;
    margin-top: 2px;
}

.accessory-option-unavailable {
    opacity: 0.58;
}

.accessory-availability-note {
    margin-top: 8px;
}

.divider-profile-field {
    display: grid;
}

.divider-profile-field.is-disabled label,
.trans-profile-field.is-disabled label {
    opacity: 0.45;
}

.divider-profile-field select:disabled,
.trans-profile-field select:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Direct 3D window-layout editor. The old predefined layout chooser was
   intentionally removed; topology is now edited around the window itself. */
.window-layout-overlay {
    position: absolute;
    inset: 0;
    z-index: 7;
    pointer-events: none;
    overflow: hidden;
}

.window-layout-node {
    position: absolute;
    transform: translate(-50%, -50%);
    -webkit-user-select: none;
    user-select: none;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    background: rgba(15, 23, 42, 0.9);
    color: #fff;
    box-shadow: 0 5px 18px rgba(15, 23, 42, 0.3);
    font: 600 22px/1 'Outfit', sans-serif;
    display: grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.window-layout-node:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: #2563eb;
    box-shadow: 0 7px 22px rgba(37, 99, 235, 0.38);
}

.window-layout-node-merge {
    width: 30px;
    height: 30px;
    font-size: 16px;
    background: rgba(30, 41, 59, 0.94);
}

.window-layout-node-trans {
    width: 30px;
    height: 30px;
    font-size: 15px;
    background: rgba(30, 41, 59, 0.94);
}

.window-layout-node-trans.is-active {
    background: #2563eb;
}

.window-type-wheel {
    position: absolute;
    width: 154px;
    height: 154px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.45);
    pointer-events: auto;
    -webkit-user-select: none;
    user-select: none;
}

.window-type-wheel *,
.window-type-wheel *::before,
.window-type-wheel *::after {
    -webkit-user-select: none;
    user-select: none;
}

.window-type-wheel::before {
    content: '';
    position: absolute;
    inset: 52px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(2, 6, 23, 0.55);
}

.window-type-wheel-option {
    position: absolute;
    top: 50%;
    width: 46px;
    min-height: 46px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 12px;
    background: rgba(51, 65, 85, 0.96);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font: 500 10px/1 'Outfit', sans-serif;
    cursor: pointer;
}

.window-type-wheel-option:hover {
    background: #2563eb;
}

.window-type-wheel-option.is-fixed { left: 4px; }
.window-type-wheel-option.is-sash { right: 4px; }

.window-type-wheel-icon {
    width: 20px;
    height: 23px;
    border: 1.5px solid currentColor;
    display: grid;
    place-items: center;
    border-radius: 2px;
    font-size: 12px;
}

.window-type-wheel-sash-icon {
    position: relative;
}

.window-type-wheel-sash-icon::before,
.window-type-wheel-sash-icon::after {
    content: '';
    position: absolute;
    left: 3px;
    right: 3px;
    height: 1px;
    background: currentColor;
    transform-origin: center;
}

.window-type-wheel-sash-icon::before { transform: rotate(37deg); }
.window-type-wheel-sash-icon::after { transform: rotate(-37deg); }

.window-type-wheel-close {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: #cbd5e1;
    font-size: 18px;
    cursor: pointer;
}


body.capture-mode .window-layout-overlay,
html.ar-mode .window-layout-overlay {
    display: none !important;
}

/* Window manufacturing summary ------------------------------------------------ */
.clean-dropdown[open] > .clean-dropdown-header .caret {
    transform: rotate(180deg);
}

.window-summary-dropdown {
    margin-top: 2px;
}

.window-summary-shell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.window-summary-section {
    margin-bottom: 8px;
}

.window-summary-section > .clean-dropdown-header {
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 9px;
    background: rgba(15, 23, 42, 0.45);
    color: #a8b4c7;
}

.window-summary-section[open] > .clean-dropdown-header {
    border-radius: 9px 9px 0 0;
    border-bottom-color: rgba(148, 163, 184, 0.08);
}

.window-summary-section-body {
    padding: 12px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-top: 0;
    border-radius: 0 0 9px 9px;
    background: rgba(5, 12, 24, 0.26);
}

.window-summary-rate-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 10px;
}

.window-summary-rate-grid > label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #7d8ca3;
}

.window-summary-rate-input {
    display: flex;
    align-items: center;
    min-width: 0;
    height: 34px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 7px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.75);
}

#controls .window-summary-rate-input input[type="number"] {
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 0 8px;
    border: 0;
    border-radius: 0;
    outline: none;
    background: transparent;
    color: #e5edf7;
    font-size: 12px;
    font-family: inherit;
}

.window-summary-rate-input b {
    flex: 0 0 auto;
    padding-right: 8px;
    color: #6ee7b7;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.window-summary-note {
    margin: 0 0 11px;
    color: #718096;
    font-size: 10px;
    line-height: 1.45;
}

.window-summary-content {
    min-width: 0;
}

.window-summary-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.window-summary-metric {
    min-width: 0;
    padding: 10px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-left: 2px solid #3b82f6;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.62);
}

.window-summary-metric:nth-child(2) {
    border-left-color: #fbbf24;
}

.window-summary-metric:nth-child(3) {
    border-left-color: #34d399;
}

.window-summary-metric.is-total {
    border-left-color: #22d3ee;
}

.window-summary-metric span,
.window-summary-item-main small,
.window-summary-item-main > span,
.window-cut-title span,
.window-cut-specs span {
    display: block;
    color: #718096;
}

.window-summary-metric span {
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.window-summary-metric strong {
    color: #e5edf7;
    font-size: 14px;
    font-weight: 800;
}

.window-summary-metric.is-total strong {
    color: #22d3ee;
}

.window-summary-list,
.window-cut-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.window-summary-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.45);
}

.window-summary-item-main {
    min-width: 0;
}

.window-summary-item-main strong {
    display: block;
    color: #e7edf5;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
}

.window-summary-item-main small {
    margin-top: 2px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.window-summary-item-main > span {
    margin-top: 4px;
    font-size: 10px;
    line-height: 1.35;
}

.window-summary-price {
    flex: 0 0 auto;
    padding: 4px 6px;
    border-radius: 5px;
    background: rgba(16, 185, 129, 0.09);
    color: #34d399;
    font-size: 10px;
    font-weight: 800;
}

.window-cut-card {
    padding: 11px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.45);
}

.window-cut-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.window-cut-title strong {
    display: block;
    color: #e7edf5;
    font-size: 11px;
    line-height: 1.35;
}

.window-cut-title span {
    margin-top: 2px;
    font-size: 9px;
    font-weight: 600;
}

.window-cut-title b {
    padding: 4px 6px;
    border-radius: 5px;
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    font-size: 10px;
}

.window-cut-specs {
    display: grid;
    grid-template-columns: minmax(76px, 0.7fr) minmax(0, 1.7fr);
    gap: 7px;
    padding: 8px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 7px;
    background: rgba(2, 6, 23, 0.26);
}

.window-cut-specs > div {
    min-width: 0;
}

.window-cut-specs span {
    margin-bottom: 4px;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.window-cut-specs strong {
    display: block;
    color: #bdc9da;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 9px;
    font-weight: 500;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.window-cut-card p {
    margin: 7px 0 0;
    color: #6f7f94;
    font-size: 9px;
    line-height: 1.45;
}

.window-summary-empty {
    padding: 16px 8px;
    color: #718096;
    font-size: 10px;
    text-align: center;
}

@media (max-width: 760px) {
    .window-summary-rate-grid,
    .window-summary-metrics {
        grid-template-columns: 1fr 1fr;
    }
}

/* Selected window editor ----------------------------------------------------- */
#selected-window-panel {
    position: fixed;
    left: 24px;
    top: 96px;
    z-index: 19;
    width: min(310px, calc(100vw - 48px));
    max-height: calc(100vh - 120px);
    box-sizing: border-box;
    overflow-y: auto;
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    color: #0f172a;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(14px);
    -webkit-user-select: none;
    user-select: none;
}

#selected-window-panel[hidden] {
    display: none;
}

body.shared-ui-dark-mode #selected-window-panel {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(15, 23, 42, 0.94);
    color: #f8fafc;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
}

.selected-window-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.selected-window-close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #0f172a;
}

body.shared-ui-dark-mode .selected-window-close {
    color: #94a3b8;
}

body.shared-ui-dark-mode .selected-window-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.selected-window-kicker {
    margin-bottom: 2px;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body.shared-ui-dark-mode .selected-window-kicker {
    color: #94a3b8;
}

.selected-window-title {
    margin-bottom: 16px;
    padding-right: 32px;
    color: #2563eb;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.1;
}

.selected-window-actions {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.selected-window-action,
.selected-window-delete {
    min-height: 42px;
    border: 1px solid #dbe4ee;
    border-radius: 10px;
    background: #f8fafc;
    color: #0f172a;
    font: 600 13px/1.2 'Outfit', sans-serif;
    cursor: pointer;
}

.selected-window-action:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

body.shared-ui-dark-mode .selected-window-action,
body.shared-ui-dark-mode .selected-window-delete {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(30, 41, 59, 0.95);
    color: #f8fafc;
}

body.shared-ui-dark-mode .selected-window-action:hover {
    border-color: rgba(96, 165, 250, 0.7);
    background: rgba(37, 99, 235, 0.25);
}

.selected-window-type-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
}

.selected-window-type-icon {
    width: 22px;
    height: 25px;
    display: grid;
    place-items: center;
    border: 1.5px solid currentColor;
    border-radius: 2px;
    box-sizing: border-box;
    font-size: 12px;
}

.selected-window-type-icon.is-sash {
    position: relative;
    font-size: 0;
}

.selected-window-type-icon.is-sash::before,
.selected-window-type-icon.is-sash::after {
    content: '';
    position: absolute;
    left: 4px;
    right: 4px;
    top: 50%;
    border-top: 1.5px solid #0f172a;
    transform-origin: center;
}

.selected-window-type-icon.is-sash::before { transform: rotate(37deg); }
.selected-window-type-icon.is-sash::after { transform: rotate(-37deg); }

body.shared-ui-dark-mode .selected-window-type-icon.is-sash::before,
body.shared-ui-dark-mode .selected-window-type-icon.is-sash::after {
    border-top-color: #f8fafc;
}

.selected-window-opening-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.selected-window-opening-actions[hidden] {
    display: none !important;
}

.selected-window-opening-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.selected-window-opening-action svg {
    width: 22px;
    height: 29px;
}

.selected-window-opening-action.is-active {
    border-color: #60a5fa;
    background: #dbeafe;
    color: #1d4ed8;
}

body.shared-ui-dark-mode .selected-window-opening-action.is-active {
    border-color: #60a5fa;
    background: rgba(37, 99, 235, 0.45);
    color: #dbeafe;
}

.selected-window-size-control {
    margin: 0 0 14px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

body.shared-ui-dark-mode .selected-window-size-control {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.selected-window-size-heading {
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}

.selected-window-size-name {
    color: #334155;
}

#windowHeightControl {
    padding-top: 0;
    border-top: 0;
}

.selected-window-size-value {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    color: #60a5fa;
    font-size: 13px;
    font-weight: 600;
}

.selected-window-size-value input[type="number"] {
    width: 48px;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-align: right;
    outline: none;
    box-shadow: none;
    appearance: textfield;
}

.selected-window-size-value input[type="number"]::-webkit-inner-spin-button,
.selected-window-size-value input[type="number"]::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}

.selected-window-size-value input[type="number"]:focus {
    border: 0;
    outline: 0;
    box-shadow: inset 0 -1px 0 currentColor;
}

.selected-window-size-value input[type="number"]:disabled {
    background: transparent;
    color: inherit;
    cursor: not-allowed;
}

.selected-window-size-unit {
    min-width: 22px;
}

body.shared-ui-mounted:not(.shared-ui-dark-mode) .selected-window-size-value {
    color: #0878c9;
}

body.shared-ui-dark-mode .selected-window-size-heading,
body.shared-ui-dark-mode .selected-window-size-name {
    color: #e2e8f0;
}

body.shared-ui-dark-mode .selected-window-size-value {
    color: #93c5fd;
}

.selected-window-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selected-window-size-row input[type="range"] {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.selected-window-size-row .handle-side-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    padding: 0;
}

.selected-window-delete {
    width: 100%;
    margin-top: 2px;
    border-color: #fecaca;
    background: #fff1f2;
    color: #b91c1c;
}

.selected-window-delete:hover:not(:disabled) {
    border-color: #fca5a5;
    background: #ffe4e6;
}

.selected-window-delete:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

body.shared-ui-dark-mode .selected-window-delete {
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(127, 29, 29, 0.24);
    color: #fecaca;
}

body.capture-mode #selected-window-panel,
html.ar-mode #selected-window-panel {
    display: none !important;
}

@media (max-width: 760px) {
    #selected-window-panel {
        left: 12px;
        top: 76px;
        width: min(300px, calc(100vw - 24px));
        max-height: calc(100vh - 88px);
    }
}

/* Selected-window size fields own their labels; suppress generic injected labels. */
.selected-window-size-heading::before,
.selected-window-size-heading::after,
.selected-window-size-value::before,
.selected-window-size-value::after {
    content: none !important;
    display: none !important;
}
