/* ═══════════════════════════════════════════════════════════
   rNPV Agent — Agave Kit Theme
   ═══════════════════════════════════════════════════════════ */

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

:root {
  /* ── Backgrounds — cool silver-gray ── */
  --bg:              #E8E9EC;
  --bg-2:            #F0F1F3;
  --bg-secondary:    #DDDFE3;
  --surface:         #F6F7F9;
  --surface-raised:  #ECEDF0;

  /* ── Borders — cool gray ── */
  --border:          #C8CCD4;
  --border-subtle:   #DCDFE6;
  --border-accent:   rgba(36, 59, 99, 0.18);

  /* ── Text — navy primary ── */
  --text:            #1B2D4F;
  --text-2:          #4A5568;
  --text-3:          #94A3B8;
  --text-gold:       #243B63;

  /* ── Accents ── */
  --accent:          #243B63;
  --accent-dk:       #1B2D4F;
  --accent-lt:       rgba(36, 59, 99, 0.06);
  --accent-glow:     rgba(36, 59, 99, 0.10);
  --emerald:         #16794A;
  --emerald-lt:      rgba(22, 121, 74, 0.07);

  /* ── Coral — accent secondary ── */
  --coral:           #E07356;
  --coral-dk:        #C45D42;
  --coral-lt:        rgba(224, 115, 86, 0.08);

  /* ── User chat ── */
  --user-bg:         #1B3A6B;
  --user-border:     #152D54;
  --user-text:       #FFFFFF;

  /* ── Error ── */
  --err:             #C53030;
  --err-bg:          rgba(197, 48, 48, 0.05);
  --err-border:      rgba(197, 48, 48, 0.18);

  /* ── Shadows — navy-tinted ── */
  --shadow-xs:       0 1px 2px rgba(27, 45, 79, 0.06);
  --shadow-sm:       0 2px 6px rgba(27, 45, 79, 0.07);
  --shadow:          0 4px 20px rgba(27, 45, 79, 0.09);
  --shadow-gold:     0 0 16px rgba(36, 59, 99, 0.06);

  /* ── Radius ── */
  --r:               3px;
  --r-sm:            2px;

  /* ── Fonts ── */
  --font-display:    'Playfair Display', 'Georgia', serif;
  --font:            'DM Sans', 'Helvetica Neue', sans-serif;
  --mono:            'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

::selection {
  background: rgba(36, 59, 99, 0.2);
  color: #1B2D4F;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── LINEN TEXTURE OVERLAY ────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 512px 512px;
  mix-blend-mode: multiply;
}

/* ── PAGE LOAD ANIMATIONS ─────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 55%, 100% { transform: translateY(0);   opacity: 0.4; }
  27%            { transform: translateY(-7px); opacity: 1;   }
}

/* ── HEADER ───────────────────────────── */
header {
  background: linear-gradient(180deg, #C8CCD4 0%, #D5D8DE 40%, #E0E2E7 75%, #E8E9EC 100%);
  border-bottom: 3px solid #1B2D4F;
  height: 58px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(27, 45, 79, 0.06);
  z-index: 10;
  animation: fadeIn 0.4s ease both;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}

.logo-mark {
  width: 34px;
  height: 34px;
  background: #1B2D4F;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(27, 45, 79, 0.25);
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.logo-name {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  color: #1B2D4F;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.logo-sub {
  font-size: 0.7rem;
  color: rgba(27, 45, 79, 0.55);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.session-badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: #4A5568;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(27, 45, 79, 0.1);
  padding: 0.25rem 0.625rem;
  border-radius: 100px;
  display: none;
}

.session-badge.visible { display: block; }

.btn {
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid rgba(27, 45, 79, 0.12);
  background: rgba(255, 255, 255, 0.85);
  color: #1B2D4F;
  padding: 0.375rem 0.8125rem;
  line-height: 1;
}

.btn:hover {
  background: rgba(255, 255, 255, 1);
  color: #1B2D4F;
  border-color: rgba(27, 45, 79, 0.2);
}

.btn-new-chat {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: 600;
}

.btn-new-chat:hover {
  background: var(--accent-dk);
  border-color: var(--accent-dk);
  color: #FFFFFF;
}

/* ── APP SHELL (sidebar + main) ────────── */
.app-shell {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease, border-width 0.2s ease;
  flex-shrink: 0;
  animation: fadeIn 0.4s ease 0.1s both;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right-width: 0;
}

.sidebar-top {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-new-btn {
  width: 100%;
  padding: 0.5rem 0.875rem;
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font);
  transition: background 0.15s;
}

.sidebar-new-btn:hover { background: var(--accent-dk); }

.sidebar-heading {
  padding: 0.625rem 0.875rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.sidebar-sessions {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0.5rem 1rem;
}

.sidebar-sessions::-webkit-scrollbar { width: 4px; }
.sidebar-sessions::-webkit-scrollbar-track { background: transparent; }
.sidebar-sessions::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.session-item {
  padding: 0.5rem 0.625rem;
  cursor: pointer;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.1s;
  user-select: none;
}

.session-item:hover { background: var(--surface-raised); }

.session-item.active {
  background: var(--accent-lt);
}

.session-item-title {
  font-size: 0.8125rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item.active .session-item-title {
  color: var(--accent);
  font-weight: 500;
}

.session-item-time {
  font-size: 0.6875rem;
  color: var(--text-3);
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
  color: rgba(27, 45, 79, 0.6);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover { background: rgba(255, 255, 255, 0.3); color: #1B2D4F; }

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  animation: fadeIn 0.4s ease 0.15s both;
}

/* ── SPLIT LAYOUT ─────────────────────── */
.main-split {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.left-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.right-panel {
  flex: 1;
  min-width: 340px;
  border-left: 1px solid var(--border);
  background: var(--bg);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.right-panel.visible {
  display: flex;
}

/* ── PANEL TOGGLE TABS ────────────────── */
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.panel-tab {
  flex: 1;
  padding: 0.625rem 1rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.panel-tab:hover {
  color: var(--text-2);
  background: var(--coral-lt);
}

.panel-tab.active {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

/* ── PANEL CONTENT ────────────────────── */
.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.panel-content::-webkit-scrollbar { width: 5px; }
.panel-content::-webkit-scrollbar-track { background: transparent; }
.panel-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.panel-view { display: none; }
.panel-view.active { display: block; }

/* ── INPUT SUMMARY CARD ───────────────── */
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-xs);
}

.summary-card h3 {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.625rem;
  letter-spacing: -0.01em;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.summary-label {
  font-size: 0.6875rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.summary-value {
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
}

/* ── RESEARCH TABLE & NOTES ───────────── */
.research-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin-top: 0.75rem;
}

.research-table th {
  text-align: left;
  font-size: 0.6875rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.research-table td {
  padding: 0.375rem 0.5rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.research-table tr:last-child td { border-bottom: none; }

.research-note {
  font-size: 0.8125rem;
  color: var(--text-2);
  margin-top: 0.75rem;
  line-height: 1.5;
}

.research-note ul { margin: 0.25rem 0 0 1.25rem; padding: 0; }
.research-note li { margin-bottom: 0.25rem; }

.research-sources {
  margin-top: 0.5rem;
  font-size: 0.75rem;
}

.research-sources a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.research-sources a:hover { text-decoration: underline; }

.search-results { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.search-results li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.search-results li:last-child { border-bottom: none; }
.search-results a { color: var(--accent); text-decoration: none; word-break: break-word; }
.search-results a:hover { text-decoration: underline; }
.search-result-age { color: var(--text-3); font-size: 0.75rem; margin-left: 0.4rem; }
.search-result-url { font-size: 0.8rem; word-break: break-all; margin: 0.25rem 0 0; }
.search-result-url a { color: var(--accent); text-decoration: none; }
.search-result-url a:hover { text-decoration: underline; }

/* ── DRUG PRICING CARD ────────────────── */
.pricing-hero {
  text-align: center;
  padding: 1rem 0 0.75rem;
}

.pricing-hero-price {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.pricing-hero-price .yr-suffix {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-2);
}

.pricing-hero-drug {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-top: 0.25rem;
}

.pricing-hero-drug em { font-style: italic; }

.confidence-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.175rem 0.625rem;
  border-radius: 100px;
  margin-top: 0.5rem;
}

.confidence-badge.high   { background: rgba(22, 121, 74, 0.1); color: #16794A; }
.confidence-badge.medium { background: rgba(36, 59, 99, 0.1); color: #243B63; }
.confidence-badge.low    { background: rgba(220, 38, 38, 0.08); color: #DC2626; }

.pricing-formula {
  background: var(--bg-2);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.8125rem;
  color: var(--text-2);
  text-align: center;
  font-family: var(--mono);
}

.calc-steps {
  background: var(--bg-2);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.75rem;
  margin: 0.375rem 0;
  font-size: 0.75rem;
  color: var(--text-2);
  font-family: var(--mono);
  line-height: 1.6;
  white-space: pre-wrap;
}

.pricing-section {
  border-top: 1px solid var(--border);
}

.pricing-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.625rem 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  font-family: var(--font);
}

.pricing-section-toggle::after {
  content: '\25B8';
  font-size: 0.75rem;
  color: var(--text-2);
  transition: transform 0.15s ease;
}

.pricing-section-toggle.open::after {
  transform: rotate(90deg);
}

.pricing-section-toggle:hover { color: var(--accent); }

.pricing-section-body {
  display: none;
  padding: 0 0.25rem 0.625rem;
}

.pricing-section-body.open {
  display: block;
}

.pricing-source-row {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.6875rem;
  color: var(--text-2);
  line-height: 1.5;
}

.pricing-source-row a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.pricing-source-row a:hover { text-decoration: underline; }

/* ── INDICATION PILLS ─────────────────── */
.indication-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.indication-pill {
  background: var(--accent-lt);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.625rem;
  border-radius: 100px;
  border: 1px solid var(--border-accent);
}

/* ── VALUATION HEADLINE ───────────────── */
.val-headline {
  text-align: center;
  margin-bottom: 1rem;
}

.val-headline .val-number {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.val-headline .val-label {
  font-size: 0.75rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.125rem;
}

.val-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.val-metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.75rem;
  text-align: center;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s ease;
}

.val-metric-card:hover {
  box-shadow: var(--shadow-xs), inset 0 0 0 1px rgba(224, 115, 86, 0.12);
}

.val-metric-card .val-metric-num {
  font-family: var(--mono);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.val-metric-card .val-metric-label {
  font-size: 0.6875rem;
  color: var(--text-3);
  margin-top: 0.125rem;
}

/* ── PROGRAM BREAKDOWN ────────────────── */
.program-list {
  margin-bottom: 1.25rem;
}

.program-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}

.program-row:last-child { border-bottom: none; }

.program-name { color: var(--text); font-weight: 500; }
.program-npv { color: var(--text-2); font-family: var(--mono); font-size: 0.8125rem; }

/* ── TORNADO CHART ────────────────────── */
.chart-container {
  width: 100%;
  min-height: 280px;
}

#tornado-chart {
  width: 100%;
  min-height: 280px;
}

.tornado-card { overflow: hidden; }

.tornado-desc {
  font-size: 0.8125rem;
  color: var(--text-2);
  line-height: 1.55;
  margin-bottom: 0.75rem;
}

/* ── PANEL EMPTY STATE ────────────────── */
.panel-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-3);
  font-size: 0.875rem;
}

/* ── MOBILE TOGGLE BUTTON ─────────────── */
.panel-toggle-btn {
  display: none;
}

@media (max-width: 900px) {
  .right-panel {
    position: fixed;
    top: 58px;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    z-index: 20;
    border-left: none;
  }

  .panel-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
  }

  .panel-toggle-btn svg {
    width: 14px;
    height: 14px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 30;
    box-shadow: var(--shadow);
  }

  .sidebar.collapsed {
    box-shadow: none;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 29;
    background: rgba(27, 45, 79, 0.3);
  }

  .sidebar-overlay.visible {
    display: block;
  }
}

/* ── CHAT AREA ────────────────────────── */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.5rem 1.5rem;
  scroll-behavior: smooth;
}

.chat-scroll::-webkit-scrollbar { width: 5px; }
.chat-scroll::-webkit-scrollbar-track { background: transparent; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chat-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.messages {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── EMPTY STATE ──────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1rem;
  gap: 1.25rem;
}

.empty-state > * {
  animation: slideUp 0.5s ease both;
}
.empty-state > *:nth-child(1) { animation-delay: 0.2s; }
.empty-state > *:nth-child(2) { animation-delay: 0.3s; }
.empty-state > *:nth-child(3) { animation-delay: 0.4s; }
.empty-state > *:nth-child(4) { animation-delay: 0.5s; }

.empty-glyph {
  width: 72px;
  height: 72px;
  background: linear-gradient(145deg, rgba(224, 115, 86, 0.08), rgba(36, 59, 99, 0.04));
  border: 1px solid rgba(224, 115, 86, 0.15);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(224, 115, 86, 0.06);
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.empty-state p {
  font-size: 0.9375rem;
  color: var(--text-2);
  line-height: 1.65;
  max-width: 420px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.25rem;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.8125rem;
  padding: 0.45rem 0.875rem;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font);
}

.chip:hover {
  background: rgba(224, 115, 86, 0.06);
  border-color: rgba(224, 115, 86, 0.25);
  color: var(--coral-dk);
  transform: translateY(-1px);
}

/* ── MESSAGE ROWS ─────────────────────── */
.msg-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  animation: fadeUp 0.2s ease both;
}

.msg-row.user { flex-direction: row-reverse; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 3px;
  letter-spacing: 0.03em;
}

.avatar.user {
  background: var(--user-bg);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(27, 58, 107, 0.3);
}

.avatar.ai {
  background: var(--coral-lt);
  color: var(--coral);
  border: 1px solid rgba(224, 115, 86, 0.25);
}

.msg-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.msg-row.user .msg-body { align-items: flex-end; }

.bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--r);
  font-size: 0.9375rem;
  line-height: 1.65;
  word-break: break-word;
  max-width: 88%;
  box-shadow: var(--shadow-xs);
}

.msg-row.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border: 1px solid var(--user-border);
  border-bottom-right-radius: 2px;
}

.msg-row.ai .bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--coral);
  border-bottom-left-radius: 2px;
}

.msg-time {
  font-size: 0.6875rem;
  color: var(--text-3);
  padding: 0 0.25rem;
}

/* ── TYPING INDICATOR ─────────────────── */
.typing-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  border-bottom-left-radius: 2px;
  padding: 0.75rem 1rem;
  display: flex;
  gap: 5px;
  align-items: center;
  width: fit-content;
  box-shadow: var(--shadow-xs);
}

.dot {
  width: 7px;
  height: 7px;
  background: var(--text-3);
  border-radius: 50%;
  animation: bounce 1.3s infinite ease-in-out;
}

.dot:nth-child(2) { animation-delay: 0.18s; }
.dot:nth-child(3) { animation-delay: 0.36s; }

.typing-status {
  font-size: 0.8125rem;
  color: var(--text-2);
  margin-left: 0.5rem;
  font-style: italic;
}

/* ── INPUT AREA ───────────────────────── */
.input-area {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.875rem 1.5rem 1rem;
  flex-shrink: 0;
  box-shadow: 0 -2px 12px rgba(27, 45, 79, 0.04);
}

.input-wrap {
  max-width: 760px;
  margin: 0 auto;
}

.error-bar {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err);
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-sm);
  margin-bottom: 0.625rem;
  display: none;
}

.error-bar.visible { display: block; }

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 0.625rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 0.5rem 0.625rem 0.5rem 0.875rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-2);
}

textarea#msg {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.5;
  min-height: 22px;
  max-height: 150px;
  overflow-y: auto;
  padding: 0.125rem 0;
}

textarea#msg::placeholder { color: var(--text-3); }

.send-btn {
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--r-sm);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.send-btn:hover:not(:disabled) { background: var(--accent-dk); transform: scale(1.06); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.input-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.375rem;
}

.hint {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-3);
  letter-spacing: 0.01em;
}

/* ── MARKDOWN STYLES (inside .bubble) ──── */
.bubble p              { margin-bottom: 0.55em; }
.bubble p:last-child   { margin-bottom: 0; }
.bubble strong         { font-weight: 650; }
.bubble em             { font-style: italic; }
.bubble ul, .bubble ol { padding-left: 1.25rem; margin: 0.35rem 0; }
.bubble li             { margin-bottom: 0.25rem; }

.bubble code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 0.1em 0.3em;
  border-radius: var(--r-sm);
}

.msg-row.user .bubble code {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.bubble pre {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.75rem;
  overflow-x: auto;
  margin: 0.5rem 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.bubble h1 { font-size: 1.125em; font-weight: 700; margin: 0.5rem 0 0.25rem; letter-spacing: -0.01em; }
.bubble h2 { font-size: 1.0625em; font-weight: 650; margin: 0.5rem 0 0.25rem; letter-spacing: -0.01em; }
.bubble h3, .bubble h4 {
  font-weight: 650;
  margin: 0.5rem 0 0.25rem;
  letter-spacing: -0.01em;
}
.bubble h3 { font-size: 1em; }
.bubble h4 { font-size: 0.9375em; }

.bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.75rem 0;
}

.bubble table { border-collapse: collapse; width: 100%; margin: 0.5rem 0; font-size: 0.875em; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 0.35rem 0.65rem; text-align: left; }
.bubble th { background: var(--bg-2); font-weight: 650; }

/* ── DOWNLOAD BAR ─────────────────────── */
.download-bar {
  max-width: 760px;
  margin: 0 auto 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.125rem;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #FFFFFF;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.4rem 0.875rem;
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: background 0.15s ease;
  box-shadow: var(--shadow-xs);
}

.download-btn:hover { background: var(--accent-dk); }

/* ── MODEL DETAIL TABLES ──────────────── */
.detail-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  border: none;
  border-radius: var(--r-sm);
  padding: 0.5rem 1rem;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: #FFFFFF;
  cursor: pointer;
  margin-top: 1rem;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
}

.detail-toggle:hover { background: var(--accent-dk); }
.detail-toggle .arrow { transition: transform 0.2s ease; }
.detail-toggle.open .arrow { transform: rotate(90deg); }

.detail-section { display: none; margin-top: 0.75rem; }
.detail-section.open { display: block; }

.detail-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.detail-table-wrap h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  padding: 0.5rem 0.625rem 0.25rem;
  margin: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.detail-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 0.6875rem;
  font-family: var(--mono);
}

.detail-table th, .detail-table td {
  padding: 0.25rem 0.5rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.detail-table th:first-child, .detail-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
  font-weight: 500;
  min-width: 120px;
}

.detail-table thead th {
  background: var(--bg-2);
  font-weight: 600;
  font-family: var(--font);
  font-size: 0.6875rem;
  color: var(--text-2);
}

.detail-table tbody tr:hover td { background: var(--surface-raised); }
.detail-table tbody tr:hover td:first-child { background: var(--surface-raised); }

/* ── LOGIN OVERLAY ────────────────────── */
#login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 30% 20%, rgba(36, 59, 99, 0.03) 0%, transparent 50%),
                    radial-gradient(ellipse at 70% 80%, rgba(27, 45, 79, 0.04) 0%, transparent 50%);
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: slideUp 0.5s ease 0.1s both;
}

.login-logo {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #2E4A7A, #1B2D4F);
  border-radius: 8px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(36, 59, 99, 0.3);
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-card p {
  color: var(--text-2);
  font-size: 0.9375rem;
  margin-bottom: 2rem;
}

.login-google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.login-google-btn:hover {
  background: var(--surface-raised);
  border-color: var(--text-3);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.login-divider hr { flex: 1; border: none; border-top: 1px solid var(--border); }
.login-divider span { color: var(--text-3); font-size: 0.8125rem; }

.login-input {
  width: 100%;
  padding: 0.6875rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg-2);
  margin-bottom: 0.75rem;
  outline: none;
  font-family: var(--font);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-submit-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font);
}

.login-submit-btn:hover { background: var(--accent-dk); }

#login-error {
  margin-top: 0.875rem;
  font-size: 0.875rem;
  color: var(--err);
  min-height: 1.25rem;
}

/* ── SUBSCRIPTION OVERLAY ─────────────── */
#subscribe-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 30% 20%, rgba(36, 59, 99, 0.03) 0%, transparent 50%),
                    radial-gradient(ellipse at 70% 80%, rgba(27, 45, 79, 0.04) 0%, transparent 50%);
  align-items: center;
  justify-content: center;
}

.subscribe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: slideUp 0.5s ease 0.1s both;
}

.subscribe-card h1 {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.subscribe-card p {
  color: var(--text-2);
  font-size: 0.9375rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.subscribe-price {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.subscribe-price-note {
  color: var(--text-3);
  font-size: 0.8125rem;
  margin-bottom: 1.5rem;
}

.subscribe-btn {
  display: inline-block;
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  margin-bottom: 1rem;
  font-family: var(--font);
}

.subscribe-btn:hover { background: var(--accent-dk); }

.subscribe-signout {
  color: var(--text-3);
  font-size: 0.8125rem;
  cursor: pointer;
  background: none;
  border: none;
  text-decoration: underline;
  font-family: var(--font);
}

.subscribe-signout:hover { color: var(--text-2); }

/* ── WEB CITATIONS ────────────────────── */
.web-citations {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85em;
}

.web-citations strong { font-size: 0.8125rem; color: var(--text-2); }
.web-citations ul { margin: 0.25rem 0 0 1.25rem; padding: 0; }
.web-citations li { margin-bottom: 0.15rem; }
.web-citations a { color: var(--accent); text-decoration: none; }
.web-citations a:hover { text-decoration: underline; }
