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

:root {
  --bg: #08080d;
  --panel: #111118;
  --panel-border: #1e1e2a;
  --text: #8a8a9a;
  --text-dim: #4a4a5a;
  --phosphor: #00ff41;
  --phosphor-dim: #003a10;
  --bezel: #1a1a22;
  --bezel-highlight: #2a2a35;
  --knob-bg: #222230;
  --knob-border: #333345;
}

html, body {
  width: 100%; min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='4' height='4' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1' height='1' fill='%23ffffff' fill-opacity='0.015'/%3E%3C/svg%3E") repeat;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* HEADER */
#header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(180deg, #16161e 0%, #111118 100%);
  border-bottom: 1px solid var(--panel-border);
}
.logo {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900; font-size: 28px;
  color: var(--phosphor);
  letter-spacing: 2px;
  text-shadow: 0 0 20px var(--phosphor), 0 0 40px var(--phosphor-dim);
}
.logo-sep { color: var(--text-dim); }
.subtitle { font-size: 11px; color: var(--text-dim); letter-spacing: 3px; text-transform: uppercase; }
.header-right { display: flex; align-items: center; gap: 8px; }
.power-led {
  width: 10px; height: 10px; border-radius: 50%;
  background: #333;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.3s;
}
.power-led.on {
  background: var(--phosphor);
  box-shadow: 0 0 6px var(--phosphor), 0 0 12px var(--phosphor), inset 0 0 2px rgba(255,255,255,0.3);
  animation: pulse-led 2s ease-in-out infinite;
}
@keyframes pulse-led {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.power-label { font-size: 10px; color: var(--text-dim); letter-spacing: 2px; }

/* MAIN LAYOUT */
#main {
  flex: 1;
  display: flex;
  padding: 16px;
  gap: 16px;
}

/* SCOPE SECTION */
#scope-section {
  flex: 0 0 auto;
  display: flex; align-items: flex-start; justify-content: center;
}

#bezel {
  position: relative;
  padding: 20px;
  background: linear-gradient(145deg, #1c1c28 0%, #141420 50%, #101018 100%);
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 4px 20px rgba(0,0,0,0.6),
    0 0 0 1px var(--panel-border),
    0 0 0 3px #0d0d14,
    0 0 0 4px var(--panel-border);
}

#screen-container {
  position: relative;
  width: 500px; height: 500px;
  border-radius: 8px;
  overflow: hidden;
  background: #020208;
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.8),
    inset 0 0 4px rgba(0,0,0,0.9);
}

#screen-container canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
}

#persist-canvas { z-index: 1; }
#trace-canvas { z-index: 2; }
#overlay-canvas { z-index: 3; pointer-events: none; }

.bezel-label {
  position: absolute;
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.bezel-label-tl { top: 5px; left: 24px; }
.bezel-label-tr { top: 5px; right: 24px; }
.bezel-label-bl { bottom: 5px; left: 24px; }
.bezel-label-br { bottom: 5px; right: 24px; }

.drop-overlay {
  position: absolute; inset: 0;
  z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 255, 65, 0.08);
  border: 2px dashed var(--phosphor);
  border-radius: 8px;
}
.drop-overlay.hidden { display: none; }
.drop-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px; font-weight: 700;
  color: var(--phosphor);
  text-shadow: 0 0 20px var(--phosphor);
  letter-spacing: 4px;
}

.warmup-overlay {
  position: absolute; inset: 0; z-index: 5;
  background: #020208;
  pointer-events: none;
  opacity: 1;
  transition: opacity 1.5s ease;
}
.warmup-overlay.fading { opacity: 0; pointer-events: none; }
.warmup-overlay.hidden { display: none; }

/* CONTROLS SECTION */
#controls-section {
  flex: 1;
  min-width: 300px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

#controls-section::-webkit-scrollbar { width: 6px; }
#controls-section::-webkit-scrollbar-track { background: var(--bg); }
#controls-section::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 3px; }

.control-panel {
  display: flex; flex-direction: column; gap: 12px;
}

.panel-group {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
}

.panel-title {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--panel-border);
}

/* HARDWARE BUTTON */
.hardware-btn {
  display: block; width: 100%;
  padding: 10px 16px;
  background: linear-gradient(180deg, #2a2a38 0%, #1e1e28 100%);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--phosphor);
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
  text-shadow: 0 0 8px var(--phosphor-dim);
}
.hardware-btn:hover {
  background: linear-gradient(180deg, #333345 0%, #252530 100%);
  box-shadow: 0 0 10px var(--phosphor-dim);
}
.hardware-btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}
.hardware-btn.small-btn { padding: 6px 12px; font-size: 11px; }

.file-info {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
}

/* TRANSPORT */
.transport-btns {
  display: flex; gap: 6px; margin-bottom: 8px;
}
.transport-btn {
  flex: 1;
  padding: 8px;
  background: linear-gradient(180deg, #222230 0%, #1a1a24 100%);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.transport-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #2e2e40 0%, #222230 100%);
  color: var(--phosphor);
}
.transport-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.transport-btn:active:not(:disabled) { transform: translateY(1px); }

.seek-container { margin-bottom: 6px; }
.seek-bar {
  width: 100%; height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #1a1a24;
  border-radius: 3px;
  outline: none;
  border: 1px solid var(--panel-border);
}
.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--phosphor);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--phosphor);
}
.seek-bar:disabled::-webkit-slider-thumb { background: #333; box-shadow: none; }

.time-display {
  text-align: center;
  font-size: 16px;
}
.lcd-text {
  color: var(--phosphor);
  text-shadow: 0 0 8px var(--phosphor-dim);
}
.lcd-sep { color: var(--text-dim); margin: 0 4px; }

/* TEST SIGNALS */
.test-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.test-btn {
  flex: 1; min-width: 70px;
  padding: 6px 8px;
  background: linear-gradient(180deg, #1e1e2a 0%, #161620 100%);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.test-btn:hover { color: var(--phosphor); border-color: var(--phosphor-dim); }
.test-btn.active { color: var(--phosphor); border-color: var(--phosphor); box-shadow: 0 0 6px var(--phosphor-dim); }

/* KNOBS */
.knobs-group { }
.knobs-row {
  display: flex; justify-content: space-around; gap: 8px;
  margin-bottom: 12px;
}
.knobs-row:last-child { margin-bottom: 0; }
.knob-wrapper {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 64px;
}
.knob {
  position: relative;
  width: 48px; height: 48px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.knob-body {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a2a3a, #18181f);
  border: 2px solid var(--knob-border);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
}
.knob-pointer {
  position: absolute;
  width: 2px; height: 14px;
  background: #ddd;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 1px;
  box-shadow: 0 0 4px rgba(255,255,255,0.2);
}
.knob-label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-align: center;
}

/* PHOSPHOR */
.phosphor-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.phosphor-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--dot-color);
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 0 6px color-mix(in srgb, var(--dot-color) 40%, transparent);
  transition: all 0.2s;
}
.phosphor-dot:hover { transform: scale(1.2); }
.phosphor-dot.active {
  border-color: #fff;
  box-shadow: 0 0 12px var(--dot-color);
}
.custom-color {
  width: 22px; height: 22px;
  border: none; padding: 0;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
}
.custom-color::-webkit-color-swatch-wrapper { padding: 0; }
.custom-color::-webkit-color-swatch { border-radius: 50%; border: 1px solid var(--panel-border); }

/* MODE SWITCH */
.mode-switch { display: flex; gap: 4px; }
.mode-btn {
  flex: 1;
  padding: 6px 4px;
  background: linear-gradient(180deg, #1a1a24 0%, #141418 100%);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  color: var(--phosphor);
  border-color: var(--phosphor);
  background: linear-gradient(180deg, #1a2a1a 0%, #101810 100%);
  box-shadow: 0 0 8px var(--phosphor-dim);
}

/* PRESETS */
.preset-row { display: flex; gap: 4px; flex-wrap: wrap; }
.preset-btn {
  flex: 1; min-width: 60px;
  padding: 6px 8px;
  background: linear-gradient(180deg, #1a1a24 0%, #141418 100%);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s;
}
.preset-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* VU METERS */
.vu-section { }
.vu-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.vu-label { font-size: 10px; color: var(--text-dim); width: 12px; }
.vu-bar {
  flex: 1; height: 8px;
  background: #0a0a12;
  border: 1px solid var(--panel-border);
  border-radius: 2px;
  overflow: hidden;
}
.vu-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--phosphor) 0%, var(--phosphor) 70%, #ffb300 85%, #ff3333 100%);
  transition: width 0.08s linear;
  border-radius: 2px;
}

/* FOOTER */
#footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px;
  border-top: 1px solid var(--panel-border);
  font-size: 11px;
  color: var(--text-dim);
  flex-wrap: wrap;
  gap: 8px;
}
.footer-left { letter-spacing: 1px; }
.footer-center { font-size: 10px; opacity: 0.6; }
.footer-link {
  color: var(--phosphor);
  text-decoration: none;
  letter-spacing: 1px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.footer-link:hover { opacity: 1; text-decoration: underline; }

/* RESPONSIVE */
@media (max-width: 960px) {
  #main { flex-direction: column; align-items: center; }
  #screen-container { width: 90vw; height: 90vw; max-width: 500px; max-height: 500px; }
  #controls-section { max-height: none; width: 100%; max-width: 540px; }
  .knobs-row { flex-wrap: wrap; }
}

@media (max-width: 540px) {
  #header { padding: 8px 12px; }
  .logo { font-size: 20px; }
  .subtitle { font-size: 9px; letter-spacing: 1px; }
  #main { padding: 8px; gap: 8px; }
  #bezel { padding: 10px; }
  #screen-container { width: calc(100vw - 56px); height: calc(100vw - 56px); }
  .knob { width: 40px; height: 40px; }
  .knob-pointer { height: 10px; }
  .knob-wrapper { width: 52px; }
  #footer { padding: 8px 12px; flex-direction: column; text-align: center; }
}