/* Apple/Linear Level Premium Design System */
:root {
  --background: #07070e;
  --foreground: #f4f4f6;
  --sidebar-bg: rgba(10, 10, 16, 0.95);
  --header-bg: rgba(9, 9, 14, 0.75);
  --card-bg: rgba(16, 16, 26, 0.85);
  --user-gradient: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
  --accent-color: #6366f1;
}

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

body {
  color: var(--foreground);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Strict Proportional SVG Icon Rules */
svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  max-width: 100%;
}

.svg-icon-xs { width: 14px !important; height: 14px !important; min-width: 14px !important; max-height: 14px !important; }
.svg-icon-sm { width: 16px !important; height: 16px !important; min-width: 16px !important; max-height: 16px !important; }
.svg-icon-md { width: 20px !important; height: 20px !important; min-width: 20px !important; max-height: 20px !important; }

/* Subtle Ambient Bloom Background (5-10% Saturation, Enterprise Grade) */
@keyframes ambientBloom {
  0% { transform: translate3d(0%, 0%, 0) scale(1); opacity: 0.7; }
  50% { transform: translate3d(-2%, -2%, 0) scale(1.05); opacity: 0.9; }
  100% { transform: translate3d(0%, 0%, 0) scale(1); opacity: 0.7; }
}

.animated-gradient-bg {
  position: fixed;
  inset: -20%;
  width: 140%;
  height: 140%;
  z-index: 0;
  pointer-events: none;
  background-color: #07070e;
  background-image: 
    radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.12), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(139, 92, 246, 0.10), transparent 55%),
    radial-gradient(circle at 50% 50%, rgba(236, 72, 153, 0.06), transparent 60%);
  will-change: transform, opacity;
  animation: ambientBloom 18s ease-in-out infinite;
}

/* Morphing Glowing AI Orb */
@keyframes orbPulse {
  0% { transform: scale(1); box-shadow: 0 0 25px rgba(99, 102, 241, 0.3); }
  50% { transform: scale(1.08); box-shadow: 0 0 45px rgba(168, 85, 247, 0.5); }
  100% { transform: scale(1); box-shadow: 0 0 25px rgba(99, 102, 241, 0.3); }
}

.ai-orb {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.8), rgba(168, 85, 247, 0.8), rgba(236, 72, 153, 0.7));
  animation: orbPulse 4s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

/* ─── Message rows: Claude-style placement and rhythm ───────────────── */
/* One centered column. The user's turn is a shrink-wrapped bubble flush to
   the right edge; the assistant's turn is unadorned prose flush to the left
   edge, spanning the full column. Vertical rhythm is asymmetric on purpose:
   a question and its answer sit close together, and a wider gap opens before
   the next question so each exchange reads as one block. */
.msg-row {
  display: flex;
  width: 100%;
  min-width: 0;
}
.msg-row.msg-user { justify-content: flex-end; }
.msg-row.msg-assistant { justify-content: flex-start; }

.msg-row + .msg-row { margin-top: 1.5rem; }
.msg-row.msg-user + .msg-row.msg-assistant { margin-top: 1.25rem; }
.msg-row.msg-assistant + .msg-row.msg-user { margin-top: 2.75rem; }

/* Column that holds the user bubble (and any attachment badge above it). */
.msg-user-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 75%;
  min-width: 0;
}

/* User Message Capsule.
   The width cap lives on .msg-user-col, not here. Capping both nested the
   limits and squeezed bubbles to roughly half the column. */
.user-bubble {
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%) !important;
  color: #ffffff !important;
  font-size: 14.5px !important;
  font-weight: 450 !important;
  line-height: 1.55 !important;
  padding: 11px 17px !important;
  border-radius: 18px !important;
  display: block !important;
  width: fit-content !important;
  max-width: 100% !important;
  height: auto !important;
  text-align: left !important;
  white-space: pre-wrap !important;
  overflow-wrap: break-word !important;
  box-shadow: 0 2px 12px rgba(67, 56, 202, 0.25) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

/* Assistant turn. Deliberately chrome-free: no panel, border, or shadow, so
   the answer reads as a document in the column rather than a nested card.
   The class name is historical; it is no longer a card. */
.assistant-card {
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  font-size: 15px !important;
  line-height: 1.7 !important;
  color: #e7e7ec !important;
}

/* Markdown flow inside an assistant turn.
   The Tailwind CDN build ships without the typography plugin, so `prose` is
   inert, and the `*` reset above zeroes every margin and padding. Without
   these rules the answer renders as one unbroken block with list bullets
   clipped off the left edge. */
.assistant-card .prose > * + * {
  margin-top: 1em;
}
.assistant-card .prose > :first-child { margin-top: 0; }
.assistant-card .prose > :last-child { margin-bottom: 0; }

.assistant-card .prose h1,
.assistant-card .prose h2,
.assistant-card .prose h3,
.assistant-card .prose h4 {
  color: #ffffff;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1.4em;
}
.assistant-card .prose h1 { font-size: 1.35em; }
.assistant-card .prose h2 { font-size: 1.2em; }
.assistant-card .prose h3 { font-size: 1.08em; }
.assistant-card .prose h4 { font-size: 1em; }

.assistant-card .prose ul,
.assistant-card .prose ol {
  padding-left: 1.4em;
}
.assistant-card .prose ul { list-style: disc; }
.assistant-card .prose ol { list-style: decimal; }
.assistant-card .prose li + li { margin-top: 0.35em; }
.assistant-card .prose li::marker { color: rgba(165, 180, 252, 0.9); }
.assistant-card .prose li > ul,
.assistant-card .prose li > ol { margin-top: 0.35em; }

.assistant-card .prose strong { color: #ffffff; font-weight: 600; }
.assistant-card .prose em { font-style: italic; }
.assistant-card .prose a {
  color: #a5b4fc;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.assistant-card .prose code {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.88em;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
}
.assistant-card .prose pre {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.86em;
  line-height: 1.55;
}
.assistant-card .prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.assistant-card .prose .table-scroll {
  overflow-x: auto;
}
.assistant-card .prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}
.assistant-card .prose th,
.assistant-card .prose td {
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 7px 11px;
  text-align: left;
  vertical-align: top;
}
.assistant-card .prose th {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  font-weight: 600;
}

.assistant-card .prose blockquote {
  border-left: 2px solid rgba(99, 102, 241, 0.5);
  padding-left: 14px;
  color: #a1a1aa;
}
.assistant-card .prose hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Action row under an assistant turn. Muted and borderless: with no card to
   sit inside, a divider would read as stray chrome. */
.msg-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.85rem;
  opacity: 0.55;
  transition: opacity 0.18s ease;
}
.msg-row.msg-assistant:hover .msg-actions,
.msg-actions:focus-within { opacity: 1; }

.msg-action-btn {
  background: none;
  border: none;
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 500;
  color: #a1a1aa;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.msg-action-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

/* Streaming indicator */
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-3px); opacity: 1; }
}
.typing-dot {
  animation: typingDot 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

/* Message entrance. Restrained: a short fade with a few pixels of travel. */
@keyframes messageEnter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-slide-up {
  animation: messageEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Interactive Pill Button */
.suggest-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  color: #d4d4d8;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.suggest-pill:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(99, 102, 241, 0.3);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.15);
}

::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
