:root {
  --paper: #F7F8FB;
  --sheet: #FFFFFF;
  --ink: #1C2B6E;
  --ink-soft: #4A5895;
  --text: #1A1F2E;
  --muted: #5F6779;
  --grid: #DCE1EC;
  --grid-soft: #ECEFF5;
  --ok: #1E7F55;
  --warn: #B26B00;
  --bad: #B42318;
  /* criterion colours: one hue family per phase */
  --c-functionality: #1C2B6E;
  --c-code: #3D57B8;
  --c-ux: #7E93E0;
  --c-impact: #0F6E6E;
  --c-integration: #2BA39B;
  --c-pitch: #8FD3C9;
  --radius-s: 4px;
  --radius-m: 8px;
  font-family: 'Schibsted Grotesk', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; font-size: 15px; line-height: 1.5; }
a { color: var(--ink); }
button {
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  border-radius: var(--radius-s); padding: 6px 12px;
}
button:hover { background: #142057; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--grid); }
button.ghost:hover { border-color: var(--ink); background: var(--sheet); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button:disabled { opacity: .5; cursor: progress; }
button.sm { padding: 3px 9px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--ink-soft); outline-offset: 2px; }
input, textarea, select { font: inherit; color: inherit; border: 1px solid var(--grid); border-radius: var(--radius-s); padding: 6px 8px; background: var(--sheet); }
textarea { width: 100%; min-height: 110px; resize: vertical; }

/* ---------- sidebar ---------- */
#side { position: sticky; top: 0; height: 100vh; overflow: auto; background: var(--sheet); border-right: 1px solid var(--grid); padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--text); }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--ink); color: #fff; font-weight: 800; border-radius: var(--radius-m); letter-spacing: -.02em; }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; }
.mainnav { display: grid; gap: 2px; }
.mainnav a, #teamnav a { text-decoration: none; color: var(--text); padding: 6px 8px; border-radius: var(--radius-s); display: flex; gap: 8px; align-items: center; }
.mainnav a:hover, #teamnav a:hover { background: var(--grid-soft); }
.mainnav a.active, #teamnav a.active { background: var(--ink); color: #fff; }
.side-head { color: var(--muted); font-size: 13px; font-weight: 600; padding: 0 8px; }
#teamnav { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; flex: 1; align-content: start; }
#teamnav .num { width: 20px; color: var(--muted); font-size: 12px; }
#teamnav a.active .num { color: #c9d1f5; }
#teamnav .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot { display: grid; gap: 6px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grid); flex: none; }
.dot.up { background: var(--ok); box-shadow: 0 0 0 3px #1e7f5522; }
.dot.busy { background: var(--warn); animation: pulse 1s infinite; }
.dot.err { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot.busy { animation: none; } }

/* ---------- main ---------- */
main { padding: 28px 36px 80px; min-width: 0; }
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 19px; margin: 34px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 18px 0 6px; }
.lede { color: var(--muted); max-width: 72ch; margin: 0 0 20px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0 18px; }
.seg { display: inline-flex; border: 1px solid var(--grid); border-radius: var(--radius-s); overflow: hidden; background: var(--sheet); }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--ink); color: #fff; }
.spacer { flex: 1; }

/* leaderboard */
.board { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--grid); border-radius: var(--radius-m); overflow: hidden; }
.board th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--grid); background: var(--paper); white-space: nowrap; }
.board td { padding: 12px; border-bottom: 1px solid var(--grid-soft); vertical-align: middle; }
.board tr:last-child td { border-bottom: 0; }
.board tr.row:hover td { background: #FAFBFF; }
.rank { font-size: 22px; font-weight: 800; color: var(--ink); width: 44px; }
.team-cell a { font-weight: 700; text-decoration: none; font-size: 15.5px; }
.team-cell small { display: block; color: var(--muted); font-size: 12.5px; max-width: 46ch; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--grid); color: var(--ink-soft); background: var(--sheet); white-space: nowrap; }
.chip.ok { border-color: #1e7f5555; color: var(--ok); }
.chip.warn { border-color: #b26b0055; color: var(--warn); }
.chip.bad { border-color: #b4231855; color: var(--bad); }
.total { font-size: 22px; font-weight: 800; text-align: right; white-space: nowrap; }
.total small { font-size: 12px; color: var(--muted); font-weight: 500; }
.run-cell { white-space: nowrap; }
.run-cell .btns { display: flex; gap: 4px; align-items: center; }

/* the score ruler: one segment per criterion, width = max points, fill = earned */
.ruler { display: flex; height: 18px; width: 100%; min-width: 260px; gap: 2px; }
.ruler .seg-c { position: relative; background: var(--grid-soft); border-radius: 2px; overflow: hidden; }
.ruler .seg-c i { position: absolute; inset: 0 auto 0 0; display: block; }
.ruler .seg-c.na { background: repeating-linear-gradient(135deg, var(--grid-soft) 0 4px, #fff 4px 8px); }
.ruler-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.ruler-legend span { display: inline-flex; gap: 6px; align-items: center; }
.ruler-legend b { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* team page */
.team-head { display: flex; gap: 24px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.team-head .meta { color: var(--muted); font-size: 14px; display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.scorebox { background: var(--sheet); border: 1px solid var(--grid); border-radius: var(--radius-m); padding: 14px 16px; min-width: 300px; }
.scorebox .big { font-size: 40px; font-weight: 800; color: var(--ink); line-height: 1; }
.scorebox .big small { font-size: 15px; color: var(--muted); font-weight: 500; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--grid); margin: 22px 0 0; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--ink); }
.panel { padding-top: 6px; }
.prose { max-width: 82ch; }
.prose p { margin: 0 0 10px; }
.prose code, code { background: var(--grid-soft); padding: 1px 5px; border-radius: 3px; font-size: .92em; font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.prose ul { padding-left: 20px; margin: 4px 0 10px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.box { background: var(--sheet); border: 1px solid var(--grid); border-radius: var(--radius-m); padding: 14px 18px; }
.box h3:first-child { margin-top: 0; }
ul.clean { padding-left: 18px; margin: 0; }
ul.clean li { margin: 4px 0; }
ul.flags li::marker { color: var(--bad); }
ul.plus li::marker { color: var(--ok); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* scoring table on team page */
.crit { display: grid; grid-template-columns: 170px 110px 120px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--grid-soft); align-items: start; }
.crit .name b { display: block; }
.crit .name small { color: var(--muted); }
.crit .ai { font-size: 20px; font-weight: 800; }
.crit .ai small { font-size: 12px; color: var(--muted); font-weight: 500; }
.crit input { width: 70px; font-weight: 700; font-size: 16px; }
.crit .phase { font-size: 12px; color: var(--muted); }
.stars { color: var(--ink); letter-spacing: 2px; white-space: nowrap; }

/* run panel */
.svc { display: grid; grid-template-columns: 22px 140px 90px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--grid-soft); }
pre.log { background: #0E1430; color: #D6DCF5; padding: 12px 14px; border-radius: var(--radius-m); max-height: 460px; overflow: auto; font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-all; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.shots img { width: 100%; border: 1px solid var(--grid); border-radius: var(--radius-m); background: #fff; cursor: zoom-in; }
ol.steps { padding-left: 22px; }
ol.steps li { margin: 6px 0; }
.qa li { margin: 8px 0; }
.empty { padding: 30px; text-align: center; color: var(--muted); background: var(--sheet); border: 1px dashed var(--grid); border-radius: var(--radius-m); }

/* compare heatmap */
.heat { border-collapse: collapse; background: var(--sheet); }
.heat th, .heat td { border: 1px solid var(--grid-soft); padding: 8px 10px; text-align: center; font-size: 13.5px; }
.heat th { color: var(--muted); font-weight: 600; background: var(--paper); }
.heat td.n { text-align: left; font-weight: 600; white-space: nowrap; }
.heat td.v { font-weight: 700; min-width: 64px; }

/* timer */
#timer { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: #fff; padding: 16px 20px; border-radius: 12px; box-shadow: 0 10px 40px #1c2b6e55; z-index: 20; min-width: 280px; }
.timer-phase { font-size: 13px; opacity: .8; }
.timer-clock { font-size: 64px; font-weight: 800; line-height: 1.05; letter-spacing: -.03em; }
#timer.late .timer-clock { color: #FFB4A8; }
.timer-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#timer button { background: #fff; color: var(--ink); border-color: #fff; }
#timer button.ghost { background: transparent; color: #fff; border-color: #ffffff55; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--text); color: #fff; padding: 8px 16px; border-radius: var(--radius-s); opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 30; }
#toast.show { opacity: 1; }
.lightbox { position: fixed; inset: 0; background: #0e1430e0; display: grid; place-items: center; z-index: 40; cursor: zoom-out; padding: 30px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-m); }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  #side { position: static; height: auto; }
  main { padding: 20px 16px 60px; }
  .crit { grid-template-columns: 1fr 1fr; }
  .svc { grid-template-columns: 22px 1fr auto; }
  .board .hide-sm { display: none; }
}

.rank, .total, .big, .ai, .heat td, .timer-clock, .crit input, .kv dd { font-variant-numeric: tabular-nums; }
.team-cell { min-width: 260px; max-width: 380px; }
.team-cell small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.board .chips { max-width: 230px; }
#teamnav li { min-width: 0; overflow: hidden; }
#teamnav a { min-width: 0; }
#side { overflow-x: hidden; }

/* public read-only build */
html.public a[href="#/settings"], html.public #stopAll { display: none; }
