:root {
  --bg: #101218;
  --shell: #1a1e29;
  --panel-2: #242a38;
  --line: #2e3546;
  --text: #f3eee6;
  --muted: #8b93a7;
  --accent: #e8b86d;
  --accent-2: #8ec0ff;
  --good: #3dd68c;
  --bad: #f07178;
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Outfit, system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.shell {
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 560px;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #1a1208;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.14em;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
}

.dot[data-state="connecting"] {
  background: var(--accent);
  animation: pulse 1.2s infinite;
}

.dot[data-state="online"] {
  background: var(--good);
}

.dot[data-state="offline"] {
  background: var(--bad);
}

.identity {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.id-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
}

.id-label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.id-value {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--accent);
  font-size: 1rem;
}

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 320px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.panel,
.stage {
  min-height: 0;
  padding: 16px;
}

.people-panel {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.chat-panel {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.stage {
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.pill {
  font-size: 0.72rem;
  color: var(--accent);
  background: rgba(232, 184, 109, 0.12);
  border-radius: 999px;
  padding: 3px 8px;
}

.people-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.people-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border-radius: 12px;
  padding: 10px 12px;
}

.people-list .empty {
  display: block;
  text-align: left;
  color: var(--muted);
  background: transparent;
  padding: 8px 0;
}

.people-list .name {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--accent-2);
}

.idle {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
}

.idle-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  color: var(--text);
}

.idle-copy {
  margin: 0;
  max-width: 28ch;
  line-height: 1.45;
}

.video-stage {
  display: none;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.remote-wrap {
  position: relative;
  background: #0d1018;
  flex: 1;
  min-height: 240px;
  border-radius: 14px;
  overflow: hidden;
}

.remote-wrap video,
.pip video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #151922;
}

.badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.62);
  color: white;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 999px;
}

.pip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 28%;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.pip-badge {
  display: none;
  top: 8px;
  bottom: auto;
}

.call-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-btn,
.btn {
  border: 0;
  cursor: pointer;
  color: var(--text);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel-2);
}

.icon-btn:hover,
.btn.ghost:hover {
  background: #32384c;
}

.icon-btn.disabled {
  background: #5a2430;
}

.btn {
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--panel-2);
}

.btn.sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn.primary {
  background: var(--accent);
  color: #1a1208;
  font-weight: 600;
}

.btn.accept {
  background: var(--good);
  color: #062414;
  font-weight: 600;
}

.btn.danger {
  background: var(--bad);
  color: white;
  font-weight: 600;
}

#hangupBtn.btn.hangup {
  display: none;
  background: var(--bad);
  color: white;
  font-weight: 600;
  width: 100%;
  margin-bottom: 10px;
}

#playAudioBtn {
  display: none;
  width: 100%;
  margin-top: 10px;
}

.stats {
  display: none;
  margin-top: 12px;
  background: var(--panel-2);
  border-radius: 14px;
  padding: 14px;
}

.stats-row,
.stats-grid {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

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

.stats span {
  color: var(--muted);
  font-size: 0.8rem;
}

.stats strong {
  font-size: 0.9rem;
}

.meter {
  height: 8px;
  background: #334155;
  border-radius: 99px;
  overflow: hidden;
  margin: 4px 0 10px;
}

#micLevel,
#speakerLevel {
  height: 100%;
  width: 0%;
  background: var(--accent-2);
}

#speakerLevel.speaker {
  background: var(--good);
}

.chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-log {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  background: #141824;
  border-radius: 12px;
  padding: 12px;
  font-size: 0.92rem;
}

.chat-line {
  margin-bottom: 8px;
  line-height: 1.35;
}

.chat-line .who {
  color: var(--accent);
  font-weight: 600;
  margin-right: 6px;
}

.chat-line.me .who {
  color: var(--accent-2);
}

.chat-line.sys {
  color: var(--muted);
  font-size: 0.85rem;
}

.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  padding: 11px 12px;
}

.log-wrap {
  margin-top: 12px;
  color: var(--muted);
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 16px;
}

#log {
  background: #0f172a;
  border-radius: 14px;
  padding: 12px;
  max-height: 180px;
  overflow: auto;
  font-size: 0.8rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-card {
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  min-width: min(90vw, 360px);
  text-align: center;
}

.modal-kicker {
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.modal-actions .btn {
  display: block;
  width: 120px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: var(--shell);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  z-index: 60;
}

.mobile-only {
  display: none;
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

@media (max-width: 980px) {
  .shell {
    min-height: 0;
  }

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

  .people-panel,
  .chat-panel {
    border: 0;
    border-top: 1px solid var(--line);
  }

  .stage {
    min-height: 220px;
  }

  .mobile-only {
    display: inline-flex;
  }
}
