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

html, body {
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

/* ============================================
   START SCREEN
   ============================================ */

#start-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#start-screen[hidden] { display: none; }

#start-content {
  text-align: center;
  padding: 0 32px;
}

#start-content h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}

#start-content p {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 48px;
  line-height: 1.4;
}

#start-btn {
  width: 160px;
  height: 56px;
  border-radius: 28px;
  border: none;
  background: #fff;
  color: #000;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

#start-btn:active { opacity: 0.7; }

/* ============================================
   CAMERA SCREEN
   ============================================ */

#camera-screen {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#camera-screen[hidden] { display: none; }

#camera-view {
  position: absolute;
  inset: 0;
}

#camera-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================
   STATUS BAR (top) — network dot + timer only
   ============================================ */

#status-bar {
  position: fixed;
  top: env(safe-area-inset-top, 12px);
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 20px;
}

#network-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}

#network-dot.good  { background: #34c759; }
#network-dot.fair  { background: #ff9f0a; }
#network-dot.poor  { background: #ff3b30; }
#network-dot.connecting {
  background: #888;
  animation: dotBlink 1s ease-in-out infinite;
}

@keyframes dotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#session-timer {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
}

#session-timer.warning { color: #ff9f0a; }

/* ============================================
   RESPONSE CARD
   ============================================ */

#response-card {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 96px; /* sits just above the bottom panel */
  z-index: 8;
  margin: 0 12px;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-height: 45vh;
  overflow-y: auto;

  /* Hidden by default — slides down off screen */
  transform: translateY(calc(100% + 120px));
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

#response-card.visible {
  transform: translateY(0);
}

#question-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  font-style: italic;
  margin-bottom: 10px;
  line-height: 1.4;
}

#question-text:empty { display: none; }

#response-text {
  font-size: 17px;
  font-weight: 500;
  color: #fff;
  line-height: 1.55;
}

#response-text:empty { display: none; }

/* ============================================
   BOTTOM PANEL
   ============================================ */

#bottom-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ---- Mic button ---- */
#talk-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  touch-action: manipulation;
  position: relative;
}

/* Connecting */
#talk-btn.mic-connecting {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

#connecting-spinner {
  animation: spin 1s linear infinite;
  transform-origin: center;
}

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

/* Idle/Ready */
#talk-btn.mic-idle {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Listening (user holding mic) */
#talk-btn.mic-listening {
  background: rgba(52, 199, 89, 0.85);
  border-color: rgba(52, 199, 89, 0.5);
  transform: scale(1.07);
  animation: listenPulse 1s ease-in-out infinite;
}

@keyframes listenPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.35); }
  50%       { box-shadow: 0 0 0 14px rgba(52, 199, 89, 0); }
}

/* Thinking (waiting for Gemini response) */
#talk-btn.mic-thinking {
  background: rgba(255, 159, 10, 0.5);
  border-color: rgba(255, 159, 10, 0.4);
  animation: thinkPulse 1.2s ease-in-out infinite;
}

@keyframes thinkPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 159, 10, 0.3); opacity: 1; }
  50%       { box-shadow: 0 0 0 10px rgba(255, 159, 10, 0); opacity: 0.75; }
}

/* AI speaking */
#talk-btn.mic-speaking {
  background: rgba(175, 82, 222, 0.7);
  border-color: rgba(175, 82, 222, 0.4);
  animation: speakPulse 2s ease-in-out infinite;
}

@keyframes speakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(175, 82, 222, 0.3); }
  50%       { box-shadow: 0 0 0 10px rgba(175, 82, 222, 0); }
}

/* ---- Side buttons ---- */
#flip-btn,
#end-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#flip-btn:active,
#end-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

#end-btn {
  color: rgba(255, 80, 60, 0.9);
}

/* ============================================
   ERROR TOAST
   ============================================ */

#error-toast {
  position: fixed;
  bottom: 108px;
  left: 16px;
  right: 16px;
  z-index: 200;
  padding: 12px 16px;
  background: rgba(255, 59, 48, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 14px;
  font-size: 14px;
  text-align: center;
  animation: slideUp 0.3s ease-out;
}

#error-toast[hidden] { display: none; }

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

/* ============================================
   SAFE AREA
   ============================================ */

@supports (padding-top: env(safe-area-inset-top)) {
  #status-bar {
    top: calc(env(safe-area-inset-top) + 4px);
  }
  #bottom-panel {
    height: calc(96px + env(safe-area-inset-bottom));
  }
  #response-card {
    bottom: calc(96px + env(safe-area-inset-bottom));
  }
}
