:root {
    --bg: #070b14;
    --panel: rgba(13, 20, 35, 0.9);
    --panel-solid: #0d1423;
    --border: rgba(6, 182, 212, 0.25);
    --cyan: #06b6d4;
    --magenta: #d946ef;
    --emerald: #10b981;
    --danger: #ef4444;
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --mono: 'Share Tech Mono', monospace;
    --sans: 'Rajdhani', sans-serif;
    --display: 'Orbitron', sans-serif;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
}

/* Top Bar */
.topbar {
    height: 54px;
    background: var(--panel-solid);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 20;
}

.topbar-left, .topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-back {
    color: var(--cyan);
    text-decoration: none;
    font-family: var(--mono);
    font-size: 0.85rem;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: 0.2s;
}
.nav-back:hover { background: rgba(6, 182, 212, 0.15); }

.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 {
    font-family: var(--display);
    font-size: 1.15rem;
    letter-spacing: 2px;
    color: #fff;
}
.badge {
    font-family: var(--mono);
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid var(--emerald);
    color: var(--emerald);
}

.tray-stats {
    display: flex;
    gap: 16px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-left: 8px;
}
.tray-stats strong { color: var(--cyan); }

/* Buttons */
.btn {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    transition: 0.15s;
}
.btn:hover { background: rgba(6, 182, 212, 0.15); border-color: var(--cyan); }
.btn-primary {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: #041018;
    border-color: var(--cyan);
    font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.12); }
.btn-toggle.active { border-color: var(--magenta); color: #f5d0fe; background: rgba(217, 70, 239, 0.15); }
.btn-danger:hover { border-color: var(--danger); color: #fecaca; background: rgba(239, 68, 68, 0.15); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    min-height: 0;
    position: relative;
}

/* Left Sidebar */
.sidebar {
    width: 330px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-section {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.sidebar-section:first-child { flex: 1; }

.settings-section {
    border-top: 1px solid var(--border);
    background: rgba(7, 11, 20, 0.6);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.section-header h2 {
    font-family: var(--display);
    font-size: 0.78rem;
    letter-spacing: 1.5px;
    color: var(--cyan);
}
.hint { font-family: var(--mono); font-size: 0.72rem; color: var(--text-dim); }

.search-input {
    width: 100%;
    padding: 7px 10px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.9rem;
    outline: none;
}
.search-input:focus { border-color: var(--cyan); }

.parts-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 4px;
}

.folder-group {
    display: flex;
    flex-direction: column;
}
.folder-group.depth-1 {
    margin-left: 10px;
    padding-left: 8px;
    border-left: 1px dashed rgba(6, 182, 212, 0.25);
}
.folder-header {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    border-radius: 5px;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--cyan);
    background: rgba(6, 182, 212, 0.06);
    border: 1px solid rgba(6, 182, 212, 0.14);
    margin-bottom: 5px;
}
.folder-header::-webkit-details-marker { display: none; }
.folder-header:hover { background: rgba(6, 182, 212, 0.14); }
.folder-title { flex: 1; font-weight: 700; letter-spacing: 0.5px; }
.folder-count {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-dim);
}
.folder-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
}

.part-card {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-left: 3px solid var(--part-color, var(--cyan));
    border-radius: 6px;
    padding: 9px 11px;
    cursor: pointer;
    transition: 0.15s;
}
.part-card:hover {
    border-color: var(--cyan);
    background: rgba(6, 182, 212, 0.12);
    transform: translateX(2px);
}
.part-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}
.part-name { font-weight: 700; font-size: 0.96rem; color: #fff; }
.part-dims { font-family: var(--mono); font-size: 0.75rem; color: var(--cyan); }
.part-meta { font-size: 0.78rem; color: var(--text-dim); }

/* Sliders */
.slider-group { display: flex; flex-direction: column; gap: 8px; }
.slider-row label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 2px;
}
.slider-row label span { font-family: var(--mono); color: var(--cyan); }
.slider-row input[type="range"] { width: 100%; accent-color: var(--cyan); cursor: pointer; }

/* 3D Viewport */
.viewport-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 50% 45%, #0f1a2e 0%, #05080f 100%);
}
#canvas-container { width: 100%; height: 100%; }

.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.empty-state.hidden { display: none; }
.empty-card {
    background: var(--panel);
    border: 1px dashed var(--border);
    padding: 20px 28px;
    border-radius: 10px;
    text-align: center;
}
.empty-card h3 { color: var(--cyan); margin-bottom: 4px; font-family: var(--display); font-size: 1rem; }
.empty-card p { color: var(--text-dim); font-size: 0.92rem; }

.controls-hud {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 16px;
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-dim);
    pointer-events: none;
}
.controls-hud strong { color: var(--cyan); font-family: var(--mono); }

/* Floating Bin Inspector */
.bin-inspector {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 304px;
    background: var(--panel);
    border: 1px solid var(--cyan);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    z-index: 15;
    backdrop-filter: blur(10px);
}
.bin-inspector.hidden { display: none; }
.inspector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-family: var(--display);
    font-size: 0.8rem;
    color: var(--cyan);
}
.close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
}
.close-btn:hover { color: #fff; }
.inspector-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.insp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.insp-grid.hidden { display: none; }
.insp-grid label {
    display: flex;
    flex-direction: column;
    font-size: 0.76rem;
    color: var(--text-dim);
    gap: 3px;
}
.insp-grid input, .insp-grid select {
    width: 100%;
    min-width: 0;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 4px;
    padding: 5px 7px;
    color: #fff;
    font-family: var(--mono);
    font-size: 0.8rem;
}
.insp-sublabel { font-size: 0.76rem; color: var(--text-dim); display: block; margin-bottom: 4px; }
.cutout-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; font-size: 0.82rem; }
.cutout-toggles label, .insp-check { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.82rem; }
.insp-check.hidden { display: none; }
.insp-actions { display: flex; justify-content: flex-end; }

/* Context Menu */
.context-menu {
    position: fixed;
    min-width: 210px;
    background: var(--panel-solid);
    border: 1px solid var(--cyan);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65);
    z-index: 50;
}
.context-menu.hidden { display: none; }
.ctx-title {
    font-family: var(--mono);
    font-size: 0.74rem;
    color: var(--cyan);
    padding: 4px 8px 6px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    margin-bottom: 4px;
}
.ctx-item {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    padding: 7px 9px;
    border-radius: 5px;
    font-family: var(--sans);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ctx-item:hover { background: rgba(6, 182, 212, 0.18); }
.ctx-item.danger { color: #fca5a5; }
.ctx-item.danger:hover { background: rgba(239, 68, 68, 0.2); }
.ctx-sep { height: 1px; background: rgba(148, 163, 184, 0.18); margin: 4px 0; }
.kbd { font-family: var(--mono); font-size: 0.72rem; color: var(--text-dim); }

/* Hover Tooltip */
.hover-tooltip {
    position: fixed;
    pointer-events: none;
    background: rgba(7, 11, 20, 0.92);
    border: 1px solid var(--cyan);
    color: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.76rem;
    z-index: 45;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}
.hover-tooltip.hidden { display: none; }

/* Toast */
.toast {
    position: fixed;
    bottom: 56px;
    right: 20px;
    background: var(--panel-solid);
    border: 1px solid var(--emerald);
    color: #d1fae5;
    padding: 8px 14px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.82rem;
    z-index: 60;
}
.toast.hidden { display: none; }
