:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2330;
  --border: #2d333b;
  --fg: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent2: #d2a8ff;
  --mark: #bb800926;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

header {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.header-row {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px 28px; min-height: 56px; padding: 8px 0;
}
.brand { font-size: 19px; font-weight: 700; color: var(--fg); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--accent); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a {
  color: var(--muted); text-decoration: none; padding: 6px 14px;
  border-radius: 6px; font-weight: 500;
}
nav a:hover { color: var(--fg); background: var(--panel2); }
nav a.active { color: var(--fg); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--accent); }
.stats {
  margin-left: auto; color: var(--muted); font-size: 12.5px;
  text-align: right; white-space: nowrap;
}
/* when brand+nav+stats don't fit on one line, give stats its own full row
   instead of letting it spill over the content below the sticky header */
@media (max-width: 860px) {
  .stats { flex-basis: 100%; text-align: left; margin-left: 0; }
}

/* main.wrap (0,1,1) must outrank .wrap (0,1,0), whose `padding: 0 20px`
   otherwise wins and glues the search bar to the header */
main.wrap { min-height: 70vh; padding: 26px 20px 40px; }

.searchbar { display: flex; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.searchbar input[type=text], .searchbar textarea {
  flex: 1 1 380px;
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: 15px; outline: none;
}
.searchbar textarea { font-family: var(--mono); font-size: 13.5px; resize: vertical; min-height: 42px; }
.searchbar input:focus, .searchbar textarea:focus { border-color: var(--accent); }
.searchbar button {
  background: var(--accent); color: #0b2239; font-weight: 700;
  border: 0; border-radius: 8px; padding: 10px 22px; font-size: 15px; cursor: pointer;
}
.searchbar button:hover { filter: brightness(1.1); }

.filters {
  display: flex; gap: 10px 22px; align-items: center; color: var(--muted);
  font-size: 13px; margin: 2px 0 18px; flex-wrap: wrap; min-height: 36px;
}
/* every control in the row shares one height + radius so nothing looks off-grid */
.filters input[type=number], .filters select, .filters .lang-select {
  height: 36px; background: var(--panel); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; padding: 0 10px;
  font-size: 13.5px;
}
.filters input[type=number] { width: 84px; }
.filters label { display: flex; gap: 8px; align-items: center; cursor: pointer; white-space: nowrap; }
.filters input[type=range] { width: 150px; accent-color: var(--accent); margin: 0; }
.filters b { color: var(--accent); font-variant-numeric: tabular-nums; min-width: 150px; }
.filters .seg { height: 36px; }
.filters .seg button { height: 34px; padding: 0 16px; }
.filters .go-right {
  margin-left: auto;
  background: var(--accent); color: #0b2239; font-weight: 700;
  border: 0; border-radius: 8px; padding: 0 22px; height: 36px;
  font-size: 15px; cursor: pointer;
}
.filters .go-right:hover { filter: brightness(1.1); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  background: var(--panel); color: var(--muted); border: 0;
  padding: 8px 16px; cursor: pointer; font-size: 13.5px; font-weight: 600;
}
.seg button.on { background: var(--panel2); color: var(--accent); }

.lang-select {
  background: var(--panel); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 13.5px; cursor: pointer;
}

.hint { color: var(--muted); font-size: 13px; margin: 6px 0 18px; }
.meta-line { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.meta-line b { color: var(--fg); }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 6px; font-size: 16.5px; }
.card h3 a { color: var(--accent); text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.snippet { color: #b6c2cf; font-size: 13.5px; }
.statement-preview {
  background: var(--panel2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent2); border-radius: 8px;
  padding: 9px 13px; margin: 8px 0 10px;
  color: #c4d0dd; font-size: 13px; line-height: 1.55;
}
.statement-preview .sp-label {
  display: block; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
.statement-preview mark { background: var(--mark); color: #e3b341; border-radius: 3px; padding: 0 2px; font-weight: 600; }

.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; border: 1px solid transparent;
}
.r-none { color: var(--muted); border-color: var(--border); }
.r-gray { color: #aab2ba; background: #aab2ba1f; }
.r-green { color: #56d364; background: #56d3641f; }
.r-cyan { color: #39c5cf; background: #39c5cf1f; }
.r-blue { color: #58a6ff; background: #58a6ff1f; }
.r-violet { color: #d2a8ff; background: #d2a8ff1f; }
.r-orange { color: #f0883e; background: #f0883e1f; }
.r-red { color: #ff7b72; background: #ff7b721f; }

.tag {
  display: inline-block; background: #21303f; color: #79b8ff;
  border-radius: 999px; padding: 1px 9px; font-size: 11.5px; margin: 2px 4px 2px 0;
}
.chip { background: var(--panel2); border-radius: 5px; padding: 1px 7px; font-size: 11.5px; color: var(--muted); }
.chip-sol { background: #1f3a28; color: #56d364; }
.chip-code { background: #1c2f3a; color: #79c0ff; }
.chip-time { background: #2a2433; color: #d2a8ff; }
.chip-off { background: #33260f; color: #e3b341; font-family: var(--mono); }
.chip-muted { opacity: 0.5; }

pre.code {
  background: #0a0e14; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.8px; line-height: 1.5;
  margin: 10px 0 4px; white-space: pre; tab-size: 4;
}
pre.code mark { background: var(--mark); color: #e3b341; border-radius: 3px; padding: 0 1px; font-weight: 700; }
.snippet mark { background: var(--mark); color: #e3b341; border-radius: 3px; padding: 0 2px; font-weight: 600; }
.tok-kw { color: #ff7b72; }
.tok-str { color: #a5d6ff; }
.tok-com { color: #8b949e; font-style: italic; }
.tok-num { color: #79c0ff; }
.tok-def { color: #d2a8ff; }
.tok-dec { color: #f0883e; }

.statement { white-space: pre-wrap; color: #c9d1d9; font-size: 14.5px; }
.statement em { color: #e3b341; font-style: normal; font-family: var(--mono); font-size: 13.5px; }

details.block { margin: 14px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
details.block > summary {
  cursor: pointer; padding: 12px 18px; font-weight: 600; color: var(--accent);
  list-style: none;
}
details.block > summary::before { content: "▸ "; }
details.block[open] > summary::before { content: "▾ "; }
details.block > .inner { padding: 0 18px 16px; }

.sol-row { display: flex; align-items: center; gap: 14px; }
.sol-row .grow { flex: 1; }
.crown { font-size: 15px; }

.block-card { }
.carousel {
  display: flex; gap: 12px; overflow-x: auto; padding: 12px 2px 4px;
  scroll-snap-type: x proximity;
}
.carousel::-webkit-scrollbar { height: 9px; }
.carousel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
.sol-card {
  flex: 0 0 360px; max-width: 360px; scroll-snap-align: start;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
}
.sol-card .sub { margin-bottom: 6px; }
.sol-card pre.code { margin: 0; max-height: 220px; overflow: auto; font-size: 12px; }

#buildbar { background: #1c2330; border-top: 1px solid var(--border); }
.buildbar-inner {
  max-width: 1000px; margin: 0 auto; padding: 6px 20px;
  display: flex; gap: 14px; align-items: center;
  font-size: 12.5px; color: var(--muted);
}
.buildbar-label { white-space: nowrap; }
.buildbar-track {
  flex: 1; height: 6px; min-width: 80px;
  background: var(--border); border-radius: 4px; overflow: hidden;
}
.buildbar-fill { height: 100%; background: var(--accent); transition: width 0.8s ease; }
.buildbar-fill.indet { opacity: 0.45; animation: buildpulse 1.6s ease-in-out infinite; }
@keyframes buildpulse { 50% { opacity: 0.15; } }

.pager { display: flex; gap: 14px; align-items: center; justify-content: center; padding: 18px 0 6px; }
.pager button {
  background: var(--panel); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 16px; cursor: pointer; font-size: 13.5px;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button:disabled { opacity: 0.35; cursor: default; }

.empty { color: var(--muted); padding: 40px 0; text-align: center; font-size: 15px; }
.error { color: #ff7b72; padding: 16px; background: #ff7b7211; border: 1px solid #ff7b7240; border-radius: 8px; margin: 14px 0; }
.spinner { color: var(--muted); padding: 30px 0; text-align: center; }

.backlink { color: var(--muted); text-decoration: none; font-size: 13.5px; display: inline-block; margin-bottom: 14px; }
.backlink:hover { color: var(--accent); }

.page-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 0 0 4px; }
.page-title h2 { margin: 0; font-size: 22px; }
.ext { color: var(--muted); font-size: 12.5px; text-decoration: none; border: 1px solid var(--border); padding: 2px 10px; border-radius: 6px; }
.ext:hover { color: var(--accent); border-color: var(--accent); }

footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; padding: 18px 20px 30px; margin-top: 30px; }
footer a { color: var(--accent); }
footer code { font-family: var(--mono); background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
.attribution { margin-top: 6px; opacity: 0.85; }
.muted { color: var(--muted); }

.examples { color: var(--muted); font-size: 13px; }
.examples a { color: var(--accent2); text-decoration: none; font-family: var(--mono); }
.examples a:hover { text-decoration: underline; }

.stats-table { border-collapse: collapse; font-size: 13px; margin-top: 10px; width: 100%; }
.stats-table th, .stats-table td {
  text-align: left; padding: 4px 18px 4px 0;
  border-bottom: 1px solid var(--border); color: #b6c2cf;
}
.stats-table th { color: var(--muted); font-weight: 600; }

.analytics-card h3 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.charts-row { display: flex; flex-wrap: wrap; gap: 18px 26px; margin-top: 8px; }
.mini-chart { flex: 1 1 300px; min-width: 0; }
.mini-chart-title { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 2px 0; }
.bar-label {
  flex: 0 0 130px; color: var(--muted); text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-track { flex: 1; background: #0a0e14; border-radius: 3px; height: 13px; }
.bar { height: 100%; background: var(--accent); border-radius: 3px; opacity: 0.85; }
.bar-n { flex: 0 0 60px; color: var(--muted); font-variant-numeric: tabular-nums; }

.inline-stats {
  display: flex; gap: 4px 12px; align-items: center; flex-wrap: wrap;
  color: var(--muted); font-size: 11px; margin: 6px 0 10px;
  background: linear-gradient(90deg, #58a6ff17, #58a6ff05 70%, transparent);
  border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 5px 11px;
}
.inline-stats b { color: var(--accent); font-size: 11.5px; }
.stat-live {
  margin-left: auto; white-space: nowrap;
  color: var(--accent); font-size: 11px; font-weight: 600;
  border: 1px solid #58a6ff55; border-radius: 999px; padding: 1px 9px;
  background: #58a6ff10;
}
.stat-bit { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.spark { display: inline-flex; align-items: flex-end; gap: 1px; height: 12px; }
.spark i { width: 3px; background: var(--accent); opacity: 0.8; border-radius: 1px; }
.spark-range { color: var(--muted); font-size: 9.5px; }

.spark-wrap { display: inline-flex; gap: 6px; align-items: flex-end; }
.spark-label { color: var(--muted); font-size: 11px; }

.mini-chart.wide { flex: 1 1 100%; }
.range-track {
  position: relative; flex: 1; height: 13px;
  background: #0a0e14; border-radius: 3px;
}
.range-bar {
  position: absolute; top: 2px; bottom: 2px;
  background: #58a6ff55; border: 1px solid #58a6ff88; border-radius: 3px;
}
.range-median {
  position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px;
  background: var(--accent2); border-radius: 1px;
}
.statement .katex { font-size: 1.02em; }

.statement code {
  font-family: var(--mono); font-size: 13px;
  background: var(--panel2); border-radius: 4px; padding: 0 5px;
  color: #79c0ff;
}
.md-h { display: inline-block; font-size: 15.5px; margin-top: 6px; }

.col-chart {
  display: flex; align-items: flex-end; gap: 3px;
  height: 84px; padding: 4px 2px 0;
  background: #0a0e14; border-radius: 6px;
}
.col-wrap { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.col { width: 100%; background: var(--accent); opacity: 0.8; border-radius: 2px 2px 0 0; }
.col-wrap:hover .col { opacity: 1; background: var(--accent2); }
.col-axis {
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: 11px; margin-top: 3px;
}

.scatter-frame {
  position: relative; background: #0a0e14; border-radius: 6px;
  padding: 4px 4px 4px 6px;
}
.scatter-frame svg { display: block; width: 100%; height: 220px; }
.scatter-x {
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: 11px; padding: 2px 4px 4px;
}
.scatter-y {
  position: absolute; top: 6px; bottom: 26px; left: 8px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: var(--muted); font-size: 11px; pointer-events: none;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.block-charts { margin: 0 0 10px; }
.block-charts .col-chart { height: 52px; }
.block-charts .mini-chart-title { font-size: 11.5px; margin-bottom: 3px; }
.block-charts .bar-row { font-size: 11px; margin: 1px 0; }
.block-charts .bar-label { flex-basis: 110px; }
.block-charts .range-track { height: 11px; }
