/* स्वर — Apple-grade visual language: SF type ramp, frosted surfaces,
   a Siri-style breathing orb, iMessage-style transcript. */

:root {
  --bg: #fbfbfd;
  --surface: rgba(255, 255, 255, 0.72);
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --separator: rgba(0, 0, 0, 0.08);
  --blue: #0a84ff;
  --user-bubble: linear-gradient(180deg, #3b9bff, #0a7aff);
  --bot-bubble: #e9e9eb;
  --bot-text: #1d1d1f;
  --green: #30d158;
  --red: #ff453a;
  --orb-a: #5ac8fa;
  --orb-b: #af52de;
  --orb-c: #0a84ff;
  --orb-d: #ff9f0a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: rgba(28, 28, 30, 0.72);
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --separator: rgba(255, 255, 255, 0.1);
    --bot-bubble: #26262a;
    --bot-text: #f5f5f7;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "Noto Sans Devanagari", "Mukta", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.app {
  width: min(720px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 20px calc(14px + env(safe-area-inset-bottom));
}

/* ---------- nav ---------- */

.nav {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 12px;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  z-index: 5;
}

.wordmark { display: flex; align-items: baseline; gap: 8px; }
.wordmark .ne {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--orb-c), var(--orb-b));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.wordmark .en {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.nav-right { display: flex; align-items: center; gap: 10px; }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  opacity: 0.4;
  transition: background 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
}
.dot.on { background: var(--green); opacity: 1; box-shadow: 0 0 8px rgba(48, 209, 88, 0.6); }

.latency {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* ---------- orb stage ---------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 4px;
}

.orb-wrap {
  width: 148px;
  height: 148px;
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  transform: scale(calc(1 + var(--level, 0) * 0.18));
}

.orb-glow {
  position: absolute;
  inset: -28px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--orb-c) 28%, transparent) 0%, transparent 65%);
  filter: blur(18px);
  opacity: 0.7;
  transition: opacity 0.6s ease;
}

.orb {
  width: 124px;
  height: 124px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 18px 50px rgba(10, 132, 255, 0.22),
    inset 0 0 24px rgba(255, 255, 255, 0.25);
  transition: transform 0.6s cubic-bezier(0.32, 0.72, 0, 1);
}

.orb-layer {
  position: absolute;
  inset: -40%;
  border-radius: 50%;
  filter: blur(22px);
  mix-blend-mode: screen;
}
.l1 { background: radial-gradient(circle at 30% 35%, var(--orb-a), transparent 60%); animation: drift1 9s ease-in-out infinite; }
.l2 { background: radial-gradient(circle at 70% 60%, var(--orb-b), transparent 60%); animation: drift2 11s ease-in-out infinite; }
.l3 { background: radial-gradient(circle at 50% 80%, var(--orb-c), transparent 60%); animation: drift3 13s ease-in-out infinite; }

@keyframes drift1 { 50% { transform: translate(14%, 10%) scale(1.1); } }
@keyframes drift2 { 50% { transform: translate(-12%, -8%) scale(1.15); } }
@keyframes drift3 { 50% { transform: translate(8%, -12%) scale(1.05); } }

.orb.idle { animation: breathe 5s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(0.96); } }

.orb.listening { animation: none; }
.orb.listening .orb-layer { animation-duration: 4s, 4s, 4s; }

.orb.thinking .orb-layer { filter: blur(14px); animation-duration: 1.6s, 1.9s, 2.2s; }

.orb.speaking { animation: speakPulse 1.1s ease-in-out infinite; }
@keyframes speakPulse { 50% { transform: scale(1.05); } }

.orb.off {
  box-shadow: none;
}
.orb.off .orb-layer { opacity: 0.35; filter: blur(30px) saturate(0.4); }

.caption {
  margin-top: 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  min-height: 1.3em;
  transition: opacity 0.3s ease;
}

/* ---------- conversation ---------- */

.conversation {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 2px;
  scrollbar-width: none;
  mask-image: linear-gradient(to bottom, transparent 0, black 18px, black 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 18px, black 100%);
}
.conversation::-webkit-scrollbar { display: none; }

.bubble {
  max-width: 78%;
  padding: 10px 15px;
  border-radius: 20px;
  line-height: 1.5;
  font-size: 1.02rem;
  white-space: pre-wrap;
  word-break: break-word;
  animation: pop 0.36s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
}

.bubble.user {
  background: var(--user-bubble);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}
.bubble.bot {
  background: var(--bot-bubble);
  color: var(--bot-text);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}
.bubble.bot.streaming::after {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typing 1s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes typing { 50% { opacity: 0.25; transform: scale(0.8); } }

.partial {
  min-height: 1.5em;
  text-align: center;
  font-size: 0.92rem;
  color: var(--text-secondary);
  padding: 2px 8px 8px;
  font-style: normal;
}

/* ---------- footer / start ---------- */

.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
}

.start-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: white;
  background: linear-gradient(180deg, #3b9bff, #0a7aff);
  padding: 14px 34px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(10, 132, 255, 0.35), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1), box-shadow 0.25s ease, opacity 0.3s ease;
}
.start-btn:hover { transform: scale(1.04); }
.start-btn:active { transform: scale(0.97); }
.start-btn.live {
  background: linear-gradient(180deg, #ff6961, #ff453a);
  box-shadow: 0 10px 30px rgba(255, 69, 58, 0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}

.start-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
}
.start-btn.live .start-dot { animation: typing 1.2s ease-in-out infinite; }

.footnote {
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}
