/* ARP8 — Korg Berlin / industrial visual language.
   Concrete + brushed steel + brass + amber phosphor.
   No external fonts — uses native macOS system stack so it loads instantly. */

:root {
  --bg-0:        #0b0c12;
  --bg-1:        #161824;
  --bg-2:        #1f2230;
  --panel:       #232636;
  --panel-edge:  #0a0b11;
  --panel-up:    #2c3041;
  --steel:       #525766;
  --steel-soft:  #8a8f9e;

  --brass:       #c89860;
  --brass-hi:    #e6b87a;
  --brass-lo:    #7d5d35;

  --amber:       #ffaa3b;
  --amber-hot:   #ffd07a;
  --amber-dim:   #5e4218;

  --led-r:       #ff3850;
  --led-g:       #b8ff36;
  --led-c:       #4ddcff;

  --text:        #e8e6dd;
  --text-mute:   #8a8d9a;
  --text-faint:  #565a6a;

  /* chord pad palette */
  --pad-1:  #ff5e3a;
  --pad-2:  #ffa630;
  --pad-3:  #c9e84a;
  --pad-4:  #4dd28a;
  --pad-5:  #4ddcff;
  --pad-6:  #7a83ff;
  --pad-7:  #e64aa6;
  --pad-8:  #ff7a7a;
  --pad-9:  #f4d35e;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;

  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow: hidden;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 30% 0%, #1c2030 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, #2a1d12 0%, transparent 50%),
    linear-gradient(180deg, #0c0e16 0%, #14161e 60%, #0a0b11 100%);
}

/* Subtle film grain so the dark areas feel like material, not flat color. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 1   0 0 0 0 1   0 0 0 0 1   0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.7;
  z-index: 1;
}

.frame {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  min-width: 980px;
  margin: 18px auto;
  padding: 0 18px 18px;
}

/* ════════ HEADER ════════ */
.bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #1d2030 0%, #14161e 100%);
  border: 1px solid #06070b;
  border-bottom: 1px solid var(--brass-lo);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 8px 24px rgba(0,0,0,0.4);
  position: relative;
}

.bar::before {
  /* brass strip across the bottom of header — phase8's wood-inlay vibe inverted */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -3px; height: 3px;
  background: linear-gradient(90deg, transparent, var(--brass) 8%, var(--brass-hi) 50%, var(--brass) 92%, transparent);
  opacity: 0.9;
  filter: blur(0.3px);
}

.brand .logo {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand .logo-num {
  color: var(--brass-hi);
  text-shadow: 0 0 14px rgba(232, 184, 122, 0.4);
}
.brand .tag {
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-top: 2px;
}

.bar-spacer { flex: 1; }

.midi-pick {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--bg-1);
  border: 1px solid #0a0b11;
  border-radius: var(--r-md);
}
.midi-pick label {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.midi-pick select {
  background: transparent;
  color: var(--amber);
  border: none;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  min-width: 130px;
  text-shadow: 0 0 6px rgba(255, 170, 60, 0.3);
}
.midi-pick option { background: var(--bg-2); color: var(--text); }
.midi-pick .midi-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: inset 0 0 4px rgba(0,0,0,0.6);
}
.midi-pick .midi-status.ok {
  background: var(--led-g);
  box-shadow: 0 0 8px var(--led-g), inset 0 0 2px rgba(255,255,255,0.6);
}
.midi-pick .midi-status.err {
  background: var(--led-r);
  box-shadow: 0 0 8px var(--led-r);
}

/* Help button — small circular pill in the header next to the transport. */
.help-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--brass-lo);
  background: linear-gradient(180deg, var(--panel-up) 0%, var(--panel) 100%);
  color: var(--brass-hi);
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 2px 4px rgba(0,0,0,0.4);
  transition: all 0.1s var(--ease);
}
.help-btn:hover {
  color: var(--amber);
  border-color: var(--brass);
  box-shadow: 0 0 12px rgba(255,170,60,0.25), inset 0 1px 0 rgba(255,255,255,0.06);
}
.help-btn:active { transform: scale(0.95); }

/* ════════ HELP MODAL ════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(8, 9, 14, 0.78);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.modal-panel {
  position: relative;
  z-index: 1;
  max-width: 880px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--panel-edge);
  border-top: 2px solid var(--brass);
  border-radius: var(--r-lg);
  padding: 28px 32px 22px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 24px 80px rgba(0,0,0,0.6);
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 30px; height: 30px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-mute);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: all 0.1s var(--ease);
}
.modal-close:hover {
  color: var(--led-r);
  border-color: var(--brass-lo);
}
.modal-head h1 {
  margin: 0;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.modal-head .help-ver {
  font-size: 11px;
  color: var(--brass);
  letter-spacing: 0.18em;
  font-weight: 400;
  margin-left: 8px;
}
.modal-head .help-tag {
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-top: 4px;
}
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 28px;
  margin-top: 22px;
}
.modal-grid section h2 {
  margin: 0 0 8px;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass-hi);
  border-bottom: 1px solid var(--brass-lo);
  padding-bottom: 4px;
}
.modal-grid ul {
  margin: 0;
  padding-left: 16px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
}
.modal-grid ul li { margin-bottom: 4px; }
.modal-grid ul.kb li {
  list-style: none;
  margin-left: -16px;
}
.modal-grid b { color: var(--amber); font-weight: 600; }
.modal-grid i { color: var(--text); font-style: normal; font-weight: 600; }
.modal-grid code {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 11px;
  background: var(--bg-1);
  border: 1px solid #050608;
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--amber);
}
.modal-grid kbd {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 10px;
  background: linear-gradient(180deg, var(--panel-up) 0%, var(--panel) 100%);
  border: 1px solid var(--panel-edge);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 2px 6px;
  color: var(--brass-hi);
  margin-right: 6px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.modal-grid a {
  color: var(--led-c);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklch, var(--led-c), transparent 70%);
}
.modal-grid a:hover { color: var(--amber); border-bottom-color: var(--amber); }

@media (max-width: 760px) {
  .modal-grid { grid-template-columns: 1fr; }
}

.transport { display: flex; gap: 6px; }
.t-btn {
  width: 38px; height: 38px;
  border: 1px solid #0a0b11;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--panel-up) 0%, var(--panel) 100%);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 2px 4px rgba(0,0,0,0.4);
  transition: all 0.1s var(--ease);
}
.t-btn:hover { background: linear-gradient(180deg, #353a4f 0%, var(--panel) 100%); }
.t-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); }
.t-btn.play.armed { color: var(--led-g); box-shadow: inset 0 0 8px rgba(184, 255, 54, 0.3), 0 0 12px rgba(184, 255, 54, 0.2); }
.t-btn.stop:hover { color: var(--led-r); }
.t-btn.panic { color: var(--text-mute); font-size: 14px; }
.t-btn.panic:hover { color: var(--led-r); }
.t-btn.test, .t-btn.song {
  width: auto; padding: 0 10px; font-size: 10px; letter-spacing: 0.18em;
  font-family: "SF Mono", "Menlo", monospace; color: var(--brass-hi);
}

/* Song picker: chevrons + amber phosphor title screen, like a tape-deck display. */
.song-pick {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-1);
  border: 1px solid #06070b;
  border-radius: var(--r-md);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
  height: 38px;
}
.song-cycle {
  width: 22px;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--brass);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  transition: color 0.1s var(--ease);
}
.song-cycle:hover { color: var(--amber); }
.song-cycle:active { transform: scale(0.92); }
.song-screen {
  min-width: 190px;
  padding: 4px 10px;
  background: linear-gradient(180deg, #1a0d04 0%, #0d0703 100%);
  border-left: 1px solid #06070b;
  border-right: 1px solid #06070b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  position: relative;
  box-shadow: inset 0 0 12px rgba(255,170,60,0.04);
}
.song-title {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-shadow: 0 0 8px rgba(255, 170, 60, 0.3);
}
.song-subtitle {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 8px;
  color: var(--brass-lo);
  letter-spacing: 0.05em;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.t-btn.test:hover, .t-btn.song:hover { color: var(--amber); box-shadow: inset 0 0 8px rgba(255,170,60,0.18), 0 2px 4px rgba(0,0,0,0.4); }
.t-btn.song.armed {
  color: var(--led-r);
  background: linear-gradient(180deg, #5a1218 0%, var(--panel) 100%);
  box-shadow: inset 0 0 12px rgba(255,56,80,0.35), 0 0 18px rgba(255,56,80,0.25);
  border-color: var(--led-r);
}
/* Playlist (shuffle) mode: cyan glow distinct from the red 'looping' state. */
.t-btn.song.playlist {
  color: var(--led-c);
  background: linear-gradient(180deg, #0f2c33 0%, var(--panel) 100%);
  box-shadow: inset 0 0 12px rgba(77,220,255,0.35), 0 0 18px rgba(77,220,255,0.30);
  border-color: var(--led-c);
}
.t-btn.song.playlist.armed {
  /* When both armed and playlist are active, cyan wins for clarity. */
  color: var(--led-c);
  border-color: var(--led-c);
}

/* ════════ MAIN GRID ════════ */
.grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.7fr;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "tines  pattern tempo"
    "knobs  knobs   knobs"
    "chords chords  chords";
  gap: 12px;
  margin-top: 12px;
}

.panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--panel-edge);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 4px 16px rgba(0,0,0,0.35);
  position: relative;
}

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.caption {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass-hi);
  font-weight: 600;
}
.caption-sub {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.05em;
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
}
.caption-sub select {
  background: var(--bg-1);
  border: 1px solid #0a0b11;
  color: var(--amber);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 11px;
  outline: none;
  cursor: pointer;
}

/* ───── TINES ───── */
.panel-tines { grid-area: tines; }

.tines {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  padding: 12px 8px;
  background: linear-gradient(180deg, #0a0c14 0%, #11131c 100%);
  border-radius: var(--r-md);
  border: 1px solid #050608;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}

.tine {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 0 8px;
  position: relative;
}

/* The tine itself: a vertical brass bar (resonator), with a glow when struck. */
.tine-bar {
  width: 6px;
  height: 56px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--brass-hi) 0%, var(--brass) 50%, var(--brass-lo) 100%);
  box-shadow:
    inset 0 0 2px rgba(255, 235, 200, 0.4),
    0 0 0 1px #1d1108;
  transition: all 0.18s var(--ease);
  position: relative;
}
.tine.active .tine-bar {
  background: linear-gradient(180deg, var(--amber-hot) 0%, var(--amber) 50%, var(--brass-lo) 100%);
  box-shadow:
    inset 0 0 4px rgba(255, 235, 200, 0.8),
    0 0 14px var(--amber),
    0 0 24px rgba(255, 170, 60, 0.4),
    0 0 0 1px #2a1a08;
  transform: scaleY(1.04);
}

.tine-label {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.05em;
}
.tine.active .tine-label { color: var(--amber); }

.tine-num {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 8px;
  color: var(--text-faint);
}

.now-playing {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--bg-1);
  border: 1px solid #050608;
  border-radius: var(--r-md);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
}
.np-label {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.np-note {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 16px;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 170, 60, 0.3);
  min-width: 50px;
}
.np-chord {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 12px;
  color: var(--text-mute);
  margin-left: auto;
}

/* ───── STEPS ───── */
.steps {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
  padding: 10px 8px;
  background: linear-gradient(180deg, #0a0c14 0%, #11131c 100%);
  border-radius: var(--r-md);
  border: 1px solid #050608;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}

.step {
  height: 26px;
  border-radius: 3px;
  background: var(--bg-2);
  border: 1px solid #050608;
  cursor: pointer;
  position: relative;
  transition: all 0.12s var(--ease);
}
.step.on {
  background: linear-gradient(180deg, #3a3e52 0%, #292c3c 100%);
  border-color: var(--brass-lo);
}
.step.on::after {
  content: "";
  position: absolute;
  left: 50%; top: 4px;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--brass-hi);
  box-shadow: 0 0 4px var(--brass);
}
.step.beat { border-top: 2px solid var(--brass-lo); }
.step.playing {
  background: linear-gradient(180deg, var(--amber-hot) 0%, var(--amber) 100%);
  box-shadow: 0 0 12px var(--amber), inset 0 0 2px rgba(255,255,255,0.6);
}
.step.playing::after { background: #fff; box-shadow: 0 0 6px #fff; }
.step:hover { transform: translateY(-1px); }

/* ───── PATTERN ───── */
.panel-pattern { grid-area: pattern; }

.patterns {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.pat {
  height: 54px;
  border: 1px solid #050608;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--panel-up) 0%, var(--panel) 100%);
  color: var(--text);
  cursor: pointer;
  font-family: "SF Mono", "Menlo", monospace;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 2px 4px rgba(0,0,0,0.4);
  transition: all 0.1s var(--ease);
  font-weight: 600;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.pat .pat-icon {
  font-size: 18px;
  line-height: 1;
  color: var(--brass-hi);
  letter-spacing: -0.05em;
}
.pat .pat-label {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--text-mute);
  font-weight: 700;
}
.pat.wide {
  grid-column: span 5;
  height: 36px;
  flex-direction: row;
  gap: 6px;
}
.pat.wide .pat-label { font-size: 12px; letter-spacing: 0.28em; color: var(--text); }
.pat:hover { background: linear-gradient(180deg, #353a4f 0%, var(--panel) 100%); }
.pat:hover .pat-icon  { color: var(--amber); }
.pat:hover .pat-label { color: var(--text); }
.pat.active {
  background: linear-gradient(180deg, var(--amber) 0%, #c08020 100%);
  color: #1a0e02;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.4),
    0 0 12px rgba(255,170,60,0.4);
  border-color: var(--amber-dim);
}
.pat.active .pat-icon  { color: #1a0e02; }
.pat.active .pat-label { color: #1a0e02; opacity: 0.85; }

/* ───── TEMPO ───── */
.panel-tempo { grid-area: tempo; display: flex; flex-direction: column; }

.bpm-screen {
  flex: 1;
  background: linear-gradient(180deg, #1a0d04 0%, #0d0703 100%);
  border: 1px solid #050608;
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
  box-shadow:
    inset 0 0 24px rgba(255,170,60,0.05),
    inset 0 2px 6px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 84px;
}
.bpm-num {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 36px;
  font-weight: 700;
  color: var(--amber);
  text-shadow:
    0 0 12px rgba(255, 170, 60, 0.5),
    0 0 28px rgba(255, 170, 60, 0.3);
  letter-spacing: 0.05em;
  line-height: 1;
}
.bpm-unit {
  font-size: 9px;
  color: var(--brass);
  letter-spacing: 0.3em;
  margin-top: 4px;
}
.pulse {
  position: absolute;
  top: 8px; right: 10px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--led-g);
  box-shadow: 0 0 8px var(--led-g);
  opacity: 0.2;
  transition: opacity 0.06s var(--ease);
}
.pulse.beat { opacity: 1; }

.tempo-ctrls { display: flex; gap: 6px; }
.ghost {
  flex: 1;
  height: 28px;
  background: linear-gradient(180deg, var(--panel-up) 0%, var(--panel) 100%);
  border: 1px solid #050608;
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.1s var(--ease);
}
.ghost:hover { background: #353a4f; color: var(--brass-hi); }

/* ───── KNOBS ───── */
.panel-knobs { grid-area: knobs; }

.knob-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr) 1.5fr;
  gap: 14px;
  align-items: center;
}

.knob-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.knob {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, #4d5165 0%, var(--panel-up) 35%, #1c1f2c 75%, #0a0b11 100%);
  border: 1px solid #050608;
  position: relative;
  cursor: ns-resize;
  box-shadow:
    inset 0 0 1px rgba(255,255,255,0.15),
    inset 0 -2px 6px rgba(0,0,0,0.5),
    0 4px 8px rgba(0,0,0,0.4);
}

/* knurled grooves */
.knob::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background:
    repeating-conic-gradient(
      from 0deg,
      rgba(255,255,255,0.06) 0deg 1deg,
      transparent 1deg 6deg);
  opacity: 0.5;
}

/* indicator notch */
.knob::after {
  content: "";
  position: absolute;
  left: 50%; top: 6px;
  transform: translateX(-50%) rotate(var(--rot, 0deg));
  transform-origin: 50% 22px;
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--amber-hot), var(--amber));
  box-shadow: 0 0 6px var(--amber);
}

/* arc track around knob to show value */
.knob {
  background-image:
    conic-gradient(from 215deg, var(--amber) 0deg, var(--amber) calc(var(--arc, 0) * 1deg), transparent calc(var(--arc, 0) * 1deg) 270deg, transparent 270deg),
    radial-gradient(circle at 30% 25%, #4d5165 0%, var(--panel-up) 35%, #1c1f2c 75%, #0a0b11 100%);
  background-size: 100% 100%, 100% 100%;
  background-blend-mode: screen, normal;
}

.k-name {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  margin-top: 2px;
}
.k-val {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 11px;
  color: var(--amber);
  min-width: 40px;
  text-align: center;
}

.knob-cell.switches {
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-1);
  border: 1px solid #050608;
  border-radius: var(--r-md);
}
.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.switch input { display: none; }
.switch::before {
  content: "";
  width: 28px; height: 14px;
  border-radius: 7px;
  background: #0a0b11;
  border: 1px solid #050608;
  position: relative;
  transition: all 0.14s var(--ease);
  flex-shrink: 0;
}
.switch::after {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--steel-soft);
  position: absolute;
  margin-left: 2px;
  transition: all 0.14s var(--ease);
  box-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.switch:has(input:checked) { color: var(--amber); }
.switch:has(input:checked)::before {
  background: linear-gradient(180deg, #5a3a14 0%, #2a1a08 100%);
  border-color: var(--amber-dim);
}
.switch:has(input:checked)::after {
  background: var(--amber);
  margin-left: 16px;
  box-shadow: 0 0 6px var(--amber), 0 1px 2px rgba(0,0,0,0.6);
}

.ch-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.ch-pick select {
  background: var(--bg-2);
  border: 1px solid #050608;
  color: var(--amber);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 11px;
  outline: none;
  cursor: pointer;
}

/* ───── CHORDS ───── */
.panel-chords { grid-area: chords; }

.chord-pads {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.pad {
  position: relative;
  background: linear-gradient(180deg, var(--panel-up) 0%, var(--panel) 100%);
  border: 1px solid #050608;
  border-top: 2px solid var(--pad-color, var(--brass));
  border-radius: var(--r-md);
  padding: 12px 10px 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: all 0.12s var(--ease);
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 2px 6px rgba(0,0,0,0.4);
}
.pad::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--pad-color, var(--brass));
  opacity: 0;
  transition: opacity 0.12s var(--ease);
  pointer-events: none;
}
.pad:hover::before { opacity: 0.06; }
.pad.armed {
  border-color: var(--pad-color, var(--brass));
  box-shadow:
    inset 0 0 0 1px var(--pad-color, var(--brass)),
    0 0 18px color-mix(in oklch, var(--pad-color, var(--brass)), transparent 60%);
}
.pad.armed::before { opacity: 0.16; }
.pad.armed .pad-roman { color: var(--pad-color, var(--brass)); text-shadow: 0 0 10px color-mix(in oklch, var(--pad-color, var(--brass)), transparent 60%); }

.pad-roman {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  position: relative;
  z-index: 1;
}
.pad-name {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 13px;
  color: var(--text);
  margin-top: 4px;
  position: relative; z-index: 1;
}
.pad-notes {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 9px;
  color: var(--text-mute);
  margin-top: 6px;
  letter-spacing: 0.05em;
  position: relative; z-index: 1;
}
.pad.out-of-range .pad-notes { color: var(--led-r); opacity: 0.65; }

/* ════════ FOOTER ════════ */
.legend {
  display: flex;
  gap: 18px;
  padding: 10px 6px;
  margin-top: 4px;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 10px;
  color: var(--text-faint);
}
.legend-mid { margin-left: auto; color: var(--amber); font-family: "SF Mono","Menlo",monospace; }
.legend-mid.err { color: var(--led-r); }
.legend-end { color: var(--brass-lo); margin-left: 14px; }
.legend-end a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--brass-lo); }
.legend-end a:hover { color: var(--brass-hi); border-bottom-color: var(--brass-hi); }

/* Slim scrollbars on selects */
select { font-family: inherit; }

/* responsive squish */
@media (max-width: 1100px) {
  .frame { min-width: auto; }
  .grid { grid-template-columns: 1fr 1fr; grid-template-areas: "tines tines" "pattern tempo" "knobs knobs" "chords chords"; }
  .knob-row { grid-template-columns: repeat(3, 1fr); }
  .knob-cell.switches { grid-column: span 3; flex-direction: row; align-items: center; justify-content: space-between; }
}
