:root {
  --cyan: #00e5ff;
  --purple: #a855f7;
  --bg: #05070d;
  --danger: #ff5566;
  --glow: rgba(0, 229, 255, 0.5);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow-x: hidden; }
body {
  background: radial-gradient(circle at 50% -10%, #0d1a30 0%, #05070d 55%, #030409 100%);
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  color: #e8ecf5;
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 24px;
  position: relative;
}

/* ---------- Header ---------- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 16px;
}
.logo {
  font-weight: 800;
  font-size: 1.35rem;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}
.badge {
  font-size: 0.58rem;
  background: rgba(255,85,102,0.15);
  color: var(--danger);
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
  margin-left: 6px;
  -webkit-text-fill-color: var(--danger);
  font-weight: 700;
}
.gf-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: #9aa6bc;
}
.gf-switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  transition: background 0.25s;
}
.gf-switch.on { background: linear-gradient(90deg, #ff5f9e, #a855f7); border-color: transparent; }
.gf-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s;
}
.gf-switch.on::after { transform: translateX(18px); }

.countdown-ring {
  position: relative;
  width: 44px;
  height: 44px;
}
.countdown-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 4; }
.ring-fg {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 163.36;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.countdown-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
}

main { flex: 1; display: flex; flex-direction: column; gap: 16px; }

/* ---------- Jarvis Neural Stage ---------- */
.stage {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
.stage.gf-active {
  border-color: rgba(255, 95, 158, 0.3);
  background: radial-gradient(circle at 50% 30%, rgba(255,95,158,0.06), rgba(255,255,255,0.02));
}

.neural-core {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.neural-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 229, 255, 0.25);
  animation: rotateRing linear infinite;
}
.neural-ring.r1 { width: 200px; height: 200px; animation-duration: 14s; border-color: rgba(0,229,255,0.22); }
.neural-ring.r2 { width: 160px; height: 160px; animation-duration: 10s; animation-direction: reverse; border-color: rgba(168,85,247,0.25); border-style: dashed; }
.neural-ring.r3 { width: 120px; height: 120px; animation-duration: 7s; border-color: rgba(0,229,255,0.3); }
@keyframes rotateRing { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.stage.gf-active .neural-ring.r1 { border-color: rgba(255,95,158,0.25); }
.stage.gf-active .neural-ring.r2 { border-color: rgba(255,95,158,0.3); }
.stage.gf-active .neural-ring.r3 { border-color: rgba(255,150,180,0.35); }

.mic-btn {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: #05070d;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 45px rgba(0,200,255,0.4);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  z-index: 2;
}
.mic-btn:active { transform: scale(0.94); }
.mic-btn.listening { animation: pulse 1.4s ease-in-out infinite; }
.mic-btn.connecting { opacity: 0.6; animation: spinPulse 1s ease-in-out infinite; }
.stage.gf-active .mic-btn { background: linear-gradient(135deg, #ff5f9e, #a855f7); box-shadow: 0 0 45px rgba(255,95,158,0.45); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 45px rgba(0,200,255,0.4); }
  50% { box-shadow: 0 0 70px rgba(168,85,247,0.6); }
}
@keyframes spinPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.9; }
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0;
  animation: floatParticle 3s ease-in-out infinite;
}
.stage.gf-active .particle { background: #ff5f9e; }
@keyframes floatParticle {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  50% { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-40px) scale(1.2); }
}

.waveform-wrap { width: 100%; height: 44px; }
#waveCanvas { width: 100%; height: 100%; }

.status {
  font-size: 0.92rem;
  color: #9aa6bc;
  text-align: center;
  min-height: 20px;
}

.stop-btn {
  padding: 9px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255,85,102,0.4);
  background: rgba(255,85,102,0.1);
  color: #ff8899;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s;
}
.stop-btn.hidden { display: none; }
.stop-btn:active { background: rgba(255,85,102,0.25); }

/* ---------- Tool log ---------- */
.tool-log-panel {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 18px;
  padding: 14px 16px;
  flex-shrink: 0;
}
.panel-title { font-size: 0.8rem; color: #7dd3fc; margin-bottom: 10px; font-weight: 600; }
.tool-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 140px;
  overflow-y: auto;
}
.tool-log-empty { color: #545e73; font-size: 0.82rem; }
.tool-log-entry {
  font-size: 0.82rem;
  color: #c8d0e0;
  background: rgba(0,229,255,0.06);
  border-left: 2px solid var(--cyan);
  padding: 6px 10px;
  border-radius: 6px;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Info chips (specs / FAQ quick access) ---------- */
.info-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.info-chip {
  font-size: 0.72rem;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: #9aa6bc;
}

/* ---------- Lead gate (name+phone form before starting) ---------- */
.lead-gate {
  position: fixed;
  inset: 0;
  background: rgba(5,7,13,0.97);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 14px;
  text-align: center;
}
.lead-gate.hidden { display: none; }
.lead-gate h2 {
  font-size: 1.5rem;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.lead-gate p { color: #9aa6bc; font-size: 0.88rem; max-width: 320px; }
.lead-gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
}
.lead-gate-form input {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 0.95rem;
}
.lead-gate-form input:focus { outline: none; border-color: var(--cyan); }
.lead-gate-form button {
  padding: 14px;
  border-radius: 26px;
  border: none;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  color: #05070d;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  margin-top: 4px;
}
.lead-gate-note { font-size: 0.68rem; color: #545e73; margin-top: 6px; }

/* ---------- Buy popup ---------- */
.buy-popup {
  position: fixed;
  inset: 0;
  background: rgba(5,7,13,0.85);
  backdrop-filter: blur(4px);
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 24px;
}
.buy-popup.show { opacity: 1; pointer-events: auto; }
.buy-popup-card {
  position: relative;
  background: linear-gradient(160deg, rgba(0,229,255,0.08), rgba(168,85,247,0.08));
  border: 1px solid rgba(0,229,255,0.3);
  border-radius: 22px;
  padding: 32px 28px;
  text-align: center;
  max-width: 340px;
  box-shadow: 0 0 60px rgba(0,200,255,0.25);
  animation: popIn 0.3s ease;
}
@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.buy-popup-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 18px; }
.buy-popup-btn {
  display: inline-block;
  padding: 14px 28px;
  border-radius: 26px;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  color: #05070d;
  font-weight: 700;
  text-decoration: none;
  font-size: 0.98rem;
}
.buy-popup-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: #9aa6bc;
  font-size: 1rem;
  cursor: pointer;
}

/* ---------- End card ---------- */
.end-card {
  position: fixed;
  inset: 0;
  background: rgba(5,7,13,0.97);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}
.end-card.hidden { display: none; }
.end-card h2 { font-size: 1.6rem; }
.end-card p { color: #9aa6bc; }
.end-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 380px;
}
.end-link {
  padding: 12px 20px;
  border-radius: 24px;
  text-decoration: none;
  color: #e8ecf5;
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 0.88rem;
}
.end-link.primary {
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  color: #05070d;
  font-weight: 700;
  border: none;
}
.retry-btn {
  margin-top: 4px;
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: #e8ecf5;
  padding: 10px 20px;
  border-radius: 20px;
}

footer {
  text-align: center;
  font-size: 0.75rem;
  color: #4c5568;
  margin-top: 18px;
}
footer a { color: #7dd3fc; text-decoration: none; }
