/* ── Variables (CMVFX Brand) ────────────────────────────── */
:root {
  --bg:        #231f20;
  --surface:   rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.09);
  --border:    rgba(255, 255, 255, 0.12);
  --text:      #f0eeed;
  --text-dim:  #8a8385;
  --accent:    #9e0918;
  --accent-2:  #b81a2b;
  --danger:    #ef4444;
  --success:   #22c55e;
  --radius:    12px;
  --radius-sm: 8px;
}

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

html, body {
  height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ─────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #231f20;
  background-image:
    linear-gradient(160deg, #231f20 0%, #2d2628 40%, #3a1a1e 70%, #4a1018 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  backdrop-filter: blur(24px);
  text-align: center;
}

.login-logo {
  margin-bottom: 1.5rem;
}

.login-logo img {
  height: 40px;
  width: auto;
}

.login-divider {
  width: 48px;
  height: 2px;
  background: var(--accent);
  margin: 0 auto 1.5rem;
}

.login-card h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
}

.login-subtitle {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-bottom: 2rem;
  letter-spacing: 0.03em;
}

.field {
  text-align: left;
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.field input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.field input:focus {
  border-color: var(--accent);
  background: rgba(158, 9, 24, 0.06);
}

.error {
  color: var(--danger);
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
  text-align: left;
}

.btn-primary {
  width: 100%;
  padding: 0.7rem;
  margin-top: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-2); }
.btn-primary:active { transform: scale(0.98); }

/* ── Loader ────────────────────────────────────────────── */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.5s;
}

.loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-inner {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Avatar viewport ───────────────────────────────────── */
#avatar-container {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#avatar-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── HUD ───────────────────────────────────────────────── */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

#hud > * {
  pointer-events: auto;
}

/* Top bar */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-pill.connected::before { background: var(--success); }
.status-pill.disconnected::before { background: var(--danger); }
.status-pill.connecting::before {
  background: #f59e0b;
  animation: pulse-dot 1s ease infinite;
}

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

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: color 0.2s, border-color 0.2s;
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

/* Subtitle area */
#subtitle-area {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 1rem 0.5rem;
  pointer-events: none;
}

#subtitles {
  max-width: 640px;
  width: 100%;
  min-height: 1.4em;
  padding: 0.6rem 1rem;
  text-align: center;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.3s;
}

#subtitles.visible {
  opacity: 1;
}

/* Controls */
#controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem 1.25rem;
  background: linear-gradient(to top, rgba(8, 8, 12, 0.85) 60%, transparent);
}

.btn-mic {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-mic:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-mic:not(:disabled):hover {
  border-color: var(--accent);
  background: rgba(158, 9, 24, 0.2);
}

.btn-mic.recording {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
  animation: pulse-ring 1.2s ease infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  100% { box-shadow: 0 0 0 16px rgba(239, 68, 68, 0); }
}

.text-bar {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.text-bar:focus-within {
  border-color: var(--accent);
}

.text-bar input {
  flex: 1;
  padding: 0.65rem 1rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.text-bar input::placeholder {
  color: var(--text-dim);
}

.text-bar input:disabled {
  opacity: 0.5;
}

.btn-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin-right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-send:not(:disabled):hover {
  background: var(--accent-2);
}

.btn-interrupt {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-interrupt:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 600px) {
  #controls {
    gap: 0.5rem;
    padding: 0.5rem 0.5rem 1rem;
  }

  .btn-mic {
    width: 48px;
    height: 48px;
  }

  .text-bar input {
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
  }

  #subtitles {
    font-size: 0.9rem;
  }

  .login-card {
    margin: 0 1rem;
    padding: 2rem 1.5rem;
  }
}
