/* DL3 leaderboard — one stylesheet, no build step. */

:root {
  color-scheme: light;
  --page: #f5f5f2;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6b6a65;
  --hair: #e4e3dc;
  --ring: rgba(11, 11, 11, 0.08);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.08);
  --bar-a: #86b6ef;
  --bar-b: #2a78d6;
  --track: #ebeae4;
  --good: #006300;
  --bad: #c42f2f;
  --warn: #9a6400;
  --gold: #e0a100;
  --silver: #9aa1ab;
  --bronze: #c2703d;
  --glow: rgba(42, 120, 214, 0.16);
  --glow-2: rgba(27, 175, 122, 0.08);
  --shadow: 0 1px 2px rgba(20, 20, 10, 0.04), 0 10px 28px -12px rgba(20, 20, 10, 0.12);
  --shadow-hover: 0 2px 4px rgba(20, 20, 10, 0.05), 0 22px 44px -16px rgba(20, 20, 10, 0.22);
  --radius: 18px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #171716;
    --surface-2: #21211f;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --hair: #2c2c2a;
    --ring: rgba(255, 255, 255, 0.08);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-wash: rgba(57, 135, 229, 0.12);
    --bar-a: #1c5cab;
    --bar-b: #5598e7;
    --track: #262624;
    --good: #0ca30c;
    --bad: #e66767;
    --warn: #fab219;
    --glow: rgba(57, 135, 229, 0.18);
    --glow-2: rgba(25, 158, 112, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 30px -14px rgba(0, 0, 0, 0.7);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.5), 0 24px 48px -16px rgba(0, 0, 0, 0.85);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #171716;
  --surface-2: #21211f;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --hair: #2c2c2a;
  --ring: rgba(255, 255, 255, 0.08);
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-wash: rgba(57, 135, 229, 0.12);
  --bar-a: #1c5cab;
  --bar-b: #5598e7;
  --track: #262624;
  --good: #0ca30c;
  --bad: #e66767;
  --warn: #fab219;
  --glow: rgba(57, 135, 229, 0.18);
  --glow-2: rgba(25, 158, 112, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 30px -14px rgba(0, 0, 0, 0.7);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.5), 0 24px 48px -16px rgba(0, 0, 0, 0.85);
}

/* --- base ---------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

.glow {
  position: fixed;
  inset: 0 0 auto 0;
  height: 520px;
  pointer-events: none;
  background:
    radial-gradient(50% 60% at 20% -10%, var(--glow), transparent 70%),
    radial-gradient(40% 50% at 85% -5%, var(--glow-2), transparent 70%);
  z-index: 0;
}

h1,
h2,
h3,
h4 {
  font-family: var(--display);
  letter-spacing: -0.015em;
  margin: 0;
}

a {
  color: inherit;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.strong {
  font-weight: 600;
}

.err {
  color: var(--bad);
}

.ok-text {
  color: var(--good);
  font-style: normal;
}

.wrap {
  word-break: break-all;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.link {
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 500;
}

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

/* --- top bar ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px max(16px, calc((100vw - 1240px) / 2));
  background: color-mix(in srgb, var(--page) 78%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--ring);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.wordmark-mark {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: conic-gradient(from 210deg, #2a78d6, #1baf7a, #4a3aa7, #2a78d6);
  box-shadow: 0 4px 14px -4px rgba(42, 120, 214, 0.7);
  flex: none;
}

.wordmark-mark-lg {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  margin-bottom: 18px;
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav a.is-current {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--ring), 0 2px 6px -2px rgba(0, 0, 0, 0.12);
}

.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-end form {
  margin: 0;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--ring);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--ink);
}

/* --- page ---------------------------------------------------------------- */

.page {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 36px 16px 80px;
}

.intro {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 36px;
}

.intro h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.intro-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.intro-actions form {
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.section {
  margin-bottom: 44px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 22px;
}

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

/* --- follow-a-team lens --------------------------------------------------- */

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

.lens-label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}

.lens-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--ring);
  background: var(--surface);
  color: var(--ink);
  font: 500 13px/1 var(--font);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.lens-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.lens-chip.is-me {
  font-weight: 700;
}

.lens-chip[aria-pressed="true"] {
  background: var(--accent-wash);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  box-shadow: 0 0 0 2px var(--surface);
  flex: none;
}

.dot-lg {
  width: 14px;
  height: 14px;
}

/* --- tiles ---------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 18px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 18px 14px;
  box-shadow: var(--shadow);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s;
  isolation: isolate;
}

/* thin gradient border */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    140deg,
    color-mix(in srgb, var(--accent) 42%, transparent),
    var(--ring) 32%,
    var(--ring) 68%,
    color-mix(in srgb, var(--accent) 22%, transparent)
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.75;
  transition: opacity 0.35s;
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.tile:hover::before {
  opacity: 1;
}

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

.tile-title {
  font-size: 17px;
  font-weight: 600;
}

.tile-sub {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.tool {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--ring);
  font: 500 11px/1.4 var(--mono);
  color: var(--ink-2);
  white-space: nowrap;
}

.tile-foot {
  margin-top: auto;
  padding-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.ranking {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.rank-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 8px;
  border-radius: 12px;
  transition: opacity 0.25s, background 0.25s, filter 0.25s;
}

.rank-row:first-child:not(.is-empty) {
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 10%, transparent), transparent 70%);
}

.rank-row.is-me {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent);
}

.rank-row.is-empty {
  opacity: 0.55;
}

.badge {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font: 700 12px/1 var(--display);
  background: var(--surface-2);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--ring);
}

.badge.gold {
  background: radial-gradient(circle at 32% 28%, #fff1bf, #e0a100 72%);
  color: #3b2a00;
  box-shadow: 0 0 0 3px color-mix(in srgb, #e0a100 22%, transparent), 0 6px 14px -4px rgba(224, 161, 0, 0.6);
}

.badge.silver {
  background: radial-gradient(circle at 32% 28%, #ffffff, #9aa1ab 74%);
  color: #1f2329;
  box-shadow: 0 0 0 3px color-mix(in srgb, #9aa1ab 22%, transparent), 0 6px 14px -4px rgba(120, 128, 140, 0.5);
}

.badge.bronze {
  background: radial-gradient(circle at 32% 28%, #fad3b3, #c2703d 74%);
  color: #3a1c07;
  box-shadow: 0 0 0 3px color-mix(in srgb, #c2703d 22%, transparent), 0 6px 14px -4px rgba(194, 112, 61, 0.5);
}

.who {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.raw {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track {
  position: relative;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.fill,
.mini-fill {
  display: block;
  height: 100%;
  width: var(--w);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bar-a), var(--bar-b));
  transition: width 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.rank-row:first-child:not(.is-empty) .fill {
  box-shadow: 0 0 12px -2px color-mix(in srgb, var(--bar-b) 70%, transparent);
}

html.js [data-tile]:not(.is-in) .fill,
html.js [data-tile]:not(.is-in) .mini-fill {
  width: 0;
}

/* uncertainty band laid over a score bar */
.ci {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--lo);
  width: max(3px, calc(var(--hi) - var(--lo)));
  background: color-mix(in srgb, var(--ink) 18%, transparent);
  box-shadow: inset 2px 0 0 var(--ink-2), inset -2px 0 0 var(--ink-2);
  border-radius: 2px;
  pointer-events: none;
}

.tie {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 6px;
  font: 600 11px/1 var(--font);
  color: var(--ink-2);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--hair);
  cursor: help;
}

.tie-inline {
  cursor: default;
  vertical-align: 1px;
}

.foot-note {
  display: block;
  margin-top: 6px;
  max-width: 80ch;
  line-height: 1.5;
}

.big {
  font: 600 22px/1 var(--display);
  min-width: 2.6ch;
  text-align: right;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font: 700 11px/1 var(--font);
  padding: 2px 5px;
  border-radius: 6px;
}

.delta span {
  font-size: 8px;
}

.delta.up {
  color: var(--good);
  background: color-mix(in srgb, var(--good) 12%, transparent);
}

.delta.down {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

/* lens focus: dim every other team in every tile */
body.has-focus .rank-row:not(.is-focus) {
  opacity: 0.25;
  filter: saturate(0.2);
}

body.has-focus .rank-row.is-focus {
  background: var(--accent-wash);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* --- hero tile ------------------------------------------------------------ */

.tile-hero {
  padding: 24px 22px 16px;
}

.tile-hero .tile-title {
  font-size: 21px;
}

.hero-table {
  display: grid;
  gap: 2px;
  overflow-x: auto;
  padding-bottom: 4px;
}

/* With many ML metrics the table scrolls sideways instead of being cut off. */
.hero-table > .hero-row {
  min-width: calc(300px + var(--subs, 4) * 78px);
}

.hero-row {
  grid-template-columns: 28px minmax(170px, 1.5fr) 64px repeat(var(--subs, 4), minmax(76px, 1fr));
}

.hero-row-head {
  display: grid;
  gap: 12px;
  padding: 0 8px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-row-head .num {
  text-align: right;
}

.hero-row .big {
  font-size: 28px;
}

.sub {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.sub-label {
  display: none;
}

.sub-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  min-width: 2.6ch;
  text-align: right;
}

.mini {
  display: block;
  height: 5px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

/* --- empty state ---------------------------------------------------------- */

.empty {
  padding: 8px 4px;
}

.empty p {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.skeleton {
  display: grid;
  gap: 14px;
}

.skeleton span {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--track) 0%, var(--surface-2) 45%, var(--track) 90%);
  background-size: 220% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton span:nth-child(1) {
  width: 88%;
}

.skeleton span:nth-child(2) {
  width: 66%;
}

.skeleton span:nth-child(3) {
  width: 42%;
}

@keyframes shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -100% 0;
  }
}

/* --- cards & forms --------------------------------------------------------- */

.cards {
  display: grid;
  gap: 18px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow), inset 0 0 0 1px var(--ring);
  min-width: 0;
}

.card h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.card-head p {
  margin: 4px 0 0;
}

.subhead {
  margin: 26px 0 12px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.subhead-sm {
  margin: 18px 0 8px;
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 14px 16px;
  align-items: start;
}

.form-grid .field-wide {
  grid-column: 1 / -1;
}

.form-grid .actions {
  grid-column: 1 / -1;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin: 8px 0 0;
}

.top-gap {
  margin-top: 18px;
}

form.inline {
  display: inline;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.field small {
  font-size: 12px;
  color: var(--muted);
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-2);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--hair);
  border-radius: 10px;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.4 var(--font);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

input[type="file"] {
  font: 13px var(--font);
  color: var(--ink-2);
  max-width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--ring);
  background: var(--surface-2);
  color: var(--ink);
  font: 600 14px/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}

.btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--surface-2) 70%, var(--hair));
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, #3987e5, #256abf);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(42, 120, 214, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #4390ea, #2a78d6);
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.actions {
  display: flex;
  gap: 10px;
}

.analyse-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--hair);
}

.analyse-bar form {
  margin: 0;
}

.analyse-bar p {
  margin: 0;
}

/* --- chips, statuses, toasts ---------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--ring);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chip-team {
  background: var(--surface);
  font-size: 13px;
}

.chip-scored {
  color: var(--accent-ink);
  background: var(--accent-wash);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  background: var(--surface-2);
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status:has(.pulse)::before {
  display: none;
}

.status-queued {
  color: var(--warn);
}

.status-running {
  color: var(--accent-ink);
}

.status-done {
  color: var(--good);
}

.status-failed {
  color: var(--bad);
}

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 currentColor;
  }
  100% {
    box-shadow: 0 0 0 7px transparent;
  }
}

.toasts {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--ring), inset 4px 0 0 var(--accent);
  font-size: 14px;
}

.toast-success {
  box-shadow: var(--shadow), inset 0 0 0 1px var(--ring), inset 4px 0 0 var(--good);
}

.toast-error {
  box-shadow: var(--shadow), inset 0 0 0 1px var(--ring), inset 4px 0 0 var(--bad);
}

.notice {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 14px;
  color: var(--ink-2);
}

.notice-error {
  color: var(--ink);
  box-shadow: inset 4px 0 0 var(--bad);
}

/* --- lists & tables -------------------------------------------------------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--hair);
}

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

.list-tight li {
  padding: 6px 2px;
}

.list .link {
  margin-left: auto;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

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

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
}

.table td {
  padding: 10px;
  border-bottom: 1px solid var(--hair);
  vertical-align: middle;
}

.table .num {
  text-align: right;
}

.table-compact td {
  padding: 7px 10px;
}

.table .bar-col {
  width: 25%;
  min-width: 80px;
}

.table tr.is-inactive td {
  opacity: 0.5;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.row-actions form {
  margin: 0;
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 0 0 12px;
}

.kv dt {
  font-weight: 600;
  color: var(--ink-2);
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* --- team page -------------------------------------------------------------- */

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr));
  gap: 10px;
}

.mini-tile {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
}

.mini-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.mini-score {
  font: 600 22px/1 var(--display);
}

.mini-raw {
  font-size: 12px;
  color: var(--muted);
}

.counters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.counter {
  display: grid;
  gap: 2px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface-2);
  min-width: 140px;
}

.counter-num {
  font: 700 32px/1 var(--display);
}

.small-num {
  font-size: 18px;
  line-height: 1.6;
}

.counter-label {
  font-size: 13px;
  color: var(--ink-2);
}

.uploads {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 14px;
}

.upload {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 18px;
  border-radius: 14px;
  background: var(--page);
  box-shadow: inset 0 0 0 1px var(--hair);
}

.upload h3 {
  font-size: 16px;
}

.upload p {
  margin: 0;
}

.upload-scored {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
  background: linear-gradient(180deg, var(--accent-wash), transparent 70%), var(--page);
}

.drop {
  position: relative;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1.5px dashed var(--hair);
  border-radius: 12px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.drop:hover,
.drop.is-over {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop input:disabled {
  cursor: not-allowed;
}

.drop.has-file span {
  color: var(--ink);
  font-weight: 600;
}

.feedback {
  display: grid;
  gap: 14px;
}

.score-strip {
  display: grid;
  grid-template-columns: 1.4fr repeat(5, 1fr);
  gap: 8px;
}

.score-strip-qa {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 118px), 1fr));
}

.score-strip-qa .score-main {
  grid-column: span 2;
}

.score-cell.beats-soft {
  box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--good) 55%, transparent);
}

.score-cell.beats-hard {
  box-shadow: inset 0 0 0 1.5px var(--good);
}

.grade-bars {
  display: grid;
  gap: 6px;
  max-width: 520px;
}

.grade-bar {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 3ch;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.grade-num {
  font-weight: 700;
  text-align: center;
}

.grade-1 .mini-fill,
.grade-2 .mini-fill {
  background: var(--bad);
}

.grade-3 .mini-fill {
  background: var(--warn);
}

.score-range {
  font-size: 12px;
  color: var(--muted);
}

/* error breakdown: correct / wrong / missed / extra */
.error-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 8px;
}

.error-cell {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
}

.error-cell .num {
  font: 600 20px/1 var(--display);
  color: var(--ink);
}

.error-cell em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.error-bad .num {
  color: var(--bad);
}

/* free format check */
.upload-check {
  margin-top: 14px;
}

.check-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px) auto;
  gap: 10px;
  align-items: end;
}

.field-inline {
  gap: 4px;
}

.chip-free {
  padding: 2px 8px;
  font-size: 11px;
  color: var(--good);
  background: color-mix(in srgb, var(--good) 12%, transparent);
  vertical-align: 2px;
}

@media (max-width: 720px) {
  .check-row {
    grid-template-columns: 1fr;
  }
}

.score-cell {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
}

.score-main {
  background: linear-gradient(135deg, var(--accent-wash), var(--surface-2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.score-label {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 600;
}

.score-val {
  font: 600 22px/1 var(--display);
}

.score-main .score-val {
  font-size: 30px;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.facts span {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
}

.log summary {
  cursor: pointer;
  font-weight: 600;
  margin-top: 18px;
}

.log pre,
.code {
  margin: 10px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--page);
  box-shadow: inset 0 0 0 1px var(--hair);
  font: 12.5px/1.55 var(--mono);
  overflow-x: auto;
  white-space: pre;
}

.log pre {
  max-height: 520px;
  overflow: auto;
}

.prose h2 {
  margin: 26px 0 8px;
  font-size: 18px;
}

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

.prose ul {
  padding-left: 20px;
}

.prose li {
  margin: 4px 0;
}

.sample-box {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0;
  padding: 16px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-wash), transparent), var(--surface-2);
}

.sample-box p {
  margin: 2px 0 0;
}

/* --- admin ML checklist ------------------------------------------------------ */

.checklist {
  display: grid;
  gap: 12px;
}

.check-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--page);
  box-shadow: inset 0 0 0 1px var(--hair);
}

.check-item p {
  margin: 2px 0 0;
}

.check-dot {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border-radius: 50%;
  border: 2px solid var(--hair);
}

.check-item.done .check-dot {
  border-color: var(--good);
  background: radial-gradient(circle, var(--good) 45%, transparent 50%);
}

.small-details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--accent-ink);
  margin-top: 10px;
}

/* --- login --------------------------------------------------------------------- */

.is-login .page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding-top: 16px;
}

.login-card {
  width: min(400px, 100%);
  padding: 36px 32px 28px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-hover), inset 0 0 0 1px var(--ring);
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 22px;
}

.stack {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.stack .btn {
  margin-top: 6px;
  padding: 12px;
}

/* --- responsive -------------------------------------------------------------------- */

@media (max-width: 900px) {
  .hero-row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }

  .hero-row-head {
    display: none;
  }

  .hero-row .sub {
    grid-column: 2 / -1;
    grid-template-columns: 120px minmax(0, 1fr) auto;
  }

  .hero-row .sub-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
  }

  .hero-row.rank-row,
  .hero-row.is-baseline {
    row-gap: 6px;
  }

  .hero-table > .hero-row {
    min-width: 0;
  }

  .score-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .score-main {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px 16px;
  }

  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .page {
    padding-top: 24px;
  }

  .card {
    padding: 18px;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .kv dd {
    margin-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  html.js [data-tile]:not(.is-in) .fill,
  html.js [data-tile]:not(.is-in) .mini-fill {
    width: var(--w);
  }
}

@media (forced-colors: active) {
  .fill,
  .mini-fill {
    background: Highlight;
  }
}

/* --- ML upload windows ------------------------------------------------------ */

.windows {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.window {
  display: grid;
  grid-template-columns: minmax(90px, 0.6fr) minmax(0, 2fr) minmax(0, 1.2fr);
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
}

.window-name {
  font-weight: 600;
  color: var(--ink);
}

.window-state {
  text-align: right;
}

.window-open {
  background: var(--accent-wash);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.window-open .window-state strong {
  color: var(--accent-ink);
}

.window-closed {
  opacity: 0.7;
}

.chip-warn {
  padding: 2px 8px;
  font-size: 11px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}

@media (max-width: 720px) {
  .window {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .window-state {
    text-align: left;
  }
}

.window-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}

/* --- baselines and measured difficulty ---------------------------------------- */

.chip-soft {
  color: var(--good);
  background: color-mix(in srgb, var(--good) 12%, transparent);
}

.chip-hard {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

.chip-tier-easy {
  color: var(--good);
}

.chip-tier-medium {
  color: var(--warn);
}

.chip-tier-hard {
  color: var(--bad);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-top: 14px;
}

.hero-row.is-baseline {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: repeating-linear-gradient(135deg, transparent 0 8px, var(--surface-2) 8px 9px);
  border-radius: 12px;
}

.hero-row.is-baseline .fill {
  background: var(--ink-2);
  opacity: 0.45;
}

.hero-row.is-baseline .name {
  font-weight: 600;
  color: var(--ink-2);
}

.baseline-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font: 700 11px/1 var(--font);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1.5px var(--hair);
}

.is-baseline-soft .baseline-mark {
  color: var(--good);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--good) 50%, transparent);
}

.is-baseline-hard .baseline-mark {
  color: var(--bad);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--bad) 50%, transparent);
}

.baseline-mark-sm {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  font-size: 10px;
  vertical-align: middle;
}

.check-row-2 {
  grid-template-columns: minmax(0, 1fr) auto;
}

/* --- (i) metric explanations -------------------------------------------------- */

.info {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 16px;
  height: 16px;
  margin-left: 5px;
  padding: 0;
  border: 1px solid var(--hair);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font: italic 700 10px/1 Georgia, "Times New Roman", serif;
  text-transform: none;
  letter-spacing: 0;
  vertical-align: 1px;
  cursor: help;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.info:hover,
.info:focus-visible,
.info[aria-expanded="true"] {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-wash);
  outline: none;
}

.info:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-wash);
}

/* A bigger touch target without a bigger icon. */
.info::before {
  content: "";
  position: absolute;
  width: 32px;
  height: 32px;
}

.info {
  position: relative;
}

.info-bubble {
  position: fixed;
  z-index: 50;
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--page);
  font: 400 13px/1.45 var(--font);
  text-transform: none;
  letter-spacing: 0;
  box-shadow: var(--shadow-hover);
  pointer-events: none;
}

.info-bubble[hidden] {
  display: none;
}

.sub-head {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.sub-head .info {
  margin-left: 3px;
}

/* --- one-time format check-in ------------------------------------------------------ */

.checkin {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--accent-wash), transparent 80%), var(--page);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.checkin h3 {
  margin: 4px 0;
  font-size: 18px;
}

.checkin-step {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.checkin-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.checkin-rule {
  margin-top: 8px;
}

.checkin .code {
  margin: 0;
}

.notice-ok {
  color: var(--ink);
  box-shadow: inset 4px 0 0 var(--good);
}

.test-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
