:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #16191d;
  --muted: #5b6672;
  --line: #d9dee5;
  --accent: #2b6cb0;
  --accent-soft: #e3edf9;
  --good: #1f8a56;
  --warn: #b7791f;
  --bad: #c03636;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1c2027;
    --surface-2: #232830;
    --text: #e8ebef;
    --muted: #9aa6b2;
    --line: #2f353e;
    --accent: #6aa9e9;
    --accent-soft: #22303f;
    --good: #4ec48a;
    --warn: #e0b44e;
    --bad: #ea7676;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--accent);
}

header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

header.site .inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}

.brand span {
  color: var(--accent);
}

nav.site {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

nav.site a {
  padding: 6px 10px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.93rem;
}

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

nav.site a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 96px;
}

h1 {
  font-size: clamp(1.7rem, 1.2rem + 1.6vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

h2 {
  font-size: 1.25rem;
  margin: 32px 0 10px;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1rem;
  margin: 20px 0 6px;
}

p.lede {
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 62ch;
  margin-top: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.gallery {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.gallery figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.gallery img {
  display: block;
  width: 100%;
  height: 190px;
  object-fit: cover;
  background: var(--surface-2);
}

.gallery figcaption {
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  display: block;
}

button,
.button {
  font: inherit;
  font-size: 0.93rem;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  filter: brightness(1.08);
  color: #fff;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* The metrics bar under the header, identical on every page. */
.metrics {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 20px 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

/* The measured grid carries one more card than the bar does. */
.metrics.wide {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1000px) {
  .metrics,
  .metrics.wide {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .metrics,
  .metrics.wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.metrics .metric {
  padding: 10px 12px;
}

/* Specific enough to beat `.metric .value`, which is defined later. */
.metrics .metric .value {
  font-size: 1.25rem;
  /* A long figure shrinks rather than wrapping and making one card taller. */
  white-space: nowrap;
}

.metrics.wide .metric .value {
  font-size: 1.15rem;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.metric .label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.metric .value {
  font-size: 1.7rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.metric .sub {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  /* Held open whether or not there is anything to say, so a card does not
     change height the moment a number arrives. */
  min-height: 1.35em;
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 8px;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.4s ease;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.scroll {
  overflow-x: auto;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.86rem;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
}

.tag {
  display: inline-block;
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
}

.tag.good {
  background: color-mix(in srgb, var(--good) 18%, transparent);
  color: var(--good);
}

.tag.warn {
  background: color-mix(in srgb, var(--warn) 20%, transparent);
  color: var(--warn);
}

.tag.bad {
  background: color-mix(in srgb, var(--bad) 18%, transparent);
  color: var(--bad);
}


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

.small {
  font-size: 0.85rem;
}


/* Debug page charts. Humps are coloured by type, below. */
.chart {
  margin-bottom: 16px;
}
.chart h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--text);
}
.chart h2 .value {
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
.chart svg {
  display: block;
  width: 100%;
  height: 240px;
  cursor: grab;
  /* Vertical swipes still scroll the page; horizontal drags pan the chart. */
  touch-action: pan-y;
  user-select: none;
}
.chart svg:active {
  cursor: grabbing;
}
.chart .grid {
  stroke: var(--line);
}
.chart .tick {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
}
.chart .legend {
  margin: 0 0 8px;
}
.chart .legend span {
  margin-left: 10px;
  white-space: nowrap;
}
.chart .legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: -1px;
  background: var(--hump);
}
.chart .hump {
  fill: var(--hump);
  fill-opacity: 0.75;
  stroke: var(--surface);
  stroke-width: 0.5;
}
.chart .hump:hover {
  fill-opacity: 1;
}
.chart [class*="type-"] {
  --hump: var(--muted);
}
.chart .type-navigation {
  --hump: var(--bad);
}
.chart .type-script {
  --hump: var(--warn);
}
.chart .type-css,
.chart .type-link {
  --hump: var(--good);
}
.chart .type-img {
  --hump: var(--accent);
}
.chart .type-fetch,
.chart .type-xmlhttprequest {
  --hump: #8b6ad8;
}
.chart .estimate {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}
