/* Two colours, square corners, system type. Light by default, dark on request. */
:root {
  --bg: #ffffff;
  --fg: #000000;
  --dim: #8a8a8a;
  --faint: #e6e6e6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #000000; --fg: #ffffff; --dim: #8a8a8a; --faint: #262626; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #000000; --fg: #ffffff; --dim: #8a8a8a; --faint: #262626; color-scheme: dark; }

* { box-sizing: border-box; border-radius: 0 !important; }
html { scroll-padding-top: 56px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.65 "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
a { color: var(--fg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
hr { border: 0; border-top: 1px solid var(--fg); margin: 40px 0; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  padding: 8px 20px; background: var(--bg); border-bottom: 2px solid var(--fg);
}
.word { font-weight: 700; font-size: 20px; text-decoration: none; letter-spacing: .02em; }
.bar nav { display: flex; gap: 16px; margin-right: auto; overflow-x: auto; }
.bar nav a { white-space: nowrap; }

/* buttons: a box that inverts */
.btn {
  display: inline-block; padding: 4px 12px; border: 1px solid var(--fg);
  background: var(--bg); color: var(--fg); font: inherit; font-size: 15px;
  text-decoration: none; cursor: pointer;
}
.btn:hover, .btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
/* preview tint only while not hovered, so hover always shows solid inverted text */
.btn.peek:not(:hover) { background: var(--faint); color: var(--fg); }

main { max-width: 1000px; margin: 0 auto; padding: 0 20px; }
.intro { padding: 48px 0 28px; }
h1 { font-size: 56px; line-height: 1; margin: 0 0 12px; font-weight: 700; letter-spacing: -.03em; }
.intro p { margin: 0 0 18px; font-size: 17px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
h2 { font-size: 24px; margin: 0; font-weight: 700; letter-spacing: -.02em; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.sub, .small, .meta { color: var(--dim); }
.small { font-size: 14px; margin: 10px 0 0; max-width: 72ch; }

/* the chart */
.chart { border: 1px solid var(--fg); padding: 10px 12px; font-size: 14px; }
.row {
  display: grid; grid-template-columns: 2.2em minmax(110px, 220px) 1fr 6.5em; gap: 10px;
  align-items: center; height: 26px; transition: transform .35s ease, opacity .2s;
}
.row .rk { color: var(--dim); text-align: right; }
.row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.track { position: relative; height: 14px; border: 1px solid var(--fg); }
.fill { position: absolute; inset: 0 auto 0 0; background: var(--fg); transition: width .35s ease; }
.mark { position: absolute; top: -5px; bottom: -5px; width: 0; border-left: 2px dashed var(--fg); }
.row .val { text-align: right; }
.row.none { opacity: .35; }
.row.none .track { border-style: dotted; }

/* categories under the chart */
.cats, .subs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.subs:empty { display: none; }
.subs { padding-left: 14px; border-left: 2px solid var(--fg); }
.subs .btn { font-size: 14px; padding: 2px 10px; }

/* results grid */
.scroll { overflow-x: auto; border: 1px solid var(--fg); }
.grid { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.grid th, .grid td { border: 1px solid var(--faint); padding: 0; }
.grid thead th { height: 150px; vertical-align: bottom; background: var(--bg); position: relative; }
.grid .rowhead { position: sticky; left: 0; background: var(--bg); text-align: left; padding: 0 10px; white-space: nowrap; font-size: 14px; font-weight: 500; border-right: 1px solid var(--fg); z-index: 1; }
.grid thead .rowhead { z-index: 300; vertical-align: bottom; padding-bottom: 8px; color: var(--dim); }
.colbtn { all: unset; cursor: pointer; display: block; width: 50px; height: 146px; position: relative; }
.colbtn span { position: absolute; left: 20px; bottom: 8px; transform: rotate(-60deg); transform-origin: left bottom; white-space: nowrap; font-size: 12.5px; }
.colbtn:hover span, .colbtn[aria-pressed="true"] span { text-decoration: underline; }
.cell {
  width: 50px; height: 28px; text-align: center; font-size: 12.5px;
  background: var(--heat, var(--bg)); color: #000; transition: opacity .15s;
}
/* viridis: the dark end needs white text, whatever the page theme */
.cell.inv { color: #fff; }
.cell.best { font-weight: 700; text-decoration: underline; }
.cell.empty { background: var(--bg); color: var(--dim); }
/* outside the selection: lighter, never gone; titles stay readable */
.grid td.off { filter: grayscale(1); opacity: .55; }
/* on black, fading toward the background turns colour to mud; grey it out at full brightness instead */
:root[data-theme="dark"] .grid td.off { opacity: .8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .grid td.off { opacity: .8; } }
.grid th.on .colbtn span { font-weight: 700; }

/* explorer */
select { font-size: 14px; padding: 4px 8px; border: 1px solid var(--fg); background: var(--bg); color: var(--fg); max-width: 80vw; }
.meta { margin: 0 0 10px; font-size: 15px; }
.meta a { color: var(--dim); }
.steps { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.steps .btn { min-width: 2.2em; text-align: center; padding: 2px 6px; font-size: 14px; }
.example { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; }
.panel { border: 1px solid var(--fg); padding: 14px 16px; min-width: 0; }
.panel h3 { font-size: 15px; margin: 0 0 10px; font-weight: 400; color: var(--dim); }
.q { font-size: 16px; font-weight: 500; margin: 0 0 12px; }
.kv .k { font-size: 13px; color: var(--dim); margin-top: 8px; }
.kv .v { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; font-size: 14px; }
.veil { position: relative; }
.veil.hidden .v { filter: blur(6px); user-select: none; pointer-events: none; }
.veil .btn { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); z-index: 1; }
.veil:not(.hidden) .btn { display: none; }
.opts { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; }
.opts li { display: grid; grid-template-columns: 1.8em 1fr; gap: 6px; padding: 5px 8px; border: 1px solid var(--faint); font-size: 15px; overflow-wrap: anywhere; }
.opts li.gold { border: 2px solid var(--fg); }
.opts li.gold::after { content: "correct"; grid-column: 2; font-size: 12px; color: var(--dim); }
.withheld { color: var(--dim); font-style: italic; }
img.ex { max-width: 100%; max-height: 300px; border: 1px solid var(--fg); margin-bottom: 10px; }
.answers { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 4.5em; gap: 6px 10px; align-items: center; font-size: 14px; }
.answers .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* a wrong answer is hatched, so the distinction needs no colour */
.fill.wrong { background: repeating-linear-gradient(45deg, var(--fg) 0 2px, transparent 2px 5px); }
.half { position: absolute; left: 50%; top: -4px; bottom: -4px; border-left: 1px solid var(--dim); }
.docs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 540px; overflow: auto; }
.docs li { display: grid; grid-template-columns: 3.2em 1fr 3.4em; gap: 8px; padding: 6px 8px; border: 1px solid var(--faint); font-size: 15px; }
.docs li.rel { border: 2px solid var(--fg); }
.docs .t { font-weight: 700; }
.docs .s { color: var(--dim); font-size: 14px; }
.docs .g, .docs .sc { font-size: 13px; }
.docs .sc { text-align: right; }

.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 14px; }
.box { display: flex; flex-direction: column; gap: 4px; padding: 18px; border: 2px solid var(--fg); text-decoration: none; }
.box b { font-size: 18px; }
.box span { color: var(--dim); }
.box:hover { background: var(--fg); color: var(--bg); }
.box:hover span { color: var(--bg); }
pre { margin: 0; padding: 14px; border: 1px solid var(--fg); overflow-x: auto; font-size: 13px; line-height: 1.6; }
.foot { max-width: 1000px; margin: 40px auto 0; padding: 16px 20px 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; border-top: 2px solid var(--fg); color: var(--dim); font-size: 14px; }

.tip { position: fixed; z-index: 2000; pointer-events: none; max-width: 280px; background: var(--fg); color: var(--bg); padding: 7px 10px; font-size: 13px; line-height: 1.5; }

@media (max-width: 760px) {
  h1 { font-size: 44px; }
  .row { grid-template-columns: 1.6em minmax(80px, 130px) 1fr 5em; }
  .example { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .row, .fill, .cell { transition: none; }
}

/* dataset cards: pick one to explore; the number is the average across models */
.extremes { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0 0 14px; font-size: 14px; }
.link { all: unset; cursor: pointer; text-decoration: underline; }
.link:focus-visible { outline: 2px solid var(--fg); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 8px; }
.card {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px; border: 1px solid var(--fg); background: var(--bg); color: var(--fg); min-height: 128px;
}
.card:hover { box-shadow: inset 0 0 0 1px var(--fg); }
.card:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.card[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.card .cat, .card .foot2 { font-size: 12px; color: var(--dim); }
.card[aria-pressed="true"] .cat, .card[aria-pressed="true"] .foot2 { color: var(--bg); opacity: .75; }
.card .name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.card .avg { font-size: 26px; font-weight: 700; margin-top: auto; letter-spacing: -.02em; }
.range { position: relative; height: 8px; border: 1px solid currentColor; margin: 2px 0 4px; }
.range .span { position: absolute; top: 0; bottom: 0; background: currentColor; opacity: .35; }
.range .mean { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: currentColor; }
.ds-head { margin-top: 28px; border-top: 1px solid var(--fg); padding-top: 14px; }
.ds-head h3 { margin: 0 0 4px; font-size: 20px; }

/* model panel: opens from the right, closes on Esc, outside click or Close */
.backdrop { position: fixed; inset: 0; z-index: 1400; background: rgba(0, 0, 0, .45); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 1500; width: min(440px, 100vw);
  overflow-y: auto; background: var(--bg); color: var(--fg); border-left: 3px solid var(--fg); padding: 18px 20px 28px;
}
.drawer[hidden], .backdrop[hidden] { display: none; }
body.locked { overflow: hidden; }
.drawer-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.drawer h2 { font-size: 22px; }
.drawer h3 { font-size: 14px; margin: 18px 0 6px; color: var(--dim); font-weight: 500; }
.drawer .links { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.drawer .slug { display: flex; align-items: center; gap: 8px; margin: 8px 0 16px; }
.drawer code { border: 1px solid var(--fg); padding: 3px 8px; font-size: 13px; }
.drawer .big { margin: 6px 0 12px; }
.drawer .big > span:first-child { font-size: 40px; font-weight: 700; letter-spacing: -.02em; }
.drawer .answers { grid-template-columns: 7.5em 1fr 3.5em; }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 14px; }
.row button.nm { text-align: left; cursor: pointer; }
.row button.nm:hover, .grid .rowhead .link:hover { text-decoration: underline; }
.grid .rowhead .link { text-decoration: none; }
.steps .pos { align-self: center; margin-left: 8px; font-size: 13px; color: var(--dim); }
/* GitHub's mark (Primer Octicons mark-github), coloured with the text so it inverts on hover */
.btn .ico { width: 15px; height: 15px; fill: currentColor; vertical-align: -2px; margin-right: 7px; }
