/* CR Neuromodulation — Synth-style single-screen layout */

:root {
    --bg: #0a0b0f;
    --surface: #12141c;
    --surface-raised: #1a1d28;
    --border: #2a2e3c;
    --border-light: #363b4d;
    --text: #f0f0f4;
    --text-muted: #a0a2b0;
    --text-dim: #6e7182;
    --accent: #7b73ff;
    --accent-glow: rgba(123, 115, 255, 0.15);
    --accent-hover: #8d86ff;
    --success: #34d399;
    --success-dim: #1a2f28;
    --success-glow: rgba(52, 211, 153, 0.15);
    --radius: 10px;
    --radius-sm: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html {
    font-size: 17.25px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.synth {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Header / Transport ---- */
header {
    display: flex;
    align-items: center;
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-shrink: 0;
    background: var(--surface);
}

.brand h1 {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.brand-sep {
    color: var(--border-light);
    font-weight: 300;
    font-size: 0.9rem;
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    letter-spacing: 0.05em;
    font-weight: 500;
    text-decoration: none;
}

.brand-sub:hover {
    color: var(--text);
}

.transport {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: 1.5rem;
}

.transport-btn {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.play-btn {
    width: 36px;
    height: 36px;
}

.play-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

.play-btn.playing {
    border-color: var(--success);
    color: var(--success);
    background: var(--success-dim);
}

.reset-btn {
    width: 28px;
    height: 28px;
}

.reset-btn:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

.play-btn svg {
    width: 16px;
    height: 16px;
}

.reset-btn svg {
    width: 13px;
    height: 13px;
}

.transport-status {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    min-width: 3rem;
}

/* ---- Instructions ---- */
.instructions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.68rem;
    color: var(--text-dim);
    flex-shrink: 0;
}

.instructions strong {
    color: var(--text-muted);
    font-weight: 600;
}

.inst-sep {
    color: var(--border-light);
}

/* ---- Module Rack ---- */
.rack {
    flex: 1;
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: 1px;
    background: var(--border);
    min-height: 0;
}

.module {
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.module-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 1rem;
    height: 2.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-raised);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.module-body {
    flex: 1;
    padding: 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

/* ---- Controls ---- */
.ctrl {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ctrl-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.ctrl-name {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
}

.ctrl-val {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    font-family: var(--font);
}

.range-ends {
    display: flex;
    justify-content: space-between;
    font-size: 0.55rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

.ctrl-row {
    display: flex;
    gap: 0.6rem;
}

.ctrl-half {
    flex: 1;
}

/* Info tooltips */
.tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 0.3rem;
    cursor: help;
}

.tip svg {
    width: 12px;
    height: 12px;
    color: var(--text-dim);
    transition: color 0.15s;
}

.tip:hover svg {
    color: var(--accent);
}

.tooltip {
    position: fixed;
    width: 220px;
    padding: 0.5rem 0.65rem;
    background: var(--surface-raised);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.15s;
}

.tooltip.visible {
    opacity: 1;
}

/* Slider with mod overlay */
.slider-wrap {
    position: relative;
    width: 100%;
    height: 18px;
    display: flex;
    align-items: center;
}

/* Visible track background rendered separately */
.slider-wrap::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    transform: translateY(-50%);
    background: var(--border-light);
    border-radius: 2px;
    z-index: 1;
}

.mod-track {
    position: absolute;
    top: 50%;
    height: 4px;
    transform: translateY(-50%);
    border-radius: 2px;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 2;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.6), 0 0 3px rgba(255, 255, 255, 0.4);
}

.mod-track.active {
    opacity: 0.85;
}

/* Range Inputs */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    position: relative;
    z-index: 3;
}

.slider-wrap input[type="range"] {
    background: transparent;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: box-shadow 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 5px var(--accent-glow);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb:hover {
    box-shadow: 0 0 0 5px var(--accent-glow);
}

/* Selects */
select {
    width: 100%;
    padding: 0.35rem 0.5rem;
    background: var(--surface-raised);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

select:focus {
    border-color: var(--accent);
}

/* Toggle in module label */
.mod-toggle {
    position: relative;
    width: 32px;
    height: 18px;
    cursor: pointer;
}

.mod-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-light);
    border-radius: 9px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.mod-toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.mod-toggle input:checked + .toggle-slider::before {
    transform: translateX(14px);
    background: #fff;
}

/* ---- Footer ---- */
footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}

footer span {
    font-size: 0.55rem;
    color: var(--text-dim);
}

footer a {
    color: inherit;
    text-decoration: none;
}

footer a:hover {
    color: var(--text-muted);
}

.sep {
    opacity: 0.4;
}

/* ---- Responsive: stack on mobile ---- */
@media (max-width: 700px) {
    html { font-size: 14px; }

    body { overflow: auto; }
    .synth { height: auto; min-height: 100vh; }

    .rack {
        grid-template-columns: 1fr;
    }

    .module-body {
        padding: 0.75rem 1rem 1rem;
    }
}
