/* ================================================================
   ScenoPlan — Conception Scénographique
   Design System & Styles
   ================================================================ */

/* ---------- CSS Variables / Design Tokens ---------- */
:root {
    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;

    /* Spacing */
    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 12px;
    --sp-lg: 16px;
    --sp-xl: 24px;
    --sp-2xl: 32px;

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 350ms ease;

    /* Sidebar widths */
    --library-width: 260px;
    --properties-width: 280px;
    --toolbar-height: 48px;
    --canvas-toolbar-height: 42px;
    --status-bar-height: 28px;
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
    --bg-app: #0d0f13;
    --bg-panel: #14161c;
    --bg-panel-alt: #1a1d26;
    --bg-hover: #1e2230;
    --bg-active: #252a38;
    --bg-canvas: #0a0c10;
    --bg-input: #1a1d26;
    --bg-toolbar: #111319;

    --border-subtle: #1e2230;
    --border-default: #272c3a;
    --border-strong: #353b4d;

    --text-primary: #e8eaf0;
    --text-secondary: #8b90a0;
    --text-muted: #555a6e;
    --text-inverse: #0d0f13;

    --accent: #6c8cff;
    --accent-hover: #8aa4ff;
    --accent-subtle: rgba(108, 140, 255, 0.12);
    --accent-glow: rgba(108, 140, 255, 0.25);

    --danger: #ff6b6b;
    --danger-hover: #ff8787;
    --danger-subtle: rgba(255, 107, 107, 0.12);

    --success: #51cf66;
    --warning: #ffd43b;

    --grid-line: rgba(108, 140, 255, 0.06);
    --grid-line-major: rgba(108, 140, 255, 0.12);
    --grid-origin: rgba(108, 140, 255, 0.3);

    --canvas-bg: #0e1018;
    --scene-bg: #141722;
    --scene-border: #2a3040;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 20px rgba(108,140,255,0.15);

    --scrollbar-bg: #14161c;
    --scrollbar-thumb: #272c3a;
    --scrollbar-thumb-hover: #353b4d;
}

/* ---------- Light Theme ---------- */
[data-theme="light"] {
    --bg-app: #f5f6f8;
    --bg-panel: #ffffff;
    --bg-panel-alt: #f0f1f4;
    --bg-hover: #e8eaef;
    --bg-active: #dfe1e8;
    --bg-canvas: #e8eaef;
    --bg-input: #f0f1f4;
    --bg-toolbar: #ffffff;

    --border-subtle: #e8eaef;
    --border-default: #d4d7e0;
    --border-strong: #bec2cf;

    --text-primary: #1a1d26;
    --text-secondary: #5a5f73;
    --text-muted: #8b90a0;
    --text-inverse: #ffffff;

    --accent: #4c6ef5;
    --accent-hover: #3b5bdb;
    --accent-subtle: rgba(76, 110, 245, 0.08);
    --accent-glow: rgba(76, 110, 245, 0.15);

    --danger: #e03131;
    --danger-hover: #c92a2a;
    --danger-subtle: rgba(224, 49, 49, 0.08);

    --success: #2f9e44;
    --warning: #e67700;

    --grid-line: rgba(76, 110, 245, 0.08);
    --grid-line-major: rgba(76, 110, 245, 0.15);
    --grid-origin: rgba(76, 110, 245, 0.35);

    --canvas-bg: #e2e4ea;
    --scene-bg: #ffffff;
    --scene-border: #c4c8d4;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --shadow-glow: 0 0 20px rgba(76,110,245,0.1);

    --scrollbar-bg: #f0f1f4;
    --scrollbar-thumb: #c4c8d4;
    --scrollbar-thumb-hover: #a8adb8;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-app);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ---------- Top Toolbar ---------- */
#toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--toolbar-height);
    background: var(--bg-toolbar);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 var(--sp-md);
    z-index: 100;
    position: relative;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.toolbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

#project-name {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    padding: 4px 12px;
    width: 300px;
    transition: border-color var(--transition-fast);
}

#project-name:hover {
    border-color: var(--border-default);
}

#project-name:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-input);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    color: var(--accent);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.3px;
    user-select: none;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-default);
    margin: 0 var(--sp-xs);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.toolbar-btn:active {
    background: var(--bg-active);
    transform: scale(0.97);
}

.toolbar-btn.icon-only {
    padding: 6px;
}

.toolbar-btn svg { flex-shrink: 0; }

/* Theme toggle icons */
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ---------- Main Layout ---------- */
#app {
    display: flex;
    height: calc(100vh - var(--toolbar-height));
}

/* ---------- Library Panel (Left Sidebar) ---------- */
#library-panel {
    width: var(--library-width);
    min-width: var(--library-width);
    background: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: var(--sp-md) var(--sp-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-header h2 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: var(--sp-sm);
}

#library-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 12px;
    transition: border-color var(--transition-fast);
}

#library-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

#library-search::placeholder {
    color: var(--text-muted);
}

#library-categories {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-sm) 0;
}

.library-category {
    margin-bottom: 2px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: 8px var(--sp-lg);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    user-select: none;
    transition: all var(--transition-fast);
}

.category-header:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.category-header .chevron {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-base);
    flex-shrink: 0;
}

.category-header.collapsed .chevron {
    transform: rotate(-90deg);
}

.category-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.category-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px var(--sp-md);
    overflow: hidden;
    transition: max-height var(--transition-slow), opacity var(--transition-base);
    max-height: 1000px;
    opacity: 1;
}

.category-items.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.library-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--bg-panel-alt);
    cursor: grab;
    transition: all var(--transition-fast);
    user-select: none;
}

.library-item:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.library-item:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.library-item-preview {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-item-preview canvas {
    border-radius: 2px;
}

.library-item-name {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-item-size {
    font-size: 9px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ---------- Canvas Area ---------- */
#canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#canvas-toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    height: var(--canvas-toolbar-height);
    padding: 0 var(--sp-md);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
}

.canvas-tool-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.canvas-tool-divider {
    width: 1px;
    height: 24px;
    background: var(--border-default);
    margin: 0 var(--sp-xs);
}

.canvas-tool {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.canvas-tool:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.canvas-tool.active {
    background: var(--accent-subtle);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.zoom-display {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 48px;
    text-align: center;
    user-select: none;
}

.grid-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    user-select: none;
    transition: all var(--transition-fast);
}

.grid-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.grid-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 3px;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.grid-toggle input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.grid-toggle input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 4px;
    width: 4px;
    height: 7px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

/* Viewports Wrapper & Containers */
#viewports-wrapper {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

#canvas-container {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--canvas-bg);
    cursor: default;
    position: relative;
}

/* Split-View Mode 2D + 3D */
#viewports-wrapper.mode-split #canvas-container {
    flex: 1 1 50%;
    width: 50% !important;
    display: flex !important;
    border-right: 2px solid var(--border-default);
}

#viewports-wrapper.mode-split #three-container {
    flex: 1 1 50%;
    width: 50% !important;
    display: flex !important;
}

#canvas-container.tool-pan { cursor: grab; }
#canvas-container.tool-pan.panning { cursor: grabbing; }
#canvas-container.tool-measure { cursor: crosshair; }
#canvas-container.tool-wall { cursor: crosshair; }
#canvas-container.tool-zone { cursor: crosshair; }
#canvas-container.tool-text { cursor: text; }
#canvas-container.dragging-item { cursor: grabbing; }

#main-canvas {
    display: block;
}

/* Status Bar */
#status-bar {
    display: flex;
    align-items: center;
    gap: var(--sp-xl);
    height: var(--status-bar-height);
    padding: 0 var(--sp-md);
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

#status-bar span {
    white-space: nowrap;
}

#status-coords {
    min-width: 180px;
}

/* ---------- Properties Panel (Right Sidebar) ---------- */
#properties-panel {
    width: var(--properties-width);
    min-width: var(--properties-width);
    background: var(--bg-panel);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#properties-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-sm);
}

.props-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    gap: var(--sp-md);
    color: var(--text-muted);
    text-align: center;
    padding: var(--sp-xl);
}

.props-empty p {
    font-size: 12px;
    line-height: 1.5;
}

.props-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin: var(--sp-lg) 0 var(--sp-sm);
    padding-bottom: var(--sp-xs);
    border-bottom: 1px solid var(--border-subtle);
}

.props-section h3:first-child {
    margin-top: var(--sp-sm);
}

.prop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-sm);
}

.prop-row label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 80px;
    flex-shrink: 0;
}

.prop-row-double {
    display: flex;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-sm);
}

.prop-field {
    flex: 1;
}

.prop-field label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.prop-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 12px;
    transition: border-color var(--transition-fast);
}

.prop-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.prop-value {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

.prop-color-input {
    width: 100%;
    height: 28px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    cursor: pointer;
    padding: 2px;
}

.prop-range {
    width: 100%;
    accent-color: var(--accent);
}

.prop-checkbox {
    accent-color: var(--accent);
}

.prop-actions {
    display: flex;
    gap: var(--sp-sm);
    margin-top: var(--sp-lg);
}

.prop-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-panel-alt);
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.prop-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.prop-btn.danger {
    border-color: var(--danger-subtle);
    color: var(--danger);
}

.prop-btn.danger:hover {
    background: var(--danger-subtle);
    border-color: var(--danger);
}

/* Scene stats */
.scene-stats {
    display: flex;
    gap: var(--sp-sm);
    margin-top: var(--sp-lg);
}

.stat-item {
    flex: 1;
    padding: var(--sp-md);
    background: var(--bg-panel-alt);
    border-radius: var(--radius-md);
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--font-mono);
}

/* ---------- Measure Tooltip ---------- */
.measure-tooltip {
    position: fixed;
    padding: 4px 10px;
    background: var(--accent);
    color: white;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    pointer-events: none;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
}

/* ---------- Context Menu ---------- */
.context-menu {
    position: fixed;
    min-width: 180px;
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.context-menu button {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast);
}

.context-menu button:hover {
    background: var(--bg-hover);
}

.context-menu button.danger {
    color: var(--danger);
}

.context-menu button.danger:hover {
    background: var(--danger-subtle);
}

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

/* ---------- Drag Ghost ---------- */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.8;
    transform: translate(-50%, -50%);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
}

/* ---------- Selection Handles ---------- */
/* Drawn on canvas, but for reference */

/* ---------- Animations ---------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.context-menu {
    animation: fadeIn 150ms ease;
}

/* ---------- Responsive fallback ---------- */
@media (max-width: 1000px) {
    #library-panel {
        width: 200px;
        min-width: 200px;
    }
    #properties-panel {
        width: 220px;
        min-width: 220px;
    }
}

/* ================================================================
   3D Viewport & Controls
   ================================================================ */

/* Toggle Button in Header */
.view-mode-toggle {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 2px;
    margin-left: var(--sp-md);
    gap: 2px;
}

.mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: calc(var(--radius-md) - 2px);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.mode-btn.active {
    background: var(--accent);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 1px 4px var(--accent-glow);
}

/* 3D Viewport Container */
.three-viewport {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #13151a;
    display: flex;
}

.three-viewport canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    outline: none;
}

/* 3D Overlay Floating Toolbar */
.three-overlay-toolbar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(22, 25, 34, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 50;
    user-select: none;
}

.three-tool-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.three-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-right: 4px;
    margin-left: 4px;
}

.three-divider {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
}

.three-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.three-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.three-btn.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.three-btn.action {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.three-btn.action:hover {
    background: var(--accent);
    color: #ffffff;
}

/* 3D Interactive Tooltip */
.three-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(18, 20, 28, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    z-index: 100;
    transition: opacity 100ms ease;
}

.three-tooltip .tooltip-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.three-tooltip .tooltip-details {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    margin-top: 2px;
}

.three-select {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 11px;
    font-weight: 500;
    padding: 5px 8px;
    border-radius: 16px;
    cursor: pointer;
    outline: none;
    transition: all var(--transition-fast);
}

.three-select:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
}

.three-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.three-select option {
    background: #181b22;
    color: #e2e8f0;
}

/* First-Person Walk HUD */
.three-walk-hud {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(14, 18, 26, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(52, 211, 153, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(52, 211, 153, 0.15);
    border-radius: var(--radius-md);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 60;
    user-select: none;
    animation: slideUp 200ms ease;
}

.walk-hud-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #34d399;
    white-space: nowrap;
}

.walk-hud-desc {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.walk-hud-desc b {
    color: #ffffff;
}

.walk-hud-quit-btn {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.walk-hud-quit-btn:hover {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

/* 3D Navigation Help Badge */
.three-help-badge {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 21, 28, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 5px 14px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    pointer-events: none;
    letter-spacing: 0.2px;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ================================================================
   Roadmap Modal Dialog
   ================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(8, 10, 15, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.roadmap-dialog {
    width: 90vw;
    max-width: 1060px;
    max-height: 88vh;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(16px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.roadmap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-lg) var(--sp-xl);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.roadmap-title-group {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
}

.roadmap-icon {
    font-size: 28px;
    line-height: 1;
}

.roadmap-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.roadmap-header p {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--trans-fast);
}

.btn-close-modal:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.roadmap-nav {
    display: flex;
    gap: var(--sp-xs);
    padding: var(--sp-sm) var(--sp-xl);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.roadmap-tab-btn {
    background: transparent;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--trans-fast);
}

.roadmap-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.roadmap-tab-btn.active {
    background: var(--accent);
    color: white;
}

.roadmap-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-xl);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--sp-md);
    background: var(--bg-base);
}

.roadmap-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--sp-lg);
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
    transition: transform var(--trans-fast), border-color var(--trans-fast), box-shadow var(--trans-fast);
}

.roadmap-card:hover {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.card-badge {
    align-self: flex-start;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 12px;
}

.badge-p1 {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.badge-p2 {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-p3 {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-p4 {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.35);
}

.badge-done {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.5);
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.2);
}

.badge-next {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.roadmap-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
}

.roadmap-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: var(--sp-xs);
}

.card-tags .tag {
    font-size: 10px;
    background: var(--bg-hover);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
}

.roadmap-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-md) var(--sp-xl);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.roadmap-footer-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.roadmap-footer-info code {
    font-family: var(--font-mono);
    color: var(--accent);
    background: rgba(91, 115, 255, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
}

.roadmap-btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--trans-fast);
}

.roadmap-btn-primary:hover {
    background: var(--accent-hover);
}


