:root {
  --bg: #04060e;
  --surface: rgba(16, 22, 38, 0.86);
  --border: rgba(148, 163, 184, 0.16);
  --text: #f8fafc;
  --muted: rgba(203, 213, 225, 0.66);
  --blue: #4facfe;
  --indigo: #6366f1;
  --violet: #a855f7;
  --rose: #f472b6;
  --cyan: #22d3ee;
  --amber: #f59e0b;
  --red: #ef4444;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, select {
  user-select: auto;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Ambient Gemini Live Backdrop */
.ambient-bg {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, rgba(79, 172, 254, 0.16) 0%, rgba(99, 102, 241, 0.08) 32%, transparent 65%),
    radial-gradient(circle at 50% 95%, rgba(168, 85, 247, 0.12) 0%, transparent 50%);
  transition: filter 0.6s ease, opacity 0.6s ease;
  z-index: 0;
}

body[data-mode="listening"] .ambient-bg {
  background:
    radial-gradient(circle at 50% 44%, rgba(34, 211, 238, 0.22) 0%, rgba(79, 172, 254, 0.12) 36%, transparent 68%),
    radial-gradient(circle at 50% 96%, rgba(56, 189, 248, 0.16) 0%, transparent 55%);
}

body[data-mode="speaking"] .ambient-bg {
  background:
    radial-gradient(circle at 50% 44%, rgba(168, 85, 247, 0.28) 0%, rgba(244, 114, 182, 0.14) 36%, transparent 68%),
    radial-gradient(circle at 50% 96%, rgba(99, 102, 241, 0.22) 0%, transparent 58%);
}

body[data-mode="paused"] .ambient-bg {
  opacity: 0.45;
}

/* Auth Screen */
.auth-screen {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--border);
  border-radius: 32px;
  padding: 36px 28px 30px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
}

.auth-orb-mini {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: conic-gradient(from 140deg, #38bdf8, #6366f1, #a855f7, #f472b6, #38bdf8);
  box-shadow: 0 0 42px rgba(99, 102, 241, 0.55);
  animation: slowSpin 9s linear infinite;
}

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

.auth-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin: 6px 0 22px;
  font-size: 13px;
  color: var(--muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form input,
.sheet-form input,
.sheet-form select {
  width: 100%;
  background: rgba(8, 12, 24, 0.85);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s ease;
}

.auth-form input:focus,
.sheet-form input:focus,
.sheet-form select:focus {
  border-color: var(--blue);
}

.error-banner {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
}

/* Full-Screen Pure Gemini Live Stage */
.live-stage {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding:
    calc(env(safe-area-inset-top, 0px) + 16px)
    20px
    calc(env(safe-area-inset-bottom, 0px) + 28px);
}

.floating-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(148, 163, 184, 0.14);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

body[data-mode="listening"] .live-dot {
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

body[data-mode="speaking"] .live-dot {
  background: var(--violet);
  box-shadow: 0 0 14px var(--violet);
}

body[data-mode="paused"] .live-dot {
  background: var(--amber);
}

.icon-circle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.icon-circle-btn:hover {
  color: var(--text);
  background: rgba(30, 41, 59, 0.78);
}

/* Camera Vision Floating PiP */
.vision-pip {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  right: 20px;
  width: 104px;
  height: 140px;
  border-radius: 18px;
  object-fit: cover;
  border: 1.5px solid rgba(79, 172, 254, 0.65);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
  background: #000;
  z-index: 6;
}

/* Center Aura Stage */
.aura-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 0;
}

.aura-wrap {
  position: relative;
  width: min(76vw, 340px);
  height: min(76vw, 340px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#auraCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.aura-hit {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
}

.voice-status {
  text-align: center;
  min-height: 52px;
  padding: 0 16px;
}

.state-label {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  transition: opacity 0.2s ease;
}

.sub-label {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.35;
}

/* Bottom Gemini Live Call Dock */
.live-dock {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 68px;
}

.glow-pill-btn {
  border: none;
  border-radius: 999px;
  padding: 15px 30px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  background: linear-gradient(135deg, #38bdf8 0%, #6366f1 55%, #a855f7 100%);
  box-shadow: 0 12px 34px rgba(99, 102, 241, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.2s ease;
}

.glow-pill-btn.full {
  width: 100%;
}

.glow-pill-btn:active {
  transform: scale(0.97);
}

.glow-pill-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.call-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.call-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(30, 41, 59, 0.78);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.call-btn:active {
  transform: scale(0.93);
}

.call-btn.active {
  background: rgba(248, 250, 252, 0.94);
  border-color: #fff;
  color: #0f172a;
}

.call-btn.muted {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.6);
  color: #fde68a;
}

.call-btn.end {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.42);
}

/* One-Time Key / Voice Modal Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(2, 4, 10, 0.76);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 430px;
  background: rgba(15, 22, 38, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 28px;
  padding: 24px 22px 20px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.7);
}

.sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sheet-top h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.sheet-lead {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.sheet-lead a {
  color: var(--blue);
  text-decoration: underline;
}

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: -6px;
}

.key-badge {
  font-size: 11px;
  color: var(--cyan);
}

.sheet-feedback {
  font-size: 13px;
  min-height: 18px;
}

.sheet-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.guardrail-note {
  font-size: 11px;
  color: var(--muted);
}

.sheet-actions {
  display: flex;
  gap: 8px;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.65);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
