:root {
  --bg: #0b0e1a;
  --bg2: #131829;
  --card: #171e33;
  --line: #2a3352;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #7c6cf6;
  --accent2: #00e5ff;
  --danger: #ff6b81;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#screen-chat { justify-content: flex-start; padding: 0; }

/* ---------- auth ---------- */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.brand { text-align: center; margin-bottom: 20px; }
.brand-orb {
  width: 72px; height: 72px; margin: 0 auto 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b9a8ff, var(--accent) 45%, #2a1e6e 90%);
  box-shadow: 0 0 32px rgba(124,108,246,.55);
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.brand h1 { margin: 0 0 4px; font-size: 26px; }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }
.tabs { display: flex; gap: 8px; margin: 4px 0 16px; }
.tab {
  flex: 1; padding: 10px; border-radius: 10px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); font-size: 15px; cursor: pointer;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.field { display: block; margin-bottom: 14px; }
.field > span, .field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg2);
  color: var(--text); font-size: 16px; font-family: inherit;
}
.field textarea { resize: vertical; }
.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 20px; cursor: pointer;
}
.error { color: var(--danger); font-size: 13px; margin: 0 0 10px; }
.btn {
  display: inline-block; padding: 12px 20px; border-radius: 12px;
  border: none; font-size: 16px; font-weight: 600; cursor: pointer;
  text-align: center;
}
.btn.primary { background: linear-gradient(135deg, var(--accent), #5a4de0); color: #fff; width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.google {
  width: 100%; background: #fff; color: #333; display: flex;
  align-items: center; justify-content: center; gap: 8px;
}
.btn.google:disabled { opacity: .55; cursor: not-allowed; }
.btn.google .g { font-weight: 800; color: #4285f4; font-size: 18px; }
.btn.google em { font-style: normal; font-size: 12px; color: #888; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fineprint { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 0; }

/* ---------- onboarding wizard ---------- */
.wizard { width: 100%; max-width: 560px; }
.wizard-head { text-align: center; margin-bottom: 16px; }
.wizard-head h2 { margin: 0 0 4px; }
.wizard-head p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.steps { display: flex; gap: 8px; justify-content: center; }
.step-dot { width: 28px; height: 6px; border-radius: 3px; background: var(--line); }
.step-dot.active { background: var(--accent); }
.step-dot.done { background: var(--accent2); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; margin-bottom: 4px; }
.chip {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg2);
  color: var(--muted); font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.orb-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  max-height: 46dvh; overflow-y: auto; padding-bottom: 8px;
}
.orb-grid.small { max-height: 30dvh; }
.orb-cell {
  border: 2px solid transparent; border-radius: 12px; padding: 6px;
  background: var(--card); cursor: pointer; text-align: center;
}
.orb-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.orb-cell p { margin: 6px 0 2px; font-size: 12px; }
.orb-cell.selected { border-color: var(--accent2); }
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-height: 46dvh; overflow-y: auto; }
.theme-grid.small { max-height: 30dvh; }
.theme-cell {
  border: 2px solid transparent; border-radius: 12px; overflow: hidden;
  cursor: pointer; position: relative; background: var(--card);
}
.theme-cell img { width: 100%; height: 90px; object-fit: cover; display: block; }
.theme-cell p {
  margin: 0; padding: 8px; font-size: 12px; text-align: center;
  background: rgba(0,0,0,.45);
}
.theme-cell.selected { border-color: var(--accent2); }
.wizard-nav { display: flex; gap: 10px; margin-top: 18px; }
.wizard-nav .btn { flex: 1; }

/* ---------- chat ---------- */
.toast {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px;
  background: #3a1420; border: 1px solid var(--danger); color: #ffc9d2;
  font-size: 14px; z-index: 60; text-align: center;
}
.trial-bar {
  width: 100%; text-align: center; font-size: 13px; padding: 8px;
  background: linear-gradient(90deg, #4a3d8f, #2c2a5e); color: #ffe9a8;
}
.disclaimer-bar {
  width: 100%; text-align: center; font-size: 12px; padding: 8px 12px;
  background: #3a2b12; color: #ffd98a; border-bottom: 1px solid #6b4d1c;
}
.chat-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: rgba(11,14,26,.85);
  border-bottom: 1px solid var(--line); z-index: 5;
}
.chat-title { flex: 1; }
.chat-title h2 { margin: 0; font-size: 18px; }
.chat-title p { margin: 0; font-size: 12px; color: var(--muted); text-transform: capitalize; }
.icon-btn {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  font-size: 18px; width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
}
#stage {
  position: relative; width: 100%; height: 220px; display: flex;
  align-items: center; justify-content: center; overflow: hidden;
  background-size: cover; background-position: center;
}
#stage-art {
  width: 150px; height: 150px; border-radius: 50%; object-fit: cover;
  position: relative; z-index: 2;
  box-shadow: 0 0 40px rgba(124,108,246,.5);
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
#stage-glow {
  position: absolute; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,108,246,.35), transparent 70%);
  animation: breathe 5s ease-in-out infinite;
}
#pulse-ring {
  position: absolute; left: 50%; top: 50%;
  width: 160px; height: 160px; margin: -80px 0 0 -80px;
  border-radius: 50%; border: 3px solid var(--accent2);
  opacity: 0; pointer-events: none; z-index: 3;
}
#pulse-ring.on { animation: ring-pulse 1.4s ease-out infinite; }
@keyframes ring-pulse {
  0% { transform: scale(0.9); opacity: .9; }
  100% { transform: scale(1.35); opacity: 0; }
}
#pickers {
  width: 100%; max-height: 44dvh; overflow-y: auto;
  background: var(--bg2); border-bottom: 1px solid var(--line); padding: 10px 14px;
}
.messages {
  flex: 1; width: 100%; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 200px;
}
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 15px; line-height: 1.45; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.orb { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg a { color: var(--accent2); }
.msg .who { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.composer {
  width: 100%; display: flex; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(11,14,26,.95); border-top: 1px solid var(--line);
}
.composer input {
  flex: 1; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 16px;
}
.voice-btn {
  width: 48px; height: 48px; border-radius: 50%; font-size: 22px;
  border: 1px solid var(--line); background: var(--bg2); cursor: pointer; flex: 0 0 auto;
}
.voice-btn.listening { background: var(--danger); border-color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.composer .btn { width: auto; }
.voice-status { text-align: center; font-size: 12px; color: var(--muted); margin: 4px 0 8px; min-height: 16px; }
