:root {
    --bg-void: #0a0a0c;
    --bg-deep: #121216;
    --glass-bg: rgba(22, 22, 28, 0.55);
    --glass-bg-strong: rgba(28, 28, 36, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hot: rgba(255, 255, 255, 0.18);
    --glass-highlight: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.8), 0 2px 8px -2px rgba(0, 0, 0, 0.4);

    --text-hi: rgba(255, 255, 255, 0.96);
    --text-mid: rgba(255, 255, 255, 0.55);
    --text-lo: rgba(255, 255, 255, 0.32);
    --text-micro: rgba(255, 255, 255, 0.22);

    --accent: #e8e8ec;
    --accent-glow: rgba(255, 255, 255, 0.12);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-xl: 28px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --dur: 220ms;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg-void);
    color: var(--text-hi);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    height: 100vh;
    overflow: hidden;
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
}

.lab-container { display: block; height: 100vh; width: 100vw; position: relative; }

canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    touch-action: none;
    background: #f4f2ed;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

/* -------- Glass primitives -------- */
.glass {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    isolation: isolate;
}

/* inner top highlight — simulates a glass edge */
.glass::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0) 40%, rgba(255,255,255,0.04));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 1;
}

/* faint noise for realism */
.glass::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    opacity: 0.35;
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 0;
}

.glass > * { position: relative; z-index: 2; }

/* -------- Typography -------- */
.eyebrow {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-lo);
}
.title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-hi);
    letter-spacing: -0.01em;
}

/* -------- Controls -------- */
.btn {
    appearance: none;
    background: var(--glass-highlight);
    color: var(--text-hi);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font: inherit;
    line-height: 1;
}
.btn:hover { background: rgba(255,255,255,0.09); border-color: var(--glass-border-hot); }
.btn:active { transform: scale(0.96); }
.btn svg { opacity: 0.8; }

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--glass-highlight);
    border: 1px solid var(--glass-border);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-mid);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    user-select: none;
    white-space: nowrap;
}
.chip:hover { color: var(--text-hi); border-color: var(--glass-border-hot); }
.chip.active {
    color: var(--text-hi);
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}

/* -------- Slider -------- */
.slider {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 20px;
    width: 140px;
    cursor: pointer;
}
.slider::-webkit-slider-runnable-track {
    height: 4px;
    background: linear-gradient(90deg, rgba(255,255,255,0.35) 0 var(--val, 30%), rgba(255,255,255,0.08) var(--val, 30%) 100%);
    border-radius: 2px;
}
.slider::-moz-range-track {
    height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    margin-top: -5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(0,0,0,0.08);
    transition: transform var(--dur) var(--ease);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
    width: 14px; height: 14px; border: none; border-radius: 50%;
    background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* -------- Color swatches -------- */
.swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: transform var(--dur) var(--ease);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.3);
}
.swatch:hover { transform: scale(1.12); }
.swatch.active {
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2), 0 0 0 2px var(--bg-void), 0 0 0 3px rgba(255,255,255,0.85);
}
.swatch-key {
    position: absolute;
    top: -6px; right: -6px;
    background: var(--bg-void);
    color: var(--text-mid);
    font-size: 9px;
    font-weight: 700;
    width: 14px; height: 14px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--glass-border);
}

/* -------- Divider -------- */
.divider-v {
    width: 1px;
    align-self: stretch;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,0.1) 20% 80%, transparent);
}

/* -------- Layout: bottom dock -------- */
.dock {
    position: absolute;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: stretch;
    gap: 12px;
    z-index: 50;
    padding: 14px 18px;
}
.dock-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}
.dock-row { display: flex; align-items: center; gap: 12px; }

/* -------- Brush preview bubble -------- */
.brush-bubble {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    overflow: hidden;
}
.brush-dot {
    border-radius: 50%;
    background: var(--brush-color, #fff);
    transition: width var(--dur) var(--ease), height var(--dur) var(--ease), background var(--dur) var(--ease);
    filter: blur(var(--brush-blur, 0px));
}

/* -------- Top-left branding -------- */
.brand {
    position: absolute;
    top: 28px; left: 28px;
    user-select: none;
    z-index: 40;
}
.brand h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, #fff, rgba(255,255,255,0.4));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.brand p {
    margin: 2px 0 0;
    font-size: 9.5px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--text-micro);
    font-weight: 700;
}

/* -------- Side rail (brush types) -------- */
.rail {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 8px;
    z-index: 40;
}
.rail-item {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-mid);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    position: relative;
}
.rail-item:hover { background: var(--glass-highlight); color: var(--text-hi); }
.rail-item.active {
    background: rgba(255,255,255,0.12);
    border-color: var(--glass-border-hot);
    color: var(--text-hi);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}
.rail-item .tip {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-deep);
    border: 1px solid var(--glass-border);
    color: var(--text-hi);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}
.rail-item:hover .tip { opacity: 1; }

/* -------- Stat HUD (top right) -------- */
.hud {
    position: absolute;
    top: 28px; right: 28px;
    padding: 12px 16px;
    display: flex;
    gap: 20px;
    z-index: 40;
}
.hud-stat { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.hud-val { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; color: var(--text-hi); }
.hud-lbl { font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-lo); font-weight: 700; }

/* -------- Mixing palette (bottom right) -------- */
.mixer {
    position: absolute;
    bottom: 28px;
    right: 28px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 45;
    user-select: none;
}
.mixer-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
}
.mixer-surface {
    position: relative;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    overflow: hidden;
    cursor: crosshair;
    background:
        radial-gradient(circle at 30% 28%, rgba(255,255,255,0.08), rgba(255,255,255,0) 55%),
        radial-gradient(circle at 70% 75%, rgba(0,0,0,0.25), rgba(0,0,0,0) 60%),
        #f0ede4;
    box-shadow:
        inset 0 2px 8px rgba(0,0,0,0.25),
        inset 0 0 0 1px rgba(0,0,0,0.15),
        0 4px 14px rgba(0,0,0,0.35);
    touch-action: none;
}
.mixer-surface canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    background: transparent;
    border-radius: 50%;
}
.mixer-readout {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mixer-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2), 0 2px 6px rgba(0,0,0,0.3);
}
.mixer-strength {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}
.mixer-strength .slider { width: 130px; }
.mixer-actions { display: flex; gap: 6px; }
.mixer-btn {
    appearance: none;
    background: var(--glass-highlight);
    color: var(--text-mid);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font: 600 10px/1 'Inter', sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}
.mixer-btn:hover { color: var(--text-hi); border-color: var(--glass-border-hot); }
.mixer-btn.primary { background: rgba(255,255,255,0.14); color: var(--text-hi); }
.mixer-btn:active { transform: scale(0.96); }

/* lil-gui theme alignment */
.lil-gui {
    --background-color: var(--glass-bg-strong);
    --text-color: var(--text-hi);
    --title-background-color: transparent;
    --title-text-color: var(--text-mid);
    --widget-color: rgba(255,255,255,0.08);
    --hover-color: rgba(255,255,255,0.12);
    --focus-color: rgba(255,255,255,0.2);
    --number-color: var(--text-hi);
    --string-color: var(--text-hi);
    --font-size: 11px;
    --width: 260px;
    backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
