:root {
  color-scheme: light dark;

  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --success-text: #006300;

  --cat-coding: #2a78d6;
  --cat-coding-track: #cde2fb;
  --cat-research: #1baf7a;
  --cat-research-track: #c7ecdf;
  --cat-data-analysis: #eda100;
  --cat-data-analysis-track: #fbe6bd;
  --cat-automation: #008300;
  --cat-automation-track: #c9e4c9;
  --cat-writing: #4a3aa7;
  --cat-writing-track: #dcd6f2;
  --cat-tool-use: #e34948;
  --cat-tool-use-track: #f9d6d5;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(11, 11, 11, 0.06), 0 1px 1px rgba(11, 11, 11, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --success-text: #0ca30c;

    --cat-coding: #3987e5;
    --cat-coding-track: #234269;
    --cat-research: #199e70;
    --cat-research-track: #1c3d31;
    --cat-data-analysis: #c98500;
    --cat-data-analysis-track: #3d2f0d;
    --cat-automation: #008300;
    --cat-automation-track: #1c331c;
    --cat-writing: #9085e9;
    --cat-writing-track: #2e2a54;
    --cat-tool-use: #e66767;
    --cat-tool-use-track: #40201f;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
  }
}

html[data-theme='light'] {
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --cat-coding: #2a78d6;
  --cat-coding-track: #cde2fb;
  --cat-research: #1baf7a;
  --cat-research-track: #c7ecdf;
  --cat-data-analysis: #eda100;
  --cat-data-analysis-track: #fbe6bd;
  --cat-automation: #008300;
  --cat-automation-track: #c9e4c9;
  --cat-writing: #4a3aa7;
  --cat-writing-track: #dcd6f2;
  --cat-tool-use: #e34948;
  --cat-tool-use-track: #f9d6d5;
  --shadow-card: 0 1px 2px rgba(11, 11, 11, 0.06), 0 1px 1px rgba(11, 11, 11, 0.04);
}

html[data-theme='dark'] {
  --surface-1: #1a1a19;
  --page-plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --cat-coding: #3987e5;
  --cat-coding-track: #234269;
  --cat-research: #199e70;
  --cat-research-track: #1c3d31;
  --cat-data-analysis: #c98500;
  --cat-data-analysis-track: #3d2f0d;
  --cat-automation: #008300;
  --cat-automation-track: #1c331c;
  --cat-writing: #9085e9;
  --cat-writing-track: #2e2a54;
  --cat-tool-use: #e66767;
  --cat-tool-use-track: #40201f;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
  line-height: 1.5;
}

a {
  color: inherit;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header / nav */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--cat-coding), var(--cat-research));
  display: inline-block;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.main-nav a:hover {
  background: var(--page-plane);
  color: var(--text-primary);
}

.main-nav a.active {
  color: var(--text-primary);
  background: var(--gridline);
}

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

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
}

.theme-toggle:hover {
  background: var(--page-plane);
}

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  cursor: pointer;
  color: var(--text-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--cat-coding);
  color: #ffffff;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: var(--surface-1);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--page-plane);
}

/* Hero */
.hero {
  padding: 72px 0 56px;
  text-align: center;
}

.hero h1 {
  font-size: 44px;
  line-height: 1.1;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.hero p.lede {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto 28px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Cards */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.section {
  padding: 48px 0;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 24px;
  margin: 0;
  letter-spacing: -0.01em;
}

.section-header p {
  color: var(--text-secondary);
  margin: 4px 0 0;
  font-size: 14px;
}

.section-link {
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: var(--cat-coding);
  white-space: nowrap;
}

/* Category grid on home / about */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.category-card {
  padding: 20px;
}

.category-card .cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.category-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  display: flex;
  align-items: center;
}

.category-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Category chip (identity color, always paired with visible text) */
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--page-plane);
  border: 1px solid var(--border);
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.cat-chip .cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

/* Stat tiles */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-tile {
  padding: 20px 22px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.stat-value {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0 0;
}

.stat-tile svg.sparkline {
  margin-top: 10px;
  display: block;
}

/* Leaderboard table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

table.leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 760px;
}

table.leaderboard th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

table.leaderboard th.sortable {
  cursor: pointer;
  user-select: none;
}

table.leaderboard th.sortable:hover {
  color: var(--text-secondary);
}

table.leaderboard th .sort-arrow {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.6;
}

table.leaderboard td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gridline);
  vertical-align: middle;
}

table.leaderboard tbody tr {
  cursor: pointer;
}

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

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

.rank-cell {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-weight: 600;
  width: 40px;
}

.rank-cell.top-1 { color: #b8860b; }
.rank-cell.top-2 { color: #8a8a8a; }
.rank-cell.top-3 { color: #a0623a; }

.agent-name {
  font-weight: 600;
  color: var(--text-primary);
}

.agent-link {
  color: inherit;
  text-decoration: none;
}

.agent-link:hover {
  text-decoration: underline;
}

.agent-org {
  font-size: 12px;
  color: var(--text-muted);
}

.overall-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
}

.meter-cell {
  min-width: 90px;
}

.meter {
  height: 8px;
  border-radius: 4px;
  width: 100%;
  position: relative;
}

.meter-fill {
  height: 100%;
  border-radius: 4px;
}

.meter-value {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.expand-row td {
  background: var(--page-plane);
  padding: 20px 24px 28px;
}

.profile-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 640px;
}

.profile-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.profile-bar-track {
  background: var(--gridline);
  border-radius: 4px;
  height: 16px;
  overflow: hidden;
}

.profile-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.profile-bar-value {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  text-align: right;
}

.agent-panels {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 1.2fr);
  gap: 20px;
  align-items: start;
}

.line-chart {
  display: block;
}

.line-chart .chart-dot:hover + circle {
  stroke-width: 3;
}

/* Category small multiples (leaderboard breakdown) */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.breakdown-card {
  padding: 18px 20px;
}

.breakdown-card h4 {
  margin: 0 0 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.breakdown-bar-row {
  display: grid;
  grid-template-columns: 84px 1fr 28px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 8px;
}

.breakdown-bar-row:last-child {
  margin-bottom: 0;
}

.breakdown-name {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown-track {
  background: var(--gridline);
  border-radius: 4px;
  height: 12px;
}

.breakdown-fill {
  height: 100%;
  border-radius: 4px;
}

.breakdown-value {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  text-align: right;
}

/* Tasks page */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.filter-bar input[type='search'],
.filter-bar select {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
}

.filter-bar input[type='search'] {
  flex: 1;
  min-width: 200px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.task-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.task-card h3 {
  margin: 0;
  font-size: 15px;
}

.task-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.difficulty-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
}

.difficulty-easy {
  color: var(--status-good);
  background: color-mix(in srgb, var(--status-good) 14%, transparent);
}

.difficulty-medium {
  color: #9a6b00;
  background: color-mix(in srgb, var(--status-warning) 22%, transparent);
}

.difficulty-hard {
  color: var(--status-critical);
  background: color-mix(in srgb, var(--status-critical) 14%, transparent);
}

.task-points {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

/* About page */
.prose h2 {
  font-size: 22px;
  margin: 40px 0 12px;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose p {
  color: var(--text-secondary);
  font-size: 15px;
}

.prose ul {
  color: var(--text-secondary);
  font-size: 15px;
  padding-left: 20px;
}

.method-steps {
  display: grid;
  gap: 14px;
  margin: 20px 0;
}

.method-step {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
}

.method-step .step-num {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--cat-coding);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.method-step h4 {
  margin: 0 0 4px;
  font-size: 15px;
}

.method-step p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Submit page */
.form-card {
  padding: 28px 32px;
  max-width: 640px;
  margin: 0 auto;
}

.form-row {
  margin-bottom: 18px;
}

.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-row .hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
}

.form-row input[type='text'] {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
}

.slider-row {
  display: grid;
  grid-template-columns: 130px 1fr 44px;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.slider-row label {
  margin: 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.slider-track-wrap {
  position: relative;
  height: 16px;
  border-radius: 4px;
  background: var(--gridline);
}

.slider-fill-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 4px;
  pointer-events: none;
}

.slider-row input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.slider-row input[type='range']::-webkit-slider-runnable-track {
  background: transparent;
  height: 16px;
  border-radius: 4px;
}

.slider-row input[type='range']::-moz-range-track {
  background: transparent;
  height: 16px;
  border-radius: 4px;
  border: none;
}

.slider-row input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: currentColor;
  border: 2px solid var(--surface-1);
  box-shadow: 0 0 0 1px var(--border);
  margin-top: 0;
  cursor: pointer;
}

.slider-row input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: currentColor;
  border: 2px solid var(--surface-1);
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}

.slider-value {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  text-align: right;
  color: var(--text-secondary);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  align-items: center;
}

.form-message {
  font-size: 13px;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: none;
}

.form-message.visible {
  display: block;
}

.form-message.success {
  background: color-mix(in srgb, var(--status-good) 14%, transparent);
  color: var(--success-text);
}

.form-message.error {
  background: color-mix(in srgb, var(--status-critical) 14%, transparent);
  color: var(--status-critical);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 13px;
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* Tooltip (chart hover) */
.viz-tooltip {
  position: absolute;
  background: var(--text-primary);
  color: var(--surface-1);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
  white-space: nowrap;
  z-index: 30;
  transform: translate(-50%, -100%);
}

.viz-tooltip.visible {
  opacity: 1;
}

.skeleton {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
}

@media (max-width: 720px) {
  .main-nav {
    display: none;
  }
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .site-header.nav-open .main-nav {
    display: flex;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 8px 16px 16px;
  }
  .hero h1 {
    font-size: 32px;
  }
  .profile-bar-row {
    grid-template-columns: 90px 1fr 34px;
  }
  .agent-panels {
    grid-template-columns: 1fr;
  }
}
