/* ── Reset & Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow-x: hidden;
  font-family: 'Courier New', monospace;
  background: #1a1a1a;
}

/* ── GLSL Background Canvas ────────────────────────────────────────── */
#bg-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── App Container ─────────────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  max-width: 580px;
  margin: 0 auto;
  padding: 0 0 32px;
  min-height: 100vh;
}

/* ── Ridged edges (PSS-470 case texture) ───────────────────────────── */
#app::before, #app::after {
  content: '';
  position: fixed;
  top: 0;
  width: 14px;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(20,20,20,0.9) 0px,
    rgba(40,40,40,0.9) 1px,
    rgba(25,25,25,0.9) 2px,
    rgba(15,15,15,0.9) 3px
  );
}
#app::before { left: 0; }
#app::after { right: 0; }

/* ── Air Vents (speaker grille) ────────────────────────────────────── */
.air-vents {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 40px;
  margin-bottom: 4px;
}

.vent-slat {
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    #080808 5%,
    #0a0a0a 50%,
    #080808 95%,
    transparent 100%
  );
  border-radius: 1px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    inset 0 -1px 0 rgba(0,0,0,0.8),
    0 1px 1px rgba(0,0,0,0.6),
    0 2px 2px rgba(0,0,0,0.2);
}

/* ── Header Plate ──────────────────────────────────────────────────── */
.plate-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 8px 20px 10px;
  margin-bottom: 4px;
}

.brand-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand {
  font-size: 26px;
  font-weight: bold;
  letter-spacing: 5px;
  color: #d0ccc4;
  text-shadow:
    1px 1px 0 rgba(0,0,0,0.6),
    -0.5px -0.5px 0 rgba(255,255,255,0.04);
}

.brand-sub {
  font-size: 11px;
  color: #777;
  letter-spacing: 2px;
  font-style: italic;
}

.model-text {
  font-size: 12px;
  color: #555;
  letter-spacing: 2px;
}

/* ── Panel Labels (shared) ─────────────────────────────────────────── */
.panel-label {
  font-size: 9px;
  letter-spacing: 3px;
  color: #22ccaa;
  margin-bottom: 6px;
  font-weight: bold;
  text-transform: uppercase;
}

/* ── Voice Bank Panel ──────────────────────────────────────────────── */
.voice-bank-panel {
  margin: 0 14px 12px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.4);
  border: 1px solid #2a2a2a;
  border-top-color: #222;
  border-bottom-color: #333;
  border-radius: 2px;
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.45),
    inset 0 -1px 0 rgba(255,255,255,0.02),
    0 1px 0 rgba(255,255,255,0.02);
}

.voice-bank-grid {
  column-count: 3;
  column-gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.vb-entry {
  font-size: 9px;
  color: #22ccaa;
  padding: 1px 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  break-inside: avoid;
  line-height: 1.7;
  border-radius: 1px;
  transition: background 0.1s;
}

.vb-entry:hover {
  background: rgba(34, 204, 170, 0.1);
}

.vb-entry.active {
  background: rgba(34, 204, 170, 0.2);
  color: #77ffdd;
  font-weight: bold;
}

.vb-num {
  color: #44aa88;
  margin-right: 3px;
  font-weight: bold;
}

.vb-entry.active .vb-num {
  color: #77ffdd;
}

/* Voice bank scrollbar */
.voice-bank-grid::-webkit-scrollbar { width: 4px; }
.voice-bank-grid::-webkit-scrollbar-track { background: transparent; }
.voice-bank-grid::-webkit-scrollbar-thumb {
  background: rgba(34, 204, 170, 0.25);
  border-radius: 2px;
}

/* ── Controls Row ──────────────────────────────────────────────────── */
.controls-row {
  display: flex;
  gap: 20px;
  margin: 0 14px 16px;
  align-items: flex-start;
}

/* ── Display Unit (7-segment) ──────────────────────────────────────── */
.display-unit {
  flex: 1;
}

.display-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: #666;
  margin-bottom: 6px;
}

.seg-housing {
  background: #060606;
  border: 2px solid #222;
  border-top-color: #181818;
  border-bottom-color: #2a2a2a;
  border-radius: 4px;
  padding: 10px 16px;
  display: inline-block;
  box-shadow:
    inset 0 3px 12px rgba(0,0,0,0.95),
    inset 0 -1px 3px rgba(0,0,0,0.5),
    0 1px 0 rgba(255,255,255,0.04),
    0 2px 6px rgba(0,0,0,0.3);
  position: relative;
}

.seg-housing::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
}

.seg-digits {
  font-size: 40px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  color: #ff4444;
  text-shadow:
    0 0 8px rgba(255,68,68,0.5),
    0 0 20px rgba(255,68,68,0.25),
    0 0 40px rgba(255,68,68,0.1);
  letter-spacing: 6px;
  line-height: 1;
}

.preset-readout {
  font-size: 12px;
  color: #22ccaa;
  margin-top: 8px;
  letter-spacing: 1px;
  font-weight: bold;
}

.display-status {
  font-size: 10px;
  color: #558877;
  margin-top: 4px;
  letter-spacing: 1px;
  min-height: 14px;
}

/* ── Voice Selector (PSS-470 style) ────────────────────────────────── */
.voice-selector {
  flex-shrink: 0;
}

.selector-grid {
  display: flex;
  gap: 8px;
  background: rgba(0,0,0,0.3);
  padding: 8px 10px;
  border-radius: 3px;
  box-shadow:
    inset 0 2px 5px rgba(0,0,0,0.5),
    inset 0 -1px 0 rgba(255,255,255,0.02),
    0 1px 0 rgba(255,255,255,0.03);
}

.sel-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.sel-label {
  font-size: 10px;
  font-weight: bold;
  color: #22ccaa;
  letter-spacing: 1px;
  line-height: 1.4;
}

.sel-btn {
  width: 56px;
  height: 15px;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  background: linear-gradient(180deg, #4ad89a 0%, #3cc88a 15%, #2aaa6e 60%, #1e8858 85%, #1a7850 100%);
  box-shadow:
    0 3px 5px rgba(0,0,0,0.5),
    0 1px 2px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -1px 0 rgba(0,0,0,0.2);
  transition: transform 0.06s, box-shadow 0.06s;
  margin-bottom: 4px;
  position: relative;
}

.sel-btn::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  border-radius: 1px;
}

.sel-btn:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 1px rgba(0,0,0,0.4),
    inset 0 1px 2px rgba(0,0,0,0.2);
  background: linear-gradient(180deg, #2aaa6e 0%, #1e8858 60%, #1a7850 100%);
}

.sel-btn:active::after {
  opacity: 0;
}

/* ── Effect Switches (PSS-470 style) ──────────────────────────────── */
.effects-row {
  display: flex;
  gap: 8px;
  margin: 0 14px 16px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.3);
  border: 1px solid #2a2a2a;
  border-radius: 3px;
  box-shadow:
    inset 0 2px 5px rgba(0,0,0,0.4),
    0 1px 0 rgba(255,255,255,0.02);
}

.fx-btn {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid #333;
  border-radius: 3px;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  color: #558877;
  font-family: 'Courier New', monospace;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 1.5px;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  box-shadow:
    0 2px 4px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

.fx-btn:hover {
  background: linear-gradient(180deg, #333 0%, #222 100%);
  color: #77aa99;
}

.fx-btn.active {
  background: linear-gradient(180deg, #1a5038 0%, #0d3020 100%);
  color: #77ffdd;
  border-color: #22ccaa;
  box-shadow:
    0 0 8px rgba(34,204,170,0.2),
    0 2px 4px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

/* ── ID Sections ───────────────────────────────────────────────────── */
.id-section {
  margin: 0 14px 16px;
}

.id-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.id-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.id-field {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #333;
  border-radius: 2px;
  background: rgba(255,255,255,0.88);
  color: #1a1a1a;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}

.id-field:focus {
  outline: none;
  border-color: #22ccaa;
  background: rgba(255,255,255,0.95);
}

.id-field[readonly] {
  cursor: default;
  opacity: 0.85;
}

.play-btn {
  width: 34px;
  height: 28px;
  border: none;
  border-radius: 3px;
  background: linear-gradient(180deg, #4ad89a 0%, #3cc88a 20%, #2aaa6a 80%, #1e8858 100%);
  color: #0a2a1a;
  font-size: 13px;
  cursor: pointer;
  box-shadow:
    0 3px 4px rgba(0,0,0,0.4),
    0 1px 1px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.2),
    inset 0 -1px 0 rgba(0,0,0,0.15);
  transition: transform 0.06s, box-shadow 0.06s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 1px rgba(0,0,0,0.3),
    inset 0 1px 2px rgba(0,0,0,0.15);
}

.play-btn.playing {
  background: linear-gradient(180deg, #cc4444 0%, #aa2222 100%);
  color: #fff;
}

/* ── MIDI Row ──────────────────────────────────────────────────────── */
.midi-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.midi-btn {
  padding: 8px 14px;
  border: 1px solid #333;
  border-radius: 3px;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  color: #22ccaa;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: background 0.15s;
}

.midi-btn:hover {
  background: linear-gradient(180deg, #333 0%, #222 100%);
}

.midi-btn.active {
  border-color: #22ccaa;
  color: #66ffdd;
}

.midi-select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #333;
  border-radius: 2px;
  background: #1a1a1a;
  color: #22ccaa;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  cursor: pointer;
}

.midi-select:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── Piano Keyboard ────────────────────────────────────────────────── */
.keyboard-section {
  margin: 0 14px;
  padding: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid #2a2a2a;
  border-top-color: #222;
  border-bottom-color: #333;
  border-radius: 4px;
  box-shadow:
    inset 0 3px 8px rgba(0,0,0,0.3),
    inset 0 -1px 0 rgba(255,255,255,0.02),
    0 1px 0 rgba(255,255,255,0.03);
}

.keyboard {
  position: relative;
  height: 120px;
  display: flex;
  user-select: none;
  -webkit-user-select: none;
}

.key-white {
  flex: 1;
  background: linear-gradient(180deg, #f0ece4 0%, #e0dcd4 85%, #d0ccc4 100%);
  border: 1px solid #888;
  border-radius: 0 0 4px 4px;
  margin: 0 1px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  box-shadow:
    0 4px 6px rgba(0,0,0,0.3),
    inset 0 -2px 3px rgba(0,0,0,0.05);
  transition: background 0.05s;
}

.key-white:active, .key-white.active {
  background: linear-gradient(180deg, #d8d4cc 0%, #c8c4bc 85%, #b8b4ac 100%);
  box-shadow:
    0 2px 3px rgba(0,0,0,0.3),
    inset 0 1px 2px rgba(0,0,0,0.1);
}

.key-black {
  position: absolute;
  width: 7%;
  height: 65%;
  background: linear-gradient(180deg, #2a2520 0%, #1a1510 70%, #0a0500 100%);
  border-radius: 0 0 3px 3px;
  cursor: pointer;
  z-index: 2;
  box-shadow:
    0 3px 5px rgba(0,0,0,0.5),
    inset 0 -2px 3px rgba(80,70,60,0.3);
  transition: background 0.05s, height 0.05s;
}

.key-black:active, .key-black.active {
  height: 63%;
  background: linear-gradient(180deg, #3a3530 0%, #2a2520 70%, #1a1510 100%);
  box-shadow:
    0 2px 3px rgba(0,0,0,0.4),
    inset 0 1px 2px rgba(0,0,0,0.2);
}

/* ── Tweak Section (collapsible) ───────────────────────────────────── */
.tweak-section {
  margin: 16px 14px 0;
}

.tweak-toggle {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  background: rgba(0,0,0,0.3);
  color: #22ccaa;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.tweak-toggle:hover {
  background: rgba(0,0,0,0.4);
}

.tweak-toggle.open {
  border-radius: 4px 4px 0 0;
  border-bottom: none;
}

.tweak-body {
  display: none;
  padding: 14px;
  border: 1px solid #2a2a2a;
  border-top: none;
  border-radius: 0 0 4px 4px;
  background: rgba(0,0,0,0.25);
}

.tweak-body.open {
  display: block;
}

.tweak-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.tweak-param {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tweak-param label {
  font-size: 8px;
  letter-spacing: 2px;
  color: #22ccaa;
  font-weight: bold;
}

.tweak-param input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #333;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.tweak-param input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3cc88a;
  border: 2px solid #1a1a1a;
  cursor: pointer;
}

.tweak-param input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3cc88a;
  border: 2px solid #1a1a1a;
  cursor: pointer;
}

.tw-val {
  font-size: 10px;
  color: #558877;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
}

.tweak-reset {
  margin-top: 12px;
  padding: 8px 16px;
  border: 1px solid #333;
  border-radius: 3px;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  color: #22ccaa;
  font-family: 'Courier New', monospace;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.15s;
}

.tweak-reset:hover {
  background: linear-gradient(180deg, #333 0%, #222 100%);
}

/* ── Visual Config TOD Controls ───────────────────────────────────── */
.tod-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tod-controls input[type="range"] {
  flex: 1;
}

.tod-mode-btn {
  padding: 3px 8px;
  border: 1px solid #333;
  border-radius: 2px;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  color: #22ccaa;
  font-family: 'Courier New', monospace;
  font-size: 8px;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.tod-mode-btn.manual {
  color: #ff8844;
  border-color: #664422;
}

.vis-tod-param {
  grid-column: 1 / -1;
}

/* ── Rhythm Section ───────────────────────────────────────────────── */
.rhythm-section {
  margin: 0 14px 16px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.4);
  border: 1px solid #2a2a2a;
  border-top-color: #222;
  border-bottom-color: #333;
  border-radius: 2px;
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.45),
    inset 0 -1px 0 rgba(255,255,255,0.02),
    0 1px 0 rgba(255,255,255,0.02);
}

.rhythm-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.rhythm-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 160px;
}

.rhythm-display {
  flex: 1;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: bold;
  color: #22ccaa;
  letter-spacing: 1px;
  padding: 6px 8px;
  background: #060606;
  border: 1px solid #222;
  border-radius: 3px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rhythm-btn {
  padding: 6px 10px;
  border: 1px solid #333;
  border-radius: 3px;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  color: #22ccaa;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow:
    0 2px 4px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.04);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.rhythm-btn:hover {
  background: linear-gradient(180deg, #333 0%, #222 100%);
  color: #77ffdd;
}

.rhythm-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.transport-btn {
  padding: 6px 14px;
}

.transport-btn.active {
  background: linear-gradient(180deg, #1a5038 0%, #0d3020 100%);
  color: #77ffdd;
  border-color: #22ccaa;
  box-shadow:
    0 0 8px rgba(34,204,170,0.2),
    0 2px 4px rgba(0,0,0,0.3);
}

.rhythm-transport {
  display: flex;
  gap: 6px;
}

.rhythm-tempo {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tempo-display {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: bold;
  color: #ff4444;
  text-shadow: 0 0 6px rgba(255,68,68,0.3);
  min-width: 32px;
  text-align: center;
  letter-spacing: 1px;
}

.tempo-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.tempo-label {
  font-size: 8px;
  letter-spacing: 2px;
  color: #558877;
  font-weight: bold;
}

/* Step indicator dots */
.rhythm-steps {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  justify-content: center;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 1px solid #333;
  transition: background 0.05s, box-shadow 0.05s;
}

.step-dot:nth-child(4n+1) {
  border-color: #444;
}

.step-dot.active {
  background: #22ccaa;
  border-color: #22ccaa;
  box-shadow: 0 0 6px rgba(34,204,170,0.5);
}

.step-dot.beat {
  background: #ff4444;
  border-color: #ff4444;
  box-shadow: 0 0 6px rgba(255,68,68,0.4);
}

/* ── Responsiveness ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .brand { font-size: 20px; letter-spacing: 3px; }
  .voice-bank-grid { column-count: 2; max-height: 200px; }
  .keyboard { height: 90px; }
  .sel-btn { width: 38px; }
  .seg-digits { font-size: 30px; }
  .controls-row { gap: 12px; }
  .id-field { font-size: 10px; padding: 5px 6px; }
  .tweak-grid { grid-template-columns: 1fr; }
  .rhythm-controls { flex-direction: column; gap: 8px; }
  .rhythm-selector { min-width: unset; }
  .step-dot { width: 6px; height: 6px; }
}
