:root {
    --bg-dark: #050508;
    --panel-bg: rgba(18, 18, 24, 0.95);
    --accent: #00f2ff;
    --text-main: #e0e0e0;
    --text-dim: #888;
    --border: rgba(255, 255, 255, 0.1);
    --sidebar-width: 320px;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main);
    user-select: none;
    padding-top: 32px; /* Space for menubar */
    touch-action: pan-x pan-y; /* Allow panning but prevent pinch-zoom */
}

/* Utility */
.hidden {
    display: none !important;
}

/* Menubar Header */
#menubar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 32px;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 200;
}

.menubar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 4px;
    cursor: pointer;
    border-radius: 3px;
    transition: color 0.15s, background-color 0.15s;
}

.back-button:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
}

.back-button svg {
    display: block;
}

.app-title {
    color: var(--text-main);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.menubar-divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 4px;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
}

.dropdown-trigger {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.75rem;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
    font-family: inherit;
    transition: background-color 0.15s;
}

.dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: rgba(30, 30, 35, 0.98);
    border: 1px solid var(--border);
    border-radius: 4px;
    min-width: 160px;
    padding: 4px 0;
    z-index: 300;
    backdrop-filter: blur(10px);
}

.dropdown-menu.hidden {
    display: none;
}

.dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 6px 12px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.15s;
    font-family: inherit;
}

.dropdown-item .shortcut {
    margin-left: auto;
    padding-left: 16px;
    color: var(--text-dim);
    font-size: 0.7rem;
    opacity: 0.7;
}

.dropdown-item:hover:not(:disabled):not(.disabled) {
    background-color: rgba(255, 255, 255, 0.08);
}

.dropdown-item:disabled,
.dropdown-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--text-dim);
}

.dropdown-item:disabled:hover,
.dropdown-item.disabled:hover {
    background-color: transparent;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Dropdown loading indicator */
.dropdown-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-dim);
    font-size: 12px;
}

.dropdown-loading.hidden {
    display: none;
}

.dropdown-loading i {
    color: var(--accent);
}

/* Dropdown status text */
.dropdown-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    color: var(--text-dim);
    font-size: 10px;
    opacity: 0.7;
}

.dropdown-status.hidden {
    display: none;
}

.dropdown-status i {
    font-size: 9px;
}

.dropdown-status.error {
    color: var(--error, #ff6b6b);
    opacity: 1;
}

.dropdown-status.error i {
    color: var(--error, #ff6b6b);
}

/* Submenu */
.dropdown-submenu {
    position: relative;
}

.dropdown-item.has-submenu {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-item.has-submenu::after {
    content: '▶';
    font-size: 0.5rem;
    margin-left: 8px;
    opacity: 0.6;
}

.submenu {
    position: absolute;
    top: -4px;
    left: 100%;
    background: rgba(30, 30, 35, 0.98);
    border: 1px solid var(--border);
    border-radius: 4px;
    min-width: 140px;
    padding: 4px 0;
    z-index: 301;
    backdrop-filter: blur(10px);
    display: none;
}

.dropdown-submenu:hover > .submenu {
    display: block;
}

.menubar-right {
    display: flex;
    align-items: center;
}

.user-widget {
    position: relative;
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 2px 4px;
}

#user-name {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-main);
}

.user-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--accent);
    color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    font-size: 0.65rem;
    user-select: none;
}

.user-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: rgba(30, 30, 35, 0.95);
    border: 1px solid var(--border);
    border-radius: 4px;
    min-width: 120px;
    padding: 2px 0;
    z-index: 300;
    backdrop-filter: blur(10px);
}

.user-menu.hidden {
    display: none;
}

.user-menu .menu-item {
    display: block;
    width: 100%;
    padding: 6px 12px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.15s;
    font-family: inherit;
}

.user-menu .menu-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Viewport Controls Overlay */
#viewport-controls {
    position: fixed;
    top: 42px; /* Below menubar */
    right: var(--sidebar-width); /* Left of sidebar */
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 100;
    padding: 8px;
    transition: right 0.3s ease-in-out;
}

#viewport-controls select {
    background: rgba(30, 30, 40, 0.9);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-main);
    font-size: 0.75rem;
    padding: 4px 8px;
    cursor: pointer;
    font-family: inherit;
    min-width: 90px;
    backdrop-filter: blur(10px);
    transition: border-color 0.15s, background-color 0.15s;
}

#viewport-controls select:hover {
    background: rgba(40, 40, 50, 0.95);
    border-color: rgba(255, 255, 255, 0.2);
}

#viewport-controls select:focus {
    outline: none;
    border-color: var(--accent);
}

#viewport-controls select option {
    background: #1a1a24;
    color: var(--text-main);
}

/* ViewHelper (3D Axis Gizmo) - Positioned programmatically in ViewportManager
   This div is kept for potential future use but positioning is handled in JS */
#view-helper {
    /* Position is calculated dynamically in ViewportManager.renderViewHelper() */
    /* to be below viewport-controls and responsive to sidebar */
    pointer-events: none; /* Clicks are handled via renderer.domElement */
}

/* Sidebar UI */
#sidebar {
    position: absolute;
    top: 32px;
    right: 0;
    width: 320px;
    height: calc(100vh - 32px - 24px); /* subtract status bar */
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border);
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    z-index: 100;
    transition: transform 0.3s ease-in-out;
}

#sidebar.hidden {
    transform: translateX(100%);
}

#sidebar > div {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Scene Outliner - scrollable top panel */
#scene-outliner {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 80px;
    max-height: 50%;
    overflow: hidden;
}

#scene-outliner .outliner-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding-right: 4px;
}

#scene-outliner .outliner-scroll-area::-webkit-scrollbar {
    width: 6px;
}

#scene-outliner .outliner-scroll-area::-webkit-scrollbar-track {
    background: transparent;
}

#scene-outliner .outliner-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

#scene-outliner .outliner-scroll-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Outliner Search */
.outliner-search-wrapper {
    padding: 6px 0;
    flex-shrink: 0;
}

.outliner-search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 8px;
    color: var(--text-main);
    font-size: 11px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, background-color 0.2s;
    font-family: inherit;
}

.outliner-search-input::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

.outliner-search-input:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
}

/* Sidebar Resize Handle */
.sidebar-resize-handle {
    flex-shrink: 0;
    height: 6px;
    cursor: row-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px 0;
    border-radius: 3px;
    transition: background-color 0.15s;
}

.sidebar-resize-handle::after {
    content: '';
    width: 32px;
    height: 2px;
    background: var(--border);
    border-radius: 1px;
    transition: background-color 0.15s, width 0.15s;
}

.sidebar-resize-handle:hover::after,
.sidebar-resize-handle.dragging::after {
    background: var(--accent);
    width: 48px;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
    background: rgba(255, 255, 255, 0.03);
}

/* Inspector Panel - scrollable */
#scene-inspector {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 80px;
    overflow: hidden;
}

#scene-inspector .control-group {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding-right: 4px;
}

#scene-inspector .control-group::-webkit-scrollbar {
    width: 6px;
}

#scene-inspector .control-group::-webkit-scrollbar-track {
    background: transparent;
}

#scene-inspector .control-group::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

#scene-inspector .control-group::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Inspector collapsible sections */
#inspector-content .collapsible-section {
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
    min-height: 0;
    flex: 0 0 auto;
    overflow: hidden;
}

#inspector-content .section-header {
    padding: 8px 10px;
    min-height: 16px;
    background: rgba(30, 30, 40, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

#inspector-content .section-header:hover {
    background: rgba(40, 40, 55, 0.6);
}

#inspector-content .section-header .section-title {
    margin: 0;
    font-size: 0.65rem;
    opacity: 1;
}

#inspector-content .section-header .collapse-icon {
    font-size: 0.5rem;
    opacity: 0.5;
    transition: transform 0.2s ease;
}

#inspector-content .collapsible-section.collapsed .section-header .collapse-icon {
    transform: rotate(-90deg);
}

#inspector-content .collapsible-section.collapsed .section-header {
    border-bottom-color: transparent;
}

#inspector-content .collapsible-content {
    padding: 8px 10px 10px 10px;
    max-height: 300px;
    opacity: 1;
    transition: max-height 0.2s ease, opacity 0.15s ease, padding 0.2s ease;
}

#inspector-content .collapsible-section.collapsed .collapsible-content {
    max-height: 0;
    opacity: 0;
    padding: 0 10px;
    overflow: hidden;
}

/* Left Toolbar */
#left-toolbar {
    position: absolute;
    top: 52px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    z-index: 95;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 7px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.toolbar-separator {
    height: 1px;
    width: 100%;
    background: var(--border);
    opacity: 0.5;
    margin: 2px 0;
}

.toolbar-btn {
    width: 27px;
    height: 27px;
    min-width: 27px;
    min-height: 27px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7px;
    font-weight: 600;
    padding: 0;
    transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
    font-family: inherit;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.15);
}

.toolbar-btn.active {
    background: rgba(0, 242, 255, 0.15);
    border-color: var(--accent);
}

.toolbar-btn.active .toolbar-icon {
    color: var(--accent);
}

.toolbar-icon {
    color: var(--text-main);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-icon svg {
    width: 11px;
    height: 11px;
}

.toolbar-icon.fas,
.toolbar-icon.far {
    font-size: 11px;
    line-height: 1;
    width: auto;
    height: auto;
}

.toolbar-btn:hover .toolbar-icon {
    color: var(--accent);
}

.toolbar-space-toggle {
    position: relative;
}

.toolbar-space-toggle .toolbar-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.toolbar-space-toggle .toolbar-icon.hidden {
    display: none;
}

/* Top Data HUD */
#data-hud {
    position: absolute;
    top: 20px;
    left: 100px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 90;
}


/* Asset list */
.asset-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Outliner tree - DCC-style */
.outliner-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

.outliner-item {
    margin: 0;
    padding: 0;
}

.outliner-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 0;
    padding-right: 8px;
    background: transparent;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
    color: var(--text-dim);
    transition: background-color 0.1s, color 0.1s;
    min-height: 20px;
}

.outliner-row:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.outliner-row.selected {
    background: rgba(0, 242, 255, 0.2);
    color: var(--accent);
    font-weight: 600;
    border: none;
    box-shadow: none;
}

.outliner-row.selected:hover {
    background: rgba(0, 242, 255, 0.25);
    color: var(--accent);
}

.outliner-toggle {
    width: 14px;
    height: 14px;
    min-width: 14px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

.outliner-row:hover .outliner-toggle {
    opacity: 0.9;
    color: var(--text-main);
}

.outliner-row.selected .outliner-toggle {
    color: var(--accent);
    opacity: 1;
}

.outliner-toggle:disabled {
    opacity: 0;
    cursor: default;
    pointer-events: none;
}

/* Spacer for items without children - handled via JS inline style */

.outliner-label {
    color: inherit;
    font-weight: inherit;
    font-size: 12px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
    cursor: pointer;
    padding: 2px 0;
}

.outliner-row.selected .outliner-label {
    font-weight: 600;
}

.outliner-row.drag-over {
    background: rgba(0, 242, 255, 0.1);
    border-left: 2px solid var(--accent);
}

.outliner-row.drag-over-inside {
    background: rgba(0, 242, 255, 0.15);
    border-left: 3px solid var(--accent);
    box-shadow: inset 0 0 8px rgba(0, 242, 255, 0.2);
}

.outliner-row.drag-over-child {
    border-left: 2px solid rgba(0, 242, 255, 0.5);
}

.outliner-visibility {
    width: 18px;
    height: 18px;
    min-width: 18px;
    padding: 0;
    margin: 0 4px 0 0;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

.outliner-row:hover .outliner-visibility {
    opacity: 0.9;
    color: var(--text-main);
}

.outliner-row.selected .outliner-visibility {
    color: var(--accent);
    opacity: 1;
}

.outliner-visibility.is-hidden {
    opacity: 0.7;
}

.outliner-visibility.is-hidden:hover {
    opacity: 1;
}

/* Ensure hidden eye icon is visible on selected rows */
.outliner-row.selected .outliner-visibility.is-hidden {
    opacity: 0.8;
    color: var(--bg-darker);
}

.outliner-row.selected .outliner-visibility.is-hidden:hover {
    opacity: 1;
}

/* Inspector visibility toggle */
.inspector-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-darker);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s;
}

.inspector-toggle:hover {
    background: var(--bg-lighter);
    border-color: var(--accent);
}

.inspector-toggle.is-hidden {
    opacity: 0.6;
    color: var(--text-dim);
}

.outliner-label.editing {
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--accent);
    border-radius: 2px;
}

.outliner-label input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    padding: 2px 4px;
    outline: none;
    font-family: inherit;
}

.outliner-rename-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--accent);
    border-radius: 2px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    padding: 2px 4px;
    outline: none;
    font-family: inherit;
}

/* Inspector Styles */
.inspector-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
}

.inspector-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
    box-sizing: border-box;
}

.inspector-section-title {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.inspector-field {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.inspector-field label {
    font-size: 11px;
    color: var(--text-dim);
    min-width: 16px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inspector-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 6px;
    color: var(--text-main);
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
    font-family: inherit;
    box-sizing: border-box;
}

.inspector-input:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

.inspector-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.2);
}

.inspector-number {
    font-family: monospace;
    color: var(--accent);
    font-weight: 600;
    text-align: right;
    -moz-appearance: textfield;
}

/* Hide number input spinners */
.inspector-number::-webkit-outer-spin-button,
.inspector-number::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.inspector-xyz-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

.inspector-toggle {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s;
}

.inspector-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

.inspector-toggle.hidden {
    opacity: 0.3;
}

.hud-card {
    background: var(--panel-bg);
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid var(--border);
    min-width: 160px;
}

.hud-card span {
    font-size: 9px;
    text-transform: uppercase;
    color: var(--text-dim);
    display: block;
    letter-spacing: 1px;
}

.hud-card b {
    font-size: 16px;
    color: var(--accent);
    font-family: monospace;
}

/* Sidebar Toggle Button (next to viewport controls) */
.sidebar-toggle-btn {
    background: rgba(30, 30, 40, 0.9);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-main);
    cursor: pointer;
    font-family: inherit;
    padding: 4px 8px;
    min-width: 24px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}

.sidebar-toggle-btn:hover {
    background: rgba(40, 40, 50, 0.95);
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-toggle-btn:active {
    transform: scale(0.95);
}

.sidebar-toggle-icon {
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    transition: transform 0.3s ease-in-out;
    display: inline-block;
}

h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
}



/* Modal Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    width: 100%;
    max-width: 520px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.template-manager-modal {
    max-width: 1100px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.template-manager-modal .modal-body {
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.modal-close {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text-main);
    cursor: pointer;
    font-size: 20px;
    line-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

.modal-body {
    padding: 18px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

.section-title {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 15px;
    opacity: 0.7;
}

/* Collapsible Section */
.collapsible-section {
    margin-top: 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    display: block;
    min-height: 44px;
    /* Ensure it doesn't shrink in flex container */
    flex: 0 0 auto;
    width: 100%;
    /* Use overflow hidden to contain the slide animation and prevent overlay */
    overflow: hidden;
    box-sizing: border-box;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    background: rgba(30, 30, 40, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 20px;
    box-sizing: content-box; /* Ensure padding adds to height if needed */
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.15); /* Distinct hover state */
}

.section-header:active {
    background: rgba(255, 255, 255, 0.2);
}

.section-header .section-title {
    margin: 0;
    opacity: 1; /* Full opacity */
    color: #fff; /* White text for visibility */
    font-weight: 600;
}

.collapse-icon {
    font-size: 10px;
    color: var(--accent);
    transition: transform 0.3s ease;
}

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

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

.collapsible-section.collapsed .collapsible-content {
    max-height: 0;
    opacity: 0;
    padding: 0 16px;
}

.collapsible-content > .control-group {
    margin: 12px 0;
    margin-bottom: 12px;
}

.collapsible-content > .control-group:last-child {
    margin-bottom: 0;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.val-box {
    color: var(--accent);
    font-family: monospace;
    font-weight: bold;
    font-size: 0.9rem;
}

.val-input {
    color: var(--accent);
    font-family: monospace;
    font-weight: bold;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    width: 70px;
    text-align: right;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
}

.val-input:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

.val-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.2);
}

.val-input::-webkit-inner-spin-button,
.val-input::-webkit-outer-spin-button {
    opacity: 1;
    cursor: pointer;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.btn-toggle {
    background: #222;
    border: 1px solid var(--border);
    color: white;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    flex: 1;
}

.btn-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    background: #222;
    border: 1px solid var(--border);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    padding: 0;
}

.btn-icon:hover {
    background: #2c2c2c;
}

.btn-danger {
    background: #3a0d0d;
    border-color: #ff4444;
    color: #ffdddd;
}

.btn-danger:hover {
    background: #520f0f;
}

.btn-active {
    background: var(--accent);
    color: #000;
    font-weight: bold;
    border-color: var(--accent);
}

.button-row {
    display: flex;
    gap: 10px;
}

.button-row-template {
    margin-top: 8px;
    align-items: center;
}

.template-form-row {
    margin-top: 8px;
}

.template-form-row-checkbox {
    align-items: center;
}

.template-form-actions {
    margin-top: 12px;
}

.confirm-message {
    margin: 0;
    color: var(--text-main);
    line-height: 1.4;
}

.delete-message {
    margin: 0;
}

.delete-modal-footer {
    margin-top: 16px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.hidden-input {
    display: none;
}

.shortcut-hint {
    opacity: 0.5;
}

.template-table {
    width: 100%;
}

.mode-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 0;
}

.mode-btn {
    flex: 1;
    text-transform: uppercase;
    font-weight: 700;
}

.mode-active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.sidebar-separator {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
    opacity: 0.5;
}

canvas {
    display: block;
    outline: none;
    cursor: crosshair;
}

/* Viewport canvas - disable browser gestures, allow custom handling */
canvas[data-viewport="true"] {
    touch-action: none; /* Disable all browser touch gestures - we handle them */
}

#error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: #ff4444;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    text-align: center;
    padding: 20px;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease-out;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#loading-overlay.removed {
    display: none;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loading-spinner-large {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color, #333);
    border-top-color: var(--accent-color, #7c5cff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-message {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary, #fff);
}

.loading-submessage {
    font-size: 0.875rem;
    color: var(--text-dim, #888);
    min-height: 1.25em;
}

/* Status Bar */
#status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24px;
    background: var(--panel-bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 10px;
    color: var(--text-dim);
    z-index: 100;
    user-select: none;
}

.status-bar-left,
.status-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-divider {
    opacity: 0.3;
}

.status-hint {
    opacity: 0.6;
}

#status-selection {
    color: var(--accent);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#status-cursor-pos {
    font-family: monospace;
    font-size: 9px;
    min-width: 120px;
    text-align: right;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: rgba(25, 25, 32, 0.98);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-width: 180px;
    padding: 4px 0;
    z-index: 500;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.context-menu.hidden {
    display: none;
}

.context-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 7px 14px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.1s;
    font-family: inherit;
    gap: 16px;
}

.context-menu-item:hover {
    background: rgba(0, 242, 255, 0.1);
}

.context-menu-item .shortcut {
    color: var(--text-dim);
    font-size: 0.65rem;
    opacity: 0.7;
}

.context-menu-item.danger {
    color: #ff6b6b;
}

.context-menu-item.danger:hover {
    background: rgba(255, 68, 68, 0.1);
}

.context-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.footer-text {
    margin-top: auto;
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
    opacity: 0.5;
}

.hint-text {
    font-size: 10px;
    color: #666;
}

/* Cabinet Management Styles */
.cabinet-select {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.cabinet-select:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

.cabinet-select:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.2);
}

.template-input {
    width: 100%;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    box-sizing: border-box;
}

.template-input:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

.template-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.2);
}

.template-input::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-dark);
    padding: 20px;
}

.login-card {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-title {
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 12px;
}

.login-subtitle {
    margin: 0 0 32px 0;
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.login-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, background-color 0.2s;
}

.login-input:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

.login-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.2);
}

.login-input::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

.login-btn {
    width: 100%;
    padding: 12px 24px;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: #000;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.login-btn:hover:not(:disabled) {
    background: #00d9e6;
    transform: translateY(-1px);
}

.login-btn:active:not(:disabled) {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-message {
    padding: 12px 16px;
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 6px;
    color: #ff6b6b;
    font-size: 0.85rem;
    text-align: center;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Logout Button Styles */
.logout-btn {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.3);
    color: #ff6b6b;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background-color 0.2s, border-color 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 68, 68, 0.2);
    border-color: rgba(255, 68, 68, 0.5);
}

/* Toast Notification System */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    min-width: 280px;
    max-width: 400px;
}

.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-hide {
    opacity: 0;
    transform: translateX(100%);
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-main);
    line-height: 1.4;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-main);
}

/* Toast Type Colors */
.toast-success {
    border-left: 3px solid #4ade80;
}

.toast-success .toast-icon {
    color: #4ade80;
}

.toast-error {
    border-left: 3px solid #f87171;
}

.toast-error .toast-icon {
    color: #f87171;
}

.toast-info {
    border-left: 3px solid #60a5fa;
}

.toast-info .toast-icon {
    color: #60a5fa;
}

.toast-warning {
    border-left: 3px solid #fbbf24;
}

.toast-warning .toast-icon {
    color: #fbbf24;
}

/* ============================================
   DRAG AND DROP OVERLAY
   ============================================ */

.drag-drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 242, 255, 0.1);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
}

.drag-drop-overlay.hidden {
    display: none;
}

.drag-drop-content {
    text-align: center;
    color: var(--accent);
}

.drag-drop-icon {
    margin-bottom: 16px;
}

.drag-drop-icon svg {
    stroke: var(--accent);
}

.drag-drop-text h3 {
    font-size: 1.5rem;
    margin: 0 0 8px 0;
    font-weight: 500;
}

.drag-drop-text p {
    font-size: 0.875rem;
    margin: 0;
    opacity: 0.8;
}

/* ============================================
   MODAL SYSTEM
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Asset Import Modal should appear above Asset Browser Modal */
#asset-import-modal {
    z-index: 1001;
}

/* Asset Browser Modal */
#asset-browser-modal {
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-container {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
    color: var(--text-main);
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* ============================================
   ASSET IMPORT MODAL
   ============================================ */

.asset-import-modal {
    width: 900px;
    max-width: 95vw;
}

.asset-import-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 20px;
}

/* Preview Panel */
.asset-preview-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.asset-preview-viewport {
    width: 100%;
    aspect-ratio: 1;
    background: #1a1a2e;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.asset-preview-viewport canvas {
    width: 100% !important;
    height: 100% !important;
}

.asset-preview-controls {
    display: flex;
    gap: 8px;
}

.asset-preview-info {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
}

/* Form Panel */
.asset-form-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 500;
}

.form-group .required {
    color: #f87171;
}

.form-input,
.form-select,
.form-textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text-main);
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-input:disabled,
.form-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.form-select {
    cursor: pointer;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button .form-select {
    flex: 1;
}

/* File Upload Area */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 6px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.file-upload-area:hover {
    border-color: var(--accent);
    background: rgba(0, 242, 255, 0.05);
}

.file-upload-area.drag-over {
    border-color: var(--accent);
    background: rgba(0, 242, 255, 0.1);
}

.file-upload-area.has-file {
    border-style: solid;
    border-color: var(--accent);
}

.file-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-upload-icon {
    font-size: 2rem;
}

.file-upload-text {
    font-size: 0.875rem;
    color: var(--text-dim);
}

.has-file .file-upload-text {
    color: var(--accent);
}

/* Version Section */
.version-section {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.version-info {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin-top: 8px;
}

/* Inline Dialogs */
.inline-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 40, 0.98);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    z-index: 1001;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.inline-dialog.hidden {
    display: none;
}

.inline-dialog-content h4 {
    margin: 0 0 12px 0;
    font-size: 0.875rem;
    font-weight: 500;
}

.inline-dialog-content .form-input {
    width: 200px;
    margin-bottom: 12px;
}

.inline-dialog-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ============================================
   ASSET BROWSER MODAL
   ============================================
   All Asset Browser Modal styles have been moved to modals.css
   to avoid duplication and maintainability issues.
   ============================================ */

/* ============================================
   BUTTONS
   ============================================ */

.btn-primary,
.btn-secondary {
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-primary:hover:not(:disabled) {
    background: #00d4e0;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-warning {
    background: #ffa500;
    color: #000;
    border: 1px solid #ff8c00;
}

.btn-warning:hover:not(:disabled) {
    background: #ffb733;
    border-color: #ffa500;
}

.btn-warning:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-main);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-add {
    font-size: 1.25rem;
    font-weight: 300;
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   HIDDEN UTILITY
   ============================================ */

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

/* ============================================
   MEASURER TOOL OVERLAY
   ============================================ */

.measurer-overlay {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.measurer-overlay.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
}

.measurer-help-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(18, 18, 24, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.measurer-help-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 6px;
    color: #000;
    font-size: 14px;
}

.measurer-help-text {
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 500;
}

.measurer-help-hint {
    color: var(--text-dim);
    font-size: 0.75rem;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

/* ============================================
   MULTI-USER COLLABORATION STYLES
   ============================================ */

/* Multi-User Menu Icon */
.multiuser-icon {
    margin-right: 6px;
    font-size: 0.75rem;
}

.room-status-badge {
    background: var(--accent);
    color: #000;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

/* Session Panel */
.session-panel {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 0 1 auto;
    max-height: 50vh;
}

.session-panel.hidden {
    display: none;
}

.session-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.session-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.8125rem;
}

.session-panel-title i {
    font-size: 0.875rem;
}

.session-panel-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.session-panel-close:hover {
    background: var(--hover);
    color: var(--text-main);
}

.session-panel-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

/* Custom scrollbar for session panel */
.session-panel-content::-webkit-scrollbar {
    width: 6px;
}

.session-panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.session-panel-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.session-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

.session-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.75rem;
}

.session-label {
    color: var(--text-dim);
}

.session-id {
    color: var(--text-main);
    font-family: monospace;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Users Section */
.session-users-section {
    margin-bottom: 12px;
}

.session-users-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.user-count {
    background: var(--hover);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.session-users-list {
    list-style: none;
    padding: 0;
    margin: 0;
    /* Remove fixed max-height since parent is now scrollable */
}

.session-user-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.8125rem;
    transition: background 0.15s ease;
}

.session-user-item:hover {
    background: var(--hover);
}

.session-user-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.session-user-name {
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-user-name i {
    color: #ffd700;
    font-size: 0.625rem;
}

/* Options Section */
.session-options-section {
    margin-bottom: 12px;
}

.session-section-header {
    font-size: 0.6875rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.session-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.8125rem;
    color: var(--text-main);
    cursor: pointer;
}

.session-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

/* Action Buttons */
.session-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.session-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.session-btn i {
    font-size: 0.8125rem;
}

.session-btn-save {
    background: var(--accent);
    color: #000;
    flex: 1;
}

.session-btn-save:hover {
    filter: brightness(1.1);
}

.session-btn-leave {
    background: var(--hover);
    color: var(--text-main);
}

.session-btn-leave:hover {
    background: var(--surface-raised);
}

.session-btn-close {
    background: #dc3545;
    color: #fff;
    width: 100%;
}

.session-btn-close:hover {
    filter: brightness(1.1);
}

/* Activity Panel */
.activity-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 320px;
    max-height: 300px;
    background: rgba(18, 18, 24, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.activity-panel.hidden {
    display: none;
}

.activity-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    cursor: move;
    user-select: none;
}

.activity-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.8125rem;
}

.activity-panel-title i {
    color: var(--accent);
}

.activity-panel-controls {
    display: flex;
    gap: 4px;
}

.activity-panel-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    transition: all 0.15s ease;
}

.activity-panel-btn:hover {
    background: var(--hover);
    color: var(--text-main);
}

.activity-panel-content {
    flex: 1;
    overflow: hidden;
}

.activity-panel-content.hidden {
    display: none;
}

.activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 220px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border-dim);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-time {
    color: var(--text-dim);
    font-family: monospace;
    font-size: 0.6875rem;
    flex-shrink: 0;
}

.activity-icon {
    font-size: 0.75rem;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.activity-message {
    color: var(--text-main);
    flex: 1;
    word-break: break-word;
}

/* Activity type colors */
.activity-join .activity-icon { color: #4ade80; }
.activity-leave .activity-icon { color: #f87171; }
.activity-edit .activity-icon { color: var(--text-dim); }
.activity-save .activity-icon { color: var(--accent); }
.activity-error .activity-icon { color: #f59e0b; }
.activity-sync .activity-icon { color: #60a5fa; }
.activity-room .activity-icon { color: #a78bfa; }

.activity-error {
    background: rgba(245, 158, 11, 0.1);
}

/* Save Revision Modal */
.save-revision-modal {
    width: 400px;
}

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

.save-revision-modal label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    color: var(--text-main);
}

.save-revision-modal .required {
    color: #dc3545;
}

.save-revision-modal textarea {
    width: 100%;
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.875rem;
    resize: vertical;
    transition: border-color 0.15s ease;
}

.save-revision-modal textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.save-revision-modal textarea.error {
    border-color: #dc3545;
}

.save-revision-modal .form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.6875rem;
    color: var(--text-dim);
}

.save-revision-modal .version-info {
    background: var(--bg);
    border-radius: 6px;
    padding: 12px;
}

.save-revision-modal .info-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    padding: 4px 0;
}

.save-revision-modal .info-label {
    color: var(--text-dim);
}

.save-revision-modal .info-value {
    color: var(--text-main);
    font-weight: 500;
}

/* Connection Modal */
.connection-modal.modal-dialog {
    width: 350px;
    min-width: 300px;
}

.connection-modal .modal-header {
    padding: 20px;
}

.connection-modal .modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
}

.connection-modal .modal-title i {
    color: var(--accent);
    font-size: 1.125rem;
}

.connection-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
}

.connection-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.connection-status-text {
    color: var(--text-main);
    font-size: 0.875rem;
    text-align: center;
    margin: 0;
}

.connection-modal .modal-footer {
    justify-content: center;
}

/* Multiuser-only visibility helpers */
.multiuser-only {
    /* Elements shown only when in multi-user mode */
}

.owner-only {
    /* Elements shown only for room owner */
}

/* Connection status indicator */
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.connection-dot.connected {
    background: #4ade80;
    box-shadow: 0 0 6px #4ade80;
}

.connection-dot.disconnected {
    background: #f87171;
}

.connection-dot.connecting {
    background: #fbbf24;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
