/* Instrument panel: dark graphite, amber on receive, teal on send.
   Every colour that is not ink carries a meaning. */

:root {
  --bg:        #0E141C;
  --panel:     #141C26;
  --panel-2:   #18212D;
  --line:      #24303F;
  --line-soft: #1B2531;
  --ink:       #E8EEF6;
  --muted:     #7D8FA6;
  --dim:       #4A5A6E;

  --dl:        #FFA92E;
  --ul:        #37D2C0;
  --pg:        #9B8CFF;
  --warn:      #FF6B5A;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --gut: clamp(1rem, 4vw, 2.5rem);
  --maxw: 1180px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* A faint vignette so the dial sits in the middle of an instrument face. */
  background-image: radial-gradient(120% 80% at 50% 0%, #16202C 0%, var(--bg) 62%);
  background-attachment: fixed;
}

.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }

::selection { background: var(--dl); color: #12181F; }

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

/* ── Header rail ─────────────────────────────────────────────────────────── */

.rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.25rem var(--gut) 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid var(--dl);
  position: relative;
  flex: none;
}
.brand__mark::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 7px; height: 2px;
  background: var(--dl);
  transform-origin: 0 50%;
  transform: rotate(-38deg) translateY(-1px);
}

.brand__name {
  font-family: var(--mono);
  font-size: .95rem;
  font-weight: 500;
}

.rail__meta {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-size: .8rem;
}
.rail__label { color: var(--dim); text-transform: uppercase; letter-spacing: .09em; font-size: .68rem; }
.rail__value { font-family: var(--mono); color: var(--muted); }

/* ── Stage ───────────────────────────────────────────────────────────────── */

.stage {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3rem) var(--gut) 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: start;
}

/* ── Meter ───────────────────────────────────────────────────────────────── */

.meter { display: flex; flex-direction: column; align-items: center; }

.meter__dial {
  position: relative;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1 / 1;
}

#dial { display: block; width: 100%; height: 100%; }

.meter__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding-bottom: 6%;
}

.meter__value {
  font-family: var(--mono);
  font-feature-settings: "tnum" 1;
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--ink);
  transition: color .3s ease;
}
.meter__value[data-kind="idle"]     { color: var(--dim); }
.meter__value[data-kind="download"] { color: var(--dl); }
.meter__value[data-kind="upload"]   { color: var(--ul); }
.meter__value[data-kind="ping"]     { color: var(--pg); }

.meter__unit {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--muted);
  margin-top: .5rem;
  letter-spacing: .04em;
}

.meter__phase {
  margin: .35rem 0 0;
  min-height: 1.5em;
  font-size: .9rem;
  color: var(--muted);
  text-align: center;
}

.go {
  margin-top: 1.4rem;
  padding: .85rem 2.4rem;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  color: #10161E;
  background: var(--dl);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease, color .18s ease;
}
.go:hover:not(:disabled) { background: #FFBC55; transform: translateY(-1px); }
.go:active:not(:disabled) { transform: translateY(0); }
.go:disabled {
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
  cursor: default;
}

/* ── Step chips ──────────────────────────────────────────────────────────── */

.steps {
  display: flex;
  gap: .4rem;
  list-style: none;
  margin: 1.4rem 0 0;
  padding: 0;
}

.steps__item {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dim);
  padding: .3rem .7rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  transition: color .25s ease, border-color .25s ease;
}
.steps__item[data-state="active"] { color: var(--ink); border-color: var(--dl); }
.steps__item[data-state="done"]   { color: var(--muted); border-color: var(--line); }

/* ── Facts ───────────────────────────────────────────────────────────────── */

.facts {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: clamp(1.1rem, 3vw, 1.6rem);
}

.facts__title {
  margin: 0 0 1rem;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}
.facts__title--sub {
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line-soft);
}

.facts__list { margin: 0; }

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

.facts__row dt {
  color: var(--muted);
  font-size: .85rem;
  flex: none;
}
.facts__row dd {
  margin: 0;
  text-align: right;
  font-size: .9rem;
  word-break: break-word;
  min-width: 0;
}

/* ── Results ─────────────────────────────────────────────────────────────── */

/* The wrapper carries the page gutter; the bar itself carries the background,
   so the gutter never shows up as a stray strip beside the cells. */
.results-wrap {
  max-width: var(--maxw);
  margin: clamp(2rem, 6vw, 3.5rem) auto 0;
  padding: 0 var(--gut);
}

.results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  overflow: hidden;
}
/* The gap is a hairline rule; cells paint over it. */
.results > * { background: var(--panel); }

.result { padding: 1.1rem clamp(.8rem, 2vw, 1.4rem); }

.result__head {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .5rem;
}
.result__arrow { font-family: var(--mono); }
.result[data-kind="download"] .result__arrow { color: var(--dl); }
.result[data-kind="upload"]   .result__arrow { color: var(--ul); }
.result[data-kind="ping"]     .result__arrow { color: var(--pg); }
.result[data-kind="jitter"]   .result__arrow { color: var(--pg); }

.result__value {
  font-size: clamp(1.3rem, 3.4vw, 1.75rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.result__value i {
  font-style: normal;
  font-size: .7rem;
  color: var(--dim);
  margin-left: .35rem;
  letter-spacing: 0;
}

/* ── Notice ──────────────────────────────────────────────────────────────── */

.notice {
  max-width: var(--maxw);
  margin: 1.25rem auto 0;
  padding: .85rem var(--gut);
  color: var(--warn);
  font-size: .9rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.foot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem var(--gut) 2.5rem;
  color: var(--dim);
  font-size: .72rem;
}
.foot p { margin: 0; }
.foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.foot a:hover { color: var(--muted); }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .meter { order: 1; }
  .facts { order: 2; }
  .meter__dial { max-width: 380px; }
}

@media (max-width: 560px) {
  .results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { flex-wrap: wrap; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .go:hover:not(:disabled) { transform: none; }
}
