:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2330;
  --muted: #667085;
  --line: #e2e6ec;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --ok: #17803d;
  --mid: #b25e00;
  --bad: #c62828;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --panel: #171c23;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --line: #2a313b;
    --accent: #4c8dff;
    --accent-text: #0b1220;
    --ok: #4ac27a;
    --mid: #e0a04a;
    --bad: #f0706b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

header, main, footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

header { padding-top: 32px; }
header h1 { margin: 0; font-size: 28px; letter-spacing: 0.5px; }
header p { margin: 4px 0 20px; color: var(--muted); }

form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

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

.tabs button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 6px 14px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.row { display: flex; gap: 8px; flex-wrap: wrap; }

#target {
  flex: 1 1 260px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

#rtype {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

#go {
  padding: 10px 22px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#go:disabled { opacity: 0.55; cursor: progress; }

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

#captcha { margin: 14px 2px 0; }
#captcha[hidden] { display: none; }

#status { min-height: 1.5em; margin: 14px 2px 8px; color: var(--muted); }
#status.error { color: var(--bad); }

#overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 14px;
  align-items: start;
  margin: 0 0 14px;
}

#overview[hidden], #map-panel[hidden], table[hidden] { display: none; }

#map-panel {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

#map-panel figcaption { font-weight: 600; }
#map { width: 100%; height: 400px; }
#map-note { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

#groups th[scope="row"] { color: var(--text); font-size: inherit; }
#groups tr.all th, #groups tr.all td { font-weight: 600; }
#groups tr.section th, #groups tr.section td { border-top: 2px solid var(--line); }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th { color: var(--muted); font-size: 13px; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }

td.pending { color: var(--muted); }
td.ok, td.fast { color: var(--ok); }
td.mid { color: var(--mid); }
td.fail, td.slow { color: var(--bad); }
td.fail { white-space: normal; min-width: 180px; overflow-wrap: anywhere; }

tr.detail > td { background: var(--bg); white-space: normal; padding: 8px 12px 12px; }
tr.detail summary { cursor: pointer; color: var(--muted); font-size: 13px; }
table.hops { margin-top: 8px; width: auto; min-width: 60%; }
table.hops th, table.hops td { padding: 5px 12px; }

footer { padding: 24px 16px 40px; color: var(--muted); font-size: 13px; }
