:root {
  color-scheme: dark;
  --bg: #080b11;
  --panel: #111722;
  --panel-2: #17202e;
  --text: #f4f7fb;
  --muted: #9ca9bb;
  --border: rgba(255,255,255,.08);
  --accent: #6d7cff;
  --accent-2: #8b5cf6;
  --danger: #ef4444;
  --success: #22c55e;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(109,124,255,.18), transparent 30%),
    radial-gradient(circle at 90% 0%, rgba(139,92,246,.16), transparent 35%),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  padding: 24px;
}

button, input { font: inherit; }

.app-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.card {
  width: min(540px, 100%);
  background: rgba(17,23,34,.92);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  backdrop-filter: blur(20px);
}

.join-card { padding: 34px; }

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 30px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 30px rgba(109,124,255,.28);
}

h1 {
  font-size: 30px;
  margin: 0 0 4px;
}

.brand p, .hint {
  color: var(--muted);
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: #d9e0ea;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  outline: none;
  color: var(--text);
  background: #0d131c;
  border-radius: 14px;
  padding: 14px 15px;
  transition: .2s ease;
}

input:focus {
  border-color: rgba(109,124,255,.8);
  box-shadow: 0 0 0 3px rgba(109,124,255,.12);
}

.room-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.btn.secondary {
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.error {
  margin: 0;
  min-height: 20px;
  color: #ff8f8f;
}

.hidden { display: none !important; }

.call-layout {
  width: 100%;
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 14px;
}

.call-header, .call-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(17,23,34,.82);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 16px;
  color: var(--muted);
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #f59e0b;
  margin-right: 8px;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 16px rgba(34,197,94,.7);
}

.room-badge {
  font-size: 13px;
}

.video-stage {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  background: #030507;
  border: 1px solid var(--border);
  border-radius: 24px;
}

#remoteVideo {
  width: 100%;
  height: 100%;
  min-height: 560px;
  object-fit: cover;
  background: #030507;
}

.remote-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  place-items: center;
  gap: 14px;
  color: var(--muted);
}

.remote-placeholder .avatar {
  width: 88px;
  height: 88px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 38px;
}

.local-preview {
  position: absolute;
  right: 18px;
  top: 18px;
  width: min(240px, 28vw);
  aspect-ratio: 4 / 3;
  background: #111;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}

.local-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.local-preview span {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
}

.control-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.control {
  min-width: 82px;
  border: 1px solid var(--border);
  background: rgba(17,23,34,.92);
  color: var(--text);
  border-radius: 18px;
  padding: 10px 14px;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 4px;
}

.control:hover { background: var(--panel-2); }

.control.off {
  background: #3a2227;
}

.control.danger {
  background: var(--danger);
  border-color: transparent;
}

.control .icon { font-size: 20px; }
.control .label { font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(30px);
  opacity: 0;
  pointer-events: none;
  background: rgba(15,20,28,.95);
  border: 1px solid var(--border);
  color: white;
  padding: 11px 16px;
  border-radius: 12px;
  transition: .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  body { padding: 12px; }

  .app-shell { min-height: calc(100vh - 24px); }

  .join-card { padding: 22px; }

  .call-layout {
    min-height: calc(100vh - 24px);
  }

  .video-stage,
  #remoteVideo {
    min-height: 68vh;
  }

  .local-preview {
    width: 34vw;
    right: 12px;
    top: 12px;
  }

  .call-header {
    gap: 8px;
    align-items: flex-start;
    flex-direction: column;
  }

  .control {
    min-width: 64px;
    padding-inline: 10px;
  }
}
