:root {
  --bg: #0c0e12;
  --panel: #181b22;
  --line: #272b34;
  --metal-1: #2c313b;
  --metal-2: #20242d;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --accent: #6ee7b7;
  --warn: #fbbf24;
  --bad: #f87171;
  --ok: #6ee7b7;
  --gap: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }      /* fix: class display:flex must not override hidden */
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  background:
    radial-gradient(1200px 500px at 50% -15%, #1a2230, #0c0e12 70%),
    var(--bg);
}

/* engraved-label helper look on headings */
h2, .mixer-head, .ch-cap {
  text-shadow: 0 1px 0 #000, 0 -1px 0 rgba(255,255,255,.04);
}

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: .02em; text-shadow: 0 2px 3px rgba(0,0,0,.6); }
.tag { font-size: 11px; background: var(--accent); color: #062a1f; padding: 2px 8px; border-radius: 999px; vertical-align: middle; margin-left: 4px; box-shadow: 0 0 12px rgba(110,231,183,.4); }
.icon-btn {
  background: linear-gradient(#2c313c, #1d222b); color: var(--text);
  border: 1px solid #0b0d12; width: 38px; height: 38px; border-radius: 10px;
  cursor: pointer; font-size: 16px; display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 2px 4px rgba(0,0,0,.5);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- amp-style control bar ---- */
.bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: linear-gradient(180deg, var(--metal-1), var(--metal-2));
  border: 1px solid #0b0d12; border-radius: 12px; padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 3px 8px rgba(0,0,0,.4);
}
.compact {
  background: #0a0c10; border: 1px solid #000; color: var(--text);
  border-radius: 8px; padding: 8px 10px; width: 130px; font-size: 14px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.7);
}
button {
  background: linear-gradient(#2c313c, #1f242d); color: var(--text);
  border: 1px solid #0b0d12; border-radius: 9px; padding: 8px 14px; cursor: pointer; font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 2px 3px rgba(0,0,0,.4);
}
button:hover:not(:disabled) { border-color: #3a4250; }
button.primary {
  background: linear-gradient(#7ef0c1, #4bd39c); color: #062a1f; border-color: #3fbf8c; font-weight: 700;
  box-shadow: 0 0 16px rgba(110,231,183,.45), inset 0 1px 0 rgba(255,255,255,.5);
}
button:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.push-right { margin-left: auto; }
.status { font-size: 12px; color: var(--muted); min-height: 16px; padding-left: 4px; }
.status.good { color: var(--ok); }
.status.bad { color: var(--bad); }
.status.pending { color: var(--warn); }

/* ---- stage layout ---- */
.stage {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr 250px;
  grid-template-rows: 1fr auto;
  gap: var(--gap);
}
.panel, .video-area, .side {
  background: linear-gradient(180deg, #1a1e26, #14171d);
  border: 1px solid #0b0d12; border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 3px 8px rgba(0,0,0,.35);
}
.video-area { grid-column: 1; grid-row: 1; min-height: 0; padding: 10px; overflow: hidden; }
.side { grid-column: 2; grid-row: 1 / span 2; padding: 12px; overflow: auto; }
h2 { font-size: 12px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.side h2:not(:first-child) { margin-top: 16px; }
.hint { color: var(--muted); font-size: 11px; text-transform: none; letter-spacing: 0; }

/* ---- video monitors ---- */
.video-grid {
  display: grid; gap: 8px; width: 100%; height: 100%;
  grid-auto-rows: 1fr; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.video-grid[data-count="0"] { place-items: center; }
.video-grid[data-count="0"]::after {
  content: "🎥  Video stage — click “Start camera”, or just jam audio-only.";
  color: var(--muted); font-size: 14px; text-align: center; padding: 0 20px;
}
.video-grid[data-count="1"] { grid-template-columns: 1fr; }
.video-grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.video-grid[data-count="3"], .video-grid[data-count="4"] { grid-template-columns: 1fr 1fr; }
.tile {
  position: relative; min-width: 0; min-height: 0; background: #000;
  border: 2px solid #0a0c10; border-radius: 10px; overflow: hidden; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04), inset 0 0 40px rgba(0,0,0,.5);
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.local video { transform: scaleX(-1); }
.tile-label { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; padding: 2px 7px; border-radius: 6px; }
.tile.enlarged { position: fixed; inset: 4vh 4vw; border-radius: 12px; z-index: 60; border-color: var(--accent); box-shadow: 0 20px 80px rgba(0,0,0,.7); cursor: zoom-out; }
body.has-enlarged::before { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.78); z-index: 55; }

/* ---- participants ---- */
.peers { display: flex; flex-direction: column; gap: 8px; }
.peer { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.peer .q { margin-left: auto; color: var(--muted); font-size: 11px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #444b57; flex: none; box-shadow: 0 0 6px rgba(0,0,0,.6) inset; }
.dot.q-excellent { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.q-good { background: #a3e635; box-shadow: 0 0 8px #a3e635; }
.dot.q-poor { background: var(--bad); box-shadow: 0 0 8px var(--bad); }

/* ---- latency LED readout ---- */
.latency {
  background: #06080b; border: 1px solid #000; border-radius: 10px; padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted);
  box-shadow: inset 0 0 12px rgba(0,0,0,.8);
}
.latency .big { font-size: 28px; font-weight: 700; line-height: 1; text-shadow: 0 0 12px currentColor; }
.latency .big.ok { color: var(--ok); }
.latency .big.warn { color: var(--warn); }
.latency .big.bad { color: var(--bad); }
.latency .unit { font-size: 12px; color: var(--muted); margin-left: 5px; text-shadow: none; }
.latency .breakdown { margin-top: 6px; font-size: 11px; }
.warn-note { margin: 14px 0 0; padding: 8px 10px; font-size: 12px; line-height: 1.4; color: var(--warn); background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.35); border-radius: 8px; }

/* ---- mixing console ---- */
.mixer-area {
  grid-column: 1; grid-row: 2; position: relative; overflow: hidden;
  padding: 12px; border-radius: 12px; border: 1px solid #0b0d12;
  background:
    radial-gradient(circle at 11px 11px, #0a0c10 0 2px, rgba(0,0,0,0) 3px),
    radial-gradient(circle at calc(100% - 11px) 11px, #0a0c10 0 2px, rgba(0,0,0,0) 3px),
    radial-gradient(circle at 11px calc(100% - 11px), #0a0c10 0 2px, rgba(0,0,0,0) 3px),
    radial-gradient(circle at calc(100% - 11px) calc(100% - 11px), #0a0c10 0 2px, rgba(0,0,0,0) 3px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 1px, rgba(0,0,0,0) 1px 3px),
    linear-gradient(180deg, #2d323d, #232730);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 3px 10px rgba(0,0,0,.45);
}
.mixer { display: flex; flex-direction: row; gap: 10px; align-items: stretch; overflow-x: auto; overflow-y: hidden; padding: 2px; }
.mixer-toggle { position: absolute; top: 8px; right: 10px; z-index: 3; width: 26px; height: 22px; padding: 0; font-size: 12px; border-radius: 6px; background: linear-gradient(#2c313c, #1d222b); border: 1px solid #0a0c10; color: var(--muted); cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }
.mixer-toggle:hover { color: var(--accent); border-color: var(--accent); }
.mixer-min-label { display: none; font-size: 11px; letter-spacing: .16em; font-weight: 700; color: var(--muted); }
.mixer-area.minimized { padding: 7px 12px; }
.mixer-area.minimized .mixer { display: none; }
.mixer-area.minimized .mixer-min-label { display: inline; }
.mix-empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }

.ch-strip {
  flex: 0 0 auto; width: 86px; display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 9px 6px 11px; border-radius: 9px; border: 1px solid #0a0c10;
  background: linear-gradient(180deg, #262b35, #181c23);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), inset 0 -10px 18px rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.4);
}
.ch-name { font-size: 11px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dfe3ea; }
.ch-cap { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ch-cap.value { color: var(--accent); font-weight: 700; }
.ch-knobbox { display: flex; flex-direction: column; align-items: center; gap: 2px; }

/* knob */
.knob {
  width: 40px; height: 40px; border-radius: 50%; position: relative; cursor: ns-resize; touch-action: none;
  background: radial-gradient(circle at 50% 30%, #454d5d, #20242d 72%);
  border: 1px solid #090b0f;
  box-shadow: inset 0 2px 2px rgba(255,255,255,.14), inset 0 -3px 7px rgba(0,0,0,.55), 0 3px 5px rgba(0,0,0,.5);
}
.knob-ind {
  position: absolute; left: calc(50% - 1.5px); top: 5px; width: 3px; height: 13px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 6px var(--accent); transform-origin: 50% 15px;
}

/* fader + VU */
.ch-faderrow { display: flex; gap: 8px; align-items: stretch; height: 100px; }
.ch-faderbox { position: relative; width: 30px; }
.ch-fader { position: absolute; left: 50%; top: 50%; width: 100px; height: 30px; transform: translate(-50%, -50%) rotate(-90deg); -webkit-appearance: none; appearance: none; background: transparent; }
.ch-fader::-webkit-slider-runnable-track { height: 6px; border-radius: 4px; background: linear-gradient(#06080b, #1b1f27); border: 1px solid #000; box-shadow: inset 0 0 5px #000; }
.ch-fader::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 26px; margin-top: -11px; border-radius: 3px; background: linear-gradient(#eef2f8, #aab2c0 47%, #3a4150 48% 52%, #aab2c0 53%, #6b7280); border: 1px solid #000; box-shadow: 0 1px 2px rgba(0,0,0,.6), inset 0 1px 0 #fff; }
.ch-fader::-moz-range-track { height: 6px; border-radius: 4px; background: linear-gradient(#06080b, #1b1f27); border: 1px solid #000; }
.ch-fader::-moz-range-thumb { width: 16px; height: 26px; border-radius: 3px; background: linear-gradient(#eef2f8, #aab2c0 48%, #6b7280); border: 1px solid #000; }
.ch-vu { display: flex; flex-direction: column; gap: 2px; width: 9px; }
.vu-seg { flex: 1; background: #14181f; border-radius: 1px; box-shadow: inset 0 0 1px #000; --c: #39d98a; }
.vu-seg.on { background: var(--c); box-shadow: 0 0 5px var(--c); }
.ch-vu .vu-seg:nth-child(-n+2) { --c: #f87171; }
.ch-vu .vu-seg:nth-child(3), .ch-vu .vu-seg:nth-child(4) { --c: #fbbf24; }

/* mute / solo */
.ch-btns { display: flex; gap: 6px; }
.ch-btn {
  width: 27px; height: 24px; font-size: 11px; font-weight: 800; border-radius: 6px; cursor: pointer;
  background: linear-gradient(#2b313c, #1c212a); border: 1px solid #0a0c10; color: var(--muted);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 1px 2px rgba(0,0,0,.5);
}
.ch-btn.mute.active { background: var(--bad); color: #2a0000; border-color: var(--bad); box-shadow: 0 0 12px var(--bad); }
.ch-btn.solo.active { background: var(--warn); color: #271c00; border-color: var(--warn); box-shadow: 0 0 12px var(--warn); }

/* mixer groups: YOUR MIX (interactive) + locked peer mixers */
.mix-group { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.mix-group + .mix-group { border-left: 1px solid #0b0d12; padding-left: 12px; margin-left: 2px; }
.mix-group-head { font-size: 10px; letter-spacing: .13em; text-transform: uppercase; font-weight: 700; color: var(--muted); white-space: nowrap; }
.mix-group.own .mix-group-head { color: var(--accent); }
.mix-group.locked .mix-group-head span { color: #cdd3dd; }
.mix-strips { display: flex; flex-direction: row; gap: 10px; }
.mix-group.locked { opacity: .9; }
.mix-group.locked .mix-strips { pointer-events: none; }

/* locked (read-only) channel strip */
.lk-strip {
  width: 64px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 5px 9px; border-radius: 8px; border: 1px solid #0a0c10;
  background: linear-gradient(180deg, #20242d, #161a20);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.lk-name { font-size: 10px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dfe3ea; }
.lk-faderrow { display: flex; gap: 6px; align-items: stretch; height: 66px; }
.lk-faderbox { position: relative; width: 22px; }
.lk-fader { position: absolute; left: 50%; top: 50%; width: 66px; height: 22px; transform: translate(-50%, -50%) rotate(-90deg); -webkit-appearance: none; appearance: none; background: transparent; pointer-events: none; }
.lk-fader::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: #0a0c10; border: 1px solid #000; box-shadow: inset 0 0 4px #000; }
.lk-fader::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 17px; margin-top: -7px; border-radius: 3px; background: linear-gradient(#b8bfca, #7a828f); border: 1px solid #000; box-shadow: 0 1px 1px rgba(0,0,0,.5); }
.lk-fader::-moz-range-track { height: 5px; border-radius: 3px; background: #0a0c10; border: 1px solid #000; }
.lk-fader::-moz-range-thumb { width: 11px; height: 17px; border-radius: 3px; background: linear-gradient(#b8bfca, #7a828f); border: 1px solid #000; }
.lk-vu { height: 66px; }
.lk-ms { display: flex; gap: 5px; }
.lk-led { width: 16px; height: 15px; border-radius: 4px; font-size: 9px; font-weight: 800; line-height: 15px; text-align: center; color: #3a4150; background: #14181f; border: 1px solid #0a0c10; }
.lk-led.m.active { background: var(--bad); color: #2a0000; box-shadow: 0 0 8px var(--bad); }
.lk-led.s.active { background: var(--warn); color: #271c00; box-shadow: 0 0 8px var(--warn); }

/* ---- diagnostics drawer ---- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 70; }
.advanced {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(440px, 94vw);
  overflow: auto; background: linear-gradient(180deg, #1a1e26, #14171d); border-left: 1px solid #0b0d12;
  z-index: 80; padding: 16px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: -12px 0 40px rgba(0,0,0,.5);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.advanced .panel { padding: 12px; }
.kvs { display: flex; flex-direction: column; gap: 6px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 5px; }
.kv span:first-child { color: var(--muted); }
.kv .ok { color: var(--ok); }
.kv .warn { color: var(--warn); }
.kv em { color: var(--muted); font-style: normal; font-size: 11px; }
.log { background: #06080b; border: 1px solid #000; border-radius: 8px; padding: 10px; height: 220px; overflow: auto; font-size: 12px; color: var(--muted); white-space: pre-wrap; margin: 0; box-shadow: inset 0 0 12px rgba(0,0,0,.7); }
code { background: #06080b; padding: 1px 5px; border-radius: 4px; }

/* ---- responsive ---- */
@media (max-width: 700px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto auto; }
  .side { grid-column: 1; grid-row: 3; }
}
