:root {
  --bg: #020617;
  --bg-soft: #0f172a;
  --bg-panel: #111827;
  --line: rgba(148, 163, 184, 0.2);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #0ea5e9;
  --primary-strong: #0284c7;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 16px;
  --shadow: 0 20px 45px -30px rgba(2, 6, 23, 0.85);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 0% 0%, rgba(14, 165, 233, 0.24) 0%, rgba(14, 165, 233, 0) 35%),
    radial-gradient(circle at 100% 100%, rgba(22, 163, 74, 0.18) 0%, rgba(22, 163, 74, 0) 25%),
    var(--bg);
  color: var(--text);
  font: 500 16px/1.45 "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

a {
  color: inherit;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.btn {
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  min-height: 44px;
}

.btn:hover,
.btn:focus-visible {
  border-color: rgba(14, 165, 233, 0.65);
  background: rgba(30, 41, 59, 0.95);
}

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

.btn-primary {
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-strong) 100%);
  border-color: rgba(56, 189, 248, 0.8);
  color: #f8fafc;
}

.btn-danger {
  border-color: rgba(220, 38, 38, 0.5);
  background: rgba(127, 29, 29, 0.35);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.7);
}

.badge-warn {
  border-color: rgba(217, 119, 6, 0.45);
  background: rgba(146, 64, 14, 0.32);
}

.badge-ok {
  border-color: rgba(22, 163, 74, 0.45);
  background: rgba(22, 101, 52, 0.28);
}

.landing-page {
  display: grid;
  place-items: center;
  padding: max(2rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom));
}

.landing {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1.25rem;
}

.landing-main,
.landing-side {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: rgba(2, 6, 23, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.landing-main {
  padding: clamp(1.2rem, 3vw, 2.2rem);
}

.landing-main h1 {
  margin: 0.3rem 0 0.8rem;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.lead {
  color: #cbd5e1;
  max-width: 38ch;
}

.landing-side {
  padding: 1.2rem;
}

.landing-actions {
  margin: 1.25rem 0 1rem;
  display: grid;
  gap: 0.9rem;
  width: min(100%, 36rem);
}

.join-form {
  display: grid;
  gap: 0.45rem;
}

.join-row {
  display: flex;
  gap: 0.55rem;
}

input,
select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.76);
  color: var(--text);
  padding: 0.68rem 0.8rem;
  font: inherit;
  min-height: 44px;
}

input::placeholder {
  color: #64748b;
}

input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(14, 165, 233, 0.6);
  outline-offset: 2px;
}

.bullet-inline {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  color: #94a3b8;
  font-size: 0.9rem;
}

.status-text {
  min-height: 1.2em;
  color: #fda4af;
}

.room-page {
  padding: max(0.7rem, env(safe-area-inset-top)) 0 max(0.8rem, env(safe-area-inset-bottom));
}

.app-shell {
  width: min(1800px, 100%);
  margin: 0 auto;
  padding: 0 0.8rem;
  display: grid;
  gap: 0.65rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.25rem 0.15rem 0.65rem;
}

.topbar h1 {
  margin: 0.15rem 0 0;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  letter-spacing: 0.01em;
  word-break: break-word;
}

.topbar-actions {
  display: flex;
  gap: 0.55rem;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.workspace {
  min-height: min(74vh, 900px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 340px);
  gap: 0.75rem;
}

.stage,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 6, 23, 0.8);
  box-shadow: var(--shadow);
}

.stage {
  position: relative;
  overflow: hidden;
  min-height: 330px;
}

.video-grid {
  height: 100%;
  width: 100%;
  padding: 0.65rem;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-content: start;
}

.video-tile {
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  overflow: hidden;
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  min-height: 160px;
  aspect-ratio: 16 / 9;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #020617;
}

.video-tile.speaking {
  border-color: rgba(14, 165, 233, 0.85);
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.7), 0 0 35px rgba(14, 165, 233, 0.25);
}

.video-meta {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: 0.45rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.68);
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
}

.video-flags {
  color: #cbd5e1;
  display: inline-flex;
  gap: 0.35rem;
}

.sidebar {
  display: grid;
  gap: 0.65rem;
  min-height: 0;
}

.panel {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel h2 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.participant-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
  max-height: 26vh;
  overflow: auto;
}

.participant-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  font-size: 0.86rem;
}

.chat-panel {
  min-height: 0;
}

.chat-messages {
  flex: 1;
  min-height: 160px;
  max-height: 45vh;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 0.45rem;
  padding-right: 0.2rem;
}

.chat-line {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.4rem 0.55rem;
  background: rgba(15, 23, 42, 0.72);
  font-size: 0.85rem;
}

.chat-line b {
  font-size: 0.8rem;
  color: #7dd3fc;
  display: block;
  margin-bottom: 0.15rem;
}

.chat-form {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.5rem;
}

.controlbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) repeat(2, minmax(160px, 1fr));
  gap: 0.45rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 6, 23, 0.82);
  box-shadow: var(--shadow);
  padding: 0.6rem;
  position: sticky;
  bottom: 0.35rem;
}

.control[aria-pressed="true"] {
  border-color: rgba(14, 165, 233, 0.78);
  background: rgba(14, 116, 144, 0.45);
}

.select {
  min-width: 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.92);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.modal-card form {
  display: grid;
  gap: 0.55rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(180%);
  background: rgba(2, 6, 23, 0.94);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.86rem;
  transition: transform 0.2s ease;
  z-index: 100;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1080px) {
  .landing {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: 0;
  }

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

  .participant-list {
    max-height: 30vh;
  }

  .controlbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .join-row,
  .chat-form {
    width: 100%;
  }

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

  .video-grid {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  }

  .controlbar {
    position: fixed;
    left: 0.55rem;
    right: 0.55rem;
    bottom: max(0.55rem, env(safe-area-inset-bottom));
    z-index: 20;
  }

  .app-shell {
    padding-bottom: 9.2rem;
  }
}
