:root {
  --bg: #0a0b0d;
  --panel: #101216;
  --panel-2: #15181e;
  --line: #23272f;
  --line-soft: #1a1e25;
  --text: #e9ecf1;
  --muted: #8a93a3;
  --dim: #5d6572;
  --amber: #ffb020;
  --amber-dim: #3a2c10;
  --red: #ff3b30;
  --green: #22c55e;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #16191f 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; color: inherit; text-align: left; }
.hidden { display: none !important; }

/* ---------------- Lobby ---------------- */
.lobby {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background:
    radial-gradient(700px 400px at 50% 0%, #1b2028 0%, transparent 65%),
    var(--bg);
  padding: 24px;
}
.lobby-card {
  width: min(460px, 100%);
  background: linear-gradient(180deg, #12151a, #0d0f13);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 32px 26px;
  box-shadow: 0 40px 80px -40px #000, inset 0 1px 0 #ffffff08;
}
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--amber), #e08900);
  color: #1a1200; font: 700 16px/1 var(--mono); letter-spacing: .5px;
  margin-bottom: 20px;
}
.lobby h1 {
  font-size: 22px; margin: 0 0 6px; letter-spacing: -.2px; font-weight: 650;
}
.lobby h1 span { color: var(--dim); font-weight: 500; font-size: 13px; margin-left: 6px; letter-spacing: .4px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 26px; line-height: 1.6; }

.field { display: block; margin-bottom: 20px; }
.field > span { display: block; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--dim); margin-bottom: 9px; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  background: #0a0c0f; border: 1px solid var(--line); color: var(--text);
  font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: #4b3a15; box-shadow: 0 0 0 3px #ffb02018; }

.roles { display: grid; gap: 8px; }
.role-chip {
  text-align: left; padding: 11px 14px; border-radius: 10px;
  background: #0a0c0f; border: 1px solid var(--line); color: var(--muted);
  font-size: 13px; transition: .15s;
}
.role-chip em { display: block; font-style: normal; color: var(--dim); font-size: 11px; margin-top: 3px; }
.role-chip.active { border-color: var(--amber); color: var(--text); background: #1a1408; }
.role-chip.active em { color: #a98a4a; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 7px 12px; text-align: center; border-radius: 999px; font-size: 12px;
  background: #0a0c0f; border: 1px solid var(--line); color: var(--muted);
}
.chip.on { border-color: #4a3a14; background: #1c1608; color: var(--amber); }

.enter {
  text-align: center;
  width: 100%; margin-top: 6px; padding: 14px; border-radius: 11px; border: 0;
  background: linear-gradient(180deg, var(--amber), #e39400);
  color: #1a1200; font-size: 14px; font-weight: 650; letter-spacing: .3px;
}
.enter:disabled { opacity: .5; }
.tiny { color: var(--dim); font-size: 11px; line-height: 1.6; margin: 14px 0 0; }

/* ---------------- App shell ---------------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
  background: #0b0d10cc; backdrop-filter: blur(8px);
}
.brand { font: 650 13px/1 var(--mono); letter-spacing: 2px; display: flex; align-items: center; gap: 8px; }
.brand i { font-style: normal; color: var(--dim); font-size: 10px; letter-spacing: 1px; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }

.tally {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--dim);
  font: 600 10.5px/1 var(--mono); letter-spacing: 1.6px;
}
.tally span { width: 8px; height: 8px; border-radius: 2px; background: #2a2f38; }
.tally.on { border-color: #5a1512; background: #1e0a09; color: #ff8b84; }
.tally.on span { background: var(--red); box-shadow: 0 0 10px var(--red); animation: tallyPulse 1.6s infinite; }
@keyframes tallyPulse { 50% { opacity: .45; } }

.meta { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.stat b { font: 600 12px/1 var(--mono); color: var(--text); }
.stat span { font-size: 9.5px; letter-spacing: 1px; color: var(--dim); text-transform: uppercase; }
.me { display: flex; align-items: center; gap: 8px; padding-left: 18px; border-left: 1px solid var(--line-soft); font-size: 12px; }
.me em { font-style: normal; color: var(--dim); font-size: 10px; }

.grid {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 268px minmax(360px, 1fr) 300px;
  gap: 1px; background: var(--line-soft);
}
.panel { background: var(--bg); padding: 18px; overflow-y: auto; }
.panel h2 {
  font-size: 10.5px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--dim); margin: 0 0 14px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: baseline;
}
.panel h2 small { font-size: 9.5px; letter-spacing: .6px; color: #404754; text-transform: none; }

/* Channels */
.ch-list { display: grid; gap: 6px; }
.ch-item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 9px; background: var(--panel);
  border: 1px solid transparent; transition: .15s;
}
.ch-item.sub { border-color: #3b2f12; background: #161205; }
.ch-item .n { font-size: 12.5px; }
.ch-item .h { font-size: 10.5px; color: var(--dim); margin-top: 3px; }
.ch-item .cnt { font: 600 10px/1 var(--mono); color: var(--dim); padding: 3px 6px; border-radius: 4px; background: #0a0c0f; }
.ch-item.sub .cnt { color: var(--amber); }
.ch-item:hover { border-color: var(--line); }

.producer-box { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.tool {
  width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 7px;
  border-radius: 9px; background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; align-items: center;
}
.tool em { font: 600 9px/1 var(--mono); letter-spacing: 1px; color: var(--dim); font-style: normal; }
.tool:hover { border-color: #333a45; color: var(--text); }
.tool.active { border-color: #5a1512; background: #1c0a09; color: #ff8b84; }
.tool.active em { color: #ff6b62; }
.tool.danger.active { border-color: var(--red); }

.legend { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.legend p { display: flex; align-items: center; gap: 9px; margin: 0 0 8px; font-size: 11px; color: var(--dim); }
.legend .k {
  font: 600 9.5px/1 var(--mono); padding: 4px 7px; border-radius: 4px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  min-width: 34px; text-align: center; font-style: normal;
}

/* Stage */
.stage {
  position: relative; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; gap: 26px;
}
.pgm-label { text-align: center; }
.pgm-label span { display: block; font: 600 9.5px/1 var(--mono); letter-spacing: 3px; color: var(--dim); margin-bottom: 8px; }
.pgm-label b { font-size: 15px; font-weight: 600; letter-spacing: .4px; }

.ptt {
  position: relative; width: 216px; height: 216px; border-radius: 50%;
  border: 1px solid #2c3138;
  background: radial-gradient(circle at 50% 35%, #1b1f26, #0d0f13 70%);
  color: var(--text); display: grid; place-items: center;
  box-shadow: inset 0 1px 0 #ffffff10, 0 24px 60px -30px #000;
  transition: transform .08s, box-shadow .2s, border-color .2s;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.ptt .ring {
  position: absolute; inset: -1px; border-radius: 50%;
  border: 1px solid transparent; transition: .2s;
}
.ptt { text-align: center; }
.ptt-inner b { display: block; font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.ptt-inner small { display: block; font: 600 9px/1 var(--mono); letter-spacing: 2.6px; color: var(--dim); margin-top: 9px; }
.ptt:hover { border-color: #3a414b; }
.ptt.on {
  border-color: var(--red); transform: scale(.985);
  background: radial-gradient(circle at 50% 35%, #2a1211, #140706 70%);
  box-shadow: inset 0 0 40px #ff3b3022, 0 0 0 6px #ff3b3012, 0 24px 60px -30px #000;
}
.ptt.on .ring { border-color: #ff3b3055; animation: pttRing 1.4s infinite; }
.ptt.on .ptt-inner b { color: #ff6b62; }
.ptt.on .ptt-inner small { color: #a33; }
@keyframes pttRing { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.16); opacity: 0; } }
.ptt.latched { border-color: var(--amber); }
.ptt.latched .ptt-inner b { color: var(--amber); }

.meter-wrap { width: min(420px, 80%); }
.meter {
  height: 10px; border-radius: 5px; background: #0d0f13;
  border: 1px solid var(--line); overflow: hidden; position: relative;
}
.meter i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #1e7a46, #4ade80 55%, var(--amber) 82%, var(--red));
  transition: width .06s linear;
}
.meter-labels { display: flex; justify-content: space-between; margin-top: 6px; font: 500 9px/1 var(--mono); color: #3f4653; }

.hint { font-size: 11.5px; color: var(--dim); text-align: center; letter-spacing: .2px; }

.stage-roster { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 560px; }
.stage-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 11px 6px 6px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--muted);
}
.stage-chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #3a424e; margin: 0 2px 0 4px;
}
.stage-chip.talk { border-color: #2f5c3f; color: var(--text); background: #0c1710; }
.stage-chip.talk .dot { background: #4ade80; box-shadow: 0 0 8px #4ade80; }

/* Roster */
.roster-list { display: grid; gap: 5px; }
.person {
  display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px; background: var(--panel);
  border: 1px solid transparent; transition: .12s;
}
.person.talk { border-color: #2f5c3f; background: #0c1710; }
.person .av {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  font: 600 10px/1 var(--mono); background: #1b1f26; color: var(--muted);
}
.person.talk .av { background: #14351f; color: #4ade80; }
.person .nm { font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.person .nm i { font: 600 8px/1 var(--mono); letter-spacing: .6px; color: var(--dim); border: 1px solid var(--line); padding: 2px 4px; border-radius: 3px; font-style: normal; }
.person .nm i.prod { color: var(--amber); border-color: #4a3a14; }
.person .sub { font-size: 10px; color: var(--dim); margin-top: 2px; }
.person .bars { display: flex; align-items: flex-end; gap: 2px; height: 18px; }
.person .bars b { width: 3px; height: 5px; background: #333b47; border-radius: 1px; transition: height .08s; }
.person.talk .bars b { background: #4ade80; }
.call-btn {
  text-align: center;
  border: 1px solid var(--line); background: #0a0c0f; color: var(--dim);
  font-size: 10px; padding: 4px 7px; border-radius: 5px;
}
.call-btn:hover { color: var(--text); border-color: #3a414b; }
.call-btn.on { color: var(--amber); border-color: #4a3a14; background: #1a1408; }

.self-test { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }

/* Tally mode */
body.onair .stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 2px #ff3b3040, inset 0 0 90px #ff3b3014;
}

@media (max-width: 1080px) {
  .grid { grid-template-columns: 220px 1fr; }
  .roster { display: none; }
}
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .channels { display: none; }
  .stage { padding: 16px; gap: 18px; }
  .ptt { width: 168px; height: 168px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .stat:nth-child(2) { display: none; }
}
