body {
    margin: 0;
    background-color: #050505;
    font-family: sans-serif;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    /* Запрещаем выделение текста в основном приложении */
    user-select: none;
}

#app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

.viewer-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #0b0b0b;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    cursor: grab;
}

.viewer-container:active {
    cursor: grabbing;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#loader-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: #333;
    transition: width 0.1s linear;
}

.controls {
    position: absolute;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    max-width: calc(100vw - 32px);
    padding: 10px 12px;
    background: rgba(16, 16, 16, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    z-index: 120;
}

button {
    padding: 10px 20px;
    border: none;
    background: #333;
    color: white;
    border-radius: 6px;
    cursor: pointer;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Выбор цвета */
.color-picker {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.color-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.18);
    padding: 0;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.color-btn.active {
    border-color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18), 0 4px 16px rgba(0, 0, 0, 0.36);
}

.color-btn[data-color="white"],
.color-btn[data-color="silver"] {
    border-color: rgba(0, 0, 0, 0.18);
}

.color-btn[data-color="white"].active,
.color-btn[data-color="silver"].active {
    border-color: #fff;
}

/* Переключатель пинов — скрыт до applyDescriptionsConfig, чтобы не мигал при загрузке */
.pins-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    margin-left: 4px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.pins-toggle.is-enabled {
    display: flex;
}

.pins-toggle input {
    display: none;
}

.toggle-slider {
    width: 38px;
    height: 22px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    position: relative;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pins-toggle input:checked + .toggle-slider {
    background: #fff;
}

.pins-toggle input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: #111;
}

.toggle-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.86);
}

/* Пины */
#pins-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.pin {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    z-index: 10;
    transition: opacity 0.2s ease;
}

/* Активный (ховернутый) пин всегда выше остальных и их тултипов */
.pin:hover {
    z-index: 1000;
}

.pin-dot {
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #333;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Полупрозрачность пинов в неактивном состоянии */
.pin .pin-dot {
    opacity: 0.4;
}

.pin:hover .pin-dot {
    opacity: 1;
}

/* Скрытие пинов при отключении */
#pins-layer.hidden .pin {
    opacity: 0 !important;
    pointer-events: none !important;
}

.pin-dot::before {
    content: '+';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: bold;
    color: #333;
    line-height: 1;
}

.pin:hover .pin-dot {
    transform: scale(1.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.pin-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px);
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.98);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    min-width: 180px;
    max-width: 260px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    transform: translateX(-50%) translateY(8px);
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.pin-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: calc(50% + var(--tooltip-offset, 0px));
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: rgba(30, 30, 30, 0.98);
    opacity: var(--arrow-opacity, 1);
    transition: opacity 0.2s;
}

/* Вариант тултипа, который показывается СНИЗУ от пина */
.pin-tooltip.bottom {
    bottom: auto;
    top: calc(100% + 12px);
    transform: translateX(-50%) translateY(-8px);
}

.pin-tooltip.bottom::after {
    top: auto;
    bottom: 100%;
    left: calc(50% + var(--tooltip-offset, 0px));
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-bottom-color: rgba(30, 30, 30, 0.98);
    opacity: var(--arrow-opacity, 1);
    transition: opacity 0.2s;
}

.pin:hover .pin-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.pin:hover .pin-tooltip.bottom {
    transform: translateX(-50%) translateY(0);
}

.pin-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    /* Разрешаем перенос заголовка на несколько строк */
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
}

.pin-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

/* Анимация пульсации только при наведении */
.pin-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 2px solid #333;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.pin:hover .pin-dot::after {
    animation: pin-pulse 1.5s ease-out infinite;
}

@keyframes pin-pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* === DEV MODE === */
body.dev-mode .viewer-container {
    outline: 3px dashed #2ca0e5;
}

.dev-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: #1e1e1e;
    color: #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    z-index: 9999;
}

/* В dev-панели и её содержимом разрешаем выделение текста и работу с текстом */
.dev-panel,
.dev-panel * {
    user-select: text;
}

.dev-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #2ca0e5;
    color: #000;
    font-weight: 600;
    border-radius: 12px 12px 0 0;
}

.dev-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #000;
    padding: 0;
    line-height: 1;
}

.dev-info {
    padding: 12px 16px;
    border-bottom: 1px solid #333;
}

.dev-frame {
    font-size: 14px;
    margin-bottom: 8px;
}

.dev-frame span {
    font-weight: bold;
    color: #2ca0e5;
}

.dev-frame-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dev-frame-nav button {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #333;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 12px;
}

.dev-frame-nav button:hover {
    background: #444;
}

.dev-frame-nav input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: #333;
    border-radius: 3px;
    cursor: pointer;
}

.dev-frame-nav input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #2ca0e5;
    border-radius: 50%;
    cursor: pointer;
}

.dev-section {
    padding: 12px 16px;
    border-bottom: 1px solid #333;
}

.dev-section-title {
    font-weight: 600;
    margin-bottom: 10px;
    color: #2ca0e5;
}

.dev-pin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #2a2a2a;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.dev-pin-item:hover {
    background: #333;
}

.dev-pin-item.selected {
    background: #2ca0e5;
    color: #000;
}

.dev-pin-name {
    font-weight: 500;
}

.dev-pin-id {
    font-size: 11px;
    opacity: 0.6;
}

.dev-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: #333;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    margin-top: 8px;
}

.dev-btn:hover {
    background: #444;
}

.dev-btn-primary {
    background: #2ca0e5;
    color: #000;
    font-weight: 600;
}

.dev-btn-primary:hover {
    background: #fbbf24;
}

.dev-btn-danger {
    background: #dc2626;
}

.dev-btn-danger:hover {
    background: #ef4444;
}

.dev-btn-sm {
    padding: 6px 10px;
    font-size: 12px;
    width: auto;
}

.dev-field {
    margin-bottom: 12px;
}

.dev-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: #999;
}

.dev-field input[type="text"],
.dev-field input[type="number"] {
    width: 100%;
    padding: 8px 10px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    box-sizing: border-box;
}

.dev-field input:focus {
    outline: none;
    border-color: #2ca0e5;
}

.dev-pos-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
}

.dev-pos-inputs input {
    width: 70px !important;
}

.dev-keyframes {
    margin-top: 12px;
}

.dev-keyframes label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: #999;
}

#dev-keyframes-list {
    max-height: 120px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.dev-keyframe {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: #2a2a2a;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 12px;
}

.dev-keyframe.current {
    background: #3a3a1a;
    border: 1px solid #2ca0e5;
}

.dev-keyframe span {
    flex: 1;
}

.dev-keyframe button {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: #444;
    color: #fff;
    cursor: pointer;
    font-size: 11px;
    padding: 0;
}

.dev-keyframe button:hover {
    background: #555;
}

.dev-export-result {
    padding: 12px 16px;
}

#dev-json-output {
    width: 100%;
    height: 200px;
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 6px;
    color: #7dd3fc;
    font-family: monospace;
    font-size: 11px;
    padding: 10px;
    resize: vertical;
    box-sizing: border-box;
    margin-bottom: 8px;
}

/* Пин в dev-режиме */
body.dev-mode .pin.draggable .pin-dot {
    cursor: move;
    border-color: #2ca0e5;
}

body.dev-mode .pin.selected .pin-dot {
    background: #2ca0e5;
    transform: scale(1.3);
}

body.dev-mode .pin.selected .pin-dot::before {
    color: #000;
}

/* === ПЕРЕКЛЮЧАТЕЛЬ ВИДА === */
.view-switcher {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.12);
    padding: 4px;
    border-radius: 12px;
}

.view-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    color: rgba(255, 255, 255, 0.68);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.25s ease;
}

.view-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.view-btn.active {
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.22);
}

.view-btn svg {
    flex-shrink: 0;
}

.separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.16);
    margin: 0 2px;
    align-self: center;
}

/* Кнопка возврата к экстерьеру */
.view-toggle-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(10px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
    transition: all 0.25s ease;
}

.view-toggle-btn:hover {
    background: rgba(40, 40, 40, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.view-toggle-btn svg {
    flex-shrink: 0;
}

/* Скрытие элементов в режиме интерьера */
.controls.interior-mode #color-picker,
.controls.interior-mode .separator:first-of-type {
    opacity: 0.3;
    pointer-events: none;
}

/* Интерьерный канвас */
#interior-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Подсказка для панорамы */
.panorama-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    color: rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    font-size: 13px;
    z-index: 50;
    opacity: 0;
    animation: hintFadeInOut 4s ease-in-out forwards;
    pointer-events: none;
}

.panorama-hint svg {
    animation: dragHint 1.5s ease-in-out infinite;
}

@keyframes hintFadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

@keyframes dragHint {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(8px); }
}

/* === АДАПТИВ: МОБИЛЬНЫЕ ЭКРАНЫ === */
@media (max-width: 768px) {
    body {
        width: 100%;
        height: 100vh;
        height: 100dvh;
    }

    #app {
        width: 100%;
        height: 100vh;
        height: 100dvh;
    }

    .viewer-container {
        height: 100%;
        border-radius: 0;
    }

    .controls {
        bottom: max(8px, env(safe-area-inset-bottom));
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
        width: calc(100% - 16px);
        max-width: none;
        box-sizing: border-box;
        padding: 6px 8px;
        border-radius: 14px;
    }

    .view-switcher {
        justify-content: center;
        padding: 2px;
        border-radius: 8px;
        gap: 2px;
    }

    .view-btn {
        padding: 6px 8px;
        font-size: 11px;
        gap: 4px;
    }

    .view-btn svg {
        width: 14px;
        height: 14px;
    }

    .color-picker {
        justify-content: center;
        gap: 6px;
    }

    .color-btn {
        width: 22px;
        height: 22px;
    }

    .separator {
        display: none;
    }

    .pins-toggle {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        gap: 4px;
    }

    .toggle-slider {
        width: 32px;
        height: 18px;
    }

    .toggle-slider::before {
        width: 14px;
        height: 14px;
    }

    .pins-toggle input:checked + .toggle-slider::before {
        transform: translateX(14px);
    }

    .toggle-label {
        font-size: 11px;
    }

    .panorama-hint {
        left: 12px;
        right: 12px;
        width: auto;
        transform: translateY(0);
        justify-content: center;
        padding: 12px 16px;
        animation: hintFadeInOutMobile 4s ease-in-out forwards;
    }
}

@keyframes hintFadeInOutMobile {
    0% { opacity: 0; transform: translateY(10px); }
    15% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* === BOXED LAYOUT: вписанный вид без выбора авто === */
html[data-layout="boxed"] body {
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow: auto;
    padding: 32px 24px;
    box-sizing: border-box;
}

html[data-layout="boxed"] #app {
    width: 100%;
    max-width: 1200px;
    height: auto;
    overflow: visible;
}

html[data-layout="boxed"] .viewer-container {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    max-width: none;
    max-height: none;
    margin-inline: 0;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

html[data-layout="boxed"] #car-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

html[data-layout="boxed"] .controls {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    margin: 20px auto 0;
    max-width: none;
    width: auto;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    gap: 12px;
}

html[data-layout="boxed"] .view-switcher {
    background: #e5e5e5;
}

html[data-layout="boxed"] .view-btn {
    color: #666;
}

html[data-layout="boxed"] .view-btn:hover {
    color: #333;
    background: rgba(255, 255, 255, 0.5);
}

html[data-layout="boxed"] .view-btn.active {
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

html[data-layout="boxed"] .separator {
    background: #ddd;
    margin: 0 10px;
}

html[data-layout="boxed"] .color-btn {
    width: 36px;
    height: 36px;
    border: 3px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

html[data-layout="boxed"] .color-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

html[data-layout="boxed"] .color-btn.active {
    border-color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

html[data-layout="boxed"] .color-btn[data-color="white"],
html[data-layout="boxed"] .color-btn[data-color="silver"] {
    border: 2px solid #ddd;
}

html[data-layout="boxed"] .color-btn[data-color="white"].active,
html[data-layout="boxed"] .color-btn[data-color="silver"].active {
    border-color: #333;
}

html[data-layout="boxed"] .pins-toggle {
    border-left-color: #ddd;
    margin-left: 20px;
    padding-left: 20px;
}

html[data-layout="boxed"] .toggle-slider {
    width: 44px;
    height: 24px;
    background: #ccc;
}

html[data-layout="boxed"] .toggle-slider::before {
    width: 20px;
    height: 20px;
}

html[data-layout="boxed"] .pins-toggle input:checked + .toggle-slider {
    background: #333;
}

html[data-layout="boxed"] .pins-toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #fff;
}

html[data-layout="boxed"] .toggle-label {
    font-size: 14px;
    color: #555;
}

@media (max-width: 768px) {
    html[data-layout="boxed"] body {
        align-items: stretch;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 0;
        overflow: hidden;
        background: #fff;
    }

    html[data-layout="boxed"] #app {
        width: 100%;
        max-width: none;
        height: auto;
    }

    html[data-layout="boxed"] .viewer-container {
        height: auto;
        aspect-ratio: 16 / 9;
        max-height: none;
        max-width: none;
        border-radius: 0;
        box-shadow: none;
    }

    html[data-layout="boxed"] .controls {
        position: relative;
        left: auto;
        bottom: auto;
        transform: none;
        margin: 8px 0 6px;
        width: 100%;
        max-width: none;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 6px;
        padding: 0 8px 6px;
        box-sizing: border-box;
        background: transparent;
        border: none;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    html[data-layout="boxed"] .view-switcher {
        width: auto;
        justify-content: center;
        padding: 2px;
        border-radius: 8px;
        gap: 2px;
    }

    html[data-layout="boxed"] .color-picker {
        justify-content: center;
        gap: 6px;
    }

    html[data-layout="boxed"] .color-btn {
        width: 22px;
        height: 22px;
        border-width: 2px;
    }

    html[data-layout="boxed"] .pins-toggle {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        gap: 4px;
    }

    html[data-layout="boxed"] .fullscreen-toggle {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }
}

/* iframe / ?embed=1 */
html[data-embed="1"] {
    width: 100%;
}

html[data-embed="1"]:not([data-layout="boxed"]),
html[data-embed="1"]:not([data-layout="boxed"]) body,
html[data-embed="1"]:not([data-layout="boxed"]) #app {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

html[data-layout="boxed"][data-embed="1"],
html[data-layout="boxed"][data-embed="1"] body {
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: hidden;
}

html[data-layout="boxed"][data-embed="1"] body {
    padding: 0;
    align-items: stretch;
    min-height: 0;
    height: auto;
}

html[data-layout="boxed"][data-embed="1"] #app {
    max-width: 1200px;
    width: 100%;
    height: auto;
    display: block;
}

html[data-layout="boxed"][data-embed="1"] .viewer-container {
    width: 100%;
    max-width: none;
    max-height: none;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

html[data-layout="boxed"][data-embed="1"] .controls {
    margin-top: 20px;
    padding: 0;
    width: auto;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    html[data-layout="boxed"][data-embed="1"] body {
        padding: 0;
        height: auto;
        min-height: 0;
        overflow: hidden;
        align-items: stretch;
        background: #fff;
    }

    html[data-layout="boxed"][data-embed="1"] #app {
        height: auto;
        width: 100%;
        max-width: none;
    }

    html[data-layout="boxed"][data-embed="1"] .viewer-container {
        aspect-ratio: 16 / 9;
        max-height: none;
        max-width: none;
        width: 100%;
        border-radius: 0;
        box-shadow: none;
    }

    html[data-layout="boxed"][data-embed="1"] .controls {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        margin: 8px 0 6px;
        padding: 0 8px 6px;
        width: 100%;
    }
}

html[data-layout="boxed"] .fullscreen-toggle {
    display: flex;
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 130;
    width: 42px;
    height: 42px;
    padding: 0;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    color: #1a1a1a;
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    cursor: pointer;
}

html[data-layout="boxed"] .fullscreen-toggle:hover {
    background: #fff;
    transform: translateY(-1px);
}

html[data-layout="boxed"] .fullscreen-toggle svg {
    display: block;
}

html[data-layout="boxed"] .fullscreen-toggle svg[hidden] {
    display: none;
}

html[data-layout="boxed"].is-fs,
html[data-layout="boxed"].is-fs body {
    background: #000;
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

html[data-layout="boxed"].is-fs body {
    display: block;
    height: 100vh;
    height: 100dvh;
}

html[data-layout="boxed"].is-fs #app,
html[data-layout="boxed"] #app:fullscreen,
html[data-layout="boxed"] #app:-webkit-full-screen {
    max-width: none;
    width: 100%;
    height: 100%;
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #000;
    z-index: 1000;
}

html[data-layout="boxed"].is-fs .viewer-container,
html[data-layout="boxed"] #app:fullscreen .viewer-container,
html[data-layout="boxed"] #app:-webkit-full-screen .viewer-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
    background: #000;
}

html[data-layout="boxed"].is-fs .controls,
html[data-layout="boxed"] #app:fullscreen .controls,
html[data-layout="boxed"] #app:-webkit-full-screen .controls {
    position: absolute;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 140;
    margin-top: 0;
    width: auto;
    max-width: calc(100vw - 32px);
    padding: 10px 12px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    background: rgba(16, 16, 16, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
}

html[data-layout="boxed"].is-fs .view-switcher {
    background: rgba(255, 255, 255, 0.12);
}

html[data-layout="boxed"].is-fs .view-btn {
    color: rgba(255, 255, 255, 0.68);
}

html[data-layout="boxed"].is-fs .view-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

html[data-layout="boxed"].is-fs .view-btn.active {
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.22);
}

html[data-layout="boxed"].is-fs .separator {
    background: rgba(255, 255, 255, 0.16);
}

html[data-layout="boxed"].is-fs .color-btn {
    width: 30px;
    height: 30px;
    border: 2px solid rgba(255, 255, 255, 0.18);
}

html[data-layout="boxed"].is-fs .color-btn.active {
    border-color: #fff;
}

html[data-layout="boxed"].is-fs .color-btn[data-color="white"],
html[data-layout="boxed"].is-fs .color-btn[data-color="silver"] {
    border-color: rgba(0, 0, 0, 0.18);
}

html[data-layout="boxed"].is-fs .color-btn[data-color="white"].active,
html[data-layout="boxed"].is-fs .color-btn[data-color="silver"].active {
    border-color: #fff;
}

html[data-layout="boxed"].is-fs .pins-toggle {
    border-left-color: rgba(255, 255, 255, 0.16);
}

html[data-layout="boxed"].is-fs .toggle-label {
    color: rgba(255, 255, 255, 0.86);
}

html[data-layout="boxed"].is-fs .fullscreen-toggle {
    background: rgba(16, 16, 16, 0.72);
    color: #fff;
}

@media (max-width: 768px) {
    html[data-layout="boxed"].is-fs .controls {
        width: calc(100% - 16px);
        max-width: none;
        box-sizing: border-box;
        bottom: max(8px, env(safe-area-inset-bottom));
        padding: 6px 8px;
        gap: 6px;
        border-radius: 14px;
    }

    html[data-layout="boxed"].is-fs .color-btn {
        width: 22px;
        height: 22px;
    }

    html[data-layout="boxed"].is-fs .viewer-container {
        aspect-ratio: auto;
        height: 100%;
        border-radius: 0;
    }
}