/* modeltierlist.ai — the one stylesheet. Owner: designer. Direction: design/DIRECTION.md.
   Register: thermal scoreboard. A deep violet-black ground, six tier blocks that cool from white-hot S to ash F,
   pastel maker tickets in dark ink. Fonts are self-hosted OFL files under /fonts. */

@font-face {
  font-family: "Unbounded";
  src: url("/fonts/unbounded-latin-wght.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque-latin-standard.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("/fonts/martian-mono-latin-standard.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Ground: violet-black in four elevations. */
  --ground-0: #070514;
  --ground: #0e0a1f;
  --panel: #17132b;
  --panel-2: #201c36;
  --line: #322e4b;
  --paper: #f1f1fa;
  --paper-dim: #b7b5ca;
  --paper-faint: #918eaa;
  --ink: #100b21;

  /* Tier scale (Daniel, 12:00): S stands alone, a bright green; A is a muted green, plainly quieter; then one ordered
     scale cools from sage through olive, ochre and rust to brick-red F, lightness falling every step
     (OKLCH L .87 | .78 .735 .69 .645 .60, hue 145 | 150 110 82 55 26). */
  --tier-s: #58fa6a;
  --tier-a: #90c79b;
  --tier-b: #adaf62;
  --tier-c: #c09337;
  --tier-d: #cd732b;
  --tier-f: #d04f49;
  --tier-s-glow: rgb(88 250 106 / 0.42);

  /* Errors and destructive actions: a red of their own, never a tier token (6:1 on --panel). */
  --danger: #ff6b5e;

  /* Maker tickets: one pastel per maker (OKLCH L .84, a deeper second ring at L .74-.77), text always --label-ink.
   Slugs match the backend seed: anthropic openai google meta xai moonshot alibaba zai deepseek xiaomi minimax baidu
   mistral nvidia tencent. Anything else gets --maker-unknown. */
  --label-ink: #100b21;
  --maker-anthropic: #d97757; /* Anthropic's own brand orange (Daniel, on the record). */
  --maker-mistral: #ebc38c;
  --maker-zai: #cbd190;
  --maker-nvidia: #abd9a6;
  --maker-openai: #8fddc4;
  --maker-deepseek: #84dbe5;
  --maker-google: #97d3fd;
  --maker-meta: #b3c9ff;
  --maker-moonshot: #d3befa;
  --maker-alibaba: #eeb6e1;
  --maker-xai: #ced9e5;
  /* Second ring, a step deeper (OKLCH L .74-.77) so they stay apart from their first-ring neighbours. */
  --maker-xiaomi: #eda063;
  --maker-minimax: #d493d8;
  --maker-baidu: #85abf0;
  --maker-tencent: #56c2ba;
  --maker-unknown: #bdb6b0;

  --display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --body: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius-board: 20px;
  --radius-label: 10px;
  --rail: 136px;
  --pad: clamp(16px, 3vw, 40px);
  --ease-lift: cubic-bezier(0.2, 0.9, 0.25, 1.15);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { background: var(--ground); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 6% -10%, rgb(88 250 106 / 0.10), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgb(137 97 180 / 0.14), transparent 65%),
    var(--ground);
  color: var(--paper);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--tier-s); outline-offset: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.app {
  max-width: 1720px;
  margin: 0 auto;
  padding: 0 var(--pad) var(--pad);
}

/* ── Masthead: brand and actions on one bar, the headline under it ─────────── */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 0;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}
.brand-mark { width: 34px; height: 34px; flex: none; border-radius: 9px; display: block; }
.brand-word {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-word span { color: var(--paper-faint); font-weight: 400; }

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out);
}
.btn:hover { background: var(--panel-2); border-color: #4a4568; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary {
  background: var(--tier-s);
  border-color: var(--tier-s);
  color: var(--ink);
  font-weight: 700;
}
.btn-primary:hover { background: #fff0a0; border-color: #fff0a0; }
.btn-key {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--paper-faint);
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper-dim);
}
.save-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--paper-faint);
  flex: none;
}
.save-state[data-save-state="saving"] .save-dot { background: var(--tier-a); animation: pulse 900ms ease-in-out infinite; }
.save-state[data-save-state="saved"] .save-dot { background: var(--maker-nvidia); }
.save-state[data-save-state="error"] { color: var(--danger); }
.save-state[data-save-state="error"] .save-dot { background: var(--danger); }

@keyframes pulse { 50% { opacity: 0.35; } }

.headline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 24px 40px;
  padding: 36px 0 28px;
}
.headline h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(30px, 4.2vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
  overflow-wrap: break-word;
}
.headline h1 em {
  font-style: normal;
  background: linear-gradient(90deg, var(--tier-s), var(--tier-b) 45%, var(--tier-d) 80%, var(--tier-f));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.headline-sub {
  margin: 12px 0 0;
  font-size: 17px;
  color: var(--paper-dim);
}
.headline-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  text-align: right;
}
.updated {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper-faint);
  letter-spacing: 0.02em;
}
.updated time { color: var(--paper); }

/* Maker legend: a key, never the only carrier (the maker is printed on every label). */
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: 560px;
}
.legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--paper-dim);
}
/* A known maker's key is its mark on a tile of its colour (a mini label); an unknown maker keeps a plain square. */
.legend li::before {
  content: "";
  width: 12px; height: 12px; border-radius: 3px;
  background: var(--maker);
}
.legend li:has(> img[data-model-logo])::before { display: none; }
.legend img[data-model-logo] {
  display: block;
  width: 18px;
  height: 18px;
  padding: 3px;
  border-radius: 5px;
  background: var(--maker);
  pointer-events: none;
}

/* ── Maker colours, keyed by data-maker (fallback is the unknown stone) ────── */

[data-maker] { --maker: var(--maker-unknown); }
[data-maker="anthropic"] { --maker: var(--maker-anthropic); }
[data-maker="openai"] { --maker: var(--maker-openai); }
[data-maker="google"] { --maker: var(--maker-google); }
[data-maker="xai"] { --maker: var(--maker-xai); }
[data-maker="meta"] { --maker: var(--maker-meta); }
[data-maker="moonshot"] { --maker: var(--maker-moonshot); }
[data-maker="alibaba"] { --maker: var(--maker-alibaba); }
[data-maker="deepseek"] { --maker: var(--maker-deepseek); }
[data-maker="zai"] { --maker: var(--maker-zai); }
[data-maker="nvidia"] { --maker: var(--maker-nvidia); }
[data-maker="mistral"] { --maker: var(--maker-mistral); }
[data-maker="xiaomi"] { --maker: var(--maker-xiaomi); }
[data-maker="minimax"] { --maker: var(--maker-minimax); }
[data-maker="baidu"] { --maker: var(--maker-baidu); }
[data-maker="tencent"] { --maker: var(--maker-tencent); }

/* ── The board ─────────────────────────────────────────────────────────────── */

.workspace { display: block; }
.workspace.is-owner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 336px);
  gap: 20px;
  align-items: stretch;
}
/* Signed in, the board is narrower: its names take a slightly narrower cut so a lane of four keeps names on one line. */
.workspace.is-owner .board .label-name { font-stretch: 88%; }
/* The tray takes the board's height and scrolls inside, so neither column leaves dead space beside the other. */
.workspace.is-owner > .tray { contain: size; }

.board {
  display: grid;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-board);
  background: var(--ground-0);
  box-shadow: 0 0 0 1px var(--line), 0 40px 80px -30px rgb(0 0 0 / 0.7);
  min-width: 0;
}

[data-tier="S"] { --tier: var(--tier-s); }
[data-tier="A"] { --tier: var(--tier-a); }
[data-tier="B"] { --tier: var(--tier-b); }
[data-tier="C"] { --tier: var(--tier-c); }
[data-tier="D"] { --tier: var(--tier-d); }
[data-tier="F"] { --tier: var(--tier-f); }

.tier {
  position: relative;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 84px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
}
.tier:first-child { border-top-left-radius: 17px; border-top-right-radius: 17px; }
.tier:last-child { border-bottom-left-radius: 17px; border-bottom-right-radius: 17px; }

.tier-letter {
  position: relative;
  display: grid;
  place-items: center;
  margin: 0;
  background:
    radial-gradient(120% 90% at 18% 8%, rgb(255 255 255 / 0.34), rgb(255 255 255 / 0) 55%),
    linear-gradient(160deg, var(--tier) 30%, color-mix(in oklab, var(--tier) 84%, black) 100%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.16), inset -1px 0 0 rgb(0 0 0 / 0.28), inset 0 1px 0 rgb(255 255 255 / 0.38);
  isolation: isolate;
  overflow: hidden;
  color: rgb(7 5 20 / 0.9);
  font-family: var(--display);
  font-weight: 900;
  font-size: 48px;
  line-height: 1;
  letter-spacing: -0.05em;
  /* Engraved: the cut letter catches light on its lower edge and shade on its upper one. */
  text-shadow: 0 2px 0 rgb(255 255 255 / 0.42), 0 -1px 0 rgb(0 0 0 / 0.22);
  transition: box-shadow 200ms var(--ease-out), filter 200ms var(--ease-out);
}
.tier-letter abbr { text-decoration: none; cursor: inherit; }

/* The lane is a grid whose columns share its width: a row of three spans the lane instead of stopping at 40%. */
.tier-items {
  /* A wrapping flex row, centred: cards grow from one basis to share their row, capped at a max width, so a lane is
     either full edge to edge or its cards sit centred with equal space both sides (ISC-54), for any count of labels.
     Three cards fill a 1440 public lane; one or two sit centred at the max, never as long bars. */
  --card-basis: 200px;
  --card-max: 400px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 16px 18px;
  list-style: none;
  background: linear-gradient(90deg, color-mix(in oklab, var(--tier) 15%, var(--panel)) 0%, var(--panel) 42%);
  transition: background-color 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
  counter-reset: tier-count;
}
/* Labels and the landing gap share one basis, so the neighbours part around the gap like around a card. */
.tier-items > .label,
.tier-items > .drop-gap {
  flex: 1 1 var(--card-basis);
  max-width: var(--card-max);
  min-width: 0;
}
.tier-items > .label { counter-increment: tier-count; }
/* Scoreboard count at the row's far end: how many models sit in this tier. */
/* The tier's total, lifted out of the lane onto the letter tile's top-right corner (counted after the labels). */
.tier-items::after {
  content: counter(tier-count);
  position: absolute;
  top: 9px;
  left: calc(var(--rail) - 36px);
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.4);
  color: var(--ground-0);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
}

/* The row under a dragged label lights up. */
.tier[data-drop-target] .tier-items {
  background: linear-gradient(90deg, color-mix(in oklab, var(--tier) 30%, var(--panel)) 0%, color-mix(in oklab, var(--tier) 12%, var(--panel)) 100%);
  box-shadow: inset 0 0 0 2px var(--tier);
}
.tier[data-drop-target] .tier-letter {
  filter: brightness(1.08) saturate(1.1);
  box-shadow: inset -2px 0 0 rgb(255 255 255 / 0.5), 0 0 48px 4px color-mix(in oklab, var(--tier) 55%, transparent);
}

/* S stands apart: a taller row, a bigger letter, a lit green ring and glow, bigger tickets. */
.tier[data-tier="S"] {
  position: relative;
  z-index: 1;
  min-height: 152px;
  box-shadow: 0 0 0 2px var(--tier-s), 0 0 44px -6px var(--tier-s-glow);
}
.tier[data-tier="S"] .tier-letter {
  font-size: 104px;
  padding-top: 22px;
  text-shadow: 0 2px 0 rgb(255 255 255 / 0.55), 0 0 30px rgb(255 255 255 / 0.4);
}
/* The S crown, cut in the letter's ink. */
.tier[data-tier="S"] .tier-letter::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 50%;
  width: 40px;
  height: 25px;
  translate: -50% 0;
  background: url("/brand/crown.svg") center / contain no-repeat;
  opacity: 0.9;
}

/* A scoreboard, not a form: rows and letters step down from S to F. */
.tier[data-tier="A"] { min-height: 124px; }
.tier[data-tier="A"] .tier-letter { font-size: 80px; }
.tier[data-tier="B"] { min-height: 112px; }
.tier[data-tier="B"] .tier-letter { font-size: 70px; }
.tier[data-tier="C"] { min-height: 102px; }
.tier[data-tier="C"] .tier-letter { font-size: 62px; }
.tier[data-tier="D"] { min-height: 94px; }
.tier[data-tier="D"] .tier-letter { font-size: 56px; }
.tier[data-tier="F"] { min-height: 86px; }
.tier[data-tier="F"] .tier-letter { font-size: 50px; }


.tier[data-tier="S"] .tier-items {
  --card-basis: 260px;
  --card-max: 520px;
  background: linear-gradient(90deg, color-mix(in oklab, var(--tier-s) 24%, var(--panel)) 0%, color-mix(in oklab, var(--tier-s) 6%, var(--panel)) 70%);
  gap: 12px;
  padding: 22px 22px;
}
/* Rank shows in the cards themselves: A is a step bigger and lit, then each tier a little smaller, D and F dimmed
   toward black (ink stays at 4.5:1 or better on every maker colour at the F dimming). */
.tier[data-tier="A"] .label { min-height: 58px; --card-sheen: 0.38; box-shadow: 0 1px 0 rgb(255 255 255 / 0.55) inset, 0 -2px 0 rgb(16 11 33 / 0.14) inset, 0 0 22px -8px color-mix(in oklab, var(--maker) 80%, transparent), 0 6px 14px -8px rgb(0 0 0 / 0.7); }
.tier[data-tier="A"] .label-name { font-size: 16px; }
.tier[data-tier="B"] .label { min-height: 54px; }
.tier[data-tier="C"] .label { min-height: 52px; --card-sheen: 0.24; }
.tier[data-tier="C"] .label-name { font-size: 14.5px; }
.tier[data-tier="D"] .label { min-height: 50px; --card-sheen: 0.18; --card-bg: color-mix(in oklab, var(--maker) 96%, black); }
.tier[data-tier="D"] .label-name { font-size: 14px; }
.tier[data-tier="F"] .label { min-height: 48px; --card-sheen: 0.12; --card-bg: color-mix(in oklab, var(--maker) 91%, black); }
.tier[data-tier="F"] .label-name { font-size: 13.5px; }

/* S cards are the hero: taller, larger type, a bigger mark. */
.tier[data-tier="S"] .label { min-height: 76px; padding: 12px 18px 12px 16px; column-gap: 12px; }
.tier[data-tier="S"] .label:has(> img[data-model-logo]) { grid-template-columns: 24px minmax(0, 1fr); }
.tier[data-tier="S"] .label img[data-model-logo] { width: 24px; height: 24px; }
.tier[data-tier="S"] .label-maker { font-size: 10.5px; }
.tier[data-tier="S"] .label-name { font-size: 20px; }

.board-empty {
  margin: 20px 0 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--paper-dim);
}

/* ── Labels: maker-coloured tickets in dark ink ────────────────────────────── */

.label {
  position: relative;
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  align-items: center;
  column-gap: 9px;
  row-gap: 3px;
  min-height: 52px;
  max-width: 100%;
  padding: 8px 14px 8px 13px;
  border-radius: var(--radius-label);
  background:
    linear-gradient(180deg, rgb(255 255 255 / var(--card-sheen, 0.28)), rgb(255 255 255 / 0) 60%),
    var(--card-bg, var(--maker));
  color: var(--label-ink);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.5) inset, 0 -2px 0 rgb(16 11 33 / 0.14) inset, 0 6px 14px -8px rgb(0 0 0 / 0.7);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: rotate 180ms var(--ease-lift), scale 180ms var(--ease-lift), box-shadow 180ms var(--ease-out), opacity 180ms var(--ease-out);
}
/* Maker mark: small, ink-coloured, to the left of the name and maker. Unknown makers have no img. */
.label:has(> img[data-model-logo]) { grid-template-columns: 18px minmax(0, 1fr); }
.label img[data-model-logo] {
  grid-row: 1 / span 2;
  grid-column: 1;
  width: 18px;
  height: 18px;
  opacity: 0.85;
  display: block;
  /* The mark is part of the label: a press on it starts the label's drag, never the browser's image drag. */
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
.label-name,
.label-maker { grid-column: -2 / -1; }
.label-name {
  font-family: var(--body);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  /* One unbroken 80-character name wraps inside its card; ordinary names still break at spaces first. */
  overflow-wrap: anywhere;
}
.label-maker {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 9.5px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.label:focus-visible { outline: 3px solid var(--paper); outline-offset: 2px; }

/* Owner affordances: grab cursor, touch drags never scroll, hover lift. */
.is-owner .label { cursor: grab; touch-action: manipulation; }
.is-owner .label:hover { scale: 1.03; box-shadow: 0 1px 0 rgb(255 255 255 / 0.5) inset, 0 -2px 0 rgb(16 11 33 / 0.14) inset, 0 12px 22px -10px rgb(0 0 0 / 0.8); }

.label-actions {
  position: absolute;
  top: -9px;
  right: -9px;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms var(--ease-out);
}
.label:hover .label-actions,
.label:focus-within .label-actions { opacity: 1; pointer-events: auto; }
.label-act {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--paper);
  cursor: pointer;
}
.label-act svg { width: 12px; height: 12px; }
.label-act:hover { background: var(--paper); color: var(--ink); }
.label-act[data-action="delete"]:hover { background: var(--danger); color: var(--ink); }

/* While dragging: the label in hand lifts and tilts. Position comes from the script's transform. */
.label[data-dragging] {
  z-index: 1000;
  cursor: grabbing;
  rotate: -3deg;
  scale: 1.08;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.6) inset, 0 0 0 2px rgb(255 255 255 / 0.85), 0 28px 44px -12px rgb(0 0 0 / 0.85), 0 10px 18px -6px rgb(0 0 0 / 0.6);
  pointer-events: none;
}
html[data-drag-active],
html[data-drag-active] * { cursor: grabbing; }
html[data-drag-active] .add-label { opacity: 0.45; }

/* The landing gap: neighbours part around a slot the size of a label. */
.drop-gap,
[data-drop-gap] {
  display: block;
  flex: none;
  width: var(--gap-width, 132px);
  height: 52px;
  border-radius: var(--radius-label);
  border: 2px dashed color-mix(in oklab, var(--tier, var(--paper)) 85%, white);
  background: color-mix(in oklab, var(--tier, var(--paper)) 16%, transparent);
  animation: gap-open 200ms var(--ease-out) backwards;
  list-style: none;
}
/* The gap fades in at its full size; the neighbours' parting is the script's FLIP, so nothing here moves layout. */
@keyframes gap-open {
  from { opacity: 0; scale: 0.9; }
}

/* ── Unranked tray (owner only) ────────────────────────────────────────────── */

.tray {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-board);
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line);
  overflow: hidden;
  min-width: 0;
}
.tray-head {
  display: grid;
  gap: 6px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.tray-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.tray-count {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  color: var(--paper-faint);
}
.tray-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--paper-dim);
}
.tray-hint kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--paper);
}
/* Header, then the add form, then the labels: the form sits right under the header, and the labels' area
   fills what is left as a visible drop zone (drag a label here to take it off the board). */
.tray > .tray-head { order: 0; }
.tray > .add-label { order: 1; }
.tray > .tray-items { order: 2; }

.tray-items {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 10px;
  min-height: 120px;
  margin: 14px;
  padding: 14px 14px 44px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  background: rgb(241 241 250 / 0.015);
  list-style: none;
  overflow-y: auto;
  flex: 1 1 auto;
  transition: background-color 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.tray-items::after {
  content: "Drop a label here to take it off the board";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--paper-faint);
  pointer-events: none;
}
.tray[data-drop-target] .tray-items {
  background: rgb(241 241 250 / 0.05);
  box-shadow: inset 0 0 0 2px var(--paper-faint);
}
.tray-empty {
  margin: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper-faint);
  text-align: center;
}

.add-label {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 8px;
  padding: 14px 18px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.add-label-title {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-faint);
}

.field {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--ground);
  color: var(--paper);
  font-size: 16px;
}
.field::placeholder { color: var(--paper-faint); }
.field:focus { outline: none; border-color: var(--tier-s); box-shadow: 0 0 0 3px rgb(255 232 90 / 0.18); }

/* Save failure notice: plain words, arrangement kept. */
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  background: color-mix(in oklab, var(--danger) 16%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--danger) 60%, transparent);
  color: var(--paper);
}
.notice[hidden] { display: none; }

/* ── Label editor dialog (rename, delete with confirm) ───────────────────── */

.label-editor {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--panel);
  color: var(--paper);
  box-shadow: 0 0 0 1px var(--line), 0 40px 80px -24px rgb(0 0 0 / 0.85);
  overflow: hidden;
}
.label-editor::backdrop { background: rgb(7 5 20 / 0.72); backdrop-filter: blur(4px); }
.editor-form { display: grid; gap: 14px; padding: 26px 24px 22px; }
.editor-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.editor-fields { display: grid; gap: 8px; }
.editor-fields label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-faint);
}
.editor-fields label + .field { margin-bottom: 6px; }
.editor-confirm { margin: 0; color: var(--paper-dim); }
.editor-confirm strong { color: var(--paper); }
.editor-error { margin: 0; font-size: 14px; color: var(--danger); }
.editor-error:empty { display: none; }
.editor-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.btn-primary[data-danger] { background: var(--danger); border-color: var(--danger); color: var(--ink); }
.btn-primary[data-danger]:hover { background: #ff8a80; border-color: #ff8a80; }

/* ── Tier picker (tap, click or Enter on a label): rank without dragging ──── */

[data-tier-tone="S"] { --tier: var(--tier-s); }
[data-tier-tone="A"] { --tier: var(--tier-a); }
[data-tier-tone="B"] { --tier: var(--tier-b); }
[data-tier-tone="C"] { --tier: var(--tier-c); }
[data-tier-tone="D"] { --tier: var(--tier-d); }
[data-tier-tone="F"] { --tier: var(--tier-f); }

/* Desktop: pops under the label it acts on (the script sets --anchor-x, the label's centre, and --anchor-y, its bottom). */
.tier-picker {
  position: fixed;
  inset: auto;
  left: clamp(12px, calc(var(--anchor-x, 50vw) - 170px), calc(100vw - 352px));
  top: min(calc(var(--anchor-y, 30vh) + 12px), calc(100vh - 260px));
  width: 340px;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--panel);
  color: var(--paper);
  box-shadow: 0 0 0 1px var(--line), 0 30px 60px -18px rgb(0 0 0 / 0.85);
  animation: picker-in 160ms var(--ease-out);
}
.tier-picker::backdrop { background: rgb(7 5 20 / 0.45); }
@keyframes picker-in {
  from { opacity: 0; translate: 0 -6px; }
}
@keyframes sheet-in {
  from { translate: 0 100%; }
}
.picker-form { display: grid; gap: 10px; padding: 16px; }
.picker-title {
  margin: 0 2px 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--paper-dim);
  overflow-wrap: anywhere;
}
.picker-tiers {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.pick {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 52px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background:
    linear-gradient(155deg, rgb(255 255 255 / 0.3), rgb(255 255 255 / 0) 55%),
    var(--tier, var(--panel-2));
  color: var(--ground-0);
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.04em;
  cursor: pointer;
  transition: filter 140ms var(--ease-out), translate 140ms var(--ease-out);
}
.pick:hover { filter: brightness(1.08); translate: 0 -2px; }
.pick:focus-visible { outline: 3px solid var(--paper); outline-offset: 2px; }
/* The tier the label sits in now: ringed and tagged. */
.pick[aria-current="true"] {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--paper);
}
.pick[aria-current="true"]::after {
  content: "now";
  position: absolute;
  bottom: 4px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pick-unranked {
  min-height: 44px;
  background: var(--panel-2);
  color: var(--paper);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 0 1px var(--line);
}
.pick-unranked[aria-current="true"] { box-shadow: inset 0 0 0 1px var(--line), 0 0 0 2px var(--panel), 0 0 0 4px var(--paper); }
.pick-unranked[aria-current="true"]::after { right: 12px; bottom: auto; }
.picker-cancel { width: 100%; }

/* ── Colophon ──────────────────────────────────────────────────────────────── */

/* What the list means: no card. A display pull line and the S-to-F rail on the left, Daniel's own words on the right. */
.meaning {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 34rem);
  align-items: center;
  gap: 32px clamp(40px, 5vw, 88px);
  margin-top: 48px;
  padding-bottom: 8px;
}
.meaning-head,
.meaning-body { min-width: 0; }

.meaning h2 {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-faint);
}

.meaning-pull {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(24px, 3vw, 44px);
  line-height: 1.06;
  letter-spacing: -0.035em;
  text-wrap: balance;
  overflow-wrap: break-word;
  color: var(--paper);
}
.meaning-pull em { font-style: normal; }
.meaning-pull .pole-usable { color: var(--tier-s); }
.meaning-pull .pole-unusable { color: var(--tier-f); }

.meaning-scale {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 16px;
  margin-top: 26px;
}
.meaning-keys {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}
.meaning-keys > span {
  display: grid;
  place-items: center;
  height: 34px;
  border-radius: 8px;
  background:
    radial-gradient(120% 90% at 18% 8%, rgb(255 255 255 / 0.34), rgb(255 255 255 / 0) 55%),
    linear-gradient(160deg, var(--tier) 30%, color-mix(in oklab, var(--tier) 84%, black) 100%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.16), inset 0 1px 0 rgb(255 255 255 / 0.38);
  color: rgb(7 5 20 / 0.9);
  font-family: var(--display);
  font-weight: 900;
  font-size: 15px;
  line-height: 1;
  letter-spacing: -0.05em;
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.42);
}
.meaning-keys > span:first-child { border-radius: 12px 8px 8px 12px; }
.meaning-keys > span:last-child { border-radius: 8px 12px 12px 8px; }
.meaning-keys > span:nth-child(1) { --tier: var(--tier-s); }
.meaning-keys > span:nth-child(2) { --tier: var(--tier-a); }
.meaning-keys > span:nth-child(3) { --tier: var(--tier-b); }
.meaning-keys > span:nth-child(4) { --tier: var(--tier-c); }
.meaning-keys > span:nth-child(5) { --tier: var(--tier-d); }
.meaning-keys > span:nth-child(6) { --tier: var(--tier-f); }

.meaning-pole {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
.meaning-pole + .meaning-pole { justify-self: end; }

.meaning-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.meaning-body p {
  margin: 0;
  font-size: 18px;
  line-height: 1.55;
  color: var(--paper-dim);
  text-wrap: pretty;
}
.meaning-body p:first-child { color: var(--paper); }

.colophon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--paper-faint);
}
.colophon p { margin: 0; }
.colophon a { color: var(--paper-dim); text-underline-offset: 3px; }
.tier-scale {
  display: inline-flex;
  gap: 3px;
  vertical-align: middle;
}
.tier-scale i {
  display: block;
  width: 18px; height: 6px; border-radius: 2px;
}
.tier-scale i:nth-child(1) { background: var(--tier-s); }
.tier-scale i:nth-child(2) { background: var(--tier-a); }
.tier-scale i:nth-child(3) { background: var(--tier-b); }
.tier-scale i:nth-child(4) { background: var(--tier-c); }
.tier-scale i:nth-child(5) { background: var(--tier-d); }
.tier-scale i:nth-child(6) { background: var(--tier-f); }

/* ── Sign-in page ──────────────────────────────────────────────────────────── */

.signin-page {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 72px);
  padding: 40px 0;
}
.signin-card {
  position: relative;
  width: min(460px, 100%);
  padding: 40px 36px 34px;
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line), 0 40px 80px -30px rgb(0 0 0 / 0.8);
  overflow: hidden;
}
.signin-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--tier-s) 0 16.66%, var(--tier-a) 0 33.33%, var(--tier-b) 0 50%, var(--tier-c) 0 66.66%, var(--tier-d) 0 83.33%, var(--tier-f) 0);
}
.signin-card h1 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 34px;
  letter-spacing: -0.035em;
}
.signin-card > p { margin: 0 0 26px; color: var(--paper-dim); }
/* One action: Sign in with Google. Google's dark-theme button (fill #131314, stroke #8E918F, text #E3E3E3) with the
   standard four-colour G, unaltered, at 20px. */
.google-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid #8e918f;
  background: #131314;
  color: #e3e3e3;
  font-family: var(--body);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.005em;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}
.google-signin:hover { background: #1e1e20; border-color: #c4c7c5; }
.google-signin:focus-visible { outline: 3px solid var(--tier-s); outline-offset: 3px; }
.google-g { width: 20px; height: 20px; flex: none; display: block; }
.signin-fine {
  margin: 18px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--paper-faint);
}
.signin-notice {
  margin: 20px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  background: var(--panel-2);
}
/* Sign-in not switched on for this site yet: informational, a calm green bar (never a tier colour, never danger red). */
.signin-notice[data-notice="unconfigured"] {
  color: var(--paper);
  box-shadow: inset 3px 0 0 var(--maker-nvidia);
}
/* A Google account that is not the owner's: refused, said plainly, in the danger colour. */
.signin-notice[data-notice="denied"] {
  color: var(--danger);
  background: color-mix(in oklab, var(--danger) 10%, var(--panel-2));
  box-shadow: inset 3px 0 0 var(--danger);
}
.signin-back {
  display: inline-block;
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper-faint);
  text-underline-offset: 3px;
}

/* ── Phone and narrow widths ───────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .meaning { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .meaning-head { text-align: center; }
  .meaning-body { justify-self: center; width: min(100%, 34rem); }
  .workspace.is-owner { grid-template-columns: minmax(0, 1fr); }
  /* One column: the board comes first, right under the headline; the tray follows as a compact owner control. */
  .workspace.is-owner > .tray { contain: none; }
  .workspace.is-owner .tray-items { max-height: 34vh; }
}

@media (max-width: 760px) {
  :root { --rail: 56px; --radius-board: 16px; }
  .masthead { min-height: 60px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-word { font-size: 15px; }
  .masthead .btn { min-height: 36px; padding: 0 12px; font-size: 11px; }
  .headline { grid-template-columns: minmax(0, 1fr); padding: 24px 0 20px; gap: 16px; }
  .headline h1 { font-size: 28px; }
  .headline-sub { font-size: 15px; }
  .meaning { margin-top: 32px; gap: 22px; }
  .meaning-head { text-align: left; }
  .meaning-scale { margin-top: 14px; }
  .meaning-keys > span { height: 30px; font-size: 13px; border-radius: 6px; }
  .meaning-keys > span:first-child { border-radius: 10px 6px 6px 10px; }
  .meaning-keys > span:last-child { border-radius: 6px 10px 10px 6px; }
  .meaning-body { justify-self: stretch; width: 100%; }
  .meaning-body p { font-size: 17px; }
  .headline-meta { align-items: flex-start; text-align: left; }
  /* The key is redundant on a phone (every label prints its maker); the board moves up a screen. */
  .headline-meta .legend { display: none; }
  .tray-hint { display: none; }
  .tier { min-height: 66px; border-radius: 10px; }
  .tier:first-child { border-top-left-radius: 13px; border-top-right-radius: 13px; }
  .tier:last-child { border-bottom-left-radius: 13px; border-bottom-right-radius: 13px; }
  .tier-letter { font-size: 30px; }
  .tier-items::after { top: auto; bottom: 5px; left: 0; width: var(--rail); min-width: 0; padding: 0; background: none; font-size: 9px; color: rgb(7 5 20 / 0.7); }
  /* Phones: two cards a row, a lone last one full width; S one full-width card a row. */
  .tier-items { gap: 6px; padding: 10px; --card-basis: 120px; --card-max: 100%; }
  .label { min-height: 42px; padding: 6px 10px; border-radius: 8px; gap: 2px; }
  /* A narrower cut of the face and a slimmer frame keep two cards a row on one line each. */
  .label-name,
  .workspace.is-owner .board .label-name { font-size: 13px; font-stretch: 82%; }
  .tier:not([data-tier="S"]) .label { min-height: 44px; padding: 6px 8px; }
  .tier:not([data-tier="S"]) .label-name { font-size: 12.5px; }
  .label-maker { font-size: 8.5px; letter-spacing: 0.06em; }
  .label { column-gap: 7px; }
  .label { column-gap: 6px; }
  .label:has(> img[data-model-logo]) { grid-template-columns: 13px minmax(0, 1fr); }
  .label img[data-model-logo] { width: 13px; height: 13px; }
  .tier[data-tier="S"] { min-height: 104px; }
  .tier[data-tier="S"] .tier-letter { font-size: 56px; padding-top: 14px; }
  .tier[data-tier="S"] .tier-letter::after { top: 9px; width: 24px; height: 15px; }
  .tier[data-tier="A"] { min-height: 88px; }
  .tier[data-tier="A"] .tier-letter { font-size: 44px; }
  .tier[data-tier="B"] { min-height: 80px; }
  .tier[data-tier="B"] .tier-letter { font-size: 40px; }
  .tier[data-tier="C"] { min-height: 74px; }
  .tier[data-tier="C"] .tier-letter { font-size: 36px; }
  .tier[data-tier="D"] { min-height: 70px; }
  .tier[data-tier="D"] .tier-letter { font-size: 33px; }
  .tier[data-tier="F"] { min-height: 66px; }
  .tier[data-tier="F"] .tier-letter { font-size: 30px; }
  .tier[data-tier="S"] .tier-items { padding: 12px; gap: 8px; --card-basis: 100%; --card-max: 100%; }
  .tier[data-tier="S"] .label { min-height: 54px; padding: 8px 12px; column-gap: 9px; }
  .tier[data-tier="S"] .label:has(> img[data-model-logo]) { grid-template-columns: 18px minmax(0, 1fr); }
  .tier[data-tier="S"] .label img[data-model-logo] { width: 18px; height: 18px; }
  .tier[data-tier="S"] .label-name { font-size: 16px; }
  .drop-gap, [data-drop-gap] { height: 42px; --gap-width: 96px; border-radius: 8px; }
  .add-label { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .add-label .btn { grid-column: 1 / -1; }
  .colophon { flex-direction: column; align-items: flex-start; }
  .signin-card { padding: 34px 22px 28px; }
  /* Phones: the picker is a bottom sheet under the thumb. */
  .tier-picker {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    max-width: none;
    border-radius: 22px 22px 0 0;
    animation-name: sheet-in;
  }
  .picker-form { padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  .pick { min-height: 56px; }
}

@media (max-width: 400px) {
  .masthead-actions .btn-key { display: none; }
}

/* ── Reduced motion: the drag is stilled, the layout is identical ─────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .label,
  .is-owner .label:hover,
  .label[data-dragging] {
    rotate: none;
    scale: none;
    transition: none;
  }
  .drop-gap,
  [data-drop-gap] { animation: none; }
  .tier-items,
  .tier-letter,
  .tray-items { transition: none; }
  .save-state[data-save-state="saving"] .save-dot { animation: none; }
  .tier-picker { animation: none; }
  .pick:hover { translate: none; }
}
