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

:root {
  --navy-0: #050508;
  --navy-1: #09090e;
  --navy-2: #0e0e17;
  --navy-3: #11111c;
  --navy-4: #161623;
  --navy-5: #1d1d2e;
  --navy-card: #131320;
  --gold: #0ea5e9;
  --gold-light: #38bdf8;
  --gold-dim: #0284c7;
  --gold-glow: rgba(14, 165, 233, 0.12);
  --gold-border: rgba(14, 165, 233, 0.20);
  --amber: #f59e0b;
  --amber-light: #fbbf24;
  --amber-glow: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.40);
  --white: #ffffff;
  --text-primary: #f2f0ff;
  --text-secondary: #c2c0d4;
  --text-muted: #7a7888;
  --text-body: #c8c6d8;
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(14, 165, 233, 0.35);
  --sidebar-width: 270px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --transition: 0.2s ease;
}

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--navy-1);
  color: var(--text-body);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ── App Shell ── */
.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ─────────────────────────────────────────────
   SIDEBAR
───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--navy-0);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  transition: transform var(--transition);
  z-index: 100;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 16px 18px;
  border-bottom: 1px solid var(--border);
  gap: 0;
  position: relative;
}

/* Close button stays top-left */
.sidebar-header .icon-btn {
  position: absolute;
  top: 14px;
  right: 12px;
}

.logo-link {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  line-height: 1;
}


.logo-text {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  text-align: center;
}

.logo-sub {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-align: center;
}

.sidebar-logo-img {
  max-width: 160px;
  max-height: 60px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sidebar-actions {
  padding: 14px 12px 10px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  background: var(--gold-glow);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  color: var(--gold);
  font-family: 'Inter', sans-serif;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.new-chat-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.new-chat-btn:hover {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(14, 165, 233, 0.45);
}

/* ── Sidebar search ── */
.sidebar-search {
  position: relative;
  padding: 10px 12px 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.sidebar-search-icon {
  position: absolute;
  left: 22px;
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 28px 6px 30px;
  font-size: 0.76rem;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.sidebar-search-input::placeholder { color: var(--text-muted); }
.sidebar-search-input:focus { border-color: var(--border-hover); }

.sidebar-search-clear {
  position: absolute;
  right: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 5px;
  display: none;
}

.sidebar-search-clear.visible { display: block; }

.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.history-section-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 10px 8px 4px;
}

.history-item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--transition), color var(--transition);
}

.history-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.history-item.active {
  background: var(--gold-glow);
  color: var(--gold);
}

.history-empty {
  padding: 16px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── History row with 3-dot menu ── */
.history-row {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  position: relative;
  transition: background var(--transition);
}

.history-row:hover,
.history-row.active {
  background: rgba(255,255,255,0.05);
}

.history-row.active {
  background: var(--gold-glow);
}

.history-row .history-item {
  flex: 1;
  min-width: 0;
  padding: 9px 4px 9px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition);
}

.history-row:hover .history-item,
.history-row.active .history-item { color: var(--text-primary); }
.history-row.active .history-item { color: var(--gold); }

.history-menu-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.45;
  margin-right: 4px;
  transition: opacity var(--transition), color var(--transition), background var(--transition);
}

.history-menu-btn svg { width: 14px; height: 14px; }

.history-row:hover .history-menu-btn,
.history-row.active .history-menu-btn { opacity: 1; }

.history-menu-btn:hover {
  color: var(--gold);
  background: rgba(14, 165, 233, 0.12);
  opacity: 1;
}

/* ── Rename inline input ── */
.history-rename-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  margin: 2px 4px 2px 6px;
  background: var(--navy-4);
  border: 1px solid var(--gold-border);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  outline: none;
  caret-color: var(--gold);
}

/* ── Context menu popup ── */
.conv-menu {
  position: fixed;
  z-index: 999;
  background: var(--navy-3);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 4px;
  min-width: 150px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: fadeSlideUp 0.14s ease forwards;
}

.conv-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.conv-menu-item svg { width: 14px; height: 14px; flex-shrink: 0; }

.conv-menu-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.conv-menu-item.delete:hover {
  background: rgba(180, 60, 60, 0.15);
  color: #e08080;
}

.sidebar-footer {
  padding: 14px 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sidebar-book-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px 14px;
  background: var(--gold-glow);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  color: var(--gold);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'DM Sans', system-ui, sans-serif;
  letter-spacing: 0.02em;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.sidebar-book-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.sidebar-book-link:hover {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(14, 165, 233, 0.45);
  color: var(--gold-light);
}

.sidebar-attribution {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── Sidebar tool buttons ── */
.sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-align: left;
}

.tool-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.tool-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-secondary); }
.tool-btn.active { color: var(--gold); }

.insights-count {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy-1);
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 1px 6px;
  line-height: 1.4;
}

/* ── Local data notice ── */
.local-data-notice {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.62rem;
  color: var(--text-muted);
  opacity: 0.7;
  text-align: center;
  line-height: 1.4;
}

/* ── Shared simple modal (Org + Insights) ── */
.simple-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  backdrop-filter: blur(4px);
}

.simple-overlay.active { display: block; }

.simple-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  width: min(480px, calc(100vw - 32px));
  max-height: 85vh;
  background: var(--navy-3);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  box-shadow: 0 28px 80px rgba(0,0,0,0.7);
  z-index: 201;
  overflow: hidden;
  flex-direction: column;
}

.simple-modal.open {
  display: flex;
  animation: catalystIn 0.22s ease forwards;
}

.simple-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.simple-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.simple-modal-close { font-size: 1.2rem; }

.simple-modal-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.55;
  padding: 14px 20px 0;
  flex-shrink: 0;
}

.simple-modal-form {
  padding: 14px 20px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.simple-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: 'DM Sans', system-ui, sans-serif;
}

.label-optional {
  font-weight: 400;
  color: var(--text-muted);
}

.simple-input, .simple-textarea {
  width: 100%;
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.82rem;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
}

.simple-input::placeholder, .simple-textarea::placeholder { color: var(--text-muted); }
.simple-input:focus, .simple-textarea:focus { border-color: var(--border-hover); }

.simple-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.simple-btn-ghost {
  padding: 7px 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.simple-btn-ghost:hover { border-color: var(--border-hover); color: var(--text-secondary); }

.simple-btn-primary {
  padding: 7px 20px;
  background: var(--gold-glow);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-pill);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.simple-btn-primary:hover { background: rgba(14,165,233,0.2); border-color: rgba(14,165,233,0.4); }

/* ── Insights modal specific ── */
.insights-modal { width: min(560px, calc(100vw - 32px)); }

/* Modal search bar (Insights + Assumption Register) */
.modal-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--border);
}

.modal-search-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.modal-search-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  padding: 4px 0;
}
.modal-search-input::placeholder { color: var(--text-muted); }

.modal-search-clear {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}
.modal-search-clear:hover { color: var(--text-primary); }
.modal-search-clear.visible { display: block; }

.insights-list {
  overflow-y: auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-group { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }

.insight-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--navy-card);
  cursor: pointer;
  user-select: none;
  gap: 8px;
  transition: background 0.15s;
}

.insight-group-header:hover { background: var(--navy-4); }

.insight-group-title {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-group-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.insight-group-count {
  font-size: 0.62rem;
  color: var(--text-muted);
  background: var(--navy-2);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
}

.insight-group-chevron {
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.insight-group.open .insight-group-chevron { transform: rotate(180deg); }

.insight-group-body {
  display: none;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
}

.insight-group.open .insight-group-body { display: flex; }

.insight-card {
  background: var(--navy-card);
  border: none;
  border-radius: 0;
  padding: 12px 14px;
}

.insight-card:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }

.insights-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.insight-card {
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.insight-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  gap: 8px;
}

.insight-card-source {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insight-card-date {
  font-size: 0.62rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.insight-card-body {
  font-size: 0.8rem;
  color: var(--text-body);
  line-height: 1.55;
  max-height: 120px;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
  white-space: pre-wrap;
}

.insight-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.insight-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: 'Inter', system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.insight-action-btn svg { width: 11px; height: 11px; }
.insight-action-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-secondary); border-color: var(--border-hover); }
.insight-action-btn.delete:hover { color: #e08080; border-color: rgba(180,60,60,0.4); }

/* ── Save insight button (in message actions) ── */
.save-insight-btn.saved { color: var(--gold); }

/* ── #closeSidebar — hide on desktop ── */
#closeSidebar { display: none; }

/* ─────────────────────────────────────────────
   MAIN CONTENT
───────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  min-width: 0;
}

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--navy-1);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

#openSidebar { display: none; }



.top-bar-title {
  flex: 1;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--gold); background: var(--gold-glow); }

/* ─────────────────────────────────────────────
   WELCOME SCREEN
───────────────────────────────────────────── */
.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 24px 24px;
}

.welcome-screen.hidden { display: none; }

.welcome-content {
  max-width: 700px;
  width: 100%;
  text-align: center;
}

.welcome-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  background: var(--gold-glow);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-pill);
  padding: 6px 18px;
  margin-bottom: 10px;
}

.welcome-version {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  opacity: 0.6;
}

.welcome-badge-sub {
  display: none;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.welcome-badge-sub:not(:empty) { display: block; }

.welcome-heading {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  color: var(--white);
  margin-bottom: 16px;
  line-height: 1.15;
}

.welcome-sub {
  font-size: 1rem;
  color: var(--text-body);
  line-height: 1.7;
  max-width: 560px;
  margin: 0 auto 36px;
}

/* ── Prompt grid ── */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
}

.prompt-card {
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 18px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), transform var(--transition), background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'Inter', sans-serif;
}

.prompt-card:hover {
  border-color: var(--gold-border);
  background: var(--navy-4);
  transform: translateY(-2px);
}

.prompt-icon {
  display: flex;
  color: var(--gold);
  margin-bottom: 2px;
}

.prompt-icon svg { width: 18px; height: 18px; }

.prompt-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.prompt-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─────────────────────────────────────────────
   CHAT THREAD
───────────────────────────────────────────── */
.chat-thread {
  flex: 1;
  overflow-y: auto;
  display: none;
  padding: 24px 0 8px;
  scroll-behavior: smooth;
}

.chat-thread.visible { display: block; }

.messages {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Message row ── */
.message-row {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.message-row + .message-row { margin-top: 20px; }

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

.user-bubble {
  max-width: 70%;
  background: var(--navy-4);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  padding: 13px 17px;
  font-size: 0.93rem;
  line-height: 1.65;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── AI message ── */
.ai-message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-glow);
  border: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-avatar svg { width: 15px; height: 15px; color: var(--gold); }

.ai-content {
  flex: 1;
  min-width: 0;
}

.ai-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.ai-bubble {
  font-size: 0.93rem;
  line-height: 1.75;
  color: var(--text-body);
  word-break: break-word;
}

/* ── Markdown rendering ── */
.ai-bubble p { margin-bottom: 0.9em; }
.ai-bubble p:last-child { margin-bottom: 0; }

.ai-bubble h1, .ai-bubble h2, .ai-bubble h3 {
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--text-primary);
  margin: 1.1em 0 0.4em;
  line-height: 1.3;
}

.ai-bubble h1 { font-size: 1.25rem; }
.ai-bubble h2 { font-size: 1.1rem; }
.ai-bubble h3 { font-size: 0.98rem; }

.ai-bubble strong { color: var(--text-primary); font-weight: 600; }
.ai-bubble em { color: var(--gold-light); font-style: italic; }

.book-cite-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--gold);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.88em;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(var(--gold-rgb, 212,175,55), 0.08);
  border: 1px solid rgba(var(--gold-rgb, 212,175,55), 0.2);
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.book-cite-link:hover {
  background: rgba(var(--gold-rgb, 212,175,55), 0.15);
  border-color: rgba(var(--gold-rgb, 212,175,55), 0.35);
}

.ai-bubble ul, .ai-bubble ol {
  padding-left: 1.3em;
  margin: 0.5em 0 0.9em;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}

.ai-bubble ul { list-style: none; }
.ai-bubble ul li { position: relative; padding-left: 0.2em; }
.ai-bubble ul li::before {
  content: '›';
  color: var(--gold);
  position: absolute;
  left: -1.1em;
  font-weight: 700;
}

.ai-bubble ol { list-style: decimal; }
.ai-bubble ol li::marker { color: var(--gold); font-weight: 600; }

.ai-bubble blockquote {
  border-left: 3px solid var(--gold);
  padding: 8px 16px;
  margin: 0.8em 0;
  background: var(--navy-4);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-primary);
}

/* ── Inline code ── */
.ai-bubble code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.83em;
  background: rgba(255,255,255,0.07);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--gold-light);
}

/* ── Fenced code blocks (from marked, before post-process) ── */
.ai-bubble pre {
  background: var(--navy-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0.8em 0;
}

.ai-bubble pre code {
  background: none;
  padding: 0;
  font-size: 0.81rem;
  color: var(--text-body);
}

/* ── Enhanced code block (post-processed) ── */
.ai-bubble .code-block {
  background: var(--navy-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 0.9em 0;
  font-size: 0.81rem;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-dim);
  font-family: 'Inter', sans-serif;
}

.code-copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 9px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.code-copy-btn:hover {
  color: var(--gold);
  border-color: var(--gold-border);
  background: var(--gold-glow);
}

.ai-bubble .code-block pre {
  background: none;
  border: none;
  border-radius: 0;
  padding: 14px 16px;
  margin: 0;
  overflow-x: auto;
}

.ai-bubble .code-block pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.81rem;
  background: none;
  padding: 0;
  color: var(--text-body);
}

/* ── Override highlight.js theme to match app ── */
.hljs { background: transparent !important; }

/* ── Mermaid diagrams ── */
.mermaid-wrap {
  margin: 0.9em 0;
  background: var(--navy-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  overflow-x: auto;
}

.mermaid-render svg {
  max-width: 100%;
  height: auto;
}

/* ── Inline SVG ── */
.svg-wrap {
  margin: 0.9em 0;
  background: var(--navy-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  overflow-x: auto;
}

.svg-wrap svg {
  max-width: 100%;
  height: auto;
}

/* ── Tables ── */
.ai-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.88rem;
  overflow-x: auto;
  display: block;
}

.ai-bubble thead tr {
  background: var(--navy-3);
  border-bottom: 2px solid var(--gold-border);
}

.ai-bubble th {
  padding: 9px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'DM Sans', system-ui, sans-serif;
  white-space: nowrap;
}

.ai-bubble td {
  padding: 8px 14px;
  color: var(--text-body);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.ai-bubble tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ai-bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.2em 0;
}

.ai-bubble a { color: var(--gold); text-decoration: none; }
.ai-bubble a:hover { text-decoration: underline; }

/* ── Message actions ── */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}

.ai-message:hover .message-actions,
.message-actions:focus-within { opacity: 1; }

.action-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.action-btn svg { width: 13px; height: 13px; }
.action-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--gold-glow);
}

.action-btn.copied { color: var(--gold); }

.token-stats {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  font-size: 0.69rem;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}

/* ── Typing indicator ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 0 4px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0.6;
  animation: typingPulse 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
  0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
  40% { transform: scale(1.3); opacity: 1; }
}

/* ── Streaming cursor ── */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--gold);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.8s ease-in-out infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Error message ── */
.error-message {
  background: rgba(180, 60, 60, 0.1);
  border: 1px solid rgba(200, 80, 80, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: #e08080;
  margin: 8px 0;
}

/* ─────────────────────────────────────────────
   INPUT AREA
───────────────────────────────────────────── */
.input-area {
  flex-shrink: 0;
  padding: 14px 24px 16px;
  background: var(--navy-1);
  border-top: 1px solid var(--border);
}

/* ── Toolbar mode buttons (Search Web + Challenger) ── */
.toolbar-modes {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  line-height: 1;
}

.mode-btn:hover {
  border-color: var(--border);
  color: var(--text-secondary);
}

/* Challenger active */
.mode-btn.active-challenger {
  border-color: var(--amber-border);
  background: rgba(245, 158, 11, 0.05);
  color: var(--amber);
}

/* Search Web active */
.mode-btn.active-search {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.06);
  color: #10b981;
}

/* ─────────────────────────────────────────────
   GENERIC TOOLTIP UTILITY  (.tip)
   Add class="tip" + data-tooltip="..." to any element.
   Modifier: .tip-right  → tooltip opens to the right (sidebar buttons)
             .tip-above  → tooltip opens above, left-aligned (default)
───────────────────────────────────────────── */
.tip { position: relative; }

.tip[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  width: 210px;
  background: var(--navy-3);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 8px 11px;
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.5;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 300;
  white-space: normal;
}
.tip[data-tooltip]:hover::after { opacity: 1; }

/* Right-opening variant — for sidebar buttons near left edge */
.tip.tip-right[data-tooltip]::after {
  bottom: auto;
  top: 50%;
  left: calc(100% + 10px);
  transform: translateY(-50%);
}

/* ── Toolbar tooltips ── */
.length-toggle[data-tooltip] { position: relative; }

.length-toggle[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 230px;
  background: var(--navy-3);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.5;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 50;
  white-space: normal;
}

.length-toggle[data-tooltip]:hover::after { opacity: 1; }

.input-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 780px;
  margin: 0 auto;
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 10px 8px 18px;
  transition: border-color 0.2s;
}

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Response length toggle ── */
.length-toggle {
  display: flex;
  align-items: center;
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px;
}

.length-btn {
  background: none;
  border: none;
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  font-size: 0.68rem;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.length-btn:hover { color: var(--text-secondary); }

.length-btn.active {
  background: var(--navy-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.input-wrapper:focus-within {
  border-color: var(--gold-border);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.08);
}

.input-wrapper.challenger-active {
  border-color: rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12), 0 0 18px 2px rgba(245, 158, 11, 0.15);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.input-wrapper.challenger-active:focus-within {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18), 0 0 24px 4px rgba(245, 158, 11, 0.2);
}

.input-wrapper.search-active {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1), 0 0 18px 2px rgba(16, 185, 129, 0.12);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.input-wrapper.search-active:focus-within {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18), 0 0 24px 4px rgba(16, 185, 129, 0.18);
}

/* Typing stage label (shown during search pipeline steps) */
.typing-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-left: 6px;
  vertical-align: middle;
}

.user-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.93rem;
  color: var(--text-primary);
  resize: none;
  line-height: 1.55;
  max-height: 180px;
  overflow-y: auto;
  caret-color: var(--gold);
  padding: 2px 0;
}

.user-input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--gold);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
}

.send-btn svg { width: 16px; height: 16px; color: var(--navy-0); }

.send-btn:hover:not(:disabled) {
  background: var(--gold-light);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: var(--navy-5);
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Daily token bar ── */
.token-bar-wrap {
  max-width: 780px;
  margin: 10px auto 0;
}

.token-bar {
  height: 3px;
  background: var(--navy-4);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.token-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  border-radius: var(--radius-pill);
  transition: width 0.5s ease, background 0.4s ease;
}

.token-bar-fill.near-limit  { background: var(--amber); }
.token-bar-fill.at-limit    { background: #e05555; }

.token-bar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.token-bar-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  opacity: 0.65;
}

.token-lock-msg {
  display: none;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--amber);
  letter-spacing: 0.02em;
}

.token-lock-msg.visible { display: block; }

/* Lock Brief only when at limit */
.length-toggle.limit-locked .length-btn:not([data-length="brief"]) {
  opacity: 0.25;
  pointer-events: none;
  cursor: default;
}

.length-toggle.limit-locked .length-btn[data-length="brief"] {
  color: var(--amber);
}

.input-disclaimer {
  max-width: 780px;
  margin: 8px auto 0;
  font-size: 0.71rem;
  color: var(--text-secondary);
  text-align: center;
  opacity: 0.8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.model-badge-inline {
  display: none;
  font-size: 0.63rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  white-space: nowrap;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.model-badge-inline:not(:empty) { display: inline-block; }

.input-disclaimer a {
  color: var(--gold-dim);
  text-decoration: none;
}

.input-disclaimer a:hover { text-decoration: underline; }

/* Co-pilot footer (copyright + terms) */
.copilot-footer {
  max-width: 780px;
  margin: 4px auto 0;
  font-size: 0.67rem;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.7;
}
.copilot-footer a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  transition: color 0.15s, border-color 0.15s;
}
.copilot-footer a:hover { color: var(--text-secondary); border-color: rgba(255,255,255,0.35); }

/* Terms modal */
.terms-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1800;
}
.terms-overlay.active { display: block; }
.terms-modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, 92vw);
  max-height: 80vh;
  background: var(--navy-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 1801;
  flex-direction: column;
  overflow: hidden;
}
.terms-modal.active { display: flex; }
.terms-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.terms-modal-title {
  font-size: 0.9rem; font-weight: 700; color: var(--text-primary);
}
.terms-close-btn {
  font-size: 1.2rem; line-height: 1; padding: 2px 6px;
  color: var(--text-muted); background: none; border: none; cursor: pointer;
}
.terms-close-btn:hover { color: var(--text-primary); }
.terms-modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-secondary);
}
.terms-modal-body h1, .terms-modal-body h2, .terms-modal-body h3 {
  color: var(--text-primary); margin: 1.1em 0 0.4em; font-size: 0.88rem;
}
.terms-modal-body strong { color: var(--text-primary); }
.terms-modal-body p { margin: 0 0 0.8em; }

/* ─────────────────────────────────────────────
   MOBILE OVERLAY
───────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

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

/* ─────────────────────────────────────────────
   LIBRARY BUTTON (sidebar)
───────────────────────────────────────────── */
.library-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 14px;
  margin-top: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.library-btn svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--gold); }
.library-btn:hover {
  background: var(--gold-glow);
  border-color: var(--gold-border);
  color: var(--gold);
}

/* ─────────────────────────────────────────────
   AI CATALYST MODAL (split: left nav + right wizard)
───────────────────────────────────────────── */
.catalyst-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  backdrop-filter: blur(4px);
}

.catalyst-overlay.active { display: block; }

.catalyst-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  width: min(820px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 56px));
  background: var(--navy-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  z-index: 201;
  box-shadow: 0 28px 80px rgba(0,0,0,0.7);
  flex-direction: row;
  overflow: hidden;
}

.catalyst-modal.open {
  display: flex;
  animation: catalystIn 0.22s ease forwards;
}

@keyframes catalystIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.98); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── Left: prompt navigation ── */
.catalyst-left {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--navy-0);
  overflow: hidden;
}

.catalyst-left-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

.library-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.library-icon {
  width: 28px;
  height: 28px;
  background: var(--gold-glow);
  border: 1px solid var(--gold-border);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--gold);
}

.library-icon svg { width: 13px; height: 13px; }

.library-title {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1px;
  white-space: nowrap;
}

.library-subtitle {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.catalyst-close-btn {
  font-size: 1.3rem;
  line-height: 1;
  padding: 3px 7px;
  flex-shrink: 0;
}

.library-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px 16px;
}

/* ── Right: wizard panel ── */
.catalyst-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--navy-2);
}

/* ── Phase dropdown selector ── */
.phase-selector {
  position: relative;
  padding: 8px 8px 4px;
}

.phase-selector-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 13px;
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s;
  text-align: left;
  gap: 8px;
}

.phase-selector-trigger:hover { border-color: var(--border-hover); }
.phase-selector-trigger svg { flex-shrink: 0; transition: transform 0.2s; }
.phase-selector-trigger.open svg { transform: rotate(180deg); }

.phase-selector-menu {
  position: absolute;
  top: calc(100% - 4px);
  left: 8px;
  right: 8px;
  background: var(--navy-3);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  overflow: hidden;
  z-index: 30;
  box-shadow: 0 8px 28px rgba(0,0,0,0.6);
}

.phase-selector-menu.hidden { display: none; }

.phase-selector-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 13px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.phase-selector-item:last-child { border-bottom: none; }
.phase-selector-item:hover { background: var(--navy-4); color: var(--text-primary); }
.phase-selector-item.active { color: var(--gold); }

.phase-count {
  font-size: 0.62rem;
  color: var(--text-muted);
  background: var(--navy-2);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
  flex-shrink: 0;
}

/* ── Pinned section ── */
.library-phase-group { margin-bottom: 4px; }

.library-phase-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 5px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.library-phase-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Phase-filtered prompt list ── */
#phasePromptList { padding-top: 4px; }

/* ── Compact nav item in left panel ── */
.library-card {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 7px 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background var(--transition), border-color var(--transition);
}

.library-card:hover {
  background: var(--navy-card);
  border-color: var(--border);
}

.library-card.active {
  background: var(--navy-card);
  border-color: var(--gold-border);
}

.library-card-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  font-size: 0.54rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--gold-glow);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  white-space: nowrap;
  margin-bottom: 3px;
}

.library-card-badge.guided {
  background: rgba(99,102,241,0.12);
  border-color: rgba(99,102,241,0.25);
  color: #a5b4fc;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.library-card-content { display: block; flex: 1; min-width: 0; }

/* ── Prompt pin button ── */
.library-card-pin {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 2px 3px;
  cursor: pointer;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  line-height: 1;
  margin-top: 1px;
}

.library-card:hover .library-card-pin,
.library-card-pin.pinned { opacity: 1; }

.library-card-pin.pinned { color: var(--gold); }

.library-phase-group.pinned-group .library-phase-label { color: var(--gold); }

.library-card-title {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}

.library-card-tagline { display: none; }
.library-card-arrow   { display: none; }

/* ── Wizard empty state ── */
.wizard-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
  padding: 40px;
  text-align: center;
}

.wizard-empty svg {
  width: 36px;
  height: 36px;
  opacity: 0.3;
}

.wizard-empty p {
  font-size: 0.83rem;
  line-height: 1.6;
  max-width: 200px;
}

.wizard-empty.hidden { display: none; }

/* ── Wizard body (right panel content) ── */
.wizard-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.wizard-body.hidden { display: none; }

/* ── Wizard info block (badge + title + desc) ── */
.wizard-header-info {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.wizard-phase-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  background: var(--gold-glow);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  margin-bottom: 6px;
}

.wizard-title {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.wizard-description {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 6px;
}

.wizard-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.wizard-fields {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Wizard field ── */
.wizard-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.wizard-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.wizard-label .required-star {
  color: var(--gold);
  margin-left: 2px;
}

.wizard-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: -2px;
}

.wizard-input,
.wizard-textarea {
  background: var(--navy-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  line-height: 1.5;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  caret-color: var(--gold);
  width: 100%;
}

.wizard-input::placeholder,
.wizard-textarea::placeholder { color: var(--text-muted); }

.wizard-input:focus,
.wizard-textarea:focus {
  border-color: var(--gold-border);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.08);
}

.wizard-input.invalid,
.wizard-textarea.invalid {
  border-color: rgba(200, 80, 80, 0.5);
}

.wizard-textarea {
  resize: vertical;
  min-height: 72px;
}

/* ── Preview ── */
.wizard-preview-wrap {
  padding: 0 22px 8px;
  flex-shrink: 0;
}

.wizard-preview-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 6px 0;
  transition: color var(--transition);
}

.wizard-preview-toggle:hover { color: var(--gold); }

.wizard-preview {
  display: none;
  background: var(--navy-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: 'Courier New', monospace;
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
  margin-top: 6px;
}

.wizard-preview.visible { display: block; }

/* ── Actions ── */
.wizard-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}

.wizard-submit-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--gold);
  border: none;
  border-radius: var(--radius-md);
  color: var(--navy-0);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.wizard-submit-btn:hover {
  background: var(--gold-light);
  transform: scale(1.02);
}

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────────────────
   AUTH GATE
───────────────────────────────────────────── */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-1);
  padding: 24px;
  transition: opacity 0.3s ease;
}

.auth-gate.hidden {
  opacity: 0;
  pointer-events: none;
}

.auth-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  max-width: 380px;
  width: 100%;
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px 32px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-logo img {
  width: 52px;
  height: auto;
}

.auth-badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-glow);
  border: 1px solid var(--gold-border);
  border-radius: 20px;
  padding: 3px 12px;
}

.auth-title {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.auth-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 300px;
}

.auth-btn-wrap {
  margin-top: 4px;
}

.auth-error {
  font-size: 0.8rem;
  color: #f87171;
  min-height: 1.2em;
}

.auth-notice {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  width: 100%;
}

/* ── Sidebar user row ── */
.top-bar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Admin preview tier row */
.preview-tier-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  width: 100%;
}

.preview-tier-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.7;
}

.preview-tier-select {
  font-size: 0.7rem;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  color: #f87171;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  flex: 1;
}

.preview-tier-select:focus { outline: none; border-color: rgba(239,68,68,0.5); }

.sidebar-user-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.tier-badge {
  font-size: 0.62rem;
  font-weight: 600;
  font-family: 'DM Sans', system-ui, sans-serif;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
  line-height: 1.4;
}
.tier-badge:hover { opacity: 0.75; }

.tier-badge.tier-free {
  color: var(--text-secondary);
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
}
.tier-badge.tier-practitioner {
  color: var(--gold);
  border-color: var(--gold-border);
  background: var(--gold-glow);
}
.tier-badge.tier-enterprise {
  color: var(--amber);
  border-color: var(--amber-border);
  background: var(--amber-glow);
}
.tier-badge.tier-admin {
  color: #fff;
  border-color: rgba(239,68,68,0.5);
  background: rgba(239,68,68,0.18);
}

.sidebar-signout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.sidebar-signout:hover { color: var(--text-secondary); border-color: rgba(255,255,255,0.2); }

/* ── Feature locked/gated state ── */
.feature-locked {
  opacity: 0.38 !important;
  cursor: pointer !important;
  position: relative;
}
.feature-locked:hover { opacity: 0.55 !important; }
.lock-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  font-size: 0.72em;
  vertical-align: middle;
  pointer-events: none;
  line-height: 1;
}
/* Prevent toggling active state on locked toolbar buttons */
.feature-locked.active-challenger,
.feature-locked.active-search { background: none !important; }
/* Locked sidebar-search wrapper */
.sidebar-search.feature-locked input { pointer-events: none; }

/* ── Onboarding Modal ── */
.onboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.82);
  backdrop-filter: blur(6px);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.onboard-overlay.visible { opacity: 1; pointer-events: all; }

.onboard-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: min(520px, calc(100vw - 32px));
  background: var(--navy-3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  z-index: 901;
  padding: 32px 36px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.onboard-modal.visible {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}

.onboard-progress {
  display: flex;
  gap: 7px;
  justify-content: center;
  margin-bottom: 28px;
}
.onboard-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: background 0.2s, width 0.2s;
}
.onboard-dot.active {
  background: var(--gold);
  width: 22px;
  border-radius: 4px;
}

.onboard-step {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  min-height: 230px;
}
.onboard-step.active { display: flex; }

.onboard-icon {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  background: var(--navy-2);
  border: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.onboard-icon--catalyst { color: var(--gold); }
.onboard-icon--context  { color: #a78bfa; }
.onboard-icon--insights { color: #fbbf24; }

.onboard-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.onboard-body {
  font-size: 0.88rem;
  color: var(--text-body);
  line-height: 1.65;
  max-width: 400px;
}
.onboard-body strong { color: var(--text-secondary); font-weight: 600; }
.onboard-body em { color: var(--text-muted); font-style: italic; }

.onboard-action-btn {
  margin-top: 4px;
  background: none;
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s;
}
.onboard-action-btn:hover { background: var(--gold-glow); }

.onboard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.onboard-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 6px;
  transition: color 0.15s;
}
.onboard-skip:hover { color: var(--text-secondary); }

.onboard-nav { display: flex; gap: 8px; }

.onboard-back {
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color 0.15s;
  visibility: hidden;
}
.onboard-back.visible { visibility: visible; }
.onboard-back:hover { border-color: rgba(255,255,255,0.25); }

.onboard-next {
  background: var(--gold);
  border: none;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: opacity 0.15s;
}
.onboard-next:hover { opacity: 0.88; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  .sidebar.open { transform: translateX(0); }

  #closeSidebar { display: flex; }
  #openSidebar { display: flex; }

  .prompt-grid { grid-template-columns: 1fr; }

  .top-bar {
    padding: 10px 14px;
  }

  .welcome-screen { padding: 30px 16px 16px; }

  .input-area { padding: 10px 12px 14px; }
  .input-wrapper { padding: 10px 8px 6px 14px; }

  .messages { padding: 0 14px; }

  .user-bubble { max-width: 88%; }
}

@media (max-width: 600px) {
  .catalyst-modal {
    flex-direction: column;
    height: calc(100dvh - 32px);
    width: calc(100vw - 24px);
  }
  .catalyst-left {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .library-body { padding: 6px 8px; }
  .library-card { padding: 6px 8px; }
}

@media (max-width: 480px) {
  .welcome-heading { font-size: 1.7rem; }
  .welcome-sub { font-size: 0.9rem; }
  .prompt-card { padding: 14px; }
}

/* ─────────────────────────────────────────────
   ANIMATIONS
───────────────────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row {
  animation: fadeSlideUp 0.22s ease forwards;
}

.welcome-content {
  animation: fadeSlideUp 0.35s ease forwards;
}

/* ── Thinking / loading state for send btn ── */
.send-btn.loading {
  pointer-events: none;
}

.send-btn.loading svg {
  animation: spinOnce 0.6s linear infinite;
}

@keyframes spinOnce {
  to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────
   UFF PHASE TRACKER
───────────────────────────────────────────── */
.uff-phase-tracker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 22px;
  flex-wrap: wrap;
  justify-content: center;
}

.uff-pt-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.uff-pt-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.uff-pt-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
  user-select: none;
}

.uff-pt-pill:hover {
  border-color: rgba(255,255,255,0.18);
  color: var(--text-secondary);
}

.uff-pt-pill.active {
  background: var(--gold-glow);
  border-color: var(--gold-border);
  color: var(--gold);
}

.uff-pt-pill.selected {
  background: var(--navy-4);
  border-color: rgba(255,255,255,0.22);
  color: var(--text-primary);
}

.uff-pt-pill.active.selected {
  background: var(--gold-glow);
  border-color: var(--gold-border);
  color: var(--gold);
}

.uff-pt-arrow {
  font-size: 0.75rem;
  color: var(--border);
  user-select: none;
}

/* ─────────────────────────────────────────────
   UFF CIRCULAR DIAGRAM
───────────────────────────────────────────── */
.uff-diagram {
  display: block;
  max-width: 400px;
  width: 100%;
  margin: 20px auto 0;
}

.uff-svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.uff-node {
  cursor: pointer;
  outline: none;
}

.uff-node .uff-node-bg {
  fill: var(--navy-5);
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1.5;
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.uff-node:hover .uff-node-bg,
.uff-node:focus-visible .uff-node-bg {
  fill: var(--gold-glow);
  stroke: var(--gold-border);
}

.uff-phase.active .uff-node-bg {
  fill: var(--gold-glow);
  stroke: var(--gold-border);
}

.uff-diagram-label {
  font-family: 'Inter', sans-serif;
  pointer-events: none;
  transition: fill 0.2s ease;
}

.uff-label-main {
  font-size: 9.5px;
  font-weight: 600;
  fill: var(--text-secondary);
}

.uff-label-sub {
  font-size: 8.5px;
  fill: var(--text-muted);
}

.uff-phase-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  fill: var(--text-muted);
  pointer-events: none;
  transition: fill 0.2s ease;
}

.uff-phase.active .uff-phase-label {
  fill: var(--gold);
}

.uff-node:hover .uff-phase-label,
.uff-node:focus-visible .uff-phase-label {
  fill: var(--gold);
}

.uff-node:hover .uff-label-main,
.uff-node:focus-visible .uff-label-main {
  fill: var(--gold-light);
}

/* ─────────────────────────────────────────────
   INSIGHT FILTER TABS
───────────────────────────────────────────── */
.insight-filter-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
}

.insight-filter-tab {
  padding: 6px 14px 8px;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.insight-filter-tab:hover { color: var(--text-primary); }
.insight-filter-tab.active {
  color: var(--gold, #0ea5e9);
  border-bottom-color: var(--gold, #0ea5e9);
}

/* ─────────────────────────────────────────────
   ASSUMPTION BUTTON + INSIGHT TYPE BADGES
───────────────────────────────────────────── */
.save-assumption-btn {
  color: var(--text-muted);
}
.save-assumption-btn.saved {
  color: #f59e0b;
}

.insight-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 10px;
  margin-bottom: 4px;
}
.insight-type-badge.assumption {
  background: rgba(245,158,11,0.12);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.25);
}
.insight-type-badge.wrapup {
  background: rgba(14,165,233,0.1);
  color: var(--gold, #0ea5e9);
  border: 1px solid var(--gold-border, rgba(14,165,233,0.25));
}

/* ─────────────────────────────────────────────
   MARKDOWN IN INSIGHT / ASSUMPTION CARDS
───────────────────────────────────────────── */
.insight-md { font-size: 0.82rem; line-height: 1.55; color: var(--text-body); }
.insight-md p { margin: 0 0 6px; }
.insight-md p:last-child { margin-bottom: 0; }
.insight-md ul, .insight-md ol { margin: 4px 0 6px 16px; }
.insight-md li { margin-bottom: 2px; }
.insight-md strong { color: var(--text-primary); }
.insight-md h1, .insight-md h2, .insight-md h3 { font-size: 0.85rem; font-weight: 600; margin: 6px 0 4px; color: var(--text-primary); }
.insight-md code { font-size: 0.78rem; background: var(--navy-4); padding: 1px 5px; border-radius: 4px; }

/* ─────────────────────────────────────────────
   ASSUMPTION STATUS BADGES
───────────────────────────────────────────── */
.assumption-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.assumption-status.untested {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
  color: var(--text-muted);
}
.assumption-status.untested:hover {
  border-color: rgba(255,255,255,0.2);
  color: var(--text-secondary);
}
.assumption-status.confirmed {
  background: rgba(34,197,94,0.12);
  border-color: rgba(34,197,94,0.28);
  color: #4ade80;
}
.assumption-status.invalidated {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.28);
  color: #f87171;
}

.insight-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

/* ─────────────────────────────────────────────
   SESSION WRAP-UP BANNER
───────────────────────────────────────────── */
.wrap-up-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  margin-bottom: 4px;
  background: rgba(14,165,233,0.08);
  border: 1px solid var(--gold-border, rgba(14,165,233,0.2));
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gold, #0ea5e9);
}

/* ─────────────────────────────────────────────
   BOOK READER MODAL
───────────────────────────────────────────── */
.book-reader-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 600;
}
.book-reader-overlay.active { display: block; }

.book-reader-modal {
  display: none;
  flex-direction: column;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(94vw, 1200px);
  height: min(90vh, 880px);
  background: var(--navy-900, #0f1a2e);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  z-index: 601;
  overflow: hidden;
  animation: catalystIn 0.22s ease forwards;
}
.book-reader-modal.active { display: flex; }

/* ── Header ── */
.book-reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.book-reader-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.book-reader-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.15s;
}
.book-reader-close:hover { color: var(--text-primary); }

/* ── Body (TOC + viewer side by side) ── */
.book-reader-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* TOC sidebar */
.book-reader-toc {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--navy-1);
  padding: 8px 0;
}

/* TOC search */
.book-toc-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
}

.book-toc-search-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.book-toc-search-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
}
.book-toc-search-input::placeholder { color: var(--text-muted); }

.book-toc-search-clear {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}
.book-toc-search-clear:hover { color: var(--text-primary); }
.book-toc-search-clear.visible { display: block; }

/* TOC header */
.book-toc-header {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px 6px;
}

/* Search results */
.book-search-results {
  flex: 1;
  overflow-y: auto;
}

.book-search-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 8px 14px 4px;
}

.book-search-result {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
}
.book-search-result:hover { background: rgba(255,255,255,0.05); }

.book-search-result-chapter {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-search-result-excerpt {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary, #8fa0bc);
  line-height: 1.45;
  /* show up to 3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-search-result-excerpt mark {
  background: rgba(14,165,233,0.25);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.book-toc-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--text-secondary, #8fa0bc);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  line-height: 1.35;
  border-radius: 0;
  transition: background 0.12s, color 0.12s;
}
.book-toc-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}
.book-toc-item.active {
  color: var(--gold);
  background: rgba(var(--gold-rgb, 14,165,233), 0.08);
}
.book-toc-item-num {
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 1.5ch;
}
.book-toc-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 14px;
}

/* EPUB viewer */
.book-reader-viewer {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #f5f0e8;
}

.book-epub-viewer {
  width: 100%;
  height: 100%;
}

/* EPUB.js injects an iframe — make it fill the container */
.book-epub-viewer iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
}

.book-reader-unavailable {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 100%;
  background: var(--navy-800, #1a2844);
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
}
.book-reader-unavailable.visible { display: flex; }
.book-reader-unavailable svg { opacity: 0.3; }
.book-reader-unavailable p { font-size: 0.9rem; max-width: 320px; }

/* ── Chapter nav bar ── */
.book-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--navy-800, #111d35);
  gap: 12px;
}

.book-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary, #8fa0bc);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.book-nav-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.18);
}
.book-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.book-nav-label {
  flex: 1;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Footer ── */
.book-reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--navy-900, #0f1a2e);
}

.book-footer-left { display: flex; align-items: center; }

.book-purchase-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.book-purchase-link:hover { color: var(--gold); }

.book-download-btns {
  display: flex;
  gap: 8px;
}

.book-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  background: var(--navy-700, #1e3160);
  color: var(--text-primary);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.book-dl-btn:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: #000;
}

/* Passage capture */
.book-passage-wrap {
  flex: 1;
  min-width: 0;
}

.book-passage-btn { white-space: nowrap; }

.book-passage-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--navy-800, #111d35);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  animation: fadeSlideUp 0.15s ease;
}

.book-passage-input {
  width: 100%;
  background: var(--navy-900, #0f1a2e);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  padding: 8px 10px;
  resize: none;
  line-height: 1.45;
}
.book-passage-input:focus {
  outline: none;
  border-color: var(--gold-border);
}

.book-passage-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.book-passage-cancel {
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.78rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.book-passage-cancel:hover { color: var(--text-primary); border-color: var(--text-muted); }

.book-passage-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--gold);
  border: none;
  color: #000;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.book-passage-save:hover { opacity: 0.85; }

/* sidebar-book-link as button — reset only non-visual properties */
button.sidebar-book-link {
  cursor: pointer;
  font-family: inherit;
}

@media (max-width: 700px) {
  .book-reader-toc { display: none; }
  .book-reader-modal {
    width: 100vw;
    height: 100dvh;
    top: 0;
    left: 0;
    transform: none;
    border-radius: 0;
  }
  .book-reader-footer { flex-direction: column; align-items: flex-start; }
  .book-passage-wrap { width: 100%; }
}

/* ── Training Hub ── */
.training-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1100; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.training-overlay.active { opacity: 1; pointer-events: all; }

.training-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.97);
  width: min(1000px, 96vw); height: min(680px, 92vh);
  background: var(--navy-2); border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column; z-index: 1101;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  overflow: hidden;
}
.training-modal.active { opacity: 1; pointer-events: all; transform: translate(-50%, -50%) scale(1); }

.training-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.training-modal-title { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }
.training-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; padding: 0 4px; line-height: 1; transition: color 0.15s; }
.training-close:hover { color: var(--text-primary); }

.training-body { display: flex; flex: 1; overflow: hidden; }

.training-sidebar {
  width: 280px; flex-shrink: 0; border-right: 1px solid var(--border);
  overflow-y: auto; background: var(--navy-1);
}
.training-list { padding: 10px 8px; display: flex; flex-direction: column; gap: 4px; }
.training-empty { font-size: 0.82rem; color: var(--text-muted); text-align: center; padding: 24px 16px; }

.training-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  transition: background 0.15s; border: 1px solid transparent;
}
.training-item:hover { background: rgba(255,255,255,0.04); }
.training-item.active { background: rgba(14,165,233,0.08); border-color: rgba(14,165,233,0.2); }
.training-item.locked { opacity: 0.45; cursor: default; }

.training-thumb {
  width: 52px; height: 38px; border-radius: 5px; overflow: hidden;
  background: var(--navy-4); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.training-thumb img { width: 100%; height: 100%; object-fit: cover; }
.training-thumb-icon { color: rgba(255,255,255,0.25); }

.training-item-info { flex: 1; min-width: 0; }
.training-item-title { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.training-item-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.training-tier-pill { font-size: 0.63rem; font-weight: 600; padding: 1px 6px; border-radius: 20px; border: 1px solid; }
.training-tier-pill.practitioner { color: var(--gold); border-color: var(--gold-border); }
.training-tier-pill.enterprise { color: var(--amber); border-color: var(--amber-border); }

.training-item-status { flex-shrink: 0; font-size: 0.85rem; }
.training-check { color: var(--green); }
.training-lock { color: var(--text-muted); font-size: 0.75rem; }

.training-viewer { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.training-placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--text-muted); font-size: 0.85rem;
}

.training-content-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.training-media { flex: 1; background: #000; overflow: hidden; position: relative; }
.training-media iframe, .training-media video {
  width: 100%; height: 100%; border: none; display: block;
}
.training-media-link {
  display: flex; align-items: center; justify-content: center; height: 100%;
  flex-direction: column; gap: 14px; background: var(--navy-3);
}
.training-media-link a {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--gold); color: #fff; font-size: 0.88rem; font-weight: 600;
  padding: 10px 22px; border-radius: 20px; text-decoration: none; transition: opacity 0.15s;
}
.training-media-link a:hover { opacity: 0.85; }
.training-media-link p { font-size: 0.8rem; color: var(--text-muted); }

.training-info-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 18px; border-top: 1px solid var(--border);
  flex-shrink: 0; background: var(--navy-2);
}
.training-content-title { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.training-content-desc { font-size: 0.78rem; color: var(--text-secondary); }
.training-complete-btn {
  flex-shrink: 0; background: none; border: 1px solid var(--green-border);
  color: var(--green); font-size: 0.78rem; font-weight: 600;
  padding: 6px 14px; border-radius: 20px; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.training-complete-btn:hover { background: var(--green-glow); }
.training-complete-btn.completed { background: var(--green-glow); opacity: 0.7; cursor: default; }

/* ── Journey Modal ─────────────────────────────────────────────── */
.journey-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 800; opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.journey-overlay.active { opacity: 1; pointer-events: auto; }

.journey-modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 720px; max-width: 94vw; max-height: 90vh;
  background: var(--navy-2); border: 1px solid var(--border);
  border-radius: 16px;
  z-index: 801; display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.journey-modal.active { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }

.journey-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}
.journey-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 24px;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background 0.15s;
}
.journey-close:hover { background: rgba(255,255,255,0.06); }
.journey-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.journey-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.journey-body {
  flex: 1; overflow-y: auto; padding: 20px 24px;
}

/* Journey cards */
.journey-card {
  background: var(--navy-3); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; margin-bottom: 12px;
  cursor: pointer; transition: border-color 0.15s, transform 0.1s;
}
.journey-card:hover { border-color: var(--gold-border); transform: translateY(-1px); }

/* Step progress */
.journey-stepper {
  display: flex; flex-direction: column; gap: 0;
  margin-bottom: 20px;
}
.journey-step-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  position: relative;
}
.journey-step-item:not(:last-child)::after {
  content: ''; position: absolute; left: 15px; top: 44px; bottom: 0;
  width: 2px; background: var(--border);
}
.journey-step-item.completed::after { background: var(--gold); }
.journey-step-item.active::after { background: var(--gold); }

.journey-step-num {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; z-index: 1;
  border: 2px solid var(--border); color: var(--text-muted);
  background: var(--navy-2);
}
.journey-step-item.completed .journey-step-num {
  background: var(--gold); border-color: var(--gold); color: var(--navy-1);
}
.journey-step-item.active .journey-step-num {
  border-color: var(--gold); color: var(--gold);
}

.journey-step-content { flex: 1; min-width: 0; }
.journey-step-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.journey-step-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.journey-step-output {
  font-size: 12px; margin-top: 6px; padding: 8px 10px;
  background: var(--gold-glow); border: 1px solid var(--gold-border);
  border-radius: 6px; color: var(--text-secondary); line-height: 1.5;
}

/* Journey chat area */
.journey-chat-wrap {
  border-top: 1px solid var(--border);
  padding: 16px 0 0;
  margin-top: 12px;
}
.journey-chat-messages {
  max-height: 250px; overflow-y: auto; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.journey-chat-msg {
  padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5;
  max-width: 85%; word-wrap: break-word;
}
.journey-chat-msg.user {
  align-self: flex-end; background: var(--gold-glow); border: 1px solid var(--gold-border);
  color: var(--text-primary); border-bottom-right-radius: 4px;
}
.journey-chat-msg.assistant {
  align-self: flex-start; background: var(--navy-3); border: 1px solid var(--border);
  color: var(--text-secondary); border-bottom-left-radius: 4px;
}
.journey-chat-msg.assistant strong { color: var(--text-primary); }
.journey-chat-input-row {
  display: flex; gap: 8px;
}
.journey-chat-input-row input {
  flex: 1; padding: 8px 12px; background: var(--navy-3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary); font-size: 13px; outline: none;
  font-family: inherit;
}
.journey-chat-input-row input:focus { border-color: var(--gold-border); }
.journey-chat-input-row button {
  padding: 8px 14px; background: var(--gold); border: none; border-radius: 8px;
  color: var(--navy-1); font-size: 13px; font-weight: 600; cursor: pointer;
}
.journey-chat-input-row button:disabled { opacity: 0.4; cursor: not-allowed; }
.journey-chat-step-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--gold); margin-bottom: 8px;
}

.journey-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: opacity 0.15s;
}
.journey-btn-primary {
  background: var(--gold); color: var(--navy-1);
}
.journey-btn-primary:hover { opacity: 0.88; }
.journey-btn-secondary {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ── Journey Bar (above chat) ─────────────────────────────────── */
#journeyBar {
  background: var(--navy-2); border-bottom: 1px solid var(--border);
  padding: 10px 20px; flex-shrink: 0;
}
.jbar-row {
  display: flex; align-items: center; gap: 12px;
}
.jbar-steps {
  display: flex; gap: 4px; align-items: center;
}
.jbar-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--border); background: transparent;
  transition: all 0.2s;
}
.jbar-dot.done { background: var(--gold); border-color: var(--gold); }
.jbar-dot.active { border-color: var(--gold); background: transparent; box-shadow: 0 0 0 2px var(--gold-glow); }
.jbar-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
}
.jbar-step-label {
  font-size: 12px; color: var(--gold);
}
.jbar-actions {
  margin-left: auto; display: flex; gap: 6px;
}
.jbar-btn {
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: none; transition: opacity 0.15s;
}
.jbar-btn-primary { background: var(--gold); color: var(--navy-1); }
.jbar-btn-primary:hover { opacity: 0.85; }
.jbar-btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.jbar-btn-ghost:hover { border-color: var(--gold-border); }

/* Save deliverable button on AI messages during journey */
.journey-save-btn {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px; padding: 5px 12px; border-radius: 6px;
  background: var(--gold-glow); border: 1px solid var(--gold-border);
  color: var(--gold); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.journey-save-btn:hover { background: var(--gold-border); }
.journey-save-btn.saved { opacity: 0.5; cursor: default; }

/* ── Safety Footer ────────────────────────────────────────── */
.msg-safety-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.grounding-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.grounding-rag {
  background: rgba(34,197,94,0.1);
  color: #22c55e;
  border: 1px solid rgba(34,197,94,0.2);
}
.grounding-web {
  background: rgba(99,102,241,0.1);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,0.2);
}
.grounding-general {
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.msg-disclaimer {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

.msg-flag-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s;
}
.msg-flag-btn:hover {
  opacity: 1;
  color: var(--red, #ef4444);
}
