/* Research Dashboard — Dark Theme */

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #111827;
  --border: #374151;
  --text: #e2e8f0;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --blue: #3b82f6;
  --green: #10b981;
  --green-light: #6ee7b7;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;

  /* Evidence tier colors */
  --tier-rct: #6ee7b7;
  --tier-human-obs: #93c5fd;
  --tier-animal: #fcd34d;
  --tier-in-vitro: #fdba74;
  --tier-case-report: #fca5a5;
  --tier-expert-opinion: #d8b4fe;
  --tier-anecdotal: #f87171;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

/* ── Navigation ─────────────────────────────────────────── */

.nav {
  display: flex;
  gap: 24px;
  padding: 12px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}

.nav a:hover,
.nav a.active {
  color: var(--text);
  text-decoration: none;
}

.nav a.active {
  color: var(--blue);
}

/* ── Typography helpers ──────────────────────────────────── */

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 32px;
}

/* ── Card grid ──────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
}

.card:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
  text-decoration: none;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-header h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.card-description {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.card-meta {
  color: var(--text-dim);
  font-size: 0.78rem;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.card-preview {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ── Badges ─────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-new {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green-light);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-unchanged {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-dim);
  border: 1px solid rgba(107, 114, 128, 0.2);
}

/* ── Peptide tags ───────────────────────────────────────── */

.peptide-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.peptide-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.73rem;
  font-weight: 500;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

/* ── Stats bar ──────────────────────────────────────────── */

.stats-bar {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 28px;
  margin-bottom: 32px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--blue);
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── What's New banner ──────────────────────────────────── */

.whats-new {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 28px;
}

.whats-new h3 {
  color: var(--green-light);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.whats-new ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.whats-new li {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding-left: 16px;
  position: relative;
}

.whats-new li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--green);
}

/* ── Peptide profile ────────────────────────────────────── */

.peptide-profile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}

.peptide-profile-header {
  background: var(--surface-alt);
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.peptide-description {
  padding: 16px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  border-bottom: 1px solid var(--border);
}

.peptide-details {
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.peptide-details dt {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.peptide-details dd {
  font-size: 0.9rem;
  color: var(--text);
}

/* ── Evidence badges ────────────────────────────────────── */

.evidence-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.tier-rct            { background: rgba(110, 231, 183, 0.15); color: var(--tier-rct); }
.tier-human-obs      { background: rgba(147, 197, 253, 0.15); color: var(--tier-human-obs); }
.tier-animal         { background: rgba(252, 211, 77, 0.15);  color: var(--tier-animal); }
.tier-in-vitro       { background: rgba(253, 186, 116, 0.15); color: var(--tier-in-vitro); }
.tier-case-report    { background: rgba(252, 165, 165, 0.15); color: var(--tier-case-report); }
.tier-expert-opinion { background: rgba(216, 180, 254, 0.15); color: var(--tier-expert-opinion); }
.tier-anecdotal      { background: rgba(248, 113, 113, 0.15); color: var(--tier-anecdotal); }

/* ── Activity feed ──────────────────────────────────────── */

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 40px;
}

.activity-date {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.dot-new_version    { background: var(--green); }
.dot-updated        { background: var(--blue); }
.dot-first_version  { background: var(--purple); }
.dot-quality_change { background: var(--amber); }
.dot-error          { background: var(--red); }
.dot-info           { background: var(--text-dim); }

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

.activity-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.activity-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Legends ────────────────────────────────────────────── */

.tier-legend,
.activity-legend {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.tier-legend h3,
.activity-legend h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.tier-legend ul,
.activity-legend ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.tier-legend li,
.activity-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Online indicator ───────────────────────────────────── */

.online-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 12px;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

/* ── Version navigation ─────────────────────────────────── */

.version-nav {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.version-nav a {
  color: var(--blue);
}

/* ── Footer ─────────────────────────────────────────────── */

.footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.7;
}

.footer p + p {
  margin-top: 6px;
}

/* ── Content HTML (rendered synthesis) ─────────────────── */

.content-body h2 {
  font-size: 1.2rem;
  margin-top: 28px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.content-body h3 {
  font-size: 1rem;
  margin-top: 20px;
  margin-bottom: 8px;
}

.content-body p {
  color: var(--text-muted);
  margin-bottom: 12px;
}

.content-body ul,
.content-body ol {
  color: var(--text-muted);
  padding-left: 20px;
  margin-bottom: 12px;
}

.content-body li {
  margin-bottom: 4px;
}

.content-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 20px;
}

.content-body th {
  background: var(--surface-alt);
  padding: 8px 12px;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.content-body td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.content-body tr:hover td {
  background: var(--surface);
}

/* ── Citations & References ─────────────────────────────── */

sup.cite {
  font-size: 0.7em;
  line-height: 0;
  vertical-align: super;
  margin: 0 1px;
}

sup.cite a {
  color: var(--blue);
  text-decoration: none;
  padding: 1px 2px;
  border-radius: 2px;
}

sup.cite a:hover {
  background: rgba(59, 130, 246, 0.15);
  text-decoration: none;
}

.references-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.references-section h2 {
  font-size: 1.2em;
  margin-bottom: 16px;
  color: var(--text);
}

.reference-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: none;
}

.reference-list li {
  padding: 10px 12px;
  margin-bottom: 4px;
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.9em;
  line-height: 1.5;
  scroll-margin-top: 20px;
}

.reference-list li:target {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.reference-list li a {
  color: var(--blue);
  font-weight: 500;
}

.ref-meta {
  color: var(--text-muted);
}

.ref-count {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.8em;
  color: var(--text-dim);
  background: var(--surface-alt);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ── Peptide auto-links ─────────────────────────────────── */

a.peptide-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
}

a.peptide-link:hover {
  color: var(--blue);
  border-bottom-color: var(--blue);
  text-decoration: none;
}

/* ── Peptide detail page ─────────────────────────────────── */

.related-buckets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}

.related-buckets-label {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.related-bucket-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 500;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.25);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.related-bucket-badge:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.5);
  text-decoration: none;
}

.findings-section {
  margin-bottom: 40px;
}

.tier-group {
  margin-bottom: 32px;
}

.tier-group h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.tier-count {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 400;
}

.findings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.finding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s;
}

.finding-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
}

.finding-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.finding-summary {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.finding-source {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.finding-source a {
  color: var(--blue);
}

/* ── Peptide index page ──────────────────────────────────── */

.category-section {
  margin-bottom: 40px;
}

.category-section > h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.peptide-card {
  /* Inherits .card base styles */
  min-height: unset;
}

.peptide-card .card-header h2 {
  font-size: 0.95rem;
  color: var(--text);
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 640px) {
  body {
    padding: 16px;
  }

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

  .stats-bar {
    gap: 20px;
    padding: 16px;
  }

  h1 {
    font-size: 1.5rem;
  }
}
