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

body {
    background: #0a0a0a;
    color: #d0d0d0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    height: 100vh;
}

/* --- Sidebar --- */

#sidebar {
    width: 280px;
    min-width: 280px;
    background: #111;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 10px;
    overflow-y: auto;
}

#sidebar h1 {
    font-size: 16px;
    font-weight: 600;
    color: #e0e0e0;
    letter-spacing: 0.5px;
}

/* --- Auth Gate --- */

#auth-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: #0a0a0a;
}

#auth-gate.hidden {
    display: none;
}

.auth-box {
    text-align: center;
    max-width: 360px;
    padding: 40px 24px;
}

.auth-box h1 {
    font-size: 28px;
    font-weight: 700;
    color: #e0e0e0;
    margin-bottom: 8px;
}

.auth-box p {
    color: #666;
    font-size: 14px;
    margin-bottom: 24px;
}

#auth-form {
    display: flex;
    gap: 8px;
}

#auth-form input {
    flex: 1;
    padding: 10px 14px;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: monospace;
    outline: none;
    letter-spacing: 1px;
}

#auth-form input:focus {
    border-color: #6bb8c4;
}

#auth-form button {
    padding: 10px 20px;
    background: #6bb8c4;
    color: #0a0a0a;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#auth-form button:hover {
    background: #7fcbd6;
}

.auth-message {
    margin-top: 12px;
    font-size: 13px;
    color: #c46b6b;
    min-height: 20px;
}

.hidden {
    display: none !important;
}

/* --- Catalog --- */

#catalog label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#catalog-search {
    width: 100%;
    padding: 6px 10px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #d0d0d0;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    margin-bottom: 6px;
}

#catalog-search:focus {
    border-color: #6bb8c4;
}

#catalog-brands {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.brand-chip {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    color: #aaa;
    padding: 2px 10px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
}

.brand-chip:hover {
    background: #252525;
    border-color: #555;
}

.brand-chip.active {
    background: #1a2a2d;
    border-color: #6bb8c4;
    color: #6bb8c4;
}

#catalog-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
}

.catalog-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: #d0d0d0;
    transition: background 0.15s;
}

.catalog-item:hover {
    background: #252525;
    border-color: #444;
}

.catalog-item.loaded {
    opacity: 0.4;
    cursor: default;
}

.catalog-item.loading {
    opacity: 0.5;
    cursor: wait;
}

.catalog-name {
    font-size: 12px;
}

.catalog-brand {
    font-size: 10px;
    color: #666;
}

/* --- Mouse List --- */

#mouse-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mouse-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: #1a1a1a;
    border-radius: 4px;
    border: 1px solid #2a2a2a;
}

.mouse-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mouse-header .color-pick {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 3px;
    padding: 0;
    cursor: pointer;
    background: none;
    flex-shrink: 0;
}

.mouse-header .color-pick::-webkit-color-swatch-wrapper {
    padding: 0;
}

.mouse-header .color-pick::-webkit-color-swatch {
    border: 1px solid #555;
    border-radius: 3px;
}

.mouse-header .name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
}

.mouse-header button {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
}

.mouse-header button:hover {
    color: #ccc;
}

.mouse-header button.active {
    color: #ccc;
}

/* --- Slider row --- */

.slider-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.slider-label {
    font-size: 11px;
    color: #666;
    flex-shrink: 0;
}

.opacity-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    border-radius: 2px;
    outline: none;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #aaa;
    cursor: pointer;
}

.opacity-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #aaa;
    border: none;
    cursor: pointer;
}

.slider-value {
    font-size: 11px;
    color: #888;
    width: 32px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* --- Flip buttons --- */

.flip-row {
    display: flex;
    gap: 4px;
}

.flip-btn {
    flex: 1;
    font-size: 11px;
    padding: 4px 0;
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 3px;
    color: #aaa;
    cursor: pointer;
    text-align: center;
}

.flip-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

.flip-btn:active {
    background: #4a4a4a;
}

/* --- Sections --- */

.section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section > label {
    font-size: 11px;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.5px;
}

.section select {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #d0d0d0;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.toggles {
    flex-direction: row;
    gap: 12px;
    flex-wrap: wrap;
}

.toggles label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    text-transform: none;
    color: #aaa;
    cursor: pointer;
}

/* --- Metrics Panel --- */

#metrics-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.metrics-card {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 8px;
}

.metrics-card .title {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.metrics-card .values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 12px;
    font-size: 12px;
}

.metrics-card .values .label {
    color: #666;
}

.metrics-card .values .value {
    color: #d0d0d0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* --- Heatmap Legend --- */

.heatmap-opt {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #888;
    cursor: pointer;
}

#heatmap-legend {
    margin-top: 4px;
}

#heatmap-legend.hidden {
    display: none;
}

.legend-bar {
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(to right, #ff4d00, #ffcc99, #ffffff, #99ddff, #0088ff);
}

.legend-desc {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: #555;
    margin-top: 1px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #666;
    margin-top: 2px;
}

/* --- Buttons --- */

#btn-reset-cam {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #aaa;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-top: auto;
}

#btn-reset-cam:hover {
    background: #3a3a3a;
    color: #ddd;
}

/* --- Viewport --- */

#viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    z-index: 0;
}

#canvas3d {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 0;
}

#view-buttons {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    z-index: 10;
    width: 120px;
}

#view-buttons button {
    width: 38px;
    padding: 4px 0;
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid #444;
    color: #ccc;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
}

#view-buttons button:hover {
    background: rgba(60, 60, 60, 0.9);
    color: #fff;
}

#viewport-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    z-index: 10;
}

#viewport-controls button {
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid #444;
    color: #ccc;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

#viewport-controls button:hover {
    background: rgba(60, 60, 60, 0.9);
    color: #fff;
}

#viewport-controls button.active {
    background: rgba(80, 80, 80, 0.9);
    color: #fff;
    border-color: #888;
}

#shading-control {
    display: flex;
    gap: 1px;
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid #444;
    border-radius: 3px;
    overflow: hidden;
}

.shade-btn {
    background: transparent;
    border: none;
    color: #888;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.shade-btn:hover {
    background: rgba(60, 60, 60, 0.9);
    color: #ccc;
}

.shade-btn.active {
    background: rgba(80, 80, 80, 0.9);
    color: #fff;
}

#light-control {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid #444;
    border-radius: 3px;
    padding: 2px 8px;
    color: #ccc;
    font-size: 11px;
}

#outline-control {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid #444;
    border-radius: 3px;
    padding: 2px 8px;
    color: #ccc;
    font-size: 11px;
}

#outline-control label {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    white-space: nowrap;
}

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

#outline-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
}

#matcap-control {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid #444;
    border-radius: 3px;
    padding: 2px 8px;
    color: #ccc;
    font-size: 11px;
}

#matcap-control input[type="range"] {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #444;
    border-radius: 2px;
    outline: none;
}

#matcap-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
}

#matcap-control.hidden, #light-control.hidden {
    display: none;
}

#light-control input[type="range"] {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #444;
    border-radius: 2px;
    outline: none;
}

#light-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
}
