/* Care Insights v2 — Soft Wellness */
:root {
  --paper: #F4F1EA;
  --surface: #FAF8F3;
  --surface-2: #EFEBE1;
  --ink: #1E2721;
  --ink-2: #3D4A42;
  --muted: #6B7668;
  --line: #DFD9CA;
  --line-2: #E9E4D6;
  --sage: #5A6B56;
  --sage-deep: #3F4E3D;
  --sage-wash: #E4E7DC;
  --coral: #C97B5A;
  --coral-wash: #F2DFD4;
  --amber: #B8894A;
  --amber-wash: #EFE3C9;
  --ok: #6A8A5C;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --shadow-soft: 0 1px 0 rgba(30,39,33,0.03), 0 2px 18px -6px rgba(30,39,33,0.08);
  --shadow-float: 0 2px 0 rgba(30,39,33,0.03), 0 14px 40px -18px rgba(30,39,33,0.22);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Geist', -apple-system, system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
  letter-spacing: -0.005em;
  height: 100vh;
  overflow: hidden;
}
.serif { font-family: 'Newsreader', Georgia, serif; font-weight: 400; letter-spacing: -0.015em; }
.mono  { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'zero','ss02'; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--sage-deep); }
button { font-family: inherit; cursor: pointer; }

/* ============ LAYOUT ============ */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr 380px;
  height: 100vh;
  width: 100vw;
}

/* ============ SIDEBAR ============ */
.sidebar {
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--sage-deep); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 20px; font-weight: 500; line-height: 1; }
.brand-meta { font-size: 10px; color: var(--muted); letter-spacing: 0.4px; text-transform: uppercase; margin-top: 3px; }

.patient-chip {
  padding: 12px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--sage-wash); color: var(--sage-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.patient-meta { flex: 1; min-width: 0; }
.patient-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.patient-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; margin-top: 6px; }
.nav-label { font-size: 10px; color: var(--muted); padding: 6px 10px; letter-spacing: 0.6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow-soft); }
.nav-item.active .nav-icon { color: var(--sage-deep); }
.nav-icon { color: var(--muted); display: inline-flex; }
.nav-item span:nth-child(2) { flex: 1; }
.nav-count { font-size: 11px; color: var(--muted); }

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 11px;
  color: var(--muted);
  margin-top: auto;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: var(--sage-deep); border-color: var(--sage-deep); color: var(--paper); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 10px; }
.btn.full { justify-content: center; width: 100%; }

/* ============ PILLS ============ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
}
.pill.sage   { background: var(--sage-wash);  border-color: transparent; color: var(--sage-deep); }
.pill.coral  { background: var(--coral-wash); border-color: transparent; color: #8B4A30; }
.pill.amber  { background: var(--amber-wash); border-color: transparent; color: #6F5328; }

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

/* ============ DASH MAIN ============ */
.dash { overflow: hidden; }
.dash-scroll {
  height: 100vh;
  overflow-y: auto;
  padding: 28px 36px 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ============ VITALS RIBBON ============ */
.ribbon {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 28px 30px;
  display: flex;
  align-items: stretch;
  gap: 28px;
  min-height: 180px;
  background:
    radial-gradient(120% 80% at 85% 0%, #E8DCC8 0%, transparent 55%),
    radial-gradient(90% 60% at 10% 100%, #D8E0CB 0%, transparent 50%),
    linear-gradient(180deg, #EFE8D6 0%, #E2DCC6 100%);
}
.grain::before {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.12  0 0 0 0 0.15  0 0 0 0 0.13  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.ribbon-text { flex: 1; display: flex; flex-direction: column; justify-content: space-between; position: relative; z-index: 2; }
.eyebrow { font-size: 11px; letter-spacing: 0.8px; color: var(--muted); text-transform: uppercase; margin-bottom: 10px; }
.eyebrow-sm { font-size: 10.5px; letter-spacing: 0.8px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.ribbon-headline { font-size: 34px; line-height: 1.1; margin: 0; font-weight: 500; color: var(--ink); letter-spacing: -0.02em; }
.ribbon-headline em { font-style: italic; color: var(--sage-deep); }
.ribbon-actions { display: flex; gap: 10px; margin-top: 16px; }

.ribbon-stats { width: 240px; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 2; }
.ribbon-stat {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,0.55);
  border-radius: 14px;
  border: 1px solid rgba(30,39,33,0.06);
  backdrop-filter: blur(6px);
}
.stat-label { font-size: 11px; color: var(--muted); letter-spacing: 0.3px; text-transform: uppercase; }
.stat-value { display: flex; align-items: baseline; gap: 6px; }
.stat-value .serif { font-size: 26px; font-weight: 500; color: var(--ink); }
.stat-unit { font-size: 11px; color: var(--muted); }

/* ============ SECTIONS ============ */
.section-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 14px;
}
.section-title { font-size: 22px; margin: 0; font-weight: 500; letter-spacing: -0.01em; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Recently added grid */
.recent-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.recent-card {
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.recent-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-float); color: var(--ink); }
.kind-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--sage-wash); color: var(--sage-deep);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.recent-body { flex: 1; min-width: 0; }
.recent-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.recent-title { font-size: 13.5px; font-weight: 500; }
.recent-time { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.recent-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }

/* List card (meds / conditions / labs) */
.list-card { padding: 4px; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border-bottom: 1px solid var(--line-2);
  transition: background 0.12s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); color: var(--ink); }
.row-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--sage-wash); color: var(--sage-deep);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.row-icon.coral   { background: var(--coral-wash); color: var(--coral); }
.row-icon.amber   { background: var(--amber-wash); color: var(--amber); }
.row-icon.neutral { background: var(--surface-2); color: var(--ink-2); }
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 13.5px; font-weight: 500; }
.row-desc  { font-size: 11.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Provider grid */
.provider-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.provider-card {
  padding: 14px;
  display: flex; gap: 12px; align-items: center;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.provider-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-float); }

/* Overview */
.overview-card { padding: 22px 26px; }
.overview-body { font-size: 14px; line-height: 1.65; color: var(--ink-2); }
.overview-body h1, .overview-body h2, .overview-body h3 { font-family: 'Newsreader', Georgia, serif; font-weight: 500; letter-spacing: -0.01em; color: var(--ink); }
.overview-body h1 { font-size: 22px; margin-top: 0; }
.overview-body h2 { font-size: 18px; }
.overview-body h3 { font-size: 15px; }
.overview-body a { color: var(--sage-deep); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.overview-body table { border-collapse: collapse; width: 100%; font-size: 13px; }
.overview-body th, .overview-body td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); text-align: left; }
.overview-body th { font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.overview-body code { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

.footer-note {
  margin-top: 20px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
}

/* ============ CHAT PANEL ============ */
.chat-panel {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  height: 100vh;
}
.chat-header {
  padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-2);
  flex-shrink: 0;
}
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-sparkle { width: 30px; height: 30px; border-radius: 9px; background: var(--sage-wash); color: var(--sage-deep); display: flex; align-items: center; justify-content: center; }
.chat-title { font-size: 13.5px; font-weight: 500; }
.chat-sub { font-size: 10.5px; color: var(--muted); margin-top: 1px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 90%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
}
.bubble.user { background: var(--ink); color: var(--paper); border-bottom-right-radius: 6px; align-self: flex-end; }
.bubble.bot  { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 6px; align-self: flex-start; }
.bubble.bot p { margin: 0 0 8px; }
.bubble.bot p:last-child { margin: 0; }
.bubble.bot a { color: var(--sage-deep); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.bubble.bot table { border-collapse: collapse; font-size: 12px; margin: 6px 0; width: 100%; }
.bubble.bot th, .bubble.bot td { padding: 4px 6px; border-bottom: 1px solid var(--line-2); text-align: left; }
.bubble.bot code { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; background: var(--surface); padding: 2px 5px; border-radius: 5px; }
.bubble.typing { display: inline-flex; gap: 4px; align-items: center; padding: 14px 16px; }
.type-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); animation: pulse 1.2s infinite ease-in-out; display: inline-block; }
.type-dot:nth-child(2) { animation-delay: 0.15s; }
.type-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%,80%,100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }
.bubble-source { font-size: 10.5px; color: var(--muted); margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--line-2); }
.bubble-source a { color: var(--sage-deep); }
.bubble-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.chat-quick {
  padding: 10px 18px 14px;
  display: flex; flex-direction: column; gap: 6px;
  border-top: 1px solid var(--line-2);
}
.quick-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 2px; }
.btn.quick { justify-content: flex-start; font-weight: 400; color: var(--ink-2); }

.chat-composer { padding: 14px; border-top: 1px solid var(--line-2); flex-shrink: 0; background: var(--surface); }
.composer-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer-box:focus-within { border-color: var(--sage); box-shadow: 0 0 0 4px var(--sage-wash); }
.composer-box input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 6px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
}
/* Send button on the LEFT of the chat composer (input fills the rest). */
#chatSend { order: -1; }
.composer-hints { font-size: 10px; color: var(--muted); margin-top: 8px; display: flex; gap: 10px; padding-left: 4px; }

/* ============ UPLOAD MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(30,39,33,0.35);
  display: none;
  align-items: center; justify-content: center;
  z-index: 90;
  padding: 32px;
}
.modal-backdrop.open { display: flex; animation: fadeIn 0.18s ease; }
.modal {
  width: 560px; max-width: 100%;
  background: var(--paper);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow-float);
  border: 1px solid var(--line);
  position: relative;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 22px; font-weight: 500; }
.upload-drop {
  border: 1.5px dashed var(--line);
  border-radius: 18px;
  padding: 32px;
  background: var(--surface);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.leaf-bg { position: absolute; right: -40px; bottom: -60px; opacity: 0.5; pointer-events: none; }
.upload-inner { position: relative; }
.upload-iconbox {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--sage-wash); color: var(--sage-deep);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.upload-title { font-size: 22px; font-weight: 500; }
.upload-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.upload-filenames { font-size: 11px; color: var(--muted); margin-top: 12px; min-height: 14px; }
.upload-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.upload-status { font-size: 11px; color: var(--muted); margin-top: 14px; text-align: left; max-height: 140px; overflow-y: auto; }
.upload-result { padding: 4px 0; }
.upload-result.ok   { color: var(--sage-deep); }
.upload-result.warn { color: var(--amber); }
.upload-result.err  { color: var(--coral); }

/* ============ ANIMATIONS ============ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp 0.4s ease both; }
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }

/* ============ SCROLLBAR ============ */
.scroll::-webkit-scrollbar, .dash-scroll::-webkit-scrollbar, .sidebar::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb, .dash-scroll::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 999px; border: 3px solid var(--paper);
}
.scroll::-webkit-scrollbar-thumb:hover, .dash-scroll::-webkit-scrollbar-thumb:hover, .sidebar::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============ RESPONSIVE (mobile) ============ */
@media (max-width: 1024px) {
  body, html { overflow: auto; height: auto; overflow-x: hidden; }
  .app-shell { grid-template-columns: 1fr; height: auto; }

  /* ---- Mobile sidebar: flex-wrap, row 1 = brand+chip, row 2 = icon actions ---- */
  .sidebar {
    position: sticky; top: 0; z-index: 10;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
    padding: 12px 14px;
    height: auto;
    overflow: visible;
    border-right: none; border-bottom: 1px solid var(--line);
    background: var(--paper);
  }
  /* Hide desktop-only elements on mobile shell */
  .sidebar-footer,
  .sidebar-ticker,
  .nav-label { display: none; }

  /* Row 1: brand (grows) + patient chip (shrinks to content) */
  .sidebar > .brand {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }
  .sidebar > .brand .brand-name { font-size: 18px; white-space: nowrap; }
  .sidebar > .brand .brand-meta { font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .sidebar > .patient-chip {
    order: 2;
    flex: 0 0 auto;
    padding: 6px 10px 6px 6px;
  }
  .sidebar > .patient-chip .avatar { width: 28px; height: 28px; font-size: 11px; }
  .sidebar > .patient-chip .patient-name { font-size: 12.5px; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar > .patient-chip .patient-sub { font-size: 10px; }

  /* Force a line-break between row 1 (brand+chip) and row 2 (actions) */
  .sidebar::after {
    content: "";
    display: block;
    order: 3;
    flex-basis: 100%;
    height: 0;
    width: 0;
  }

  /* Belt-and-suspenders hide for desktop-only sidebar elements on mobile */
  .sidebar > .sidebar-ticker,
  .sidebar > .sidebar-footer { display: none !important; }

  /* Row 2: compact icon-only actions, wrap-safe */
  .sidebar > .btn.primary.full {
    order: 4;
    flex: 0 0 auto;
    width: auto;
    padding: 8px 10px;
    font-size: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 0;
  }
  .sidebar > .btn.primary.full svg { width: 16px; height: 16px; }

  .sidebar > .share-btn {
    order: 5;
    flex: 0 0 auto;
    padding: 8px 10px;
    border-radius: 10px;
    display: inline-flex;
    gap: 0;
  }
  .sidebar > .share-btn .share-btn-label { display: none; }
  .sidebar > .share-btn svg { width: 16px; height: 16px; }

  .sidebar > .pending-pill {
    order: 6;
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 10.5px;
  }

  /* Nav: icon-only chips, wrap to next line as needed */
  .sidebar > .nav {
    order: 7;
    flex: 1 1 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 0;
  }
  .sidebar > .nav .nav-item {
    padding: 7px 10px;
    font-size: 0;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    gap: 5px;
  }
  .sidebar > .nav .nav-item .nav-icon { font-size: initial; }
  .sidebar > .nav .nav-item span:not(.nav-icon):not(.nav-count) { display: none; }
  .sidebar > .nav .nav-item .nav-count {
    font-size: 10px;
    background: var(--surface-2);
    color: var(--muted);
    padding: 1px 6px;
    border-radius: 999px;
  }

  .dash { overflow: visible; }
  .dash-scroll { height: auto; overflow: visible; padding: 20px 16px 40px; gap: 20px; }
  .chat-panel { height: 70vh; border-left: none; border-top: 1px solid var(--line); }
  .ribbon { flex-direction: column; padding: 20px; gap: 18px; }
  .ribbon-stats { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .ribbon-stat { flex: 1; min-width: 110px; }
  .ribbon-headline { font-size: 26px; }
  .two-col, .recent-grid, .provider-grid { grid-template-columns: 1fr; }
}

/* ============ VERTICAL TICKER (in ribbon) ============ */
.ribbon-ticker {
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 2;
}
.ticker-eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.8px;
  color: var(--muted);
  text-transform: uppercase;
}
.ticker-window {
  flex: 1;
  min-height: 140px;
  max-height: 160px;
  overflow: hidden;
  position: relative;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(30,39,33,0.06);
  border-radius: 14px;
  backdrop-filter: blur(6px);
  mask-image: linear-gradient(180deg, transparent 0%, black 14%, black 86%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, black 14%, black 86%, transparent 100%);
}
.ticker-track-v {
  display: flex;
  flex-direction: column;
  animation: ticker-v 45s linear infinite;
  will-change: transform;
}
.ticker-window:hover .ticker-track-v { animation-play-state: paused; }
.ticker-group-v { display: flex; flex-direction: column; flex-shrink: 0; }
.ticker-row {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--ink-2);
  transition: background 0.12s ease, color 0.12s ease;
}
.ticker-row:hover { background: rgba(255,255,255,0.6); color: var(--ink); }
.ticker-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--sage-deep);
  opacity: 0.55;
}
.ticker-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.ticker-meta {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
@keyframes ticker-v {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* ============ CARE INSIGHT TILES ============ */
.insight-em { font-style: italic; font-weight: 400; color: var(--sage-deep); }
.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.insight-card {
  padding: 12px 14px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
  overflow: hidden;
  transition: transform 0.14s ease, box-shadow 0.22s ease, border-color 0.2s ease;
}
.insight-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--sage) 0%, var(--sage-deep) 100%);
  opacity: 0.65;
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
}
.insight-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-float);
  border-color: var(--sage-wash);
  color: var(--ink);
}
.insight-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.insight-section {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--sage-deep);
  background: var(--sage-wash);
  padding: 2px 7px;
  border-radius: 999px;
}
.insight-time { font-size: 10.5px; color: var(--muted); }
.insight-title {
  font-size: 16px;
  line-height: 1.25;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.insight-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .ribbon-ticker { width: 100%; }
  .ticker-window { max-height: 120px; }
  .insight-grid { grid-template-columns: 1fr; }
}

/* ============ WIKI SUBPAGE ============ */
.wiki-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 18px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.wiki-breadcrumb a { color: var(--ink-2); }
.wiki-breadcrumb a:hover { color: var(--sage-deep); }
.crumb-sep { color: var(--line); }
.crumb-mid { color: var(--muted); }
.crumb-current { color: var(--sage-deep); font-weight: 500; }

.wiki-article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 44px 52px;
  box-shadow: var(--shadow-soft);
  max-width: 820px;
  position: relative;
}
.wiki-header { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px dashed var(--line-2); }
.wiki-header .eyebrow { margin-bottom: 8px; }
.wiki-title {
  font-size: 38px;
  line-height: 1.12;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.wiki-sources {
  background: rgba(90,107,86,0.05);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-md, 8px);
  padding: 12px 18px;
  margin-bottom: 24px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.wiki-sources h3 {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--sage-deep);
  margin: 0 0 6px;
}
.wiki-sources ul { list-style: none; padding: 0; margin: 0; }
.wiki-sources li { display: inline-block; margin-right: 14px; margin-bottom: 4px; }
.wiki-sources a {
  color: var(--sage-deep);
  text-decoration: none;
  border-bottom: 1px dashed var(--line);
}
.wiki-sources a:hover { color: var(--ink); border-bottom-style: solid; }
.wiki-body {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--ink-2);
}
.wiki-body h1, .wiki-body h2, .wiki-body h3, .wiki-body h4 {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-top: 1.6em;
  margin-bottom: 0.5em;
  line-height: 1.2;
}
.wiki-body > *:first-child { margin-top: 0; }
.wiki-body h1 { font-size: 28px; }
.wiki-body h2 { font-size: 22px; padding-bottom: 6px; border-bottom: 1px solid var(--line-2); }
.wiki-body h3 { font-size: 18px; }
.wiki-body h4 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--sage-deep); }
.wiki-body p { margin: 0 0 1.1em; }
.wiki-body a {
  color: var(--sage-deep);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.wiki-body a.wikilink { color: var(--sage-deep); font-weight: 500; }
.wiki-body a:hover { color: var(--ink); text-decoration-style: solid; }
.wiki-body strong { color: var(--ink); font-weight: 600; }
.wiki-body em { font-style: italic; color: var(--ink-2); }
.wiki-body ul, .wiki-body ol { padding-left: 1.4em; margin: 0 0 1.2em; }
.wiki-body li { margin-bottom: 0.4em; }
.wiki-body li::marker { color: var(--sage); }
.wiki-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: var(--surface-2);
  color: var(--sage-deep);
  padding: 2px 7px;
  border-radius: 6px;
}
.wiki-body pre {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
  margin: 1.2em 0;
}
.wiki-body pre code { background: transparent; padding: 0; color: var(--ink-2); }
.wiki-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  margin: 1.2em 0;
}
.wiki-body th, .wiki-body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  text-align: left;
  vertical-align: top;
}
.wiki-body thead th {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  background: var(--surface-2);
}
.wiki-body tr:hover td { background: rgba(90,107,86,0.04); }
.wiki-body blockquote {
  border-left: 3px solid var(--sage);
  margin: 1.2em 0;
  padding: 2px 0 2px 18px;
  color: var(--ink-2);
  font-style: italic;
}
.wiki-body hr {
  border: none;
  border-top: 1px dashed var(--line);
  margin: 2em 0;
}
.wiki-body img {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
}
/* Obsidian-style callouts rendered by markdown */
.wiki-body blockquote p:first-child:has(> strong:first-child) { font-weight: 500; color: var(--ink); font-style: normal; }

.wiki-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px dashed var(--line-2);
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .wiki-article { padding: 26px 22px; }
  .wiki-title { font-size: 28px; }
  .wiki-body { font-size: 15px; }
}

/* ============ MOBILE OVERFLOW GUARDS ============ */
/* Prevent grid/flex children from expanding to fit intrinsic wide content */
.app-shell, .dash, .dash-scroll, .wiki-article { min-width: 0; }

@media (max-width: 1024px) {
  html, body { overflow-x: hidden; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  /* Wide tables scroll internally instead of stretching the page */
  .wiki-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: normal;
  }
  .wiki-body pre { max-width: 100%; overflow-x: auto; }
  .wiki-body img, .wiki-body video { max-width: 100%; height: auto; }
  .wiki-body a, .wiki-body code { overflow-wrap: anywhere; word-break: break-word; }
  .wiki-breadcrumb { flex-wrap: wrap; }
  .wiki-article { padding: 22px 18px; border-radius: var(--radius-lg); }
  .wiki-title { font-size: 26px; }
  .dash-scroll { padding: 16px 12px 40px; }
}

@media (max-width: 520px) {
  .wiki-article { padding: 18px 14px; }
  .wiki-title { font-size: 22px; }
  .wiki-body { font-size: 14.5px; line-height: 1.65; }
  .wiki-body h1 { font-size: 22px; }
  .wiki-body h2 { font-size: 18px; }
  .wiki-body h3 { font-size: 16px; }
}

/* ============ QUERY HISTORY ============ */
.query-card { padding: 4px; }
.query-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-2);
  border-radius: 10px;
  transition: background 0.12s ease;
  color: var(--ink-2);
}
.query-row:last-child { border-bottom: none; }
.query-row:hover { background: var(--surface-2); color: var(--ink); }
.query-time { font-size: 10.5px; color: var(--muted); letter-spacing: 0.4px; white-space: nowrap; }
.query-text { font-size: 13.5px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.query-src { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; }
.query-src-fast    { background: var(--sage-wash);  color: var(--sage-deep); }
.query-src-router  { background: var(--amber-wash); color: #6F5328; }
.query-src-qmd     { background: var(--sage-wash);  color: var(--sage-deep); }
.query-src-deep    { background: var(--coral-wash); color: #8B4A30; }
.query-src-note    { background: var(--surface-2); color: var(--ink-2); }
.query-src-system  { background: var(--surface-2); color: var(--ink-2); }

/* ============ /log PAGE (structured view) ============ */
.log-subheading { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.55; }
.log-list { display: flex; flex-direction: column; border-top: 1px dashed var(--line-2); margin-top: 8px; }
.log-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: flex-start;
  padding: 14px 6px;
  border-bottom: 1px dashed var(--line-2);
  color: var(--ink-2);
  transition: background 0.12s ease, color 0.12s ease;
}
.log-row:hover { background: var(--surface-2); color: var(--ink); }
.log-main { min-width: 0; }
.log-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-section {
  font-size: 10px;
  color: var(--sage-deep);
  background: var(--sage-wash);
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.log-title { font-size: 17px; font-weight: 500; color: var(--ink); letter-spacing: -0.01em; }
.log-count { font-size: 10px; background: var(--surface-2); color: var(--muted); padding: 2px 8px; }
.log-q { font-size: 12px; color: var(--muted); margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: italic; }
.log-meta { text-align: right; font-size: 11px; color: var(--muted); white-space: nowrap; }
.log-source { color: var(--sage); margin-top: 2px; }
.log-empty { padding: 28px 4px; color: var(--muted); font-style: italic; }

@media (max-width: 720px) {
  .log-row { grid-template-columns: 1fr; }
  .log-meta { text-align: left; display: flex; gap: 10px; }
}

@media (max-width: 720px) {
  .query-row { grid-template-columns: 1fr auto; }
  .query-row .query-time { grid-column: 1 / -1; font-size: 10px; }
  .log-row { grid-template-columns: 1fr 70px; }
  .log-row .log-time { grid-column: 1 / -1; font-size: 10px; }
}

/* ============ SIDEBAR TICKERS (chat history + pages answered) ============ */
.sidebar-ticker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding: 0 4px;
}
.sidebar-ticker-eyebrow {
  font-size: 9.5px;
  letter-spacing: 0.9px;
  color: var(--muted);
  text-transform: uppercase;
  padding: 0 6px;
}
.sidebar-ticker-window {
  position: relative;
  height: 330px; /* +50% over previous (was 220) */
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  mask-image: linear-gradient(180deg, transparent 0%, black 10%, black 90%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, black 10%, black 90%, transparent 100%);
}
.sidebar-ticker-track {
  display: flex;
  flex-direction: column;
  animation: sidebar-ticker-v 40s linear infinite;
  will-change: transform;
}
.sidebar-ticker-window:hover .sidebar-ticker-track {
  animation-play-state: paused;
}
.sidebar-ticker-group {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-ticker-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-bottom: 1px dashed var(--line-2);
  color: var(--ink-2);
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-ticker-row:last-child { border-bottom: none; }
.sidebar-ticker-row:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.sidebar-ticker-meta {
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.3px;
  text-transform: lowercase;
}
.sidebar-ticker-title {
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Pages ticker gets a slightly different accent to distinguish */
.sidebar-ticker-pages .sidebar-ticker-eyebrow {
  color: var(--sage-deep);
}

@keyframes sidebar-ticker-v {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sidebar-ticker-track { animation: none; }
}

@media (max-width: 1024px) {
  .sidebar-ticker { display: none; } /* Sidebar is horizontal on mobile — tickers don't fit */
}

/* Elapsed-time hint shown inside typing bubble during async deep queries */
.typing-elapsed {
  font-size: 10px;
  color: var(--muted);
  margin-left: 8px;
  letter-spacing: 0.3px;
}

/* ============ Pending jobs pill in sidebar ============ */
.pending-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--amber-wash);
  color: #6F5328;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.pending-pill:hover { background: var(--amber); color: var(--paper); }
.pending-spinner {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  animation: pending-spin 1s linear infinite;
}
@keyframes pending-spin {
  to { transform: rotate(360deg); }
}

/* ============ Typing indicator with stage + progress ============ */
.typing-stage {
  font-size: 11.5px;
  color: var(--muted);
  margin-left: 10px;
  font-style: italic;
}
.typing-elapsed {
  font-size: 10px;
  color: var(--muted);
  margin-left: 8px;
  letter-spacing: 0.3px;
}
.typing-progress {
  width: 100%;
  height: 2px;
  background: var(--line-2);
  border-radius: 999px;
  margin-top: 10px;
  overflow: hidden;
}
.typing-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sage) 0%, var(--sage-deep) 100%);
  border-radius: 999px;
  transition: width 0.6s ease-out;
}

/* ============ Escalation announce bubble ============ */
.bubble.announce {
  background: var(--amber-wash);
  color: #6F5328;
  border: 1px dashed rgba(184, 137, 74, 0.4);
  align-self: stretch;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.55;
}
.bubble.announce strong { color: #6F5328; }
.bubble.announce .announce-safe {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--sage-deep);
  font-weight: 500;
}

/* ============ Fresh-answer pulse on render ============ */
@keyframes bubble-fresh-pulse {
  0%   { background: var(--sage-wash); transform: scale(1.01); }
  100% { background: var(--surface-2); transform: scale(1); }
}
.bubble.bot.bubble-fresh { animation: bubble-fresh-pulse 1s ease-out; }

/* ============ Toast container + cards ============ */
.toast-container {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 360px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-float);
  font-size: 13px;
  color: var(--ink-2);
  animation: toast-slide-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast-leaving { animation: toast-slide-out 0.3s ease forwards; }
.toast-msg { flex: 1; line-height: 1.35; }
.toast-action {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.toast-action:hover { background: var(--sage-deep); }
.toast-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.toast-close:hover { color: var(--ink); }
.toast-success { border-left: 3px solid var(--sage); }
.toast-error   { border-left: 3px solid var(--coral); }
.toast-info    { border-left: 3px solid var(--amber); }
@keyframes toast-slide-in {
  from { transform: translateX(400px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes toast-slide-out {
  to { transform: translateX(400px); opacity: 0; }
}

/* ============ Audit viewer table ============ */
.audit-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 4px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line-2);
}
.audit-filter {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
}
.audit-filter:hover { background: var(--surface-2); color: var(--ink); }
.audit-filter.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.audit-table-wrap { overflow-x: auto; margin-top: 12px; }
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.audit-table thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.audit-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: top;
}
.audit-row { cursor: pointer; transition: background 0.12s ease; }
.audit-row:hover { background: var(--surface-2); }
.audit-row .audit-q {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 500;
}
.audit-row .audit-time { color: var(--muted); white-space: nowrap; }
.audit-row .audit-target a { color: var(--sage-deep); text-decoration: underline; text-decoration-style: dotted; }

.audit-detail { display: none; }
.audit-detail.open { display: table-row; }
.audit-detail > td {
  background: var(--paper);
  padding: 14px 16px;
  border-bottom: 2px solid var(--line);
}
.audit-error {
  color: var(--coral);
  background: var(--coral-wash);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 8px;
}
.audit-response {
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 6px 0;
}
.audit-meta {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 6px;
}

@media (max-width: 720px) {
  .audit-row .audit-q { max-width: 180px; }
  .audit-table thead { display: none; }
}

/* ============ Share with doctor ============ */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  margin-top: -4px;
}
.share-btn:hover {
  background: var(--sage-wash);
  border-color: var(--sage);
  color: var(--sage-deep);
}
.share-btn:hover svg { color: var(--sage-deep); }
.share-btn svg { color: var(--ink-2); flex-shrink: 0; }
.share-btn-label { letter-spacing: 0.1px; }

/* Modal card — reuses modal-backdrop/modal from upload modal, adds share-specific layout */
.share-modal-card { max-width: 380px; padding: 28px; text-align: center; }
.share-modal-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-top: 4px;
}

.share-qr-wrap {
  margin: 20px auto 12px;
  width: 280px;
  height: 280px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.35s ease;
}
.share-qr-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}
.share-qr-wrap svg path { fill: var(--ink); }
.share-qr-loading, .share-qr-error {
  color: var(--muted);
  font-size: 12px;
}
.share-qr-error { color: var(--coral); }

@keyframes share-qr-flash-anim {
  0%   { box-shadow: 0 0 0 0 rgba(90, 107, 86, 0.45); }
  50%  { box-shadow: 0 0 0 10px rgba(90, 107, 86, 0.10); }
  100% { box-shadow: 0 0 0 0 rgba(90, 107, 86, 0); }
}
.share-qr-flash { animation: share-qr-flash-anim 0.7s ease-out; }

.share-modal-meta { display: flex; flex-direction: column; gap: 8px; padding: 0 6px; }
.share-expiry {
  display: inline-block;
  font-size: 10.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--sage-deep);
  background: var(--sage-wash);
  padding: 5px 12px;
  border-radius: 999px;
  margin: 0 auto;
}
.share-hint {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  padding: 4px 8px 0;
}

/* On mobile, keep the QR generous but fit the viewport */
@media (max-width: 480px) {
  .share-qr-wrap { width: 240px; height: 240px; padding: 10px; }
  .share-modal-card { padding: 22px 18px; }
}

/* ============ Chat column: question pills + day groupings ============ */
.chat-pills {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pill-day-group {
  font-size: 9.5px;
  letter-spacing: 0.9px;
  color: var(--muted);
  text-transform: uppercase;
  margin: 10px 2px 4px;
}
.pill-day-group:first-child { margin-top: 0; }

.question-pill {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px 11px 9px 10px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--ink-2);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.question-pill:hover {
  background: var(--surface-2);
  border-color: var(--sage);
  color: var(--ink);
}
.question-pill:active { transform: scale(0.99); }

.question-pill .pill-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--sage-wash);
  color: var(--sage-deep);
  font-size: 10px;
  font-weight: 600;
}
.question-pill-pending .pill-status { background: var(--amber-wash); color: var(--amber); }
.question-pill-error .pill-status { background: var(--coral-wash); color: var(--coral); }

.question-pill .pill-question {
  font-size: 12.5px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.question-pill .pill-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  color: var(--muted);
}
.question-pill .pill-meta .pill {
  padding: 1px 7px;
  font-size: 9.5px;
}
.question-pill .pill-time { font-size: 9.5px; color: var(--muted); }

.pill-spinner {
  width: 10px; height: 10px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  animation: pending-spin 1s linear infinite;
  display: inline-block;
}

/* Typing pill (while a query is in flight) */
.typing-pill {
  padding: 12px;
  background: var(--amber-wash);
  border: 1px dashed rgba(184, 137, 74, 0.4);
  border-radius: 12px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.typing-pill .typing-pill-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.typing-pill .pill-question {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ Middle-pane answer view ============ */
.dash-default { display: contents; }
.answer-view { display: block; }
.dash-default[hidden],
.answer-view[hidden] { display: none !important; }

.answer-breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.answer-breadcrumb-label {
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--sage-deep);
  background: var(--sage-wash);
  padding: 3px 10px;
  border-radius: 999px;
}

.answer-article { max-width: 900px; }
.answer-article .wiki-header { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px dashed var(--line-2); }
.answer-article .wiki-header .eyebrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

.answer-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .question-pill { grid-template-columns: 18px 1fr; grid-auto-rows: auto; gap: 6px; }
  .question-pill .pill-meta { grid-column: 2; font-size: 9px; }
}

/* Floating chat FAB — jumps from anywhere on the page down to the chat panel. */
.chat-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.10);
  font-size: 22px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  z-index: 1000;
  opacity: 0.6;
  transition: opacity 150ms ease, transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chat-fab:hover, .chat-fab:focus-visible {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.85);
  outline: none;
}
.chat-fab:active {
  transform: translateY(0);
}
@media (prefers-color-scheme: dark) {
  .chat-fab {
    background: rgba(30, 30, 30, 0.55);
    border-color: rgba(255, 255, 255, 0.10);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.40);
  }
  .chat-fab:hover, .chat-fab:focus-visible {
    background: rgba(40, 40, 40, 0.92);
  }
}
@media (max-width: 600px) {
  .chat-fab {
    right: 14px;
    bottom: 14px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}
