:root {
  --bg:       #0c0f0f;
  --surface:  #141818;
  --surface2: #1a1f1f;
  --border:   rgba(255,255,255,0.07);
  --accent:   #c8f060;
  --accent2:  #60f0c8;
  --text:     #e8ece8;
  --muted:    #7a8a7a;
  --danger:   #f06060;
  --thinking: #f0c860;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ════════════════════════════════════
   SETUP SCREEN
════════════════════════════════════ */
#setup-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  position: relative;
  z-index: 10;
}

#setup-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(200,240,96,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200,240,96,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: -1;
}

.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 44px;
  width: 100%;
  max-width: 440px;
}

.setup-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 28px;
}

.setup-logo span { color: var(--muted); }

.setup-card h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 32px;
  font-weight: 400;
  line-height: 1.15;
  margin-bottom: 12px;
}

.setup-card h1 em { font-style: italic; color: var(--accent); }

.setup-card > p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.65;
}

.permissions-note {
  display: flex;
  gap: 10px;
  background: rgba(200,240,96,0.05);
  border: 1px solid rgba(200,240,96,0.12);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 24px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.field { margin-bottom: 20px; }

.field label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 7px;
}

.field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.field input:focus  { border-color: rgba(200,240,96,0.5); }
.field input::placeholder { color: #3a4a3a; }

.field select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23556655' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.field select:focus { border-color: rgba(200,240,96,0.5); }
.field select option { background: #1a2a1a; }

.btn-start {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #0a0d0a;
  border: none;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-start:hover  { opacity: 0.88; }
.btn-start:active { transform: scale(0.99); }

/* ════════════════════════════════════
   INTERVIEW SCREEN — FULLSCREEN
════════════════════════════════════ */
#interview-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000;
  isolation: isolate;
}

/* Avatar fills entire screen */
#sdk-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Loading overlay */
#avatar-loader {
  position: absolute;
  inset: 0;
  background: #060909;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 5;
  transition: opacity 0.7s;
}

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

.loader-ring {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(200,240,96,0.12);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

#loader-text {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

/* ── Camera PiP — top-left ── */
#camera-pip {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 192px;
  height: 144px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.1);
  background: #111;
  z-index: 10;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

.pip-name {
  position: absolute;
  bottom: 7px;
  left: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  pointer-events: none;
}

#pip-no-cam {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  background: #111;
}

/* ── Top HUD ── */
#top-hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
  z-index: 10;
  gap: 10px;
}

.hud-badge {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 4px 10px;
  border-radius: 20px;
}

.hud-q {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: rgba(200,240,96,0.75);
  border: 1px solid rgba(200,240,96,0.2);
  padding: 4px 10px;
  border-radius: 20px;
}

/* ── Caption bubbles ── */
#transcript-overlay {
  display: none;
  position: fixed;
  bottom: 158px;
  left: 50%;
  transform: translateX(-50%);
  width: min(700px, 88vw);
  flex-direction: column;
  gap: 8px;
  z-index: 10010;
  pointer-events: none;
  /* show only last 2 captions */
  overflow: hidden;
  max-height: 148px;
}

.caption {
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.55;
  animation: fadeUp 0.3s ease;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.caption.interviewer {
  background: rgba(200,240,96,0.12);
  border: 1px solid rgba(200,240,96,0.2);
  color: #dff0a0;
  align-self: flex-start;
}

.caption.candidate {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  align-self: flex-end;
}

.caption-role {
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  opacity: 0.5;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Live interim speech text */
#live-text {
  position: fixed;
  bottom: 152px;
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, 86vw);
  text-align: center;
  font-size: 13px;
  font-style: italic;
  color: rgba(255,255,255,0.38);
  font-family: 'DM Mono', monospace;
  z-index: 10011;
  pointer-events: none;
  min-height: 20px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.65);
}

/* ── Side controls (right) ── */
#bottom-controls {
  position: fixed;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  height: auto;
  background: rgba(8,10,10,0.86);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 9999;
  padding: 16px 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}

#status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 24px;
  padding: 8px 16px;
  min-width: 126px;
  justify-content: center;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.idle      { background: var(--muted); }
.status-dot.thinking  { background: var(--thinking); animation: pulse 1s infinite; }
.status-dot.speaking  { background: var(--accent);   animation: pulse 0.6s infinite; }
.status-dot.listening { background: var(--accent2);  animation: pulse 0.7s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

#status-text {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  min-width: 68px;
}

/* Big mic button */
#btn-mic {
  width: 68px; height: 68px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.13);
  background: rgba(255,255,255,0.07);
  color: #ffffff;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

#btn-mic:hover:not(:disabled) {
  background: rgba(255,255,255,0.12);
}

#btn-mic:active:not(:disabled) { transform: scale(0.95); }

#btn-mic.recording {
  background: rgba(200,240,96,0.18);
  border-color: rgba(200,240,96,0.55);
  color: var(--accent);
  animation: mic-pulse 1.4s ease-in-out infinite;
}

#btn-mic:disabled {
  opacity: 0.85;
  cursor: not-allowed;
  color: #ffffff;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(200,240,96,0.3); }
  50%       { box-shadow: 0 0 0 14px rgba(200,240,96,0); }
}

#mic-hint {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: rgba(255,255,255,0.95);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
}

/* End session */
#btn-end {
  margin-top: 4px;
  padding: 10px 22px;
  background: transparent;
  border: 1px solid rgba(240,96,96,0.3);
  border-radius: 24px;
  color: rgba(240,96,96,0.65);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

#btn-end:hover {
  background: rgba(240,96,96,0.1);
  border-color: rgba(240,96,96,0.6);
  color: #f06060;
}

@media (max-width: 768px) {
  #bottom-controls {
    right: 12px;
    gap: 10px;
    padding: 12px 10px;
  }

  #btn-mic {
    width: 60px;
    height: 60px;
    font-size: 22px;
  }

  #btn-end {
    padding: 9px 16px;
    font-size: 12px;
  }

  #status-pill {
    min-width: 112px;
    padding: 7px 12px;
  }
}

/* ════════════════════════════════════
   COMPLETE SCREEN
════════════════════════════════════ */
#complete-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  align-items: center;
  justify-content: center;
  padding: 40px;
}

#complete-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(200,240,96,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200,240,96,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.complete-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 52px 44px;
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.complete-check {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(200,240,96,0.1);
  border: 1px solid rgba(200,240,96,0.3);
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.complete-check svg { width: 28px; height: 28px; }

.complete-card h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 30px;
  font-weight: 400;
  margin-bottom: 10px;
}

.complete-card .tagline {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 28px;
}

.complete-divider { height: 1px; background: var(--border); margin-bottom: 24px; }

.complete-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 28px;
}

.meta-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: left;
}

.meta-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: 'DM Mono', monospace;
  margin-bottom: 4px;
}

.meta-value { font-size: 14px; font-weight: 500; color: var(--text); }

.btn-restart {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 28px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-restart:hover { border-color: var(--accent); color: var(--accent); }

/* Error banner */
.error-banner {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,24,24,0.95);
  border: 1px solid rgba(240,96,96,0.4);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--danger);
  z-index: 200;
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
}
