/* SPILL — Tactile Braun / Teenage Engineering / Monome hardware aesthetic */

:root {
  --bg-desk: #11100e;
  --chassis: #1a1816;
  --chassis-hi: #23201d;
  --chassis-deep: #131210;
  --bezel: #2e2a25;
  --bezel-hi: rgba(255, 245, 230, 0.08);
  --bezel-lo: rgba(0, 0, 0, 0.55);

  --ink: #ebe4d7;
  --ink-dim: #9c9486;
  --ink-faint: #625c53;

  --amber: #f5a623;
  --amber-glow: rgba(245, 166, 35, 0.38);
  --vermilion: #eb5e28;
  --vermilion-hi: #f57342;
  --mint: #4fd19b;
  --cerulean: #5ca7eb;

  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html, body {
  height: 100%;
  background: radial-gradient(circle at 50% 0%, #201d19 0%, var(--bg-desk) 75%);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}

.chassis {
  height: 100vh;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 12px 16px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto auto;
  gap: 10px;
  overflow: hidden;
}

.chassis > * {
  min-width: 0;
}

/* ---------------- Top Hardware Faceplate ---------------- */
.faceplate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #211e1b 0%, var(--chassis) 100%);
  border: 1px solid var(--bezel);
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    0 6px 20px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.faceplate-left,
.faceplate-right {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: nowrap;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  border-right: 1px solid var(--bezel);
}

.power-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber), 0 0 2px #fff inset;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.power-led.paused {
  background: #5c5347;
  box-shadow: none;
}

.brand-name {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.16em;
  color: var(--ink);
}

.brand-rev {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  padding: 2px 5px;
  border: 1px solid #302c27;
  border-radius: 4px;
}

.micro-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

.study-picker,
.scale-picker {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hardware-select {
  appearance: none;
  background: var(--chassis-deep) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239c9486' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 9px center;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 26px 5px 9px;
  border: 1px solid var(--bezel);
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.hardware-select:hover,
.hardware-select:focus {
  border-color: var(--amber);
}

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

.keycap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  background: linear-gradient(180deg, #2d2925 0%, #221f1c 100%);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  border: 1px solid #3a352f;
  border-radius: 7px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 2px 0 #110f0d,
    0 4px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 80ms ease, border-color 120ms ease, background 120ms ease;
}

.keycap:hover {
  border-color: #544d44;
  background: linear-gradient(180deg, #342f2a 0%, #26221e 100%);
}

.keycap:active,
.keycap.pressed {
  transform: translateY(1.5px);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.45),
    0 0.5px 0 #110f0d;
}

.keycap-icon {
  width: 34px;
  padding: 0;
  font-size: 13px;
}

.keycap-play {
  min-width: 82px;
  background: linear-gradient(180deg, var(--vermilion-hi) 0%, var(--vermilion) 100%);
  border-color: #ff8f66;
  color: #fffaf3;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 2px 0 #8f300f,
    0 4px 12px rgba(235, 94, 40, 0.32);
}

.keycap-play:hover {
  background: linear-gradient(180deg, #fb7c4d 0%, #f06530 100%);
  border-color: #ffa482;
}

.keycap-play.playing {
  background: linear-gradient(180deg, #2d2925 0%, #221f1c 100%);
  border-color: var(--vermilion);
  color: var(--vermilion-hi);
  box-shadow:
    inset 0 0 0 1px rgba(235, 94, 40, 0.22),
    0 2px 0 #110f0d;
}

.keycap-nudge {
  border-color: #463c2c;
}

.keycap-nudge:hover {
  border-color: var(--amber);
}

.nudge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber-glow);
}

.keycap-code.active {
  border-color: var(--mint);
  color: var(--mint);
}

/* Oscilloscope housing */
.scope-housing {
  position: relative;
  width: 104px;
  height: 34px;
  background: #0d0c0a;
  border: 1px solid #302b25;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.75);
  flex-shrink: 0;
}

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

.scope-tick {
  position: absolute;
  right: 5px;
  bottom: 2px;
  font-family: var(--mono);
  font-size: 8.5px;
  color: rgba(245, 166, 35, 0.65);
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* Sliders */
.knob-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.knob-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 58px;
}

.knob-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.knob-val {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #0f0e0c;
  border: 1px solid #302b25;
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid #24211d;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  transition: background 120ms ease, transform 120ms ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--amber);
  transform: scale(1.12);
}

/* ---------------- Main Board Bed ---------------- */
.board-stage {
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.board-frame {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #171513 0%, #131210 100%);
  border: 1px solid var(--bezel);
  border-radius: 14px;
  box-shadow:
    inset 0 2px 14px rgba(0, 0, 0, 0.65),
    0 1px 0 var(--bezel-hi);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Machined corner screws */
.screw {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3d3832, #1c1916);
  border: 1px solid rgba(0, 0, 0, 0.7);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
  pointer-events: none;
  z-index: 2;
}
.screw::after {
  content: '';
  position: absolute;
  left: 1.5px;
  right: 1.5px;
  top: 3.5px;
  height: 1px;
  background: rgba(0, 0, 0, 0.75);
  transform: rotate(-32deg);
}
.screw-tl { top: 8px; left: 8px; }
.screw-tr { top: 8px; right: 8px; }
.screw-bl { bottom: 8px; left: 8px; }
.screw-br { bottom: 8px; right: 8px; }

/* Sound wake floating pill */
.audio-wake-pill {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  background: rgba(26, 23, 20, 0.92);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  border: 1px solid rgba(235, 94, 40, 0.65);
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55), 0 0 18px rgba(235, 94, 40, 0.22);
  cursor: pointer;
  z-index: 6;
  transition: opacity 280ms ease, transform 280ms ease;
}

.audio-wake-pill.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
}

.audio-wake-pill strong {
  color: var(--amber);
}

.wake-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vermilion-hi);
  box-shadow: 0 0 8px var(--vermilion);
  animation: wakePulse 1.6s ease-in-out infinite;
}

@keyframes wakePulse {
  0%, 100% { transform: scale(0.95); opacity: 0.75; }
  50% { transform: scale(1.25); opacity: 1; }
}

/* Micro Toast */
.toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 6px 14px;
  background: rgba(28, 25, 22, 0.94);
  border: 1px solid rgba(245, 166, 35, 0.55);
  border-radius: 8px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 8;
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Circuit Listing Slide-over Drawer */
.code-drawer {
  position: absolute;
  top: 10px;
  right: 10px;
  bottom: 10px;
  width: 340px;
  background: rgba(18, 17, 15, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid #3c362e;
  border-radius: 10px;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 18px));
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 10;
}

.code-drawer.open {
  transform: translateX(0);
}

.code-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #2b2722;
}

.code-drawer-title {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--mint);
}

.code-drawer-actions {
  display: flex;
  gap: 5px;
}

.mini-btn {
  padding: 3px 8px;
  background: #26221e;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid #3a342e;
  border-radius: 5px;
  cursor: pointer;
}

.mini-btn:hover {
  border-color: var(--amber);
}

.code-listing {
  flex: 1;
  padding: 12px;
  margin: 0;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.62;
  color: #dfd7c9;
  user-select: text;
}

.code-drawer-foot {
  padding: 8px 12px;
  border-top: 1px solid #2b2722;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-dim);
}

/* ---------------- Fixed-Height Inspector Strip ---------------- */
.inspector-strip {
  height: 42px;
  padding: 0 14px;
  background: var(--chassis);
  border: 1px solid var(--bezel);
  border-radius: 10px;
  display: flex;
  align-items: center;
  box-shadow: inset 0 1px 0 var(--bezel-hi);
  overflow: hidden;
}

.inspector-content {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-dim);
}

.study-note-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.note-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  background: rgba(245, 166, 35, 0.13);
  color: var(--amber);
  border: 1px solid rgba(245, 166, 35, 0.3);
}

.note-text {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-shortcut-hint {
  flex-shrink: 0;
  font-size: 10.5px;
  color: var(--ink-faint);
}

.insp-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.insp-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-weight: 600;
}

.insp-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.insp-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--chassis-deep);
  border: 1px solid #322d27;
  border-radius: 6px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
}

.insp-btn {
  padding: 4px 9px;
  background: #272420;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #3c362f;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 110ms ease, background 110ms ease;
}

.insp-btn:hover {
  border-color: var(--amber);
  background: #302c27;
}

.insp-btn.active {
  border-color: var(--amber);
  color: var(--amber);
}

.insp-btn.danger:hover {
  border-color: var(--vermilion);
  color: var(--vermilion-hi);
}

/* ---------------- Bottom Tactile Module Deck ---------------- */
.deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  background: linear-gradient(180deg, #201d1a 0%, #171513 100%);
  border: 1px solid var(--bezel);
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 var(--bezel-hi),
    0 6px 20px rgba(0, 0, 0, 0.42);
}

.palette {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.mod-key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  width: 68px;
  height: 48px;
  padding: 6px 8px 6px;
  background: linear-gradient(180deg, #2b2723 0%, #201d1a 100%);
  border: 1px solid #39342e;
  border-radius: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 2px 0 #0e0d0b;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 80ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.mod-key:hover {
  border-color: #544d44;
  background: linear-gradient(180deg, #322d28 0%, #24201d 100%);
}

.mod-key.active {
  transform: translateY(1px);
  background: linear-gradient(180deg, #26221e 0%, #1d1a17 100%);
  border-color: var(--mod-accent, var(--amber));
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 0 0 1px color-mix(in srgb, var(--mod-accent, var(--amber)) 35%, transparent),
    0 0 14px color-mix(in srgb, var(--mod-accent, var(--amber)) 18%, transparent);
}

.mod-key-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mod-led {
  width: 14px;
  height: 3px;
  border-radius: 99px;
  background: var(--mod-accent, var(--amber));
  opacity: 0.45;
  transition: opacity 120ms ease, box-shadow 120ms ease;
}

.mod-key.active .mod-led {
  opacity: 1;
  box-shadow: 0 0 8px var(--mod-accent, var(--amber));
}

.mod-hotkey {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-faint);
}

.mod-code {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1;
}

.mod-name {
  font-family: var(--sans);
  font-size: 9.5px;
  color: var(--ink-dim);
  line-height: 1;
}

.deck-utils {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 10px;
  border-left: 1px solid var(--bezel);
}

.util-btn {
  height: 34px;
  padding: 0 10px;
  background: #23201d;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  border: 1px solid #35302a;
  border-radius: 7px;
  cursor: pointer;
  transition: all 120ms ease;
}

.util-btn:hover {
  color: var(--ink);
  border-color: #554e45;
}

.util-btn.active {
  color: var(--amber);
  border-color: var(--amber);
  background: rgba(245, 166, 35, 0.09);
}

.util-btn.util-danger:hover {
  color: var(--vermilion-hi);
  border-color: var(--vermilion);
}

/* Responsive compactness for slightly narrower viewports */
@media (max-width: 1180px) {
  .knob-control { width: 52px; }
  .scope-housing { width: 84px; }
  .mod-key { width: 60px; padding: 5px 6px; }
  .note-shortcut-hint { display: none; }
}

/* Mobile / phone layout (portrait & landscape) */
@media (max-width: 820px) {
  html, body {
    overflow: hidden;
    touch-action: manipulation;
  }

  .chassis {
    height: 100dvh;
    padding: 8px;
    gap: 7px;
  }

  .faceplate {
    flex-wrap: wrap;
    padding: 7px 9px;
    gap: 6px;
  }

  .faceplate-left,
  .faceplate-right {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: wrap;
  }

  .brand {
    padding-right: 6px;
    gap: 6px;
  }

  .brand-rev,
  .scope-housing,
  #btn-step,
  .note-shortcut-hint,
  .desktop-only,
  .knob-control:nth-child(2),
  .knob-control:nth-child(3) {
    display: none;
  }

  .brand-name {
    font-size: 13px;
    letter-spacing: 0.12em;
  }

  .study-picker .micro-label,
  .scale-picker .micro-label {
    display: none;
  }

  .hardware-select {
    font-size: 11px;
    padding: 5px 22px 5px 7px;
    max-width: 140px;
  }

  .transport {
    gap: 5px;
  }

  .keycap {
    height: 30px;
    padding: 0 8px;
    font-size: 10px;
  }

  .keycap-icon {
    width: 30px;
    padding: 0;
  }

  .keycap-play {
    min-width: 64px;
  }

  .knob-group {
    gap: 6px;
    flex: 0 1 auto;
  }

  .knob-control {
    width: 72px;
  }

  #board-canvas {
    touch-action: none;
  }

  .audio-wake-pill {
    padding: 10px 18px;
    font-size: 12.5px;
    bottom: 12px;
    white-space: nowrap;
  }

  .code-drawer {
    width: calc(100% - 20px);
  }

  .inspector-strip {
    height: auto;
    min-height: 36px;
    padding: 6px 10px;
  }

  .inspector-content {
    flex-wrap: wrap;
    gap: 6px;
  }

  .note-text {
    white-space: normal;
    font-size: 11.5px;
    line-height: 1.3;
  }

  .deck {
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    padding: 7px 8px;
  }

  .palette {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    gap: 5px;
  }

  .mod-key {
    flex: 0 0 auto;
    width: 56px;
    height: 44px;
    padding: 5px 6px;
  }

  .deck-utils {
    border-left: none;
    border-top: 1px solid var(--bezel);
    padding-left: 0;
    padding-top: 6px;
    justify-content: space-between;
  }

  .util-btn {
    flex: 1;
    height: 30px;
    font-size: 10px;
    padding: 0 6px;
  }
}
