:root {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #111827;
  --surface-strong: #1f2937;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #14b8a6;
  --accent-strong: #22c55e;
  --warn: #f97316;
  --danger: #ef4444;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.18), transparent 34%),
    linear-gradient(225deg, rgba(249, 115, 22, 0.12), transparent 30%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(960px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 16px;
}

.topbar,
.panel,
.call-surface {
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.topbar {
  min-height: 76px;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.1rem;
  font-weight: 760;
}

.brand p,
.eyebrow,
.peer-state,
label span {
  color: var(--muted);
  font-size: 0.85rem;
}

.status-pill {
  border: 1px solid rgba(20, 184, 166, 0.46);
  border-radius: 999px;
  padding: 8px 10px;
  color: #a7f3d0;
  background: rgba(20, 184, 166, 0.12);
  font-size: 0.78rem;
  white-space: nowrap;
}

.panel {
  border-radius: 8px;
  padding: 14px;
}

.setup-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto auto auto;
  align-items: end;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

.checkbox-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.82);
  outline: none;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18);
}

button {
  min-height: 44px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 6px;
  padding: 0 16px;
  color: var(--text);
  background: rgba(30, 41, 59, 0.9);
  cursor: pointer;
}

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

.primary-button {
  border-color: rgba(20, 184, 166, 0.5);
  background: linear-gradient(135deg, #0f766e, #16a34a);
}

.danger-button {
  border-color: rgba(239, 68, 68, 0.44);
  background: rgba(127, 29, 29, 0.66);
}

.rooms-panel {
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rooms-header h2 {
  font-size: 0.98rem;
  font-weight: 760;
}

.room-list {
  display: grid;
  gap: 8px;
}

.room-row {
  min-height: 52px;
  width: 100%;
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.room-row.selected {
  border-color: rgba(20, 184, 166, 0.62);
  background: rgba(15, 118, 110, 0.34);
}

.room-name {
  font-weight: 720;
  overflow-wrap: anywhere;
}

.room-count,
.room-empty {
  color: var(--muted);
  font-size: 0.86rem;
}

.call-surface {
  border-radius: 8px;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto;
  gap: 18px;
  min-height: 360px;
}

.call-meter {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pulse {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(20, 184, 166, 0.4);
  background:
    radial-gradient(circle at center, rgba(34, 197, 94, 0.9) 0 21%, transparent 22%),
    radial-gradient(circle at center, rgba(20, 184, 166, 0.2), rgba(15, 23, 42, 0.1));
}

.pulse.live {
  animation: breathe 1.8s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.26);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 13px rgba(20, 184, 166, 0);
  }
}

.call-meter h2 {
  margin-top: 3px;
  font-size: clamp(1.6rem, 6vw, 3.5rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.peer-list {
  align-content: start;
  display: grid;
  gap: 10px;
}

.peer {
  min-height: 64px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(17, 24, 39, 0.72);
}

.peer-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.peer-badge {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--warn);
}

.peer.connected .peer-badge {
  background: var(--accent-strong);
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.chat-panel {
  min-height: 180px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.48);
}

.chat-header {
  min-height: 44px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-header h3 {
  margin: 0;
  font-size: 0.96rem;
}

.chat-header span,
.chat-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.chat-messages {
  min-height: 0;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.chat-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-message {
  max-width: min(78%, 520px);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(30, 41, 59, 0.82);
}

.chat-message.own {
  justify-self: end;
  border-color: rgba(20, 184, 166, 0.32);
  background: rgba(15, 118, 110, 0.34);
}

.chat-text {
  margin-top: 3px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-form {
  padding: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

#audioMount {
  display: none;
}

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

  .topbar {
    align-items: flex-start;
  }

  .setup-panel {
    grid-template-columns: 1fr;
  }

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

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-message {
    max-width: 100%;
  }

  .status-pill {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
