/* ------------------------------------------------------------------
   ChaoEng · LLM Leaderboard Aggregator
   A calm, high-contrast light theme optimised for data density.
------------------------------------------------------------------- */

:root {
  --bg: #f5f6f8;
  --bg-elev: #ffffff;
  --bg-muted: #eef0f3;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #0f172a;
  --text-muted: #5b6372;
  --text-faint: #8b93a1;

  --accent: #1d4ed8;
  --accent-2: #0f766e;
  --accent-3: #7c3aed;

  --success: #10a36b;
  --warning: #d97706;
  --danger: #dc2626;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  /* Sticky thead offset = .header-inner min-height + .site-header border */
  --site-header-h: 61px;

  --font-sans: "Inter", "PingFang SC", "Microsoft YaHei", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas,
    "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum", "ss01", "cv11";
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }

/* --------------------------- Site header ---------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(6px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none !important;
  font-weight: 600;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 0.8rem;
}

.brand-text { display: inline-flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1rem; }
.brand-text em { font-style: normal; color: var(--text-muted); font-size: 0.72rem; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 4px;
  margin-left: 12px;
  flex: 1;
  align-self: stretch;
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  padding: 0 12px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.site-nav a:hover {
  color: var(--text);
  background: rgba(15, 23, 42, 0.03);
}

.site-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(29, 78, 216, 0.06);
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 6px 10px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.status-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(16, 163, 107, 0.18);
}

/* ----------------------------- Hero -------------------------------- */

.page-main { padding-top: 32px; padding-bottom: 72px; }

.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 28px;
  align-items: end;
  padding: 32px 0 24px;
}

.hero .eyebrow {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--border);
  color: var(--accent);
  background: #eff4fe;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.hero h1 {
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  max-width: 38ch;
  color: var(--text);
}

.hero .lede {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 58ch;
  margin: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}

.stat-num {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* -------------------------- Section head --------------------------- */

section {
  margin-top: 48px;
  scroll-margin-top: calc(var(--site-header-h) + 16px);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-head h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 0;
}

.section-head p { color: var(--text-muted); margin: 0; font-size: 0.9rem; }

/* --------------------------- Form inputs --------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.text-input {
  appearance: none;
  font: inherit;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  min-width: 200px;
  transition: border-color .15s, box-shadow .15s;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

select.text-input { cursor: pointer; }

/* ----------------------- Chart (bar chart) ------------------------- */

.chart-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.chart-tabs button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.chart-tabs button:hover { color: var(--text); border-color: var(--border-strong); }
.chart-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chart-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.chart-meta strong { color: var(--text); font-weight: 600; }
.chart-meta a { font-weight: 500; }

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 38px minmax(200px, 1.1fr) 2fr auto;
  align-items: center;
  gap: 14px;
  font-size: 0.88rem;
}

.bar-rank {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
}

.bar-name {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  overflow: hidden;
}

.bar-name strong {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-name span {
  color: var(--text-muted);
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 22px;
  background: var(--bg-muted);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
  width: 0;
  transition: width .6s cubic-bezier(.2,.7,.2,1);
  min-width: 4px;
}

.chart-card[data-key="arena_elo"] .bar-fill,
.chart-card[data-key="lmarena"] .bar-fill {
  background: linear-gradient(90deg, #14b8a6 0%, #0f766e 100%);
}

.chart-card[data-key="benchlm"] .bar-fill,
.chart-card[data-key="llmstats"] .bar-fill {
  background: linear-gradient(90deg, #a855f7 0%, #7c3aed 100%);
}

.chart-card[data-key="swebench"] .bar-fill,
.chart-card[data-key="onyx"] .bar-fill,
.chart-card[data-key="onyx_sh"] .bar-fill {
  background: linear-gradient(90deg, #f97316 0%, #ea580c 100%);
}

.chart-card[data-key="superclue"] .bar-fill,
.chart-card[data-key="opencompass"] .bar-fill,
.chart-card[data-key="llmrank"] .bar-fill {
  background: linear-gradient(90deg, #f43f5e 0%, #be123c 100%);
}

.bar-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  min-width: 56px;
  text-align: right;
}

.chart-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: var(--bg-muted);
  border-radius: var(--radius);
}

/* ----------------------------- Tables ------------------------------ */

/* overflow:visible so thead position:sticky uses the viewport scrollport;
   overflow:hidden makes sticky stick inside this box and overlap tbody rows. */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: visible;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}

.data-table thead th {
  position: sticky;
  top: var(--site-header-h);
  z-index: 11;
  background: var(--bg-elev);
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-strong);
}

.data-table thead th:first-child {
  border-top-left-radius: calc(var(--radius-lg) - 1px);
}

.data-table thead th:last-child {
  border-top-right-radius: calc(var(--radius-lg) - 1px);
}

.data-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: calc(var(--radius-lg) - 1px);
}

.data-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: calc(var(--radius-lg) - 1px);
}

.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-muted); }
.data-table td.num, .data-table th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.cell-model { display: flex; flex-direction: column; gap: 2px; }
.cell-model strong { color: var(--text); font-weight: 600; }
.cell-sub { color: var(--text-muted); font-size: 0.76rem; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: #eef4fe;
  color: #1d4ed8;
  border: 1px solid #d7e2fc;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  margin: 1px 3px 1px 0;
}

.tag.neutral { background: var(--bg-muted); color: var(--text-muted); border-color: var(--border); }
.tag.success { background: #e6f6ee; color: var(--success); border-color: #c6ebd4; }
.tag.warning { background: #fef1e0; color: var(--warning); border-color: #f7d9a1; }
.tag.danger  { background: #fde9e9; color: var(--danger);  border-color: #f5c1c1; }

/* --------------------------- Source grid --------------------------- */

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.source-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.source-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.source-card h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.source-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.source-card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text-faint);
  margin-top: auto;
}

.source-card a.link {
  color: var(--accent);
  font-weight: 500;
  font-size: 0.82rem;
}

/* ---------------------------- News list ---------------------------- */

.news-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.news-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}

.news-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.news-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.news-head time { color: var(--text-faint); }

.news-item h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.news-item p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.source-link {
  margin-top: 4px;
  font-size: 0.8rem;
  align-self: flex-start;
}

/* ---------------------------- Sub pages ---------------------------- */

.page-header {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: end;
  padding: 16px 0 8px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.page-header .lede { color: var(--text-muted); font-size: 0.95rem; margin: 0; max-width: 56ch; }

.page-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.table-section { margin-top: 32px; }

/* ----------------------------- Footer ------------------------------ */

.site-footer {
  margin-top: 80px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

/* --------------------------- Responsive ---------------------------- */

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 28px 40% 1fr auto; }
  .site-nav { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .hero h1 { font-size: 1.5rem; }
  .section-head h2 { font-size: 1.1rem; }
  .data-table { font-size: 0.82rem; }
  .bar-row { grid-template-columns: 24px 34% 1fr auto; gap: 8px; }
  .bar-name span { display: none; }
  .page-stats { grid-template-columns: repeat(3, 1fr); }
  .header-status { display: none; }
}
