/* ============================================
   Cosmos Wisdom Papers — Stylesheet
   ============================================ */

:root {
  --primary: #0f766e;
  --primary-light: #14b8a6;
  --primary-dark: #134e4a;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-section: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.06);
  --radius: 10px;
  --radius-sm: 6px;
  --max-w: 1280px;
  --pink: #ec4899;
  --indigo: #6366f1;
  --rose: #f43f5e;
  --emerald: #10b981;
  --sky: #0ea5e9;
  --violet: #8b5cf6;
  --lime: #84cc16;
  --orange: #fb923c;
  --cyan: #06b6d4;
  --fuchsia: #d946ef;
  --amber: #f59e0b;
  --green: #22c55e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Hiragino Sans GB", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ============================================
   Header & Nav
   ============================================ */
.header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color: #fff;
  padding: 20px 0;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
}
.brand-logo {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.brand-text { line-height: 1.15; }
.brand-text small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 2px;
}
.nav {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.nav a {
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.9;
  transition: all .15s;
}
.nav a:hover { background: rgba(255,255,255,.15); opacity: 1; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.2); opacity: 1; }

.main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px;
}

/* ============================================
   Stat Cards
   ============================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.stat-card .label {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.1;
}
.stat-card .sub {
  color: var(--text-soft);
  font-size: 12px;
  margin-top: 4px;
}
.stat-card .value-if { color: var(--accent); }
.stat-card .value-journals { color: var(--rose); }
.stat-card .value-authors { color: var(--indigo); }

/* ============================================
   Section Card
   ============================================ */
.section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.section h2 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.section h2 .icon { font-size: 18px; }
.section-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 768px) { .section-row { grid-template-columns: 1fr; } }

/* ============================================
   Charts
   ============================================ */
.chart-wrap {
  position: relative;
  height: 300px;
}
.chart-wrap-sm { height: 260px; }
.chart-wrap-lg { height: 340px; }

/* ============================================
   Top lists
   ============================================ */
.bar-list { list-style: none; padding: 0; margin: 0; }
.bar-list li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.bar-list li:last-child { border-bottom: none; }
.bar-list .rank {
  font-weight: 700;
  color: var(--primary);
  text-align: right;
  font-size: 13px;
}
.bar-list .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.bar-list .count {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.bar-list .bar-bg {
  background: var(--bg-section);
  height: 6px;
  border-radius: 3px;
  margin-top: 4px;
  grid-column: 1 / -1;
  overflow: hidden;
}
.bar-list .bar-fg {
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  height: 100%;
  border-radius: 3px;
}
.bar-list .label-row {
  display: contents;
}

/* ============================================
   Search page
   ============================================ */
.search-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.search-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20,184,166,.15);
}
.search-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 130px;
}
.filter-group label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.filter-group select, .filter-group input {
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13px;
  color: var(--text);
}
.filter-group select:focus, .filter-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.reset-btn {
  align-self: flex-end;
  background: var(--bg-section);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.reset-btn:hover { background: var(--border); color: var(--text); }

.active-filters {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
}
.tag .x { cursor: pointer; opacity: 0.7; }
.tag .x:hover { opacity: 1; }
.tag.omics { background: var(--indigo); }
.tag.tissue { background: var(--emerald); }
.tag.year { background: var(--sky); }
.tag.mention { background: var(--accent); }

/* ============================================
   Paper cards
   ============================================ */
.papers-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.paper-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  transition: all .15s;
  cursor: pointer;
}
.paper-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}
.paper-card.expanded {
  background: linear-gradient(180deg, #ecfdf5 0%, var(--bg-card) 30%);
}
.paper-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px 0;
  line-height: 1.35;
}
.paper-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  align-items: center;
}
.paper-meta .sep { color: var(--text-soft); }
.paper-journal { color: var(--primary); font-weight: 600; }
.paper-if {
  background: var(--accent);
  color: #fff;
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
}
.paper-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.paper-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.paper-tag.omics { background: #ede9fe; color: var(--indigo); }
.paper-tag.tissue { background: #d1fae5; color: var(--emerald); }
.paper-tag.mention { background: #fef3c7; color: #92400e; }
.paper-tag.field { background: var(--bg-section); color: var(--text-muted); }
.paper-tag.year { background: #e0f2fe; color: var(--sky); }

.paper-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: none;
  font-size: 13px;
  line-height: 1.5;
}
.paper-card.expanded .paper-detail { display: block; }
.paper-detail dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.paper-detail dt { color: var(--text-muted); font-weight: 600; font-size: 12px; }
.paper-detail dd { margin: 0; color: var(--text); }
.paper-links {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.paper-links a {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--bg-section);
  color: var(--primary-dark);
}
.paper-links a:hover { background: var(--primary); color: #fff; text-decoration: none; }

/* ============================================
   Empty / Loading
   ============================================ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state .icon { font-size: 32px; margin-bottom: 8px; opacity: 0.5; }

.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pagination button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.pagination button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .info { font-size: 12px; color: var(--text-muted); }

/* ============================================
   Footer
   ============================================ */
.footer {
  margin-top: 40px;
  padding: 24px;
  text-align: center;
  color: var(--text-soft);
  font-size: 12px;
  border-top: 1px solid var(--border);
}
.footer .build-time { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.footer a { color: var(--text-muted); }

/* ============================================
   Mobile
   ============================================ */
@media (max-width: 640px) {
  .header { padding: 14px 0; }
  .header-inner { padding: 0 16px; gap: 12px; }
  .brand { font-size: 15px; }
  .brand-logo { width: 32px; height: 32px; font-size: 18px; }
  .nav { width: 100%; justify-content: center; }
  .nav a { padding: 6px 10px; font-size: 13px; }
  .main { padding: 16px; }
  .stat-card .value { font-size: 22px; }
  .filter-group { min-width: 100%; }
  .chart-wrap, .chart-wrap-sm { height: 240px; }
}
