/*
 * The site's one stylesheet.
 *
 * There were three before this: the landing page, the demo and the report each carried their own
 * inline block, with three different sets of colour variables and three different type scales. A
 * reader clicking from one to the next arrived somewhere that looked like a different project,
 * which is most of what "confusing" meant.
 *
 * Dark by default and light when the reader's system asks for it. No web fonts: the whole point of
 * this project is that it depends on nothing, and a landing page that blocks on a CDN to render its
 * own headline would be arguing against itself.
 */

:root {
  color-scheme: dark;

  --bg: #090c11;
  --bg-soft: #0d1219;
  --panel: #111823;
  --panel-2: #161f2b;
  --line: #1e2836;
  --line-strong: #2a3648;
  --ink: #e8eef8;
  --ink-dim: #97a6bd;
  --ink-faint: #7d8ca6;
  --accent: #5aa9ff;
  --accent-soft: rgba(90, 169, 255, 0.12);
  --accent-ink: #06101d;
  --up: #35d399;
  --down: #ff6f6f;
  --warn: #f5b544;
  --warn-soft: rgba(245, 181, 68, 0.09);

  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;

  --radius: 12px;
  --radius-sm: 8px;
  --shell: 1080px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;

    --bg: #ffffff;
    --bg-soft: #f6f8fb;
    --panel: #ffffff;
    --panel-2: #f4f7fb;
    --line: #e4e9f0;
    --line-strong: #d2dae5;
    --ink: #0b1017;
    --ink-dim: #55637a;
    --ink-faint: #646e80;
    --accent: #1d63d8;
    --accent-soft: rgba(29, 99, 216, 0.08);
    --accent-ink: #ffffff;
    --up: #0b7a51;
    --down: #b8271f;
    --warn: #9a6410;
    --warn-soft: rgba(154, 100, 16, 0.07);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

code,
kbd,
pre {
  font-family: var(--mono);
}

.wrap {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 15.5px;
}

.brand svg {
  display: block;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.topnav a {
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
}

.topnav a:hover {
  color: var(--ink);
  background: var(--panel-2);
}

.topnav a[aria-current='page'] {
  color: var(--ink);
  background: var(--panel-2);
}

@media (max-width: 720px) {
  .topnav a.optional {
    display: none;
  }
}

/* ------------------------------------------------------------- primitives */

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 10px;
}

h1 {
  font-size: clamp(34px, 5.2vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.032em;
  font-weight: 680;
  margin: 0 0 16px;
}

h2 {
  font-size: clamp(23px, 3vw, 29px);
  line-height: 1.2;
  letter-spacing: -0.022em;
  font-weight: 650;
  margin: 0 0 12px;
}

h3 {
  font-size: 16.5px;
  letter-spacing: -0.01em;
  font-weight: 620;
  margin: 0 0 6px;
}

.lede {
  color: var(--ink-dim);
  font-size: 18px;
  line-height: 1.62;
  max-width: 64ch;
  margin: 0 0 26px;
}

p {
  margin: 0 0 14px;
}

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

.small {
  font-size: 14.5px;
}

.section {
  padding: 68px 0;
  border-top: 1px solid var(--line);
}

.section__head {
  max-width: 68ch;
  margin: 0 0 32px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--ghost {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--panel);
}

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------------- code */

.code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.code__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
}

.code__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
}

.code pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.66;
  color: var(--ink);
  tab-size: 2;
}

.t-key {
  color: #c792ea;
}
.t-fn {
  color: var(--accent);
}
.t-str {
  color: var(--up);
}
.t-num {
  color: var(--warn);
}
.t-com {
  color: var(--ink-faint);
  font-style: italic;
}
.t-typ {
  color: #7fd1e0;
}

@media (prefers-color-scheme: light) {
  .t-key {
    color: #8250c4;
  }
  .t-typ {
    color: #0f6f86;
  }
}

/* ------------------------------------------------------------------ stats */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat {
  background: var(--panel);
  padding: 18px 20px;
}

.stat b {
  display: block;
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat span {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ------------------------------------------------------------------ cards */

.cards {
  display: grid;
  gap: 14px;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.card__index {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 10px;
}

.card p {
  color: var(--ink-dim);
  font-size: 14.5px;
  margin: 0;
}

.card__fix {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.55;
}

/* ---------------------------------------------------------------- callout */

.callout {
  border: 1px solid color-mix(in srgb, var(--warn) 38%, var(--line));
  background: var(--warn-soft);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.callout h3 {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warn);
  margin: 0 0 8px;
}

.callout ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-dim);
  font-size: 14.5px;
}

.callout li + li {
  margin-top: 6px;
}

/* ----------------------------------------------------------------- charts */

.panel svg {
  display: block;
  width: 100%;
  height: auto;
}

.grid {
  stroke: var(--line);
  stroke-width: 1;
}

.tick {
  fill: var(--ink-faint);
  font-size: 13px;
  font-family: var(--mono);
}

.equity-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.equity-area {
  fill: var(--accent-soft);
  stroke: none;
}

.drawdown-line {
  fill: none;
  stroke: var(--down);
  stroke-width: 1.4;
}

.drawdown-area {
  fill: color-mix(in srgb, var(--down) 14%, transparent);
  stroke: none;
}

/* ----------------------------------------------------------------- footer */

.footer {
  border-top: 1px solid var(--line);
  padding: 34px 0 48px;
  color: var(--ink-faint);
  font-size: 14px;
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 12px;
}

.footer__links a {
  color: var(--ink-dim);
  text-decoration: none;
}

.footer__links a:hover {
  color: var(--accent);
}

/* ------------------------------------------------------------------- hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
  align-items: center;
  gap: 44px;
  padding: 76px 0 52px;
}

.hero__copy {
  min-width: 0;
}

.hero__code {
  min-width: 0;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 48px 0 36px;
  }
}

/* ------------------------------------------------------------------ meter */

.meter {
  height: 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.meter > i {
  display: block;
  height: 100%;
  background: var(--down);
}

/* -------------------------------------------------------------- demo page */

.page-head {
  padding: 52px 0 26px;
}

.page-head h1 {
  font-size: clamp(28px, 4vw, 40px);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 22px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.field--wide {
  flex: 1 1 240px;
}

.toolbar input[type='number'],
.toolbar select {
  font: 14px/1.4 var(--mono);
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink);
  width: 100%;
  min-width: 112px;
}

.toolbar input:focus-visible,
.toolbar select:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  color: var(--ink);
  padding-bottom: 9px;
}

.switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.toolbar__hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-faint);
}

.error {
  min-height: 22px;
  margin: 12px 0 0;
  font-size: 14.5px;
  color: var(--down);
}

/* The callout class is added by the script only when there is something to say. An always-on
   container drew an empty warning box on a run that had no warnings. */
#warnings:not(.callout) {
  display: none;
}

#warnings.callout {
  margin: 6px 0 18px;
}

.metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  margin-bottom: 12px;
}

.metrics--lead {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

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

.metric .label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.metric .value {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.metrics--lead .metric {
  padding: 18px 20px;
}

.metrics--lead .value {
  font-size: 28px;
}

.value.up {
  color: var(--up);
}

.value.down {
  color: var(--down);
}

.chart-title {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
  margin: 28px 0 10px;
}

.chart-panel {
  padding: 14px 12px 8px;
}

/* The tick labels are sized in the chart's own user units, so they shrink with the SVG. At 13 they
   are unreadable once the panel is a phone wide. Scaling them up in a media query is the only lever
   without a script: the viewBox is fixed, so a bigger glyph is the only way to a bigger label. */
@media (max-width: 720px) {
  .tick {
    font-size: 20px;
  }
}

/* ---------------------------------------------------------------- market picker */

.markets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.market {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink-dim);
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 0.16s ease,
    color 0.16s ease,
    background 0.16s ease,
    transform 0.16s ease;
}

.market:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  transform: translateY(-1px);
}

.market[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.market__ticker {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.market__name {
  font-size: 11.5px;
  color: var(--ink-faint);
}

.market[aria-pressed='true'] .market__name {
  color: var(--accent);
}

/* Out of the flow, so a field with a hint stays exactly as tall as one without it. In the flow it
   made its own column taller and, under `align-items: flex-end`, lifted its label above the rest. */
.field__hint {
  position: absolute;
  top: calc(100% + 5px);
  left: 1px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}

/* -------------------------------------------------------------------- help bubbles */

.metric .label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.help {
  position: relative;
  flex: none;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  font: 600 9px/1 var(--mono);
  cursor: help;
}

.help:hover,
.help:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.help__bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  z-index: 30;
  width: max-content;
  max-width: 260px;
  transform: translateX(-50%) translateY(3px);
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--ink-dim);
  font: 400 12.5px/1.45 var(--sans);
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.28);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    visibility 0.16s;
}

.help:hover .help__bubble,
.help:focus-visible .help__bubble {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* The first and last card in a row would push their bubble off the page. */
.metrics > .metric:first-child .help__bubble {
  left: 0;
  transform: translateY(3px);
}

.metrics > .metric:first-child .help:hover .help__bubble,
.metrics > .metric:first-child .help:focus-visible .help__bubble {
  transform: translateY(0);
}

.metrics > .metric:last-child .help__bubble {
  left: auto;
  right: 0;
  transform: translateY(3px);
}

.metrics > .metric:last-child .help:hover .help__bubble,
.metrics > .metric:last-child .help:focus-visible .help__bubble {
  transform: translateY(0);
}

/* ------------------------------------------------------------------- chart cursor */

.chart-panel {
  position: relative;
}

.chart-title__hint {
  float: right;
  font-weight: 400;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chart-title:hover .chart-title__hint,
.chart-panel:hover + .chart-title__hint {
  opacity: 1;
}

.cursor {
  opacity: 0;
  transition: opacity 0.12s ease;
}

.chart-panel.is-tracking .cursor {
  opacity: 1;
}

.cursor-line {
  stroke: var(--ink-faint);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.cursor-dot {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 2;
}

#drawdown .cursor-dot {
  stroke: var(--down);
}

.readout {
  position: absolute;
  top: 6px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.chart-panel.is-tracking .readout {
  opacity: 1;
}

.readout__date {
  color: var(--ink-faint);
}

.readout__value {
  color: var(--ink);
  font-weight: 600;
}

/* ---------------------------------------------------------------------- motion */

@keyframes draw {
  from {
    stroke-dashoffset: 1;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* `pathLength="1"` on the path normalises the dash to the whole line, so this is one offset
   regardless of how many points the downsampler kept. */
.draw {
  stroke-dasharray: 1;
  animation: draw 1.1s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

#results.is-ready .metric {
  animation: rise 0.34s ease-out backwards;
}

#results.is-ready .metric:nth-child(2) {
  animation-delay: 0.04s;
}
#results.is-ready .metric:nth-child(3) {
  animation-delay: 0.08s;
}
#results.is-ready .metric:nth-child(4) {
  animation-delay: 0.12s;
}
#results.is-ready .metric:nth-child(5) {
  animation-delay: 0.16s;
}
#results.is-ready .metric:nth-child(6) {
  animation-delay: 0.2s;
}

body.is-loading .toolbar,
body.is-loading #results {
  opacity: 0.45;
  transition: opacity 0.12s ease;
}

body.is-loading .market[aria-pressed='true'] {
  animation: pulse 0.9s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    border-color: var(--line);
  }
}

/* Motion is decoration. Someone who has asked their system for less gets the same information
   with none of it, rather than a reduced-but-still-moving version. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------- entry page */

.gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px 20px;
  background:
    radial-gradient(60rem 40rem at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}

.gate__panel {
  width: 100%;
  max-width: 400px;
  padding: 32px 30px 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  text-align: center;
}

.gate__brand {
  justify-content: center;
  margin-bottom: 22px;
}

.gate__title {
  font-size: 26px;
  letter-spacing: -0.024em;
  margin: 0 0 10px;
}

.gate__lede {
  color: var(--ink-dim);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0 0 22px;
}

.gate__guest {
  width: 100%;
  justify-content: center;
  font-size: 15.5px;
  padding: 13px 18px;
}

.gate__note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--ink-faint);
}

.gate__accounts {
  margin-top: 24px;
}

.gate__or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  color: var(--ink-faint);
  font-size: 12px;
}

.gate__or::before,
.gate__or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.gate__form {
  display: grid;
  gap: 12px;
  text-align: left;
}

.gate__form input {
  font: 14px/1.4 var(--sans);
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink);
  width: 100%;
}

.gate__form input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gate__form .btn {
  justify-content: center;
}

.gate__foot {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-faint);
}

.gate .error {
  min-height: 0;
  margin-top: 14px;
  font-size: 13.5px;
}

.topnav__cta {
  border: 1px solid var(--line-strong);
  color: var(--ink) !important;
  margin-left: 6px;
}

.topnav__cta:hover {
  border-color: var(--accent);
  color: var(--accent) !important;
}

/* Help buttons sit inside form labels as well as metric cards, so the label becomes a flex row. */
.field > span,
.switch > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.results__more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 26px 0 0;
}

.results__more .small {
  flex: 1;
  min-width: 240px;
  line-height: 1.5;
}

/* ------------------------------------------------- narrow screens */

/* The bar gained a "Sign in" and stopped fitting a phone. Benchmark and API drop first because
   they are reference material; GitHub goes next because the footer still carries it. Demo, Report
   and Sign in are the three things a visitor came to press, so they never drop. */
@media (max-width: 600px) {
  .topbar__inner {
    padding: 0 16px;
    gap: 10px;
  }

  .topnav a {
    padding: 6px 9px;
    font-size: 13px;
  }

  .topnav a.secondary {
    display: none;
  }

  .wrap {
    padding: 0 16px;
  }
}

/* A tooltip wider than the screen is a tooltip you cannot read, and anchoring it to the button that
   opens it cannot help: `left: 0` is relative to a 14px button, so one sitting near the right edge
   throws a 260px bubble off the page whatever the alignment. On a phone the bubble stops trying to
   point at anything and docks to the bottom of the viewport, which cannot overflow by construction. */
.help__bubble {
  max-width: min(260px, calc(100vw - 32px));
}

@media (max-width: 600px) {
  .help__bubble,
  .metrics > .metric:first-child .help__bubble,
  .metrics > .metric:last-child .help__bubble,
  .toolbar .help__bubble,
  .switch .help__bubble {
    position: fixed;
    inset: auto 16px 16px 16px;
    width: auto;
    max-width: none;
    transform: translateY(8px);
    box-shadow: 0 12px 32px rgb(0 0 0 / 0.4);
  }

  .help:hover .help__bubble,
  .help:focus-visible .help__bubble,
  .metrics > .metric:first-child .help:hover .help__bubble,
  .metrics > .metric:first-child .help:focus-visible .help__bubble,
  .metrics > .metric:last-child .help:hover .help__bubble,
  .metrics > .metric:last-child .help:focus-visible .help__bubble,
  .toolbar .help:hover .help__bubble,
  .toolbar .help:focus-visible .help__bubble,
  .switch .help:hover .help__bubble,
  .switch .help:focus-visible .help__bubble {
    transform: none;
  }
}

/* --------------------------------------------------------------- language toggle */

.langs {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.lang {
  padding: 4px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-faint);
  font: 600 11.5px/1 var(--mono);
  letter-spacing: 0.04em;
  cursor: pointer;
}

.lang:hover {
  color: var(--ink);
}

.lang[aria-pressed='true'] {
  background: var(--panel-2);
  color: var(--ink);
}

.lang:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.topnav .langs {
  margin-left: 8px;
}

.gate__langs {
  margin: 0 0 20px;
}

/* The header runs out of room on a phone once it carries a language toggle as well as Sign in.
   Rather than dropping another item, the nav itself scrolls: `min-width: 0` lets it shrink inside
   the flex row, so the overflow is contained and the page never moves sideways. Everything stays
   reachable with a swipe, and nothing is hidden from someone who came looking for it. */
@media (max-width: 600px) {
  .topnav {
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .topnav::-webkit-scrollbar {
    display: none;
  }

  .topnav a,
  .topnav .langs {
    flex: none;
  }

  .lang {
    padding: 4px 7px;
    font-size: 11px;
  }
}

/* ------------------------------------------------------------------------- brand */

/* The D keeps its blue in both themes because that is the half people recognise; the T rides
   `currentColor` so it inverts. Two tokens rather than hard-coded stops, so a future palette change
   moves the logo with it. */
:root {
  --brand-1: #5cb0ff;
  --brand-2: #1358c9;
  --brand-line: #3d9bff;
}

@media (prefers-color-scheme: light) {
  :root {
    --brand-1: #3d9bff;
    --brand-2: #0f4fbd;
    --brand-line: #1d63d8;
  }
}

.mark {
  display: block;
  flex: none;
}

.mark-full {
  display: block;
  margin: 0 auto 4px;
  color: var(--ink);
}

.gate__brand {
  display: block;
  color: var(--ink);
  text-decoration: none;
}

/* ------------------------------------------------------------- account and saving */

.whoami {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-dim);
  white-space: nowrap;
}

.whoami__out {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font: 600 12px/1 var(--mono);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 5px;
}

.whoami__out:hover {
  color: var(--down);
  background: var(--panel-2);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 26px 0 0;
}

.actions__note {
  flex: 1;
  min-width: 240px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.saved {
  margin-top: 20px;
  padding: 18px 20px;
}

.saved__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.saved__head h3 {
  margin: 0;
  font-size: 14.5px;
}

.saved__form {
  display: flex;
  gap: 8px;
}

.saved__form input {
  font: 13.5px/1.4 var(--sans);
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink);
  min-width: 190px;
}

.saved__form input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.saved__error {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--down);
}

.saved__error:empty {
  display: none;
}

.saved__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.saved__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.saved__name {
  font-weight: 600;
  font-size: 14px;
}

.saved__meta {
  flex: 1;
  min-width: 180px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-faint);
}

.saved__empty {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-faint);
}

@media (max-width: 600px) {
  .saved__form input {
    min-width: 0;
    flex: 1;
  }
}

/* The wordmark is real text in the site's own stack rather than SVG outlines: it stays selectable,
   it reads to a screen reader, and it cannot render differently from the headings beside it. */
.gate__wordmark {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-indent: 0.15em;
  line-height: 1;
}

.gate__wordmark b {
  color: var(--ink);
  font-weight: 700;
}

.gate__wordmark i {
  color: var(--brand-line);
  font-style: normal;
  font-weight: 700;
}

.gate__rule {
  display: block;
  width: 52px;
  height: 3px;
  margin: 9px auto 0;
  border-radius: 2px;
  background: var(--brand-line);
}

.gate__tagline {
  display: block;
  margin-top: 9px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
