:root {
  --navy: #1E2761;
  --navy-dark: #161d4d;
  --gold: #B8860B;
  --ice: #CADCFC;
  --bg: #F4F5FA;
  --text: #1A1A1A;
  --muted: #5B5B6B;
  --card: #FFFFFF;
  --danger: #B00020;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Calibri, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-badge {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--ice); }

.status {
  font-size: 12px;
  background: rgba(255,255,255,0.12);
  padding: 5px 10px;
  border-radius: 999px;
}
.status.ok { background: rgba(46, 204, 113, 0.25); }
.status.err { background: rgba(224, 63, 63, 0.3); }

.disclaimer {
  background: #FFF7E6;
  border-bottom: 1px solid #EBD08A;
  color: #6b5107;
  font-size: 13px;
  padding: 10px 20px;
  line-height: 1.4;
}

.chat-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  overflow: hidden;
}

.chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 4px 16px;
}

.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 14.5px;
  white-space: pre-wrap;
}

.msg.assistant .bubble {
  background: var(--card);
  border: 1px solid #E3E5F0;
  border-top-left-radius: 4px;
  color: var(--text);
}

.msg.user .bubble {
  background: var(--navy);
  color: #fff;
  border-top-right-radius: 4px;
}

.bubble.error {
  background: #FDECEC;
  border: 1px solid #F3C0C0;
  color: var(--danger);
}

.bubble.typing { display: flex; gap: 4px; align-items: center; }
.bubble.typing .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.bubble.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.bubble.typing .dot:nth-child(3) { animation-delay: 0.4s; }

.listening-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--navy);
  padding: 4px 4px 10px;
}
.listening-indicator.active { display: flex; }
.listening-indicator .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
  animation: blink 1s infinite ease-in-out;
}
.listening-indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.listening-indicator .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid #E3E5F0;
  border-radius: 14px;
  padding: 8px;
}

.composer input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14.5px;
  padding: 10px 8px;
  background: transparent;
  color: var(--text);
}

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: #E3E5F0; }
.icon-btn.recording {
  background: var(--danger);
  color: #fff;
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(176,0,32,0.35); }
  70% { box-shadow: 0 0 0 10px rgba(176,0,32,0); }
  100% { box-shadow: 0 0 0 0 rgba(176,0,32,0); }
}

.send-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--navy-dark); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
  .bubble { max-width: 88%; }
  .brand-title { font-size: 13px; }
}
