:root {
  --bg-main: #090d16;
  --panel-bg: #131b2a;
  --ai-bubble-bg: #151d2d;
  --ai-border: rgba(255, 255, 255, 0.08);
  --user-bubble-bg: #2563eb;
  --text-white: #ffffff;
  --text-muted: #94a3b8;
  --accent-green: #10b981;
  --accent-blue: #3b82f6;
  --radius-bubble: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-main);
  color: var(--text-white);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 650px;
  margin: 0 auto;
  position: relative;
}

/* Header with Full iOS Notch Support */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
  padding-left: 18px;
  padding-right: 18px;
  padding-bottom: 12px;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 10;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pulse {
  width: 9px;
  height: 9px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
}

.user-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.3px;
}

.weather-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px 12px;
  border-radius: 24px;
  font-size: 0.82rem;
  color: #cbd5e1;
}

.weather-pill strong {
  color: #60a5fa;
}

/* Chat Feed */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

.chat-feed::-webkit-scrollbar {
  width: 4px;
}
.chat-feed::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.feed-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 8px;
}

/* Message Rows */
.msg-row {
  display: flex;
  gap: 10px;
  width: 100%;
  animation: fadeInMsg 0.2s ease-out;
}

@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-row {
  align-items: flex-start;
}

.user-row {
  justify-content: flex-end;
}

.ai-avatar-icon {
  font-size: 1.25rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-bubble {
  max-width: 82%;
  padding: 12px 16px;
  line-height: 1.5;
  font-size: 0.98rem;
  position: relative;
  word-break: break-word;
}

.ai-bubble {
  background: var(--ai-bubble-bg);
  border: 1px solid var(--ai-border);
  color: #f1f5f9;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.user-bubble {
  background: var(--user-bubble-bg);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

/* Audio Status Pill inside AI Bubble */
.audio-status-tag {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #93c5fd;
  cursor: pointer;
  user-select: none;
}

.audio-status-tag:active {
  background: rgba(255, 255, 255, 0.16);
}

.speaking-anim {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.speaking-anim span {
  width: 3px;
  height: 10px;
  background: #60a5fa;
  border-radius: 2px;
  animation: wave 1s infinite ease-in-out;
}
.speaking-anim span:nth-child(2) { animation-delay: 0.2s; height: 14px; }
.speaking-anim span:nth-child(3) { animation-delay: 0.4s; height: 8px; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1.2); }
}

/* Bottom Panel */
.bottom-panel {
  padding-left: 14px;
  padding-right: 14px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  padding-top: 6px;
  background: linear-gradient(to top, var(--bg-main) 70%, rgba(9, 13, 22, 0));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Quick Chips */
.quick-chip-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px;
  scrollbar-width: none;
}
.quick-chip-scroller::-webkit-scrollbar {
  display: none;
}

.chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  padding: 6px 13px;
  border-radius: 18px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:active {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
  transform: scale(0.96);
}

/* Input Form */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel-bg);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 6px 8px 6px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s;
}

.chat-input-bar:focus-within {
  border-color: var(--accent-blue);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  resize: none;
  max-height: 110px;
  padding: 6px 0;
}

.chat-textarea::placeholder {
  color: #64748b;
  font-size: 0.94rem;
}

.submit-arrow-btn {
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}

.submit-arrow-btn:active {
  transform: scale(0.92);
}

.submit-arrow-btn svg {
  margin-left: 2px;
}

/* Audio Status & Stop/Play Button */
.audio-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 10px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.audio-status-tag.is-playing {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.3);
}

.audio-status-tag:active {
  transform: scale(0.95);
}

.speaking-anim {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 14px;
}

.speaking-anim span {
  width: 3.5px;
  height: 100%;
  background-color: currentColor;
  border-radius: 3px;
  animation: audioWave 0.8s infinite ease-in-out;
}

.speaking-anim span:nth-child(2) {
  animation-delay: 0.2s;
}

.speaking-anim span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes audioWave {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}
