@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=JetBrains+Mono:wght@400;500;700;800&family=Syne:wght@400;500;700;800&display=swap');

:root {
  --bg: #000;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.05);
  --surface-raised: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.38);
  --muted-soft: rgba(255, 255, 255, 0.22);
  --label: rgba(255, 255, 255, 0.2);
  --good: #4ade80;
  --good-soft: rgba(74, 222, 128, 0.08);
  --good-border: rgba(74, 222, 128, 0.35);
  --warn: #facc15;
  --radius: 10px;
  --radius-lg: 14px;
  --font-sans: 'Syne', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;
  --font-display: 'JetBrains Mono', ui-monospace, monospace;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.07) transparent; }
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.07); }

.wrap {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

/* Titlebar */
.titlebar {
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.titlebar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 16px 0;
}

.tb-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 9px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.title-block { min-width: 0; }

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.tagline {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.28);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tb-tag {
  font-size: 9px;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.3);
  padding: 3px 9px;
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 0.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-size: 10px;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  transition: all 0.15s;
  user-select: none;
}

.tb-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.tb-btn.primary {
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.tb-btn.primary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.instructions-btn { font: inherit; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 22px 0 10px;
}

.stat {
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.15s;
}

.stat:hover { border-color: var(--line-strong); }

.stat .label {
  color: var(--label);
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat .value {
  margin-top: 8px;
  font-size: 1.35rem;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.stat .value.good { color: var(--good); }
.stat .sub {
  color: rgba(255, 255, 255, 0.28);
  font-size: 9px;
  font-family: var(--font-mono);
  margin-top: 4px;
}

/* Panels */
.panel {
  margin: 16px 0;
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px 20px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--label);
  font-weight: 400;
}

.hint {
  color: rgba(255, 255, 255, 0.28);
  font-size: 9px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.chart-box { position: relative; height: 380px; padding-bottom: 4px; }

/* Table */
.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

table.leaderboard {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.86rem;
  min-width: 980px;
}

col.w-id { width: 76px; }
col.w-author { width: 148px; }
col.w-model { width: 132px; }
col.w-score { width: 100px; }
col.w-delta { width: 112px; }
col.w-zstd { width: 84px; }
col.w-open { width: 96px; }

table.leaderboard th,
table.leaderboard td {
  padding: 0 12px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.leaderboard thead th {
  height: 36px;
  color: var(--label);
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 0.5px solid var(--line);
  vertical-align: middle;
}

table.leaderboard tbody td {
  height: 50px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

table.leaderboard tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

table.leaderboard tbody tr:hover { background: var(--surface-hover); }

table.leaderboard tbody tr:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.35);
  outline-offset: -1px;
}

table.leaderboard tbody tr:last-child td { border-bottom: none; }

table.leaderboard tbody tr.record {
  position: relative;
}

table.leaderboard tbody tr.record td.c-id {
  box-shadow: inset 2px 0 0 var(--good);
}

.c-id,
.c-delta,
.c-open,
.c-score,
.c-zstd {
  overflow: visible;
  text-overflow: clip;
}

.c-id {
  color: rgba(255, 255, 255, 0.32);
  font-weight: 500;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.c-author .avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  object-fit: cover;
  vertical-align: middle;
  margin-right: 8px;
}

.c-author .aname {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 500;
  font-size: 11px;
  vertical-align: middle;
}

.c-model {
  color: rgba(255, 255, 255, 0.32);
  font-size: 10px;
  font-family: var(--font-mono);
}

.c-score {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.c-zstd {
  color: rgba(255, 255, 255, 0.68);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 400;
  padding: 2px 7px;
  border-radius: 10px;
  border: 0.5px solid transparent;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.badge.good {
  color: var(--good);
  background: var(--good-soft);
  border-color: var(--good-border);
}

.badge.flat {
  color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.c-open { text-align: right; overflow: visible; }

.open-btn {
  display: inline-block;
  color: rgba(255, 255, 255, 0.32);
  font-size: 9px;
  font-family: var(--font-mono);
  padding: 4px 9px;
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  white-space: nowrap;
  transition: all 0.15s;
}

tr:hover .open-btn {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.05);
}

/* Shared note rendering (table + dialog) */
.note {
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
  font-family: var(--font-mono);
  margin: 0;
  line-height: 1.65;
  overflow-wrap: break-word;
  word-break: break-word;
}

.note code {
  background: rgba(255, 255, 255, 0.04);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.92em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.note strong { color: #fff; font-weight: 500; }

.sha {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* Dialog */
.entry-dialog {
  width: min(720px, 92vw);
  max-height: 88vh;
  padding: 0;
  border: 0.5px solid rgba(255, 255, 255, 0.11);
  border-radius: var(--radius-lg);
  background: #0c0c0c;
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.8);
  overflow: auto;
  overflow-wrap: break-word;
}

.entry-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
}

.dialog-inner {
  padding: 22px 24px 24px;
  position: relative;
  min-width: 0;
  overflow-wrap: break-word;
}

.dialog-close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.dialog-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 40px;
  min-width: 0;
}

.d-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  object-fit: cover;
  flex: none;
}

.d-head-text { min-width: 0; flex: 1; }

.d-title {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.d-sub {
  color: rgba(255, 255, 255, 0.28);
  font-size: 10px;
  font-family: var(--font-mono);
  margin-top: 3px;
  overflow-wrap: break-word;
}

.d-sub a {
  color: rgba(255, 255, 255, 0.68);
  text-decoration: none;
}

.d-sub a:hover { color: #fff; }

.d-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0 6px;
  min-width: 0;
}

.d-metric {
  background: rgba(255, 255, 255, 0.03);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  overflow-wrap: break-word;
}

.m-label {
  color: var(--label);
  font-size: 8px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.m-value {
  font-weight: 500;
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.85);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.m-value a {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
}

.m-value a:hover { color: #fff; }

.d-sec { margin-top: 20px; min-width: 0; }

.d-sec h3 {
  margin: 0 0 8px;
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--label);
  font-weight: 400;
}

.snapshot {
  margin: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.68);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.dialog-foot {
  margin-top: 20px;
  border-top: 0.5px solid var(--line);
  padding-top: 14px;
}

.dialog-foot a {
  color: rgba(255, 255, 255, 0.68);
  text-decoration: none;
  font-weight: 400;
  font-size: 10px;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
  transition: color 0.15s;
}

.dialog-foot a:hover { color: #fff; }

/* Instructions dialog */
.instructions-dialog { width: min(680px, 92vw); }
.instructions-head { padding-right: 40px; }

.instructions-body {
  min-width: 0;
  overflow-wrap: break-word;
}

.instructions-body .d-sec:first-child { margin-top: 8px; }

.instructions-list {
  margin: 0;
  padding-left: 1.25rem;
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
  font-family: var(--font-mono);
  line-height: 1.65;
  overflow-wrap: break-word;
}

.instructions-list li {
  margin-bottom: 6px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.instructions-list li:last-child { margin-bottom: 0; }

.instructions-list code {
  background: rgba(255, 255, 255, 0.04);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.92em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.prompt-examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  min-width: 0;
}

.prompt-block {
  background: rgba(255, 255, 255, 0.03);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}

.prompt-label {
  padding: 7px 12px;
  font-size: 8px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--label);
  border-bottom: 0.5px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.prompt-text {
  margin: 0;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.68);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.instructions-foot {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  min-width: 0;
}

/* Footer */
.site-footer {
  border-top: 0.5px solid rgba(255, 255, 255, 0.07);
  margin-top: 28px;
  padding: 18px 0 40px;
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: rgba(255, 255, 255, 0.28);
  font-size: 9px;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}

.site-footer code {
  background: rgba(255, 255, 255, 0.04);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 5px;
}

.error {
  text-align: center;
  color: var(--warn);
  padding: 40px;
  font-family: var(--font-mono);
  font-size: 11px;
}

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chart-box { height: 320px; }
  .d-metrics { grid-template-columns: repeat(2, 1fr); }
  .titlebar-inner { padding: 14px 0; }
}
