:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --line: #e4e7ec;
  --code: #f3f4f6;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --http: #2563eb;
  --js: #ea580c;
  --meta: #7c3aed;
  --final: #15803d;
  --loop: #b45309;
  --err: #b91c1c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --panel: #141a21;
    --fg: #e6ebf1;
    --muted: #94a1b0;
    --line: #242c37;
    --code: #1a212a;
    --accent: #3b82f6;
    --accent-fg: #ffffff;
    --http: #7aa2f7;
    --js: #fb923c;
    --meta: #c084fc;
    --final: #4ade80;
    --loop: #fbbf24;
    --err: #f87171;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
html, body { margin: 0; }

body {
  min-height: 100vh;
  padding: 52px 20px 64px;
  background:
    radial-gradient(900px 420px at 50% -8%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--bg);
  color: var(--fg);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { position: relative; max-width: 900px; margin: 0 auto; }

/* ---------- language selector ---------- */
.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;
}

.lang-select {
  position: absolute;
  top: -6px;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
}
.guide-link {
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
}
.guide-link:hover { color: var(--accent); }
.lang-select select {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 27px 6px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--fg);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.lang-select select:hover { border-color: var(--accent); }
.lang-select select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- header ---------- */
.hero { margin-bottom: 26px; }

h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -.02em;
}
.logo {
  width: 36px;
  height: 24px;
  flex: none;
  color: var(--accent);
}
.logo circle { fill: currentColor; }

.sub { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; }

.bar {
  display: flex;
  gap: 8px;
  padding: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent), var(--shadow);
}

#url {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font: 14px/1.4 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
#url::placeholder { color: var(--muted); opacity: .72; }

button { font: inherit; }

.btn-primary {
  padding: 0 22px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: default; filter: none; }

.opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12.5px;
}
.opts label { display: flex; align-items: center; gap: 7px; }
.opts input[type="number"] {
  width: 66px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 12.5px;
}
.opts input[type="checkbox"] { accent-color: var(--accent); }

/* ---------- history ---------- */
.history {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 15px;
}
.history[hidden] { display: none; }
.h-label { color: var(--muted); font-size: 12px; }
.chip-btn {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.chip-btn:hover { color: var(--fg); border-color: var(--accent); }

/* ---------- status / error ---------- */
.status {
  display: flex;
  align-items: center;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}
.status[hidden] { display: none; }

.spinner {
  width: 14px;
  height: 14px;
  margin-right: 9px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.error {
  margin-top: 22px;
  padding: 12px 15px;
  border: 1px solid color-mix(in srgb, var(--err) 35%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--err) 9%, var(--panel));
  color: var(--err);
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.error[hidden] { display: none; }

/* ---------- summary ---------- */
.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 30px;
  margin-bottom: 22px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: rise .35s ease both;
}
.summary .k {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.summary b { font-size: 16px; font-variant-numeric: tabular-nums; }
.summary .final { flex: 1; min-width: 240px; }
.summary .final a {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  color: var(--final);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  text-decoration: none;
}
.summary .final a:hover { text-decoration: underline; }

.ghost {
  margin-left: 8px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ghost:hover { color: var(--fg); border-color: var(--accent); }

.full-url-box { margin-top: 0; margin-bottom: 24px; }
.full-url { margin-bottom: 10px; }
.full-actions { display: flex; justify-content: flex-end; gap: 8px; }
.full-actions .ghost { margin-left: 0; display: inline-flex; align-items: center; }
.link-btn { text-decoration: none; }

/* ---------- chain ---------- */
.chain { list-style: none; margin: 0; padding: 0; }

.hop {
  position: relative;
  padding-left: 38px;
  padding-bottom: 16px;
  animation: rise .35s ease both;
}
.hop:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 31px;
  bottom: -2px;
  width: 2px;
  background: var(--line);
}

.dot {
  position: absolute;
  left: 0;
  top: 15px;
  z-index: 1;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 2px solid var(--http);
  border-radius: 50%;
  background: var(--panel);
  color: var(--http);
  font-size: 11px;
  font-weight: 700;
}
.dot.js { border-color: var(--js); color: var(--js); }
.dot.meta { border-color: var(--meta); color: var(--meta); }
.dot.final { border-color: var(--final); color: var(--final); }
.dot.loop { border-color: var(--loop); color: var(--loop); }
.dot.err { border-color: var(--err); color: var(--err); }

.card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.badge {
  padding: 3px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.http { color: var(--http); }
.badge.js { color: var(--js); }
.badge.meta { color: var(--meta); }
.badge.final { color: var(--final); }
.badge.loop { color: var(--loop); }
.badge.err { color: var(--err); }

.ms {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.label { margin: 8px 0 4px; color: var(--muted); font-size: 12px; }

.url {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
}
.url a { color: inherit; text-decoration: none; }
.url a:hover { text-decoration: underline; }
.url.target { border-color: color-mix(in srgb, var(--final) 40%, var(--line)); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--code);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
}

.note { margin-top: 8px; color: var(--loop); font-size: 12.5px; }

details { margin-top: 10px; }
summary {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
details table { margin-top: 6px; }

/* ---------- tables ---------- */
.params {
  margin-top: 30px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: rise .35s ease both;
}
.params[hidden] { display: none; }
.params h2 { margin: 0 0 12px; font-size: 14.5px; }
.params .muted { color: var(--muted); font-size: 12.5px; font-weight: 400; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 500; }
tr:last-child th, tr:last-child td { border-bottom: 0; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }

/* ---------- homepage guide ---------- */
.home-guide {
  margin-top: 52px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}
.home-guide-eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.home-guide h2 {
  margin: 0 0 10px;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: -.01em;
}
.home-guide-lead {
  max-width: 74ch;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}
.home-guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 34px;
}
.home-guide-card {
  padding: 17px 19px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.home-guide-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
}
.home-guide-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}
.home-guide-card li { margin-bottom: 8px; }
.home-guide-card li:last-child { margin-bottom: 0; }
.home-guide-card strong {
  color: var(--fg);
  font-weight: 600;
}
.home-guide-card span { color: var(--muted); }

.home-faq h2 {
  margin: 0 0 6px;
  font-size: 23px;
}
.faq-item {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}
.faq-item h3 {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.45;
}
.faq-item p {
  max-width: 78ch;
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.72;
}
.home-guide-more { margin: 24px 0 0; }
.home-guide-more a {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.home-guide-more a:hover { text-decoration: underline; }

footer {
  margin-top: 34px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }

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

@media (max-width: 640px) {
  body { padding: 32px 14px 48px; }
  .lang-select {
    position: static;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
  }
  h1 { font-size: 24px; }
  .bar { flex-direction: column; padding: 8px; }
  .btn-primary { width: 100%; padding: 12px; }
  .hop { padding-left: 32px; }
  .dot { left: 2px; width: 22px; height: 22px; top: 17px; }
  .hop:not(:last-child)::before { left: 13px; }
  .summary { gap: 14px 22px; }
  .home-guide { margin-top: 40px; padding-top: 28px; }
  .home-guide h2, .home-faq h2 { font-size: 20px; }
  .home-guide-grid { grid-template-columns: 1fr; }
}
