:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-2: #64748b;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --purple: #7c3aed;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }

/* ---------- Join view ---------- */
.view { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.join-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%; max-width: 440px;
  padding: 28px;
}
.logo { font-size: 22px; font-weight: 700; }
.join-sub { color: var(--text-2); margin: 6px 0 20px; font-size: 13px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; color: var(--text);
  outline: none; background: var(--panel-2);
}
.field input:focus { border-color: var(--accent); background: #fff; }
.join-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn {
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-2); color: var(--text); font-size: 14px;
  cursor: pointer; transition: all .15s; flex: 1;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; flex: 1.3; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #fff; }
.btn-mini { padding: 6px 10px; font-size: 12px; flex: 0 0 auto; }
.btn-danger { background: var(--red-soft); border-color: #fca5a5; color: var(--red); }
.btn-danger:hover { background: #fee2e2; }

.meeting-info {
  background: var(--accent-soft); border: 1px solid #bfdbfe; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 14px; font-size: 13px; color: #1e40af;
}
.role-banner {
  background: var(--amber-soft); border: 1px solid #fde68a; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 14px; font-size: 13px; color: #92400e;
}
.error { color: var(--red); background: var(--red-soft); border: 1px solid #fecaca; border-radius: 8px; padding: 10px 12px; margin-top: 12px; font-size: 13px; }

/* share panel */
.share-panel { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.share-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.share-tab { padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 13px; }
.share-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.share-item { margin-top: 6px; }
.share-item input { width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; color: var(--text-2); }
#share-link { display: flex; gap: 8px; align-items: center; }
#qr-box { text-align: center; }
#qr-box canvas, #qr-box img { border: 1px solid var(--border); border-radius: 8px; }
.big-code { font-size: 34px; font-weight: 800; letter-spacing: 8px; text-align: center; padding: 10px; color: var(--accent); }

/* ---------- Room view ---------- */
#room-view { flex-direction: column; padding: 0; height: 100vh; display: flex; }
.room-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.rh-left { display: flex; align-items: center; gap: 8px; }
.rh-right { display: flex; align-items: center; gap: 8px; }
.room-title { font-weight: 700; font-size: 15px; }
.chip { padding: 4px 10px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.chip-role { background: var(--accent-soft); color: #1d4ed8; border-color: #bfdbfe; font-weight: 600; }
.conn-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.conn-dot.on { background: var(--green); }
.conn-dot.off { background: #cbd5e1; }

.room-main { flex: 1; display: flex; overflow: hidden; }
.stage { flex: 1; position: relative; display: flex; flex-direction: column; padding: 10px; gap: 8px; background: #0f172a; }
.main-tile { flex: 1; background: #1e293b; border-radius: 10px; position: relative; overflow: hidden; }
.main-tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.filmstrip { display: flex; gap: 8px; overflow-x: auto; height: 120px; flex: 0 0 auto; }
.filmstrip .tile { width: 160px; flex: 0 0 160px; background: #1e293b; border-radius: 8px; position: relative; overflow: hidden; }
.filmstrip video { width: 100%; height: 100%; object-fit: cover; }
.stage-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #94a3b8; }

.tile { position: relative; }
.tile .tile-label {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff;
  padding: 3px 8px; border-radius: 6px; font-size: 12px; z-index: 3; max-width: calc(100% - 16px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile .tile-badges { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; z-index: 3; }
.tile .badge { background: rgba(0,0,0,.55); color: #fff; border-radius: 4px; padding: 2px 5px; font-size: 11px; }
.tile .mic-off-badge { position: absolute; left: 8px; top: 8px; z-index: 3; }

/* sidebar */
.sidebar { width: 320px; flex: 0 0 320px; background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.side-tabs { display: flex; border-bottom: 1px solid var(--border); }
.side-tab { flex: 1; padding: 12px; border: none; background: transparent; cursor: pointer; font-size: 14px; color: var(--text-2); border-bottom: 2px solid transparent; }
.side-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.side-body { flex: 1; overflow-y: auto; }
.side-panel { padding: 12px; }
.side-note { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filter { cursor: pointer; }
.filter.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.people-list { list-style: none; }
.people-list li {
  display: flex; align-items: center; gap: 8px; padding: 9px 8px; border-bottom: 1px solid var(--border);
}
.people-list li:last-child { border-bottom: none; }
.p-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: #1d4ed8; font-weight: 700; flex: 0 0 auto;
}
.p-info { flex: 1; min-width: 0; }
.p-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-sub { font-size: 11px; color: var(--text-2); display: flex; gap: 4px; flex-wrap: wrap; }
.p-actions { display: flex; gap: 4px; }
.p-actions button { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 4px 6px; cursor: pointer; font-size: 12px; }
.p-actions button:hover { background: var(--panel-2); }
.tag { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text-2); }
.tag.admin { background: var(--purple); color: #fff; border-color: var(--purple); }
.tag.host { background: var(--accent); color: #fff; border-color: var(--accent); }
.tag.cohost { background: var(--accent-soft); color: #1d4ed8; }
.tag.speaker { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.tag.questioner { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }

/* control bar */
.control-bar { padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: center; position: relative; }
.controls { display: flex; gap: 12px; }
.ctl {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--panel-2); font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.ctl:hover { background: var(--border); }
.ctl.off { background: var(--red-soft); border-color: #fca5a5; }
.ctl.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.toast {
  position: absolute; top: -50px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; z-index: 100;
}

/* modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-box { background: var(--panel); border-radius: var(--radius); width: 380px; max-width: 92vw; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-body { padding: 16px; }
.modal-body .share-item input { margin-bottom: 8px; }
.m-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.m-row input { flex: 1; }

/* responsive: mobile */
@media (max-width: 720px) {
  .sidebar { position: fixed; right: 0; top: 0; bottom: 0; width: 86vw; max-width: 340px; z-index: 50; box-shadow: -4px 0 16px rgba(0,0,0,.15); }
  .filmstrip .tile { width: 110px; flex-basis: 110px; }
  .ctl { width: 46px; height: 46px; }
}
