/* ============================================================
   UNC Charlotte Academic Policy Assistant — Design Spec Build
   GOV.UK clarity + Perplexity citation-forward + Linear craft.
   Font: Inter (local). Brand: UNC Charlotte green 00703C.
   ============================================================ */

/* ── Custom Properties ───────────────────────────────────── */
:root {
  /* Spacing scale (8px base) */
  --sp-2:  4px;
  --sp-3:  6px;
  --sp-4:  8px;
  --sp-6:  12px;
  --sp-8:  16px;
  --sp-12: 24px;
  --sp-16: 32px;
  --sp-20: 40px;
  --sp-24: 48px;

  /* Semantic spacing grid (UI1) — aliases to sp-* for named-token use */
  --space-1: var(--sp-2);    /* 4px  */
  --space-2: var(--sp-4);    /* 8px  */
  --space-3: var(--sp-6);    /* 12px */
  --space-4: var(--sp-8);    /* 16px */
  --space-5: var(--sp-12);   /* 24px */
  --space-6: var(--sp-16);   /* 32px */

  /* Typography scale (UI1) */
  --type-display:    28px;
  --type-heading:    20px;
  --type-subheading: 16px;
  --type-body:       14px;
  --type-caption:    12px;

  /* Brand */
  --brand-green:      #00703C; /* brand primary green */
  --brand-green-dark: #005A30; /* brand dark green */
  --brand-gold:       #B3A369; /* brand gold */

  /* Neutral */
  --gray-50:  #F7F8FA; /* lightest gray */
  --gray-100: #F3F4F6; /* near-white */
  --gray-200: #E5E7EB; /* light border */
  --gray-300: #D1D5DB; /* divider */
  --gray-400: #9CA3AF; /* muted text */
  --gray-500: #6B7280; /* secondary text */
  --gray-600: #4B5563; /* subdued text */
  --gray-700: #374151; /* dark text */
  --gray-800: #1F2937; /* primary text */
  --gray-900: #111827; /* heading text */
  --white:    #FFFFFF; /* white surface */

  /* Semantic */
  --green-50:  #F0FDF4; /* success tint bg */
  --green-100: #DCFCE7; /* success bg */
  --green-600: #059669; /* success text */
  --amber-50:  #FFFBEB; /* warning tint bg */
  --amber-700: #B45309; /* warning text */
  --red-50:    #FEF2F2; /* error tint bg */
  --red-700:   #B91C1C; /* error text */
  --blue-50:   #EFF6FF; /* info tint bg */
  --blue-700:  #1D4ED8; /* info text */

  /* Semantic text aliases (resolve dark overrides via --gray-* cascade) */
  --text-primary:   var(--gray-800); /* body / heading primary text */
  --text-secondary: var(--gray-600); /* subdued / secondary text */
  --text-muted:     var(--gray-400); /* placeholder / muted text */

  /* On-brand (text/icons on colored backgrounds) */
  --on-brand:           #FFFFFF; /* white for text on brand-green surfaces */
  --focus-ring:         rgba(0, 112, 60, 0.08); /* brand focus halo */
  --redirect-border:    #DBEAFE; /* redirect card border (light mode) */
  --badge-border-green: #BBF7D0; /* upload badge border (light mode) */

  /* Layout */
  --content-w: 720px;
  --header-h:  56px;
  --input-area-h: 104px;
}

/* ── Dark Theme Overrides ────────────────────────────────── */
[data-theme="dark"] {
  /* Neutral — invert semantic meaning */
  --white:    #1F2937; /* dark: card surface */
  --gray-50:  #111827; /* dark: page bg */
  --gray-100: #1F2937; /* dark: surface variant */
  --gray-200: #374151; /* dark: border */
  --gray-300: #4B5563; /* dark: divider */
  --gray-400: #9CA3AF; /* dark: muted */
  --gray-500: #9CA3AF; /* dark: secondary text */
  --gray-600: #D1D5DB; /* dark: subdued text */
  --gray-700: #E5E7EB; /* dark: body text */
  --gray-800: #F3F4F6; /* dark: primary text */
  --gray-900: #F9FAFB; /* dark: heading text */

  /* Semantic — dark-bg appropriate tints */
  --green-50:  #052e16; /* dark: success tint bg */
  --green-100: #14532d; /* dark: success bg */
  --green-600: #4ade80; /* dark: success text */
  --amber-50:  #451a03; /* dark: warning tint bg */
  --amber-700: #fbbf24; /* dark: warning text */
  --red-50:    #450a0a; /* dark: error tint bg */
  --red-700:   #f87171; /* dark: error text */
  --blue-50:   #1e3a8a; /* dark: info tint bg */
  --blue-700:  #93c5fd; /* dark: info text */

  /* Derived */
  --focus-ring:         rgba(0, 112, 60, 0.25); /* dark: more visible focus halo */
  --redirect-border:    #1e40af; /* dark: redirect card border */
  --badge-border-green: #166534; /* dark: upload badge border */
}

/* ── Skip navigation link (keyboard / screen-reader) ─────── */
.skip-link {
  position: absolute;
  top: -48px;
  left: 0;
  background: var(--brand-green);
  color: #fff;
  padding: var(--sp-4) var(--sp-8);
  border-radius: 0 0 4px 0;
  z-index: 200;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: top 200ms ease;
}
.skip-link:focus {
  top: 0;
}

/* ── Dark theme via OS preference (no-JS fallback) ────────── */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --white:    #1F2937; /* dark: card surface */
    --gray-50:  #111827; /* dark: page bg */
    --gray-100: #1F2937; /* dark: surface variant */
    --gray-200: #374151; /* dark: border */
    --gray-300: #4B5563; /* dark: divider */
    --gray-400: #9CA3AF; /* dark: muted */
    --gray-500: #9CA3AF; /* dark: secondary text */
    --gray-600: #D1D5DB; /* dark: subdued text */
    --gray-700: #E5E7EB; /* dark: body text */
    --gray-800: #F3F4F6; /* dark: primary text */
    --gray-900: #F9FAFB; /* dark: heading text */
    --green-50:  #052e16; /* dark: success tint bg */
    --green-100: #14532d; /* dark: success bg */
    --green-600: #4ade80; /* dark: success text */
    --amber-50:  #451a03; /* dark: warning tint bg */
    --amber-700: #fbbf24; /* dark: warning text */
    --red-50:    #450a0a; /* dark: error tint bg */
    --red-700:   #f87171; /* dark: error text */
    --blue-50:   #1e3a8a; /* dark: info tint bg */
    --blue-700:  #93c5fd; /* dark: info text */
    --focus-ring:         rgba(0, 112, 60, 0.25); /* dark: more visible focus halo */
    --redirect-border:    #1e40af; /* dark: redirect card border */
    --badge-border-green: #166534; /* dark: upload badge border */
  }
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

/* Ensure [hidden] is never overridden by component display rules */
[hidden] { display: none !important; }

a {
  color: var(--brand-green);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover {
  color: var(--brand-green-dark);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

textarea {
  font-family: inherit;
  resize: none;
}

ul { list-style: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Focus ───────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--brand-green);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════
   HEADER — 56px, sticky top
   ═══════════════════════════════════════════════════════════ */
.header {
  flex-shrink: 0;
  z-index: 100;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--brand-green) 0%, var(--brand-green-dark) 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-8);
}

.header-inner {
  width: 100%;
  max-width: var(--content-w);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  flex-shrink: 0;
  min-width: 270px;
}

.header-text {
  min-width: 0;
}

.header-avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  line-height: 1;
}

/* SVG fill classes — use CSS variables so dark mode works */
.hdr-avatar-circle  { fill: var(--on-brand); }
.hdr-avatar-text    { fill: var(--brand-green); }
.empty-avatar-circle { fill: var(--brand-green); }
.empty-avatar-text  { fill: var(--on-brand); }
.msg-avatar-circle  { fill: var(--brand-green); }
.msg-avatar-text    { fill: var(--on-brand); }

/* Theme toggle button */
.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.8);
  transition: color 150ms ease, background 150ms ease;
  flex-shrink: 0;
}
.theme-btn:hover {
  color: var(--on-brand);
  background: rgba(255, 255, 255, 0.12);
}
/* Show sun icon in dark mode, moon in light mode */
.theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-sun { display: block; }
[data-theme="dark"] .theme-icon-moon { display: none; }

.header-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--on-brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-subtitle {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.7);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-shrink: 0;
}

/* Clear button — ghost, white text */
.clear-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 500;
  transition: color 150ms ease, background 150ms ease;
}
.clear-btn:hover {
  color: var(--on-brand);
  background: rgba(255, 255, 255, 0.12);
}

/* Mode toggle — pill shape */
.mode-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 2px;
}

.mode-btn {
  padding: var(--sp-2) var(--sp-6);
  border-radius: 18px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  transition: all 200ms ease;
  white-space: nowrap;
}
.mode-btn.active {
  background: rgba(255, 255, 255, 0.95);
  color: var(--brand-green);
}
.mode-btn:not(.active):hover {
  color: var(--on-brand);
}

/* Audience toggle — visually separated from source-mode toggle */
.audience-toggle {
  margin-right: var(--sp-3);
}
.audience-toggle.hidden {
  display: none;
}

/* ── Button hierarchy (UI1) ──────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-8);
  background: var(--brand-green);
  color: var(--on-brand);
  border: none;
  border-radius: 8px;
  font-size: var(--type-body);
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}
.btn-primary:hover { background: var(--brand-green-dark); }
.btn-primary:focus-visible {
  outline: 2px solid var(--brand-green);
  outline-offset: 2px;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-8);
  background: transparent;
  color: var(--brand-green);
  border: 1.5px solid var(--brand-green);
  border-radius: 8px;
  font-size: var(--type-body);
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
}
.btn-secondary:hover { background: var(--green-50); }
.btn-secondary:focus-visible {
  outline: 2px solid var(--brand-green);
  outline-offset: 2px;
}
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-tertiary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-8);
  background: transparent;
  color: var(--gray-600);
  border: none;
  border-radius: 8px;
  font-size: var(--type-body);
  font-weight: 500;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}
.btn-tertiary:hover { color: var(--gray-800); background: var(--gray-100); }
.btn-tertiary:focus-visible {
  outline: 2px solid var(--brand-green);
  outline-offset: 2px;
}
.btn-tertiary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════
   MAIN — scrollable area between header and input
   ═══════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: var(--sp-8);
}

/* Custom scrollbar — invisible until hover */
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
  transition: background 200ms;
}
.main:hover::-webkit-scrollbar-thumb {
  background: var(--gray-300);
}

.content-col {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 var(--sp-8);
  min-height: 100%;
}

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE — vertically centered
   ═══════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: var(--sp-24) 0;
  text-align: center;
}

/* At tablet widths the 5 category sections exceed the viewport height,
   so centering pushes the heading above the fold — switch to flex-start. */
@media (max-width: 1024px) {
  .empty-state { justify-content: flex-start; }
}

.empty-avatar {
  margin-bottom: var(--sp-6);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
}

/* Decorative outer ring (UI1) */
.empty-avatar::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1.5px solid var(--green-100);
  pointer-events: none;
}

[data-theme="dark"] .empty-avatar::before {
  border-color: rgba(0, 112, 60, 0.3);
}

.empty-heading {
  font-size: var(--type-heading);
  font-weight: 600;
  line-height: 1.3;
  color: var(--gray-900);
}

.empty-subtitle {
  font-size: var(--type-body);
  font-weight: 400;
  line-height: 1.5;
  color: var(--gray-500);
  margin-top: var(--sp-2);
}

.category-section {
  width: 100%;
  max-width: 560px;
  text-align: left;
  margin-top: var(--sp-12);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: var(--sp-12) var(--sp-16);
}

.category-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-600);
  margin-bottom: var(--sp-8);
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.category-pill {
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: var(--sp-4) 14px;
  cursor: pointer;
  color: var(--gray-700);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.category-pill:hover {
  border-color: var(--brand-green);
  color: var(--brand-green);
}
.category-pill:active {
  transform: scale(0.97);
}

/* ═══════════════════════════════════════════════════════════
   MESSAGES
   ═══════════════════════════════════════════════════════════ */
.messages {
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
  padding-top: var(--sp-12);
}

/* Message appear animation */
.msg-appear {
  animation: msgSlideUp 200ms ease-out both;
}
@keyframes msgSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── User message ────────────────────────────────────────── */
.msg-user {
  display: flex;
  justify-content: flex-end;
}

.msg-user-bubble {
  max-width: 75%;
  background: var(--brand-green);
  color: var(--on-brand);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  padding: var(--sp-6) var(--sp-8);
  border-radius: 18px 18px 4px 18px;
  opacity: 1;
}

/* ── Assistant message ───────────────────────────────────── */
.msg-assistant {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-6);
}

.msg-assistant-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-assistant-card {
  flex: 1;
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* Source chips — inside card, top */
.source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--sp-8);
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--gray-700);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: var(--sp-2) var(--sp-4);
  transition: all 150ms ease;
}
a.source-chip {
  text-decoration: none;
  color: inherit;
}
a.source-chip::after {
  content: '\2197';
  font-size: 10px;
  opacity: 0;
  margin-left: 2px;
  transition: opacity 150ms ease;
}
a.source-chip:hover::after {
  opacity: 0.6;
}
.source-chip:hover {
  background: var(--green-50);
  border-color: var(--brand-green);
}

.source-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-green);
  flex-shrink: 0;
}

.source-chips-overflow {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-400);
  padding: var(--sp-2) var(--sp-4);
}

/* Answer body */
.answer-body {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  max-width: 640px;
}

.answer-body h2 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  margin-top: var(--sp-12);
  margin-bottom: var(--sp-4);
}

.answer-body h3 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  margin-top: var(--sp-8);
  margin-bottom: var(--sp-2);
}

.answer-body strong:first-of-type,
.answer-body b:first-of-type {
  font-weight: 600;
  color: var(--text-primary);
}

.answer-body p {
  margin-bottom: var(--sp-6);
}
.answer-body p:last-child {
  margin-bottom: 0;
}

.answer-body ul, .answer-body ol {
  padding-left: 14px;
  margin-bottom: var(--sp-6);
}
.answer-body li {
  margin-bottom: var(--sp-4);
  list-style: disc;
}
.answer-body ol li {
  list-style: decimal;
}

/* Step indicator (S04 timeline transform) */
.step-indicator {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 0;
  margin-bottom: var(--sp-6);
}
.step-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  position: relative;
  padding-bottom: var(--sp-6);
}
.step-item::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--gray-300);
}
.step-item:last-child::before {
  display: none;
}
.step-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  position: relative;
  z-index: 1;
}
.step-text {
  flex: 1;
  padding-top: 3px;
  line-height: 1.5;
}

/* Checklist (S04 requirement transform) */
.policy-checklist {
  list-style: none;
  padding-left: 0;
  margin-bottom: var(--sp-6);
}
.policy-checklist li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--gray-200);
}
.policy-checklist li:last-child {
  border-bottom: none;
}
.checklist-label {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  cursor: pointer;
  flex: 1;
}
.policy-checklist input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--brand-green);
  cursor: pointer;
}
.checklist-text {
  flex: 1;
  line-height: 1.5;
}
.policy-checklist input[type="checkbox"]:checked + .checklist-text {
  text-decoration: line-through;
  opacity: 0.7;
}

/* Streaming cursor */
.streaming-cursor::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--brand-green);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 530ms step-end infinite;
}
@keyframes blink {
  50% { opacity: 0; }
}

/* Typing dots */
.typing-dots {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-4) 0;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gray-300);
  animation: typingPulse 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 200ms; }
.typing-dot:nth-child(3) { animation-delay: 400ms; }
@keyframes typingPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1); }
}

/* ── Skeleton shimmer loader ─────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton-loader {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--sp-2) 0;
}
.skeleton-line {
  height: 14px;
  border-radius: 6px;
  width: 85%;
  background: linear-gradient(
    90deg,
    var(--gray-100) 25%,
    var(--gray-200) 50%,
    var(--gray-100) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}
.skeleton-line--md { width: 65%; }
.skeleton-line--sm { width: 45%; }

/* ── Confidence left border ──────────────────────────────── */
.msg-assistant-card.conf-border-high {
  border-left: 3px solid var(--green-600);
}
.msg-assistant-card.conf-border-good {
  border-left: 3px solid var(--amber-700);
}
.msg-assistant-card.conf-border-low {
  border-left: 3px solid var(--red-700);
}

/* ── Sources expander ────────────────────────────────────── */
.sources-expander {
  margin-top: var(--sp-6);
}

.sources-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: background 150ms ease;
}
.sources-toggle:hover {
  background: var(--gray-100);
}

.sources-toggle-left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.sources-chevron {
  transition: transform 200ms ease;
  display: flex;
  align-items: center;
}
.sources-expander.open .sources-chevron {
  transform: rotate(180deg);
}

.sources-content {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 250ms ease, opacity 200ms ease;
}
.sources-expander.open .sources-content {
  opacity: 1;
  /* max-height set by JS via scrollHeight */
}

.sources-cards {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-top: var(--sp-4);
  background: var(--gray-50);
  border-radius: 0 0 8px 8px;
}

[data-theme="dark"] .sources-cards { background: var(--gray-100); }

/* Bottom border between consecutive citation cards (not after last) */
.sources-cards .citation-card {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  border-bottom: 1px solid var(--gray-200);
  background: transparent;
}

[data-theme="dark"] .sources-cards .citation-card {
  border-bottom-color: var(--gray-300);
}

.sources-cards .citation-card:first-child { border-radius: 0; }
.sources-cards .citation-card:last-child  { border-bottom: none; }

/* ── Confidence legend (inside sources expander) ─────────── */
.confidence-legend {
  font-size: 11px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: var(--sp-4) 0 var(--sp-2);
}

.legend-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-high { background: var(--green-600); }
.legend-good { background: var(--amber-700); }
.legend-low  { background: var(--red-700); }

.sources-show-all {
  background: none;
  border: none;
  color: var(--brand-green);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  width: 100%;
  text-align: left;
}
.sources-show-all:hover {
  text-decoration: underline;
}
.sources-overflow {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding-top: var(--sp-4);
}

/* ── Citation card ───────────────────────────────────────── */
.citation-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: var(--sp-6) var(--sp-8);
}

.citation-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--gray-900);
}
a.citation-title {
  text-decoration: none;
}
a.citation-title:hover {
  text-decoration: underline;
}

.citation-section {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--gray-500);
  margin-top: 2px;
}

.citation-excerpt {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--gray-600);
  font-style: italic;
  border-left: 2px solid var(--gray-200);
  padding-left: var(--sp-6);
  margin-top: var(--sp-4);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.citation-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--brand-green);
  text-decoration: none;
  margin-top: var(--sp-4);
  transition: gap 150ms ease;
}
.citation-link:hover {
  gap: 6px;
  color: var(--brand-green-dark);
}

/* ── Context bar (related policy areas) ─────────────────── */
.context-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-8);
}

.context-bar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
}

.context-chip {
  font-size: 12px;
  color: var(--gray-600);
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: 12px;
  padding: 2px 10px;
}

/* ── Suggestion chips ────────────────────────────────────── */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-8);
}

.suggestion-chip {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  max-width: 400px;
  color: var(--gray-700);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: var(--sp-4) 14px;
  cursor: pointer;
  transition: all 150ms ease;
}
.suggestion-chip:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  transform: translateY(-1px);
}
.suggestion-chip:active {
  transform: scale(0.98);
  transition-duration: 100ms;
}

.suggestion-arrow {
  color: var(--gray-400);
  margin-left: var(--sp-2);
}

/* ── Feedback row ────────────────────────────────────────── */
.feedback-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-4);
  margin-top: var(--sp-4);
  padding-right: var(--sp-4);
  opacity: 0.5;
  transition: opacity 200ms ease;
}
.msg-assistant:hover + .feedback-row,
.feedback-row:hover {
  opacity: 1;
}
.feedback-row + .msg-user {
  margin-top: -12px;
}

.feedback-label {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--gray-400);
}

.feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--gray-300);
  transition: all 150ms ease;
}
.feedback-btn:hover {
  background: var(--gray-50);
}
.feedback-btn.fb-positive:hover,
.feedback-btn.fb-positive.selected {
  color: var(--green-600);
}
.feedback-btn.fb-negative:hover,
.feedback-btn.fb-negative.selected {
  color: var(--red-700);
}

.feedback-thanks {
  font-size: 12px;
  font-weight: 400;
  color: var(--gray-400);
}

/* ── Copy button ─────────────────────────────────────────── */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-6);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-400);
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms ease;
}
.copy-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-600);
}
.copy-btn.copied {
  color: var(--green-600);
  border-color: var(--green-600);
}
.copy-btn svg {
  flex-shrink: 0;
}
.print-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  margin-left: var(--sp-2);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-400);
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms ease;
}
.print-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-600);
}
.print-btn svg {
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   REFUSAL / REDIRECT CARD
   ═══════════════════════════════════════════════════════════ */
.redirect-card {
  background: var(--amber-50);
  border: 1px solid #fde68a;
  border-left: 3px solid var(--amber-700);
  border-radius: 12px;
  padding: 20px 24px;
}

[data-theme="dark"] .redirect-card {
  background: var(--amber-50); /* remapped to #451a03 in dark */
  border-color: rgba(251,191,36,.2);
  border-left-color: var(--amber-700); /* #fbbf24 in dark */
}

.redirect-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--gray-800);
  margin-bottom: var(--sp-4);
}

.redirect-body {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--gray-600);
  margin-bottom: var(--sp-8);
}

.redirect-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-8);
  margin-bottom: var(--sp-8);
}

.redirect-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--blue-700);
  text-decoration: underline;
}

.redirect-action {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-green);
  border: 1px solid var(--brand-green);
  border-radius: 8px;
  padding: var(--sp-4) var(--sp-8);
  background: transparent;
  cursor: pointer;
  transition: all 150ms ease;
}
.redirect-action:hover {
  background: var(--green-50);
}

.multi-policy-alert {
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-700);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 8px;
}

[data-theme="dark"] .multi-policy-alert {
  background: rgba(59,130,246,0.10);
  color: var(--blue-700);
  border-color: rgba(147,197,253,0.4);
}

/* ═══════════════════════════════════════════════════════════
   NOT FOUND — redesigned card
   ═══════════════════════════════════════════════════════════ */
.not-found-card {
  border-left: 3px solid var(--blue-700);
  padding: 12px 16px;
  background: var(--blue-50);
  border-radius: 0 8px 8px 0;
}

[data-theme="dark"] .not-found-card {
  background: rgba(59,130,246,0.08);
}

.not-found-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.not-found-icon {
  color: var(--gray-400);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.not-found-desc {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 10px;
  line-height: 1.5;
}
.not-found-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.not-found-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.not-found-chip:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

/* ═══════════════════════════════════════════════════════════
   UPLOAD MODE — amber visual distinction
   ═══════════════════════════════════════════════════════════ */
.msg-assistant-card[data-mode="upload"] {
  border-left: 3px solid var(--amber-700);
}
.upload-mode-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--amber-50);
  color: var(--amber-700);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.upload-mode-disclaimer {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 8px;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   INPUT AREA — fixed to bottom
   ═══════════════════════════════════════════════════════════ */
.input-area {
  flex-shrink: 0;
  z-index: 50;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: var(--sp-6) 0;
}

.input-area-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 var(--sp-8);
}

/* Upload panel */
.upload-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 250ms ease, opacity 200ms ease, margin 250ms ease;
  margin-bottom: 0;
}
.upload-panel.panel-open {
  max-height: 160px;
  opacity: 1;
  margin-bottom: var(--sp-6);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border: 2px dashed var(--gray-300);
  border-radius: 12px;
  padding: var(--sp-12);
  cursor: pointer;
  text-align: center;
  transition: all 150ms ease;
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--brand-green);
  background: var(--green-50);
}

.dropzone-text {
  font-size: 14px;
  color: var(--gray-700);
}

.dropzone-hint {
  font-size: 12px;
  color: var(--gray-400);
}

/* Input wrapper — pill shape */
.input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 24px;
  padding: 10px 10px 10px 16px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.input-wrapper:focus-within {
  border-color: var(--brand-green);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Upload badge inside input */
.upload-badge-slot:empty { display: none; }

.upload-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--green-100);
  border: 1px solid var(--badge-border-green);
  border-radius: 6px;
  padding: var(--sp-2) var(--sp-4);
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
  max-width: 180px;
  white-space: nowrap;
  flex-shrink: 0;
}

.upload-badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-badge-remove {
  font-size: 14px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: color 150ms ease;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
}
.upload-badge-remove:hover {
  color: var(--gray-600);
}

#question-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--gray-800);
  background: transparent;
  max-height: 120px;
  min-height: 20px;
}
#question-input::placeholder {
  color: var(--gray-400);
  font-size: 15px;
  font-weight: 400;
}

/* Send button — 40px circle */
.send-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: var(--brand-green);
  color: var(--on-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) {
  background: var(--brand-green-dark);
  transform: scale(1.02);
}
.send-btn:disabled {
  background: var(--gray-200);
  color: var(--gray-400);
  cursor: default;
}
.send-btn.streaming {
  background: var(--brand-green-dark);
}
.send-btn.streaming svg {
  animation: sendPulse 1.5s ease-in-out infinite;
}
@keyframes sendPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Disclaimer */
.disclaimer {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--gray-600);
  text-align: center;
  margin-top: var(--sp-4);
}

/* Upload warning */
.upload-warning {
  font-size: 12px;
  color: var(--red-700);
  text-align: center;
  padding: var(--sp-2) 0;
  display: none;
}

/* Attachment status bar (loading / error below input) */
.attachment-status {
  font-size: 12px;
  text-align: center;
  padding: var(--sp-2) 0;
}
.attachment-status:empty { display: none; }
.attachment-error { color: var(--red-700); }
.attachment-loading { color: var(--gray-500); }

/* ═══════════════════════════════════════════════════════════
   SCROLL-TO-LATEST PILL
   ═══════════════════════════════════════════════════════════ */
.scroll-pill {
  position: fixed;
  bottom: calc(var(--input-area-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: var(--sp-4) var(--sp-6);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  cursor: pointer;
  z-index: 60;
}
.scroll-pill.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Narrow Mobile < 481px (375px target)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Two-row header: title row + controls row */
  .header { --header-h: auto; height: auto; padding-top: 8px; padding-bottom: 8px; }
  .header-inner { flex-direction: column; align-items: stretch; gap: 6px; }

  /* Title row: avatar + text, no shrink floor needed */
  .header-left { min-width: 0; }

  /* Controls row: center-aligned, wraps audience+mode toggles neatly */
  .header-right {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
  }

  /* Shrink pill/control font sizes */
  .mode-btn   { font-size: 11px; padding: 2px 8px; }
  .clear-btn  { font-size: 11px; }

  /* Context bar chip overflow prevention */
  .context-chip { font-size: 11px; }

  /* Copy button */
  .copy-btn { font-size: 11px; }

  /* Step badges */
  .step-number { width: 22px; height: 22px; font-size: 11px; }

  /* Tighter assistant card padding */
  .msg-assistant-card { padding: 12px; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile < 768px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .content-col {
    padding: 0 var(--sp-8);
  }

  .header-subtitle { display: none; }
  .header-title { font-size: 15px; }


  .msg-user-bubble {
    max-width: 85%;
  }

  .source-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .suggestion-chips {
    flex-direction: column;
  }
  .suggestion-chip {
    width: 100%;
    text-align: left;
  }

  .input-area-inner {
    padding: 0 var(--sp-6);
  }

  /* Touch: always show feedback */
  .feedback-row { opacity: 1; }
}

/* Touch devices — always show feedback */
@media (hover: none) {
  .feedback-row { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════
   ACCESSIBILITY — reduced motion
   ═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE FADE TRANSITIONS
   ═══════════════════════════════════════════════════════════ */
.empty-state.fade-out {
  opacity: 0;
  transition: opacity 150ms ease;
}

.messages.fade-out {
  opacity: 0;
  transition: opacity 150ms ease;
}

/* ═══════════════════════════════════════════════════════════
   CITATION SUPERSCRIPTS
   ═══════════════════════════════════════════════════════════ */

.cit-ref {
  color: var(--brand-green);
  font-size: 0.75em;
  vertical-align: super;
  cursor: pointer;
  font-weight: 600;
  border-bottom: 1px dotted var(--brand-green);
  text-decoration: none;
  margin: 0 1px;
  line-height: 0;
}

.cit-ref:hover,
.cit-ref:focus {
  color: var(--brand-green-dark);
  outline: 2px solid var(--green-100);
  outline-offset: 1px;
}

[data-theme="dark"] .cit-ref {
  color: #4ade80;
  border-bottom-color: #4ade80;
}
[data-theme="dark"] .cit-ref:hover,
[data-theme="dark"] .cit-ref:focus {
  color: #86efac;
  outline-color: rgba(74,222,128,0.4);
}

/* ═══════════════════════════════════════════════════════════
   CITATION HOVER POPOVER
   ═══════════════════════════════════════════════════════════ */

#cit-popover {
  position: fixed;
  z-index: 9000;
  max-width: 300px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  transition: opacity 150ms ease;
}

#cit-popover[hidden] {
  display: none;
}

.popover-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}

.popover-section {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
}

.popover-excerpt {
  font-size: 12px;
  line-height: 1.5;
  color: var(--gray-600);
  font-style: italic;
  margin-top: 8px;
  border-left: 2px solid var(--gray-200);
  padding-left: 8px;
}

/* ─────────────────────────────────────────────────────────────
   Typeahead dropdown
   ───────────────────────────────────────────────────────────── */

#typeahead-dropdown {
  position: fixed;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
  z-index: 200;
  max-height: 320px;
  overflow-y: auto;
  display: none;
}

.typeahead-item {
  padding: var(--sp-6) var(--sp-8);
  font-size: 14px;
  line-height: 1.4;
  color: var(--gray-700);
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background 100ms ease, color 100ms ease;
}
.typeahead-item:last-child {
  border-bottom: none;
}
.typeahead-item:hover,
.typeahead-item.active {
  background: var(--green-50);
  color: var(--brand-green);
}
.typeahead-item mark {
  background: transparent;
  color: var(--brand-green);
  font-weight: 600;
}

.typeahead-empty {
  padding: var(--sp-6) var(--sp-8);
  font-size: 13px;
  color: var(--gray-400);
  font-style: italic;
}

/* Compact header controls at tablet widths */
@media (max-width: 900px) {
  .mode-btn { padding: 4px 10px; font-size: 13px; }
}

/* ─────────────────────────────────────────────────────────────
   Retrieval Explainer ("Why this answer?")
   ───────────────────────────────────────────────────────────── */

.retrieval-explainer {
  margin-top: var(--sp-8);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  overflow: hidden;
}

[data-theme="dark"] .retrieval-explainer {
  border-color: var(--gray-700);
  background: var(--gray-800);
}

.retrieval-explainer-summary {
  cursor: pointer;
  padding: var(--sp-6) var(--sp-8);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  user-select: none;
  transition: color 100ms ease;
}

.retrieval-explainer-summary::-webkit-details-marker { display: none; }

.retrieval-explainer-summary::before {
  content: '▶';
  font-size: 9px;
  transition: transform 120ms ease;
  display: inline-block;
}

.retrieval-explainer[open] > .retrieval-explainer-summary::before {
  transform: rotate(90deg);
}

.retrieval-explainer-summary:hover { color: var(--gray-700); }
[data-theme="dark"] .retrieval-explainer-summary:hover { color: var(--gray-300); }

.retrieval-explainer-body {
  padding: var(--sp-6) var(--sp-8) var(--sp-8);
  border-top: 1px solid var(--gray-200);
}

[data-theme="dark"] .retrieval-explainer-body {
  border-top-color: var(--gray-700);
}

.retrieval-explainer-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}

.retrieval-explainer-query {
  font-size: 12px;
  color: var(--gray-600);
  font-family: 'Inter', system-ui, sans-serif;
}

[data-theme="dark"] .retrieval-explainer-query { color: var(--gray-400); }

.retrieval-conf-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.retrieval-conf-badge.conf-high {
  background: var(--green-50);
  color: var(--green-600);
}

.retrieval-conf-badge.conf-good {
  background: #eff6ff;
  color: #1d4ed8;
}

.retrieval-conf-badge.conf-low {
  background: #fef9c3;
  color: #92400e;
}

[data-theme="dark"] .retrieval-conf-badge.conf-high  { background: rgba(74,222,128,.18); color: #6ee7b7; }
[data-theme="dark"] .retrieval-conf-badge.conf-good  { background: rgba(59,130,246,.25); color: #93c5fd; }
[data-theme="dark"] .retrieval-conf-badge.conf-low   { background: rgba(234,179,8,.22); color: #fde68a; }

.retrieval-explainer-reasoning {
  font-size: 12px;
  color: var(--gray-500);
  margin: 0 0 var(--sp-8);
  font-style: italic;
}

[data-theme="dark"] .retrieval-explainer-reasoning { color: var(--gray-400); }

.retrieval-explainer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: var(--gray-700);
}

[data-theme="dark"] .retrieval-explainer-table { color: var(--gray-300); }

.retrieval-explainer-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--gray-500);
  padding: var(--sp-3) var(--sp-6) var(--sp-3) 0;
  border-bottom: 1px solid var(--gray-200);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[data-theme="dark"] .retrieval-explainer-table th {
  color: var(--gray-400);
  border-bottom-color: var(--gray-700);
}

.retrieval-explainer-table td {
  padding: var(--sp-4) var(--sp-6) var(--sp-4) 0;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}

[data-theme="dark"] .retrieval-explainer-table td { border-bottom-color: var(--gray-700); }

.retrieval-explainer-table tbody tr:last-child td { border-bottom: none; }

.retrieval-explainer-num {
  font-variant-numeric: tabular-nums;
  color: var(--gray-500);
}

.retrieval-explainer-method {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-400);
}

/* ═══════════════════════════════════════════════════════════
   PRINT STYLESHEET
   ═══════════════════════════════════════════════════════════ */
@media print {
  @page { margin: 2cm; }

  body {
    font-family: Georgia, serif;
    font-size: 12pt;
    background: white !important;
    color: black !important;
  }

  .header,
  .input-area,
  .empty-state,
  .feedback-row,
  .copy-btn,
  .print-btn,
  .suggestion-chips,
  .context-bar,
  .multi-policy-alert,
  .scroll-pill,
  .source-mode-toggle,
  .audience-toggle,
  .retrieval-explainer,
  #typeahead-dropdown,
  #cit-popover {
    display: none !important;
  }

  .msg-assistant-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
  }

  .source-chips { break-inside: avoid; }
  .step-item { break-inside: avoid; }

  .policy-checklist input[type="checkbox"] {
    -webkit-appearance: auto;
    appearance: auto;
  }

  .msg-user-bubble {
    background: #f0f0f0 !important;
    color: black !important;
  }
}

/* ============================================================
   Legal disclaimer banner
   ============================================================ */

.legal-banner {
  position: sticky;
  top: 0;
  z-index: 1100;
  background-color: #fff8e1;
  border-bottom: 1px solid #f0c040;
  font-size: 0.8125rem;
  line-height: 1.4;
}

[data-theme="dark"] .legal-banner {
  background-color: #2a2200;
  border-bottom-color: #6b5000;
  color: #f0d060;
}

.legal-banner-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.legal-banner-text {
  flex: 1;
  color: #5a4000;
}

[data-theme="dark"] .legal-banner-text {
  color: #f0d060;
}

.legal-banner-text a {
  color: #00703c;
  text-decoration: underline;
}

[data-theme="dark"] .legal-banner-text a {
  color: #4caf82;
}

.legal-banner-link {
  margin-left: 0.25rem;
  white-space: nowrap;
}

.legal-banner-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: #5a4000;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  line-height: 1;
}

.legal-banner-dismiss:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .legal-banner-dismiss {
  color: #f0d060;
}

.legal-banner[hidden] {
  display: none;
}
