/* ==========================================================================
   MOONTUNE STUDIOS // PHOTONSOUND PS-660 STUDIO SYSTEM
   1970s Walnut & Brushed Aluminum Optical Hi-Fi + Midnight Obsidian Theme
   ========================================================================== */

:root {
    /* Studio Chassis & Surface Tokens (Light Brushed Aluminum Default) */
    --bg-backdrop: radial-gradient(circle at 50% 25%, #1c1f24 0%, #0a0b0e 100%);
    --walnut-wood: linear-gradient(135deg, #3c2114 0%, #24120a 52%, #140905 100%);
    --walnut-border: #120804;
    --faceplate-bg:
        linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 3%, rgba(0, 0, 0, 0.08) 100%),
        repeating-linear-gradient(90deg, #dde1e4 0px, #e8ebed 2px, #d6dade 4px, #eceff1 6px);
    --faceplate-border: #a2a9af;
    --panel-surface: #e3e6e9;
    --panel-border: #9ba2a8;
    --panel-inset: rgba(255, 255, 255, 0.85);
    --card-dark-bg: linear-gradient(180deg, #1a1e24 0%, #101318 100%);
    --card-dark-border: #48505a;

    /* Typography & Contrast Tokens */
    --text-primary: #111418;
    --text-muted: #4b5259;
    --text-on-dark: #e2e8f0;
    --divider-color: #8d949b;

    /* Interactive Controls */
    --btn-bg: linear-gradient(180deg, #f3f5f7 0%, #d4d9de 52%, #bcc3ca 100%);
    --btn-hover: linear-gradient(180deg, #ffffff 0%, #e4e8ec 52%, #cbd1d8 100%);
    --btn-border: #7a828a;
    --btn-text: #111418;
    --input-bg: #ffffff;
    --input-border: #64748b;
    --input-text: #0f172a;

    /* Warm Incandescent VU Meters */
    --vu-lamp-bg: radial-gradient(circle at 50% 85%, #fffcf2 0%, #fff4d4 65%, #e8d294 100%);
    --vu-lamp-glow: rgba(255, 210, 110, 0.45);
    --vu-scale-black: #111418;
    --vu-danger-red: #d32f2f;
    --vu-carrier-cyan: #0284c7;

    /* Jewel Indicator Lamps & Laser Accents */
    --jewel-red: #ff2d3b;
    --jewel-red-glow: rgba(255, 45, 59, 0.78);
    --jewel-green: #00e676;
    --jewel-green-glow: rgba(0, 230, 118, 0.78);
    --jewel-amber: #ffb300;
    --jewel-amber-glow: rgba(255, 179, 0, 0.78);
    --photon-cyan: #00f0ff;

    /* Phosphor CRT Oscilloscope */
    --crt-phosphor: #00ff66;
    --crt-bg: #030d07;

    /* Font Stacks (Google Fonts + Clean System Fallbacks) */
    --font-brand: 'Oswald', 'Arial Narrow', 'Impact', sans-serif;
    --font-label: 'Chakra Petch', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
    --font-script: 'Chakra Petch', 'Georgia', serif;
}

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

body {
    background: var(--bg-backdrop);
    color: var(--text-primary);
    font-family: var(--font-label);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 24px 12px 48px 12px;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

.vintage-vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.8);
    z-index: 1;
}

/* ==========================================================================
   1. MAIN STUDIO CHASSIS & BRUSHED FACEPLATE
   ========================================================================== */
.hifi-chassis {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1100px;
    background: var(--walnut-wood);
    border-radius: 10px;
    padding: 12px 16px 18px 16px;
    box-shadow:
        0 28px 70px rgba(0, 0, 0, 0.88),
        0 6px 18px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
    border: 1px solid var(--walnut-border);
}

.aluminum-faceplate {
    background: var(--faceplate-bg);
    border-radius: 6px;
    border: 1px solid var(--faceplate-border);
    box-shadow:
        inset 0 1px 2px var(--panel-inset),
        inset 0 -3px 6px rgba(0, 0, 0, 0.25),
        0 4px 12px rgba(0, 0, 0, 0.4);
    padding: 22px 26px;
    color: var(--text-primary);
    transition: background 0.25s ease, border-color 0.25s ease;
}

/* ==========================================================================
   2. MOONTUNE STUDIOS HEADER & GLOBAL NAVIGATION
   ========================================================================== */
.hifi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid var(--divider-color);
    padding-bottom: 16px;
    margin-bottom: 18px;
    box-shadow: 0 1px 0 var(--panel-inset);
    flex-wrap: wrap;
    gap: 14px;
}

.brand-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-top-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.brand-emblem {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.brand-wordmark {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-family: var(--font-brand);
    font-size: clamp(1.55rem, 3vw, 2.2rem);
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-primary);
    line-height: 1.05;
    text-transform: uppercase;
}

.brand-series {
    font-family: var(--font-script);
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: 2px;
    color: #b45309;
    text-transform: uppercase;
}

body.theme-midnight .brand-series {
    color: #38bdf8;
}

.model-line {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1.3px;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
}

.model-number {
    color: var(--text-primary);
    font-weight: 800;
    background: rgba(100, 116, 139, 0.18);
    padding: 1px 7px;
    border-radius: 3px;
}

.header-right-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

@media (max-width: 820px) {
    .header-right-stack {
        align-items: flex-start;
        width: 100%;
    }
}

.spec-badges,
.studio-nav {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.badge-pill {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    padding: 3px 8px;
    background: rgba(148, 163, 184, 0.22);
    border: 1px solid var(--panel-border);
    border-radius: 3px;
    color: var(--text-primary);
}

.badge-pill.highlight {
    background: #0f172a;
    color: #38bdf8;
    border-color: #0284c7;
}

.badge-pill.offline-ok {
    background: rgba(22, 101, 52, 0.18);
    color: #15803d;
    border-color: #22c55e;
}

body.theme-midnight .badge-pill.offline-ok {
    color: #4ade80;
}

.hifi-toggle-btn,
.hifi-link-btn {
    font-family: var(--font-label);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 6px 11px;
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    border-radius: 4px;
    color: var(--btn-text);
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 0.6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), inset 0 1px 0 var(--panel-inset);
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.hifi-toggle-btn:hover,
.hifi-link-btn:hover {
    background: var(--btn-hover);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
}

.hifi-link-btn.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.hifi-link-btn.highlight {
    background: #0f172a;
    color: #38bdf8;
    border-color: #0284c7;
}

.hifi-link-btn.highlight:hover,
.hifi-link-btn.highlight.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #38bdf8;
}

.hifi-link-btn.accent {
    background: #2b0d12;
    color: #ff7a84;
    border-color: #d32f2f;
}

.hifi-link-btn.accent:hover,
.hifi-link-btn.accent.active {
    background: #d32f2f;
    color: #ffffff;
    border-color: #ff7a84;
}

.btn-install-pwa {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border-color: #38bdf8;
}

.btn-install-pwa:hover {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}

/* ==========================================================================
   3. PILOT TELEMETRY STRIP
   ========================================================================== */
.pilot-status-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    background: #1b2026;
    border-radius: 5px;
    border: 1px solid #0f1318;
    padding: 9px 14px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.55);
    gap: 10px 16px;
}

.pilot-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pilot-lamp {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #475569;
    flex-shrink: 0;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.7);
    transition: all 0.25s ease;
}

.pilot-lamp.active {
    background: var(--jewel-green);
    box-shadow: 0 0 8px var(--jewel-green-glow);
}

.pilot-lamp.carrier-locked {
    background: #00f0ff;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.9);
}

.pilot-lamp.amber {
    background: var(--jewel-amber);
    box-shadow: 0 0 8px var(--jewel-amber-glow);
}

.pilot-label {
    font-size: 0.66rem;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.9px;
    white-space: nowrap;
}

.pilot-val {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: #f1f5f9;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================================================
   4. DUAL BACKLIT ANALOG VU METERS
   ========================================================================== */
.vu-meters-enclosure {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 20px;
}

@media (max-width: 720px) {
    .vu-meters-enclosure { grid-template-columns: 1fr; }
}

.vintage-vu-meter {
    background: #171a1e;
    border: 2px solid #4e565e;
    border-radius: 7px;
    padding: 8px;
    box-shadow:
        inset 0 3px 7px rgba(0, 0, 0, 0.9),
        0 2px 5px rgba(0, 0, 0, 0.25);
}

.vu-glass-face {
    background: var(--vu-lamp-bg);
    border-radius: 4px;
    border: 1px solid #736952;
    box-shadow:
        inset 0 0 18px var(--vu-lamp-glow),
        inset 0 2px 5px rgba(0, 0, 0, 0.22);
    height: 145px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 14px;
}

.vu-dial-scale {
    position: relative;
    width: 100%;
    height: 100%;
}

.vu-ticks-legend {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--vu-scale-black);
    padding: 0 4px;
    z-index: 2;
    position: relative;
}

.vu-ticks-legend .vu-red { color: var(--vu-danger-red); }
.vu-ticks-legend .vu-zero { font-weight: 800; font-size: 0.72rem; }

.vu-arc-graphic {
    position: relative;
    width: 100%;
    height: 3px;
    margin-top: 4px;
    display: flex;
}

.vu-black-arc {
    width: 72%;
    height: 2px;
    background: var(--vu-scale-black);
}

.vu-red-arc {
    width: 28%;
    height: 3px;
    background: var(--vu-danger-red);
}

.vu-cyan-arc {
    width: 28%;
    height: 3px;
    background: var(--vu-carrier-cyan);
}

.vu-title-center {
    position: absolute;
    top: 34px;
    left: 0; right: 0;
    text-align: center;
    font-family: var(--font-brand);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: rgba(20, 24, 28, 0.78);
}

.vu-subtext-center {
    position: absolute;
    top: 52px;
    left: 0; right: 0;
    text-align: center;
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 1.4px;
    color: rgba(20, 24, 28, 0.62);
}

.vu-needle-pivot {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 32px;
    z-index: 5;
}

.vu-needle {
    position: absolute;
    bottom: 16px;
    left: 50%;
    width: 1.8px;
    height: 98px;
    background: #0f1215;
    transform-origin: bottom center;
    transform: rotate(var(--vu-rot-left, -38deg));
    transition: transform 0.06s cubic-bezier(0.2, 0.8, 0.3, 1);
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.35);
}

.vu-needle::before {
    content: '';
    position: absolute;
    top: 0; left: -1px;
    width: 3.5px; height: 18px;
    background: var(--vu-danger-red);
    border-radius: 1px;
}

.vu-needle.red {
    transform: rotate(var(--vu-rot-right, -38deg));
}

.vu-needle.red::before {
    background: #0284c7;
}

.vu-pivot-cap {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #525a61 0%, #111418 100%);
    border: 1px solid #737c84;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.vu-meter-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 6;
    margin-top: auto;
}

.vu-metric-text {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: #272d33;
}

.peak-lamp {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 2px 6px;
    background: #334155;
    color: #94a3b8;
    border-radius: 2px;
    transition: all 0.2s;
}

.peak-lamp.active {
    background: var(--jewel-red);
    color: #ffffff;
    box-shadow: 0 0 10px var(--jewel-red-glow);
}

/* ==========================================================================
   5. CASSETTE WELL, TRACK PLAYER & CRT OSCILLOSCOPE BAY
   ========================================================================== */
.deck-middle-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 18px;
    margin-bottom: 20px;
}

@media (max-width: 860px) {
    .deck-middle-row { grid-template-columns: 1fr; }
}

.cassette-crt-bay {
    background: #12161b;
    border: 2px solid #4c555f;
    border-radius: 7px;
    padding: 12px 14px;
    box-shadow: inset 0 2px 7px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 700;
}

.tape-counter-block {
    display: flex;
    align-items: center;
    gap: 8px;
}

.counter-digits {
    display: flex;
    background: #000000;
    border: 1px solid #475569;
    border-radius: 3px;
    padding: 2px 6px;
    gap: 4px;
}

.digit {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: #ffb300;
    text-shadow: 0 0 4px rgba(255, 179, 0, 0.5);
}

.btn-counter-reset {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 3px 7px;
    background: #273242;
    border: 1px solid #4e5d73;
    border-radius: 3px;
    color: #e2e8f0;
    cursor: pointer;
}

.btn-counter-reset:hover {
    background: #334155;
}

.scope-mode-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

/* Dedicated Cassette Tape Strip above CRT so scope waveform stays 100% clear */
.cassette-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #0b0e14 0%, #161c26 100%);
    border: 1px solid #2b3545;
    border-radius: 5px;
    padding: 7px 14px;
    gap: 12px;
}

.cassette-reel {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    background: radial-gradient(circle, #f59e0b 24%, #1e293b 25%, #0f172a 70%);
    border: 2px dashed #cbd5e1;
    opacity: 0.55;
    transition: opacity 0.25s;
}

.cassette-strip.running .cassette-reel {
    opacity: 1;
    animation: reel-spin 1.8s linear infinite;
}

@keyframes reel-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cassette-label-plate {
    display: flex;
    flex-direction: column;
    text-align: center;
    min-width: 0;
    flex: 1;
}

.tape-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tape-sub {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* CRT OSCILLOSCOPE */
.crt-screen-frame {
    position: relative;
    width: 100%;
    height: 170px;
    background: var(--crt-bg);
    border: 2px solid #222d27;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: inset 0 0 26px rgba(0, 255, 102, 0.14);
}

#oscilloscope {
    width: 100%;
    height: 100%;
    display: block;
}

/* Track Transport Scrubber Bar */
.track-player-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0a0e13;
    border: 1px solid #28323e;
    border-radius: 4px;
    padding: 6px 10px;
}

.track-time {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: #00ff66;
    white-space: nowrap;
}

.track-scrub {
    flex: 1;
    height: 6px;
    accent-color: #38bdf8;
    cursor: pointer;
}

.btn-mini-pill {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid #3f4e63;
    background: #1a2330;
    color: #cbd5e1;
    cursor: pointer;
}

.btn-mini-pill.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #38bdf8;
}

/* ==========================================================================
   6. RIGHT-HAND TUNING RACK & LEVER SWITCHES
   ========================================================================== */
.analog-tuning-rack {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--panel-surface);
    border: 1px solid var(--panel-border);
    border-radius: 7px;
    padding: 14px 16px;
    box-shadow: inset 0 1px 0 var(--panel-inset), 0 2px 5px rgba(0, 0, 0, 0.12);
    gap: 12px;
}

.tuning-module {
    margin-bottom: 4px;
}

.knob-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.9px;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-wrapper input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #94a3b8;
    outline: none;
    -webkit-appearance: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #94a3b8 100%);
    border: 2px solid #334155;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.slider-readout {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-primary);
    width: 68px;
    text-align: right;
}

.switch-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.lever-switch-block {
    display: flex;
}

.tactile-lever {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 9px 6px;
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16), inset 0 1px 0 var(--panel-inset);
    transition: all 0.15s ease;
}

.tactile-lever.active {
    background: #0f172a;
    border-color: #0284c7;
}

.lever-text {
    font-family: var(--font-label);
    font-size: 0.64rem;
    font-weight: 700;
    color: var(--btn-text);
    text-align: center;
}

.tactile-lever.active .lever-text {
    color: #38bdf8;
    font-weight: 800;
}

.lever-handle {
    width: 16px;
    height: 7px;
    background: #475569;
    border-radius: 2px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.tactile-lever.active .lever-handle {
    background: var(--jewel-green);
    box-shadow: 0 0 7px var(--jewel-green-glow);
}

/* ==========================================================================
   7. MECHANICAL PIANO-KEY TRANSPORT DECK (RESPONSIVE GRID)
   ========================================================================== */
.transport-deck-section {
    background: #161a1f;
    border: 2px solid #485058;
    border-radius: 7px;
    padding: 14px 16px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.72);
}

.transport-label {
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 1.4px;
    color: #94a3b8;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.piano-keys-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 10px;
}

.piano-key {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    padding: 8px 10px;
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    border-radius: 5px;
    cursor: pointer;
    box-shadow:
        0 4px 7px rgba(0, 0, 0, 0.36),
        inset 0 1px 0 var(--panel-inset),
        inset 0 -2px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.08s ease, box-shadow 0.12s ease, background 0.15s ease;
    position: relative;
}

.piano-key:hover {
    background: var(--btn-hover);
}

.piano-key:active {
    transform: translateY(2px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), inset 0 1px 3px rgba(0, 0, 0, 0.35);
}

.piano-key.active-hero {
    border: 2px solid #0284c7;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.32), inset 0 1px 0 var(--panel-inset);
}

.piano-key.running-active {
    background: linear-gradient(to bottom, #166534 0%, #14532d 100%) !important;
    border-color: #22c55e !important;
    color: #ffffff !important;
}

.key-icon {
    font-size: 1.05rem;
    color: var(--btn-text);
}

.key-name {
    font-family: var(--font-brand);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--btn-text);
    white-space: nowrap;
}

.running-active .key-icon,
.running-active .key-name {
    color: #ffffff !important;
}

.key-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    flex-shrink: 0;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
}

.key-indicator.on {
    background: var(--jewel-green);
    box-shadow: 0 0 8px var(--jewel-green-glow);
}

.key-indicator.rec.on {
    background: var(--jewel-red);
    box-shadow: 0 0 8px var(--jewel-red-glow);
}

/* ==========================================================================
   8. SIGNAL ROUTING PANEL & STUDIO MODULE CARDS
   ========================================================================== */
.hifi-routing-panel,
.studio-panel {
    background: var(--panel-surface);
    border: 1px solid var(--panel-border);
    border-radius: 7px;
    padding: 16px 18px;
    margin-bottom: 20px;
    box-shadow: inset 0 1px 0 var(--panel-inset);
}

.studio-card-dark {
    background: var(--card-dark-bg);
    border: 2px solid var(--card-dark-border);
    border-radius: 7px;
    padding: 20px 22px;
    margin-bottom: 18px;
    color: var(--text-on-dark);
    box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.65);
}

.studio-card-title {
    font-family: var(--font-brand);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: #f8fafc;
    border-bottom: 1px solid rgba(148, 163, 184, 0.24);
    padding-bottom: 8px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.studio-card-title .spec-label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: #38bdf8;
    font-weight: 600;
}

.routing-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-primary);
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.hifi-btn-small {
    font-family: var(--font-label);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 10px;
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

.hifi-btn-small:hover {
    background: var(--btn-hover);
}

.routing-grid,
.studio-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}

@media (max-width: 720px) {
    .routing-grid,
    .studio-grid-2 { grid-template-columns: 1fr; }
}

.routing-channel label,
.studio-field-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.studio-card-dark .studio-field-label {
    color: #fbbf24;
}

.hifi-select,
.studio-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    padding: 8px 11px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--input-text);
    font-weight: 600;
    outline: none;
}

.studio-card-dark .hifi-select,
.studio-card-dark .studio-input {
    background: #070a10;
    border-color: #334155;
    color: #f8fafc;
}

.hifi-select:focus,
.studio-input:focus {
    border-color: #38bdf8;
}

.hardware-info-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #0f172a;
    border-radius: 5px;
    padding: 10px 13px;
    color: #e2e8f0;
    flex-wrap: wrap;
}

.info-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: #38bdf8;
    white-space: nowrap;
}

.info-desc {
    font-size: 0.74rem;
    color: #cbd5e1;
    margin: 0;
}

/* ==========================================================================
   9. MASTERING BUTTONS, GAUGES & PROGRESS BARS
   ========================================================================== */
.studio-btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.studio-btn {
    font-family: var(--font-brand);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 11px 18px;
    border-radius: 5px;
    border: 1px solid var(--btn-border);
    border-bottom: 3px solid #475569;
    background: var(--btn-bg);
    color: var(--btn-text);
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.15s ease;
    text-transform: uppercase;
}

.studio-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.studio-btn:active:not(:disabled) {
    transform: translateY(2px);
}

.studio-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.studio-btn.primary-crimson {
    background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
    color: #ffffff;
    border-color: #f87171;
    border-bottom-color: #7f1d1d;
}

.studio-btn.primary-cyan {
    background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border-color: #38bdf8;
    border-bottom-color: #0c4a6e;
}

.studio-btn.audition-green {
    background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
    color: #ffffff;
    border-color: #4ade80;
    border-bottom-color: #14532d;
}

.gauge-track {
    width: 100%;
    height: 18px;
    background: #05080d;
    border: 1px solid #334155;
    border-radius: 4px;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00e676 0%, #38bdf8 65%, #f59e0b 90%, #ef4444 100%);
    transition: width 0.25s ease;
}

.gauge-stats {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: #cbd5e1;
}

.progress-wrap {
    width: 100%;
    height: 10px;
    background: #05080d;
    border: 1px solid #334155;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 14px;
    display: none;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ff2d3b, #ffb300, #00e676);
    transition: width 0.12s linear;
}

.status-console-box {
    margin-top: 14px;
    padding: 13px 15px;
    border-radius: 5px;
    background: #040806;
    border: 1px solid #163322;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.55;
    color: #34d399;
    white-space: pre-wrap;
    max-height: 220px;
    overflow-y: auto;
}

.track-queue-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 10px 0 14px 0;
}

.track-queue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #080c12;
    border: 1px solid #263142;
    border-radius: 4px;
    padding: 7px 10px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: #e2e8f0;
    gap: 10px;
}

.track-queue-meta {
    color: #38bdf8;
    font-size: 0.7rem;
    white-space: nowrap;
}

.wiring-prose {
    font-size: 0.82rem;
    line-height: 1.65;
    color: #cbd5e1;
}

.wiring-prose strong {
    color: #ffffff;
}

.wiring-prose code {
    background: rgba(56, 189, 248, 0.14);
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
}

.physics-callout {
    background: rgba(2, 132, 199, 0.1);
    border-left: 3px solid #38bdf8;
    padding: 12px 14px;
    border-radius: 0 5px 5px 0;
    margin-top: 12px;
    font-size: 0.8rem;
    color: #e2e8f0;
}

.ascii-diagram {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: #a7f3d0;
    background: #05090d;
    border: 1px solid #1e293b;
    border-radius: 5px;
    padding: 12px 14px;
    margin: 12px 0;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.4;
}

/* ==========================================================================
   10. DIAGNOSTIC ENGINEERING CONSOLE
   ========================================================================== */
.hifi-engineering-console {
    background: #020604;
    border: 2px solid #15311f;
    border-radius: 7px;
    padding: 14px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.9);
}

.console-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--crt-phosphor);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 700;
    border-bottom: 1px dashed rgba(0, 255, 102, 0.28);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.quick-commands-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.quick-cmd-title {
    font-size: 0.65rem;
    color: #94a3b8;
    font-weight: 700;
    letter-spacing: 0.6px;
}

.btn-quick-cmd {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    padding: 4px 9px;
    background: rgba(0, 255, 102, 0.08);
    border: 1px solid rgba(0, 255, 102, 0.32);
    border-radius: 3px;
    color: var(--crt-phosphor);
    cursor: pointer;
    transition: background 0.15s;
}

.btn-quick-cmd:hover {
    background: rgba(0, 255, 102, 0.2);
}

.terminal-log-box {
    height: 130px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid #0f2415;
    border-radius: 4px;
    padding: 8px 10px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.45;
    color: #e2e8f0;
    margin-bottom: 10px;
}

.log-line { margin-bottom: 2px; }
.log-line.ok { color: #00ff66; }
.log-line.warn { color: #f59e0b; }
.log-line.err { color: #ef4444; }
.log-line.cmd { color: #38bdf8; }
.log-line.sys { color: #94a3b8; }

.terminal-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #050c07;
    border: 1px solid #142e1d;
    border-radius: 4px;
    padding: 6px 10px;
}

.terminal-prompt {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--crt-phosphor);
    font-weight: 700;
}

#cmd-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #ffffff;
}

.cursor-block {
    width: 8px;
    height: 14px;
    background: var(--crt-phosphor);
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.studio-footer {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 14px;
}

/* Update Toast Banner */
.pwa-update-toast {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 50;
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid #38bdf8;
    border-radius: 6px;
    padding: 10px 14px;
    display: none;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    font-size: 0.76rem;
}

/* Technical Optical Telemetry & Architecture Grid */
.tech-spec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.tech-spec-cell {
    background: #070b11;
    border: 1px solid #263244;
    border-radius: 5px;
    padding: 10px 12px;
}

.tech-spec-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.9px;
    color: #94a3b8;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.tech-spec-val {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: #38bdf8;
}

.tech-spec-sub {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: #cbd5e1;
    margin-top: 3px;
}
