:root {
  --bg: #0b0d10;
  --surface: #15181d;
  --surface-2: #1b1f25;
  --border: #23272e;
  --text: #e6e8eb;
  --muted: #8a93a0;
  --accent: #4f9cf9;
  --accent-soft: rgba(79, 156, 249, 0.15);
  --gold: #d4af37;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --red: #d9534f;
  --green: #4caf50;
  --radius: 8px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 28px 0 22px;
}

.site-header h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: -0.01em;
}

.site-header h1 a { color: var(--text); }

.tag {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.topnav {
  margin-top: 14px;
  display: flex;
  gap: 18px;
}

.topnav a {
  color: var(--muted);
  font-size: 14px;
}
.topnav a.active { color: var(--text); border-bottom: 2px solid var(--accent); padding-bottom: 2px; }

#app { padding: 22px 0 64px; }

.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

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

.pills button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.pills button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.toggles {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}
.toggles label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.toggles input { accent-color: var(--accent); }

.controls {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

.controls input, .controls select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font: inherit;
}

.controls input:focus, .controls select:focus {
  outline: none;
  border-color: var(--accent);
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; min-width: 980px; }

thead th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

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

tbody tr {
  cursor: pointer;
  transition: background 80ms ease;
}
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.col-num { text-align: right; font-variant-numeric: tabular-nums; }
.col-rank { width: 56px; font-weight: 600; text-align: center; }
.col-name { min-width: 220px; }
.col-engine { width: 110px; }
.col-caps { width: 220px; }
.col-date { width: 140px; color: var(--muted); }

.rank-1 { color: var(--gold); }
.rank-2 { color: var(--silver); }
.rank-3 { color: var(--bronze); }

.delta-pos { color: var(--green); }
.delta-neg { color: var(--red); }
.delta-zero { color: var(--muted); }

.name-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.name-cell strong { font-size: 14.5px; }
.name-cell small { color: var(--muted); font-size: 12px; }

.caps {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.caps span {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--muted);
}
.caps span.on { color: var(--accent); border-color: rgba(79,156,249,0.4); }

.velocity {
  display: inline-block;
  min-width: 48px;
  text-align: right;
  font-weight: 600;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card h3 {
  margin: 0 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stat-card .v { font-size: 22px; font-weight: 600; }
.stat-card ul { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; }
.stat-card li { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.stat-card li strong { color: var(--text); font-weight: 500; }

.backlink {
  display: inline-block;
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.detail-card h2 { margin: 0 0 6px; font-size: 24px; }
.detail-card .lead { color: var(--muted); margin: 0 0 20px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}
.detail-grid .cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.detail-grid .cell h4 {
  margin: 0 0 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.detail-grid .cell .v { font-size: 18px; font-weight: 600; }

.spark {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 32px;
  max-width: 760px;
}
.prose h2 { margin-top: 0; }
.prose h3 { margin-top: 24px; }
.prose code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 14px 0;
  font-size: 13px;
  color: var(--muted);
}
.site-footer .wrap {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.site-footer button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}
.site-footer button:hover { border-color: var(--accent); color: var(--accent); }
.site-footer .muted { margin-left: auto; }

@media (max-width: 720px) {
  .controls { margin-left: 0; width: 100%; }
  .controls input { flex: 1; }
  .site-footer .muted { margin-left: 0; width: 100%; }
}
