* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #fff;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Toolbar */
#toolbar {
    display: flex;
    gap: 20px;
    padding: 10px 20px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-section {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toolbar-section label {
    color: #94a3b8;
    font-size: 13px;
}

#toolbar select,
#toolbar input {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
}

#toolbar button {
    background: #0f3460;
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

#toolbar button:hover {
    background: #1a4a7a;
}

#toolbar button.primary {
    background: #e94560;
}

#toolbar button.primary:hover {
    background: #ff6b6b;
}

#toolbar button.save-btn {
    background: #10b981;
}

#toolbar button.save-btn:hover {
    background: #34d399;
}

#toolbar button.mode-btn.active {
    background: #4ade80;
    color: #000;
}

/* Main Container */
#main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#canvas-container {
    flex: 1;
    position: relative;
    /* Default gradient background - JS can override */
    background: radial-gradient(circle, #3a3d40 0%, #000000 100%);
    /* Prevent browser handling of touch gestures */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* Safe Area Overlay */
#safe-area-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

#safe-area-overlay.hidden {
    display: none;
}

/* Hide safe areas in view mode */
body:not(.editor-mode) #safe-area-overlay {
    display: none !important;
}

.safe-area {
    position: absolute;
    border: 2px dashed;
    background: transparent;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.safe-area::before {
    content: attr(data-label);
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
}

/* Mobile safe area - 375x667 (iPhone SE) */
.safe-area.mobile {
    width: 375px;
    height: 667px;
    max-width: 100%;
    max-height: 100%;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.safe-area.mobile::before {
    background: #ef4444;
    color: white;
}

/* Mobile + Panel safe area - shows overlay zone where description panel appears */
.safe-area.mobile-panel {
    width: 375px;
    height: 667px;
    max-width: 100%;
    max-height: 100%;
    border-color: #f97316;
    background: transparent;
    display: none; /* Hidden by default, shown when selected */
}

.safe-area.mobile-panel.active {
    display: flex;
}

.safe-area.mobile-panel::before {
    background: #f97316;
    color: white;
}

/* The bottom 50% overlay zone indicating panel coverage */
.panel-overlay-zone {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: rgba(249, 115, 22, 0.25);
    border-top: 2px dashed #f97316;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-overlay-zone::after {
    content: "Panel Overlay Zone";
    color: #f97316;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Tablet safe area - 768x1024 (iPad) */
.safe-area.tablet {
    width: 768px;
    height: 600px;
    max-width: 100%;
    max-height: 100%;
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

.safe-area.tablet::before {
    background: #f59e0b;
    color: white;
}

/* Desktop safe area - 1280x720 */
.safe-area.desktop {
    width: 1280px;
    height: 720px;
    max-width: 100%;
    max-height: 100%;
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.05);
}

.safe-area.desktop::before {
    background: #22c55e;
    color: white;
}

/* Legend */
.safe-area-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.85);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: auto;
}

.legend-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.legend-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.legend-btn.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
}

.legend-btn::before {
    content: '';
    width: 10px;
    height: 10px;
    border: 2px dashed;
    border-radius: 2px;
}

.legend-mobile::before {
    border-color: #ef4444;
}

.legend-mobile-panel::before {
    border-color: #f97316;
    background: rgba(249, 115, 22, 0.3);
}

.legend-tablet::before {
    border-color: #f59e0b;
}

.legend-desktop::before {
    border-color: #22c55e;
}

.legend-reset::before {
    border-color: #94a3b8;
    border-style: solid;
}

/* Canvas preview mode */
#canvas-container.preview-size {
    position: relative !important;
    margin: auto;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3), 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Sidebar */
#sidebar {
    width: 280px;
    background: #16213e;
    border-left: 1px solid #0f3460;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.panel {
    padding: 15px;
    border-bottom: 1px solid #0f3460;
}

.panel h3 {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Collapsible Panel */
.panel.collapsible .panel-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    margin-bottom: 0;
    transition: margin-bottom 0.2s;
}

.panel.collapsible .panel-header:hover {
    color: #fff;
}

.panel.collapsible.expanded .panel-header {
    margin-bottom: 12px;
}

.panel.collapsible .collapse-icon {
    font-size: 10px;
    transition: transform 0.2s;
}

.panel.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.panel.collapsible .panel-content {
    overflow: hidden;
    transition: max-height 0.2s ease-out, opacity 0.2s;
    max-height: 500px;
    opacity: 1;
}

.panel.collapsible.collapsed .panel-content {
    max-height: 0;
    opacity: 0;
}

/* Scene Settings Panel */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-row label {
    color: #94a3b8;
    flex-shrink: 0;
}

.setting-row input[type="number"] {
    width: 80px;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    text-align: right;
}

.setting-row input[type="number"]:focus {
    border-color: #82bc00;
    outline: none;
}

/* Scene List */
#scene-list,
#hotspot-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scene-item,
.hotspot-item {
    background: #1a1a2e;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.scene-item:hover,
.hotspot-item:hover {
    background: #0f3460;
}

.scene-item.active {
    background: #0f3460;
    border-left: 3px solid #82bc00;
}

.scene-item .scene-name,
.hotspot-item .hotspot-name {
    font-size: 13px;
    font-weight: 500;
}

.scene-item .scene-duration {
    font-size: 11px;
    color: #64748b;
}

.hotspot-item .hotspot-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #82bc00;
    margin-right: 8px;
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.6);
}

/* Camera Info */
#camera-info {
    font-size: 12px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 4px 0;
}

.info-row label {
    color: #64748b;
}

.info-row span {
    font-family: monospace;
    color: #4ade80;
}

#capture-camera {
    width: 100%;
    margin-top: 10px;
    background: #0f3460;
    border: none;
    color: #fff;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

#capture-camera:hover {
    background: #1a4a7a;
}

/* Slide-out Panel (from right, overlays sidebar) */
.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: #16213e;
    border-left: 1px solid #0f3460;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

.slide-panel.hidden {
    transform: translateX(100%);
}

.slide-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #0f3460;
}

.slide-panel-header h3 {
    margin: 0;
    font-size: 16px;
    color: #fff;
}

.panel-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.panel-close:hover {
    color: #fff;
}

.slide-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.slide-panel-content .form-group {
    margin-bottom: 16px;
}

.slide-panel-content button {
    background: #0f3460;
    border: none;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.slide-panel-content button:hover {
    background: #1a4a7a;
}

.slide-panel-content button.capture-btn {
    background: #10b981;
}

.slide-panel-content button.capture-btn:hover {
    background: #34d399;
}

.slide-panel-footer {
    padding: 16px 20px;
    border-top: 1px solid #0f3460;
    display: flex;
    gap: 10px;
}

.slide-panel-footer button {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.slide-panel-footer button.primary {
    background: #e94560;
    color: #fff;
}

.slide-panel-footer button.primary:hover {
    background: #ff6b6b;
}

.slide-panel-footer button.danger {
    background: transparent;
    color: #ef4444;
    margin-left: auto;
}

.slide-panel-footer button:not(.primary):not(.danger) {
    background: #0f3460;
    color: #fff;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #16213e;
    padding: 24px;
    border-radius: 12px;
    min-width: 400px;
    max-width: 90%;
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 18px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #94a3b8;
    font-size: 13px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    color: #fff;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-group input[type="checkbox"] {
    margin-right: 8px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.modal-buttons button.primary {
    background: #e94560;
    color: #fff;
}

.modal-buttons button.danger {
    background: transparent;
    color: #ef4444;
    margin-left: auto;
}

.modal-buttons button:not(.primary):not(.danger) {
    background: #0f3460;
    color: #fff;
}

/* CSS2D Hotspot Labels */
.hotspot-label {
    background: rgba(233, 69, 96, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    pointer-events: auto;
    white-space: nowrap;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.hotspot-label:hover {
    background: rgba(255, 107, 107, 1);
    transform: scale(1.05);
}

.hotspot-label::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid rgba(233, 69, 96, 0.9);
}

/* Hotspot placement indicator */
.placement-indicator {
    position: fixed;
    pointer-events: none;
    background: rgba(74, 222, 128, 0.8);
    color: #000;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    z-index: 100;
}

/* Add Hotspot Mode Cursor */
#canvas-container.hotspot-mode {
    cursor: crosshair;
}

/* Move Hotspot Mode */
#canvas-container.move-mode {
    cursor: grab;
}

#canvas-container.move-mode.dragging {
    cursor: grabbing;
}

/* Light Edit Mode */
#canvas-container.light-edit-mode {
    cursor: crosshair;
}

#canvas-container.light-edit-mode.dragging {
    cursor: grabbing;
}

/* Anchor Setting Mode */
#canvas-container.anchor-mode {
    cursor: crosshair;
}

/* Light Panel Styles */
.light-group {
    background: #1e293b;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    border-left: 3px solid #64748b;
    transition: opacity 0.2s;
}

.light-group.disabled {
    opacity: 0.5;
}

.light-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.light-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Toggle switch */
.light-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.light-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #475569;
    border-radius: 20px;
    transition: 0.2s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

.light-toggle input:checked + .toggle-slider {
    background-color: #10b981;
}

.light-toggle input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

.light-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
}

.light-row span:first-child {
    width: 60px;
    color: #94a3b8;
    flex-shrink: 0;
}

.light-row input[type="range"] {
    flex: 1;
    min-width: 80px;
}

.light-row span:last-child {
    width: 35px;
    text-align: right;
    color: #fff;
    font-family: monospace;
}

.light-row .pos-input {
    width: 50px;
    padding: 4px 6px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    text-align: center;
}

.light-row .pos-input:focus {
    border-color: #3b82f6;
    outline: none;
}

.light-total {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    padding: 10px;
    background: #0f172a;
    border-radius: 6px;
    margin-top: 10px;
}

.light-total span {
    color: #fff;
    font-weight: 600;
}

/* Light type select dropdown */
.light-type-select {
    flex: 1;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #fff;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.light-type-select:focus {
    border-color: #3b82f6;
    outline: none;
}

.light-type-select option {
    background: #0f172a;
    color: #fff;
}

/* Spotlight controls container */
.spotlight-controls {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #334155;
}

.spotlight-controls .light-row {
    margin-top: 4px;
}

.spotlight-controls .light-row span:first-child {
    width: 70px;
    color: #60a5fa;
}

/* Add Light Button */
.add-light-section {
    margin: 15px 0;
    text-align: center;
}

.add-light-btn {
    background: #10b981;
    border: none;
    color: #fff;
    padding: 10px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, transform 0.1s;
    width: 100%;
}

.add-light-btn:hover {
    background: #34d399;
    transform: scale(1.02);
}

.add-light-btn:active {
    transform: scale(0.98);
}

/* Dynamic Lights List */
.lights-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Dynamic Light Item */
.light-item {
    background: #1e293b;
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid #64748b;
    transition: opacity 0.2s;
}

.light-item.disabled {
    opacity: 0.5;
}

.light-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.light-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.light-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
}

.light-item-header .light-enable {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.light-delete-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1;
}

.light-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Light item rows */
.light-item .light-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
}

.light-item .light-row > span:first-child {
    width: 60px;
    color: #94a3b8;
    flex-shrink: 0;
}

.light-item .light-intensity {
    flex: 1;
    min-width: 60px;
}

.light-item .light-intensity-value {
    width: 40px;
    text-align: right;
    color: #fff;
    font-family: monospace;
}

.light-position-row input {
    width: 45px;
    padding: 4px 6px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    text-align: center;
}

.light-position-row input:focus {
    border-color: #3b82f6;
    outline: none;
}

.light-item .light-type-select {
    flex: 1;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #fff;
    padding: 4px 8px;
    font-size: 11px;
}

.light-spot-controls {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #334155;
}

.light-spot-controls .light-angle {
    flex: 1;
    min-width: 60px;
}

.light-spot-controls .light-angle-value {
    width: 35px;
    text-align: right;
    color: #60a5fa;
    font-family: monospace;
}

/* Draggable hotspot styling */
.hotspot-label.draggable {
    cursor: grab;
    border: 2px dashed rgba(255, 255, 255, 0.5);
}

.hotspot-label.draggable:hover {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.8);
}

.hotspot-label.dragging {
    cursor: grabbing;
    opacity: 0.8;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(74, 222, 128, 1);
}

/* Status Messages */
.status-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(74, 222, 128, 0.9);
    color: #000;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    z-index: 1000;
    animation: fadeInOut 3s ease-in-out forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    10% { opacity: 1; transform: translateX(-50%) translateY(0); }
    90% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 20px;
    color: #64748b;
    font-size: 13px;
}

/* Description Panel - Slide up from bottom (both desktop and mobile) */
.description-panel {
    position: fixed;
    z-index: 200;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50vh;
    max-height: 400px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.5);
    overflow-y: auto;
}

@supports (-webkit-backdrop-filter: none) or (backdrop-filter: none) {
    .description-panel {
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
}

.description-panel.visible {
    transform: translateY(0);
}

/* Description panel text colors */
.description-close {
    background: #f3f4f6;
    color: #111827;
}

.description-close:hover {
    background: #e5e7eb;
}

.description-title {
    color: #111827;
    border-bottom: 1px solid #e5e7eb;
}

.description-content {
    color: #374151;
    overflow-y: auto;
}

.description-content a {
    color: #059669;
}

.description-close {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.description-title {
    padding: 20px 20px 12px;
    font-size: 18px;
    font-weight: 600;
    margin-right: 40px; /* Space for close button */
}

.description-content {
    margin: 0;
    padding: 0;
    font-size: 15px;
    line-height: 1.6;
}

.description-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
}

.description-content a {
    text-decoration: none;
}

.description-content a:hover {
    text-decoration: underline;
}

/* ============================================
   EDITOR UI - Hidden by default, shown in editor mode
   ============================================ */
#toolbar,
#sidebar,
.slide-panel {
    display: none;
}

.editor-mode #toolbar {
    display: flex;
}

.editor-mode #sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 280px;
}

.editor-mode .slide-panel {
    display: flex;
}

/* ============================================
   VIEW MODE (default) - Full viewport canvas
   ============================================ */
html,
body {
    margin: 0 !important;
    padding: 0 !important;
}

/* View mode specific - only apply fixed positioning when NOT in editor mode */
html:not(.editor-mode),
body:not(.editor-mode) {
    overflow: hidden;
    width: 100%;
    height: 100%;
    /* Prevent iOS bounce scrolling */
    position: fixed;
    -webkit-overflow-scrolling: touch;
}

body:not(.editor-mode) #app,
body:not(.editor-mode) #main-container {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

body:not(.editor-mode) #canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Fallback for browsers without dvh support */
@supports not (height: 100dvh) {
    body:not(.editor-mode) #canvas-container {
        /* Use -webkit-fill-available for iOS Safari */
        height: -webkit-fill-available;
    }
}

/* ============================================
   EDITOR MODE - Restore layout
   ============================================ */
html.editor-mode,
.editor-mode body {
    position: static;
    overflow: visible;
    width: auto;
    height: auto;
}

.editor-mode #app,
.editor-mode #main-container {
    overflow: visible;
    width: auto;
    height: auto;
}

.editor-mode #app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.editor-mode #main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-mode #canvas-container {
    position: relative;
    flex: 1;
    width: auto;
    height: auto;
}

/* ============================================
   VIEW MODE CONTROLS
   ============================================ */
#view-controls {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    gap: 8px;
}

#view-controls button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#view-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    color: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

#view-controls button:active {
    transform: scale(0.95);
}

#view-controls button svg {
    width: 20px;
    height: 20px;
}

/* Hide view controls in editor mode */
.editor-mode #view-controls {
    display: none;
}

/* ============================================
   MOBILE & RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Use dynamic viewport height for mobile (handles browser chrome) */
@supports (height: 100dvh) {
    body:not(.editor-mode) #canvas-container {
        height: 100dvh;
    }

    #app {
        height: 100dvh;
    }
}

/* Mobile viewport fixes */
@media screen and (max-width: 768px) {
    /* View controls - slightly smaller on mobile */
    #view-controls {
        top: 12px;
        right: 12px;
    }

    #view-controls button {
        width: 36px;
        height: 36px;
    }

    #view-controls button svg {
        width: 18px;
        height: 18px;
    }

    /* Modal adjustments */
    .modal-content {
        min-width: auto;
        width: 90%;
        max-width: 400px;
        margin: 20px;
    }

    /* Slide panel full width on mobile */
    .slide-panel {
        width: 100%;
    }
}

/* Very small screens (phones in portrait) */
@media screen and (max-width: 480px) {
    .description-panel {
        max-height: 60vh;
    }

    .description-title {
        font-size: 16px;
        padding: 16px 16px 10px;
    }

    .description-content {
        font-size: 14px;
        padding: 0;
    }
}

/* Landscape mobile - more horizontal space */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .description-panel {
        max-height: 70vh;
    }

    #view-controls {
        top: 8px;
        right: 8px;
    }

    #view-controls button {
        width: 32px;
        height: 32px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    #view-controls button {
        width: 44px;
        height: 44px;
    }

    /* Remove hover effects that don't work on touch */
    #view-controls button:hover {
        transform: none;
        background: rgba(255, 255, 255, 0.15);
    }

    #view-controls button:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0.95);
    }
}

/* ============================================
   PREVIEW MODAL
   ============================================ */
#preview-modal {
    background: rgba(0, 0, 0, 0.9);
}

.preview-container {
    display: flex;
    flex-direction: column;
    width: 95vw;
    height: 95vh;
    max-width: 1400px;
    background: #1a1a2e;
    border-radius: 12px;
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
}

.preview-header h3 {
    margin: 0;
    font-size: 16px;
    color: #fff;
}

.preview-size-buttons {
    display: flex;
    gap: 8px;
}

.preview-size-btn {
    background: #0f3460;
    border: none;
    color: #94a3b8;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.preview-size-btn:hover {
    background: #1a4a7a;
    color: #fff;
}

.preview-size-btn.active {
    background: #82bc00;
    color: #000;
}

.preview-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d0d1a;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

#preview-iframe {
    background: #fff;
    border: none;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: width 0.3s ease, height 0.3s ease;
}

/* Full mode - fill the viewport */
#preview-iframe.full-size {
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
}

.preview-info {
    display: flex;
    justify-content: center;
    padding: 10px;
    background: #16213e;
    border-top: 1px solid #0f3460;
}

#preview-dimensions {
    font-size: 13px;
    color: #64748b;
    font-family: monospace;
}

/* Device frame styling for preview */
.preview-viewport::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}
