/* =========================================================
   rbxts-bench — Engineering Instrument Panel
   Warm amber on deep charcoal, dense & data-forward
   ========================================================= */

:root {
  --bg: oklch(14% 0.01 60);
  --surface: oklch(17% 0.012 60);
  --surface-raised: oklch(20% 0.014 60);
  --border: oklch(26% 0.015 60);
  --border-subtle: oklch(22% 0.012 60);

  --text: oklch(90% 0.02 70);
  --text-secondary: oklch(62% 0.03 65);
  --text-tertiary: oklch(48% 0.02 60);

  --amber: oklch(76% 0.14 75);
  --amber-dim: oklch(76% 0.14 75 / 0.15);
  --amber-strong: oklch(82% 0.15 78);

  --pass: oklch(68% 0.13 155);
  --pass-dim: oklch(68% 0.13 155 / 0.12);
  --fail: oklch(65% 0.16 25);
  --fail-dim: oklch(65% 0.16 25 / 0.12);
  --warn: oklch(76% 0.14 85);
  --warn-dim: oklch(76% 0.14 85 / 0.12);

  --cat-bug: oklch(68% 0.15 20);
  --cat-bug-dim: oklch(68% 0.15 20 / 0.12);
  --cat-code: oklch(68% 0.13 155);
  --cat-code-dim: oklch(68% 0.13 155 / 0.12);
  --cat-ui: oklch(72% 0.12 250);
  --cat-ui-dim: oklch(72% 0.12 250 / 0.12);

  --font-display: "Instrument Serif", Georgia, serif;
  --font-body: "DM Sans", system-ui, sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ---- Custom Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

@supports (scrollbar-color: auto) {
  * {
    scrollbar-color: var(--border) var(--bg);
    scrollbar-width: thin;
  }
}

html {
  font-size: clamp(14px, 1.1vw, 16px);
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  height: 3rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--amber);
  letter-spacing: -0.02em;
}

.logo-sep {
  color: var(--text-tertiary);
  font-weight: 300;
}

.logo-sub {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 400;
}

.topbar-right {
  display: flex;
  gap: 0.35rem;
}

.action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-family: var(--font-body);
  font-weight: 500;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: color 0.15s, border-color 0.15s;
}

.action-btn:hover {
  color: var(--text);
  border-color: var(--amber);
}

/* ---- Page ---- */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  min-height: calc(100vh - 3rem);
}

/* ---- Empty / Drop State ---- */
.empty-state {
  padding: 6rem 0 4rem;
}

.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: 4px;
  padding: 4rem 2rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--amber);
  background: var(--amber-dim);
}

.drop-icon {
  color: var(--text-tertiary);
  margin-bottom: 1rem;
}

.drop-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.drop-sub {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

/* ---- Run Tabs ---- */
.run-tabs {
  display: flex;
  gap: 2px;
  padding-top: 1.5rem;
  padding-bottom: 0.5rem;
  overflow-x: auto;
}

.run-tab {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  border-radius: 3px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.run-tab:hover {
  color: var(--text-secondary);
  background: var(--surface);
}

.run-tab.active {
  color: var(--amber);
  background: var(--amber-dim);
}

/* ---- Report Header ---- */
.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 2rem 0 2.5rem;
  border-bottom: 1px solid var(--border-subtle);
  gap: 2rem;
}

.agent-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 400;
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.03em;
}

.run-meta {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 0.4rem;
}

.report-header-right {
  text-align: right;
  flex-shrink: 0;
}

.big-score {
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.big-score-num {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4rem);
  color: var(--amber);
  letter-spacing: -0.03em;
}

.big-score-sep {
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--text-tertiary);
  margin: 0 0.1em;
  font-weight: 300;
}

.big-score-max {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--text-tertiary);
}

.pass-rate {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 0.4rem;
  font-variant-numeric: tabular-nums;
}

/* ---- Categories ---- */
.categories {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  margin-top: 2.5rem;
}

.cat-block {
  background: var(--bg);
  padding: 1.25rem 1.5rem;
}

.cat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.cat-label-bug { color: var(--cat-bug); }
.cat-label-code { color: var(--cat-code); }
.cat-label-ui { color: var(--cat-ui); }

.cat-score {
  font-family: var(--font-display);
  font-size: 1.8rem;
  line-height: 1;
  margin-bottom: 0.15rem;
  font-variant-numeric: tabular-nums;
}

.cat-max {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.cat-bar {
  height: 3px;
  background: var(--surface-raised);
  margin-top: 0.9rem;
  border-radius: 1.5px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: 1.5px;
  transition: width 0.6s var(--ease-out);
}

.cat-bar-fill-bug { background: var(--cat-bug); }
.cat-bar-fill-code { background: var(--cat-code); }
.cat-bar-fill-ui { background: var(--cat-ui); }

.cat-pass {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
}

/* ---- Task Section ---- */
.task-section {
  margin-top: 3rem;
}

.task-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.task-section-head h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.task-filters {
  display: flex;
  gap: 3px;
  align-items: center;
}

.filter-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 6px;
}

.filter-chip {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 0.01em;
  transition: color 0.12s, background 0.12s;
}

.filter-chip:hover {
  color: var(--text-secondary);
}

.filter-chip.active {
  color: var(--text);
  background: var(--surface-raised);
}

/* ---- Task List ---- */
.task-list {
  border-top: 1px solid var(--border-subtle);
}

.task-row {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s;
}

.task-row-head {
  display: grid;
  grid-template-columns: 24px 1fr 80px 56px 90px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  cursor: pointer;
  user-select: none;
}

.task-row-head:hover {
  background: var(--surface);
}

.task-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  justify-self: center;
}

.dot-pass { background: var(--pass); box-shadow: 0 0 6px var(--pass-dim); }
.dot-fail { background: var(--fail); box-shadow: 0 0 6px var(--fail-dim); }

.task-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.task-name-sub {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.task-cat-tag {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
  justify-self: start;
}

.tag-bug-fix { color: var(--cat-bug); background: var(--cat-bug-dim); }
.tag-code-writing { color: var(--cat-code); background: var(--cat-code-dim); }
.tag-ui-creation { color: var(--cat-ui); background: var(--cat-ui-dim); }

.task-diff {
  font-size: 0.7rem;
  font-weight: 600;
  justify-self: center;
}

.diff-easy { color: var(--pass); }
.diff-medium { color: var(--warn); }
.diff-hard { color: var(--fail); }

.task-score-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.task-score-val {
  font-size: 0.85rem;
  font-weight: 600;
}

.task-score-max {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.task-duration {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

/* ---- Task Detail (inline expand) ---- */
.task-detail {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s var(--ease-out);
}

.task-detail.open {
  grid-template-rows: 1fr;
}

.task-detail-inner {
  overflow: hidden;
}

.task-detail-content {
  padding: 0 0 1.25rem 24px;
  margin-left: 0.75rem;
}

.validator-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 0.75rem;
  height: 20px;
}

.validator-block {
  border-radius: 2px;
  position: relative;
  transition: opacity 0.15s;
  cursor: default;
}

.validator-block.v-pass { background: var(--pass); }
.validator-block.v-fail { background: var(--fail); opacity: 0.4; }
.validator-block.v-fail:hover { opacity: 0.7; }

.validator-block::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.validator-block:hover::after {
  opacity: 1;
}

.validator-rows {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.v-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  background: var(--surface);
  border-radius: 2px;
}

.v-row:first-child { border-radius: 3px 3px 2px 2px; }
.v-row:last-child { border-radius: 2px 2px 3px 3px; }

.v-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  justify-self: center;
}

.v-icon-pass { background: var(--pass); }
.v-icon-fail { background: var(--fail); }

.v-label {
  color: var(--text-secondary);
}

.v-pts {
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.v-pts-earned {
  color: var(--pass);
}

.v-detail {
  grid-column: 2 / -1;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  padding-top: 2px;
  line-height: 1.4;
  font-style: italic;
}

/* ---- LLM Judge ---- */
.judge-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.judge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.judge-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--amber);
}

.judge-score {
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.score-good { color: var(--pass); }
.score-mid { color: var(--warn); }
.score-low { color: var(--fail); }

.judge-reasoning {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 0.6rem;
  line-height: 1.45;
}

.judge-criteria {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.j-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  background: var(--surface);
  border-radius: 2px;
}

.j-row:first-child { border-radius: 3px 3px 2px 2px; }
.j-row:last-child { border-radius: 2px 2px 3px 3px; }

.j-name {
  color: var(--text-secondary);
}

.j-score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.j-full { color: var(--pass); }
.j-partial { color: var(--warn); }
.j-zero { color: var(--fail); }

.j-note {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-style: italic;
}

/* ---- Leaderboard (dot matrix) ---- */
.leaderboard {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
}

.leaderboard h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  margin-bottom: 1.25rem;
}

.matrix {
  overflow-x: auto;
}

.matrix table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.matrix th {
  text-align: left;
  padding: 0.4rem 0.5rem;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.matrix th.task-col {
  text-align: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-width: 32px;
  padding: 0.5rem 0.2rem;
  font-size: 0.55rem;
  line-height: 1.2;
}

.matrix td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.matrix tr:hover td {
  background: var(--surface);
}

.matrix-rank {
  font-weight: 700;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  width: 24px;
}

.matrix-rank-1 { color: var(--amber-strong); }
.matrix-rank-2 { color: var(--amber); }
.matrix-rank-3 { color: var(--text-secondary); }

.matrix-agent {
  font-weight: 600;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.matrix-pct {
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
  text-align: right;
  font-size: 0.7rem;
}

/* Dot cells */
.dot-cell {
  text-align: center;
  padding: 0.4rem 0.15rem;
}

.dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  position: relative;
  cursor: default;
}

.dot-full {
  background: var(--pass);
}

.dot-partial {
  background: var(--warn);
}

.dot-zero {
  background: var(--surface-raised);
  border: 1px solid var(--border);
}

.dot::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 20;
}

.dot:hover::after {
  opacity: 1;
}

/* Category sub-scores in matrix */
.matrix-cat {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 0.7rem;
  white-space: nowrap;
}

.matrix-cat-bug { color: var(--cat-bug); }
.matrix-cat-code { color: var(--cat-code); }
.matrix-cat-ui { color: var(--cat-ui); }

/* ---- Footer ---- */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  font-size: 0.72rem;
  color: var(--text-tertiary);
  letter-spacing: 0.03em;
}

.footer-dot {
  width: 3px;
  height: 3px;
  background: var(--text-tertiary);
  border-radius: 50%;
}

/* ---- Entrance animations ---- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.anim-in {
  animation: fadeUp 0.5s var(--ease-out) both;
}

.anim-delay-1 { animation-delay: 0.05s; }
.anim-delay-2 { animation-delay: 0.1s; }
.anim-delay-3 { animation-delay: 0.15s; }
.anim-delay-4 { animation-delay: 0.2s; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .categories {
    grid-template-columns: 1fr;
  }

  .report-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .report-header-right {
    text-align: left;
  }

  .task-row-head {
    grid-template-columns: 20px 1fr 56px;
    gap: 0.5rem;
  }

  .task-cat-tag,
  .task-duration {
    display: none;
  }

  .task-filters {
    flex-wrap: wrap;
  }

  .comp-row {
    grid-template-columns: 1fr 60px;
  }

  .comp-bar-track {
    display: none;
  }
}
