:root {
  --bg: #0b0d10;
  --bg-elev: #11151a;
  --bg-elev-2: #161b22;
  --border: #1f2630;
  --border-soft: #1a2027;
  --text: #e6edf3;
  --text-dim: #8c98a4;
  --text-very-dim: #5a6470;
  --accent: #6ee7b7;
  --accent-2: #7dd3fc;
  --warn: #f1b500;
  --bad: #ef4444;
  --good: #22c55e;
  --mono: ui-monospace, "SF Mono", "Menlo", "JetBrains Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { min-height: 100vh; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

#app { max-width: 1200px; margin: 0 auto; padding: 24px 28px 80px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand .logo { font-size: 22px; }
.brand .title { font-family: var(--mono); font-size: 18px; letter-spacing: -0.4px; }
.brand .dim { font-size: 13px; }
.meta { display: flex; align-items: center; gap: 12px; }

.dim { color: var(--text-dim); }
.very-dim { color: var(--text-very-dim); }
.mono { font-family: var(--mono); }

button.ghost, .chip {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button.ghost:hover, .chip:hover { background: var(--bg-elev); border-color: #2a3340; }
.chip.active { background: var(--bg-elev-2); border-color: var(--accent); color: var(--accent); }

.controls {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.chip-row { display: flex; gap: 6px; }
.sort-row { display: flex; align-items: center; gap: 8px; }
select.sort {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 12px;
}

/* Summary cards */
.summary-cards {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 22px;
}
.summary-card {
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-elev-2));
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 14px 16px;
}
.summary-card .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim);
}
.summary-card .value {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 18px;
}
.summary-card .sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-dim);
}

/* Table */
.lb-wrap { border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden; background: var(--bg-elev); }
table.lb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lb th, table.lb td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
table.lb th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim);
  background: var(--bg-elev-2);
  font-weight: 500;
}
table.lb tr:last-child td { border-bottom: none; }
table.lb tbody tr { cursor: pointer; transition: background 0.1s; }
table.lb tbody tr:hover { background: rgba(255,255,255,0.02); }
table.lb td.num { font-family: var(--mono); text-align: right; }
table.lb th.num { text-align: right; }

.rank { color: var(--text-dim); font-family: var(--mono); }
.sdk-cell { display: flex; align-items: center; gap: 8px; }
.lang-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: 11px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
}
.lang-badge.python { color: #ffd43b; }
.lang-badge.typescript { color: #3178c6; }
.stainless-mark { color: var(--accent); font-weight: 600; font-size: 12px; }
.stale-pill {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-family: var(--mono); font-size: 10px; margin-left: 6px;
}
.no-data {
  font-family: var(--mono); color: var(--text-very-dim);
}

/* Bar */
.bar-wrap { display: flex; align-items: center; gap: 8px; }
.bar {
  flex: 1; min-width: 80px; max-width: 180px;
  height: 8px; background: var(--bg-elev-2);
  border-radius: 4px; overflow: hidden;
}
.bar > span {
  display: block; height: 100%; transition: width 0.3s;
}
.score-num { font-family: var(--mono); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.col-good > span { background: var(--good); }
.col-warn > span { background: var(--warn); }
.col-bad > span { background: var(--bad); }
.col-na > span { background: var(--text-very-dim); }
.color-good { color: var(--good); }
.color-warn { color: var(--warn); }
.color-bad { color: var(--bad); }
.color-na { color: var(--text-very-dim); }

/* Drill-down */
.detail-back { margin-bottom: 14px; }
.detail-head {
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-elev-2));
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 22px;
}
.detail-head h1 { margin: 0; font-family: var(--mono); font-size: 22px; }
.detail-head .row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.detail-head .row .kv { color: var(--text-dim); font-size: 13px; }
.detail-head .row .kv b { color: var(--text); font-family: var(--mono); margin-right: 4px; }
.detail-head .score-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

.section { margin-top: 28px; }
.section h2 {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: -0.2px;
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.section h2 .count { color: var(--text-dim); font-size: 13px; }

.timeline { border-left: 2px solid var(--border); padding-left: 18px; }
.tl-item { position: relative; padding: 10px 0; }
.tl-item::before {
  content: ""; position: absolute; left: -23px; top: 14px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--bg);
}
.tl-item.prerelease::before { background: var(--warn); }
.tl-tag { font-family: var(--mono); font-size: 13px; color: var(--text); }
.tl-meta { font-size: 12px; color: var(--text-dim); }

.cl-list { display: flex; flex-direction: column; gap: 10px; }
.cl-card {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg-elev);
}
.cl-card .cl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cl-version { font-family: var(--mono); font-size: 14px; }
.cl-date { color: var(--text-dim); font-size: 12px; }
.cl-pill {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  background: var(--bg-elev-2); color: var(--text-dim);
  font-family: var(--mono); font-size: 10px;
  border: 1px solid var(--border-soft);
}
.cl-pill.breaking { background: rgba(239,68,68,0.15); color: #fca5a5; border-color: rgba(239,68,68,0.4); }
.cl-pill.feature { color: var(--accent); }
.cl-pill.fix { color: var(--accent-2); }
.cl-toggle {
  margin-left: auto; cursor: pointer; user-select: none;
  font-size: 11px; color: var(--text-dim); font-family: var(--mono);
}
.cl-raw {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 360px;
  overflow-y: auto;
}
.cl-card.open .cl-raw { display: block; }

.sparkline-wrap {
  border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 12px 14px; background: var(--bg-elev);
}

.embed-snippet {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 14px;
}
.embed-snippet pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}
.embed-snippet .label { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.embed-snippet .badge-preview { margin: 10px 0 14px; }

.footer {
  margin-top: 60px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 12px;
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 800px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  table.lb th, table.lb td { padding: 8px 6px; font-size: 12px; }
  table.lb .hide-sm { display: none; }
  #app { padding: 18px 14px 60px; }
}
