:root {
    color-scheme: dark;

    --rail-width: 240px;
    --skin: #e3bb95;
    --skin-dark: #aa7752;
    --bg: #17130f;
    --panel-bg: #221c17;
    --panel-bg-hover: #2a231d;
    --text: #f0e6dc;
    --muted: #a2938a;
    --border: #362c25;
    --track: #3b302a;
}

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

html,
body {
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;

    /* Only the rail is in flow (the canvas is absolute). Column wrap +
       align-content:flex-end pins the groups to the right edge and spills into
       a second column leftward instead of overflowing. */
    display: flex;
    flex-flow: column wrap;
    align-content: flex-end;
    gap: 10px;
    padding: 16px;
}

/* #rail groups the panels for markup's sake only. display:contents keeps the
   sections themselves as body's flex items, so the wrap above still breaks
   between groups -- a rail that were its own flex item could not wrap into a
   second column at all. */
#rail {
    display: contents;
}

.group {
    width: var(--rail-width);
    z-index: 2;

    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px 12px;
    transition: background 120ms ease, border-color 120ms ease;
}

.group:hover,
.group:focus-within {
    background: var(--panel-bg-hover);
    border-color: #4a3d33;
}

/* Category name. */
.group > h2 {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--skin-dark);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.group:focus-within > h2 {
    color: var(--skin);
}

.ctl + .ctl {
    margin-top: 6px;
}

/* The <h1> in each control is a value readout, not a page heading. */
.ctl h1 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctl:focus-within h1 {
    color: var(--skin);
}

#reset {
    display: block;
    width: 100%;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 8px 10px;
    cursor: pointer;
    transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

#reset:hover {
    color: var(--text);
    border-color: var(--skin-dark);
    background: #2f2620;
}

#reset:active {
    background: var(--panel-bg);
}

#reset:focus-visible {
    outline: 2px solid var(--skin);
    outline-offset: 2px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 20px;
    background: transparent;
    cursor: ew-resize;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: var(--track);
}

input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: var(--track);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    margin-top: -5.5px;
    border-radius: 50%;
    background: var(--skin);
    border: 2px solid var(--panel-bg);
    box-shadow: 0 1px 4px #0008;
}

input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--skin);
    border: 2px solid var(--panel-bg);
    box-shadow: 0 1px 4px #0008;
}

input[type="range"]:focus-visible {
    outline: 2px solid var(--skin);
    outline-offset: 4px;
    border-radius: 4px;
}

/* WebGL viewport: fills the window, with the rail painting over it via
   z-index. three.js writes width/height inline via renderer.setSize().
   pointer-events must stay enabled or OrbitControls receives no input. */
#cnv {
    position: fixed;
    inset: 0;
    z-index: 0;
    display: block;
    pointer-events: auto;
}

@media (max-width: 700px) {
    :root {
        --rail-width: 200px;
    }
}

/* The bra is a toggle and a model, not a coverage percentage: the two
   controls that are not ranges. */
.ctl .check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
}

.ctl .check:hover,
.ctl .check:focus-within {
    color: var(--skin);
}

input[type="checkbox"] {
    appearance: none;
    width: 15px;
    height: 15px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--track);
    cursor: pointer;
}

input[type="checkbox"]:checked {
    background: var(--skin);
    border-color: var(--skin);
}

input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--skin);
    outline-offset: 2px;
}

select {
    width: 100%;
    font: inherit;
    font-size: 0.75rem;
    color: var(--text);
    background: var(--track);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 7px;
    cursor: pointer;
}

select:focus-visible {
    outline: 2px solid var(--skin);
    outline-offset: 2px;
}
