:root {
  --bg: #12141a;
  --bg-panel: #1c2028;
  --bg-input: #0e1014;
  --border: #3a4150;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #3d8bfd;
  --ok: #3dd68c;
  --bad: #f07178;
  --dock: #151820;
  --card: #1a3358;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Microsoft YaHei", "Segoe UI", sans-serif;
  user-select: none;
}

button, input, select {
  font: inherit;
  color: var(--text);
}

input, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

button {
  background: #2a3140;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

button:hover { border-color: #5a6578; }
button.primary { background: var(--accent); border-color: #2f6fd4; }
button.danger { background: #8a2a32; border-color: #b43a44; }
button.on { background: #1f4a38; border-color: #2f8a5a; color: var(--ok); }
.icon-btn.on { background: #1f4a38; border-color: #2f8a5a; }
.icon-btn:not(.on) { background: #3a2226; border-color: #8a3a44; color: #f3c0c4; }

.hint { color: var(--muted); font-size: 12px; }
.err { color: var(--bad); margin: 8px 0 0; }

.lobby {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lobby-card {
  width: min(420px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-icon { width: 48px; height: 48px; align-self: center; }
.lobby-card h1 { margin: 4px 0 0; font-size: 20px; text-align: center; }
.lobby-card .hint { text-align: center; margin: 0 0 8px; }
.lobby-card label { color: var(--muted); margin-top: 6px; }
.lobby-card .primary { margin-top: 14px; padding: 10px 12px; }
#signalingRow { display: flex; flex-direction: column; gap: 8px; }
#signalingRow[hidden] { display: none !important; }

.local-preview.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.local-preview.empty video { display: none; }
.local-preview.empty::after { content: '未开摄像头'; }
.card.local { outline: 1px dashed #4a6a9a; }

.room {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
}

.stage {
  flex: 1;
  min-width: 0;
  position: relative;
  background: #000;
}

.stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  pointer-events: none;
}

.stage-empty.hidden { display: none; }

.stage-name {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
}

.local-preview {
  position: absolute;
  width: 220px;
  height: 140px;
  right: 16px;
  bottom: 16px;
  border: 1px solid #5a6578;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  cursor: move;
  z-index: 3;
}

.local-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.local-preview.swap {
  width: 100%;
  height: 100%;
  right: 0;
  bottom: 0;
  border: 0;
  border-radius: 0;
  cursor: default;
  background: #000;
}

.local-preview.swap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.local-tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 12px;
}

.cards-col {
  width: 380px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: #152238;
  border-left: 1px solid #243652;
}

body.cards-hidden .cards-col { display: none; }

.cards-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  color: #c5d4ea;
}

.cards {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  font-size: 12px;
}

.card.active { outline: 2px solid var(--accent); }
.card.local { outline: 1px dashed #4a6a9a; }

.card-tbl {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.card-tbl col.lab { width: 72px; }
.card-tbl col.val { width: auto; }
.card-tbl th,
.card-tbl td {
  border: 1px solid var(--border);
  padding: 3px 5px;
  text-align: center;
  vertical-align: middle;
  height: 26px;
}

.card-tbl th {
  color: var(--muted);
  background: #1e2229;
  font-weight: 600;
  white-space: nowrap;
}

.card-tbl td { color: var(--text); }
.card-tbl .name { font-weight: 600; text-align: left; }
.card-tbl .chk label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.card-tbl input[type="checkbox"] { accent-color: var(--ok); }
.card-tbl .vol { width: 100%; }
.card-tbl .vu { padding: 4px 6px; }
.vu-track {
  height: 10px;
  background: #111;
  border: 1px solid #333;
  overflow: hidden;
}
.vu-fill {
  height: 100%;
  width: 0%;
  background: #3d8bfd;
}
.card-tbl .btncell { padding: 0; }
.card-tbl .cell-btn {
  width: 100%;
  height: 26px;
  border: 0;
  border-radius: 0;
  background: #2e3542;
}
.card-tbl .cell-btn.danger { background: #5a2a30; }
.card-tbl .cell-btn.on { background: #1f4a38; color: var(--ok); }
.card-tbl .loss.hot { color: var(--bad); }

.card-preview {
  height: 132px;
  background: #1a4aa8;
  position: relative;
  cursor: pointer;
}
.card-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0b1628;
}
.card-preview .ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #dbe7ff;
  font-size: 22px;
  font-weight: 700;
  pointer-events: none;
}
.card-preview.has-video .ph { display: none; }

.dock {
  height: 72px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--dock);
  border-top: 1px solid #2a3140;
}

.dock-meta { min-width: 160px; display: flex; flex-direction: column; gap: 2px; }
.dock-tools { flex: 1; display: flex; justify-content: center; gap: 18px; }
.dock-end { margin-left: auto; display: flex; gap: 8px; }

.split { display: flex; align-items: stretch; }
.icon-btn {
  width: 48px;
  height: 44px;
  border-radius: 8px 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.caret {
  width: 22px;
  border-radius: 0 8px 8px 0;
  border-left: 0;
  padding: 0;
}

.popover {
  position: fixed;
  z-index: 20;
  width: 280px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.picker {
  width: min(880px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.picker-head h2 { margin: 0; font-size: 16px; }

.share-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.share-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
}

.share-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  background: #000;
}

.share-item span {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-list .hint { grid-column: 1 / -1; margin: 0; }
