@font-face {
  font-family: "Inter Fallback";
  src: local("Inter"), local("Helvetica Neue");
}

:root {
  color-scheme: light;
  --ink: #16171a;
  --muted: #6d7178;
  --line: #dedfdf;
  --line-strong: #c9cbcc;
  --panel: #ffffff;
  --soft: #f4f4f1;
  --orange: #f46f2c;
  --orange-soft: #fff0e7;
  --purple: #8b45c7;
  --purple-soft: #f4eafa;
  --blue: #2868cd;
  --green: #16794f;
  --green-soft: #e7f5ed;
  --shadow: 0 1px 2px rgba(20, 24, 31, 0.05), 0 12px 36px rgba(20, 24, 31, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: #ffffff;
  color: var(--ink);
  font-family: "Inter Fallback", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  background: #ffffff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  margin: 0 42px;
  padding: 0;
  border-bottom: 2px solid #27292c;
  background: #ffffff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 760;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 5px;
  background: var(--ink);
  transform: rotate(-3deg);
}

.brand-mark img {
  width: 21px;
  filter: invert(1);
  transform: rotate(3deg);
}

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #5f646a;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #25a66a;
  box-shadow: 0 0 0 4px #e2f5eb;
}

main {
  padding: 18px 42px 28px;
}

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

.results-panel,
.server-panel,
.measurements {
  background: var(--panel);
}

.results-panel {
  padding: 0 6px 0 0;
}

.local-warning {
  margin-top: 14px;
  padding: 9px 12px;
  border-left: 3px solid var(--orange);
  background: #fff7f1;
  color: #6a442f;
  font-size: 10px;
  font-weight: 620;
  line-height: 1.45;
}

.local-warning[hidden] {
  display: none;
}

.section-heading,
.server-heading,
.measurements-heading,
.quality-heading,
.loss-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 780;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: -0.035em;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(22px, 1.8vw, 29px);
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 0;
  font-size: 14px;
}

.measured-at {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.headline-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 0.72fr;
  gap: 18px;
  margin-top: 28px;
}

.metric-card {
  min-width: 0;
}

.metric-label,
.health-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #383b40;
  font-size: 12px;
  font-weight: 730;
}

.icon-button {
  display: grid;
  width: 20px;
  height: 20px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: help;
}

.icon-button img {
  width: 14px;
  opacity: 0.52;
}

.info-trigger {
  position: relative;
}

.info-trigger::after {
  position: absolute;
  z-index: 10;
  bottom: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: 220px;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  content: attr(data-tip);
  font-size: 10px;
  font-weight: 520;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 3px);
  transition: 160ms ease;
}

.info-trigger:hover::after,
.info-trigger:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.metric-value {
  margin: 28px 0 20px;
  font-size: clamp(38px, 4vw, 64px);
  font-weight: 720;
  letter-spacing: -0.07em;
  line-height: 0.9;
}

.metric-value small {
  font-size: 20px;
  font-weight: 690;
  letter-spacing: -0.035em;
}

.chart-shell {
  position: relative;
  height: 92px;
  border-bottom: 1px solid #e2e3e3;
}

.chart-shell::before {
  position: absolute;
  top: 25px;
  right: 0;
  left: 0;
  border-top: 1px dashed #e1e2e2;
  content: "";
}

.percentile {
  position: absolute;
  z-index: 1;
  top: 9px;
  left: 0;
  color: #aaaeb2;
  font-size: 9px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.metric-health {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding-left: 4px;
}

.health-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid #ededeb;
}

.health-row.compact {
  border-bottom: 0;
}

.health-row p {
  margin: 7px 0 0;
  line-height: 1;
}

.health-row strong {
  font-size: 23px;
  letter-spacing: -0.05em;
}

.health-row small {
  color: #5d6167;
  font-size: 11px;
  font-weight: 650;
}

.direction-values {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 2px;
  font-size: 9px;
  font-weight: 650;
  text-align: right;
}

.direction-values .down {
  color: var(--orange);
}

.direction-values .up {
  color: var(--purple);
}

.test-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.control {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid #d8d9d8;
  border-radius: 4px;
  background: #fff;
  color: #34383d;
  cursor: pointer;
  font-size: 11px;
  font-weight: 690;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.control:hover:not(:disabled) {
  border-color: #aeb0b2;
  background: #f8f8f6;
  transform: translateY(-1px);
}

.control:focus-visible {
  outline: 3px solid rgba(40, 104, 205, 0.2);
  outline-offset: 2px;
}

.control:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.control.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.control img {
  width: 14px;
}

.control.primary img {
  filter: invert(1);
}

.test-state {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 620;
}

.quality-card {
  margin-top: 18px;
  overflow: hidden;
  border-top: 1px solid #cfd1d1;
  border-bottom: 1px solid #cfd1d1;
}

.quality-heading {
  align-items: center;
  padding: 13px 15px;
  border-bottom: 1px solid #e2e3e1;
  background: #ffffff;
}

.quality-heading h2 {
  font-size: 13px;
}

.score-pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 10px;
  font-weight: 760;
}

.quality-items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.quality-item {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  color: #565b61;
  font-size: 10px;
  white-space: nowrap;
}

.quality-item + .quality-item {
  border-left: 1px solid #e5e6e3;
}

.quality-item img {
  width: 15px;
  opacity: 0.62;
}

.quality-item strong {
  color: var(--blue);
}

.server-panel {
  padding: 0 0 0 6px;
  min-width: 0;
}

.server-heading {
  align-items: center;
  margin-bottom: 14px;
}

.node-status {
  padding: 5px 8px;
  border: 1px solid #bfe4cf;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 9px;
  font-weight: 780;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.route-map {
  position: relative;
  min-height: 350px;
  overflow: hidden;
  border: 1px solid #d1d2d0;
  border-radius: 0;
  background: #e6e7e3;
}

.map-tiles {
  position: absolute;
  display: grid;
  width: 1280px;
  height: 768px;
  grid-template-columns: repeat(5, 256px);
  grid-template-rows: repeat(3, 256px);
  filter: grayscale(1) contrast(0.88) brightness(1.08);
}

.map-tiles img {
  display: block;
  width: 256px;
  height: 256px;
}

.map-unavailable {
  position: absolute;
  inset: 0;
  display: grid;
  max-width: 300px;
  margin: auto;
  place-items: center;
  color: #656a70;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.5;
  text-align: center;
}

.map-unavailable[hidden],
.server-map-marker[hidden] {
  display: none;
}

.server-map-marker {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 17px;
  height: 17px;
  border: 5px solid #fff;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 2px var(--orange), 0 4px 14px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
}

.server-map-marker::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(244, 111, 44, 0.45);
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.map-controls {
  position: absolute;
  z-index: 4;
  top: 10px;
  right: 10px;
  display: grid;
  overflow: hidden;
  border: 1px solid #cfd1ce;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 8px rgba(30, 35, 40, 0.12);
}

.map-controls button {
  width: 30px;
  height: 29px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #34373b;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.map-controls button + button {
  border-top: 1px solid #d8d9d6;
}

.map-attribution {
  position: absolute;
  z-index: 4;
  right: 5px;
  bottom: 4px;
  padding: 3px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.78);
  color: #5f6468;
  font-size: 8px;
  text-decoration: none;
}

.server-details {
  display: grid;
  gap: 0;
  margin: 15px 0 0;
}

.server-details div {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #ededeb;
}

.server-details div:last-child {
  border-bottom: 0;
}

.server-details dt,
.server-details dd {
  margin: 0;
  font-size: 10px;
}

.server-details dt {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.server-details dt img {
  width: 14px;
  opacity: 0.64;
}

.server-details dd {
  color: #303338;
  font-weight: 670;
  text-align: right;
}

.measurements {
  margin-top: 18px;
  padding: 18px 0 0;
  border-top: 1px solid #cfd1d1;
}

.measurements-heading {
  align-items: flex-end;
  margin-bottom: 20px;
}

.measurements-heading > p {
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 10px;
}

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

.measurement-column {
  min-width: 0;
}

.column-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.orange { background: var(--orange); }
.legend-dot.purple { background: var(--purple); }
.legend-dot.blue { background: var(--blue); }

.measurement-list {
  display: grid;
  gap: 9px;
}

.measurement-card {
  padding: 11px 12px 10px;
  border: 1px solid #dedfdf;
  border-radius: 2px;
  background: #fff;
}

.measurement-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.measurement-card-header span {
  color: #363a3f;
  font-size: 10px;
  font-weight: 690;
}

.measurement-card-header small {
  color: #96999d;
  font-size: 8px;
}

.plot {
  position: relative;
  height: 28px;
  margin-top: 6px;
  border-bottom: 1px solid #efefed;
  background: repeating-linear-gradient(to right, transparent 0, transparent calc(25% - 1px), #ececea 25%);
}

.plot::after {
  position: absolute;
  bottom: -12px;
  left: 0;
  color: #a0a3a5;
  content: "0";
  font-size: 7px;
}

.plot-range {
  position: absolute;
  top: 13px;
  left: var(--start);
  width: var(--width);
  height: 1px;
  background: var(--plot-colour);
}

.plot-box {
  position: absolute;
  top: 8px;
  left: var(--box-start);
  width: var(--box-width);
  height: 11px;
  border: 1px solid var(--plot-colour);
  background: color-mix(in srgb, var(--plot-colour) 20%, white);
}

.plot-box::after {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: 53%;
  border-left: 1px solid var(--plot-colour);
  content: "";
}

.plot-dot {
  position: absolute;
  top: 20px;
  left: var(--dot);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--plot-colour);
}

.plot.empty .plot-range,
.plot.empty .plot-box,
.plot.empty .plot-dot {
  display: none;
}

.loss-card {
  margin-top: 15px;
  padding: 14px;
  border: 1px solid #dedfdf;
  border-radius: 2px;
}

.loss-heading {
  align-items: center;
  font-size: 10px;
}

.loss-heading div {
  display: grid;
  gap: 3px;
}

.loss-heading strong {
  color: var(--muted);
  font-size: 8px;
}

.loss-heading > span {
  color: var(--green);
  font-size: 17px;
  font-weight: 760;
  letter-spacing: -0.04em;
}

.loss-bar {
  height: 13px;
  margin-top: 11px;
  overflow: hidden;
  border-radius: 4px;
  background: #e7b8ae;
}

.loss-bar span {
  display: block;
  width: 98.1%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #168b54, #27a76a);
  transition: width 500ms ease;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 0 42px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  color: #777b80;
  font-size: 10px;
}

footer span:first-child {
  color: #303338;
  font-weight: 760;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 28px;
  bottom: 28px;
  padding: 11px 15px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 680;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.is-testing .metric-value span,
.is-testing .health-row strong,
.is-testing .score-pill {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1120px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .server-panel {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 0 20px;
  }

  .server-heading {
    grid-column: 1 / -1;
  }

  .route-map {
    min-height: 255px;
  }
}

@media (max-width: 820px) {
  .shell {
    width: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    margin: 0 18px;
  }

  main {
    padding: 18px 18px 24px;
  }

  .headline-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .metric-health {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
    padding-top: 4px;
  }

  .health-row {
    border-right: 1px solid #ededeb;
    border-bottom: 0;
    padding-right: 12px;
  }

  .health-row:last-child {
    border-right: 0;
  }

  .measurement-grid {
    grid-template-columns: 1fr;
  }

  .measurement-column {
    margin-top: 12px;
  }
}

@media (max-width: 600px) {
  .topbar {
    min-height: 62px;
    margin: 0 14px;
    padding: 0;
  }

  .brand {
    font-size: 18px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .topbar-status span:last-child {
    display: none;
  }

  .results-panel,
  .server-panel,
  .measurements {
    padding: 0;
  }

  .headline-metrics {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .metric-health {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .health-row {
    border-right: 0;
    border-bottom: 1px solid #ededeb;
    padding-right: 0;
  }

  .quality-items {
    grid-template-columns: 1fr;
  }

  .quality-item {
    justify-content: flex-start;
    padding-left: 15px;
  }

  .quality-item + .quality-item {
    border-top: 1px solid #e5e6e3;
    border-left: 0;
  }

  .share-button span {
    display: none;
  }

  .test-state {
    display: none;
  }

  .server-panel {
    display: block;
  }

  .server-details {
    margin-top: 13px;
  }

  .measurements-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  footer {
    margin: 0 14px;
    padding: 18px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Node picker + depth picker */
.depth-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.depth-picker label,
.node-picker label {
  flex: none;
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.depth-picker select,
.node-picker select {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.depth-picker select:disabled,
.node-picker select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.node-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.node-custom-toggle {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.node-custom-toggle:hover {
  border-color: var(--ink);
  background: var(--soft);
}

.custom-node {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.custom-node[hidden] {
  display: none;
}

.custom-node input {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel);
}

.custom-node button {
  flex: none;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.extreme-warning {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #eeb9a4;
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  background: var(--orange-soft);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.extreme-warning[hidden] {
  display: none;
}

.extreme-warning strong {
  display: block;
  margin-bottom: 4px;
}

.extreme-warning p {
  margin: 0 0 8px;
}

.warning-ack {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

.warning-ack input {
  accent-color: var(--orange);
}
