:root {
  /* Disney Pictures Blue Intro palette */
  --brand-blue: #113CCF;
  --brand-blue-hover: #0F35B5;
  --brand-blue-soft: #E6EBFB;
  --ice-blue: #BFFAFD;
  --ice-blue-soft: #EAFDFE;

  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-alt: #F7F9FC;
  --border: #E2E6EF;
  --border-strong: #C8D0DE;

  --text: #0B1130;
  --text-muted: #4A5274;
  --text-subtle: #7A8198;

  --user-bubble: var(--brand-blue);
  --user-bubble-text: #FFFFFF;

  /* Semantic colors for authority */
  --auth-bg: #F0FDF4;
  --auth-border: #BBF7D0;
  --auth-text: #166534;
  --forum-bg: #FFFBEB;
  --forum-border: #FDE68A;
  --forum-text: #92400E;
  --warning-bg: #FEF3C7;
  --warning-border: #FBBF24;
  --warning-text: #78350F;

  --max-w: 760px;
  --max-w-composer: 720px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(17, 60, 207, 0.04);
  --shadow-md: 0 4px 12px rgba(17, 60, 207, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-alt);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.brand-mark { color: var(--brand-blue); font-size: 16px; }
.brand-name { font-weight: 700; letter-spacing: 0.14em; color: var(--brand-blue); }
.brand-divider { color: var(--text-subtle); }
.brand-product { color: var(--text-muted); }

/* Demo pill */
.demo-pill {
  display: inline-block;
  padding: 2px 8px;
  margin-left: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-blue);
  background: var(--brand-blue-soft);
  border-radius: 999px;
  line-height: 1.4;
}

/* Toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-muted);
}
.toggle input { display: none; }
.toggle-slider {
  width: 32px;
  height: 18px;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--brand-blue); }
.toggle input:checked + .toggle-slider::after { transform: translateX(14px); }

/* ============================================================
   STATE-DRIVEN LAYOUT
   body[data-state="empty"]  → centered composer, no thread, no bottom bar
   body[data-state="chat"]   → bottom-pinned composer + scrolling thread
   ============================================================ */

/* Empty shell — visible when data-state="empty" */
.empty-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}
body[data-state="chat"] .empty-shell { display: none; }

.empty-inner {
  width: 100%;
  max-width: var(--max-w-composer);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 24px;
}

.empty-greeting {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-greeting h1 {
  font-size: 28px;
  margin: 0;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.empty-greeting p {
  margin: 0;
  color: var(--text-muted);
  max-width: 560px;
  font-size: 15px;
}

/* Composer slot containers */
.composer-slot { display: contents; }

.composer-slot-center { /* receives the composer in empty state — nothing to style directly */ }

.composer-slot-bottom {
  display: none;
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px;
}
body[data-state="chat"] .composer-slot-bottom { display: flex; justify-content: center; }

/* Disclaimer — between composer and chips in empty state */
.empty-disclaimer {
  margin: 0;
  font-size: 12.5px;
  font-style: italic;
  color: var(--text-subtle);
  text-align: center;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}
body[data-state="chat"] .empty-disclaimer { display: none; }

/* Suggestions — chips below disclaimer */
.suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.suggestion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.suggestion:hover {
  border-color: var(--brand-blue);
  background: var(--brand-blue-soft);
  color: var(--brand-blue);
}

/* Chat thread — hidden in empty state, visible in chat state */
.thread {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 16px;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
}
body[data-state="chat"] .thread { display: flex; }

/* ============================================================
   MESSAGES (chat state only — display unchanged from prior version)
   ============================================================ */

.message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
}
.message.user { justify-content: flex-end; }
.message.bot { justify-content: flex-start; width: 100%; }
.message.user .bubble-wrap { max-width: 80%; }
.message.bot .bubble-wrap { flex: 1; min-width: 0; }

.bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-blue);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
  user-select: none;
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.55;
  word-wrap: break-word;
}
.message.user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 4px;
}
.message.bot .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 600; }
.bubble ul, .bubble ol { margin: 8px 0; padding-left: 22px; }
.bubble li { margin-bottom: 4px; }

.bubble h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 14px 0 6px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.bubble h3:first-child { margin-top: 0; }
.bubble h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--text);
}
.bubble h4:first-child { margin-top: 0; }

.conflict-banner {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--warning-text);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.conflict-banner .icon { flex-shrink: 0; font-size: 14px; }

.sources {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sources-toggle {
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-subtle);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  letter-spacing: 0.02em;
}
.sources-toggle:hover { color: var(--brand-blue); }
.sources-list {
  display: none;
  flex-direction: column;
  gap: 6px;
}
.sources-list.open { display: flex; }

.source-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid;
}
.source-card.authoritative {
  background: var(--auth-bg);
  border-color: var(--auth-border);
  color: var(--auth-text);
}
.source-card.forum {
  background: var(--forum-bg);
  border-color: var(--forum-border);
  color: var(--forum-text);
}
.source-icon { font-size: 14px; }
.source-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.source-name { font-weight: 600; }
.source-detail { font-size: 11px; opacity: 0.75; }

.typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--brand-blue);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
  opacity: 0.6;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   COMPOSER — same visual styling in both states, container differs
   ============================================================ */
.composer {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: var(--max-w-composer);
  margin: 0 auto;
  flex-shrink: 0;
}
#input {
  flex: 1;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  background: var(--surface);
  transition: border 0.15s, box-shadow 0.15s;
  color: var(--text);
}
#input:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--brand-blue-soft);
}
#send {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--brand-blue);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
#send:disabled { opacity: 0.4; cursor: not-allowed; }
#send:hover:not(:disabled) { background: var(--brand-blue-hover); }
#send:active:not(:disabled) { transform: scale(0.96); }

/* Empty-state composer gets a subtle elevation to feel like the focal point */
body[data-state="empty"] .composer #input {
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
body[data-state="empty"] .composer #input:focus {
  box-shadow: var(--shadow-md), 0 0 0 3px var(--brand-blue-soft);
}

/* Mobile */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .toggle-label { display: none; }
  .empty-greeting h1 { font-size: 22px; }
  .empty-shell { padding: 16px; }
  .empty-inner { gap: 18px; }
  .composer-slot-bottom { padding: 12px; }
  .bot-avatar { width: 28px; height: 28px; font-size: 12px; }
  .demo-pill { font-size: 9px; padding: 1px 6px; }
  #input { padding: 12px 18px; }
  #send { width: 44px; height: 44px; }
}
