/* ==========================================================
   PulseCall — Design Tokens
   Farbe:  #0B0E17 (Tiefsee-Navy), #121826 (Fläche),
           #4FE3C1 (Signal-Türkis), #FF6A4D (Live-Warm),
           #8B7FFF (Screen-Violett), #EAF0F6 (Text), #6B7688 (Muted)
   Typo:   Space Grotesk (Display), Inter (Fließtext), JetBrains Mono (Codes)
   ========================================================== */

:root{
  --bg: #0B0E17;
  --surface: #121826;
  --surface-2: #182033;
  --line: #232c40;
  --teal: #4FE3C1;
  --warm: #FF6A4D;
  --violet: #8B7FFF;
  --text: #EAF0F6;
  --muted: #6B7688;
  --shadow: 0 20px 60px -20px rgba(0,0,0,0.6);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#bg-canvas{
  position: fixed; inset:0; width:100%; height:100%;
  z-index:0; pointer-events:none;
}

.hidden{ display:none !important; }

.screen{
  position: relative; z-index:1;
  width:100%; height:100vh;
  display:flex; align-items:center; justify-content:center;
}

/* ---------------- Lobby ---------------- */

.lobby-card{
  width:min(480px, 92vw);
  text-align:center;
  padding: 40px 36px 32px;
}

.brand{
  display:flex; align-items:center; justify-content:center; gap:10px;
  margin-bottom: 36px;
}
.brand-mark{
  width:10px; height:10px; border-radius:50%;
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(79,227,193,0.6);
  animation: brand-pulse 2.4s ease-out infinite;
}
@keyframes brand-pulse{
  0%{ box-shadow: 0 0 0 0 rgba(79,227,193,0.55); }
  70%{ box-shadow: 0 0 0 10px rgba(79,227,193,0); }
  100%{ box-shadow: 0 0 0 0 rgba(79,227,193,0); }
}
.brand-name{
  font-family:'Space Grotesk', sans-serif;
  font-weight:600; letter-spacing:0.02em; font-size:15px;
  color: var(--muted); text-transform: uppercase;
}

.headline{
  font-family:'Space Grotesk', sans-serif;
  font-size: 40px; line-height:1.12; font-weight:700;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.sub{
  color: var(--muted); font-size:15px; line-height:1.6;
  max-width: 380px; margin: 0 auto 30px;
}

.orb-wrap{
  position:relative; width:150px; height:150px;
  margin: 0 auto 34px;
  display:flex; align-items:center; justify-content:center;
}
.orb-core{
  width:52px; height:52px; border-radius:50%;
  background: radial-gradient(circle at 35% 30%, #7ff4dc, var(--teal) 60%, #1b7a67 100%);
  box-shadow: 0 0 40px rgba(79,227,193,0.45);
  z-index:2;
}
.orb-ring{
  position:absolute; border-radius:50%;
  border: 1px solid rgba(79,227,193,0.35);
  animation: ring-expand 3.6s cubic-bezier(.2,.6,.3,1) infinite;
}
.orb-ring.r1{ width:70px; height:70px; animation-delay:0s; }
.orb-ring.r2{ width:70px; height:70px; animation-delay:1.2s; }
.orb-ring.r3{ width:70px; height:70px; animation-delay:2.4s; }
@keyframes ring-expand{
  0%{ width:70px; height:70px; opacity:0.9; border-color: rgba(79,227,193,0.55); }
  100%{ width:190px; height:190px; opacity:0; border-color: rgba(79,227,193,0); }
}

.mic-gate{
  margin: 0 0 22px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.mic-gate-row{
  display:flex; align-items:center; justify-content:center; gap:10px;
  font-size: 13.5px; color: var(--muted);
}
.mic-gate-dot{
  width:9px; height:9px; border-radius:50%;
  background: var(--warm);
  flex-shrink:0;
  animation: brand-pulse 1.6s infinite;
}
.mic-gate-dot.granted{
  background: var(--teal);
  animation: none;
  box-shadow: 0 0 0 4px rgba(79,227,193,0.18);
}
.mic-gate-dot.denied{
  background: var(--warm);
  animation: none;
}
.ghost-btn-wide{
  margin-top: 10px;
  width:100%;
  padding: 10px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--warm);
  color: var(--warm);
  font-size: 13px; font-weight:600;
  cursor:pointer;
  transition: background .2s ease;
}
.ghost-btn-wide:hover{ background: rgba(255,106,77,0.1); }

.room-controls{ margin-bottom: 22px; }
.room-label{
  display:block; font-size:11px; letter-spacing:0.14em;
  color: var(--muted); margin-bottom:8px; font-weight:600;
}
.room-input-row{
  display:flex; gap:8px; margin-bottom:14px;
}
#room-input{
  flex:1;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-family:'JetBrains Mono', monospace;
  font-size: 22px; letter-spacing: 0.24em; text-align:center;
  text-transform: uppercase;
  padding: 14px 10px;
  border-radius: 12px;
  outline:none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
#room-input:focus{
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(79,227,193,0.15);
}
.ghost-btn{
  width:52px; border-radius:12px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size:18px; cursor:pointer;
  transition: transform .3s ease, color .2s ease, border-color .2s ease;
}
.ghost-btn:hover{ color: var(--teal); border-color: var(--teal); transform: rotate(120deg); }

.primary-btn{
  width:100%;
  padding: 15px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--teal), #2fb59b);
  color: #062822;
  font-family:'Space Grotesk', sans-serif;
  font-weight:600; font-size:15.5px;
  cursor:pointer;
  transition: transform .15s ease, box-shadow .2s ease;
  box-shadow: 0 12px 30px -10px rgba(79,227,193,0.5);
}
.primary-btn:hover{ transform: translateY(-2px); box-shadow: 0 16px 34px -8px rgba(79,227,193,0.6); }
.primary-btn:active{ transform: translateY(0); }
.primary-btn:disabled{ opacity:0.5; cursor:not-allowed; transform:none; }

.status-line{
  min-height: 18px; font-size:13px; color: var(--warm); margin: 12px 0 0;
}

.hint{ font-size:12.5px; color: var(--muted); line-height:1.6; max-width:360px; margin: 0 auto; }

/* ---------------- Call Screen ---------------- */

#call-screen{
  padding: 0;
  display: grid;
  grid-template-columns: 240px 1fr;
  align-items: stretch;
  justify-content: stretch;
}

.name-input{
  width:100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-family:'Inter', sans-serif;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 12px;
  outline:none;
  margin-bottom: 16px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.name-input:focus{
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(79,227,193,0.15);
}

/* Discord-style member sidebar */
.member-sidebar{
  background: var(--surface);
  border-right: 1px solid var(--line);
  display:flex;
  flex-direction:column;
  height:100vh;
  overflow:hidden;
  z-index: 4;
}
.sidebar-header{
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.sidebar-title{
  display:block;
  font-family:'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight:600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}
.member-count{
  font-size: 12px;
  color: var(--teal);
  font-weight: 500;
}
.member-list{
  list-style:none;
  margin:0;
  padding: 10px 8px;
  overflow-y: auto;
  flex:1;
}
.member-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 2px;
  transition: background .15s ease;
}
.member-item:hover{ background: rgba(255,255,255,0.04); }
.member-item.self{ background: rgba(79,227,193,0.06); }
.member-item.connected .member-name{ color: var(--text); }

.member-avatar{
  width:32px; height:32px;
  border-radius:50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display:flex; align-items:center; justify-content:center;
  font-family:'Space Grotesk', sans-serif;
  font-size: 14px; font-weight:600;
  color: var(--teal);
  flex-shrink:0;
}
.member-info{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
}
.member-name{
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.you-tag{
  font-size: 11px;
  color: var(--teal);
  font-weight: 400;
}
.member-status{
  font-size: 11px;
  color: var(--muted);
  opacity: 0.75;
}
.member-dot{
  width:8px; height:8px;
  border-radius:50%;
  flex-shrink:0;
}
.member-dot.online{
  background: var(--teal);
  box-shadow: 0 0 6px rgba(79,227,193,0.5);
}
.member-dot.pending{
  background: var(--warm);
  animation: brand-pulse 1.5s infinite;
}

.remote-audio-container{
  position:absolute;
  width:0; height:0;
  overflow:hidden;
  pointer-events:none;
}

.stage{
  position:relative;
  width:100%; height:100vh;
  background: #05070c;
  overflow:hidden;
}

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

.stage.video-active #remote-video{
  opacity: 0.35;
  filter: blur(2px) saturate(0.8);
}

/* ---------- Live Chat (center) ---------- */
.chat-panel{
  position:absolute;
  left:50%;
  top:50%;
  transform: translate(-50%, -50%);
  width: min(540px, calc(100% - 48px));
  height: min(520px, calc(100vh - 200px));
  display:flex;
  flex-direction:column;
  background: rgba(18, 24, 38, 0.82);
  border: 1px solid rgba(79, 227, 193, 0.18);
  border-radius: 20px;
  backdrop-filter: blur(20px);
  box-shadow:
    0 24px 80px -20px rgba(0,0,0,0.7),
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 0 40px -10px rgba(79,227,193,0.12);
  z-index: 4;
  overflow:hidden;
  transition: width .3s ease, height .3s ease, transform .3s ease, bottom .3s ease, top .3s ease;
}

.stage.video-active .chat-panel{
  top: auto;
  bottom: 100px;
  transform: translateX(-50%);
  width: min(480px, calc(100% - 32px));
  height: min(320px, 42vh);
}

.chat-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink:0;
}
.chat-header-left{
  display:flex;
  align-items:center;
  gap:10px;
}
.chat-title{
  font-family:'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight:600;
  letter-spacing: 0.02em;
}
.chat-live-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size: 11px;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.08em;
  color: var(--teal);
  background: rgba(79,227,193,0.1);
  border: 1px solid rgba(79,227,193,0.25);
  padding: 3px 9px;
  border-radius: 999px;
}
.chat-live-dot{
  width:6px; height:6px;
  border-radius:50%;
  background: var(--teal);
  box-shadow: 0 0 8px rgba(79,227,193,0.8);
  animation: brand-pulse 1.8s ease-out infinite;
}
.chat-status{
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.chat-status #waiting-room-code{
  font-family:'JetBrains Mono', monospace;
  color: var(--teal);
  letter-spacing:0.1em;
}

.chat-messages{
  flex:1;
  overflow-y:auto;
  padding: 14px 16px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar{ width:6px; }
.chat-messages::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
}

.chat-welcome{
  margin:auto;
  text-align:center;
  color: var(--muted);
  padding: 20px 12px;
}
.chat-welcome-icon{
  display:block;
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.8;
}
.chat-welcome p{
  margin:0;
  font-size: 13.5px;
  line-height:1.55;
  max-width: 280px;
}

.chat-msg{
  display:flex;
  align-items:flex-start;
  gap:10px;
  max-width: 92%;
}
.chat-msg.self{
  flex-direction: row-reverse;
  align-self: flex-end;
}
.chat-msg.system{
  align-self:center;
  max-width:100%;
  justify-content:center;
}
.chat-msg-in{
  animation: chat-in .28s ease;
}
@keyframes chat-in{
  from{ opacity:0; transform: translateY(8px); }
  to{ opacity:1; transform: translateY(0); }
}

.chat-avatar{
  width:34px; height:34px;
  border-radius:50%;
  flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  font-family:'Space Grotesk', sans-serif;
  font-size: 14px; font-weight:600;
  color: var(--user-color);
  background: color-mix(in srgb, var(--user-color) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--user-color) 35%, transparent);
}
.chat-bubble{
  background: rgba(24, 32, 51, 0.9);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 9px 12px;
  min-width: 0;
}
.chat-msg.self .chat-bubble{
  background: rgba(79, 227, 193, 0.1);
  border-color: rgba(79, 227, 193, 0.22);
}
.chat-meta{
  display:flex;
  align-items:baseline;
  gap:8px;
  margin-bottom: 3px;
}
.chat-author{
  font-size: 12.5px;
  font-weight:600;
}
.chat-time{
  font-size: 10.5px;
  color: var(--muted);
  font-family:'JetBrains Mono', monospace;
}
.chat-text{
  margin:0;
  font-size: 14px;
  line-height:1.45;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-system-text{
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(255,255,255,0.08);
  padding: 5px 12px;
  border-radius: 999px;
}

.chat-input-row{
  display:flex;
  gap:8px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink:0;
}
#chat-input{
  flex:1;
  background: rgba(11, 14, 23, 0.7);
  border: 1px solid var(--line);
  color: var(--text);
  font-family:'Inter', sans-serif;
  font-size: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  outline:none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
#chat-input:focus{
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(79,227,193,0.12);
}
#chat-input::placeholder{ color: var(--muted); }
#chat-send-btn{
  width:46px; height:46px;
  border-radius:12px;
  border:none;
  background: linear-gradient(135deg, var(--teal), #2fb59b);
  color:#062822;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
  transition: transform .15s ease, box-shadow .2s ease;
  box-shadow: 0 8px 20px -8px rgba(79,227,193,0.5);
}
#chat-send-btn:hover{ transform: translateY(-1px); }
#chat-send-btn:active{ transform: translateY(0); }
#chat-send-btn .icon{
  width:18px; height:18px;
  fill:none; stroke:currentColor; stroke-width:2;
}

.pip-wrap{
  position:absolute; top:20px; left:20px;
  width: 200px; aspect-ratio: 16/10;
  border-radius: 16px; overflow:hidden;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow);
  background: var(--surface-2);
  cursor: grab;
  z-index: 5;
}
#local-video{ width:100%; height:100%; object-fit:cover; }
.pip-label{
  position:absolute; bottom:6px; left:8px;
  font-size:11px; color:#fff; background: rgba(0,0,0,0.45);
  padding: 2px 8px; border-radius:20px; font-weight:500;
  backdrop-filter: blur(4px);
}

.local-mic-chip{
  position:absolute; top:20px; right:20px;
  display:flex; align-items:center; gap:9px;
  background: rgba(18,24,38,0.75);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px; border-radius: 999px;
  font-size:13px; font-weight:500;
  backdrop-filter: blur(10px);
  z-index: 5;
}
.mic-chip-dot{
  width:8px; height:8px; border-radius:50%; background: var(--teal);
  animation: brand-pulse 2s infinite;
}
.mic-chip-dot.muted{ background: var(--warm); animation:none; }

.badge{
  position:absolute; top:20px; left:20px;
  display:flex; align-items:center; gap:8px;
  background: rgba(139,127,255,0.15);
  border: 1px solid rgba(139,127,255,0.4);
  color: #cfc9ff;
  padding: 8px 14px; border-radius: 999px;
  font-size:13px; font-weight:500;
  backdrop-filter: blur(6px);
}
.badge .dot{
  width:7px; height:7px; border-radius:50%; background: var(--violet);
  animation: brand-pulse 1.8s infinite;
}

#wave-canvas{
  position:absolute; bottom:110px; left:0; right:0;
  height: 60px; width:100%;
  pointer-events:none;
  opacity: 0.85;
}

.control-dock{
  position:absolute; bottom: 26px; left:50%; transform: translateX(-50%);
  display:flex; align-items:center; gap: 18px;
  background: rgba(18,24,38,0.75);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(16px);
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 6;
}

.room-chip{
  display:flex; align-items:center; gap:8px;
  font-family:'JetBrains Mono', monospace;
  font-size: 13px; color: var(--muted);
  letter-spacing: 0.1em;
  padding-right: 14px;
  border-right: 1px solid var(--line);
}
.room-chip-dot{
  width:7px; height:7px; border-radius:50%; background: var(--teal);
}

.controls{ display:flex; align-items:center; gap:10px; }

.ctrl-btn{
  width: 50px; height:50px;
  border-radius:50%;
  border:none;
  background: var(--surface-2);
  color: var(--text);
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: background .2s ease, transform .15s ease;
}
.ctrl-btn:hover{ background: #232d47; transform: translateY(-2px); }
.ctrl-btn.active{ background: var(--teal); color:#06231d; }
.ctrl-btn.muted-state{ background: var(--warm); color:#2a0e07; }
.ctrl-btn.hangup{ background: var(--warm); color:#2a0e07; }
.ctrl-btn.hangup:hover{ background: #ff8266; }

.icon{ width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

.dock-spacer{ width:2px; }

.toast{
  position: fixed; top: 24px; left:50%; transform: translateX(-50%);
  background: var(--surface-2); border:1px solid var(--line);
  color: var(--text); padding: 12px 20px; border-radius: 12px;
  font-size: 13.5px; z-index: 50; box-shadow: var(--shadow);
  animation: toast-in .25s ease;
}
@keyframes toast-in{ from{ opacity:0; transform: translate(-50%, -10px);} to{ opacity:1; transform: translate(-50%,0);} }

@media (max-width: 720px){
  #call-screen{
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .member-sidebar{
    height: auto;
    max-height: 140px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .member-list{
    display:flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    padding: 8px;
  }
  .member-item{
    flex-shrink: 0;
    min-width: 140px;
    margin-bottom: 0;
  }
  .stage{ height: calc(100vh - 140px); }
  .chat-panel{
    width: calc(100% - 24px);
    height: calc(100% - 120px);
    top: 52%;
  }
  .stage.video-active .chat-panel{
    height: min(260px, 38vh);
    bottom: 88px;
  }
}

@media (max-width: 560px){
  .headline{ font-size: 30px; }
  .pip-wrap{ width: 110px; }
  .control-dock{ gap: 10px; padding: 10px 14px; }
  .ctrl-btn{ width:44px; height:44px; }
}

@media (prefers-reduced-motion: reduce){
  .brand-mark, .orb-ring, .badge .dot, .chat-live-dot, .chat-msg-in{ animation: none !important; }
}
