/* PubMed Evidence Explorer — Blocksy-inspired professional theme.
   Cool light surfaces, navy headings, softened medical-blue accent, serif
   display titles, rounded cards with layered shadows and subtle motion. */

:root {
  --bg: #F6F8FB;
  --surface: #FFFFFF;
  --surface-2: #F2F5F9;
  --ink: #22304B;
  --muted: #5A6B82;
  --muted-light: #8B99AC;
  --border: #DFE5EC;
  --border-strong: #C6D0DC;
  --primary: #2F6FDF;
  --primary-dark: #2459C4;
  --primary-soft: #E9F0FB;
  --success: #2E9E6B;
  --success-soft: #E6F4EE;
  --danger: #D95555;
  --danger-soft: #FCEAEA;
  --warning: #E08A2E;
  --warning-soft: #FBF1DE;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(31, 42, 68, 0.05), 0 6px 20px rgba(31, 42, 68, 0.06);
  --shadow-md: 0 10px 34px rgba(31, 42, 68, 0.12);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --tier-guest: #64748B;
  --tier-guest-soft: #F1F5F9;
  --tier-free: #0F766E;
  --tier-free-soft: #F0FDFA;
  --tier-basic: #0F766E;
  --tier-basic-soft: #F0FDFA;
  --tier-pro: #4F46E5;
  --tier-pro-soft: #EEF2FF;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); font-size: 12px; }
svg { display: inline-block; vertical-align: middle; }
::selection { background: rgba(47, 111, 223, 0.16); }

/* ---------------------------------------------------------------- header */
.header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner {
  max-width: none; margin: 0 auto; padding: 18px 28px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.logo { flex-shrink: 0; }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff;
  font-family: var(--serif); font-weight: 700; font-size: 16px; letter-spacing: 0.4px;
}
.header-title { flex: 1; min-width: 220px; }
.header-title h1 { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.tagline { font-size: 13px; color: var(--muted); }
.tagline strong { font-weight: 600; color: var(--ink); }
.header-right { display: flex; align-items: center; gap: 10px; }

.mode-badge {
  display: inline-block;
  font-size: 12px; font-weight: 600; padding: 5px 11px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  color: var(--muted); white-space: nowrap;
}
.mode-ai { color: var(--primary); border-color: rgba(47, 111, 223, 0.4); background: var(--primary-soft); }
.mode-det { color: var(--muted); }
.mode-unknown { color: var(--muted-light); }

/* ---------------------------------------------------------------- main */
.main-content { max-width: none; margin: 0 auto; padding: 30px 28px 60px; }

/* ------------------------------------------------------- Pass 4: shell + i18n */
.app-shell { max-width: none; margin: 0 auto; display: flex; gap: 28px; padding: 0 20px; }
.app-shell .main-content { flex: 1; min-width: 0; max-width: none; margin: 0; padding: 30px 4px 60px; }
@media (max-width: 1000px) {
  .app-shell { flex-direction: column; padding: 0 14px; }
  .app-shell .main-content { padding: 22px 2px 50px; }
}

.features-pane {
  width: 268px; flex-shrink: 0; position: sticky; top: 16px; align-self: flex-start;
  margin-top: 30px; max-height: calc(100vh - 40px); overflow-y: auto;
}
@media (max-width: 1000px) {
  .features-pane { width: 100%; position: static; margin-top: 18px; }
  .features-list { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .feature-item { min-width: 220px; }
}
.features-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 0 2px 10px;
}
.features-list { display: flex; flex-direction: column; gap: 6px; }
.feature-item {
  display: block; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); text-decoration: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.feature-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.feature-item .feature-title { display: block; font-weight: 700; font-size: 13.5px; color: var(--ink); margin-bottom: 2px; }
.feature-item:hover .feature-title { color: var(--primary-dark); }
.feature-item .feature-desc { display: block; font-size: 12px; line-height: 1.45; color: var(--muted); }
.manual-card {
  display: flex; flex-direction: column; gap: 5px; margin-top: 4px;
  padding: 16px 14px; border-radius: var(--radius);
  border: 1px dashed var(--border-strong); background: var(--surface);
  text-decoration: none; color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.manual-card:hover { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--shadow-sm); }
.manual-card-icon { color: var(--primary); margin-bottom: 3px; }
.manual-card-title { font-weight: 700; font-size: 14px; }
.manual-card-sub { font-size: 12px; color: var(--muted); line-height: 1.5; }
.manual-card-cta { font-size: 12.5px; font-weight: 700; color: var(--primary); margin-top: 3px; }

/* AI-Free Author Assist card (sits below the User manual card, visible to all) */
.author-card { margin-top: 10px; }
.author-card:hover { border-color: var(--success); background: var(--success-soft); }
.author-card .manual-card-icon { color: var(--success); }
.author-card .manual-card-cta { color: var(--success); }

.lang-picker {
  font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 5px 8px; cursor: pointer; max-width: 130px;
}
.lang-picker:focus { outline: none; border-color: var(--primary); }

[dir="rtl"] .main-content, [dir="rtl"] .app-shell { direction: rtl; }
[dir="rtl"] .reader-split { direction: rtl; }

/* ------------------------------------------------------- Pass 4: manual page */
.manual-page { max-width: 900px; margin: 0 auto; padding: 34px 24px 70px; }
.manual-page h1 { font-family: var(--serif); font-size: 30px; font-weight: 700; margin-bottom: 6px; }
.manual-page .manual-intro { color: var(--muted); font-size: 15px; line-height: 1.65; margin-bottom: 26px; }
.manual-nav {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 30px;
  border-bottom: 1px solid var(--border); padding-bottom: 16px;
}
.manual-nav a {
  font-size: 13px; font-weight: 600; color: var(--primary); background: var(--primary-soft);
  border: 1px solid transparent; padding: 6px 12px; border-radius: 999px; text-decoration: none;
}
.manual-nav a:hover { background: var(--primary); color: #fff; }
.manual-section {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.manual-section h2 { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--primary-dark); margin-bottom: 10px; }
.manual-section h3 { font-size: 15px; margin: 14px 0 6px; color: var(--ink); }
.manual-section p { font-size: 14px; line-height: 1.7; color: #3A3A36; margin: 8px 0; }
.manual-section ul, .manual-section ol { padding-left: 22px; margin: 8px 0; }
.manual-section li { font-size: 14px; line-height: 1.7; color: #3A3A36; margin: 5px 0; }
.manual-section code {
  font-family: var(--mono); font-size: 12.5px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}
.manual-scenario {
  border-left: 3px solid var(--primary); background: var(--surface-2);
  padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 10px 0;
}
.manual-scenario .sc-label { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary-dark); }
.manual-scenario p { margin: 6px 0; }
.manual-langbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }

/* Manual figures / screenshots */
.manual-figure {
  margin: 16px 0 20px; padding: 0; border: none; background: transparent;
}
.manual-figure img {
  width: 100%; border-radius: var(--radius); box-shadow: var(--shadow-md);
  border: 1px solid var(--border); display: block;
}
.manual-figure figcaption {
  font-size: 13px; color: var(--muted); text-align: center;
  margin-top: 8px; line-height: 1.5; font-style: italic;
}

/* Manual cover page */
.manual-cover {
  text-align: center; padding: 24px 0 30px; margin-bottom: 10px;
  border-bottom: 2px solid var(--primary-soft);
}
.manual-cover h1 {
  font-family: var(--serif); font-size: 28px; font-weight: 700;
  color: var(--primary-dark); margin-bottom: 8px;
}
.manual-cover .manual-intro {
  font-size: 15px; color: var(--muted); line-height: 1.65;
  max-width: 600px; margin: 0 auto;
}
@media print {
  .manual-cover { padding: 100px 20px; }
  .manual-cover h1 { font-size: 32px; margin-bottom: 16px; }
  .manual-cover .manual-intro { font-size: 16px; }
}

/* Manual cover graphic (access flow diagram) */
.manual-cover-graphic {
  max-width: 760px; margin: 26px auto 4px;
}
.manual-cover-graphic svg { width: 100%; height: auto; display: block; }

/* Manual cover "How to access" panel */
.manual-access {
  max-width: 760px; margin: 22px auto 0; text-align: left;
}
.manual-access .access-h {
  font-size: 15px; font-weight: 800; color: var(--primary-dark);
  margin-bottom: 12px; text-align: center; letter-spacing: 0.02em;
}
.manual-access .access-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.manual-access .access-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.manual-access .access-num {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.manual-access .access-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.manual-access .access-url {
  font-family: var(--mono); font-size: 11.5px; color: var(--primary-dark);
  margin: 3px 0 5px; word-break: break-all;
}
.manual-access .access-step { font-size: 12.5px; color: #3A3A36; line-height: 1.55; }
.manual-free-note {
  max-width: 640px; margin: 16px auto 0; font-size: 12.5px; line-height: 1.6;
  color: var(--muted); background: var(--primary-soft);
  border: 1px solid var(--primary-soft); border-radius: var(--radius);
  padding: 10px 14px;
}

/* Print layout for PDF generation */
@media print {
  @page { size: A4; margin: 18mm 20mm; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .manual-page { max-width: 100%; padding: 0; }
  .manual-cover { page-break-after: always; break-after: page; text-align: center; padding: 60px 20px; }
  .manual-section { break-inside: avoid; page-break-inside: avoid; border: none; box-shadow: none; padding: 14px 0; margin-bottom: 10px; }
  .manual-section h2 { font-size: 18px; margin-bottom: 8px; }
  .manual-nav { display: none; }
  .manual-langbar { display: none; }
  .manual-pdfbar { display: none !important; }
  .manual-figure img { box-shadow: none; border: 1px solid #ccc; }
  .manual-figure { page-break-inside: avoid; break-inside: avoid; margin: 12px 0; }
}

@page :first { @bottom-center { content: ''; } }
@page :left { @bottom-left { content: counter(page); font-size: 10px; color: var(--muted); } }
@page :right { @bottom-right { content: counter(page); font-size: 10px; color: var(--muted); } }


/* ---------------------------------------------------------------- search */
.search-section {
  max-width: 760px; margin: 0 auto;
  padding: clamp(72px, 24vh, 260px) 16px 20px; text-align: left;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 6px 6px 6px 20px;
  box-shadow: 0 1px 2px rgba(31,42,68,.05), 0 12px 36px rgba(31,42,68,.09);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 2px 4px rgba(47,111,223,.1), 0 16px 44px rgba(31,42,68,.14); }
.search-box .search-icon { flex-shrink: 0; color: var(--muted); }
textarea.query-input {
  flex: 1; min-width: 0; min-height: 0; font-family: inherit; font-size: 16px;
  color: var(--ink); border: 0; border-radius: 0; padding: 10px 6px;
  resize: none; overflow: hidden; background: transparent; line-height: 1.45; outline: none;
}
textarea.query-input::placeholder { color: var(--muted-light); }
.search-box .btn { border-radius: 999px; padding: 11px 22px; white-space: nowrap; }
.search-help {
  display: flex; align-items: center; justify-content: flex-end; gap: 16px;
  margin-top: 10px; padding: 0 8px;
}
.char-counter { color: var(--muted); font-size: 12.5px; }
.guest-counter { color: var(--tier-guest); font-size: 12.5px; }
.guest-counter a { color: var(--primary); font-weight: 600; }
.link-btn {
  background: none; border: 0; color: var(--primary); font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 2px; text-decoration: underline dotted;
}
.link-btn:hover { color: var(--primary-dark); }

/* compact top search bar (Google-results style) */
.search-compact {
  flex: 1; max-width: 640px; min-width: 200px; display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 5px 5px 5px 16px; margin: 2px 6px 0; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-compact:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 223, 0.12); }
.search-compact .search-icon { flex-shrink: 0; color: var(--muted); }
.search-compact-input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-family: inherit; font-size: 14.5px; color: var(--ink); padding: 7px 2px;
}
.search-compact-input::placeholder { color: var(--muted-light); }
.search-compact .btn { border-radius: 999px; padding: 7px 16px; }
body.has-results .header-title { display: none; }
body.has-results .app-shell { padding-top: 6px; }

/* pinned Pro message (always visible, no scroll) */
body.app { padding-bottom: 54px; }
.pro-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 9px 16px; font-size: 13px; color: var(--muted);
  box-shadow: 0 -6px 22px rgba(31, 42, 68, 0.07);
}
.pro-bar strong { color: var(--primary); font-weight: 700; }
.pro-bar-cta {
  background: var(--primary); color: #fff; border: 0; border-radius: 999px;
  font-family: inherit; font-weight: 700; font-size: 12.5px; padding: 6px 14px; cursor: pointer;
  transition: background 0.12s ease;
}
.pro-bar-cta:hover { background: var(--primary-dark); }

/* Subscribers/admin never see the "Go Pro" pitch — they get the thank-you panel. */
body.is-pro .pro-bar { display: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px;
  border-radius: 9px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
              box-shadow 0.15s ease, transform 0.12s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }
.btn-primary {
  background: linear-gradient(180deg, #3B79E6 0%, var(--primary) 100%);
  color: #fff; border-color: var(--primary); box-shadow: 0 4px 14px rgba(47, 111, 223, 0.28);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(47, 111, 223, 0.34); }
.btn-ghost { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); transform: translateY(-1px); }
.btn-google {
  background: #fff; color: #3c4043; border-color: var(--border-strong);
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.15);
}
.btn-google:hover { background: #f8f9fa; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(60, 64, 67, 0.2); }
.btn-google svg { flex-shrink: 0; }

/* federated sign-in buttons (Apple, Facebook, X, Microsoft, GitHub) */
.provider-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 2px;
}
.btn-provider {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 9px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn-provider:hover { background: var(--surface-2); border-color: var(--primary); }
.btn-provider svg { flex-shrink: 0; }
.btn-link {
  background: none; border: none; padding: 0; font-family: inherit;
  color: var(--primary); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }
.auth-link-row { text-align: right; margin: 2px 0 10px; }
.auth-error { color: var(--danger); }

/* ---------------------------------------------------------------- status */
.status-section { margin: 26px 0; }
.status-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px 22px; text-align: center; box-shadow: var(--shadow-sm);
}
.loading-card { display: flex; align-items: center; justify-content: center; gap: 18px; text-align: left; padding: 26px 22px; }
.spinner {
  width: 26px; height: 26px; flex-shrink: 0;
  border: 3px solid var(--border-strong); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.spinner.small { width: 15px; height: 15px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-weight: 700; margin-bottom: 4px; font-size: 15px; }
.loading-sub { color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 460px; }
.error-card { border-color: rgba(217, 85, 85, 0.4); background: var(--danger-soft); }
.notice-card { border-color: rgba(47, 111, 223, 0.35); background: var(--primary-soft); }
.error-title { font-weight: 700; margin-bottom: 6px; font-size: 16px; }
.error-sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }

/* ---------------------------------------------------------------- view switcher */
.view-switcher { margin: 20px 0 24px; border-bottom: 1px solid var(--border); }
.view-switcher-inner { display: flex; gap: 2px; max-width: 100%; overflow-x: auto; }
.view-tab {
  border: none; background: none; cursor: pointer;
  padding: 10px 18px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  white-space: nowrap; transition: color 0.12s ease, border-color 0.12s ease;
}
.view-tab:hover { color: var(--primary); }
.view-tab:disabled { opacity: 0.45; cursor: not-allowed; }
.view-tab:disabled:hover { color: var(--muted); }
.view-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------------------------------------------------------------- query card */
.query-section { margin: 4px 0 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow-sm);
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.card-title { font-weight: 700; font-size: 14px; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------- results */
.results-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin: 4px 0 14px; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow-sm);
  /* sticky while scrolling the results (professional-site standard) */
  position: sticky; top: 62px; z-index: 30;
}
.results-count { font-weight: 700; font-size: 15px; }
.mode-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 20px; }
@media (max-width: 900px) { .results-grid { grid-template-columns: 1fr; } }

/* Faceted filter sidebar + results layout (item 18) */
.results-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
.facet-sidebar {
  position: sticky; top: 74px; align-self: start; max-height: calc(100vh - 92px);
  overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 14px 14px 10px;
}
.facet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.facet-title { font-weight: 700; font-size: 14px; }
.facet-h2 {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 10px 0 6px;
}
.facet-group { margin-bottom: 12px; }
.facet-opts { display: flex; flex-direction: column; gap: 3px; }
.facet-opt {
  display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 8px;
  border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.facet-opt:hover { background: var(--surface-2); border-color: var(--border-strong); }
.facet-opt.active { background: var(--primary-soft); border-color: #C8D9F3; }
.facet-opt.empty { opacity: 0.45; }
.facet-opt input { accent-color: var(--primary); cursor: pointer; }
.facet-opt-label { flex: 1; min-width: 0; }
.facet-count {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 8px; min-width: 26px; text-align: center;
}
.facet-opt.active .facet-count { background: var(--primary); color: #fff; border-color: var(--primary); }
.facet-pubmed { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 4px; }
.facet-mesh { margin-top: 2px; }
.facet-chips { display: flex; flex-direction: column; gap: 5px; }
.facet-chips .filter-chip { justify-content: flex-start; }
.facet-toggle { display: none; }
@media (max-width: 900px) {
  .results-layout { grid-template-columns: 1fr; }
  .facet-toggle { display: inline-flex; }
  .facet-sidebar.collapsed { display: none; }
}
@media (min-width: 901px) {
  .facet-sidebar.collapsed { display: none; }
}

.col-header {
  display: flex; align-items: center; gap: 8px; font-weight: 700;
  padding: 9px 14px; border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 14px;
}
.col-free { background: var(--success-soft); color: var(--success); }
.col-paywall { background: var(--danger-soft); color: var(--danger); }
.col-badge {
  margin-left: auto; background: rgba(0, 0, 0, 0.06); color: inherit;
  padding: 1px 9px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 700;
}
.articles { display: flex; flex-direction: column; gap: 12px; }

.article-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.article-card:hover {
  border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px);
}
.article-card.muted { color: var(--muted); font-style: italic; text-align: center; }
.article-title-row { display: flex; align-items: flex-start; gap: 8px; }
.article-title { font-weight: 600; font-size: 15px; margin-bottom: 5px; line-height: 1.4; flex: 1; min-width: 0; }
.article-title mark { background: #FFE9A8; color: #5A3E00; border-radius: 3px; padding: 0 1px; }
[data-theme="dark"] .article-title mark,
[data-theme="oled"] .article-title mark { background: #7A5A00; color: #FFE9A8; }
.corrected-mark {
  display: inline-block; margin-left: 6px; vertical-align: 2px;
  font-size: 10.5px; font-weight: 700; color: #8A5B14;
  background: var(--warning-soft); border: 1px solid #E8D9AE;
  border-radius: 999px; padding: 1px 8px; cursor: help;
}
.article-summary mark { background: #FFE9A8; color: #5A3E00; border-radius: 3px; padding: 0 1px; }
[data-theme="dark"] .article-summary mark,
[data-theme="oled"] .article-summary mark { background: #7A5A00; color: #FFE9A8; }

/* "show more" per column (item 18/1b) */
.col-more { margin: 10px auto 0; display: block; }
.article-meta { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.article-meta .journal { font-weight: 600; color: var(--ink); }
.meta-dot { color: var(--muted-light); margin: 0 4px; }

.chips { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.chip {
  display: inline-block;
  font-size: 11.5px; font-weight: 600; padding: 3px 10px;
  border-radius: 999px; border: 1px solid transparent;
}
.chip-free { color: var(--success); background: var(--success-soft); border-color: #CDE3D5; }
.chip-likely { color: var(--warning); background: var(--warning-soft); border-color: #EDDCAE; }
.chip-paywall { color: var(--danger); background: var(--danger-soft); border-color: #EBD3C9; }
.chip-type { color: var(--primary); background: var(--primary-soft); border-color: #C8D9F3; }
.chip-pmc { color: #5B4A8F; background: #F0EDF7; border-color: #DCD3EE; }
.chip-license { color: #2A6B78; background: #E8F2F4; border-color: #C6E0E5; }
.chip-corrected { color: #8A5B14; background: var(--warning-soft); border-color: #E8D9AE; }
.chip-cited {
  color: #5A6B82; background: #F0F4F7; border-color: #D7DFE8;
}
.chip-pct { color: #6B3FA0; background: #F1EAF8; border-color: #DFCFF0; }
.chip-fund-industry { color: #8A3D2B; background: #FBEFEA; border-color: #F0D4C9; }
.chip-fund-gov { color: #1F5B3B; background: #EAF4EE; border-color: #CBE2D3; }
.chip-fund { color: #4A5F8A; background: #EDF1F8; border-color: #D3DCEB; }
.chip-medline { color: #2A6B78; background: #E8F2F4; border-color: #C6E0E5; }
.chip-convo { cursor: pointer; color: #7A5B14; background: var(--warning-soft); border-color: #E8D9AE; }
.chip-convo:hover { background: var(--warning); color: #fff; border-color: var(--warning); }
.article-conversation {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--warning); border-radius: 6px;
  padding: 9px 12px; margin: 0 0 9px; font-size: 12.5px; color: var(--ink);
}
.convo-title { font-weight: 700; margin-bottom: 5px; font-size: 12px; }
.convo-item { line-height: 1.5; margin: 3px 0; }
.article-epub { font-size: 11.5px; color: var(--muted); margin: 0 0 8px; }

.article-retracted {
  background: var(--danger-soft); border: 1px solid #E8B4B4; color: var(--danger);
  border-radius: 6px; font-size: 12.5px; font-weight: 700; padding: 7px 11px;
  margin-bottom: 10px; line-height: 1.4;
}

.article-summary {
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  padding: 9px 13px;
  font-size: 13px; margin: 2px 0 9px; color: var(--ink);
}
.article-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
/* Secondary action row (PubMed / PMC / PDF / Similar / References / Cited by):
   smaller, quieter pills so the primary Quick read / CPD / bib row stays
   dominant while every card action remains visible (no kebab menu). */
.article-links-secondary { margin-top: 7px; }
.article-links-secondary .link-pill {
  font-size: 11.5px; font-weight: 500; padding: 3px 9px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border-strong);
}
.article-links-secondary .link-pill:hover {
  background: var(--primary-soft); border-color: var(--primary); color: var(--primary);
}
.link-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); padding: 5px 12px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; transition: all 0.15s ease;
}
.link-pill:hover { background: var(--primary); color: #fff; text-decoration: none; }
.link-accent { color: var(--success); background: var(--success-soft); }
.link-accent:hover { background: var(--success); color: #fff; }

/* ---------------------------------------------------------------- dashboard */
.synth-header {
  background: linear-gradient(120deg, #22304B 0%, #2B3B5C 100%); color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 22px; display: flex; justify-content: space-between;
  align-items: center; gap: 12px; flex-wrap: wrap;
}
.synth-title { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.synth-meta { font-size: 13px; opacity: 0.85; }
.synth-mode {
  font-size: 12px; font-weight: 600;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 4px 10px; border-radius: var(--radius-sm); white-space: nowrap;
}
.synth-loading {
  background: var(--surface); padding: 24px 22px;
  display: flex; align-items: center; gap: 12px; color: var(--muted);
  border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius);
}.synth-loading[hidden], #synthBody[hidden] { display: none; }
.explore-loading-msg {
  font-size: 13px; color: var(--muted); line-height: 1.55;
  margin-bottom: 10px; font-weight: 500;
}
#xLoading { flex-direction: column; align-items: stretch; }
#xLoading .explore-loading-msg { text-align: left; }
#synthBody {
  background: var(--surface); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px 22px 24px; box-shadow: var(--shadow-sm);
}

.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; padding: 9px 14px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; border-radius: 0;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted);
  transition: color 0.12s ease, border-color 0.12s ease;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.caption { font-size: 13px; color: var(--muted); margin: 4px 0 12px; max-width: 720px; }

/* export bar */
.export-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.export-label { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-right: 4px; }

/* plots */
.plot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 14px; }
@media (max-width: 900px) { .plot-grid { grid-template-columns: 1fr; } }
.plot-box {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: #fff;
}
.plot-title {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.plot { width: 100%; min-height: 300px; }
.plot-empty {
  color: var(--muted); padding: 28px; text-align: center; font-size: 14px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); margin: 8px 0;
}

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
#evidenceTable { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 13px; text-align: left; vertical-align: top; }
.table th {
  background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
.table td { border-top: 1px solid var(--border); }
.table tbody tr:hover td { background: var(--surface-2); }
.td-title { min-width: 250px; font-weight: 500; }
.effect-list { margin-bottom: 14px; }
.meta-note { font-size: 13px; color: var(--muted); margin: 10px 0; }

/* summary + references */
.synthesis-text { font-size: 15px; line-height: 1.7; max-width: 860px; color: var(--ink); }
.synthesis-text h1, .synthesis-text h2 { font-family: var(--serif); color: var(--ink); margin: 18px 0 7px; font-weight: 600; }
.synthesis-text h1 { font-size: 20px; } .synthesis-text h2 { font-size: 17px; }
.synthesis-text h3 { color: var(--ink); margin: 12px 0 5px; font-size: 15px; }
.synthesis-text ul { padding-left: 22px; margin: 8px 0; }
.synthesis-text p { margin: 9px 0; }
.cite {
  color: var(--muted); font-size: 11px; font-weight: 700; text-decoration: none;
  border-bottom: 1px dotted var(--border-strong); cursor: pointer;
}
.cite:hover { color: var(--primary); border-bottom-color: var(--primary); }

/* clean, sectioned narrative (no raw markdown symbols) */
.narrative-sec { margin: 0 0 22px; }
.narrative-h {
  font-family: var(--serif); font-size: 17px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.01em; margin: 0 0 6px; padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.narrative-body p { margin: 8px 0; }
.narrative-list { padding-left: 22px; margin: 8px 0; }
.narrative-list li { margin: 4px 0; }

/* question-type badge */
.synth-qtype {
  display: inline-block; margin-top: 7px;
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); border: 1px solid #C8D9F3;
  border-radius: 999px; padding: 3px 12px;
}
.synth-qtype[hidden] { display: none; }

/* grounded cited answers — the sources behind the AI narrative */
.grounding { margin-top: 20px; max-width: 860px; }
.ground-h {
  font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em;
  text-transform: uppercase; margin: 0 0 10px;
}
.ground-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.ground-src {
  display: flex; gap: 11px; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 13px; scroll-margin-top: 96px; transition: background 0.15s ease, border-color 0.15s ease;
}
.ground-src:target {
  background: #F0F5FF; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 223, 0.12);
}
.ground-num {
  flex: 0 0 auto; min-width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--muted); font-weight: 700; font-size: 12.5px;
  display: inline-flex; align-items: center; justify-content: center;
}
.ground-body { flex: 1; min-width: 0; }
.ground-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.ground-pmid { color: var(--muted); font-weight: 500; }
.ground-sec { color: var(--muted); background: var(--surface); border: 1px solid var(--border-strong); font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; margin-left: 5px; }
.ground-quote {
  font-size: 13px; color: var(--ink); font-style: italic; line-height: 1.55; margin: 0 0 6px;
  padding-left: 11px; border-left: 3px solid var(--border-strong);
}
.ground-src .link-pill { font-size: 12px; padding: 3px 10px; }

.references { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.references-title {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px;
}
.reference-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.reference-list li { display: flex; gap: 9px; font-size: 12.5px; line-height: 1.5; color: #3A3A36; }
.ref-num {
  flex-shrink: 0; min-width: 24px; height: 21px; text-align: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700;
  border-radius: 4px; font-size: 11.5px; padding: 1px 0;
}
.ref-authors { font-weight: 600; }
.ref-title { color: var(--ink); }
.ref-free { color: var(--success); background: var(--success-soft); font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 4px; margin-left: 5px; }

/* footer */
.footer {
  margin-top: 40px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  font-size: 12.5px; color: var(--muted); box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------- plot export */
.plot-export { float: right; display: inline-flex; gap: 4px; }
.btn-export {
  font-size: 10px; font-weight: 700; padding: 1px 7px; cursor: pointer;
  background: #fff; color: var(--primary); border: 1px solid var(--border-strong);
  border-radius: 3px; transition: all 0.12s ease;
}
.btn-export:hover { background: var(--primary); color: #fff; }

/* ---------------------------------------------------------------- findings */
.outcome-blocks { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.outcome-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface); }
.ob-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.ob-name { font-weight: 700; font-size: 14px; }
.ob-label { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 4px; }
.ob-n { font-size: 12px; color: var(--muted); margin-left: auto; }
.ob-pooled { font-size: 13px; font-weight: 600; color: var(--primary-dark); margin: 4px 0; }
.ob-studies { padding-left: 20px; margin: 4px 0 0; }
.ob-studies li { font-size: 12.5px; margin-bottom: 3px; }
.lbl-good { color: var(--success); background: var(--success-soft); }
.lbl-bad { color: var(--danger); background: var(--danger-soft); }
.lbl-mixed { color: var(--warning); background: var(--warning-soft); }

/* ---------------------------------------------------------------- account chip */
.account-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 6px 12px; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); white-space: nowrap;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.account-chip:hover { border-color: var(--primary); color: var(--primary); }
.ac-guest { color: var(--tier-guest); border-color: rgba(100, 116, 139, 0.4); }
.ac-basic { color: var(--tier-basic); border-color: rgba(15, 118, 110, 0.4); }
.ac-pro { color: var(--tier-pro); border-color: rgba(79, 70, 229, 0.45); }

.account-menu {
  position: fixed; z-index: 1100; width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12); padding: 6px;
}
.am-status { font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.am-item {
  display: block; width: 100%; text-align: left; border: none; background: none; cursor: pointer;
  font-size: 13px; padding: 7px 8px; border-radius: 4px; color: var(--ink);
}
.am-item:hover { background: var(--primary-soft); color: var(--primary); }

/* ---------------------------------------------------------------- tier comparison table */
.tier-compare { margin-bottom: 8px; }
.tier-table {
  width: 100%; border-collapse: collapse; margin-bottom: 12px;
  font-size: 12.5px; background: var(--surface);
}
.tier-table th, .tier-table td {
  padding: 8px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top;
}
.tier-table thead th {
  font-size: 12px; font-weight: 700; background: var(--surface-2); white-space: nowrap;
}
.tier-table .th-feature, .tier-table .td-feature { color: var(--ink); font-weight: 600; }
.tier-table thead .col-guest { color: var(--tier-guest); }
.tier-table thead .col-basic { color: var(--tier-basic); }
.tier-table thead .col-pro { color: var(--tier-pro); }
.tier-table td.col-guest, .tier-table td.col-basic, .tier-table td.col-pro { color: var(--muted); white-space: nowrap; }
.tier-table td.td-feature { white-space: normal; min-width: 190px; }
.tier-table .col-guest.is-current { background: var(--tier-guest-soft); }
.tier-table .col-basic.is-current { background: var(--tier-basic-soft); }
.tier-table .col-pro.is-current { background: var(--tier-pro-soft); }
.tier-table thead .is-current { box-shadow: inset 0 -2px 0 currentColor; }
.tick-yes { color: var(--success); font-weight: 700; }
.tick-no { color: #B4534D; font-weight: 700; }
@media (max-width: 640px) {
  .tier-table td.col-guest, .tier-table td.col-basic, .tier-table td.col-pro { white-space: normal; font-size: 11.5px; }
  .tier-table td.td-feature { min-width: 0; }
}

/* ---------------------------------------------------------------- premium section */
.premium-section { margin-top: 10px; }
.section-header { margin-bottom: 20px; }
.section-label { font-size: 11.5px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.section-title.serif { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--ink); }
.section-desc { color: var(--muted); font-size: 14.5px; max-width: 640px; margin-top: 4px; }
.support-note {
  background: var(--surface-2); border-left: 4px solid var(--primary);
  border-top: 1px solid var(--border); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 20px; margin-bottom: 20px; max-width: 860px;
}
.support-note p { font-size: 14px; line-height: 1.7; color: var(--ink); margin: 0 0 8px; }
.support-note p:last-child { margin-bottom: 0; }
.support-cta { color: var(--muted); font-size: 13.5px; }
.support-note strong { color: var(--primary-dark); }
.premium-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
@media (max-width: 760px) { .premium-grid { grid-template-columns: 1fr; } }
.premium-col {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm); position: relative;
}
.premium-col-pro { border: 2px solid var(--primary); }
.premium-flag {
  position: absolute; top: -11px; right: 16px; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 4px; letter-spacing: 0.06em;
}
.premium-col-title { font-size: 16px; margin-bottom: 12px; }
.premium-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.premium-list li { font-size: 13.5px; color: var(--ink); padding-left: 18px; position: relative; }
.premium-list li::before { content: '✓'; position: absolute; left: 0; color: var(--primary); font-weight: 700; }
.premium-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------------------------------------------------------------- pro UI */
.premium-banner {
  background: var(--warning-soft); border: 1px solid #E8D9AE; color: #6E4E12;
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
}
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 24px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(28, 27, 25, 0.45); }
.modal-panel {
  position: relative; width: 100%; max-width: 880px; background: var(--surface);
  border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  margin: auto 0; max-height: 90vh; display: flex; flex-direction: column;
}
.modal-narrow { max-width: 460px; }
.modal-wide { max-width: 860px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-title { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.modal-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.modal-body { overflow-y: auto; padding: 20px; }
.divider { text-align: center; color: var(--muted-light); font-size: 12px; margin: 12px 0; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
}
.field input:focus { outline: 2px solid rgba(15, 118, 110, 0.2); border-color: var(--primary); }
.modal-body .btn-block + .btn-block { margin-top: 8px; }

/* ---------------------------------------------------------------- quick read (legacy modal) */
.qr-atglance { margin-bottom: 16px; }
.ag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.ag-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--surface); }
.ag-key { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ag-val { display: block; font-size: 13px; font-weight: 600; margin-top: 2px; }
.qr-llm { border-left: 3px solid var(--primary); background: var(--primary-soft); padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-bottom: 16px; }
.qr-section { margin-bottom: 16px; }
.qr-section h4 { font-size: 13px; color: var(--primary-dark); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.qr-section ul { padding-left: 22px; }
.qr-section li { font-size: 13.5px; margin-bottom: 4px; }
.sm-list li { list-style: none; }
.sm-head { font-weight: 600; }
.qr-note {
  background: var(--warning-soft); border: 1px solid #E8D9AE; color: #6E4E12;
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin: 10px 0;
}
mark.hl { background: #FFF1B8; padding: 0 2px; border-radius: 2px; }
.qr-article { font-size: 13.5px; line-height: 1.65; color: #3A3A36; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--surface); }

/* ================================================================
   QUICK READ SPLIT VIEW (read.html)
   ================================================================ */
html, body.reader { height: 100%; }
body.reader { display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }

.reader-topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
  flex-shrink: 0;
}
.reader-title { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.reader-meta { font-size: 12.5px; color: var(--muted); }
.reader-retracted {
  background: var(--danger-soft); border: 1px solid #E8B4B4; color: var(--danger);
  border-radius: 6px; font-size: 12.5px; font-weight: 700; padding: 6px 10px;
  margin-bottom: 8px; line-height: 1.4;
}
.reader-retracted.corrected { color: #8A5B14; background: var(--warning-soft); border-color: #E8D9AE; }
.reader-topbar .spacer { flex: 1; }

.reader-split { display: flex; flex: 1; min-height: 0; }

/* left: summary */
.rp-left {
  width: 42%; min-width: 300px; overflow-y: auto; background: var(--bg);
  border-right: 1px solid var(--border); padding: 20px 18px 40px;
}
/* right: article */
.rp-right { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 26px 60px; background: var(--surface); }

/* draggable divider */
.rp-divider {
  width: 7px; flex-shrink: 0; cursor: col-resize; background: var(--border);
  position: relative;
}
.rp-divider:hover, .rp-divider.dragging { background: var(--primary); }
.rp-divider::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--border-strong); }

.reader-loading { display: flex; align-items: center; gap: 12px; padding: 40px; color: var(--muted); }

/* left-pane blocks */
.rp-block { margin-bottom: 22px; }
.rp-h { font-size: 12px; font-weight: 700; color: var(--primary-dark); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }

.rp-kpoints { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.rp-kp {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; background: var(--surface); font-size: 13.5px; line-height: 1.5;
  cursor: pointer; transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.rp-kp:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.rp-kp.active { border-color: var(--primary); background: var(--primary-soft); }
.rp-kp-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.rp-tag {
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 3px;
  color: var(--primary); background: var(--primary-soft); cursor: pointer;
}
.rp-tag:hover { background: var(--primary); color: #fff; }
.rp-tag.fig { color: #2A6B78; background: #E8F2F4; }
.rp-tag.fig:hover { background: #2A6B78; color: #fff; }

/* right-pane article */
.rp-article-title { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.35; margin-bottom: 6px; }
.rp-article-meta { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

.rp-section { margin-bottom: 22px; scroll-margin-top: 16px; }
.rp-section h3 { font-family: var(--serif); font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.rp-section p { font-size: 14.5px; line-height: 1.75; color: #33322E; margin: 0 0 10px; }
.kp-sentence { background: transparent; border-radius: 2px; padding: 1px 2px; transition: background 0.25s ease; }
.kp-sentence.hl { background: #FFF1B8; box-shadow: 0 0 0 2px #FFF1B8; }
.kp-sentence.soft { background: #FBF3D9; }

/* persisted user highlights (Quick Read) */
.user-hl { border-radius: 2px; padding: 1px 2px; cursor: pointer; }
.user-hl.cat-findings { background: #FFF1B8; }
.user-hl.cat-methods { background: #DDF1DD; }
.user-hl.cat-limitations { background: #FBDEE4; }
.user-hl.cat-definitions { background: #DCEBFB; }
.user-hl.cat-other { background: #EAEAEA; }
.user-hl.flash-ring { box-shadow: 0 0 0 3px rgba(47, 111, 223, 0.55); }

/* highlights panel (left pane) */
.rp-hl { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; background: var(--surface); font-size: 13px; line-height: 1.5; cursor: pointer; transition: border-color 0.12s ease, box-shadow 0.12s ease; }
.rp-hl:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.hl-main { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; justify-content: space-between; }
.hl-quote { color: #33322E; font-style: italic; }
.hl-cat { font-size: 11.5px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); color: var(--ink); cursor: pointer; }
.hl-remove { border: none; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; padding: 0 2px; line-height: 1; }
.hl-remove:hover { color: #C0392B; }
.hl-clear { font-size: 11px; color: var(--muted); text-decoration: underline; cursor: pointer; margin-left: 6px; }
.hl-clear:hover { color: #C0392B; }
.hl-legend { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.hl-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0, 0, 0, 0.15); }
.hl-dot.cat-findings { background: #FFF1B8; }
.hl-dot.cat-methods { background: #DDF1DD; }
.hl-dot.cat-limitations { background: #FBDEE4; }
.hl-dot.cat-definitions { background: #DCEBFB; }
.hl-dot.cat-other { background: #EAEAEA; }

.rp-figure, .rp-table { margin: 14px 0; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); scroll-margin-top: 16px; }
.rp-figure img { max-width: 100%; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.rp-figure .cap, .rp-table .cap { font-size: 12px; color: var(--muted); margin-top: 6px; }
.rp-figure .cap strong, .rp-table .cap strong { color: var(--ink); }
.rp-table .tbl { overflow-x: auto; }
.rp-table table { border-collapse: collapse; width: 100%; font-size: 12px; background: #fff; }
.rp-table th, .rp-table td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; vertical-align: top; }
.rp-table th { background: var(--surface-2); }

/* mobile: stacked panes */
@media (max-width: 900px) {
  body.reader { overflow: auto; }
  .reader-split { flex-direction: column; }
  .rp-left { width: 100% !important; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); }
  .rp-divider { display: none; }
  .rp-right { flex: none; }
  .reader-mobile-toggle { display: flex; }
}
.reader-mobile-toggle { display: none; gap: 6px; margin-left: auto; }
.reader-mobile-toggle .btn-sm.active { background: var(--primary); color: #fff; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 700px) {
  .main-content { padding: 20px 14px 44px; }
  .header-inner { padding: 13px 16px; gap: 12px; }
  .logo-mark { width: 34px; height: 34px; font-size: 13px; }
  .header-title h1 { font-size: 18px; }
  .tagline { font-size: 12px; }
  .search-hero h2 { font-size: 22px; }
  .mode-badge { font-size: 11px; padding: 4px 9px; }
  .view-switcher-inner { width: 100%; }
  .view-tab { flex: 1; padding: 10px 8px; text-align: center; }
  .synth-header { padding: 13px 16px; }
  #synthBody { padding: 14px 13px 18px; }
  .results-bar { align-items: flex-start; }
  .article-card { padding: 13px 14px; }
}

/* ------------------------------------------------------- Pass 5: Blocksy life */
.header { position: sticky; top: 0; z-index: 60; }
.header::after {
  content: ''; display: block; height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, #3B79E6 45%, #6FA3F2 100%);
}
.header-inner { box-shadow: 0 1px 0 rgba(31, 42, 68, 0.04); }
.logo-mark { border-radius: 10px; box-shadow: 0 4px 12px rgba(47, 111, 223, 0.32); }
.header-title h1 { letter-spacing: -0.2px; }

.feature-item { transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease; }
.feature-item:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* entrance motion */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.view, #resultsSection, #synthBody, #mapBody, .status-card, .notice-card {
  animation: fadeUp 0.32s ease both;
}
#resultsSection .article-card { animation: fadeUp 0.32s ease both; }
#freeArticles .article-card:nth-child(2) { animation-delay: 0.04s; }
#freeArticles .article-card:nth-child(3) { animation-delay: 0.08s; }
#freeArticles .article-card:nth-child(4) { animation-delay: 0.12s; }
#paywalledArticles .article-card:nth-child(2) { animation-delay: 0.04s; }
#paywalledArticles .article-card:nth-child(3) { animation-delay: 0.08s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------- Pass 2: discovery */

/* cited-by badge */
.chip-cited {
  color: var(--primary-dark); background: var(--primary-soft);
  border-color: #CBE2DE; font-weight: 700;
}

/* refine bar (filters + MeSH chips) */
.filter-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin: 0 0 14px;
  box-shadow: var(--shadow-sm);
}
.filter-row { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.filter-row + .filter-row { margin-top: 10px; }
.filter-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding-top: 5px; white-space: nowrap;
}
.filter-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.filter-chip {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  padding: 5px 11px; border-radius: 999px; cursor: pointer; transition: all 0.12s ease;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  color: #fff; background: var(--primary); border-color: var(--primary);
}

/* explore buttons on cards */
.link-pill.discover { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--muted); }
.link-pill.discover:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* explore drawer */
.drawer { position: fixed; inset: 0; z-index: 80; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(28, 27, 25, 0.4); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 94vw);
  background: var(--bg); border-left: 1px solid var(--border); box-shadow: -12px 0 40px rgba(28, 27, 25, 0.12);
  display: flex; flex-direction: column;
}
.drawer-header { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.drawer-title { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.drawer-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.drawer-tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.drawer-list { flex: 1; overflow-y: auto; padding: 14px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.ex-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px;
}
.ex-card .article-title { font-size: 13.5px; line-height: 1.45; font-weight: 600; margin-bottom: 5px; }
.ex-card .ex-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.ex-links { display: flex; gap: 7px; flex-wrap: wrap; }
.ex-empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13.5px; }

/* stance chips (consensus) */
.chip-stance { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 2px 8px; border-radius: 4px; }
.stance-support { color: var(--success); background: var(--success-soft); border: 1px solid #CDE3D5; }
.stance-refute { color: var(--danger); background: var(--danger-soft); border: 1px solid #EBD3C9; }
.stance-neutral { color: var(--warning); background: var(--warning-soft); border: 1px solid #EDDCAE; }
.stance-unclear { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-strong); }

/* consensus meter (dashboard summary) */
.consensus-meter {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px 12px; margin-bottom: 18px; background: var(--surface);
}
.cm-title {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 9px;
}
.cm-bar { display: flex; height: 30px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border-strong); }
.cm-seg { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; cursor: pointer; min-width: 34px; transition: filter 0.12s ease; }
.cm-seg:hover { filter: brightness(0.94); }
.cm-seg.support { background: var(--success); }
.cm-seg.refute { background: var(--danger); }
.cm-seg.neutral { background: var(--warning); }
.cm-seg.unclear { background: var(--muted-light); }
.cm-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.cm-groups { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cm-group .cm-head { font-size: 13px; font-weight: 600; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.cm-group .cm-papers { margin: 6px 0 2px 22px; display: flex; flex-direction: column; gap: 6px; }
.cm-paper { font-size: 12.5px; line-height: 1.45; }
.cm-paper .muted { display: block; font-size: 12px; }

/* citation map view */
.map-toolbar .map-rebuild { color: #fff; background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.35); }
.map-toolbar .map-rebuild:hover { background: rgba(255, 255, 255, 0.22); }
.map-body {
  background: var(--surface); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); padding: 18px 18px 20px;
  box-shadow: var(--shadow-sm);
}
.map-body .plot { min-height: 460px; }
.map-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.legend-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.dot-seed { background: #0F766E; }
.dot-discovered { background: #009E73; }
.map-detail {
  margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 14px 16px;
}
.map-detail .md-title { font-family: var(--serif); font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.map-detail .md-meta { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.map-detail .md-abstract { font-size: 13.5px; line-height: 1.6; color: var(--ink); margin-bottom: 10px; }

/* Pass 3: two-pane citation map */
.map-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.map-hint { font-size: 12.5px; color: var(--muted); }
.map-panes { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 14px; }
@media (max-width: 900px) { .map-panes { grid-template-columns: 1fr; } }
.map-list-pane {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); display: flex; flex-direction: column; max-height: 560px;
}
.map-list-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 9px 13px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.map-list { overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.map-row {
  border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; border: 1px solid transparent;
}
.map-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.map-row-title { font-size: 12.5px; font-weight: 600; line-height: 1.4; }
.map-row-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.map-tag {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 1px 6px; border-radius: 3px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border-strong); vertical-align: 1px; margin-left: 4px;
}
.map-tag-seed { color: #fff; background: var(--primary); border-color: var(--primary); }
.map-graph-pane { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.map-graph-pane .plot { min-height: 460px; }
.map-more { align-self: center; margin: 8px; }

/* Pass 3: verdict pills + result tables */
.outcome-blocks { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.outcome-block {
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface);
}
.ob-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.ob-name { font-weight: 700; font-size: 14.5px; }
.ob-verdict { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.ob-verdict.v-good { color: var(--success); background: var(--success-soft); border: 1px solid #CDE3D5; }
.ob-verdict.v-bad { color: var(--danger); background: var(--danger-soft); border: 1px solid #EBD3C9; }
.ob-verdict.v-mixed { color: var(--warning); background: var(--warning-soft); border: 1px solid #EDDCAE; }
.ob-verdict.v-insuff { color: var(--muted); background: var(--surface); border: 1px solid var(--border-strong); }
.ob-n { font-size: 12px; color: var(--muted); margin-left: auto; }
.ob-pooled { padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 13px; background: var(--primary-soft); }
.ob-pooled-none { background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.outcome-block .table { margin: 0; }
.td-study { min-width: 160px; font-weight: 600; }
.td-est { min-width: 150px; font-variant-numeric: tabular-nums; }
.td-src { color: var(--muted); font-size: 12.5px; min-width: 240px; }

.read-more { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--surface); }
.read-more summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 13px; color: var(--primary); }
.read-more-body { padding: 2px 18px 14px; font-size: 13px; color: var(--muted); line-height: 1.65; }
.read-more-body ul { padding-left: 20px; }

/* Pass 3: export dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); padding: 6px; display: flex; flex-direction: column;
}
.dropdown-menu button {
  text-align: left; background: none; border: none; padding: 9px 12px; font-size: 13px;
  font-weight: 600; color: var(--ink); border-radius: var(--radius-sm); cursor: pointer;
}
.dropdown-menu button:hover { background: var(--primary-soft); color: var(--primary); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* Project workspaces dropdown */
.projects-dd #projectsMenu { min-width: 260px; }
.ws-row { display: flex; align-items: center; gap: 4px; border-radius: var(--radius-sm); }
.ws-row.active { background: var(--primary-soft); }
.ws-open { flex: 1; text-align: left; background: none; border: none; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--ink); border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-row:hover .ws-open { color: var(--primary); }
.ws-row.active .ws-open { color: var(--primary); }
.ws-rename, .ws-del { border: none; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 4px 5px; border-radius: 4px; }
.ws-rename:hover { color: var(--primary); }
.ws-del:hover { color: #C0392B; }
.ws-empty { padding: 8px 10px; font-size: 12.5px; color: var(--muted); }
.ws-new { width: 100%; }

/* Pass 3: reader type badge + AI loading */
.rp-type-badge {
  display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 10px; border-radius: 999px;
  color: var(--primary-dark); background: var(--primary-soft); border: 1px solid #CBE2DE;
}
.llm-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; padding: 6px 0; }

/* Pass 6: honour the HTML `hidden` attribute against display:flex rules
   (fixes the permanently-open export menu and the empty reader split). */
[hidden] { display: none !important; }

/* Pass 6: reader right pane — hierarchy, references, figure fallback */
.rp-section h2 { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 4px 0 10px; }
.rp-section h3 { font-family: var(--serif); font-size: 18px; font-weight: 600; margin: 4px 0 9px; }
.rp-section h4 { font-family: var(--serif); font-size: 16px; font-weight: 600; margin: 4px 0 8px; }
.rp-section p { font-size: 14.5px; line-height: 1.75; color: #33322E; margin: 0 0 10px; }
.rp-section ul, .rp-section ol { margin: 0 0 10px; padding-left: 24px; }
.rp-section li { font-size: 14px; line-height: 1.7; color: #33322E; margin: 4px 0; }
.rp-fig-fallback {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 13px; color: var(--muted); background: var(--surface-2);
}
.rp-references { border-top: 2px solid var(--border); padding-top: 14px; }
.rp-reflist { counter-reset: ref; list-style: none; padding-left: 0 !important; }
.rp-reflist li { font-size: 13px; line-height: 1.6; color: #3A3A36; margin: 8px 0; padding-left: 34px; position: relative; }
.rp-reflist li::before {
  counter-increment: ref; content: counter(ref); position: absolute; left: 0; top: 1px;
  min-width: 24px; height: 20px; text-align: center; background: var(--primary-soft);
  color: var(--primary); font-weight: 700; border-radius: 4px; font-size: 11.5px; padding: 1px 0;
}

/* Pass 6: citation map — list first, graph below */
.map-panes { grid-template-columns: 1fr; }
.map-list-pane { max-height: 320px; }
@media (min-width: 901px) and (max-width: 1200px) { .map-list-pane { max-height: 280px; } }

/* Pass 6: explore workspace — interactive network (Cytoscape) */
.explore-page { height: 100vh; display: flex; flex-direction: column; }
.explore-main {
  flex: 1; min-height: 0; width: 100%;
  padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.x-trail {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 14px; box-shadow: var(--shadow-sm); flex-shrink: 0;
}
.x-trail-controls { display: flex; gap: 6px; flex-shrink: 0; }
.x-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; }
.x-crumb {
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 11px; cursor: pointer;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.x-crumb:hover { border-color: var(--primary); color: var(--primary); }
.x-crumb.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.x-crumb-sep { color: var(--muted-light); }

/* Full-page map: graph fills the viewport; left list + right rankings float
   over it and collapse to small icon toggles (Google Maps style). */
.x-body {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.x-graph-wrap {
  position: absolute; inset: 0;
  /* Full-page graph/map: the graph slot fills the whole wrap; the top toolbar
     (view toggle + controls) and the bottom legend/hint float over it as
     translucent overlays (Google-Maps style) instead of stealing layout height. */
}
.x-graph-slot { position: absolute; inset: 0; min-height: 0; display: flex; flex-direction: column; }
.x-cytoscape {
  flex: 1; min-height: 0; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: radial-gradient(circle at 20% 20%, #FBFDFF, #F4F7FB);
  position: relative;
}

/* world-map view (Part 5b): plotly scattergeo fills the same slot as the graph */
.x-map { position: absolute; inset: 0; display: flex; flex-direction: column; z-index: 5; }
.x-map[hidden] { display: none; }
.x-map-toggle { display: flex; gap: 6px; position: absolute; top: 52px; left: 50%; transform: translateX(-50%); z-index: 1000; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px; box-shadow: var(--shadow-md); }
.x-map-toggle .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.x-map-leaflet { position: absolute; inset: 0; z-index: 1; }
.x-map-leaflet .plotly-graph-div { width: 100% !important; height: 100% !important; }

/* left paper list — floating card */
.x-list-wrap {
  position: absolute; left: 14px; top: 14px; bottom: 14px; width: 320px; z-index: 20;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; overflow: hidden;
}
.x-list-wrap.collapsed { display: none; }

/* right rankings — floating card */
.x-rank-wrap {
  position: absolute; right: 14px; top: 14px; bottom: 14px; width: 270px; z-index: 20;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  box-shadow: var(--shadow-md); overflow-y: auto; padding: 12px;
}
.x-rank-wrap.collapsed { display: none; }
.x-rank-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }

/* floating collapse toggles */
.x-panel-toggle {
  position: absolute; z-index: 25;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--ink);
  font-size: 12.5px; font-weight: 700; padding: 7px 13px; border-radius: 999px;
  box-shadow: var(--shadow-md); cursor: pointer;
}
.x-panel-toggle:hover { border-color: var(--primary); color: var(--primary); }
.x-panel-toggle-left { left: 14px; top: 14px; }
.x-panel-toggle-right { right: 14px; top: 14px; }
.x-collapse-btn {
  background: none; border: 1px solid var(--border-strong); color: var(--muted);
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.x-collapse-btn:hover { border-color: var(--primary); color: var(--primary); }

.map-list-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.x-rank-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 2px 0 8px; }
.x-rank-h2 { margin-top: 16px; }
.x-rank-list { list-style: none; padding: 0; margin: 0 0 4px; display: flex; flex-direction: column; gap: 4px; }
.x-rank-item {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: pointer;
  padding: 5px 8px; border-radius: 6px; border: 1px solid transparent; min-width: 0;
}
.x-rank-item:hover { background: var(--primary-soft); border-color: #C8D9F3; }
.x-rank-num {
  flex: 0 0 auto; min-width: 19px; height: 19px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--muted);
  font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.x-rank-name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.x-rank-item .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: 11px; }
.x-rank-note { font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.x-rank-empty { list-style: none; padding: 4px 0; }
.x-list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 6px;
  display: flex; flex-direction: column; gap: 6px;
}
.x-row {
  display: flex; gap: 10px; padding: 10px 10px; border-radius: var(--radius-sm);
  border: 1px solid transparent; transition: border-color 0.12s ease, background 0.12s ease;
}
.x-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.x-row.picked {
  background: var(--primary-soft); border-color: #C8D9F3;
  box-shadow: inset 3px 0 0 var(--primary);
}
.x-row.picked .x-row-title { color: var(--primary-dark); }
@keyframes xRowPicked { 0% { background: #FFF3D6; } 100% { background: var(--primary-soft); } }
.x-row.picked { animation: xRowPicked 0.7s ease; }
.x-check { flex-shrink: 0; padding-top: 2px; }
.x-check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.x-row-body { min-width: 0; }
.x-row-title { font-size: 13px; font-weight: 600; line-height: 1.4; }
.x-row-meta { font-size: 11.5px; color: var(--muted); margin: 2px 0 6px; }

/* Floating top toolbar (view toggle + controls) over the full-page graph/map.
   Slim single row so it never blocks the map; collapsible to a tiny pill. */
.x-topbar {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 30; max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; justify-content: center;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--border-strong); border-radius: 999px;
  box-shadow: var(--shadow-md); padding: 4px 7px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.x-topbar .x-view-buttons { display: flex; gap: 3px; flex-wrap: nowrap; flex-shrink: 0; }
.x-topbar .x-view-buttons .btn { font-size: 11.5px; padding: 3px 9px; white-space: nowrap; }
.x-topbar .x-controls { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; flex-shrink: 0; min-width: 0; }
.x-topbar .x-controls .btn { font-size: 11.5px; padding: 3px 9px; white-space: nowrap; }
.x-topbar-toggle {
  flex-shrink: 0; font-size: 12px; font-weight: 700; cursor: pointer; line-height: 1.3;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 2px 9px;
}
.x-topbar-toggle:hover { color: var(--primary); border-color: var(--primary); }
.x-topbar-active {
  flex-shrink: 0; font-size: 11.5px; font-weight: 700; white-space: nowrap;
  color: var(--primary-dark); text-transform: uppercase; letter-spacing: .04em;
}
.x-topbar-active[hidden] { display: none; }
.x-topbar.collapsed { gap: 6px; padding: 4px 7px; }
.x-topbar.collapsed .x-view-buttons,
.x-topbar.collapsed .x-controls { display: none; }
.x-controls-spacer { flex: 1; }
.x-search {
  font-family: var(--font); font-size: 12.5px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  min-width: 120px; max-width: 180px; outline: none;
}
.x-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 223, 0.12); }
.x-edge-toggles { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.x-edge-toggle { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.x-edge-toggle input { accent-color: var(--primary); cursor: pointer; }

.x-filter-banner {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 6; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--primary-soft); border: 1px solid #C8D9F3; color: var(--ink);
  border-radius: var(--radius-sm); font-size: 13px; padding: 7px 12px;
  box-shadow: var(--shadow-md); max-width: calc(100% - 28px);
}
.x-filter-banner[hidden] { display: none; }
@media (max-width: 900px) { .x-filter-banner { top: 56px; } }
.x-axis-x {
  position: absolute; left: 14px; bottom: 6px; z-index: 2; pointer-events: none;
  font-size: 11px; color: var(--muted); font-weight: 600;
}
.x-axis-y {
  position: absolute; left: -12px; top: 50%; z-index: 2; pointer-events: none;
  transform: rotate(-90deg); transform-origin: left center;
  font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap;
}
.x-axis-y[hidden], .x-axis-x[hidden] { display: none; }

/* faint grid + axes (Papers view) — drawn in a pan/zoom-synced SVG layer */
.x-grid-svg {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1;
  pointer-events: none; overflow: hidden;
}
.x-grid-svg .grid-line { stroke: var(--graph-grid, #E3E9F0); stroke-width: 1; opacity: 0.55; }
.x-grid-svg .grid-line.strong { stroke-width: 1.2; opacity: 0.8; }
.x-grid-svg .grid-tick { fill: var(--muted); font-size: 10px; font-weight: 600; }
.x-scale-bar {
  position: absolute; left: 14px; bottom: 12px; z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; color: var(--muted);
}
.x-scale-bar .scale-line { width: 90px; height: 0; border-top: 2px solid var(--muted); }
.x-scale-bar[hidden] { display: none; }

.x-expanding-note {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%); z-index: 7;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 600;
  padding: 5px 14px; border-radius: 999px; box-shadow: var(--shadow-md);
  pointer-events: none; white-space: nowrap;
}
.x-expanding-note[hidden] { display: none; }
.x-graph-foot {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  z-index: 20; max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--border-strong); border-radius: 999px;
  box-shadow: var(--shadow-sm); padding: 4px 8px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.x-legend-toggle {
  flex-shrink: 0; font-size: 11.5px; font-weight: 700; cursor: pointer;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 3px 10px; line-height: 1.3;
}
.x-legend-toggle:hover { color: var(--primary); border-color: var(--primary); }
.x-graph-foot-inner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0;
}
.x-graph-foot.collapsed .x-graph-foot-inner { display: none; }
.x-graph-foot .map-hint { margin-top: 1px; flex: 1; min-width: 180px; font-size: 11.5px; }
.x-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; font-size: 10.5px; color: var(--muted);
  background: transparent; border: none; border-radius: 0; padding: 0;
}
.x-legend-title { font-weight: 700; font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 2px 0 0; }
.x-legend-title-2 { margin-left: 8px; }
.x-legend-row { display: flex; align-items: center; gap: 4px; margin: 0; }
.x-legend-swatch { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, 0.08); flex-shrink: 0; }
.x-legend-ring { border: 2px solid #2459C4; background: transparent; border-radius: 50%; }
.x-legend-line { width: 18px; border-top: 2px; flex-shrink: 0; }

.x-actionbar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 80;
  max-width: 640px; width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 10px 14px; font-size: 13px; color: var(--ink);
}
.x-actionbar[hidden] { display: none; }
.x-action-title { font-weight: 700; margin-bottom: 2px; }
.x-action-sub { color: var(--muted); margin-bottom: 8px; }
.x-action-links { display: flex; gap: 8px; flex-wrap: wrap; }
.x-action-note { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

@media (max-width: 1180px) {
  .x-list-wrap { width: 280px; }
  .x-rank-wrap { width: 230px; }
}
@media (max-width: 900px) {
  .explore-main { padding: 10px 12px 130px; }
  .x-list-wrap { width: min(320px, calc(100vw - 28px)); top: 44px; }
  .x-rank-wrap { width: min(270px, calc(100vw - 28px)); top: 44px; }
  .x-panel-toggle { top: 8px; }
  .x-topbar { top: 8px; }
  .x-map-toggle { top: 52px; }
  .x-filter-banner { top: 56px; }
}
@media (max-width: 760px) {
  .x-topbar .x-view-buttons .btn { font-size: 11px; padding: 3px 7px; }
  .x-topbar .x-controls .btn { font-size: 11px; padding: 3px 7px; }
  .x-search { min-width: 90px; max-width: 130px; }
  .x-edge-toggles { gap: 6px; font-size: 11px; }
}
@media (max-width: 600px) {
  .x-topbar { gap: 4px; padding: 4px 5px; }
  .x-topbar .x-controls { gap: 3px; }
  .x-search { max-width: 96px; min-width: 70px; }
  .x-topbar .x-view-buttons .btn { padding: 3px 6px; }
}
@media (max-width: 640px) {
  .x-cytoscape { min-height: 320px; }
  .x-axis-y { display: none !important; }
}

/* landing-page responsive */
@media (max-width: 1000px) {
  .search-section { padding-top: 40px; }
  .search-compact { max-width: 100%; }
  .features-pane .features-title, .features-pane .features-list { display: none; }
  .manual-card { margin-top: 2px; }
}
@media (max-width: 640px) {
  .search-box { border-radius: 22px; padding: 4px 4px 4px 14px; }
  textarea.query-input { font-size: 15px; padding: 9px 4px; }
  .search-box .btn { padding: 9px 14px; font-size: 12.5px; }
  .pro-bar { font-size: 12px; padding: 7px 12px; gap: 6px; }
  .search-compact { padding-left: 12px; }
  .search-compact .btn { padding: 6px 11px; }
}

.x-sel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--ink); color: #fff; padding: 12px 22px; box-shadow: 0 -8px 24px rgba(31, 42, 68, 0.18);
}
.x-sel-count { font-weight: 700; font-size: 14px; }
.x-sel-hint { font-size: 12px; color: #C9C7BE; }

/* ---------------------------------------------------------------- bibliography (shared) */
.bib-chip {
  display: inline-block; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 5px 12px; white-space: nowrap; text-decoration: none;
}
.bib-chip:hover { border-color: var(--primary); color: var(--primary); }
.bib-chip.has { background: var(--primary); color: #fff; border-color: var(--primary); }
.bib-chip.has:hover { background: var(--primary-dark); color: #fff; }
.field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; resize: vertical; box-sizing: border-box;
}
.field textarea:focus { outline: 2px solid rgba(15, 118, 110, 0.2); border-color: var(--primary); }
.bib-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px;
  font-weight: 600; z-index: 1100; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; box-shadow: 0 8px 24px rgba(31, 42, 68, 0.2);
}
.bib-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- what's new */
.whatsnew-link {
  background: transparent; border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--muted); padding: 5px 12px; cursor: pointer;
}
.whatsnew-link:hover { border-color: var(--primary); color: var(--primary); }

/* "New search" — visible only while results are on screen (results mode). */
.new-search-btn { display: none; }
body.has-results .new-search-btn { display: inline-flex; }

/* New-topic wipe confirm modal */
.new-topic-counts { font-size: 13.5px; line-height: 1.55; color: var(--muted); margin: 0 0 14px; }
.new-topic-counts strong { color: var(--ink); }
.wn-body { display: flex; flex-direction: column; gap: 14px; }
.wn-title { font-size: 13.5px; font-weight: 700; color: var(--primary-dark); }
.wn-why { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 2px; }

/* ---------------------------------------------------------------- bibliography page */
.bib-status {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.bib-status-text { font-size: 13px; color: var(--muted); font-weight: 500; }
.bib-coverage { flex: 1; min-width: 140px; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.bib-coverage-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--success));
  display: flex; align-items: center; justify-content: flex-end;
  color: #fff; font-size: 9px; font-weight: 700; padding-right: 6px;
  transition: width 0.4s ease;
  white-space: nowrap;
}

.bib-addpmid {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 10px 14px; margin-bottom: 18px;
}
.bib-addpmid input {
  width: 180px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--mono); background: var(--surface);
}
.bib-addpmid input:focus { outline: 2px solid rgba(47, 111, 223, 0.25); border-color: var(--primary); }
.bib-addpmid-err { font-size: 12px; color: var(--danger); }

.bib-empty { text-align: center; padding: 56px 20px; max-width: 460px; margin: 0 auto; }
.bib-empty-icon {
  width: 60px; height: 60px; margin: 0 auto 18px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.bib-empty-title { font-family: var(--serif); font-size: 21px; font-weight: 600; margin-bottom: 8px; color: var(--ink); }
.bib-empty-body { font-size: 13.5px; color: var(--muted); line-height: 1.6; margin-bottom: 22px; }
.bib-empty-actions { display: flex; justify-content: center; gap: 8px; }

.bib-export-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow-md);
  padding: 14px 18px; position: sticky; bottom: 14px;
}
.bib-export-info { display: flex; align-items: baseline; gap: 8px; }
.bib-export-info strong { font-size: 13.5px; color: var(--ink); }
.bib-hint { font-size: 11.5px; color: var(--muted); }
.bib-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.bib-row {
  display: flex; gap: 14px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); padding: 18px 20px;
  border-left: 3px solid var(--primary);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.bib-row:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); transform: translateY(-1px); }
.bib-row.bib-ready { border-left-color: var(--success); }
.bib-num {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; font-size: 13.5px;
  display: flex; align-items: center; justify-content: center;
}
.bib-row.bib-ready .bib-num { background: var(--success-soft); color: var(--success); }
.bib-body { flex: 1; min-width: 0; }
.bib-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bib-title { font-family: var(--serif); font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.bib-meta { font-size: 11.5px; color: var(--muted); margin: 3px 0 14px; }
.bib-chips { display: flex; gap: 6px; flex-shrink: 0; }
.bib-chip-state {
  font-size: 10.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--muted);
}
.bib-chip-state.ok { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.bib-chip-state.todo { background: var(--warning-soft); border-color: var(--warning); color: #8A5B14; }
.bib-pin-grid { display: grid; grid-template-columns: 1fr 220px; gap: 12px; }
@media (max-width: 720px) { .bib-pin-grid { grid-template-columns: 1fr; } }
.bib-pin-grid .field { margin-bottom: 4px; }
.bib-pin-grid textarea { min-height: 42px; }
.bib-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.bib-saved { font-size: 11.5px; color: var(--success); font-weight: 600; min-width: 54px; text-align: right; }
.bib-saved.saving { color: var(--muted); }
.link-pill.danger { color: var(--danger); border-color: var(--danger); }
.link-pill.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---------------------------------------------------------------- read page "cite this point" */
.rp-cite {
  font-size: 11px; font-weight: 700; color: var(--primary); cursor: pointer; margin-left: 8px;
  text-decoration: none; border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 8px;
}
.rp-cite:hover { background: var(--primary); color: #fff; border-color: var(--primary); }



/* ---------------------------------------------------------------- fair pricing / support */
.field select,
.field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.field select:focus,
.field textarea:focus { outline: 2px solid rgba(15, 118, 110, 0.2); border-color: var(--primary); }
.field-input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.field-input:focus { outline: 2px solid rgba(15, 118, 110, 0.2); border-color: var(--primary); }

.funded-tag {
  display: inline-block; background: var(--tier-free-soft); color: var(--tier-free);
  border-radius: 999px; padding: 2px 10px; font-weight: 700; font-size: 12px;
}
.support-nudge {
  margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--tier-basic-soft); border: 1px solid rgba(15, 118, 110, 0.25);
  font-size: 13px; color: var(--ink);
}
.support-nudge a { color: var(--primary); font-weight: 600; }

.renew-banner {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  background: var(--tier-basic-soft); border-top: 1px solid rgba(15, 118, 110, 0.3);
  padding: 8px 14px; font-size: 13px;
}
.renew-banner[hidden] { display: none; }

.grant-row { display: flex; gap: 8px; margin-bottom: 14px; }
.grant-row .field-input { flex: 1; min-width: 0; }

.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-card {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; background: var(--surface);
}
.admin-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-card-meta { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.admin-card-line { font-size: 13px; color: var(--muted); margin-top: 6px; }
.admin-card-actions { display: flex; gap: 8px; margin-top: 10px; }
.kind-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--tier-free); background: var(--tier-free-soft);
  border-radius: 999px; padding: 2px 8px;
}

/* ---------------------------------------------------------------- guest role prompt */
.role-opt-head { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }

/* ---------------------------------------------------------------- AI-Free Author Assist */
.au-aifree-badge {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  color: #0E7A4F; background: #E2F6EC; border: 1px solid rgba(14,122,79,0.35);
  border-radius: 999px; padding: 4px 12px; white-space: nowrap;
}
.au-gate-sub { font-size: 14.5px; color: var(--muted); line-height: 1.65; }
.au-gate-reassure {
  background: var(--success-soft); border: 1px solid rgba(46,158,107,0.3); border-radius: 10px;
  padding: 12px 14px; font-size: 13.5px; margin: 14px 0 18px; line-height: 1.55;
}
.au-gate-reassure strong { color: var(--success); }

.au-list-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* overview summary strip + cards */
.au-ov-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px;
}
.au-ov-stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 14px 16px; text-align: center;
}
.au-ov-num { display: block; font-size: 26px; font-weight: 800; color: var(--primary-dark); }
.au-ov-lab { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.au-ms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.au-ms-card { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.au-ms-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.au-type-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--primary-dark); background: var(--primary-soft);
  border-radius: 999px; padding: 3px 10px;
}
.au-aifree-mini {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 0.05em;
  color: #0E7A4F; background: #E2F6EC; border-radius: 999px; padding: 3px 9px;
}
.au-ms-card-title { font-family: var(--serif); font-size: 17px; font-weight: 700; line-height: 1.35; color: var(--ink); }
.au-ms-card-meta { font-size: 12.5px; color: var(--muted); }
.au-ms-progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.au-ms-progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #2F6FDF, #4F46E5); transition: width 0.4s ease; }
.au-ms-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.au-ms-state { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.au-ms-actions { display: flex; gap: 6px; }
.au-ms-actions .danger { color: var(--danger); }
.au-ms-empty { grid-column: 1 / -1; text-align: center; padding: 40px 20px; color: var(--muted); }
.au-ms-empty strong { font-size: 16px; color: var(--ink); }

/* chooser */
.au-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.au-type-card { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.au-type-label { font-size: 17px; font-weight: 800; color: var(--ink); }
.au-type-tag { font-size: 13px; font-weight: 600; color: var(--primary-dark); }
.au-type-when { font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.au-type-secs { font-size: 12px; color: var(--muted-light); line-height: 1.5; margin-top: 2px; }
.au-type-card .btn { margin-top: 8px; }

/* editor */
.au-editor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.au-saved { font-size: 12.5px; color: var(--muted); min-width: 60px; text-align: right; }
.au-saved.saving { color: var(--warning); }

.au-top-progress {
  display: flex; align-items: center; gap: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 12px 16px; margin-bottom: 12px;
}
.au-top-progress-left { min-width: 170px; }
.au-top-progress-label { font-size: 15px; font-weight: 800; color: var(--primary-dark); }
.au-top-progress-sub { font-size: 12px; color: var(--muted); display: block; }
.au-top-progress-track {
  flex: 1; height: 14px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); overflow: hidden;
}
.au-top-progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #2F6FDF, #4F46E5, #2E9E6B);
  transition: width 0.4s ease;
}

.au-aifree-banner {
  background: var(--success-soft); border: 1px solid rgba(46,158,107,0.35);
  border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--ink);
  margin-bottom: 14px; line-height: 1.55;
}
.au-aifree-banner strong { color: #0E7A4F; }

.au-editor-headline {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 14px;
  margin-bottom: 14px;
}
.au-editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.au-sections { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.au-section { padding: 16px 18px; }
.au-sec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.au-sec-title { font-family: var(--serif); font-size: 16px; font-weight: 700; color: var(--ink); }
.au-sec-words { font-size: 11.5px; font-weight: 600; color: var(--muted-light); }
.au-sec-state { font-size: 12px; color: var(--muted); margin-top: 2px; }
.au-tips {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; line-height: 1.55; margin: 6px 0 10px;
}
.au-tips p { margin: 0 0 6px; }
.au-tips ul { margin: 0; padding-left: 18px; }
.au-tips li { margin: 3px 0; }
.au-section textarea {
  width: 100%; box-sizing: border-box; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 12px; font-family: var(--serif); font-size: 15px; line-height: 1.7; color: #1F2937;
  background: #FFFEFC; resize: vertical; min-height: 120px;
}
.au-section textarea:focus { outline: 2px solid rgba(47,111,223,0.35); border-color: var(--primary); }

/* references sidebar */
.au-refs {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px; position: sticky; top: 16px; max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.au-refs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.au-refs-head h3 { font-family: var(--serif); font-size: 16px; font-weight: 700; color: var(--ink); margin: 0; }
.au-ref-add { display: flex; gap: 6px; margin: 8px 0 4px; }
.au-ref-add input { flex: 1; }
.au-ref-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.au-ref-group-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted-light); margin-bottom: 2px;
}
.au-ref-row {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  display: flex; gap: 8px; align-items: flex-start;
}
.au-ref-row.inc { border-color: rgba(46,158,107,0.4); background: #F7FCF9; }
.au-ref-num { font-weight: 800; color: var(--primary-dark); font-size: 13px; min-width: 22px; }
.au-ref-body { flex: 1; min-width: 0; }
.au-ref-meta { font-size: 12.5px; line-height: 1.5; color: var(--ink); }
.au-ref-note {
  font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 6px;
  padding: 4px 8px; margin-top: 5px;
}
.au-ref-btns { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.au-ref-btns .btn { padding: 3px 8px; font-size: 11.5px; }
.au-ref-btns .danger { color: var(--danger); }

/* declaration */
.au-declaration {
  background: var(--surface); border: 1px solid rgba(46,158,107,0.45); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 20px; margin-top: 20px;
}
.au-decl-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin: 8px 0; }
.au-decl-check input { margin-top: 2px; width: 18px; height: 18px; }
.au-decl-fields {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr); gap: 12px;
  margin-top: 8px; padding-left: 28px;
}

.au-si-or { text-align: center; color: var(--muted-light); font-size: 12px; margin: 10px 0; }

/* manuscript preview */
.modal-wide { max-width: 880px; }
.au-preview-body {
  font-family: var(--serif); font-size: 15px; line-height: 1.7; color: #1F2937;
  max-height: 70vh; overflow-y: auto;
}
.au-preview-body h1 { font-size: 22px; margin: 0 0 8px; color: var(--ink); }
.au-preview-body h2 { font-size: 17px; margin: 16px 0 4px; color: var(--primary-dark); }
.au-preview-body p { margin: 8px 0; }
.au-preview-body hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.au-preview-body strong { color: var(--primary-dark); }
.au-preview-body em { color: var(--muted); }

@media (max-width: 1100px) {
  .au-editor-grid { grid-template-columns: 1fr; }
  .au-refs { position: static; max-height: none; }
}
@media (max-width: 720px) {
  .au-editor-headline { grid-template-columns: 1fr; }
  .au-ov-summary { grid-template-columns: repeat(2, 1fr); }
}

/* references sidebar tabs + manual refs */
.au-refs-tabs { display: flex; gap: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.au-ref-tab {
  border: none; background: transparent; padding: 7px 12px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
}
.au-ref-tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.au-ref-manual-btn { width: 100%; margin: 8px 0 2px; }
.au-ref-manual-tag {
  display: inline-block; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--primary-dark); background: var(--primary-soft); border-radius: 999px; padding: 1px 7px; margin-left: 4px;
}
.au-ref-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* style & readability panel */
.au-style-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.au-style-grade { text-align: center; }
.au-style-grade-num { display: block; font-size: 26px; font-weight: 800; color: var(--primary-dark); }
.au-style-grade-lab { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.au-style-metrics { display: flex; gap: 14px; }
.au-style-metric { text-align: center; }
.au-style-metric strong { display: block; font-size: 16px; color: var(--ink); }
.au-style-metric span { font-size: 11px; color: var(--muted); }
.au-style-note { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; line-height: 1.5; }
.au-style-flags { margin: 0 0 8px; padding-left: 18px; font-size: 12.5px; line-height: 1.6; color: var(--ink); }
.au-style-ex { color: var(--muted); font-size: 12px; }
.au-style-quote {
  font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 6px;
  padding: 6px 8px; margin-top: 6px; line-height: 1.5;
}

/* advisory checklist */
.au-checklist {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 20px; margin-top: 20px;
}
.au-checklist-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.au-checklist-progress {
  font-size: 13px; font-weight: 800; color: var(--success); background: var(--success-soft);
  border-radius: 999px; padding: 4px 12px; white-space: nowrap;
}
.au-cl-group { margin-top: 12px; }
.au-cl-group-title {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin-bottom: 4px;
}
.au-cl-item {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
}
.au-cl-item.done { border-color: rgba(46,158,107,0.4); background: #F7FCF9; }
.au-cl-label { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.au-cl-label input { margin-top: 2px; width: 16px; height: 16px; }
.au-cl-hint { color: var(--muted); font-size: 12.5px; }
.au-cl-auto { font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--success); }
.au-cl-note {
  width: calc(100% - 28px); margin: 6px 0 0 25px; padding: 6px 9px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 6px;
}

/* guideline banner + section essentials */
.au-guide-banner {
  background: var(--primary-soft); border: 1px solid rgba(47,111,223,0.35);
  border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--ink); margin-bottom: 12px; line-height: 1.55;
}
.au-guide-banner strong { color: var(--primary-dark); }
.au-ess {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-top: 10px;
}
.au-ess-title { font-size: 12px; font-weight: 700; color: var(--primary-dark); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.au-ess-count { color: var(--muted); font-weight: 600; }
.au-ess-item { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 4px 0; cursor: pointer; }
.au-ess-item input { margin-top: 2px; width: 15px; height: 15px; }
.au-ess-item.done span { color: var(--muted); text-decoration: line-through; }

/* chooser families */
.au-type-family { margin-bottom: 22px; }
.au-type-family-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 10px;
}
.au-type-guideline { font-size: 12px; color: var(--primary-dark); background: var(--primary-soft); border-radius: 6px; padding: 5px 8px; }

/* reference search */
.au-ref-search { display: flex; gap: 6px; margin: 8px 0 4px; }
.au-ref-search input { flex: 1; }
.au-ref-search-results { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }

/* media panel */
.au-media-group { margin-top: 12px; }
.au-media-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.au-media-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.au-media-thumb { display: block; max-width: 100%; max-height: 150px; border-radius: 6px; border: 1px solid var(--border); margin-bottom: 6px; }
.au-media-caption { width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: 12.5px; border: 1px solid var(--border); border-radius: 6px; }
.au-media-title { font-size: 12.5px; line-height: 1.5; margin-bottom: 6px; }
.au-media-title em { color: var(--muted-light); }

/* table editor + rendered tables */
.au-tbl { border-collapse: collapse; width: 100%; font-size: 13px; margin: 8px 0; }
.au-tbl th, .au-tbl td { border: 1px solid var(--border-strong); padding: 6px 10px; text-align: left; }
.au-tbl th { background: var(--surface-2); font-weight: 700; }
.au-tbl-caption { font-size: 12px; color: var(--muted); font-style: italic; margin-bottom: 8px; }
.au-tbl-preview { margin-top: 4px; }

/* live preview */
.au-preview-toggle { margin-bottom: 12px; }
.au-preview-check { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; color: var(--muted); }
.au-live-preview {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 22px 26px; margin-top: 18px;
}
.au-live-preview-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 10px;
}
.au-live-preview-body { font-family: var(--serif); font-size: 15px; line-height: 1.7; color: #1F2937; }
.au-live-preview-body h1 { font-size: 22px; margin: 0 0 8px; color: var(--ink); }
.au-live-preview-body h2 { font-size: 17px; margin: 16px 0 4px; color: var(--primary-dark); }
.au-live-preview-body p { margin: 8px 0; }
.au-fig { margin: 10px 0; text-align: center; }
.au-fig img { max-width: 100%; border: 1px solid var(--border); border-radius: 6px; }
.au-fig figcaption { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.au-supp { font-size: 12.5px; color: var(--muted); }
.au-refs-ol { padding-left: 22px; font-size: 13px; color: var(--ink); }
.au-refs-ol li { margin: 4px 0; }

/* plain-language panel */
.au-plain { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.au-plain.warn { border-color: rgba(224,138,46,0.5); background: var(--warning-soft); }
.au-plain-title { font-size: 12px; font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.au-plain-grade { font-size: 12.5px; margin: 4px 0; }
.au-plain-target { color: var(--warning); font-size: 12px; }
.au-plain-jargon { font-size: 12.5px; margin-top: 4px; }
.au-plain-jargon ul { margin: 4px 0 0; padding-left: 18px; }
.au-plain-jargon li { margin: 3px 0; }

/* ==================================================================
   DESIGN SYSTEM 2.0 — Phase 5 items 13–16
   Semantic tokens, multi-theme engine (Light/Dark/OLED/Sepia),
   skeleton loaders, toast notifications and the command palette.
   Appended so later rules win over the earlier hand-rolled values.
   ================================================================== */

:root {
  color-scheme: light;

  /* --- semantic core (superset of the original palette) --- */
  --text-body: #3A3A36;          /* prose on surfaces (article text, refs) */
  --editor-bg: #FFFEFC;          /* writing textareas / live preview */
  --editor-ink: #1F2937;
  --inverse-bg: #22304B;         /* solid dark bars with light text */
  --inverse-ink: #FFFFFF;
  --scrim: rgba(28, 27, 25, 0.45);
  --warn-ink: #6E4E12;
  --warn-border: #E8D9AE;
  --danger-border: #E8B4B4;
  --tick-no: #B4534D;
  --aifree-ink: #0E7A4F;
  --aifree-soft: #E2F6EC;
  --graph-bg: radial-gradient(circle at 20% 20%, #FBFDFF, #F4F7FB);
  --ground-target-bg: #F0F5FF;
  --shimmer-hi: rgba(255, 255, 255, 0.5);

  /* highlight / annotation colours (kept light for legibility in all themes) */
  --hl-bg: #FFF1B8;
  --hl-soft: #FBF3D9;
  --hl-findings: #FFF1B8;
  --hl-methods: #DDF1DD;
  --hl-limitations: #FBDEE4;
  --hl-definitions: #DCEBFB;
  --hl-other: #EAEAEA;

  /* chip border tints (soft pastel in light, translucent on dark) */
  --chip-free-border: #CDE3D5;
  --chip-likely-border: #EDDCAE;
  --chip-paywall-border: #EBD3C9;
  --chip-type-border: #C8D9F3;
  --chip-cited-border: #D7DFE8;
  --chip-pmc-ink: #5B4A8F;
  --chip-pmc-soft: #F0EDF7;
  --chip-pmc-border: #DCD3EE;
  --chip-license-ink: #2A6B78;
  --chip-license-soft: #E8F2F4;
  --chip-license-border: #C6E0E5;
}

/* ============================ DARK MODERN ============================ */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F172A;
  --surface: #1E293B;
  --surface-2: #26324A;
  --ink: #E6EDF7;
  --muted: #9AA9BF;
  --muted-light: #6B7A93;
  --border: #2C3A52;
  --border-strong: #3B4A64;
  --primary: #7AA7F5;
  --primary-dark: #96BDFB;
  --primary-soft: rgba(47, 111, 223, 0.18);
  --success: #3ECB8E;
  --success-soft: rgba(46, 158, 107, 0.16);
  --danger: #F08080;
  --danger-soft: rgba(217, 85, 85, 0.16);
  --warning: #F2B25C;
  --warning-soft: rgba(224, 138, 46, 0.16);
  --tier-guest: #94A3B8;
  --tier-guest-soft: rgba(100, 116, 139, 0.18);
  --tier-basic: #2DD4BF;
  --tier-basic-soft: rgba(15, 118, 110, 0.18);
  --tier-pro: #818CF8;
  --tier-pro-soft: rgba(79, 70, 229, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 34px rgba(0, 0, 0, 0.5);
  --text-body: #C6CDD9;
  --editor-bg: #1B2536;
  --editor-ink: #E2E8F0;
  --inverse-bg: #0B1220;
  --inverse-ink: #E6EDF7;
  --scrim: rgba(0, 0, 0, 0.6);
  --warn-ink: #E5C078;
  --warn-border: rgba(224, 138, 46, 0.5);
  --danger-border: rgba(217, 85, 85, 0.6);
  --aifree-ink: #4ADE80;
  --aifree-soft: rgba(14, 122, 79, 0.2);
  --graph-bg: radial-gradient(circle at 20% 20%, #16213A, #0F172A);
  --ground-target-bg: rgba(47, 111, 223, 0.16);
  --shimmer-hi: rgba(255, 255, 255, 0.08);
  --chip-free-border: rgba(46, 158, 107, 0.45);
  --chip-likely-border: rgba(224, 138, 46, 0.45);
  --chip-paywall-border: rgba(217, 85, 85, 0.45);
  --chip-type-border: rgba(47, 111, 223, 0.45);
  --chip-cited-border: rgba(148, 163, 184, 0.4);
  --chip-pmc-border: rgba(139, 122, 220, 0.45);
  --chip-license-border: rgba(42, 107, 120, 0.5);
}

/* ============================== OLED BLACK ============================== */
[data-theme="oled"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0A0A0A;
  --surface-2: #141414;
  --border: #1F1F1F;
  --border-strong: #2E2E2E;
  --primary: #7AA7F5;
  --primary-dark: #96BDFB;
  --primary-soft: rgba(47, 111, 223, 0.18);
  --success: #3ECB8E;
  --success-soft: rgba(46, 158, 107, 0.16);
  --danger: #F08080;
  --danger-soft: rgba(217, 85, 85, 0.16);
  --warning: #F2B25C;
  --warning-soft: rgba(224, 138, 46, 0.16);
  --tier-guest: #94A3B8;
  --tier-guest-soft: rgba(100, 116, 139, 0.18);
  --tier-basic: #2DD4BF;
  --tier-basic-soft: rgba(15, 118, 110, 0.18);
  --tier-pro: #818CF8;
  --tier-pro-soft: rgba(79, 70, 229, 0.18);
  --ink: #E6EDF7;
  --muted: #9AA9BF;
  --muted-light: #6B7A93;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6), 0 6px 20px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 34px rgba(0, 0, 0, 0.7);
  --text-body: #C6CDD9;
  --editor-bg: #000000;
  --editor-ink: #E2E8F0;
  --inverse-bg: #000000;
  --inverse-ink: #E6EDF7;
  --scrim: rgba(0, 0, 0, 0.72);
  --warn-ink: #E5C078;
  --warn-border: rgba(224, 138, 46, 0.5);
  --danger-border: rgba(217, 85, 85, 0.6);
  --aifree-ink: #4ADE80;
  --aifree-soft: rgba(14, 122, 79, 0.2);
  --graph-bg: radial-gradient(circle at 20% 20%, #0D0D0D, #000000);
  --ground-target-bg: rgba(47, 111, 223, 0.16);
  --shimmer-hi: rgba(255, 255, 255, 0.06);
  --chip-free-border: rgba(46, 158, 107, 0.45);
  --chip-likely-border: rgba(224, 138, 46, 0.45);
  --chip-paywall-border: rgba(217, 85, 85, 0.45);
  --chip-type-border: rgba(47, 111, 223, 0.45);
  --chip-cited-border: rgba(148, 163, 184, 0.4);
  --chip-pmc-border: rgba(139, 122, 220, 0.45);
  --chip-license-border: rgba(42, 107, 120, 0.5);
}

/* ============================= ACADEMIC SEPIA ============================= */
[data-theme="sepia"] {
  color-scheme: light;
  --bg: #F7F1E3;
  --surface: #FDFAF2;
  --surface-2: #F3ECDC;
  --ink: #4A3B2A;
  --muted: #7A6A55;
  --muted-light: #A49681;
  --border: #E3D8C2;
  --border-strong: #D3C5A8;
  --shadow-sm: 0 1px 2px rgba(74, 59, 42, 0.06), 0 6px 20px rgba(74, 59, 42, 0.08);
  --shadow-md: 0 10px 34px rgba(74, 59, 42, 0.14);
  --text-body: #4A3B2A;
  --editor-bg: #FFFDF5;
  --editor-ink: #3E3328;
  --inverse-bg: #4A3B2A;
  --inverse-ink: #FDFAF2;
  --scrim: rgba(60, 45, 25, 0.5);
  --graph-bg: radial-gradient(circle at 20% 20%, #FBF6EA, #F2E9D6);
  --ground-target-bg: #F1E7CE;
  --shimmer-hi: rgba(255, 255, 255, 0.45);
}

/* Smooth theme transition (respects prefers-reduced-motion below). */
body { transition: background-color 0.2s ease, color 0.2s ease; }

/* --- hard-coded colours now driven by tokens (so every theme is coherent) --- */
.manual-section p, .manual-section li,
.manual-access .access-step,
.reference-list li { color: var(--text-body); }

.rp-section p, .rp-section li, .hl-quote,
.rp-reflist li { color: var(--text-body); }

.au-section textarea { color: var(--editor-ink); background: var(--editor-bg); }
.au-preview-body, .au-live-preview-body { color: var(--editor-ink); }

.plot-box { background: var(--surface); }
.ground-src:target { background: var(--ground-target-bg); }
.manual-access .access-card { background: var(--surface); }
.rp-table table { background: var(--surface); }
.btn-export { background: var(--surface); }

mark.hl { background: var(--hl-bg); }
.kp-sentence.hl { background: var(--hl-bg); box-shadow: 0 0 0 2px var(--hl-bg); }
.kp-sentence.soft { background: var(--hl-soft); }
/* keep annotation text dark for contrast on bright highlight backgrounds */
mark.hl, .user-hl, .kp-sentence.hl, .kp-sentence.soft { color: #1F2937; }
.user-hl.cat-findings, .hl-dot.cat-findings { background: var(--hl-findings); }
.user-hl.cat-methods, .hl-dot.cat-methods { background: var(--hl-methods); }
.user-hl.cat-limitations, .hl-dot.cat-limitations { background: var(--hl-limitations); }
.user-hl.cat-definitions, .hl-dot.cat-definitions { background: var(--hl-definitions); }
.user-hl.cat-other, .hl-dot.cat-other { background: var(--hl-other); }

.chip-free { border-color: var(--chip-free-border); }
.chip-likely { border-color: var(--chip-likely-border); }
.chip-paywall { border-color: var(--chip-paywall-border); }
.chip-type, .synth-qtype, .x-rank-item:hover, .x-row.picked, .x-filter-banner { border-color: var(--chip-type-border); }
.chip-corrected { color: var(--warn-ink); border-color: var(--warn-border); }
.chip-pmc { color: var(--chip-pmc-ink); background: var(--chip-pmc-soft); border-color: var(--chip-pmc-border); }
.chip-license { color: var(--chip-license-ink); background: var(--chip-license-soft); border-color: var(--chip-license-border); }
.chip-cited { border-color: var(--chip-cited-border); }

.stance-support { border-color: var(--chip-free-border); }
.stance-refute { border-color: var(--chip-paywall-border); }
.stance-neutral { border-color: var(--chip-likely-border); }

.premium-banner, .qr-note { color: var(--warn-ink); border-color: var(--warn-border); }
.reader-retracted, .article-retracted { border-color: var(--danger-border); }
.tick-no { color: var(--tick-no); }
.hl-remove:hover, .hl-clear:hover, .ws-del:hover { color: var(--danger); }
.rp-tag.fig { color: var(--chip-license-ink); background: var(--chip-license-soft); }
.rp-tag.fig:hover { background: var(--chip-license-ink); color: #fff; }

.au-aifree-badge { color: var(--aifree-ink); background: var(--aifree-soft); }
.au-ref-row.inc, .au-cl-item.done { background: var(--success-soft); }

.x-cytoscape { background: var(--graph-bg); }
@keyframes xRowPicked { 0% { background: var(--hl-soft); } 100% { background: var(--primary-soft); } }

.modal-backdrop, .drawer-backdrop { background: var(--scrim); }
.x-sel { background: var(--inverse-bg); color: var(--inverse-ink); }
.x-sel-hint { color: var(--muted-light); }
.x-expanding-note { background: var(--inverse-bg); color: var(--inverse-ink); }
.bib-toast { background: var(--inverse-bg); color: var(--inverse-ink); }

/* ============================ THEME SWITCHER ============================ */
.theme-switch {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--muted); padding: 5px 11px; cursor: pointer;
  font-family: var(--font); white-space: nowrap; line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-switch:hover { border-color: var(--primary); color: var(--primary); }
.theme-switch svg { flex-shrink: 0; }

/* ============================ SKELETON LOADERS (item 14) ============================ */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--surface-2); border-radius: 6px;
}
.skeleton::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--shimmer-hi), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.skeleton-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 10px;
}
.skeleton-title { height: 16px; width: 78%; }
.skeleton-meta { height: 11px; width: 52%; }
.skeleton-line { height: 11px; width: 100%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-chiprow { display: flex; gap: 6px; }
.skeleton-chip { height: 20px; width: 64px; border-radius: 999px; }
.skeleton-badge { height: 18px; width: 72px; border-radius: 999px; }
.skeleton-chart { height: 240px; border-radius: var(--radius-sm); }
.skeleton-pane { height: 300px; border-radius: var(--radius-sm); }

.sk-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
  gap: 20px; margin-top: 16px;
}
@media (max-width: 900px) { .sk-grid { grid-template-columns: 1fr; } }
.sk-col { display: flex; flex-direction: column; gap: 12px; }
.sk-col-head { height: 34px; border-radius: var(--radius-sm); }

/* article cursor for j/k navigation (item 15) */
.article-card.cursor {
  outline: 2px solid var(--primary); outline-offset: 2px;
  box-shadow: var(--shadow-md);
}

/* ============================ TOASTS (item 16) ============================ */
.toast-stack {
  position: fixed; top: 74px; right: 18px; z-index: 1300;
  display: flex; flex-direction: column; gap: 10px;
  width: min(360px, calc(100vw - 36px)); pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: 11px 12px; font-size: 13px; line-height: 1.5; color: var(--ink);
  animation: toastIn 0.22s ease both;
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }
.toast-msg { flex: 1; min-width: 0; word-break: break-word; }
.toast-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px;
}
.toast-close:hover { color: var(--ink); }
.toast-action {
  flex-shrink: 0; background: var(--primary-soft); color: var(--primary);
  border: 1px solid var(--chip-type-border); border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 4px 12px; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.toast-action:hover { background: var(--primary); color: #fff; }
.toast.leaving { animation: toastOut 0.18s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }

/* ============================ COMMAND PALETTE (item 15) ============================ */
.palette {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 24px;
}
.palette[hidden] { display: none; }
.palette-backdrop { position: fixed; inset: 0; background: var(--scrim); }
.palette-panel {
  position: relative; width: 100%; max-width: 560px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden;
}
.palette-input {
  width: 100%; border: none; outline: none; background: var(--surface-2);
  padding: 15px 18px; font-size: 16px; font-family: inherit; color: var(--ink);
  border-bottom: 1px solid var(--border);
}
.palette-input::placeholder { color: var(--muted-light); }
.palette-list { max-height: 340px; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.palette-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--ink); cursor: pointer; border: none; background: none;
  text-align: left; font-family: inherit; width: 100%;
}
.palette-item .kbd { margin-left: auto; color: var(--muted-light); font-family: var(--mono); font-size: 11px; }
.palette-item:hover { background: var(--surface-2); }
.palette-item.active { background: var(--primary-soft); color: var(--primary-dark); }
.palette-icon { flex-shrink: 0; color: var(--primary); display: inline-flex; }
.palette-icon svg { display: block; }
.palette-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* ============================ PICO BUILDER (item 17) ============================ */
.pico-wrap {
  margin-top: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.pico-wrap[hidden] { display: none; }
.pico-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 12px; }
.pico-field { position: relative; }
.pico-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.pico-tag {
  min-width: 18px; text-align: center; font-size: 10px; font-weight: 800;
  background: var(--primary-soft); color: var(--primary); border-radius: 4px; padding: 1px 5px;
}
.pico-input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 13.5px; font-family: inherit;
  background: var(--surface); color: var(--ink);
}
.pico-input:focus { outline: 2px solid rgba(47, 111, 223, 0.25); border-color: var(--primary); }
.pico-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md); overflow: hidden;
  max-height: 240px; overflow-y: auto;
}
.pico-suggest[hidden] { display: none; }
.pico-suggest-item {
  display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; padding: 9px 12px; font-size: 13px; font-family: inherit;
  color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--border);
}
.pico-suggest-item:last-child { border-bottom: none; }
.pico-suggest-item:hover { background: var(--primary-soft); color: var(--primary-dark); }
.pico-suggest-item .ui { margin-left: auto; color: var(--muted-light); font-size: 11px; }
.pico-suggest-item:hover .ui { color: var(--primary); }
.pico-suggest-empty { padding: 10px 12px; font-size: 12.5px; color: var(--muted); }

.pico-preview {
  margin-top: 14px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.pico-preview[hidden] { display: none; }
.pico-preview-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin-bottom: 6px;
}
.pico-preview-query { display: block; font-size: 12.5px; line-height: 1.6; color: var(--ink); word-break: break-word; white-space: pre-wrap; }
.pico-preview-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.pico-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.pico-actions .link-btn { margin-left: auto; }
.pico-status { font-size: 12.5px; color: var(--muted); }

/* ===================== All-access promo (banner + modal callout) ===================== */
.promo-banner {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 8px 16px;
  background: linear-gradient(90deg, var(--primary-soft), var(--tier-pro-soft));
  border-bottom: 1px solid var(--border);
  color: var(--ink); font-size: 13px; text-align: center;
}
.promo-banner[hidden] { display: none; }
.promo-banner-text strong { color: var(--primary-dark); }
.promo-banner-sub { display: inline-block; color: var(--muted); margin-left: 8px; font-size: 12px; }
.promo-banner-close { flex: 0 0 auto; }
@media (max-width: 720px) {
  .promo-banner { flex-direction: column; gap: 6px; padding: 8px 12px; text-align: left; }
  .promo-banner-sub { display: block; margin-left: 0; margin-top: 2px; }
}
.promo-callout {
  margin: 0 0 14px; padding: 12px 14px;
  border: 1px solid var(--tier-pro-soft);
  background: linear-gradient(135deg, var(--primary-soft), var(--tier-pro-soft));
  border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.55; color: var(--ink);
}
.promo-callout[hidden] { display: none; }
.promo-callout strong { color: var(--primary-dark); }
.promo-callout em { font-style: italic; color: var(--ink); }
.promo-callout-note {
  display: block; margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--border-strong);
  font-size: 12px; color: var(--muted);
}

/* ==================================================================
   DESIGN SYSTEM 3.0 — "Vibrant Modern Clinical" (2026-08-18)
   Whole-site visual refresh: a signature blue→teal gradient identity,
   tinted canvas, vibrant teal/indigo accents, refined depth and subtle
   motion. Appended so these rules win over earlier values.
   ================================================================== */

:root {
  color-scheme: light;

  /* canvas: subtle cool-teal tint — alive but clinical */
  --bg: #F2F8F6;
  --surface-2: #EDF4F1;
  --border: #DCE7E4;
  --border-strong: #BFD4CD;

  /* vibrant accents + signature gradient identity */
  --accent-teal: #0E9F86;
  --accent-teal-soft: #DFF5EF;
  --accent-teal-ink: #0B6B5A;
  --accent-indigo: #6D5AE6;
  --accent-indigo-soft: #EFECFD;
  --grad-brand: linear-gradient(135deg, #2459C4 0%, #0E9F86 100%);
  --grad-primary: linear-gradient(135deg, #2F6FDF 0%, #0E9F86 100%);
  --grad-soft: linear-gradient(135deg, rgba(47, 111, 223, 0.10), rgba(14, 159, 134, 0.12));

  --ring-focus: 0 0 0 3px rgba(47, 111, 223, 0.16);
  --shadow-sm: 0 1px 2px rgba(18, 60, 84, 0.05), 0 6px 20px rgba(18, 60, 84, 0.07);
  --shadow-md: 0 12px 36px rgba(18, 60, 84, 0.12);
  --shadow-lg: 0 20px 50px rgba(14, 90, 110, 0.16);
  --shadow-ring-teal: 0 0 0 1px rgba(14, 159, 134, 0.30), 0 10px 30px rgba(14, 120, 100, 0.14);

  --graph-bg: radial-gradient(circle at 20% 20%, #EAF4F1, #F2F8F6);
  --shimmer-hi: rgba(255, 255, 255, 0.65);
}

[data-theme="dark"] {
  --bg: #0B1626;
  --accent-teal: #2DD4BF;
  --accent-teal-soft: rgba(45, 212, 191, 0.14);
  --accent-teal-ink: #7FF0E2;
  --accent-indigo: #8B7CF8;
  --accent-indigo-soft: rgba(139, 124, 248, 0.14);
  --grad-brand: linear-gradient(135deg, #4F8DF5 0%, #2DD4BF 100%);
  --grad-primary: linear-gradient(135deg, #4F8DF5 0%, #1FB9A0 100%);
  --grad-soft: linear-gradient(135deg, rgba(122, 167, 245, 0.14), rgba(45, 212, 191, 0.12));
  --ring-focus: 0 0 0 3px rgba(122, 167, 245, 0.24);
  --shadow-md: 0 12px 36px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  --shadow-ring-teal: 0 0 0 1px rgba(45, 212, 191, 0.30), 0 10px 30px rgba(0, 0, 0, 0.4);
  --graph-bg: radial-gradient(circle at 20% 20%, #14243C, #0F172A);
  --shimmer-hi: rgba(255, 255, 255, 0.08);
}

[data-theme="oled"] {
  --bg: #000000;
  --accent-teal: #2DD4BF;
  --accent-teal-soft: rgba(45, 212, 191, 0.14);
  --accent-teal-ink: #7FF0E2;
  --accent-indigo: #8B7CF8;
  --accent-indigo-soft: rgba(139, 124, 248, 0.14);
  --grad-brand: linear-gradient(135deg, #4F8DF5 0%, #2DD4BF 100%);
  --grad-primary: linear-gradient(135deg, #4F8DF5 0%, #1FB9A0 100%);
  --grad-soft: linear-gradient(135deg, rgba(122, 167, 245, 0.14), rgba(45, 212, 191, 0.12));
  --ring-focus: 0 0 0 3px rgba(122, 167, 245, 0.24);
  --shadow-md: 0 12px 36px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  --shadow-ring-teal: 0 0 0 1px rgba(45, 212, 191, 0.30), 0 10px 30px rgba(0, 0, 0, 0.45);
  --graph-bg: radial-gradient(circle at 20% 20%, #0A0F1C, #000000);
  --shimmer-hi: rgba(255, 255, 255, 0.08);
}

[data-theme="sepia"] {
  --accent-teal: #1E8A72;
  --accent-teal-soft: #E3F1EC;
  --accent-teal-ink: #14604F;
  --accent-indigo: #7A67D6;
  --accent-indigo-soft: #F0EDFB;
  --grad-brand: linear-gradient(135deg, #6B4E2E 0%, #1E8A72 100%);
  --grad-primary: linear-gradient(135deg, #3E6BA8 0%, #1E8A72 100%);
  --grad-soft: linear-gradient(135deg, rgba(62, 107, 168, 0.12), rgba(30, 138, 114, 0.14));
  --ring-focus: 0 0 0 3px rgba(62, 107, 168, 0.18);
  --shadow-sm: 0 1px 2px rgba(74, 59, 42, 0.06), 0 6px 20px rgba(74, 59, 42, 0.09);
  --shadow-md: 0 12px 36px rgba(74, 59, 42, 0.15);
  --shadow-lg: 0 20px 50px rgba(74, 59, 42, 0.18);
  --shadow-ring-teal: 0 0 0 1px rgba(30, 138, 114, 0.30), 0 10px 30px rgba(30, 110, 90, 0.14);
  --graph-bg: radial-gradient(circle at 20% 20%, #FBF6EA, #F2E9D6);
  --shimmer-hi: rgba(255, 255, 255, 0.5);
}

/* --- brand identity: signature gradient --- */
.header::after {
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent-teal) 60%, var(--accent-indigo) 130%);
}
.logo-mark {
  background: var(--grad-brand);
  box-shadow: 0 4px 16px rgba(14, 100, 120, 0.35);
  border-radius: 12px;
}
.header-title h1 { letter-spacing: -0.3px; }

/* --- primary buttons: gradient fill + soft glow --- */
.btn-primary {
  background: var(--grad-primary);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(47, 111, 223, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn-primary:hover {
  background: var(--grad-primary);
  filter: saturate(1.12) brightness(1.05);
  box-shadow: 0 8px 22px rgba(47, 111, 223, 0.36);
}
.btn-ghost:hover { background: var(--primary-soft); }
.btn-primary.btn-sm, .btn-primary.btn-sm:hover { background: var(--grad-primary); }

/* --- accessible focus rings (keyboard) --- */
button:focus-visible, a:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- search hero: gradient halo behind the box + glow on focus --- */
.search-section { position: relative; }
.search-section::before {
  content: ''; position: absolute; left: 50%; top: 4px; transform: translateX(-50%);
  width: min(600px, 94%); height: 200px; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(47, 111, 223, 0.14), rgba(14, 159, 134, 0.10), transparent 72%);
  filter: blur(6px); pointer-events: none;
}
.search-box {
  box-shadow: 0 2px 4px rgba(18, 60, 84, 0.05), 0 14px 44px rgba(18, 60, 84, 0.10);
}
.search-box:focus-within {
  border-color: var(--accent-teal);
  box-shadow: 0 2px 4px rgba(47, 111, 223, 0.1), 0 18px 48px rgba(18, 60, 84, 0.16),
              0 0 0 3px rgba(47, 111, 223, 0.12);
}
.search-box .search-icon { color: var(--accent-teal); }

/* --- cards: hairline border + tinted teal ring on hover --- */
.article-card, .card, .results-bar {
  background: var(--surface);
}
.article-card:hover {
  border-color: rgba(14, 159, 134, 0.40);
  box-shadow: var(--shadow-ring-teal);
  transform: translateY(-2px);
}
.article-title { letter-spacing: -0.1px; }
.article-title:hover { color: var(--accent-teal-ink); }

/* --- evidence chips: richer accents --- */
.chip-pct { color: var(--accent-indigo); background: var(--accent-indigo-soft); border-color: rgba(109, 90, 230, 0.28); }
.chip-pmc { color: #5B4A8F; }
.chip-medline, .chip-license { color: var(--accent-teal-ink); background: var(--accent-teal-soft); border-color: rgba(14, 159, 134, 0.30); }
.chip-cited { color: var(--muted); }

/* --- AI / mode badge: teal = AI live, blue = deterministic --- */
.mode-ai { color: var(--accent-teal-ink); border-color: rgba(14, 159, 134, 0.40); background: var(--accent-teal-soft); }

/* --- section kickers + tabs: teal accent --- */
.section-label { color: var(--accent-teal); }
.view-tab.active, .tab.active { color: var(--accent-teal); border-bottom-color: var(--accent-teal); }

/* --- synthesis header: blue→teal gradient panel --- */
.synth-header { background: linear-gradient(120deg, #1E2F52 0%, #125D6E 58%, #0E7A6B 100%); }
[data-theme="dark"] .synth-header, [data-theme="oled"] .synth-header {
  background: linear-gradient(120deg, #152238 0%, #123B47 58%, #0E3D36 100%);
}
[data-theme="sepia"] .synth-header { background: linear-gradient(120deg, #3E3328 0%, #4A3B2A 100%); }

/* --- Explore view switch: proper active pill (gradient) --- */
.x-topbar .x-view-buttons .btn.active {
  background: var(--grad-primary); color: #fff; border-color: transparent;
  box-shadow: 0 3px 10px rgba(47, 111, 223, 0.30);
}
.x-map-toggle .btn.active {
  background: var(--grad-primary); color: #fff; border-color: transparent;
  box-shadow: 0 3px 10px rgba(47, 111, 223, 0.30);
}

/* --- promo banner: soft gradient wash --- */
.promo-banner { background: var(--grad-soft); border-bottom-color: rgba(14, 159, 134, 0.25); }
.promo-banner-text strong { color: var(--accent-teal-ink); }
.promo-callout { background: var(--grad-soft); }

/* --- toasts: matched surface + subtle slide --- */
.toast { box-shadow: var(--shadow-lg); }
.toast.success { border-left-color: var(--accent-teal); }

/* --- skeleton shimmer uses the theme shimmer token --- */
.skeleton { background: var(--surface-2); }

/* --- scroll reveal (gated on .js so it fails soft without JS) --- */
html.js [data-reveal] { opacity: 0; transform: translateY(10px); transition: opacity 0.5s ease, transform 0.5s ease; }
html.js [data-reveal].revealed { opacity: 1; transform: none; }
html.js [data-reveal][data-reveal-delay="1"] { transition-delay: 0.06s; }
html.js [data-reveal][data-reveal-delay="2"] { transition-delay: 0.12s; }
html.js [data-reveal][data-reveal-delay="3"] { transition-delay: 0.18s; }

/* card entrance: refined stagger for results + synthesis */
#resultsSection .article-card, #freeArticles .article-card, #paywalledArticles .article-card {
  animation: fadeUp 0.36s ease both;
}
#freeArticles .article-card:nth-child(1) { animation-delay: 0.02s; }
#freeArticles .article-card:nth-child(2) { animation-delay: 0.06s; }
#freeArticles .article-card:nth-child(3) { animation-delay: 0.10s; }
#freeArticles .article-card:nth-child(4) { animation-delay: 0.14s; }
#paywalledArticles .article-card:nth-child(1) { animation-delay: 0.02s; }
#paywalledArticles .article-card:nth-child(2) { animation-delay: 0.06s; }
#paywalledArticles .article-card:nth-child(3) { animation-delay: 0.10s; }
#paywalledArticles .article-card:nth-child(4) { animation-delay: 0.14s; }

/* --- site-visit confidence note (bottom-right, once per session) --- */
.visits-note {
  position: fixed; right: 18px; bottom: 66px; z-index: 56;
  display: flex; align-items: center; gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border-strong); border-radius: 999px;
  box-shadow: var(--shadow-md); padding: 7px 8px 7px 13px;
  font-size: 12px; color: var(--muted);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: visitsIn 0.4s ease both;
}
.visits-note[hidden] { display: none; }
.visits-note strong { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.visits-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--success); box-shadow: 0 0 0 3px var(--success-soft);
}
.visits-close {
  background: none; border: none; color: var(--muted-light); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 3px 6px; border-radius: 999px;
}
.visits-close:hover { color: var(--ink); background: var(--surface-2); }
@keyframes visitsIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 640px) {
  .visits-note { right: 12px; left: 12px; bottom: 62px; justify-content: center; }
}

/* ==================================================================
   LANDING PAGE MODERNISATION (2026-08-18)
   Hero copy + search glow, quiet header nav, slim tool rows.
   ================================================================== */

/* --- header: refined brand, quiet nav links (kill the button soup) --- */
.header-inner { padding: 14px 28px; gap: 16px; }
.header-title h1 { font-size: 20px; }
.tagline { font-size: 12.5px; }
.header .btn-ghost {
  background: transparent; border-color: transparent; color: var(--muted);
  padding: 6px 8px;
}
.header .btn-ghost:hover {
  background: var(--primary-soft); color: var(--primary-dark); transform: none;
}

/* --- hero: headline, then the search pill with a soft glow --- */
.search-section {
  padding: clamp(40px, 11vh, 92px) 16px 20px;
  text-align: center;
}
.search-section::before { display: none; } /* old halo superseded by the search-box glow */
.hero-copy { margin: 0 auto 28px; max-width: 720px; }
.hero-eyebrow {
  display: inline-block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent-teal);
  background: var(--accent-teal-soft); border: 1px solid rgba(14, 159, 134, 0.25);
  border-radius: 999px; padding: 5px 14px; margin-bottom: 16px;
}
.hero-title {
  font-size: clamp(30px, 4.6vw, 46px); font-weight: 600; line-height: 1.12;
  letter-spacing: -0.02em; color: var(--ink);
}
.hero-sub {
  margin: 14px auto 0; max-width: 640px; font-size: 15.5px; line-height: 1.6;
  color: var(--muted);
}
.search-box { position: relative; max-width: 760px; margin: 0 auto; }
.search-box::before {
  content: ''; position: absolute; inset: -26px -34px; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(47, 111, 223, 0.16), rgba(14, 159, 134, 0.12), transparent 72%);
  filter: blur(10px); pointer-events: none;
}
.search-box .query-input { font-size: 16.5px; padding: 12px 6px; }
.hero-chips {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin: 16px auto 0; max-width: 640px;
}
.hero-chip {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.hero-chip:hover { border-color: var(--accent-teal); color: var(--accent-teal-ink); }
.search-help { justify-content: center; }

/* --- slim left pane: compact auto-width pill links --- */
.features-pane {
  width: 252px;
  display: flex; flex-direction: column; align-items: flex-start;
}
.manual-card {
  display: inline-flex; align-items: center; flex-direction: row; gap: 9px;
  padding: 7px 12px 7px 7px; border-radius: 999px;
  margin: 0 0 6px 0;
  border: 1px solid var(--border); background: var(--surface);
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
              background 0.15s ease, transform 0.15s ease;
}
.manual-card:hover {
  border-color: rgba(14, 159, 134, 0.40);
  background: var(--grad-soft);
  box-shadow: var(--shadow-ring-teal);
  transform: translateY(-1px);
}
.manual-card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px;
  background: var(--grad-primary); color: #fff; margin-bottom: 0;
  box-shadow: 0 3px 10px rgba(47, 111, 223, 0.28);
}
.manual-card-title { font-weight: 700; font-size: 12.5px; letter-spacing: -0.1px; }
.manual-card-cta {
  font-size: 15px; color: var(--muted-light);
  transition: transform 0.15s ease, color 0.15s ease;
}
.manual-card:hover .manual-card-cta { transform: translateX(2px); color: var(--accent-teal); }

/* restore full-width pane on mobile (the width:252px above would otherwise
   beat the earlier ≤1000px media query) */
@media (max-width: 1000px) {
  .features-pane { width: 100%; position: static; margin-top: 18px; }
}
