:root {
  --bg: #0a0c10;
  --bg-raised: #12161d;
  --line: #232a35;
  --text: #e7ecf3;
  --muted: #8c97a8;
  --accent: #4f8cff;
  --ok: #3ecf8e;
  --warn: #f2b544;
  --bad: #ef5f5f;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 50% -10%, #162031 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  display: flex;
}

.screen {
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

/* Landing ---------------------------------------------------------- */

.gate {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card {
  width: min(460px, 100%);
  background: linear-gradient(180deg, #141924, #0f131a);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 40px 32px;
  box-shadow: var(--shadow);
  text-align: center;
}

.brand {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(79, 140, 255, 0.12);
  color: var(--accent);
}

h1 {
  margin: 0 0 8px;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0 0 24px;
  color: var(--muted);
}

.invite-preview {
  margin: 0 0 18px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

.primary {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 600;
  color: #06101f;
  background: var(--accent);
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease;
}

.primary:hover {
  filter: brightness(1.08);
}

.primary:active {
  transform: translateY(1px);
}

.primary:focus-visible,
.ctl:focus-visible,
.ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.hint {
  margin: 18px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Call ------------------------------------------------------------- */

.call {
  padding: 14px clamp(12px, 3vw, 28px) 20px;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 32px;
}

.spacer {
  flex: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: 0.82rem;
  color: var(--muted);
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pill[data-state="ok"] {
  color: var(--ok);
  border-color: rgba(62, 207, 142, 0.35);
}

.pill[data-state="busy"],
.pill[data-state="wait"] {
  color: var(--warn);
  border-color: rgba(242, 181, 68, 0.3);
}

.pill[data-state="warn"] {
  color: var(--warn);
}

.pill[data-state="bad"] {
  color: var(--bad);
  border-color: rgba(239, 95, 95, 0.35);
}

.ghost {
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}

.ghost:hover {
  border-color: #33405a;
}

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}

.tile {
  position: relative;
  background: #05070a;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 220px;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #05070a;
}

.tile-local video {
  transform: scaleX(-1);
}

.tile-label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 0.72rem;
  color: #cfd8e6;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(5, 7, 10, 0.72);
  color: var(--muted);
}

.placeholder-sub {
  font-size: 0.82rem;
  opacity: 0.75;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 900ms linear infinite;
}

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

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

.ctl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.ctl:hover {
  background: #171c25;
}

.ctl[aria-pressed="true"] {
  border-color: rgba(242, 181, 68, 0.5);
  color: var(--warn);
}

.ctl.danger {
  border-color: rgba(239, 95, 95, 0.35);
  color: var(--bad);
}

.ctl.danger:hover {
  background: rgba(239, 95, 95, 0.12);
}

.ctl-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.devices {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.devices label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.devices select {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  max-width: 220px;
}

/* Notice ----------------------------------------------------------- */

.notice {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.notice-card {
  width: min(440px, 100%);
  text-align: center;
  background: linear-gradient(180deg, #141924, #0f131a);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 30px;
  box-shadow: var(--shadow);
}

.notice-card h2 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}

.notice-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

/* Toast ------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 10px;
  background: #1b2230;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.86rem;
  box-shadow: var(--shadow);
  z-index: 10;
}

/* Small screens ---------------------------------------------------- */

@media (max-width: 860px) {
  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: 1.35fr 1fr;
  }

  .tile {
    min-height: 0;
  }

  .ctl-text {
    display: none;
  }

  .ctl {
    padding: 12px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}
