:root {
  --room-bg: #07080a;
  --room-glow: rgba(255, 200, 120, 0.028);
  --chassis-top: #181a1f;
  --chassis-bot: #101216;
  --chassis-border: rgba(255, 255, 255, 0.055);
  --chassis-edge: rgba(255, 255, 255, 0.068);
  --silk: rgba(220, 224, 232, 0.46);
  --silk-bright: rgba(238, 242, 248, 0.86);
  --unit-model: rgba(232, 236, 244, 0.72);
  --cabinet-rail: linear-gradient(90deg, #0b0c0f 0%, #14161b 16px, #050608 18px, #050608 calc(100% - 18px), #14161b calc(100% - 16px), #0b0c0f 100%);
  --amber: #f0b35a;
  --mono: "SF Mono", "JetBrains Mono", "Menlo", ui-monospace, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Inter", sans-serif;
}

/* Hardware Theme 2: McIntosh Piano-Black Glass & Chrome */
body[data-theme="mcintosh"] {
  --room-bg: #04060b;
  --room-glow: rgba(52, 148, 255, 0.045);
  --chassis-top: #12151d;
  --chassis-bot: #07090e;
  --chassis-border: rgba(145, 200, 255, 0.13);
  --chassis-edge: rgba(200, 230, 255, 0.18);
  --unit-model: rgba(188, 230, 255, 0.88);
  --amber: #58c4ff;
}

/* Hardware Theme 3: Brushed Silver Marantz + Oiled Walnut Stack Cheeks */
body[data-theme="marantz"] {
  --room-bg: #120e0b;
  --room-glow: rgba(90, 210, 240, 0.035);
  --chassis-top: #cfd3da;
  --chassis-bot: #a6acb6;
  --chassis-border: rgba(255, 255, 255, 0.35);
  --chassis-edge: rgba(255, 255, 255, 0.65);
  --silk: rgba(24, 28, 36, 0.62);
  --unit-model: rgba(16, 20, 28, 0.88);
  --cabinet-rail: linear-gradient(90deg, #3c2212 0%, #5e371f 15px, #1e120a 18px, #121317 calc(100% - 18px), #5e371f calc(100% - 15px), #3c2212 100%);
  --amber: #52d4ff;
}

body[data-theme="marantz"] .unit {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -1px 0 rgba(40, 44, 52, 0.45),
    0 10px 26px rgba(0, 0, 0, 0.55);
}

body[data-theme="marantz"] .micro-btn {
  background: rgba(16, 20, 28, 0.14);
  border-color: rgba(16, 20, 28, 0.24);
  color: rgba(16, 20, 28, 0.76);
}

body[data-theme="marantz"] .micro-btn:hover {
  background: rgba(16, 20, 28, 0.26);
  color: #090b10;
}

/* Hardware Theme 4: Braun Atelier Matte Graphite */
body[data-theme="nocturne"] {
  --room-bg: #0b0c0e;
  --room-glow: rgba(220, 226, 236, 0.02);
  --chassis-top: #212327;
  --chassis-bot: #17191d;
  --chassis-border: rgba(255, 255, 255, 0.075);
  --chassis-edge: rgba(255, 255, 255, 0.09);
  --unit-model: rgba(238, 242, 248, 0.82);
  --amber: #ea4b30;
}

/* Hardware Theme 5: Soviet Lab 74 Olive Gunmetal */
body[data-theme="soviet"] {
  --room-bg: #080a07;
  --room-glow: rgba(110, 255, 96, 0.03);
  --chassis-top: #222820;
  --chassis-bot: #161b15;
  --chassis-border: rgba(190, 210, 165, 0.09);
  --chassis-edge: rgba(205, 224, 175, 0.12);
  --silk: rgba(204, 214, 182, 0.52);
  --unit-model: rgba(218, 232, 188, 0.84);
  --amber: #86f274;
}

/* Hardware Theme 6: Midnight Amber Obsidian */
body[data-theme="amber"] {
  --room-bg: #060403;
  --room-glow: rgba(255, 152, 46, 0.045);
  --chassis-top: #16110d;
  --chassis-bot: #0c0907;
  --chassis-border: rgba(255, 178, 88, 0.09);
  --chassis-edge: rgba(255, 190, 110, 0.11);
  --silk: rgba(235, 198, 150, 0.46);
  --unit-model: rgba(250, 210, 148, 0.84);
  --amber: #ffaa40;
}

/* Hardware Theme 7: OBSCURA — Suggestive Architectural Minimalist (zero skeuomorphism) */
body[data-theme="obscura"] {
  --room-bg: #050506;
  --room-glow: rgba(0, 0, 0, 0);
  --chassis-top: #050506;
  --chassis-bot: #050506;
  --chassis-border: rgba(235, 231, 223, 0.07);
  --chassis-edge: rgba(0, 0, 0, 0);
  --silk: rgba(235, 231, 223, 0.24);
  --unit-model: rgba(235, 231, 223, 0.42);
  --cabinet-rail: #050506;
  --amber: #d44d34;
}

body[data-theme="obscura"]::before {
  display: none;
}

body[data-theme="obscura"] .unit {
  background: #050506;
  border-radius: 0;
  box-shadow: none;
}

body[data-theme="obscura"] .unit::before,
body[data-theme="obscura"] .unit::after {
  display: none;
}

body[data-theme="obscura"] .unit-head {
  padding: 8px 12px 2px;
}

body[data-theme="obscura"] .unit-desc {
  display: none;
}

body[data-theme="obscura"].layout-stack .rack {
  background: transparent;
  border: none;
  box-shadow: none;
  gap: 0;
  padding: 0;
}

body[data-theme="obscura"].layout-stack .unit {
  padding-left: 0;
  padding-right: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  border-bottom: 1px solid rgba(235, 231, 223, 0.08);
  box-shadow: none;
}

body[data-theme="obscura"].is-fullscreen .unit-model {
  opacity: 0.35;
}

/* Hardware Theme 8: GALLERY PAPER — Archival Light Paper & Charcoal Ink Minimal */
body[data-theme="paper"] {
  --room-bg: #f1ede4;
  --room-glow: rgba(0, 0, 0, 0);
  --chassis-top: #f1ede4;
  --chassis-bot: #f1ede4;
  --chassis-border: rgba(28, 27, 24, 0.11);
  --chassis-edge: rgba(0, 0, 0, 0);
  --silk: rgba(28, 27, 24, 0.44);
  --silk-bright: #1c1b18;
  --unit-model: rgba(28, 27, 24, 0.52);
  --cabinet-rail: #f1ede4;
  --amber: #cf4229;
}

body[data-theme="paper"]::before {
  display: none;
}

body[data-theme="paper"] .top-bar {
  background: rgba(241, 237, 228, 0.94);
  border-bottom-color: rgba(28, 27, 24, 0.10);
}

body[data-theme="paper"] .brand {
  color: rgba(28, 27, 24, 0.82);
}

body[data-theme="paper"] .src-readout {
  border-left-color: rgba(28, 27, 24, 0.14);
}

body[data-theme="paper"] .tb-btn {
  border-color: rgba(28, 27, 24, 0.15);
  background: rgba(28, 27, 24, 0.03);
  color: rgba(28, 27, 24, 0.72);
}

body[data-theme="paper"] .tb-btn:hover {
  border-color: rgba(28, 27, 24, 0.42);
  color: #11100e;
}

body[data-theme="paper"] .tb-btn.active {
  border-color: rgba(207, 66, 41, 0.65);
  background: rgba(207, 66, 41, 0.10);
  color: #a82e18;
}

body[data-theme="paper"] .unit {
  background: #f1ede4;
  border-radius: 0;
  box-shadow: none;
}

body[data-theme="paper"] .unit::before,
body[data-theme="paper"] .unit::after {
  display: none;
}

body[data-theme="paper"] .unit-head {
  padding: 8px 12px 2px;
}

body[data-theme="paper"] .unit-desc {
  display: none;
}

body[data-theme="paper"] .micro-btn {
  background: rgba(28, 27, 24, 0.05);
  border-color: rgba(28, 27, 24, 0.16);
  color: rgba(28, 27, 24, 0.72);
}

body[data-theme="paper"] .micro-btn:hover {
  border-color: rgba(28, 27, 24, 0.42);
  color: #11100e;
}

body[data-theme="paper"].layout-stack .rack {
  background: transparent;
  border: none;
  box-shadow: none;
  gap: 0;
  padding: 0;
}

body[data-theme="paper"].layout-stack .unit {
  padding-left: 0;
  padding-right: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  border-bottom: 1px solid rgba(28, 27, 24, 0.11);
  box-shadow: none;
}

body[data-theme="paper"].is-fullscreen .unit-model {
  opacity: 0.38;
}

/* Optical Room Dimmer & Drag-Drop Audio File Veil */
.dimmer-veil {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: #000000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.drop-veil {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 8, 0.80);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.drop-veil.active {
  opacity: 1;
}

.drop-card {
  padding: 24px 32px;
  border-radius: 8px;
  border: 1px dashed rgba(240, 179, 90, 0.65);
  background: rgba(16, 18, 22, 0.92);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #f4efe6;
}

.dr-mini-acts {
  display: flex;
  gap: 5px;
}

.dr-mini-btn {
  appearance: none;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(230, 236, 244, 0.80);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.14s ease;
}

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

.dr-mini-btn.danger:hover {
  border-color: rgba(235, 86, 68, 0.65);
  color: #ff9484;
}

.rack-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 260px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--silk);
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--room-bg);
  color: var(--silk-bright);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Subtle dark listening-room ambient depth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at 50% 45%, var(--room-glow) 0%, transparent 68%),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.007) 0px,
      rgba(255, 255, 255, 0.007) 1px,
      transparent 1px,
      transparent 3px
    );
}

/* Top console strip */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(16, 18, 22, 0.94), rgba(10, 11, 14, 0.88));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

/* 100% HUDless Fullscreen Mode */
body.is-fullscreen .top-bar {
  display: none !important;
}

body.is-fullscreen .rack-stage {
  top: 0;
  padding: 6px;
}

body.is-fullscreen.layout-stack .rack-stage {
  padding: 8px 16px;
}

body.is-fullscreen .unit-ctrls {
  display: none !important;
}

body.is-fullscreen .unit-head {
  cursor: default;
}

body.is-fullscreen .unit-canvas {
  cursor: default;
}

body.is-fullscreen.cursor-idle,
body.is-fullscreen.cursor-idle * {
  cursor: none !important;
}

.tb-left, .tb-center, .tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.power-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #444952;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.power-led.live {
  background: #d8a256;
  box-shadow: 0 0 4px rgba(216, 162, 86, 0.55);
}

.brand {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(232, 236, 242, 0.78);
}

.src-readout {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--silk);
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.09);
  max-width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(220, 226, 236, 0.68);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.13em;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.tb-btn:hover {
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}

.tb-btn.active {
  border-color: rgba(240, 179, 90, 0.55);
  background: rgba(240, 179, 90, 0.12);
  color: #ffe2b0;
}

/* Stage wrapper for Wall / 19" Stack / Solo */
.rack-stage {
  position: fixed;
  top: 44px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.rack-stage::-webkit-scrollbar {
  display: none;
}

.rack {
  width: 100%;
  min-height: 100%;
}

/* =========================================================================
   WALL LAYOUT: Dense architectural studio equipment wall
   ========================================================================= */
body.layout-wall .rack {
  height: 100%;
  display: grid;
  grid-auto-flow: dense;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  grid-auto-rows: minmax(175px, 1fr);
}

body.layout-wall .rack[data-cols="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.layout-wall .rack[data-cols="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.layout-wall .rack[data-cols="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

body.layout-wall .unit.span-2 {
  grid-column: span 2;
}

body.layout-wall .unit.span-3 {
  grid-column: span 3;
}

/* =========================================================================
   19" STACK LAYOUT: Flush stacked Japanese/German Hi-Fi studio tower
   ========================================================================= */
body.layout-stack .rack-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12px 16px;
}

body.layout-stack .rack {
  width: min(940px, 100%);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: 8px;
  background: var(--cabinet-rail);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.8),
    0 24px 64px rgba(0, 0, 0, 0.85);
}

body.layout-stack .unit {
  border-radius: 2px;
  padding-left: 14px;
  padding-right: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.085),
    inset 0 -1px 0 rgba(0, 0, 0, 0.82);
}

body.layout-stack .unit:first-child {
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

body.layout-stack .unit:last-child {
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
}

/* Authentic 1U / 2U / 3U vertical rack heights */
body.layout-stack .unit.u-1 {
  flex: 1 0 108px;
  min-height: 108px;
}

body.layout-stack .unit.u-2 {
  flex: 2 0 185px;
  min-height: 185px;
}

body.layout-stack .unit.u-3 {
  flex: 3 0 268px;
  min-height: 268px;
}

/* Rack-ear vertical slots in 19" Stack mode */
body.layout-stack .unit::before,
body.layout-stack .unit::after {
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  box-shadow:
    0 -22px 0 -0.5px #111318,
    0 22px 0 -0.5px #111318;
}

/* =========================================================================
   SOLO LAYOUT: Single expanded museum unit
   ========================================================================= */
body.layout-solo .rack {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

body.layout-solo .unit:not(.is-solo) {
  display: none;
}

/* =========================================================================
   Individual Machined Anodized Aluminum Component Unit
   ========================================================================= */
.unit {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-radius: 5px;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.011) 0px,
      rgba(255, 255, 255, 0.011) 1px,
      transparent 1px,
      transparent 2px
    ),
    linear-gradient(180deg, var(--chassis-top) 0%, var(--chassis-bot) 100%);
  border: 1px solid var(--chassis-border);
  box-shadow:
    inset 0 1px 0 var(--chassis-edge),
    inset 0 -1px 0 rgba(0, 0, 0, 0.65),
    0 10px 26px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  transition: border-color 0.16s ease, opacity 0.16s ease;
}

.unit.dragging {
  opacity: 0.42;
}

.unit.drag-over {
  border-color: rgba(240, 179, 90, 0.68);
  box-shadow: inset 0 0 0 1px rgba(240, 179, 90, 0.45);
}

/* Subtle machined rack-mount corner hex/screw indents */
.unit::before,
.unit::after {
  content: "";
  position: absolute;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a2e36, #090a0d);
  border: 1px solid rgba(255, 255, 255, 0.075);
  z-index: 3;
  pointer-events: none;
}
.unit::before { left: 9px; }
.unit::after { right: 9px; }

.unit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 24px 2px;
  flex: 0 0 auto;
  cursor: grab;
}

.unit-head:active {
  cursor: grabbing;
}

.unit-id {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.unit-model {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--unit-model);
  white-space: nowrap;
}

.unit-desc {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  color: var(--silk);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-ctrls {
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.32;
  transition: opacity 0.18s ease;
}

.unit:hover .unit-ctrls,
.unit:focus-within .unit-ctrls {
  opacity: 1;
}

.micro-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(0, 0, 0, 0.34);
  color: rgba(215, 222, 232, 0.65);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.11em;
  padding: 2px 6px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.micro-btn:hover {
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.micro-btn.danger:hover {
  border-color: rgba(255, 96, 76, 0.6);
  color: #ff8e7e;
}

.unit-canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.unit-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Brief Fullscreen Exit Toast (fades completely to 0) */
.fs-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 60;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(12, 14, 18, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(235, 240, 248, 0.82);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.fs-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Initial one-tap Audio Unlock Veil */
.start-veil {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 6, 8, 0.76);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: opacity 0.45s ease;
}

.start-veil.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-card {
  width: min(440px, 100%);
  padding: 28px 26px;
  border-radius: 8px;
  background: linear-gradient(180deg, #17191f, #0f1115);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.8);
}

.start-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.20em;
  color: rgba(242, 245, 250, 0.9);
  margin-bottom: 12px;
}

.start-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px rgba(240, 179, 90, 0.8);
}

.start-sub {
  font-size: 13px;
  line-height: 1.55;
  color: rgba(210, 216, 226, 0.66);
  margin-bottom: 22px;
}

.start-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.btn-primary, .btn-ghost {
  appearance: none;
  border-radius: 5px;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-primary {
  border: 1px solid rgba(240, 179, 90, 0.65);
  background: rgba(240, 179, 90, 0.16);
  color: #ffebd0;
}

.btn-primary:hover {
  background: rgba(240, 179, 90, 0.25);
  box-shadow: 0 0 22px rgba(240, 179, 90, 0.22);
}

.btn-ghost {
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(220, 226, 236, 0.72);
}

.btn-ghost:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.start-err {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: #ff6e5a;
  min-height: 15px;
}

/* Rack Builder Slide-out Drawer */
.drawer-bg {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(4, 5, 8, 0.64);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-bg.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  width: min(440px, 100%);
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: linear-gradient(180deg, #15171c, #0e1014);
  border-left: 1px solid rgba(255, 255, 255, 0.10);
  transform: translateX(24px);
  transition: transform 0.25s ease;
}

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

.dr-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.20em;
  color: rgba(235, 240, 248, 0.88);
  margin-bottom: 18px;
}

.dr-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
}

.dr-sec {
  margin-bottom: 20px;
}

.dr-lbl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dr-lbl {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--silk);
  margin-bottom: 8px;
}

.dr-lbl-row .dr-lbl { margin-bottom: 0; }

.dr-val {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--amber);
}

.dr-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.dr-pill {
  appearance: none;
  flex: 1 1 auto;
  padding: 8px 9px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(220, 226, 236, 0.72);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dr-pill:hover {
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}

.dr-pill.active {
  border-color: rgba(240, 179, 90, 0.62);
  background: rgba(240, 179, 90, 0.14);
  color: #ffebd0;
}

input[type="range"] {
  width: 100%;
  accent-color: #f0b35a;
}

/* Hardware Theme Swatch Grid */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.theme-btn {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(220, 226, 236, 0.78);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.theme-btn.active {
  border-color: var(--amber);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  flex: 0 0 auto;
}

/* Grouped Hardware Module Catalog */
.catalog-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cat-group {
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.015);
  overflow: hidden;
}

.cat-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.025);
  transition: background 0.14s ease;
}

.cat-group-head:hover {
  background: rgba(255, 255, 255, 0.05);
}

.cat-group-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: rgba(232, 238, 246, 0.78);
}

.cat-group-chev {
  font-size: 8px;
  color: var(--silk);
  transition: transform 0.16s ease;
}

.cat-group.collapsed .cat-group-chev {
  transform: rotate(-90deg);
}

.cat-group.collapsed .catalog-grid {
  display: none;
}

.cat-group-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cat-group-stat {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--silk);
}

.cat-group-stat.has-some {
  color: var(--amber);
}

.cat-group .catalog-grid {
  padding: 7px;
}

/* Add Hardware Module 2-Column Catalog */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.cat-btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.025);
  color: rgba(232, 238, 246, 0.88);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-btn:hover {
  border-color: rgba(240, 179, 90, 0.52);
  background: rgba(240, 179, 90, 0.08);
}

.cat-btn.in-rack {
  border-color: rgba(240, 179, 90, 0.34);
  background: rgba(240, 179, 90, 0.06);
}

.cat-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cat-model {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.cat-sub {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--silk);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.cat-count {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(240, 179, 90, 0.18);
  border: 1px solid rgba(240, 179, 90, 0.45);
  color: #ffe2b0;
  letter-spacing: 0.04em;
}

.cat-plus {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--amber);
  flex: 0 0 auto;
}

/* Installed Units Editor List */
.module-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mod-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 9px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.075);
}

.mod-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(235, 240, 248, 0.88);
}

.mod-sub {
  color: var(--silk);
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mod-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.mod-actions button {
  appearance: none;
  height: 23px;
  min-width: 23px;
  padding: 0 5px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(220, 226, 236, 0.78);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
  transition: all 0.14s ease;
}

.mod-actions button:hover {
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.mod-actions button.accent {
  border-color: rgba(240, 179, 90, 0.35);
  color: #f3c882;
}

.mod-actions button.del:hover {
  border-color: rgba(255, 90, 74, 0.6);
  color: #ff8c7a;
}

.dr-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  color: var(--silk);
}

.dr-foot kbd {
  padding: 1px 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  color: #fff;
}

@media (max-width: 720px) {
  .src-readout, .unit-desc { display: none; }
  .rack-stage { padding: 8px; }
  body.layout-wall .rack,
  body.layout-wall .rack[data-cols] {
    height: auto;
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(175px, 1fr);
  }
  body.layout-wall .unit.span-2,
  body.layout-wall .unit.span-3 {
    grid-column: span 1;
  }
  body.layout-wall .unit.u-3 {
    grid-row: span 1;
  }
  .unit-ctrls {
    opacity: 0.85;
  }
}
