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

:root {
  --bg:           #060914;
  --surface:      #0b0f1e;
  --surface2:     #111628;
  --surface3:     #181f35;
  --border:       #1a2138;
  --border2:      #222c48;
  --accent:       #6366f1;
  --accent2:      #8b5cf6;
  --accent-glow:  rgba(99,102,241,0.28);
  --accent-light: #a5b4fc;
  --text:         #f1f5f9;
  --text-dim:     #64748b;
  --text-muted:   #334155;
  --user-bg:      #1a2e5c;
  --model-bg:     #111628;
  --green:        #10b981;
  --red:          #f43f5e;
  --amber:        #f59e0b;
}

/* ── Base ──────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Subtle radial glow behind the chat area */
body::before {
  content: '';
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(99,102,241,0.07) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Gradient text ─────────────────────────────────────────────── */
.grad-text {
  background: linear-gradient(135deg, #818cf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Header ────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 62px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 9, 20, 0.92);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-orb {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  box-shadow: 0 0 16px rgba(99,102,241,0.35);
}

.logo-name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.logo-ai-badge {
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--surface3);
  border: 1px solid var(--border2);
  color: var(--accent-light);
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.06em;
  margin-left: 2px;
}

.header-tagline {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 400;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* Status badge */
#status-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 20px;
}

#status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

#status-dot.connecting { background: var(--amber);  animation: blink 1.2s infinite; }
#status-dot.ready      { background: var(--green); }
#status-dot.listening  { background: var(--accent); animation: blink 0.8s infinite; }
#status-dot.speaking   { background: #a78bfa;       animation: blink 1s infinite; }
#status-dot.error      { background: var(--red); }

@keyframes blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* ── Main layout ───────────────────────────────────────────────── */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 420px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ── Conversation panel ────────────────────────────────────────── */
#conversation-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

/* ── Intro hero ────────────────────────────────────────────────── */
#intro-hero {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 40px;
  gap: 20px;
  background: var(--bg);
  z-index: 5;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#intro-hero.hidden {
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
}

/* Navia orb (large, hero) */
.hero-orb-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.hero-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(99,102,241,0.2);
  animation: spin linear infinite;
}

.ring-1 {
  width: 100%;
  height: 100%;
  border-top-color: rgba(99,102,241,0.5);
  animation-duration: 8s;
}

.ring-2 {
  width: 130%;
  height: 130%;
  border-right-color: rgba(139,92,246,0.35);
  animation-duration: 14s;
  animation-direction: reverse;
}

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

.hero-orb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 0 40px rgba(99,102,241,0.4), 0 0 80px rgba(99,102,241,0.15);
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%,100% { box-shadow: 0 0 40px rgba(99,102,241,0.4), 0 0 80px rgba(99,102,241,0.15); }
  50%      { box-shadow: 0 0 60px rgba(99,102,241,0.55), 0 0 100px rgba(99,102,241,0.22); }
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: center;
}

.hero-sub {
  font-size: 0.88rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 380px;
  line-height: 1.65;
}

.hero-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}

.hero-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.hero-pill-dot.connecting { background: var(--amber); animation: blink 1.2s infinite; }
.hero-pill-dot.ready      { background: var(--green); }
.hero-pill-dot.listening  { background: var(--accent); animation: blink 0.8s infinite; }
.hero-pill-dot.speaking   { background: #a78bfa; animation: blink 1s infinite; }
.hero-pill-dot.error      { background: var(--red); }

.hero-features {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.hf-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}

.hf-item span:first-child { font-size: 1rem; }

.hf-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

/* ── Messages ──────────────────────────────────────────────────── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.message {
  display: flex;
  gap: 12px;
  max-width: 88%;
  animation: fadeUp 0.22s ease;
}

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

.message.user  { align-self: flex-end; flex-direction: row-reverse; }
.message.model { align-self: flex-start; }

/* Avatars */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.model .avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 0 12px rgba(99,102,241,0.3);
}

.message.user .avatar {
  background: var(--surface3);
  color: var(--text-dim);
  border: 1px solid var(--border2);
}

/* Bubbles */
.bubble {
  padding: 11px 16px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  max-width: 100%;
}

.message.model .bubble {
  background: var(--model-bg);
  border: 1px solid var(--border2);
  border-radius: 4px 16px 16px 16px;
  color: var(--text);
}

.message.user .bubble {
  background: var(--user-bg);
  border: 1px solid #1e3a6e;
  border-radius: 16px 4px 16px 16px;
  color: var(--text);
}

/* Thinking indicator */
.thinking {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.84rem;
}

.thinking::after {
  content: '...';
  animation: dots 1.4s steps(1) infinite;
}

@keyframes dots {
  0%   { content: '.'; }
  33%  { content: '..'; }
  66%  { content: '...'; }
  100% { content: '.'; }
}

/* ── Controls ──────────────────────────────────────────────────── */
#controls {
  flex-shrink: 0;
  padding: 20px 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Visualiser */
#visualiser {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  opacity: 0;
  transition: opacity 0.3s;
}

#visualiser.active { opacity: 1; }

#visualiser span {
  display: block;
  width: 3px;
  border-radius: 3px;
  height: 6px;
  animation: bar 0.9s ease-in-out infinite;
}

#visualiser span:nth-child(1)  { background: #6366f1; animation-delay: 0s; }
#visualiser span:nth-child(2)  { background: #7069f3; animation-delay: 0.08s; }
#visualiser span:nth-child(3)  { background: #7c71f5; animation-delay: 0.16s; }
#visualiser span:nth-child(4)  { background: #8879f6; animation-delay: 0.12s; }
#visualiser span:nth-child(5)  { background: #9480f7; animation-delay: 0.2s; }
#visualiser span:nth-child(6)  { background: #9f88f8; animation-delay: 0.1s; }
#visualiser span:nth-child(7)  { background: #a78bfa; animation-delay: 0.18s; }
#visualiser span:nth-child(8)  { background: #b595fb; animation-delay: 0.06s; }
#visualiser span:nth-child(9)  { background: #c4a0fc; animation-delay: 0.14s; }

@keyframes bar {
  0%,100% { transform: scaleY(1); }
  50%      { transform: scaleY(4); }
}

/* Mic button */
#mic-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.2s;
  box-shadow: 0 0 0 0 var(--accent-glow), 0 4px 20px rgba(99,102,241,0.3);
  position: relative;
}

#mic-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent2)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.2s;
}

#mic-btn:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 0 0 0 var(--accent-glow), 0 6px 28px rgba(99,102,241,0.45);
}

#mic-btn:hover:not(:disabled)::before { opacity: 1; }

#mic-btn.active {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  box-shadow: 0 0 0 8px rgba(244,63,94,0.15), 0 4px 20px rgba(244,63,94,0.35);
  animation: mic-pulse 1.1s ease infinite;
}

#mic-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

@keyframes mic-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(244,63,94,0.4),  0 4px 20px rgba(244,63,94,0.3); }
  70%  { box-shadow: 0 0 0 16px rgba(244,63,94,0),   0 4px 20px rgba(244,63,94,0.3); }
  100% { box-shadow: 0 0 0 0   rgba(244,63,94,0),    0 4px 20px rgba(244,63,94,0.3); }
}

#mic-label {
  font-size: 0.76rem;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ── Vehicles panel ────────────────────────────────────────────── */
#vehicles-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

#vehicles-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.vh-spark {
  color: var(--accent-light);
  font-size: 0.9rem;
}

#vehicles-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#vehicles-list::-webkit-scrollbar { width: 4px; }
#vehicles-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 28px;
  gap: 14px;
  height: 100%;
}

.empty-icon-wrap {
  width: 80px;
  height: 80px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.empty-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
  max-width: 260px;
}

.empty-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  margin-top: 8px;
}

.empty-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.79rem;
  color: var(--text-dim);
}

.es-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-light);
  flex-shrink: 0;
}

/* ── Vehicle card ──────────────────────────────────────────────── */
.vehicle-card {
  background: var(--bg);
  animation: slideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.card-photo {
  width: 100%;
  height: 210px;
  background: var(--surface3);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-photo.no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* Gradient overlay on photo */
.card-photo::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(transparent, rgba(6,9,20,0.85));
  pointer-events: none;
}

.card-photo-overlay {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 1;
}

.match-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, rgba(99,102,241,0.9), rgba(139,92,246,0.9));
  backdrop-filter: blur(6px);
  border: 1px solid rgba(165,180,252,0.3);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card-body {
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
}

.card-body::-webkit-scrollbar { width: 3px; }
.card-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.card-year-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent-light);
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.2);
  padding: 2px 10px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  width: fit-content;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: -6px;
  font-weight: 400;
}

.card-price {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #818cf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Tags */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

.tag-amber  { background: rgba(245,158,11,0.12); color: #fbbf24; border: 1px solid rgba(245,158,11,0.22); }
.tag-blue   { background: rgba(59,130,246,0.12);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.22); }
.tag-green  { background: rgba(16,185,129,0.12);  color: #34d399; border: 1px solid rgba(16,185,129,0.22); }
.tag-purple { background: rgba(139,92,246,0.12);  color: #c4b5fd; border: 1px solid rgba(139,92,246,0.22); }
.tag-default { background: var(--surface3); color: var(--text-dim); border: 1px solid var(--border2); }

/* Meta grid */
.card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-dim);
}

.meta-icon { font-size: 0.9rem; }

/* Dealer */
.card-dealer {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  color: var(--text-dim);
  padding: 0 2px;
}

.dealer-icon { font-size: 0.9rem; }

/* View listing CTA */
.card-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 10px;
  transition: opacity 0.15s, transform 0.15s;
  margin-top: 2px;
}

.card-link:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 760px) {
  main { grid-template-columns: 1fr; }
  #vehicles-panel { display: none; }
  .header-tagline { display: none; }
}
