/* CowRoll website: components built only from tokens.css.
   The page is a query tab: a line-number gutter runs its whole height,
   every section is a statement in the editor, and its result sits under it. */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-height) + var(--space-6));
  scrollbar-color: var(--line-strong) var(--chrome);
}

body {
  margin: 0;
  background: var(--milk);
  color: var(--hide);
  font: 400 var(--text-body) / 1.6 var(--font-ui);
  font-variant-ligatures: none;
  counter-reset: line;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--select-soft); color: var(--hide); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-radius: var(--radius-xs);
}

h1, h2, h3, p, ul, ol, dl, dd, figure, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--select); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
input, button { font: inherit; color: inherit; }
svg.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

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

.skip {
  position: absolute; left: var(--space-4); top: -100px; z-index: 30;
  background: var(--raised); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-popover);
}
.skip:focus { top: var(--space-2); }

/* ---------- Buttons, kbd, badges ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-height); padding: 0 var(--space-4);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--milk); color: var(--hide);
  font: 600 var(--text-label) / 1.2 var(--font-ui);
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn:hover { background: var(--chrome); }
.btn:active { background: var(--sunken); }
.btn[disabled] { color: var(--faint); border-color: var(--line); background: var(--chrome); cursor: not-allowed; }

.btn--primary { background: var(--select); border-color: var(--select); color: var(--on-select); }
.btn--primary:hover { background: color-mix(in oklab, var(--select) 88%, var(--hide)); }
.btn--primary:active { background: color-mix(in oklab, var(--select) 78%, var(--hide)); }

.btn--pending { background: var(--butter); border-color: var(--butter); color: var(--on-butter); }
.btn--pending:hover { background: color-mix(in oklab, var(--butter) 90%, var(--on-butter)); }

.btn--production { background: var(--env-production); border-color: var(--env-production); color: var(--on-env); }
.btn--production:hover { background: color-mix(in oklab, var(--env-production) 88%, var(--hide)); }
.btn--production[disabled] { background: var(--chrome); border-color: var(--line); color: var(--faint); }

.btn--quiet { border-color: transparent; background: transparent; }
.btn--quiet:hover { background: var(--sunken); }
.btn--icon { padding: 0; width: var(--control-height); }

.keys { display: inline-flex; gap: 3px; }
kbd {
  display: inline-grid; place-items: center;
  min-width: 1.6em; height: 1.6em; padding: 0 0.35em;
  border: 1px solid color-mix(in oklab, currentColor 55%, transparent);
  border-radius: var(--radius-xs);
  font-size: 0.75rem; font-weight: 500; line-height: 1;
}

.env {
  display: inline-flex; align-items: center; height: 22px; padding: 0 var(--space-2);
  border-radius: var(--radius-sm); background: var(--env-production); color: var(--on-env);
  font: 600 var(--text-overline) / 1 var(--font-ui); letter-spacing: 0.06em; text-transform: uppercase;
}

.null {
  display: inline-block; padding: 0 5px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs); color: var(--muted);
  font: italic 400 0.6875rem / 1.5 var(--font-mono);
}

/* ---------- Nav: the window's chrome ---------- */

.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--space-6);
  height: var(--nav-height); padding: 0 var(--page-pad) 0 0;
  background: var(--chrome); border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: var(--space-3); height: 100%;
  padding-left: max(var(--space-3), calc((var(--gutter) - 32px) / 2));
  color: var(--hide); text-decoration: none;
  font: 700 1.125rem / 1 var(--font-ui); letter-spacing: -0.01em;
}
.brand img { width: 32px; height: 32px; display: block; }
.nav__links { display: flex; gap: var(--space-1); margin-left: var(--space-2); }
.nav__links a {
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font: 500 var(--text-label) / 1.2 var(--font-ui);
}
.nav__links a:hover { color: var(--hide); background: var(--sunken); }
.nav__end { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.theme .icon--moon { display: none; }
:root[data-theme="dark"] .theme .icon--sun { display: none; }
:root[data-theme="dark"] .theme .icon--moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .icon--sun { display: none; }
  :root:not([data-theme="light"]) .theme .icon--moon { display: block; }
}

/* ---------- The tab: gutter down the whole page ---------- */

.tab {
  background:
    linear-gradient(90deg,
      var(--chrome) calc(var(--gutter) - 1px),
      var(--line) calc(var(--gutter) - 1px) var(--gutter),
      transparent var(--gutter));
}
.col { padding-left: calc(var(--gutter) + var(--page-pad) / 2 + var(--space-2)); padding-right: var(--page-pad); }

.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 22rem);
  align-items: end; gap: var(--space-6) var(--space-12);
  padding-top: clamp(40px, 6vw, 76px); padding-bottom: clamp(28px, 3.4vw, 44px);
}
.hero__side { display: grid; gap: var(--space-6); justify-items: start; }
.hero h1 {
  font: 700 var(--text-display) / 0.94 var(--font-ui);
  letter-spacing: -0.035em; text-wrap: balance;
}
.hero__line { display: block; } /* one sentence a line; each wraps by itself when narrow */
.hero h1 .nb { white-space: nowrap; } /* col/row never breaks at its slash */
.lede { font-size: var(--text-lede); line-height: 1.5; color: var(--muted); text-wrap: pretty; }

.stmt + .stmt { margin-top: var(--space-section); }
.stmt__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--space-6); padding-bottom: var(--space-8); }
.stmt__head h2 {
  font: 700 var(--text-title) / 1.05 var(--font-ui);
  letter-spacing: -0.028em; text-wrap: balance; max-width: 22ch;
}
.stmt__head p { margin-top: var(--space-4); max-width: var(--measure); color: var(--muted); font-size: var(--text-lede); line-height: 1.5; text-wrap: pretty; }
.stmt__head p strong { color: var(--hide); font-weight: 600; }

/* ---------- Editor ---------- */

.editor {
  border-top: 1px solid var(--line);
  padding: var(--space-3) 0;
  --lh: calc(var(--text-statement) * 1.62);
  font: 400 var(--text-statement) / var(--lh) var(--font-mono);
  font-variant-ligatures: none;
  background: linear-gradient(90deg, transparent var(--gutter), var(--milk) var(--gutter));
}
.editor--sm { --lh: calc(var(--text-code) * 1.75); font-size: var(--text-code); line-height: var(--lh); }
.l {
  position: relative; counter-increment: line;
  padding-left: calc(var(--gutter) + var(--page-pad) / 2 + var(--space-2));
  padding-right: var(--page-pad);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.l::before {
  content: counter(line);
  position: absolute; left: 0; top: 0; width: calc(var(--gutter) - 1px);
  padding-right: clamp(8px, 1.6vw, 24px); text-align: right;
  color: var(--muted); font-size: clamp(0.6875rem, 0.6rem + 0.3vw, 0.875rem); line-height: var(--lh);
  font-variant-numeric: tabular-nums;
}
.l--at { background: linear-gradient(90deg, transparent var(--gutter), var(--select-soft) var(--gutter)); }
.k { color: var(--syn-keyword); }
.s { color: var(--syn-string); }
.n { color: var(--syn-number); }
.f { color: var(--syn-function); }
.c { color: var(--syn-comment); font-style: italic; }
.editor:not(.editor--sm) .c { font-size: max(0.75rem, 0.68em); }

/* ---------- Claims: the app beside the headline, the query under both ---------- */

.shot { margin: 0; padding-bottom: clamp(28px, 3.4vw, 48px); }
.shot__tabs {
  display: flex; gap: var(--space-1); max-width: 72rem; margin-bottom: var(--space-3);
  overflow-x: auto; scrollbar-width: none;
}
.shot__tab {
  display: inline-flex; align-items: center; gap: var(--space-2); flex: none;
  min-height: var(--control-height); padding: 0 var(--space-3);
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent;
  color: var(--muted); font: 500 var(--text-label) / 1.2 var(--font-ui); white-space: nowrap; cursor: pointer;
}
.shot__tab small { color: var(--faint); font-weight: 400; font-size: var(--text-small); }
.shot__tab:hover { color: var(--hide); background: var(--sunken); }
.shot__tab[aria-selected="true"] { color: var(--hide); background: var(--chrome); border-color: var(--line); }
.shot__tab[aria-selected="true"] small { color: var(--muted); }
.shot__frames { display: grid; max-width: 72rem; }
.shot__frame { grid-area: 1 / 1; }
.shot__frame[hidden] { display: block; visibility: hidden; opacity: 0; }
.shot img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
}
@media (prefers-reduced-motion: no-preference) {
  .shot__frame { transition: opacity 0.4s var(--ease-out), visibility 0.4s; }
}
@media (max-width: 560px) { .shot__tab small { display: none; } }
.editor--claims { --lh: calc(var(--text-statement) * 1.9); font-size: var(--text-statement); }

/* ---------- Speed: the 200,000-row clip and what it measured ---------- */

.clip { margin: 0; padding-bottom: var(--space-8); }
.clip video {
  display: block; width: 100%; max-width: 72rem; height: auto; aspect-ratio: 16 / 9;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: #17191c; /* the app's dark chrome, behind the poster while it loads */
  box-shadow: var(--shadow-popover);
}
.clip figcaption { max-width: 72rem; }
.clip__stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: var(--space-4) var(--space-6); margin: var(--space-6) 0 0;
}
.clip__stats div { border-top: 1px solid var(--line); padding-top: var(--space-3); }
.clip__stats dt { color: var(--muted); font-size: var(--text-small); }
.clip__stats dd {
  margin: var(--space-1) 0 0; color: var(--hide);
  font: 700 clamp(1.5rem, 1.1rem + 1.2vw, 2rem) / 1.1 var(--font-ui); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.clip__stats dd small { font: 400 var(--text-small) / 1.3 var(--font-ui); color: var(--muted); letter-spacing: 0; }

/* ---------- Toolbar under a statement ---------- */

.toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3);
  min-height: var(--toolbar-height);
  padding-top: var(--space-2); padding-bottom: var(--space-2);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, transparent var(--gutter), var(--chrome) var(--gutter));
  color: var(--muted); font-size: var(--text-small);
}
.toolbar__status { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.ok { color: var(--ok); font-weight: 600; display: inline-flex; align-items: center; gap: var(--space-1); }

/* ---------- Result grid ---------- */

.result { overflow-x: auto; scrollbar-width: thin; }
.grid {
  width: 100%; border-collapse: collapse;
  font: 400 var(--text-cell) / 1.45 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.grid th, .grid td {
  height: var(--row-height); padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  text-align: left; vertical-align: middle;
}
.grid th:last-child, .grid td:last-child { border-right: 0; }
.grid thead th {
  background: var(--chrome); white-space: nowrap;
  font: 500 var(--text-small) / 1.2 var(--font-ui);
}
.grid thead th small { margin-left: var(--space-2); color: var(--muted); font: 400 0.75rem / 1 var(--font-mono); }
.grid .num { text-align: right; white-space: nowrap; }
.grid .nowrap { white-space: nowrap; }
.grid .prose { font-family: var(--font-ui); font-size: var(--text-label); color: var(--muted); min-width: 16rem; }
.grid .lead { font-weight: 500; min-width: 11rem; }
.grid .big { font-size: 1.15em; font-weight: 500; white-space: nowrap; }
.grid .never { font-weight: 700; white-space: nowrap; }
.grid .sent { white-space: nowrap; }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.pair > * + * { border-left: 1px solid var(--line); }
.pair .lead { white-space: nowrap; min-width: 0; }
.pair .prose { min-width: 0; }

/* The caret, at the end of the statement Run would run. */
.caret { display: inline-block; width: 2px; height: 1.15em; margin-left: 1px; vertical-align: text-bottom; background: var(--select); }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .caret { animation: caret 1.1s steps(1) infinite; }
  @keyframes caret { 50% { opacity: 0; } }
}

/* ---------- The demo: a table tab with staged edits ---------- */

.connline {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3);
  min-height: 44px; padding-top: var(--space-2); padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, transparent var(--gutter), var(--sunken) var(--gutter));
  font-size: var(--text-small); color: var(--muted);
}
.connline strong { color: var(--hide); font-weight: 600; font-family: var(--font-mono); }
.connline .hint { margin-left: auto; }

.grid--edit td.rn, .grid--edit th.rn {
  width: 3.2rem; padding-inline: var(--space-2); text-align: right;
  background: var(--chrome); color: var(--muted); white-space: nowrap;
}
.grid--edit td { white-space: nowrap; position: relative; }
.grid--edit td[data-col] { cursor: cell; }
.grid--edit td[data-col]:hover { background: var(--chrome); }
.grid--edit td[data-col]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 0; }
.grid--edit td.is-staged { background: var(--butter-soft); }
.grid--edit td.is-staged::after {
  content: ""; position: absolute; top: 0; right: 0;
  border: 5px solid var(--butter-ink); border-left-color: transparent; border-bottom-color: transparent;
}
.grid--edit td.is-editing { padding: 0; outline: 2px solid var(--focus); outline-offset: -2px; }
.grid--edit td input {
  width: 100%; min-width: 8ch; height: calc(var(--row-height) - 1px); padding: 0 var(--space-4);
  border: 0; outline: 0; background: var(--milk); font: inherit; text-align: inherit;
  caret-color: var(--select);
}
.grid--edit .locked { color: var(--muted); }

.statusbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-4);
  min-height: var(--toolbar-height); padding-top: var(--space-2); padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, transparent var(--gutter), var(--chrome) var(--gutter));
  font-size: var(--text-small); color: var(--muted);
}
.statusbar .btn { margin-left: auto; }
.statusbar [hidden] { display: none; }

.log { font: 400 var(--text-code) / 1.5 var(--font-mono); }
.log li {
  display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) auto; gap: var(--space-4); align-items: baseline;
  min-height: 34px; padding-top: 7px; padding-bottom: 7px; border-bottom: 1px solid var(--line);
}
.log time, .log .took { color: var(--muted); white-space: nowrap; }
.log code { overflow-wrap: anywhere; }
.log__empty { color: var(--muted); font-family: var(--font-ui); font-size: var(--text-small); display: block !important; }

/* ---------- Review sheet ---------- */

.sheet {
  width: min(100% - 24px, 54rem); max-height: min(100dvh - 24px, 46rem);
  padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--raised); color: var(--hide); box-shadow: var(--shadow-dialog);
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; }
.sheet::backdrop { background: var(--scrim); }
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: sheet 0.28s var(--ease-out); }
  @keyframes sheet { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
}
.sheet__head {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3);
  padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--line);
}
.sheet__head h2 { font: 600 1.25rem / 1.2 var(--font-ui); letter-spacing: -0.01em; }
.sheet__head .where { font: 400 var(--text-small) / 1.2 var(--font-mono); color: var(--muted); }
.sheet__head .order { margin-left: auto; font-size: var(--text-small); color: var(--muted); }
.sheet__body { overflow-y: auto; padding: var(--space-4) var(--space-6); display: grid; gap: var(--space-3); }
.change { border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.change__head {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-3); background: var(--chrome); border-bottom: 1px solid var(--line);
  font: 400 var(--text-small) / 1.3 var(--font-mono);
}
.change__head .idx { color: var(--muted); }
.change__head .cols { margin-left: auto; color: var(--muted); font-family: var(--font-ui); }
.tag {
  padding: 1px 6px; border: 1px solid var(--butter); border-radius: var(--radius-xs);
  background: var(--butter-soft); color: var(--butter-ink); font: 500 0.6875rem / 1.5 var(--font-mono);
}
.change pre { padding: var(--space-3) var(--space-4); font-size: 0.8125rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff { width: 100%; table-layout: fixed; border-collapse: collapse; border-top: 1px solid var(--line); font: 400 0.8125rem / 1.5 var(--font-mono); }
.diff th { padding: 6px var(--space-4); text-align: left; background: var(--chrome); color: var(--muted); font: 600 var(--text-overline) / 1.3 var(--font-ui); letter-spacing: 0.06em; text-transform: uppercase; }
.diff td { padding: 6px var(--space-4); }
.diff td:first-child { color: var(--muted); width: 28%; }
.diff .before { background: var(--danger-soft); }
.diff .after { background: var(--ok-soft); }
.diff .before::before { content: "\2212\00a0\00a0"; color: var(--danger); }
.diff .after::before { content: "+\00a0\00a0"; color: var(--ok); }

.check { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--space-3); align-items: center; font-size: var(--text-label); }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--select); }
.check small { grid-column: 2; color: var(--muted); font-size: var(--text-small); line-height: 1.45; }

.confirm {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3) var(--space-4);
  padding: var(--space-3) var(--space-6); background: var(--danger-soft); font-size: var(--text-label); line-height: 1.45;
}
.confirm svg { color: var(--danger); width: 20px; height: 20px; }
.confirm p { flex: 1 1 16rem; }
.confirm input {
  flex: 0 1 12rem; min-width: 0; height: var(--control-height); padding: 0 var(--space-3);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--milk);
  font: 400 var(--text-small) / 1 var(--font-mono); caret-color: var(--select);
}
.confirm input::placeholder { color: var(--muted); }
.sheet__foot {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2);
  padding: var(--space-3) var(--space-6); border-top: 1px solid var(--line);
}
.sheet__foot .push { margin-left: auto; }

/* ---------- Shortcuts ---------- */

.grid--keys .lead { font-family: var(--font-ui); font-size: var(--text-label); }
.grid--keys th:last-child, .grid--keys td:last-child { width: 1%; padding-left: var(--space-8); }
.grid--keys kbd { color: var(--muted); }

/* ---------- Download ---------- */

.downloads { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.fine { margin-top: var(--space-4); color: var(--muted); font-size: var(--text-small); max-width: var(--measure); }

/* ---------- Footer: the end of the file ---------- */

.foot {
  margin-top: var(--space-section);
  border-top: 1px solid var(--line);
  background: linear-gradient(90deg, transparent var(--gutter), var(--sunken) var(--gutter));
  padding-top: var(--space-8); padding-bottom: var(--space-12);
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-6) var(--space-12);
  color: var(--muted); font-size: var(--text-small);
}
.foot__brand { display: flex; align-items: center; gap: var(--space-3); color: var(--hide); }
.foot__brand img { width: 40px; height: 40px; }
.foot__brand b { display: block; font: 600 var(--text-body) / 1.3 var(--font-ui); }
.foot__brand span { color: var(--muted); }
.foot ul { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--hide); }

/* ---------- Narrow screens ---------- */

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero__side { grid-template-columns: auto 1fr; align-items: center; }
  .nav__links { display: none; }
}
@media (max-width: 560px) {
  :root { --row-height: 40px; }
  .nav { gap: var(--space-2); }
  .nav .btn--buy { display: none; }
  .toolbar__status, .connline .hint { margin-left: 0; }
  .toolbar .btn--primary { flex: 1 1 100%; }
  .grid th, .grid td { padding-inline: var(--space-3); }
  .grid .prose { min-width: 13rem; }
  .log li { grid-template-columns: 1fr; gap: 0; }
  .log .took { display: none; }
  .sheet__head, .sheet__body, .confirm, .sheet__foot { padding-inline: var(--space-4); }
  .sheet__head .order { margin-left: 0; }
  .sheet__foot .btn { flex: 1 1 auto; }
  .sheet__foot .push { margin-left: 0; }
  .pair > * + * { border-left: 0; }
  .grid--edit .wide { display: none; }

  /* Short results read as records on a phone, one field a line. */
  .grid--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .grid--stack, .grid--stack tbody, .grid--stack tr, .grid--stack td { display: block; }
  .grid--stack tr { padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
  .grid--stack td, .grid--stack td.num, .grid--stack td:first-child, .grid--stack td:last-child {
    height: auto; min-width: 0; padding: 2px var(--page-pad) 2px calc(var(--page-pad) / 2 + var(--space-2));
    border: 0; text-align: left; white-space: normal;
  }
  .grid--stack .lead { font-weight: 600; }
  .grid--stack .prose { padding-top: var(--space-1); }
  .grid--stack td:not(.lead):not(:last-child) { color: var(--muted); }
  .grid--stack td[data-label]::before { content: attr(data-label) " "; color: var(--muted); }
}

/* Results start at the gutter's edge; their first column lines up with the code. */
.result, .log { margin-left: var(--gutter); }
.grid:not(.grid--edit) th:first-child,
.grid:not(.grid--edit) td:first-child,
.log li { padding-left: calc(var(--page-pad) / 2 + var(--space-2)); }
.log li { padding-right: var(--page-pad); }
.grid td:last-child, .grid th:last-child { padding-right: var(--page-pad); }
.pair .grid td:last-child, .pair .grid th:last-child { padding-right: var(--space-4); }

/* ---------- Mascot: the mark, with one small move per section ----------
   It plays once when its section comes into view, and again on hover. */

.mascot { display: block; width: clamp(56px, 8vw, 104px); aspect-ratio: 1; flex: none; }
.mascot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.m-cow { transform-box: view-box; transform-origin: 50% 95%; }
.m-ear, .m-eye, .m-spark, .m-part { transform-box: fill-box; transform-origin: center; }
.m-ear--l { transform-origin: 100% 60%; }
.m-ear--r { transform-origin: 0% 60%; }
.m-row, .m-line { transform-origin: 0% 50%; }
.m-tag { transform-origin: 24% 50%; }
.m-staged { opacity: 0; }
.m-check { stroke-dasharray: 1; }
/* The sparkle gives its corner to the section's own prop. */
.mascot:not([data-move="peek"]):not([data-move="nod"]) .m-spark { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .mascot.is-in .m-eye { animation: m-blink 1.8s 1.1s both; }
  .mascot.is-in .m-spark, .mascot.is-in .m-twinkle { animation: m-spark 1.4s var(--ease-out) both; }

  /* Claims: the cow peeks up, the rows arrive. */
  .mascot.is-in[data-move="peek"] .m-cow { animation: m-peek 1.1s var(--ease-out) both; }
  .mascot.is-in .m-row { animation: m-grow 0.6s var(--ease-out) both; }
  .mascot.is-in .m-row:nth-child(1) { animation-delay: 0.5s; }
  .mascot.is-in .m-row:nth-child(2) { animation-delay: 0.65s; }
  .mascot.is-in .m-row:nth-child(3) { animation-delay: 0.8s; }

  /* Speed: in from the left, streaks trailing. */
  .mascot.is-in[data-move="dash"] .m-cow { animation: m-dash 0.8s var(--ease-out) both; }
  .mascot.is-in .m-line { animation: m-streak 0.9s var(--ease-out) both; }
  .mascot.is-in .m-line:nth-child(2) { animation-delay: 0.08s; }
  .mascot.is-in .m-line:nth-child(3) { animation-delay: 0.16s; }

  /* Security: duck, the lock closes, look again. */
  .mascot.is-in[data-move="duck"] .m-cow { animation: m-duck 1.6s var(--ease-out) both; }
  .mascot.is-in .m-shackle { animation: m-shackle 1.6s var(--ease-out) both; }
  .mascot.is-in .m-lock { animation: m-lock 1.6s var(--ease-out) both; }

  /* Safe commits: staged in butter, a nod, committed. */
  .mascot.is-in[data-move="nod"] .m-cow { animation: m-nod 1.3s 0.5s var(--ease-out) both; }
  .mascot.is-in .m-staged { animation: m-staged 2.2s linear both; }
  .mascot.is-in .m-check { animation: m-draw 2.2s var(--ease-out) both; }

  /* Keyboard: three keys in turn, ears keeping time. */
  .mascot.is-in[data-move="tap"] .m-cow { animation: m-tap 1.2s var(--ease-out) both; }
  .mascot.is-in[data-move="tap"] .m-ear--l { animation: m-ear-l 1.2s var(--ease-out) both; }
  .mascot.is-in[data-move="tap"] .m-ear--r { animation: m-ear-r 1.2s var(--ease-out) both; }
  .mascot.is-in .m-key > rect + rect, .mascot.is-in .m-key > text { animation: m-press 0.36s ease-out both; }
  .mascot.is-in .m-key:nth-child(1) > * { animation-delay: 0.15s; }
  .mascot.is-in .m-key:nth-child(2) > * { animation-delay: 0.5s; }
  .mascot.is-in .m-key:nth-child(3) > * { animation-delay: 0.85s; }

  /* Engines: four databases appear along the tunnel, the cow counts them. */
  .mascot.is-in[data-move="look"] .m-cow { animation: m-look 1.6s var(--ease-out) both; }
  .mascot.is-in .m-db { animation: m-pop 0.45s var(--ease-out) both; }
  .mascot.is-in .m-db:nth-child(2) { animation-delay: 0.1s; }
  .mascot.is-in .m-db:nth-child(3) { animation-delay: 0.3s; }
  .mascot.is-in .m-db:nth-child(4) { animation-delay: 0.5s; }
  .mascot.is-in .m-db:nth-child(5) { animation-delay: 0.7s; }
  .mascot.is-in .m-wire { animation: m-wire 1.1s linear both; }

  /* Licence: the tag swings, the cow hops. */
  .mascot.is-in[data-move="hop"] .m-cow { animation: m-hop 1.2s var(--ease-out) both; }
  .mascot.is-in .m-tag { animation: m-swing 1.5s var(--ease-out) both; }

  @keyframes m-blink { 0%, 12%, 100% { transform: scaleY(1); } 6% { transform: scaleY(0.1); } }
  @keyframes m-spark { 0% { transform: scale(0.4) rotate(-90deg); } 60% { transform: scale(1.35) rotate(20deg); } 100% { transform: none; } }
  @keyframes m-peek { 0% { transform: translateY(64px); } 60% { transform: translateY(-5px); } 100% { transform: none; } }
  @keyframes m-grow { 0% { transform: scaleX(0); } 100% { transform: none; } }
  @keyframes m-dash { 0% { transform: translateX(-120px) skewX(-14deg); } 55% { transform: translateX(8px) skewX(4deg); } 100% { transform: none; } }
  @keyframes m-streak { 0% { transform: translateX(70px) scaleX(0.2); opacity: 0; } 45% { opacity: 1; } 100% { transform: none; opacity: 1; } }
  @keyframes m-duck { 0%, 100% { transform: none; } 20%, 50% { transform: translateY(46px); } 78% { transform: translateY(-3px); } }
  @keyframes m-shackle { 0%, 25% { transform: translateY(-7px) rotate(-14deg); } 45% { transform: translateY(1.5px); } 55%, 100% { transform: none; } }
  @keyframes m-lock { 0%, 44%, 60%, 100% { transform: none; } 50% { transform: translateY(2px) scale(1.06, 0.94); } }
  @keyframes m-nod { 0%, 100% { transform: none; } 20%, 60% { transform: translateY(7px) rotate(5deg); } 40%, 80% { transform: translateY(-1px) rotate(-1deg); } }
  @keyframes m-staged { 0% { opacity: 0; } 12%, 62% { opacity: 1; } 82%, 100% { opacity: 0; } }
  @keyframes m-draw { 0%, 62% { stroke-dashoffset: 1; } 86%, 100% { stroke-dashoffset: 0; } }
  @keyframes m-tap { 0%, 100% { transform: none; } 20%, 50%, 80% { transform: translateY(3px); } 35%, 65% { transform: translateY(-1px); } }
  @keyframes m-ear-l { 0%, 100% { transform: none; } 20%, 50%, 80% { transform: rotate(-22deg); } 35%, 65% { transform: rotate(6deg); } }
  @keyframes m-ear-r { 0%, 100% { transform: none; } 20%, 50%, 80% { transform: rotate(22deg); } 35%, 65% { transform: rotate(-6deg); } }
  @keyframes m-press { 0%, 100% { transform: none; } 40% { transform: translateY(4px); } }
  @keyframes m-look { 0%, 100% { transform: none; } 25% { transform: translateX(-9px) rotate(-5deg); } 65% { transform: translateX(9px) rotate(5deg); } }
  @keyframes m-pop { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: none; } }
  @keyframes m-wire { 0% { stroke-dashoffset: 1; opacity: 0; } 20% { opacity: 1; } 100% { stroke-dashoffset: 0; } }
  @keyframes m-swing { 0% { transform: rotate(-22deg); } 30% { transform: rotate(12deg); } 55% { transform: rotate(-7deg); } 78% { transform: rotate(3deg); } 100% { transform: none; } }
  @keyframes m-hop { 0%, 45%, 100% { transform: none; } 22% { transform: translateY(-11px); } 68% { transform: translateY(-6px); } }
}

.grid--bench .big { font-size: 1.3em; font-weight: 600; }
@media (max-width: 560px) { .stmt__head { align-items: start; } }
