*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f1a;
  --surface: #13162a;
  --surface2: #1a1f3a;
  --border: rgba(255,255,255,0.07);
  --accent: #7c6ff7;
  --accent-dim: rgba(124,111,247,0.15);
  --accent2: #56cfb2;
  --red: #f05f7a;
  --red-dim: rgba(240,95,122,0.15);
  --text: #e8eaf0;
  --text-muted: #5a6080;
  --green: #56cfb2;
  --radius: 14px;
  --radius-sm: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 32px 16px 64px;
  position: relative;
  overflow-x: hidden;
}

/* Sfondo glow ambientale */
.bg-glow {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse at center, rgba(124,111,247,0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Card base */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.logo svg { opacity: 0.9; }

/* Status */
.status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status--connecting {
  background: rgba(90,96,128,0.2);
  border-color: rgba(90,96,128,0.3);
  color: var(--text-muted);
}
.status--connecting .status-dot {
  background: var(--text-muted);
}

.status--connected {
  background: rgba(86,207,178,0.1);
  border-color: rgba(86,207,178,0.25);
  color: var(--green);
}
.status--connected .status-dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status--error {
  background: var(--red-dim);
  border-color: rgba(240,95,122,0.3);
  color: var(--red);
}
.status--error .status-dot { background: var(--red); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Error banner */
.error-banner {
  background: var(--red-dim);
  border: 1px solid rgba(240,95,122,0.3);
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* Mic section */
#mic-section {
  text-align: center;
  padding: 32px 24px;
}

.mic-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid rgba(124,111,247,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent);
}

.mic-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.mic-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Buttons */
.btn {
  padding: 11px 28px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.15s, box-shadow 0.15s;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124,111,247,0.35);
}

/* Controls (mute buttons) */
.controls {
  display: flex;
  gap: 10px;
  padding: 14px;
}

.control-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.control-btn.active {
  background: var(--accent-dim);
  border-color: rgba(124,111,247,0.35);
  color: var(--accent);
}

.control-btn.muted {
  background: var(--red-dim);
  border-color: rgba(240,95,122,0.35);
  color: var(--red);
}

.control-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.control-btn:active { transform: translateY(0); }

/* Peers section */
#peers-section { padding: 20px; }

h2 {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 0 8px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Peer card */
.peer-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s;
}

.peer-card:last-child { margin-bottom: 0; }

.peer-card.speaking {
  border-color: rgba(86,207,178,0.4);
}

.peer-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  color: #fff;
  position: relative;
}

.peer-avatar::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.peer-card.speaking .peer-avatar::after {
  border-color: var(--green);
}

.peer-info {
  flex: 1;
  min-width: 0;
}

.peer-name {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

.peer-volume-wrap {
  height: 3px;
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
  overflow: hidden;
}

.peer-volume-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 2px;
  transition: width 0.25s ease;
}

.peer-distance {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

#audio-container { display: none; }
