/* S1Vave Tweak Synth Custom Editor (SDK 16) */
:root {
  --s1-bg: #141618;
  --s1-panel: #1b1e21;
  --s1-panel-border: #2a2e33;
  --s1-teal: #00b887;
  --s1-teal-bright: #1cd69d;
  --s1-teal-glow: rgba(0, 184, 135, 0.25);
  --s1-orange: #ff6b18;
  --s1-orange-glow: rgba(255, 107, 24, 0.25);
  --s1-blue: #3fa9f5;
  --s1-gold: #ffd424;
  --s1-text: #e0e4e8;
  --s1-text-dim: #7f8c8d;
  --s1-display-bg: #0d0f11;
  --s1-seg-red: #ff3333;
  --s1-seg-dim: #3a0a0a;
  --vibe-accent: var(--s1-teal);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--s1-bg);
  color: var(--s1-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 11px;
  line-height: 1.3;
  padding: 10px;
  min-width: 820px;
  overflow-x: hidden;
}

/* Header */
header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  background: #111315;
  border: 1px solid var(--s1-panel-border);
  border-radius: 6px;
  padding: 8px 14px;
  margin-bottom: 10px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.header-patch-row {
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

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

.brand .logo-img {
  height: 24px;
  width: auto;
  display: block;
}

.brand h1 {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #fff;
}

.brand h1 span {
  color: var(--s1-teal);
}

.brand .badge {
  font-size: 9px;
  font-weight: 700;
  color: #111;
  background: var(--s1-teal);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.brand .subhead {
  font-size: 10px;
  color: var(--s1-text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.top-global,
.top-patch {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.transp-box {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* 7-Segment Display Box */
.seg-display {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #08090a;
  border: 1px solid #331515;
  padding: 4px 10px;
  border-radius: 4px;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.8);
}

.seg-text {
  font-family: "Courier New", Courier, monospace;
  font-size: 15px;
  font-weight: 900;
  color: var(--s1-seg-red);
  letter-spacing: 2px;
  text-shadow: 0 0 6px rgba(255, 51, 51, 0.6);
}

.btn {
  background: #25292e;
  color: var(--s1-text);
  border: 1px solid #3a3f45;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn:hover {
  background: #32373e;
  border-color: var(--s1-teal);
  color: #fff;
}

.btn:active, .btn.active {
  background: var(--s1-teal);
  color: #111;
  border-color: var(--s1-teal-bright);
}

select {
  background: #1e2226;
  color: var(--s1-text);
  border: 1px solid #3a3f45;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

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

/* Main Layout Grid */
.synth-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px;
}

.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

/* Panels / Cards */
.panel {
  background: linear-gradient(180deg, #1f2328 0%, #171a1e 100%);
  border: 1px solid #2b3036;
  border-radius: 7px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.42), inset 0 1px 0 rgba(255,255,255,0.05);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 4px;
}

.panel-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--s1-teal);
}

.panel-title.orange {
  color: var(--s1-orange);
}

.panel-title.blue {
  color: var(--s1-blue);
}

/* Knob / Slider Groups */
.controls-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 8px;
}

.control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 52px;
}

.control-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--s1-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.control-val {
  font-size: 9px;
  font-family: monospace;
  color: #fff;
  background: #111315;
  padding: 1px 4px;
  border-radius: 3px;
  min-width: 32px;
  text-align: center;
}

/* Knob Rotary Arc + Conic LED Collar */
.knob {
  --knob-c: var(--s1-teal);
  --knob-glow: var(--s1-teal-glow);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: conic-gradient(
    from -135deg,
    var(--knob-c) 0deg,
    var(--knob-c) calc(var(--pct, 0) * 2.7deg),
    #252a30 calc(var(--pct, 0) * 2.7deg),
    #252a30 270deg,
    transparent 270deg
  );
  border: 1px solid #2a2f35;
  position: relative;
  cursor: ns-resize;
  touch-action: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6), 0 0 8px rgba(0,0,0,0.3);
}

.knob::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2c3138, #111316 80%);
  border: 1px solid color-mix(in srgb, var(--knob-c) 50%, #24282c);
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.09);
  z-index: 1;
}

.knob::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 2px;
  height: 12px;
  margin-left: -1px;
  background: var(--knob-c);
  border-radius: 1px;
  transform-origin: 50% 16px;
  transform: rotate(var(--rot, 0deg));
  box-shadow: 0 0 5px var(--knob-c);
  z-index: 2;
}

.knob.orange {
  --knob-c: var(--s1-orange);
  --knob-glow: var(--s1-orange-glow);
}

.knob.blue {
  --knob-c: var(--s1-blue);
  --knob-glow: rgba(63, 169, 245, 0.25);
}

.knob.gold {
  --knob-c: var(--s1-gold);
  --knob-glow: rgba(255, 212, 36, 0.28);
}

/* Sliders */
.slider-v {
  writing-mode: bt-lr;
  -webkit-appearance: slider-vertical;
  width: 8px;
  height: 56px;
  accent-color: var(--s1-teal);
  cursor: pointer;
}

.slider-h {
  width: 100%;
  accent-color: var(--s1-teal);
  cursor: pointer;
}

.slider-h.orange {
  accent-color: var(--s1-orange);
}

/* Canvases */
canvas.graph-canvas {
  background: #0e1012;
  border: 1px solid #23272b;
  border-radius: 4px;
  width: 100%;
  height: 60px;
  display: block;
}

/* OSC DRAW Canvas */
#draw-canvas {
  height: 70px;
  cursor: crosshair;
}

/* Live Device LCD Canvas */
#lcd-frame {
  width: 120px;
  height: 120px;
  image-rendering: pixelated;
  border: 2px solid #2a2e33;
  border-radius: 4px;
  background: #000;
}

/* 16-Step Pads (CHOP Mask) */
.step-pads {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 3px;
  margin-top: 4px;
}

.step-pad {
  aspect-ratio: 1 / 1.1;
  background: #25282c;
  border: 1px solid #363b40;
  border-radius: 2px;
  color: #888;
  font-size: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.08s;
}

.step-pad.on {
  background: var(--s1-orange);
  color: #111;
  border-color: #ffa060;
  box-shadow: 0 0 6px var(--s1-orange-glow);
}

/* On-Screen Keyboard */
.keyboard-container {
  background: #111315;
  border: 1px solid var(--s1-panel-border);
  border-radius: 6px;
  padding: 8px;
  margin-top: 10px;
}

.keyboard-wrap {
  display: flex;
  height: 74px;
  position: relative;
  background: #0c0e10;
  border-radius: 4px;
  overflow: hidden;
}

.key-white {
  flex: 1;
  background: #e6e8eb;
  border: 1px solid #bbb;
  border-top: none;
  border-bottom-left-radius: 3px;
  border-bottom-right-radius: 3px;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.key-white:active, .key-white.active {
  background: var(--s1-teal);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
}

.key-black {
  position: absolute;
  width: 2.8%;
  height: 60%;
  background: #1c1d1f;
  border: 1px solid #000;
  border-bottom-left-radius: 2px;
  border-bottom-right-radius: 2px;
  z-index: 2;
  cursor: pointer;
}

.key-black:active, .key-black.active {
  background: var(--s1-orange);
  box-shadow: 0 0 8px var(--s1-orange-glow);
}

/* Interactive Step Sequencer (Panel 9) */
.seq-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 10px;
}

.seq-toolbar, .seq-step-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.seq-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.seq-param {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--s1-text-dim);
  letter-spacing: 0.04em;
}

.seq-param input[type="number"], .seq-param select {
  background: #101214;
  color: var(--s1-text);
  border: 1px solid #2d3338;
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 10.5px;
  width: 46px;
}

.seq-param input[type="range"] {
  width: 58px;
  accent-color: var(--s1-teal);
  cursor: pointer;
}

.seq-val {
  min-width: 28px;
  font-family: monospace;
  font-size: 10px;
  color: var(--s1-text);
}

.seq-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 4px;
}

.seq-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 4px 2px 5px;
  background: #121518;
  border: 1px solid #272c31;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.08s, background 0.08s;
}

.seq-cell:hover {
  border-color: #48525c;
}

.seq-cell.active {
  background: #15211d;
  border-color: rgba(0, 184, 135, 0.55);
}

.seq-cell.selected {
  border-color: var(--s1-orange);
  box-shadow: 0 0 0 1px var(--s1-orange), 0 0 8px var(--s1-orange-glow);
}

.seq-cell.playing {
  background: #1a332b;
  border-color: var(--s1-teal-bright);
  box-shadow: 0 0 10px var(--s1-teal-glow);
}

.seq-cell.muted {
  opacity: 0.45;
}

.seq-cell.oob {
  opacity: 0.28;
  background: #0d0f11;
}

.seq-cell-top {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
  font-size: 8.5px;
  color: var(--s1-text-dim);
}

.seq-cell-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2b3137;
}

.seq-cell.active .seq-cell-dot {
  background: var(--s1-teal-bright);
  box-shadow: 0 0 4px var(--s1-teal-glow);
}

.seq-cell.playing .seq-cell-dot {
  background: var(--s1-gold);
  box-shadow: 0 0 6px rgba(255, 212, 36, 0.7);
}

.seq-cell-note {
  font-family: monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--s1-text-dim);
}

.seq-cell.active .seq-cell-note {
  color: #ffffff;
}

.seq-cell-sub {
  font-size: 8px;
  color: var(--s1-gold);
  min-height: 10px;
}

.seq-cell-vel {
  width: calc(100% - 6px);
  height: 4px;
  background: #1d2126;
  border-radius: 2px;
  overflow: hidden;
}

.seq-cell-vel-fill {
  height: 100%;
  background: var(--s1-teal);
}

.seq-step-bar {
  background: #111316;
  border: 1px solid #23282d;
  border-radius: 5px;
  padding: 5px 8px;
}

.seq-step-badge {
  font-family: monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--s1-orange);
  min-width: 54px;
}

.seq-chord-readout {
  font-family: monospace;
  font-size: 10px;
  color: var(--s1-teal-bright);
  min-width: 72px;
}

/* Patch, Sequence & MIDI Transfer Toolbar */
.io-panel {
  padding: 7px 10px;
}

.io-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.io-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.io-folder-hint {
  font-family: monospace;
  font-size: 9.5px;
  color: var(--s1-text-dim);
  background: #101214;
  border: 1px solid #22262a;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

.io-folder-hint strong {
  color: var(--s1-gold);
  font-weight: 600;
}

.io-status {
  font-family: monospace;
  font-size: 10px;
  color: var(--s1-teal-bright);
  background: #0c0e10;
  border: 1px solid #24292e;
  border-radius: 4px;
  padding: 3px 8px;
  min-width: 145px;
  text-align: center;
}

.btn.teal { border-color: rgba(0, 184, 135, 0.45); color: var(--s1-teal-bright); }
.btn.orange { border-color: rgba(255, 107, 24, 0.45); color: var(--s1-orange); }
.btn.blue { border-color: rgba(63, 169, 245, 0.45); color: var(--s1-blue); }
.btn.teal.active { background: var(--s1-teal); color: #111; border-color: var(--s1-teal-bright); }
.btn.orange.active { background: var(--s1-orange); color: #111; border-color: #ffa060; }
.btn.blue.active { background: var(--s1-blue); color: #111; border-color: #7cc4ff; }
.btn.rec-btn { border-color: rgba(255, 80, 80, 0.45); color: #ff8080; }
.btn.rec-btn.active { background: #ff3333; color: #fff; border-color: #ff8080; box-shadow: 0 0 8px rgba(255, 51, 51, 0.55); }
.btn.teal:hover, .btn.orange:hover, .btn.blue:hover, .btn.rec-btn:hover { filter: brightness(1.18); }

/* Responsive adjustments */
@media (max-width: 1000px) {
  .synth-grid { gap: 6px; }
  .panel { padding: 8px; }
}

