:root {
  color-scheme: light dark;
  --bg: #f5f7fa;
  --bg-glow: #e8efff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #15202b;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #2f6fed;
  --brand-hover: #255cc9;
  --brand-weak: #eaf1ff;
  --success: #067647;
  --success-weak: #ecfdf3;
  --danger: #b42318;
  --danger-weak: #fef3f2;
  --radius: 16px;
  --shadow: 0 20px 60px rgb(16 24 40 / 10%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-glow: #14213d;
    --surface: #161b22;
    --surface-2: #1c232c;
    --text: #f0f3f6;
    --muted: #98a2b3;
    --line: #2a3038;
    --brand: #6b9bff;
    --brand-hover: #8bb4ff;
    --brand-weak: #17233d;
    --success: #75e0a7;
    --success-weak: #102a1e;
    --danger: #f97066;
    --danger-weak: #2a1515;
    --shadow: 0 24px 80px rgb(0 0 0 / 35%);
  }
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, var(--bg-glow), transparent 38%),
    radial-gradient(circle at 92% 0%, color-mix(in srgb, var(--brand-weak) 70%, transparent), transparent 34%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--brand); }
button, input { font: inherit; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 14px clamp(18px, 4vw, 48px);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #8bb4ff);
  color: #fff; font-size: 14px; font-weight: 800;
}
.topbar-spacer { flex: 1; }
.space-button, .user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); cursor: pointer;
}
.space-button:hover, .user-chip:hover { border-color: var(--brand); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--brand-weak); color: var(--brand);
  font-weight: 700; font-size: 12px; object-fit: cover;
}
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }

.shell { width: min(1120px, 100%); margin: 0 auto; padding: clamp(24px, 5vw, 56px) clamp(18px, 4vw, 32px) 64px; }
.hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  margin-bottom: 26px;
}
.hero h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 38px); letter-spacing: -.03em; }
.hero p { margin: 0; color: var(--muted); }
.primary, .secondary, .ghost, .danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 9px 16px; border-radius: 11px;
  border: 1px solid transparent; cursor: pointer; font-weight: 650;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.primary { background: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-hover); }
.primary:active, .secondary:active, .ghost:active { transform: translateY(1px); }
.primary:disabled, .secondary:disabled { opacity: .5; cursor: not-allowed; }
.secondary { background: var(--surface); border-color: var(--line); color: var(--text); }
.secondary:hover { border-color: var(--brand); }
.ghost { background: transparent; color: var(--muted); }
.ghost:hover { background: var(--surface-2); color: var(--text); }
.danger { background: var(--danger-weak); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

.meetings-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px;
}
.meeting-card {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 1px 2px rgb(16 24 40 / 3%);
}
.meeting-card:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.meeting-card h3 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.meeting-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--surface-2); color: var(--muted);
}
.badge.live { background: var(--success-weak); color: var(--success); }
.badge.host { background: var(--brand-weak); color: var(--brand); }
.meeting-actions { display: flex; gap: 8px; margin-top: auto; }
.empty {
  display: grid; place-items: center; gap: 10px; min-height: 240px;
  padding: 32px; border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); text-align: center; background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.empty strong { color: var(--text); font-size: 17px; }

.dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line); border-radius: 18px; padding: 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(9 12 18 / 55%); backdrop-filter: blur(4px); }
.dialog form { padding: 22px; display: grid; gap: 16px; }
.dialog h2 { margin: 0; font-size: 20px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select {
  width: 100%; min-height: 42px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--text); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 15px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px;
  box-shadow: var(--shadow); z-index: 100;
}
.toast.error { background: var(--danger); color: #fff; }

/* Room */
.room-body { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.room-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px clamp(14px, 3vw, 28px); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
}
.room-title { min-width: 0; }
.room-title h1 { margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-title p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.room-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 18%, transparent); }
.dot.warn { background: #f79009; }
.room-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stage {
  flex: 1; min-height: 0; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; align-content: center;
  padding: clamp(16px, 4vw, 40px);
}
.participant {
  min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 18px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); position: relative; overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.participant.speaking { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-weak); }
.participant.local { background: linear-gradient(180deg, var(--surface), var(--brand-weak)); }
.participant .avatar { width: 62px; height: 62px; font-size: 22px; }
.participant .name { font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participant .role { color: var(--muted); font-size: 12px; }
.mic-state {
  position: absolute; right: 10px; top: 10px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--danger-weak); color: var(--danger); font-size: 12px;
}
.room-footer {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px; border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.control {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.control:hover { border-color: var(--brand); }
.control.off { background: var(--danger-weak); color: var(--danger); border-color: transparent; }
.control.leave { width: auto; border-radius: 999px; padding: 0 18px; background: var(--danger); color: #fff; border: 0; font-weight: 650; }
.control.end { width: auto; border-radius: 999px; padding: 0 18px; background: var(--danger-weak); color: var(--danger); border-color: transparent; font-weight: 650; }
.control.invite { width: auto; border-radius: 999px; padding: 0 18px; background: var(--brand); color: #fff; border: 0; font-weight: 650; }
.control svg { width: 20px; height: 20px; }

@media (max-width: 720px) {
  .topbar { gap: 8px; padding: 10px 14px; }
  .brand span.brand-text { display: none; }
  .space-button .space-label { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-chip .user-name { display: none; }
  .hero { flex-direction: column; align-items: stretch; }
  .hero .primary { width: 100%; }
  .meetings-grid { grid-template-columns: 1fr; }
  .stage { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; padding: 14px; }
  .participant { min-height: 128px; }
  .participant .avatar { width: 52px; height: 52px; font-size: 18px; }
}
