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

:root {
  --bg: #0d0d1a;
  --bg2: #1a1a2e;
  --bg3: #16213e;
  --cyan: #00f0ff;
  --magenta: #ff00aa;
  --green: #00ff88;
  --amber: #ffaa00;
  --red: #ff3355;
  --text: #c8d6e5;
  --text-dim: #576574;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-display: 'Orbitron', sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  background: linear-gradient(180deg, #1a1a30 0%, #12122a 100%);
  border-bottom: 1px solid #2a2a4a;
  flex-shrink: 0;
  min-height: 48px;
  flex-wrap: wrap;
}

#title-area {
  flex-shrink: 0;
}

#app-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 3px;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0,240,255,0.6), 0 0 30px rgba(0,240,255,0.2);
}

#node-palette {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.palette-btn {
  background: var(--bg3);
  border: 1px solid #2a3a5e;
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  cursor: grab;
  user-select: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.palette-btn:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0,240,255,0.3);
  transform: translateY(-1px);
}
.palette-btn:active { cursor: grabbing; }

#toolbar-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#preset-select {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid #2a3a5e;
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}

.tb-btn {
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.tb-btn.play {
  background: #0a3a2a;
  color: var(--green);
  border: 1px solid var(--green);
}
.tb-btn.play.active {
  background: var(--green);
  color: #000;
  box-shadow: 0 0 16px rgba(0,255,136,0.5);
}
.tb-btn.clear {
  background: #3a1a1a;
  color: var(--red);
  border: 1px solid #5a2a2a;
}
.tb-btn:hover { transform: translateY(-1px); }

#main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#graph-container {
  flex: 3;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#scope-container {
  flex: 2;
  display: flex;
  flex-direction: column;
  background: #0a0a14;
  border-left: 1px solid #2a2a4a;
  min-width: 280px;
}

#scope-frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#scope-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-width: 500px;
  max-height: 500px;
  border-radius: 12px;
  overflow: hidden;
  background: #040810;
  border: 3px solid #1a2a3a;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.8), 0 0 20px rgba(0,240,255,0.05);
}

#scope-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#scope-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0,0,0,0.08) 2px,
      rgba(0,0,0,0.08) 4px
    );
  border-radius: 12px;
}

.axis-label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(0,240,255,0.3);
  font-weight: 700;
}
.x-label { bottom: 6px; right: 10px; }
.y-label { top: 6px; left: 10px; }

#scope-controls {
  display: flex;
  gap: 14px;
  padding: 10px 16px;
  background: #0d0d1a;
  border-top: 1px solid #1a2a3a;
  flex-wrap: wrap;
  justify-content: center;
}

#scope-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

#scope-controls input[type="range"] {
  width: 70px;
  accent-color: var(--cyan);
}
#scope-controls input[type="color"] {
  width: 24px; height: 24px;
  border: 1px solid #2a3a5e;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  padding: 0;
}

#status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 5px 14px;
  background: #0d0d1a;
  border-top: 1px solid #1a1a2e;
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  flex-wrap: wrap;
}

#status-hint {
  flex: 1;
  text-align: center;
  font-style: italic;
  opacity: 0.7;
}

#remix-link {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 500;
  opacity: 0.7;
  transition: opacity 0.2s;
}
#remix-link:hover { opacity: 1; }

@media (max-width: 768px) {
  #main-area { flex-direction: column; }
  #scope-container { border-left: none; border-top: 1px solid #2a2a4a; min-width: unset; }
  #graph-container { min-height: 45vh; }
  #scope-frame { padding: 8px; }
  #toolbar { gap: 6px; padding: 4px 8px; }
  #app-title { font-size: 12px; letter-spacing: 1px; }
  .palette-btn { font-size: 10px; padding: 3px 7px; }
  #status-hint { display: none; }
}