* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0a0a0a;
  --surface: #161618;
  --surface-2: #242428;
  --accent: #00d4aa;
  --accent-hot: #ff3b4e;
  --accent-warm: #ffb03b;
  --accent-watch: #8e7bff;
  --text: #f5f5f5;
  --text-dim: #8a8a90;
  --border: #2a2a2e;
}

html, body { height: 100%; overscroll-behavior: none; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse at top, rgba(0,212,170,0.08), transparent 50%),
    radial-gradient(ellipse at bottom, rgba(255,59,78,0.05), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

input, code { user-select: text; -webkit-user-select: text; }

.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.screen.active { display: flex; }

/* ----- LOGIN ----- */
#login {
  padding: 2rem 1.5rem;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2rem;
}
.logo-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.logo {
  font-size: 3.5rem;
  filter: drop-shadow(0 0 20px rgba(0,212,170,0.4));
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
#login h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.tagline { color: var(--text-dim); font-size: 0.9rem; font-weight: 500; }

.form {
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column;
}
.form label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 0.8rem 0 0.4rem; text-align: left;
}
.form input {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 0.95rem 1rem; border-radius: 12px;
  font-size: 1rem; transition: border-color 0.15s;
}
.form input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,212,170,0.15);
}

#joinBtn {
  background: var(--accent); color: #000; border: none;
  padding: 1rem; border-radius: 12px; font-size: 1rem;
  font-weight: 700; margin-top: 1.5rem; cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
#joinBtn:active { transform: scale(0.98); }
#joinBtn:disabled { background: var(--surface-2); color: var(--text-dim); cursor: wait; }

.hint {
  display: flex; gap: 0.6rem; align-items: flex-start;
  margin-top: 1.5rem; padding: 0.8rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-dim);
  font-size: 0.78rem; line-height: 1.4; text-align: left;
}
.lock-badge {
  background: rgba(0,212,170,0.15); color: var(--accent);
  padding: 0.2rem 0.5rem; border-radius: 6px;
  font-weight: 700; font-size: 0.72rem; flex-shrink: 0;
}

/* ----- INTERCOM ----- */
#intercom header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
  background: rgba(10,10,10,0.6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.room-info { display: flex; align-items: center; gap: 0.7rem; }
.status-dot {
  width: 10px; height: 10px; background: var(--accent);
  border-radius: 50%; box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s infinite;
}
.status-dot.offline { background: var(--text-dim); box-shadow: none; animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.room-name { font-weight: 600; font-size: 1rem; }
.peer-count { color: var(--text-dim); font-size: 0.78rem; margin-top: 2px; }

.icon-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); width: 40px; height: 40px;
  border-radius: 10px; font-size: 1.1rem; cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:active { background: var(--surface-2); }

.peers {
  flex: 1; overflow-y: auto; padding: 1rem 1.2rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.empty-peers {
  text-align: center; color: var(--text-dim);
  padding: 2rem 1rem; font-size: 0.9rem; line-height: 1.6;
}
.empty-peers small { display: block; margin-top: 0.4rem; font-size: 0.8rem; opacity: 0.7; }

.peer {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.75rem; background: var(--surface);
  border-radius: 12px; border: 2px solid transparent;
  transition: all 0.2s;
}
.peer.speaking {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(0,212,170,0.15), rgba(0,212,170,0.05));
  box-shadow: 0 0 20px rgba(0,212,170,0.2);
}

.peer-avatar {
  width: 42px; height: 42px; background: var(--surface-2);
  border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; color: var(--accent); font-size: 1.1rem; flex-shrink: 0;
}
.peer.speaking .peer-avatar {
  background: var(--accent); color: #000;
  animation: talkPulse 0.6s ease-in-out infinite;
}
@keyframes talkPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.peer-body { flex: 1; min-width: 0; }
.peer-name { font-weight: 600; font-size: 0.95rem; }
.peer-status { color: var(--text-dim); font-size: 0.78rem; margin-top: 2px; }

.peer-wave {
  display: flex; gap: 3px; align-items: center;
  height: 24px; opacity: 0; transition: opacity 0.2s;
}
.peer.speaking .peer-wave { opacity: 1; }
.peer-wave span {
  display: block; width: 3px; background: var(--accent);
  border-radius: 2px; animation: wave 0.9s ease-in-out infinite;
}
.peer-wave span:nth-child(1) { animation-delay: 0s; height: 12px; }
.peer-wave span:nth-child(2) { animation-delay: 0.15s; height: 20px; }
.peer-wave span:nth-child(3) { animation-delay: 0.3s; height: 14px; }
@keyframes wave { 0%, 100% { transform: scaleY(0.5); } 50% { transform: scaleY(1); } }

/* Crown next to leader name in peer list */
.peer-crown {
  font-size: 0.85rem;
  margin-right: 3px;
  vertical-align: middle;
}

/* Three-dots menu button (visible to leader only) */
.peer-menu-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-dim);
  border-radius: 8px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 1.1rem; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  line-height: 1; letter-spacing: -1px;
}
.peer-menu-btn:hover { background: rgba(255,255,255,0.14); color: var(--text); }
.peer-menu-btn:active { transform: scale(0.93); }

/* Dropdown menu */
.peer-dropdown {
  position: fixed;
  z-index: 999;
  background: #1e1e2e;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
  min-width: 175px;
  animation: fadeIn 0.12s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.dd-item {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; padding: 0.65rem 1rem;
  background: none; border: none;
  color: var(--text); font-size: 0.9rem;
  cursor: pointer; text-align: left;
  transition: background 0.12s;
}
.dd-item:hover { background: rgba(255,255,255,0.08); }
.dd-kick { color: #ff6b6b; }
.dd-kick:hover { background: rgba(255, 70, 70, 0.12); }

/* Dim banner shown to the dimmed user */
.dim-banner {
  margin: 0 1.2rem 0.5rem;
  padding: 0.55rem 0.8rem;
  background: rgba(255, 70, 70, 0.12);
  border: 1px solid rgba(255, 70, 70, 0.4);
  border-radius: 8px;
  font-size: 0.84rem;
  color: #ff6b6b;
  text-align: center;
  animation: slideIn 0.3s ease-out;
}

/* Leader badge shown above peer list */
.leader-badge {
  margin: 0 1.2rem 0.5rem;
  padding: 0.4rem 0.8rem;
  background: rgba(255, 200, 0, 0.12);
  border: 1px solid rgba(255, 200, 0, 0.35);
  border-radius: 8px;
  font-size: 0.82rem;
  color: #ffd700;
  text-align: center;
}

/* Voice messages from Watch/Shortcut */
.voice-messages {
  padding: 0 1.2rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.voice-msg {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: linear-gradient(90deg, rgba(142,123,255,0.18), rgba(142,123,255,0.05));
  border: 1px solid rgba(142,123,255,0.4);
  border-radius: 10px; font-size: 0.85rem;
  animation: slideIn 0.3s ease-out;
  cursor: pointer;
}
@keyframes slideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.voice-msg.playing {
  border-color: var(--accent-watch);
  box-shadow: 0 0 16px rgba(142,123,255,0.3);
}
.voice-msg.needs-tap {
  border-color: var(--accent-warm);
  animation: shake 0.5s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.vm-icon { font-size: 1.1rem; }
.vm-name { font-weight: 600; flex: 1; }
.vm-status { color: var(--text-dim); font-size: 0.75rem; }

.status-bar {
  text-align: center; padding: 0.6rem;
  color: var(--text-dim); font-size: 0.85rem; font-weight: 500;
}
.status-bar[data-kind="active"] { color: var(--accent-hot); }
.status-bar[data-kind="error"] { color: var(--accent-warm); }

/* PTT button */
.ptt-container { display: flex; justify-content: center; padding: 0.5rem 1rem 1.5rem; }
.ptt {
  position: relative; width: 210px; height: 210px;
  border-radius: 50%; background: none; border: none;
  cursor: pointer; touch-action: none; padding: 0;
  -webkit-user-select: none;
}
.ptt-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--surface-2), var(--surface));
  border: 3px solid var(--border);
  transition: all 0.15s ease-out;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4), inset 0 2px 6px rgba(255,255,255,0.05);
}
.ptt-inner {
  position: absolute; inset: 14px; border-radius: 50%;
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.4rem; transition: all 0.15s ease-out;
  box-shadow: inset 0 -4px 10px rgba(0,0,0,0.3);
}
.ptt-icon { font-size: 2.8rem; transition: transform 0.15s; }
.ptt-label {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.12em;
  color: var(--text-dim); text-align: center;
  padding: 0 1.2rem; line-height: 1.3;
}

.ptt.active .ptt-ring {
  background: radial-gradient(circle at 30% 30%, #ff5a6e, #aa0010);
  border-color: var(--accent-hot);
  box-shadow: 0 0 60px rgba(255,59,78,0.7), inset 0 2px 6px rgba(255,255,255,0.1);
  transform: scale(0.96);
}
.ptt.active .ptt-inner {
  background: linear-gradient(145deg, #ff5a6e, #cc1a2e);
  box-shadow: inset 0 4px 10px rgba(0,0,0,0.3);
}
.ptt.active .ptt-icon { transform: scale(1.1); }
.ptt.active .ptt-label { color: #fff; }

.controls { display: flex; gap: 0.5rem; padding: 0 1.2rem 1rem; }
.mode-btn, .leave-btn {
  flex: 1; padding: 0.85rem; border-radius: 11px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.1s, background 0.15s;
}
.mode-btn:active, .leave-btn:active { transform: scale(0.98); }
.mode-btn { background: var(--surface); color: var(--text); }
.leave-btn { background: var(--accent-hot); color: #fff; border-color: var(--accent-hot); }

/* Modal */
.modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 1rem; z-index: 100;
  align-items: flex-end; justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 1.5rem; width: 100%; max-width: 480px;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  animation: slideUp 0.25s ease-out;
  max-height: 85vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-content { border-radius: 20px; }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}
.modal-content h2 { font-size: 1.2rem; }

.setting {
  padding: 0.9rem 0; border-bottom: 1px solid var(--border);
}
.setting:last-of-type { border-bottom: none; }
.setting label {
  display: flex; align-items: flex-start; gap: 0.7rem;
  cursor: pointer; line-height: 1.4;
}
.setting input[type="checkbox"] {
  width: 20px; height: 20px; accent-color: var(--accent);
  margin-top: 2px; flex-shrink: 0;
}
.setting span { font-size: 0.9rem; }
.setting small {
  display: block; color: var(--text-dim);
  margin-top: 0.2rem; font-size: 0.75rem; font-weight: 400;
}

.settings-info {
  margin: 1rem 0; padding: 0.8rem;
  background: var(--surface-2); border-radius: 10px;
  font-size: 0.8rem; line-height: 1.5; color: var(--text-dim);
}
.settings-info code {
  display: inline-block; word-break: break-all;
  background: var(--bg); padding: 0.2rem 0.4rem;
  border-radius: 4px; color: var(--accent-watch);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem; margin-top: 0.3rem;
}

.primary-btn {
  width: 100%; margin-top: 1rem;
  background: var(--accent); color: #000; border: none;
  padding: 0.9rem; border-radius: 11px;
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
.primary-btn:active { transform: scale(0.98); }

/* ----- INVITE BANNER ----- */
.invite-banner {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.2rem;
  background: linear-gradient(135deg, rgba(142,123,255,0.25), rgba(0,212,170,0.18));
  border: 1px solid rgba(142,123,255,0.5);
  border-radius: 14px;
  width: 100%;
  max-width: 340px;
  animation: slideDown 0.4s ease-out;
}
@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.invite-icon { font-size: 1.8rem; flex-shrink: 0; }
.invite-text { text-align: left; }
.invite-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.invite-sub { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }

/* ----- HEADER ACTIONS ----- */
.header-actions { display: flex; gap: 0.5rem; }

/* ----- SHARE MODAL ----- */
.share-intro {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}
.share-url-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  max-height: 80px;
  overflow-y: auto;
}
.share-url-box code {
  color: var(--accent-watch);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  line-height: 1.4;
}

.share-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.share-actions button { flex: 1; margin-top: 0; }

.secondary-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.9rem;
  border-radius: 11px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}
.secondary-btn:active { transform: scale(0.98); }

.share-qr {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}
.share-qr img, .share-qr svg {
  border-radius: 8px;
  background: white;
  padding: 4px;
}

.share-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 0.5rem;
}

/* Knock banner (shown to the person being invited back) */
.knock-banner {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: #1a2230;
  border: 1px solid rgba(0, 212, 170, 0.4);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 9999;
  min-width: 280px;
  max-width: 90vw;
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp { from { opacity: 0; transform: translateX(-50%) translateY(16px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.knock-icon { font-size: 1.6rem; flex-shrink: 0; }
.knock-text { flex: 1; font-size: 0.88rem; line-height: 1.4; }
.knock-text strong { color: var(--accent); }
.knock-text small { color: var(--text-dim); }

.knock-rejoin-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.knock-rejoin-btn:hover { opacity: 0.85; }

.knock-dismiss-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  flex-shrink: 0;
}
.knock-dismiss-btn:hover { color: var(--text); }

/* "Eerder aanwezig" section shown to the leader */
.lurker-section {
  margin: 0 1.2rem 0.5rem;
}
.lurker-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}
.lurker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.7rem;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 0.3rem;
}
.lurker-name { font-size: 0.88rem; color: var(--text-dim); }
.lurker-knock-btn {
  background: rgba(0, 212, 170, 0.1);
  border: 1px solid rgba(0, 212, 170, 0.35);
  color: var(--accent);
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}
.lurker-knock-btn:hover { background: rgba(0, 212, 170, 0.2); }
.lurker-knock-btn:disabled { opacity: 0.5; cursor: default; }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e1e2e;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 0.8rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast--kicked {
  border-color: rgba(255, 70, 70, 0.5);
  background: #2a1010;
  color: #ff8080;
}
