/* Fonts: Barlow (SIL OFL 1.1), self-hosted so the page never depends on Google Fonts in mainland China. */
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/barlow-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/barlow-latin-500-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(fonts/barlow-latin-600-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/barlow-semi-condensed-latin-500-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(fonts/barlow-semi-condensed-latin-600-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #15181f;
  --text-2: #5b6270;
  --text-muted: #8a909c;
  --border: #dde1e7;
  --line: #e7eaef;
  --down: #2f6fe4;
  --up: #c8731a;
  --down-fill: rgba(47, 111, 228, 0.24);
  --up-fill: rgba(200, 115, 26, 0.2);
  --hot: #dc5a0c;
  --bad: #d64545;
  --chart-grid: #eceef2;
  --seg-on: #ffffff;
  --shadow: 0 1px 2px rgba(21, 24, 31, 0.04), 0 8px 24px -12px rgba(21, 24, 31, 0.12);

  --radius: 16px;
  --radius-sm: 10px;
  --font-ui: 'Barlow', system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-num: 'Barlow Semi Condensed', 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #121419;
  --surface: #1a1d24;
  --surface-2: #22262e;
  --text: #eceef2;
  --text-2: #969caa;
  --text-muted: #6c7282;
  --border: #2a2e37;
  --line: #2b303a;
  --down: #5b8def;
  --up: #d98a35;
  --down-fill: rgba(91, 141, 239, 0.28);
  --up-fill: rgba(217, 138, 53, 0.22);
  --hot: #f2913f;
  --bad: #ef6b6b;
  --chart-grid: #262a33;
  --seg-on: #323743;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #121419;
    --surface: #1a1d24;
    --surface-2: #22262e;
    --text: #eceef2;
    --text-2: #969caa;
    --text-muted: #6c7282;
    --border: #2a2e37;
    --line: #2b303a;
    --down: #5b8def;
    --up: #d98a35;
    --down-fill: rgba(91, 141, 239, 0.28);
    --up-fill: rgba(217, 138, 53, 0.22);
    --hot: #f2913f;
    --bad: #ef6b6b;
    --chart-grid: #262a33;
    --seg-on: #323743;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
p,
dl,
dd,
figure,
fieldset,
ul {
  margin: 0;
  padding: 0;
}

fieldset {
  border: 0;
  min-width: 0;
}

ul {
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--down);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left));
}

.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Top bar ---------- */

.topbar {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: 'brand links tools';
  align-items: center;
  gap: 12px 24px;
  min-height: 64px;
  padding-block: 10px;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand__mark {
  width: 32px;
  height: 32px;
  color: var(--down);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__name {
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.01em;
}

.brand__tag {
  font-size: 12.5px;
  color: var(--text-2);
}

.links {
  grid-area: links;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 18px;
}

.links__item {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}

.links__item--hot {
  color: var(--hot);
  font-weight: 600;
}

.links__item:hover {
  color: var(--down);
}

.tools {
  grid-area: tools;
  display: flex;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
  white-space: nowrap;
}

.chip:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.chip--icon {
  width: 34px;
  padding: 0;
}

.chip[aria-expanded='true'] {
  color: var(--down);
  border-color: var(--down);
}

.icon--moon {
  display: none;
}

:root[data-theme='dark'] .icon--sun {
  display: none;
}

:root[data-theme='dark'] .icon--moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .icon--sun {
    display: none;
  }
  :root:not([data-theme='light']) .icon--moon {
    display: block;
  }
}

/* ---------- Layout ---------- */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-block: 12px 40px;
}

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

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* As tall as the 34 px chip (shown or not), pulled up so the title lines up with other cards' titles. */
  min-height: 34px;
  margin: -6px 0 8px;
}

.card__head .card__title {
  margin-bottom: 0;
}

.card__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

.card__foot {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* ---------- Hero ---------- */

.hero {
  padding: 0;
  overflow: hidden;
}

.hero__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 16px 20px 0;
}

/* Region tabs, then Start with its status; the switch and settings stay at the right end
   (on their own row when the bar is too narrow for all three). */
.hero__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.switch__track {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  transition: background-color 0.15s;
}

.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}

.switch input:checked + .switch__track {
  background: var(--down);
}

.switch input:checked + .switch__track .switch__thumb {
  transform: translateX(16px);
}

.switch input:checked ~ .switch__label {
  color: var(--text);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--down);
  outline-offset: 2px;
}

.switch:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (forced-colors: active) {
  /* System colors swap instantly; animating between them leaves the thumb invisible mid-way. */
  .switch__track,
  .switch__thumb {
    transition: none;
  }
  .switch__track {
    border: 1px solid CanvasText;
    background: Canvas;
  }
  .switch__thumb {
    top: 2px;
    left: 2px;
    background: CanvasText;
  }
  .switch input:checked + .switch__track {
    border-color: Highlight;
    background: Highlight;
  }
  .switch input:checked + .switch__track .switch__thumb {
    background: HighlightText;
  }
}

.hero__hint {
  margin: 12px 20px 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--up) 11%, transparent);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.seg {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  padding: 4px;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 14px;
}

.seg__btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 7px 16px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.seg__btn[aria-checked='true'] {
  background: var(--seg-on);
  box-shadow: 0 1px 2px rgba(21, 24, 31, 0.08), 0 2px 8px -4px rgba(21, 24, 31, 0.16);
}

.seg__btn:disabled {
  cursor: not-allowed;
}

.seg__btn:disabled:not([aria-checked='true']) {
  opacity: 0.5;
}

.seg__title {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.25;
  color: var(--text-2);
}

.seg__btn[aria-checked='true'] .seg__title {
  color: var(--text);
}

.seg__sub {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.25;
}

.settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 24px;
  margin: 16px 20px 0;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

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

.field__label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
  padding: 0;
}

.field__value {
  font-family: var(--font-num);
  font-weight: 600;
  color: var(--text);
}

.field__control {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.field__range {
  width: 100%;
  height: 36px;
  accent-color: var(--down);
}

.toggle {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  height: 36px;
  width: max-content;
}

.toggle label {
  position: relative;
}

.toggle input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.toggle span {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 12px;
  border-radius: 6px;
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-2);
}

.toggle input:checked + span {
  background: var(--down);
  color: #fff;
}

.toggle input:focus-visible + span {
  outline: 2px solid var(--down);
  outline-offset: 2px;
}

.settings__hint {
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: var(--text-2);
}

.readouts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.readout {
  position: relative;
  /* Label and big number on the left; peak and loaded latency stacked on the right. */
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 20px;
  padding: 18px 20px;
  min-width: 0;
}

.readout__main {
  min-width: 0;
}

.readout + .readout {
  border-left: 1px solid var(--line);
}

.readout::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: transparent;
  transition: background-color 0.2s;
}

.readout--down[data-active]::before {
  background: var(--down);
}

.readout--up[data-active]::before {
  background: var(--up);
}

.readout__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

.readout--down .readout__label .icon {
  color: var(--down);
}

.readout--up .readout__label .icon {
  color: var(--up);
}

.readout__value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 6px;
  min-height: 1em;
  font-size: clamp(46px, 9vw, 92px);
  line-height: 1;
}

.readout__value .num {
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: color 0.2s;
}

.readout:not([data-has-value]) .readout__value .num {
  color: var(--border);
  font-weight: 500;
}

.readout--down[data-has-value] .readout__value .num {
  color: var(--down);
}

.readout--up[data-has-value] .readout__value .num {
  color: var(--up);
}

.unit {
  font-family: var(--font-num);
  font-weight: 500;
  font-size: 15px;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.readout__value .unit {
  font-size: clamp(14px, 1.6vw, 18px);
}

.readout__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 6px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.readout__meta b {
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.readout__note {
  max-width: 13em;
  padding-bottom: 6px;
  font-size: 13px;
  color: var(--text-2);
}

.runner {
  flex: 1 1 380px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px 20px;
}

.start {
  flex: none;
  min-width: 168px;
  height: 54px;
  padding: 0 28px;
  border: 2px solid var(--down);
  border-radius: 999px;
  background: var(--down);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 8px 20px -10px var(--down);
  transition: transform 0.12s, background-color 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.start:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -10px var(--down);
}

.start:active {
  transform: translateY(0);
}

.start[data-state='running'] {
  background: transparent;
  color: var(--bad);
  border-color: var(--bad);
  box-shadow: none;
}

.runner__status {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status {
  font-size: 14.5px;
  color: var(--text-2);
  min-height: 1.5em;
}

.progress {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--down), color-mix(in srgb, var(--down) 60%, var(--up)));
  transition: width 0.2s linear;
}

.progress[data-indeterminate] .progress__bar {
  width: 30% !important;
  animation: slide 1.4s ease-in-out infinite;
}

@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

.chart {
  border-top: 1px solid var(--line);
  padding: 14px 20px 16px;
}

.chart__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.chart__title {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.chart__legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart__legend .dot:not(:first-child) {
  margin-left: 10px;
}

.chart__unit {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--text-muted);
}

.dot--down {
  background: var(--down);
}

.dot--up {
  background: var(--up);
}

.chart__canvas {
  display: block;
  width: 100%;
  height: 230px;
}

/* ---------- Tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}

.tile__label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile__tag {
  font-weight: 500;
  color: var(--text-muted);
}

.tile__value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin: 6px 0 4px;
  font-size: 34px;
  line-height: 1.05;
}

.tile__value .num {
  font-weight: 600;
}

.tile__sub {
  font-size: 13px;
  color: var(--text-2);
}

.tile__sub b {
  font-family: var(--font-num);
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.tile__loss {
  margin-left: 8px;
  color: var(--bad);
}

/* ---------- Connection facts ---------- */

.facts {
  display: flex;
  flex-direction: column;
}

.facts__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.facts__row:first-child {
  border-top: 0;
  padding-top: 0;
}

.facts dt {
  flex: none;
  color: var(--text-2);
  font-size: 14px;
}

.facts dd {
  min-width: 0;
  text-align: right;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.facts a {
  color: var(--down);
  text-decoration: none;
}

.facts a:hover {
  text-decoration: underline;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 12px;
  vertical-align: 1px;
  white-space: nowrap;
}

/* ---------- History ---------- */

.history-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.empty {
  color: var(--text-2);
  font-size: 14px;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  /* Not a multiple of the row height, so a partly visible row shows there is more to scroll. */
  max-height: 440px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Side by side with "Your connection": that card sets the row height and the list scrolls within it. */
@media (min-width: 901px) {
  .history {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    contain: size;
  }
}

.history__item {
  /* Wraps rather than overlaps on narrow screens: the time drops below the speeds when they don't fit. */
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.history__item:first-child {
  border-top: 0;
  padding-top: 0;
}

.history__speed {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.history__speed b {
  font-family: var(--font-num);
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.history__speed--down b {
  color: var(--down);
}

.history__speed--up b {
  color: var(--up);
}

.history__time {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history__meta {
  flex-basis: 100%;
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--line);
  padding-block: 22px calc(22px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}

.footer__disclaimer {
  margin-bottom: 6px;
}

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

.footer a {
  color: var(--text-2);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .topbar__inner {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'brand tools'
      'links links';
  }
  .links {
    justify-content: flex-start;
  }
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  main {
    padding-block: 12px 32px;
    gap: 12px;
  }
  .topbar {
    position: static;
  }
  .links {
    gap: 4px 14px;
  }
  .links__item {
    font-size: 13.5px;
  }
  .hero__bar {
    padding: 12px 12px 0;
    flex-wrap: wrap;
  }
  .hero__actions {
    flex: 1 1 100%;
    justify-content: space-between;
  }
  .hero__hint {
    margin: 10px 12px 0;
  }
  .seg {
    flex: 1 1 100%;
  }
  .seg__btn {
    padding: 6px 10px 7px;
  }
  .seg__sub {
    font-size: 11.5px;
  }
  #settingsBtn {
    width: 40px;
    height: 40px;
    padding: 0;
  }
  #settingsBtn .chip__text {
    display: none;
  }
  .settings {
    grid-template-columns: minmax(0, 1fr);
    margin: 12px 12px 0;
  }
  .readouts {
    margin: 12px;
  }
  /* Half-width readouts leave no room beside the number: peak and latency go underneath. */
  .readout {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px 12px;
  }
  .readout__value {
    font-size: clamp(36px, 12vw, 52px);
    flex-wrap: wrap;
    gap: 2px 6px;
  }
  .readout__meta {
    gap: 2px;
    padding-bottom: 0;
    font-size: 12.5px;
    white-space: normal;
  }
  .readout__note {
    padding-bottom: 0;
  }
  .runner {
    flex: 1 1 100%;
    flex-wrap: wrap;
  }
  .start {
    width: 100%;
  }
  .runner__status {
    flex-basis: 100%;
  }
  .chart {
    padding: 12px 12px 14px;
  }
  .chart__canvas {
    height: 190px;
  }
  .tiles {
    gap: 12px;
  }
  .tile {
    padding: 14px;
  }
  .tile__value {
    font-size: 28px;
  }
  .tile__label {
    white-space: normal;
  }
  .tile__tag {
    display: block;
  }
  .card {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
