:root {
  --primary: #0e72ed;
  --primary-hover: #0c66d6;
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #252525;
  --text: #f0f0f0;
  --text2: #999;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-overflow-scrolling: none;
  overscroll-behavior: none;
}

input, textarea, button, select {
  font-family: inherit;
}

/* ===== Toast ===== */
#toast-container {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 99999; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: 90vw; width: 420px;
}

.toast {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 14px; line-height: 1.5; pointer-events: auto;
  animation: toastIn .25s ease, toastOut .25s ease 3.2s forwards;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  backdrop-filter: blur(8px);
}

.toast-icon { flex-shrink: 0; font-size: 18px; line-height: 1.4; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; }
.toast-desc { color: rgba(255,255,255,.7); font-size: 12px; margin-top: 2px; }

.toast-success { background: rgba(34,197,94,.2); border: 1px solid rgba(34,197,94,.3); }
.toast-error { background: rgba(239,68,68,.2); border: 1px solid rgba(239,68,68,.3); }
.toast-warning { background: rgba(245,158,11,.2); border: 1px solid rgba(245,158,11,.3); }
.toast-info { background: rgba(14,114,237,.2); border: 1px solid rgba(14,114,237,.3); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px) scale(.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ===== Pre-join ===== */
#pre-join {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}

.join-card {
  width: 100%; max-width: 420px; padding: 32px 24px;
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,.06);
}

.join-card h2 { font-size: 20px; font-weight: 600; }
.join-card .subtitle { color: var(--text2); font-size: 13px; margin: 4px 0 20px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 4px; }

input, textarea, select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid transparent; font-size: 15px; outline: none;
  transition: border .15s; background: var(--surface2); color: var(--text);
}

input:focus, textarea:focus { border-color: var(--primary); }
input::placeholder, textarea::placeholder { color: #555; }
textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 10px 16px; border-radius: var(--radius);
  border: none; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s, opacity .15s;
  background: var(--primary); color: #fff; gap: 8px;
}

.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover { background: #333; }

.spinner-sm {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}

.btn .spinner-sm { border-top-color: #fff; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Device status ===== */
.device-status { margin-top: 16px; display: none; }
.device-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; font-size: 13px; color: var(--text2);
}
.device-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.device-dot.ok { background: var(--success); }
.device-dot.fail { background: var(--error); }
.device-dot.pending { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ===== Loading ===== */
.meeting-loading {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: none; flex-direction: column; align-items: center;
  justify-content: center; background: var(--bg); z-index: 100;
}

.spinner-lg {
  width: 40px; height: 40px;
  border: 3px solid var(--surface2); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}

.meeting-loading p { margin-top: 16px; color: var(--text2); font-size: 14px; }

/* ===== Meeting SDK ===== */
#meetingSDKElement {
  height: 100vh; width: 100vw; position: fixed; top: 0; left: 0; background: #000;
  display: none;
}

/* ===== Reconnect bar ===== */
#reconnectBar {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); backdrop-filter: blur(12px);
  padding: 10px 20px; border-radius: 12px; font-size: 13px;
  display: none; z-index: 9999; align-items: center; gap: 10px;
  border: 1px solid rgba(255,255,255,.08);
}

#reconnectBar .spinner-sm { border-top-color: #0e72ed; }
