/* ============================================
   Katakō - Deep Space UI Theme
   ============================================ */

:root {
    /* Colors - Deep Space & Vivid Accents */
    --bg-app: #050505;
    --bg-viewport: radial-gradient(circle at center, #1a1a1a 0%, #050505 100%);

    /* Glassmorphism Panels */
    --bg-panel: rgba(18, 18, 20, 0.75);
    --bg-panel-hover: rgba(28, 28, 32, 0.85);
    --backdrop-blur: blur(20px);

    /* Inputs */
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-input-hover: rgba(255, 255, 255, 0.1);
    --bg-input-active: rgba(255, 255, 255, 0.15);

    /* Accents */
    --accent-primary: #0A84FF;
    /* iOS Blue */
    --accent-hover: #409CFF;
    --accent-glow: 0 0 16px rgba(10, 132, 255, 0.4);

    /* Text */
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --text-disabled: rgba(255, 255, 255, 0.2);

    /* Borders */
    --border-light: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 255, 255, 0.15);

    /* Metrics */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-pill: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);

    --header-height: 60px;
    --toolbar-width: 68px;
    --panel-width: 300px;

    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --ease-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-smooth: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-app);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    font-size: 13px;
    letter-spacing: -0.01em;
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

button {
    outline: none;
    font-family: inherit;
}

/* ============================================
   Loading Screen
   ============================================ */
#loading-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-app);
    z-index: 9999;
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s ease-in-out infinite;
    margin: 0 auto 20px auto;
    box-shadow: var(--accent-glow);
}

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

.loader-text h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

.loader-text p {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

/* ============================================
   Viewport
   ============================================ */
#viewport-container {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: var(--bg-viewport);
}

#viewport {
    width: 100%;
    height: 100%;
    display: block;
}

/* Help Hint - Floating Pill */


kbd {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    margin: 0 2px;
}

/* ============================================
   Top Action Bar
   ============================================ */
#top-bar {
    position: fixed;
    top: 16px;
    left: 16px;
    right: 16px;
    height: var(--header-height);
    background: var(--bg-panel);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow-sm);
    z-index: 100;
    transition: background 0.2s;
}

/* Logo Area */
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.app-logo {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    background: linear-gradient(135deg, #fff 0%, #bbb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.v-separator {
    width: 1px;
    height: 24px;
    background: var(--border-light);
}

/* Tool Groups */
.tool-group {
    display: flex;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 2px;
}

.tool-group.compact {
    background: transparent;
    padding: 0;
    gap: 8px;
}




/* Right Area */
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

#debug-stats-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Roboto Mono', monospace;
    background: var(--bg-input);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
}

#fps-counter {
    color: #32D74B;
}

.action-btn {
    height: 32px;
    padding: 0 16px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: all 0.2s var(--ease-smooth);
}

.action-btn:hover {
    background: var(--bg-input-hover);
    transform: translateY(-1px);
}

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

.action-btn.primary:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

/* ============================================
   Left Toolbar
   ============================================ */
#toolbar-left {
    position: fixed;
    top: calc(var(--header-height) + 32px);
    left: 16px;
    width: var(--toolbar-width);
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--bg-panel);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 16px 0;
    align-items: center;
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: center;
}

.separator {
    width: 32px;
    height: 1px;
    background: var(--border-light);
}

.tool-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-sizing: border-box;
}

.tool-btn svg,
.tool-btn i svg,
.transform-mode-btn svg,
.transform-mode-btn i svg,
.layer-actions-mini button svg,
.layer-actions-mini button i svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8px;
    transition: transform 0.2s;
}

/* Smaller icons in panel header */
.layer-actions-mini button svg,
.layer-actions-mini button i svg {
    width: 16px;
    height: 16px;
}

.layer-actions-mini button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer-actions-mini button:hover {
    color: var(--text-primary);
    background: var(--bg-input-hover);
}

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

.tool-btn:hover svg {
    transform: scale(1.1);
}

.tool-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--accent-glow);
}

/* Transform Modes */
.transform-mode-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.transform-mode-btn.active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(10, 132, 255, 0.1);
    box-shadow: 0 0 12px rgba(10, 132, 255, 0.2) inset;
}

/* ============================================
   Floating Properties Island (Bottom)
   ============================================ */
#panel-bottom {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    width: auto;
    min-width: 600px;
    /* Base width */
    /* Base width */
    height: auto;
    min-height: 80px;

    background: var(--bg-panel);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);

    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 8px;

    /* Ensure it sits below side panels if they overlap, and doesn't get too wide */
    z-index: 90;
    max-width: calc(100vw - 340px);
    overflow-x: auto;
    /* Allow scrolling if content is too wide for screen */
    scrollbar-width: none;
    /* Hide scrollbar for aesthetics */
    box-shadow: var(--shadow-lg);
    transition: transform 0.4s var(--ease-elastic), opacity 0.3s ease;
}

#panel-bottom.hidden {
    transform: translateX(-50%) translateY(100px) scale(0.9);
    opacity: 0;
    pointer-events: none;
}

.prop-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    height: 100%;
    justify-content: flex-start;
    /* changed from center */
}

/* Transform Grid Layout */
.prop-row {
    display: grid;
    grid-template-columns: 40px 1fr 1fr 1fr;
    /* Label + 3 inputs */
    gap: 8px;
    align-items: center;
}

.prop-row label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Universal Panel Input Styling */
/* Universal Panel Input Styling */
#panel-bottom input[type="number"],
#panel-bottom input[type="text"] {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 6px 8px;
    /* Slightly more padding */
    font-size: 12px;
    font-family: 'SF Mono', monospace;
    width: 100%;
    min-width: 60px;
    /* Ensure space for decimals */
    outline: none;
    transition: all 0.2s;
    cursor: ew-resize;
    /* Indicate scrubbable */
    -moz-appearance: textfield;
    /* Firefox remove spinner */
}

/* Remove WebRunner/Chrome spinners */
#panel-bottom input[type="number"]::-webkit-inner-spin-button,
#panel-bottom input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#panel-bottom input[type="number"]:focus,
#panel-bottom input[type="text"]:focus {
    border-color: var(--accent-primary);
    background: rgba(10, 132, 255, 0.1);
    cursor: text;
    /* Text cursor when editing */
}

/* Primitive Properties Grid (Box Size, etc.) */
#primitive-properties .property-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Consistent grid for dynamic properties */
.property-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    /* Label Value */
    gap: 8px 12px;
    /* Row Gap, Column Gap */
    align-items: center;
}

/* Compact layout for X Y Z size vectors */
.property-grid.vector3 {
    grid-template-columns: 40px 1fr 1fr 1fr;
}

/* Boolean Mode Pills */
.bool-mode-btns {
    display: flex;
    background: var(--bg-input);
    padding: 3px;
    border-radius: 8px;
    gap: 2px;
}

.bool-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.bool-btn svg,
.bool-btn i svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.8px;
}

.bool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.bool-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Color Picker */
input[type=color] {
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
}

input[type=color]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type=color]::-webkit-color-swatch {
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

/* Sliders */
input[type=range] {
    -webkit-appearance: none;
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
    border: 2px solid var(--bg-app);
}

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

input[type=range]::-webkit-slider-thumb:active {
    transform: scale(0.95);
    background: var(--accent-primary);
}

/* ============================================
   Right Panel (Outliner)
   ============================================ */
#panel-right {
    position: fixed;
    top: calc(var(--header-height) + 32px);
    right: 16px;
    width: var(--panel-width);
    max-height: calc(100vh - 120px);
    /* Leave room at bottom */
    background: var(--bg-panel);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.panel-header h3 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.header-controls {
    display: flex;
    flex-direction: row;
    /* Always horizontal */
    gap: 8px;
}

/* Outliner Tree */
.outliner-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.outliner-node {
    display: flex;
    align-items: center;
    height: 36px;
    padding: 0 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.1s;
    border-left: 3px solid transparent;
}

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

.outliner-node.active {
    background: rgba(10, 132, 255, 0.1);
    color: white;
    border-left-color: var(--accent-primary);
}


.node-icon {
    margin-right: 10px;
    opacity: 0.7;
    font-size: 16px;
    width: 24px;
    display: flex;
    justify-content: center;
}

/* Constrain Lucide icons in outliner to original sizes */
.node-icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2px;
}

.node-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 2px;
}

.node-name {
    flex: 1;
    font-weight: 500;
}

/* Node Controls (Eye, Trash) */
.node-controls {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.outliner-node:hover .node-controls,
.outliner-node.active .node-controls {
    opacity: 1;
}

.node-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
    background: transparent;
    border: none;
    cursor: pointer;
}

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

.node-btn.delete:hover {
    background: rgba(255, 59, 48, 0.2);
    color: #ff3b30;
}

/* Custom Tooltip */
.ui-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    pointer-events: none;
    z-index: 1000;
    border: 1px solid var(--border-light);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
    white-space: nowrap;
}

.ui-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   Mobile Responsiveness (Max Width 768px)
   ============================================ */
@media (max-width: 768px) {

    /* ---- Left Toolbar: Scaled Down & Scrollable ---- */
    :root {
        --toolbar-width: 56px;
    }

    #toolbar-left {
        width: var(--toolbar-width);
        gap: 12px;
        padding: 10px 0;
        max-height: calc(100vh - var(--header-height) - 64px);
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
    }

    #toolbar-left::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari */
    }

    .tool-btn,
    .transform-mode-btn {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .tool-btn svg,
    .tool-btn i svg,
    .transform-mode-btn svg,
    .transform-mode-btn i svg {
        width: 18px;
        height: 18px;
    }

    .tool-section {
        gap: 8px;
    }

    .separator {
        width: 24px;
        margin: 2px 0;
    }

    /* ---- Right Panel ---- */
    #panel-right {
        width: 60px;
        /* Slim mode by default */
        transition: width 0.3s var(--ease-elastic);
    }

    #panel-right.expanded {
        width: 300px;
    }

    /* Mobile Collapsed State: Stacked Header */
    #panel-right:not(.expanded) .panel-header {
        flex-direction: column;
        justify-content: center;
        padding: 12px 0;
        gap: 8px;
        height: auto;
        cursor: pointer;
    }

    #panel-right:not(.expanded) .panel-header h3 {
        display: block;
        /* Visible now */
        font-size: 10px;
        /* Smaller */
        margin: 0;
    }

    #panel-right:not(.expanded) .header-controls {
        display: flex;
        /* Visible now */
        /* Buttons already horizontal from base style */
        gap: 4px;
    }

    /* Slightly wider to fit side-by-side buttons if needed, or keep 60px */
    /* 24px + 24px + 4px gap = 52px. Fits in 60px. */

    /* Hide tree content when collapsed */
    #panel-right:not(.expanded) .node-name,
    #panel-right:not(.expanded) .node-controls,
    #panel-right:not(.expanded) .outliner-placeholder {
        display: none;
    }

    /* Center icons when collapsed */
    #panel-right:not(.expanded) .outliner-node {
        justify-content: center;
        padding: 0;
    }

    #panel-right:not(.expanded) .node-icon {
        margin: 0;
    }

    /* Indicator dot no longer needed if we show text? Or keep it? */
    /* User didn't mention it, but explicit "Scene" text is better than dot */
    .panel-header::after {
        display: none;
    }

    #panel-right.expanded .panel-header {
        justify-content: space-between;
        flex-direction: row;
        /* Reset to row when expanded */
    }

    /* ---- Bottom Properties Panel: Scroll Handle Approach ---- */
    #panel-bottom {
        min-width: auto;
        max-width: calc(100vw - 32px);
        left: 16px;
        right: 16px;
        transform: translateX(0) translateY(0);
        /* Vertical stack: handle on top, content below */
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        overflow: hidden;
    }

    #panel-bottom.hidden {
        transform: translateX(0) translateY(100px) scale(0.9);
    }

    /* Horizontal scrolling content wrapper */
    .panel-content {
        display: flex;
        flex-direction: row;
        align-items: center;
        overflow: visible;
        /* Allow content to extend for transforms */
        padding: 8px 16px;
        padding-right: 32px;
        /* Extra padding so last element isn't clipped */
    }

    .prop-section {
        padding: 8px 12px;
        flex-shrink: 0;
    }

    .prop-divider {
        flex-shrink: 0;
    }

    /* ---- Scroll Handle (mobile only) ---- */
    .panel-scroll-handle {
        display: block;
        width: 100%;
        padding: 8px 16px 4px 16px;
        touch-action: pan-x;
    }

    .scroll-handle-track {
        width: 100%;
        height: 4px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 2px;
        position: relative;
    }

    .scroll-handle-thumb {
        position: absolute;
        height: 100%;
        width: 30%;
        background: rgba(255, 255, 255, 0.4);
        border-radius: 2px;
        left: 0;
        transition: background 0.2s;
    }

    .scroll-handle-thumb:active,
    .scroll-handle-thumb.dragging {
        background: var(--accent-primary);
    }

    /* ---- iOS Auto-Zoom Prevention ---- */
    /* Font size >= 16px prevents iOS Safari from zooming on focus */
    #panel-bottom input[type="number"],
    #panel-bottom input[type="text"] {
        font-size: 16px;
        padding: 4px 6px;
        width: 56px;
        min-width: 56px;
        max-width: 56px;
        cursor: ew-resize;
    }

    /* Tighter grid layout for mobile */
    .prop-row {
        grid-template-columns: 32px 56px 56px 56px;
        gap: 4px;
    }

    .prop-row label {
        font-size: 10px;
    }
}

/* ============================================
   Desktop: Ensure panel-content doesn't break layout
   ============================================ */
/* Base panel-content styles (for desktop) */
.panel-content {
    display: flex;
    flex-direction: row;
    align-items: center;
}

/* Hide scroll handle on desktop */
@media (pointer: fine) {
    .panel-scroll-handle {
        display: none;
    }
}

/* Transform HUD */
#transform-hud {
    position: absolute;
    bottom: 120px;
    /* Above floating island */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    padding: 8px 16px;
    border-radius: 8px;
    display: flex;
    gap: 12px;
    color: white;
    font-family: 'SF Mono', monospace;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
    z-index: 500;
}

.axis-x {
    color: #ff3b30;
}

.axis-y {
    color: #32d74b;
}

.axis-z {
    color: #0a84ff;
}

/* Outliner Drag and Drop */
.outliner-node.dragging {
    opacity: 0.4;
}

.outliner-node.drag-over-top {
    border-top: 2px solid var(--accent-primary);
    margin-top: -1px;
}

.outliner-node.drag-over-bottom {
    border-bottom: 2px solid var(--accent-primary);
    margin-bottom: -1px;
}

/* Node name - cursor stays default until editing */
.node-name {
    cursor: default;
}

/* Visual Transform Guide Line */
#transform-line {
    position: fixed;
    height: 1px;
    background: transparent;
    border-top: 1px dashed rgba(255, 255, 255, 0.5);
    transform-origin: 0 50%;
    pointer-events: none;
    z-index: 400;
    /* Below HUD but above 3D */
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* Boolean Mode Color Coding */
.outliner-node.bool-subtract {
    border-left-color: #ff3b30;
}

.outliner-node.bool-subtract .node-name {
    color: #ff6b60;
}

.outliner-node.bool-intersect {
    border-left-color: #bf5af2;
}

.outliner-node.bool-intersect .node-name {
    color: #d88bfc;
}

/* ============================================
   Brick Pool Debug HUD
   ============================================ */
#brick-debug-hud {
    position: absolute;
    top: 100px;
    left: 100px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    padding: 12px 16px;
    border-radius: 10px;
    font-family: 'SF Mono', 'Roboto Mono', monospace;
    font-size: 12px;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: auto;
    /* Allow interaction */
    z-index: 1000;
    /* Ensure on top of other panels */
    min-width: 180px;
}

#brick-debug-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

#brick-debug-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

#brick-debug-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

#brick-debug-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #32d74b 0%, #ffd60a 60%, #ff3b30 100%);
    border-radius: 3px;
    transition: width 0.1s ease-out;
}

/* DC Edge Pool Bar (reuse brick pool styling) */
#dc-edge-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

#dc-edge-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0a84ff 0%, #bf5af2 60%, #ff375f 100%);
    border-radius: 3px;
    transition: width 0.1s ease-out;
}

#dc-edge-value {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Dev Mode Panel Extensions */
#dev-mode-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#brick-debug-hud {
    pointer-events: auto;
    /* Enable interaction for toggles */
}

.dev-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dev-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.dev-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.dev-sublabel {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

.dev-toggle-row {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 6px;
}

.dev-toggle-btn {
    flex: 1;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.dev-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.dev-toggle-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 6px rgba(10, 132, 255, 0.3);
}

.dev-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.dev-checkbox-row:hover {
    color: var(--text-primary);
}

.dev-checkbox-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.dev-checkbox-row span {
    user-select: none;
}

/* Viewport and Virtual Cursor */
#viewport-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
}

/* Dev Mode Toggle Button (always visible) */
#dev-mode-toggle {
    position: fixed;
    top: 100px;
    left: 100px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    color: var(--accent-primary);
    font-size: 14px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    z-index: 501;
    transition: all 0.2s;
}

#dev-mode-toggle:hover {
    background: rgba(10, 132, 255, 0.2);
    border-color: var(--accent-primary);
}

#dev-mode-toggle.active {
    background: var(--accent-primary);
    color: white;
}

/* Dev Mode Header with Collapse Button */
#dev-mode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#dev-collapse-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

#dev-collapse-btn:hover {
    color: var(--text-primary);
}

/* DC Tuning Slider Styling */
.dc-slider-row {
    margin-bottom: 8px;
}

.dc-slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 4px;
}

.dc-slider-header .dc-slider-label {
    color: var(--text-secondary);
}

.dc-slider-header .dc-slider-value {
    color: var(--text-primary);
    font-family: 'SF Mono', monospace;
}

.dc-slider-row input[type="range"] {
    width: 100%;
    height: 4px;
}

/* Touch-friendly slider thumb for mobile */
@media (pointer: coarse) {
    input[type=range]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    input[type=range]::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }

    .dc-slider-row input[type="range"] {
        height: 6px;
    }
}

/* Meshing Mode Selector */
.dc-mode-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dc-mode-row .dc-slider-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.dc-mode-buttons {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 6px;
}

.dc-mode-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.dc-mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.dc-mode-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 6px rgba(10, 132, 255, 0.3);
}

/* Outliner Placeholder */
.outliner-placeholder {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: 36px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    opacity: 0.5;
    gap: 8px;
    font-style: italic;
}

.outliner-placeholder i,
.outliner-placeholder svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.5px;
    opacity: 0.8;
    margin-bottom: 0;
}

/* ============================================
   Dev Mode Toggle (Mobile Only)
   ============================================ */
#dev-mode-toggle {
    display: flex;
    /* Visible on all devices (requested overlap) */
    position: fixed;
    top: 100px;
    /* Clear of top bar */
    left: 100px;
    /* Clear of sidebar */
    width: 44px;
    /* Make it square/circular */
    height: 44px;
    /* Match toolbar button height */
    padding: 0;
    /* Remove padding */
    background: var(--bg-panel);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    /* Make it a circle */
    /* Pill shape */
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    align-items: center;
    justify-content: center;
    /* Center the icon */
    cursor: pointer;
    z-index: 2000;
    /* Above toolbar */
    box-shadow: var(--shadow-sm);
    transition: all 0.2s var(--ease-smooth);
}

#dev-mode-toggle:hover {
    background: var(--bg-input-hover);
    color: var(--text-primary);
    transform: translateY(1px);
    box-shadow: var(--shadow-lg);
}

#dev-mode-toggle i,
#dev-mode-toggle svg {
    width: 20px !important;
    height: 20px !important;
    stroke-width: 2px;
    min-width: 20px;
    /* Prevent crushing */
    min-height: 20px;
}

#dev-mode-toggle.hidden {
    display: none !important;
}