:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #e9edf9;
  --muted: #8d96b2;
  --accent-1: #6366f1;
  --accent-2: #22d3ee;
  --green: #34d399;
  --cyan: #22d3ee;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 18px;
  --shadow: 0 20px 60px rgba(2, 6, 23, 0.5);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1000px 600px at 85% -10%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(800px 500px at -10% 30%, rgba(34, 211, 238, 0.14), transparent 60%),
    var(--bg);
}

.bg span {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  animation: float 18s ease-in-out infinite alternate;
}

.bg span:nth-child(1) { width: 420px; height: 420px; left: -120px; top: 10%; background: #4f46e5; }
.bg span:nth-child(2) { width: 360px; height: 360px; right: -100px; top: 35%; background: #0891b2; animation-delay: -6s; }
.bg span:nth-child(3) { width: 300px; height: 300px; left: 35%; bottom: -140px; background: #7c3aed; animation-delay: -12s; }

@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(30px, -40px, 0) scale(1.12); }
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) 16px 40px;
}

.hero { text-align: center; margin-bottom: clamp(24px, 4vw, 40px); }

.logo {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.45);
}

.logo svg { width: 32px; height: 32px; }

h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 5.5vw, 40px);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.grad {
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  margin: 0 auto;
  max-width: 560px;
  color: var(--muted);
  font-size: clamp(13px, 2.6vw, 15px);
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: clamp(16px, 3.5vw, 24px);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.input-row { display: flex; gap: 12px; }

.input-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 12px;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid var(--card-border);
  border-radius: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
  border-color: rgba(99, 102, 241, 0.7);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.input-box.error { border-color: rgba(248, 113, 113, 0.8); animation: shake 0.35s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.input-icon { width: 18px; height: 18px; color: var(--muted); flex: none; }

#ghUrl {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 14px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#ghUrl::placeholder { color: #5b6479; font-family: inherit; }

.clear-btn {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  cursor: pointer;
}

.clear-btn svg { width: 13px; height: 13px; }
.clear-btn:hover { background: rgba(255, 255, 255, 0.18); color: var(--text); }

.btn-primary {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 13px;
  padding: 0 22px;
  min-height: 50px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-1), #3b82f6 55%, var(--accent-2));
  box-shadow: 0 10px 26px rgba(59, 130, 246, 0.35);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}

.btn-primary svg { width: 17px; height: 17px; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(59, 130, 246, 0.45); }
.btn-primary:active { transform: translateY(0) scale(0.98); }

.chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip-label { color: var(--muted); font-size: 12.5px; }

.chip {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover { color: var(--text); border-color: rgba(99, 102, 241, 0.6); background: rgba(99, 102, 241, 0.12); }

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

.node-head h2 { margin: 0; font-size: 17px; }
.node-sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.node-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }

.slider {
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  position: relative;
  transition: background 0.2s;
  flex: none;
}

.slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.switch input:checked + .slider { background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); }
.switch input:checked + .slider::after { transform: translateX(17px); }
.switch-text { font-size: 13px; color: var(--muted); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost svg { width: 15px; height: 15px; }
.btn-ghost:hover { border-color: rgba(34, 211, 238, 0.6); background: rgba(34, 211, 238, 0.1); }
.btn-ghost:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ghost.loading svg { animation: spin 0.9s linear infinite; }

.btn-ghost.sm { padding: 8px 15px; font-size: 13px; min-height: 42px; flex: none; }

@keyframes spin { to { transform: rotate(360deg); } }

.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}

.node {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 13px;
  border-radius: 13px;
  border: 1px solid var(--card-border);
  background: rgba(2, 6, 23, 0.4);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.12s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.node:hover { border-color: rgba(99, 102, 241, 0.55); transform: translateY(-1px); }

.node.selected {
  border-color: transparent;
  background:
    linear-gradient(rgba(2, 6, 23, 0.88), rgba(2, 6, 23, 0.88)) padding-box,
    linear-gradient(135deg, var(--accent-1), var(--accent-2)) border-box;
  border: 1px solid transparent;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.35), 0 8px 24px rgba(59, 130, 246, 0.18);
}

.node-del {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #5b6479;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.15s;
  padding: 0;
}

.node-del svg { width: 12px; height: 12px; }
.node-del:hover { background: rgba(248, 113, 113, 0.16); color: var(--red); opacity: 1; }

.add-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  animation: toast-in 0.2s ease;
}

.add-box { flex: 1; min-width: 0; }

#addInput {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  padding: 11px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#addInput::placeholder { color: #5b6479; font-family: inherit; }

.dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5b6479;
  transition: background 0.2s;
}

.dot.testing { background: var(--amber); animation: pulse 0.9s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(251, 191, 36, 0); }
}

.dot.ok { background: var(--green); }
.node.ok { --lat-color: var(--green); }
.dot.good { background: var(--cyan); }
.node.good { --lat-color: var(--cyan); }
.dot.slow { background: var(--amber); }
.node.slow { --lat-color: var(--amber); }
.dot.bad { background: var(--red); }
.node.bad { --lat-color: var(--red); }
.dot.fail { background: #6b7280; }

.node-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lat { flex: none; font-size: 12px; color: #5b6479; font-variant-numeric: tabular-nums; }
.node.ok .lat, .node.good .lat, .node.slow .lat, .node.bad .lat { color: var(--lat-color); font-weight: 700; }

.test-summary { margin: 14px 2px 0; color: var(--muted); font-size: 12.5px; }
.test-summary strong { color: var(--green); font-weight: 600; }

.result { border-color: rgba(52, 211, 153, 0.35); }

.result-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.result-head h2 { margin: 0; font-size: 16px; }
.result-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.result-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: rgba(52, 211, 153, 0.12);
}

.result-icon svg { width: 17px; height: 17px; }

.link-box {
  display: flex;
  gap: 10px;
  align-items: stretch;
  padding: 10px 10px 10px 14px;
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid var(--card-border);
}

.link-box code {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--cyan);
  word-break: break-all;
  align-self: center;
  line-height: 1.5;
}

#copyBtn {
  flex: none;
  border: 0;
  border-radius: 9px;
  padding: 0 18px;
  min-height: 38px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  transition: filter 0.15s, transform 0.12s;
}

#copyBtn:hover { filter: brightness(1.12); }
#copyBtn:active { transform: scale(0.96); }

.countdown { margin-top: 14px; }

.count-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.count-bar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
}

.count-bar i.run { transition: width linear; }

.count-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

#countText { color: var(--muted); font-size: 13px; }
.count-btns { display: inline-flex; gap: 6px; }

.btn-text {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-text:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.btn-text.primary { color: var(--cyan); }
.btn-text.primary:hover { background: rgba(34, 211, 238, 0.12); }

.foot { text-align: center; margin-top: 26px; }
.foot p { color: #5b6479; font-size: 12px; margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 99;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: toast-in 0.25s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.err { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
.toast.ok { border-color: rgba(52, 211, 153, 0.5); color: #a7f3d0; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 640px) {
  .input-row { flex-direction: column; }
  .btn-primary { width: 100%; padding: 15px 22px; }
  .node-grid { grid-template-columns: repeat(2, 1fr); }
  .node { padding: 11px 10px; gap: 7px; }
  .node-name { font-size: 12px; }
  .lat { font-size: 11px; }
  .node-head { flex-direction: column; align-items: flex-start; }
  .node-actions { width: 100%; justify-content: space-between; }
  .btn-ghost.sm { flex: 1; }
  .add-row { flex-wrap: wrap; }
  .add-row .add-box { flex-basis: 100%; }
  .link-box { flex-direction: column; }
  #copyBtn { width: 100%; min-height: 40px; }
  .count-foot { flex-direction: column; align-items: stretch; }
  #countText { text-align: center; }
  .count-btns { justify-content: center; }
}

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

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