:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: rgba(18, 24, 38, 0.86);
  --panel-strong: rgba(22, 31, 49, 0.96);
  --text: #eef3ff;
  --muted: #9aa8c7;
  --line: rgba(255, 255, 255, 0.1);
  --danger: #d94f61;
  --ok: #62d99a;
  --warn: #ffd166;
  --accent: #7aa7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(91, 129, 255, 0.2), transparent 36rem),
    radial-gradient(circle at bottom right, rgba(65, 214, 168, 0.16), transparent 32rem),
    var(--bg);
  color: var(--text);
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.82rem 0.9rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.primary {
  background: linear-gradient(135deg, #5f86ff, #55d6ae);
  color: #051019;
}

.secondary {
  background: rgba(255, 255, 255, 0.1);
}

.secondary.active {
  color: #06101b;
  background: var(--accent);
}

.danger {
  background: rgba(217, 79, 97, 0.18);
  color: #ffb6c0;
}

.small {
  padding: 0.55rem 0.8rem;
  font-size: 0.82rem;
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.hero,
.prejoin,
.call {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 28px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.hero {
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 6vw, 78px);
}

.prejoin,
.call {
  min-height: calc(100vh - 80px);
  padding: 22px;
}

.hero h1,
.call h1,
.prejoin h1 {
  margin: 0.8rem 0 1rem;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

.prejoin h1,
.call-header h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.hero p,
.device-panel p {
  max-width: 690px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.badge {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.82rem;
  font-weight: 700;
}

.actions,
.controls,
.layout-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.stacked-actions {
  display: grid;
  grid-template-columns: 1fr;
}

.created-link {
  word-break: break-all;
  color: var(--accent) !important;
}

.hint {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.hidden {
  display: none !important;
}

.call-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 8px 20px;
}

.status-stack {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.status {
  border-radius: 999px;
  padding: 0.62rem 0.8rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 700;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warn);
}

.status.bad {
  color: #ffb6c0;
}

.prejoin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.device-panel,
.join-requests {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  background: var(--panel-strong);
}

.device-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.device-panel h2,
.join-requests h2 {
  margin: 0;
  font-size: 1.25rem;
}

.preview-card {
  min-height: min(62vh, 620px);
}

.videos {
  display: grid;
  gap: 16px;
  min-height: min(64vh, 690px);
}

.videos.layout-vertical {
  grid-template-columns: 1fr 1fr;
}

.videos.layout-horizontal {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
}

.video-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 24px;
  min-height: 280px;
}

.remote-card,
.local-card {
  min-height: inherit;
}

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

.video-label {
  position: absolute;
  left: 12px;
  top: 12px;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.empty-video {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  background: linear-gradient(135deg, rgba(122, 167, 255, 0.12), rgba(85, 214, 174, 0.08));
}

.controls {
  justify-content: center;
  margin-top: 20px;
}

.layout-controls {
  align-items: center;
  justify-content: flex-end;
  margin: 0 6px 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.join-requests {
  margin-bottom: 16px;
}

.join-request {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.join-request strong,
.join-request span {
  display: block;
}

.join-request span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.request-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  max-width: min(720px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  color: var(--text);
  background: rgba(10, 14, 24, 0.92);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.3);
  transition: all 0.18s ease;
  z-index: 10;
}

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

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 1200px);
    padding: 10px 0;
  }

  .hero,
  .prejoin,
  .call {
    min-height: calc(100vh - 20px);
    border-radius: 22px;
  }

  .prejoin,
  .call {
    padding: 14px;
  }

  .call-header {
    flex-direction: column;
  }

  .status-stack {
    justify-items: stretch;
    width: 100%;
  }

  .status {
    white-space: normal;
  }

  .prejoin-grid {
    grid-template-columns: 1fr;
  }

  .preview-card {
    min-height: 42vh;
  }

  .videos {
    min-height: 62vh;
  }

  .videos.layout-vertical {
    grid-template-columns: 1fr 1fr;
  }

  .videos.layout-horizontal {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .video-card {
    min-height: 220px;
    border-radius: 18px;
  }

  .controls button {
    flex: 1 1 160px;
  }

  .layout-controls {
    justify-content: flex-start;
  }

  .join-request {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .hero {
    padding: 26px;
  }

  .hero h1,
  .prejoin h1,
  .call h1 {
    letter-spacing: -0.04em;
  }

  .videos.layout-vertical {
    grid-template-columns: 1fr 1fr;
    min-height: 52vh;
  }

  .videos.layout-horizontal {
    min-height: 66vh;
  }

  .video-card {
    min-height: 190px;
  }

  .videos.layout-vertical .video-card {
    min-height: 52vh;
  }

  .controls,
  .layout-controls {
    gap: 8px;
  }

  button {
    padding: 0.78rem 0.92rem;
  }
}
