:root {
  color-scheme: dark;
  --ink: #f7f8ff;
  --muted: #a8adbd;
  --panel: #161922;
  --panel-soft: #1f2330;
  --line: rgba(255, 255, 255, 0.09);
  --violet: #7357ff;
  --violet-light: #a999ff;
  --green: #56d6a0;
  --red: #ff5d73;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 15%, rgba(115, 87, 255, 0.16), transparent 28rem),
    #0b0d13;
}

button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--violet-light), var(--violet));
  box-shadow: 0 8px 26px rgba(115, 87, 255, 0.3);
}

.brand-mark i {
  position: absolute;
  width: 12px;
  height: 7px;
  border: 2px solid white;
  border-radius: 8px;
  transform: rotate(-35deg);
}

.brand-mark i:first-child { translate: -4px 2px; }
.brand-mark i:last-child { translate: 4px -2px; }
.brand-mark.large { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 18px; }
.brand-mark.large i { width: 20px; height: 11px; }
.brand-mark.large i:first-child { translate: -7px 3px; }
.brand-mark.large i:last-child { translate: 7px -3px; }

.status-pill {
  color: var(--muted);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

.status-pill span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #f2aa5b;
  box-shadow: 0 0 10px currentColor;
}

.status-pill.online span { background: var(--green); }
.status-pill.error span { background: var(--red); }

.call-shell {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1px;
  background: var(--line);
}

.video-panel {
  position: relative;
  min-height: calc(100vh - 72px);
  overflow: hidden;
  background: #080a0e;
}

#remoteVideo {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 72px);
  object-fit: cover;
  display: block;
}

.waiting-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  padding: 30px;
  background:
    radial-gradient(circle at center, rgba(115, 87, 255, .18), transparent 34%),
    linear-gradient(145deg, #121520, #090b10);
}

.waiting-state.hidden { opacity: 0; pointer-events: none; transition: opacity .35s ease; }
.waiting-state h1 { margin: 20px 0 6px; font-size: clamp(26px, 3vw, 42px); letter-spacing: -.045em; }
.waiting-state p { color: var(--muted); margin: 0 0 24px; }

.pulse-avatar {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(115, 87, 255, .16);
  border: 1px solid rgba(169, 153, 255, .3);
  animation: pulse 2s infinite;
}

.pulse-avatar span {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, #c4b8ff, var(--violet));
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 18px rgba(115, 87, 255, 0); }
  0%, 100% { box-shadow: 0 0 0 2px rgba(115, 87, 255, .17); }
}

.primary-button {
  border: 0;
  color: white;
  font-weight: 700;
  padding: 13px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--violet-light), var(--violet));
  box-shadow: 0 10px 26px rgba(115, 87, 255, .3);
}

.primary-button:disabled { opacity: .55; cursor: wait; }

.remote-label,
.local-video-wrap span {
  position: absolute;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(7, 8, 12, .66);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 650;
}

.remote-label { left: 18px; top: 18px; }

.local-video-wrap {
  position: absolute;
  right: 20px;
  top: 20px;
  width: min(23vw, 220px);
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .18);
  background: #202431;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .4);
}

#localVideo { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.local-video-wrap span { left: 8px; bottom: 8px; }

.controls {
  position: absolute;
  left: 50%;
  bottom: 24px;
  translate: -50% 0;
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  background: rgba(12, 14, 20, .72);
  backdrop-filter: blur(18px);
}

.control-button {
  width: 62px;
  height: 56px;
  border: 0;
  color: var(--ink);
  background: rgba(255,255,255,.08);
  border-radius: 12px;
  display: grid;
  place-items: center;
  gap: 1px;
}

.control-button span { font-size: 19px; line-height: 1; }
.control-button small { font-size: 10px; color: var(--muted); }
.control-button:hover { background: rgba(255,255,255,.14); }
.control-button:disabled { opacity: .35; cursor: not-allowed; }
.control-button.off { color: var(--red); background: rgba(255, 93, 115, .12); }
.control-button.danger { background: var(--red); color: white; }
.control-button.danger small { color: white; }

.chat-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.chat-heading {
  height: 86px;
  padding: 19px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.eyebrow { margin: 0 0 3px; color: var(--violet-light); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.chat-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.03em; }
.private-badge { color: var(--muted); font-size: 11px; border: 1px solid var(--line); padding: 5px 8px; border-radius: 999px; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.system-message {
  align-self: center;
  max-width: 260px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
  padding: 8px 11px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
}

.message { max-width: 82%; }
.message.mine { align-self: flex-end; }
.message.theirs { align-self: flex-start; }
.message b { display: block; margin: 0 0 4px 4px; color: var(--muted); font-size: 10px; font-weight: 650; }
.message p { margin: 0; padding: 10px 12px; border-radius: 13px; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; background: var(--panel-soft); }
.message.mine p { background: var(--violet); }

.chat-form {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  min-width: 0;
  color: var(--ink);
  background: var(--panel-soft);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 13px;
  outline: none;
}

.chat-form input:focus { border-color: var(--violet); }
.chat-form button { border: 0; border-radius: 12px; color: white; background: var(--violet); font-size: 18px; }

.fatal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 8, 12, .88);
  backdrop-filter: blur(20px);
}

.fatal-overlay[hidden] { display: none; }
.fatal-card { max-width: 420px; text-align: center; }
.fatal-card h2 { margin: 0 0 8px; font-size: 28px; }
.fatal-card p { margin: 0; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
  .topbar { height: 60px; padding: 0 16px; }
  .call-shell { min-height: calc(100vh - 60px); grid-template-columns: 1fr; grid-template-rows: minmax(440px, 68vh) 360px; }
  .video-panel, #remoteVideo { min-height: 440px; }
  .local-video-wrap { width: 130px; }
  .chat-panel { min-height: 360px; }
}

