:root {
  --bg: #121419;
  --card: #181c25;
  --card-2: #20252f;
  --card-3: #2a303c;
  --border: #2a303c;
  --border-soft: rgba(255, 255, 255, .055);
  --text: #e9ebf1;
  --text-2: #b8bfcc;
  --muted: #7b8392;
  --green: #34d18a;
  --green-soft: #1b3024;
  --amber: #ffb648;
  --amber-soft: #342a19;
  --red: #ff786c;
  --red-soft: #3b2321;
  --blue: #6b8afd;
  --blue-soft: #121a33;
  --violet: #a98bff;
  --btn-white: #f2f4f8;
  --btn-white-text: #12141a;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="light"] {
  --bg: #eef1f5;
  --card: #ffffff;
  --card-2: #f4f6f9;
  --card-3: #e9edf3;
  --border: #dfe4ec;
  --border-soft: rgba(20, 28, 45, .07);
  --text: #1b1e25;
  --text-2: #4b5260;
  --muted: #7c8493;
  --green: #12855c;
  --green-soft: #e3f5ec;
  --amber: #b5790e;
  --amber-soft: #fbf0dc;
  --red: #d0453d;
  --red-soft: #fdeae8;
  --blue: #3a63e8;
  --blue-soft: #e9effd;
  --violet: #7048c8;
  --btn-white: #2a3040;
  --btn-white-text: #ffffff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.wrap, .card, .score-right, .search { min-width: 0; max-width: 100%; }
.card > *, .score-right > * { min-width: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { width: min(1060px, calc(100% - 32px)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; top: 6px; z-index: 30; background: var(--card); color: var(--text); padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; }
.skip-link:focus { left: 12px; }
.small { font-size: 11.5px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.good { color: var(--green); }
.warn { color: var(--amber); }
.bad { color: var(--red); }

/* ------------------------------ top bar ------------------------------ */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 0 12px;
}
.brand-line { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.page-title {
  margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.5px;
  white-space: nowrap;
}
.page-title em { font-style: normal; color: var(--text); }
.brand-tag { font-size: 10.5px; color: var(--muted); letter-spacing: .6px; white-space: nowrap; }
.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search input {
  width: 210px; min-width: 0;
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 11px; font: inherit; font-family: var(--mono); font-size: 12px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(107,138,253,.16); }
.search input::placeholder { color: var(--muted); font-family: var(--font); }
.btn {
  cursor: pointer; border-radius: 9px; padding: 8px 14px;
  font: inherit; font-size: 12px; font-weight: 550; border: 1px solid transparent;
  white-space: nowrap; transition: opacity .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-ghost { background: var(--card-2); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-solid { background: var(--btn-white); color: var(--btn-white-text); }
.btn-solid:hover { opacity: .86; }
.btn[aria-busy="true"] { opacity: .55; pointer-events: none; }
.btn-blue { background: var(--blue); color: #fff; padding: 5px 10px; font-size: 10.5px; border-radius: 6px; }

/* ------------------------------ toolbar ------------------------------ */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 9px; }
.chip-btn {
  background: var(--card); color: var(--text-2); cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 11px; font: inherit; font-size: 11px;
}
.chip-btn:hover { color: var(--text); border-color: var(--muted); }
.badge { border-radius: 999px; padding: 3px 10px; font-size: 10.5px; font-weight: 600; }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.shot-hint { color: var(--muted); font-size: 11px; }
.status { margin: 0 0 9px; padding: 8px 12px; border-radius: 9px; background: var(--card); border: 1px solid var(--border); color: var(--text-2); font-size: 12px; }
.status.is-error { background: var(--red-soft); border-color: transparent; color: var(--red); }

/* -------------------------------- cards -------------------------------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; }
.stack > * + * { margin-top: 9px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.card-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 9px;
}
.card-title .ico { color: var(--blue); display: inline-flex; }
.card-title .spacer { flex: 1; }
.card-title .tail { font-size: 10.5px; font-weight: 400; color: var(--muted); }
.note { margin-top: 8px; color: var(--muted); font-size: 10.5px; line-height: 1.5; }

/* --------------------------- score panel --------------------------- */
.score-panel { display: grid; grid-template-columns: minmax(190px, 27%) 1fr; gap: 0; padding: 0; overflow: hidden; }
.score-left {
  background: var(--green-soft); border-right: 1px solid var(--border);
  padding: 12px 15px 11px; display: flex; flex-direction: column; justify-content: center;
}
.score-left.is-warn { background: var(--amber-soft); }
.score-left.is-bad { background: var(--red-soft); }
.score-cap { font-size: 10.5px; color: var(--text-2); }
.score-num { font-size: 46px; line-height: 1.05; font-weight: 700; letter-spacing: -2.6px; color: var(--green); font-variant-numeric: tabular-nums; margin: 3px 0 2px; }
.score-num.is-warn { color: var(--amber); }
.score-num.is-bad { color: var(--red); }
.score-num small { font-size: 13px; font-weight: 600; letter-spacing: 0; margin-left: 6px; }
.seg-bar { display: flex; gap: 3px; margin: 9px 0 7px; }
.seg-bar i { height: 5px; flex: 1; border-radius: 2px; opacity: .32; }
.seg-bar i.on { opacity: 1; }
.seg-bar .s0 { background: var(--red); }
.seg-bar .s1 { background: #ff9f45; }
.seg-bar .s2 { background: var(--amber); }
.seg-bar .s3 { background: #9ed34a; }
.seg-bar .s4 { background: var(--green); }
.seg-ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
.score-hint { color: var(--muted); font-size: 10px; margin-top: 8px; line-height: 1.45; }

.score-right { padding: 12px 15px; min-width: 0; }
.ip-line { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ip-main { font-family: var(--mono); font-size: 21px; font-weight: 650; letter-spacing: -.4px; word-break: break-all; }
.icon-btn {
  width: 24px; height: 24px; display: inline-grid; place-items: center;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: 11px; font-family: var(--mono); padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.geo-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; color: var(--text-2); font-size: 11.5px; }
.flag {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 14px; padding: 0 3px;
  background: var(--card-3); color: var(--text-2);
  border-radius: 3px; font: 600 9px var(--mono); letter-spacing: .3px;
}
.mini-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mini {
  background: var(--card-2); border: 1px solid var(--border-soft); border-radius: 9px;
  padding: 8px 10px; min-width: 0;
}
.mini-head { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.mini-ico { width: 18px; height: 18px; border-radius: 5px; display: inline-grid; place-items: center; font-size: 9px; font-weight: 700; flex: 0 0 auto; }
.mini-ico.g { background: rgba(52,209,138,.14); color: var(--green); }
.mini-ico.a { background: rgba(255,182,72,.14); color: var(--amber); }
.mini-ico.r { background: rgba(255,120,108,.14); color: var(--red); }
.mini-value { font-size: 14px; font-weight: 600; margin: 4px 0 3px; }
.mini-sub { color: var(--muted); font-size: 10px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.split-bar { display: flex; height: 5px; border-radius: 3px; overflow: hidden; margin: 7px 0 4px; background: var(--card-3); }
.split-bar i { display: block; height: 100%; }
.split-legend { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--muted); }

/* --------------------------- location card --------------------------- */
.loc-top { display: grid; grid-template-columns: 45% 1fr; gap: 10px; margin-bottom: 9px; }
.loc-map {
  position: relative; height: 100px; border-radius: 9px; overflow: hidden;
  background:
    radial-gradient(circle at 62% 44%, rgba(107,138,253,.22), transparent 42%),
    linear-gradient(160deg, #121a33, #172142 60%, #10182e);
  border: 1px solid rgba(107,138,253,.14);
}
.loc-map::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(140,165,230,.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140,165,230,.10) 1px, transparent 1px);
  background-size: 22px 18px;
}
.loc-map::after {
  content: ""; position: absolute; left: 58%; top: 44%; width: 10px; height: 10px;
  border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 5px rgba(107,138,253,.2), 0 0 14px rgba(107,138,253,.8);
}
.loc-coord { position: absolute; left: 8px; bottom: 7px; font: 9px var(--mono); color: rgba(190,205,245,.65); z-index: 1; }
.loc-map-label { position: absolute; right: 8px; top: 7px; font: 9px var(--mono); color: rgba(190,205,245,.5); z-index: 1; }
.loc-rows { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.loc-row .k { color: var(--muted); font-size: 10px; display: flex; align-items: center; gap: 5px; }
.loc-row .v { font-size: 12.5px; font-weight: 550; margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--card-2); border: 1px solid var(--border-soft); border-radius: 8px; padding: 7px 8px; min-width: 0; }
.tile .k { color: var(--muted); font-size: 9.5px; display: flex; align-items: center; gap: 4px; }
.tile .v { font-size: 11.5px; font-weight: 550; margin-top: 4px; word-break: break-all; }

/* ------------------------------ asn card ------------------------------ */
.asn-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.asn-num { font-family: var(--mono); font-size: 18px; font-weight: 700; }
.asn-org { color: var(--text-2); font-size: 11px; }
.asn-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 9px 0; }
.gradient-bar { height: 6px; border-radius: 4px; background: linear-gradient(90deg, var(--red), var(--amber) 45%, #9ed34a 72%, var(--green)); position: relative; }
.gradient-bar i { position: absolute; top: -4px; width: 2px; height: 14px; background: var(--text); border-radius: 2px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0 9px; font-size: 10px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend b { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.asn-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 11px; }
.asn-line:last-child { border-bottom: 0; }
.asn-up { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; background: var(--card-2); border-radius: 7px; padding: 5px 9px; margin-top: 5px; font-size: 10.5px; }
.asn-up .lab { color: var(--muted); }
.asn-up .a { font-family: var(--mono); color: var(--blue); font-weight: 600; }
.asn-up .n { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------- source strip --------------------------- */
.source-strip { display: grid; grid-template-columns: 108px repeat(4, minmax(0, 1fr)); gap: 7px; align-items: stretch; }
.strip-labels { display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; padding-bottom: 2px; }
.strip-labels span { color: var(--muted); font-size: 10.5px; }
.src-col { background: var(--card-2); border: 1px solid var(--border-soft); border-radius: 9px; padding: 8px; text-align: center; }
.src-logo { width: 18px; height: 18px; border-radius: 5px; display: inline-grid; place-items: center; font: 700 8.5px var(--mono); color: #fff; margin: 0 0 6px; flex: 0 0 auto; }
.src-col .src-logo { margin-inline: auto; }
.score-row .src-logo, .bl-item .src-logo { margin: 0; width: 16px; height: 16px; font-size: 8px; }
.src-name { font-size: 10.5px; color: var(--text-2); }
.src-val { font-size: 11px; font-weight: 600; margin-top: 5px; min-height: 16px; }
.src-val.plain { color: var(--muted); font-weight: 400; }
.tag { display: inline-block; border-radius: 4px; padding: 1px 6px; font-size: 9.5px; font-weight: 600; }
.tag.bad { background: var(--red-soft); color: var(--red); }
.tag.good { background: var(--green-soft); color: var(--green); }
.tag.warn { background: var(--amber-soft); color: var(--amber); }
.tag.plain { background: var(--card-3); color: var(--muted); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }

/* ----------------------- score list / detect list ----------------------- */
.score-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.score-row:last-child { border-bottom: 0; }
.score-row .left { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 0; }
.score-row .nm { font-size: 11.5px; }
.score-row .sub { color: var(--muted); font-size: 10px; }
.score-row .right { display: flex; align-items: center; gap: 7px; }
.score-meter-sm { width: 100%; height: 4px; border-radius: 3px; background: var(--card-3); grid-column: 1 / -1; overflow: hidden; }
.score-meter-sm i { display: block; height: 100%; border-radius: 3px; background: var(--green); }
.score-meter-sm i.warn { background: var(--amber); }
.score-meter-sm i.bad { background: var(--red); }
.detect-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.detect-row:last-child { border-bottom: 0; }
.detect-row .l { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 11.5px; }
.detect-row .l .di { width: 15px; height: 15px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--card-3); color: var(--muted); font-size: 9px; flex: 0 0 auto; }
.pill { display: inline-block; border-radius: 5px; padding: 2px 8px; font-size: 10px; font-weight: 600; background: var(--green-soft); color: var(--green); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.plain { background: var(--card-3); color: var(--muted); }

/* ---------------------------- blacklist ---------------------------- */
.alert-bar { display: flex; align-items: center; gap: 8px; border-radius: 8px; padding: 7px 10px; font-size: 11.5px; font-weight: 550; }
.alert-bar.amber { background: var(--amber-soft); color: var(--amber); margin-bottom: 7px; }
.alert-bar.green { background: var(--green-soft); color: var(--green); margin-bottom: 9px; }
.alert-bar .ab-ico { width: 16px; height: 16px; border-radius: 4px; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; background: rgba(255,255,255,.08); }
.bl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.bl-item { display: flex; align-items: center; gap: 6px; background: var(--card-2); border: 1px solid var(--border-soft); border-radius: 7px; padding: 6px 8px; font-size: 10px; min-width: 0; }
.bl-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bl-item .ck { color: var(--green); font-size: 11px; flex: 0 0 auto; }
.bl-item.off { opacity: .42; }
.bl-item.off .ck { color: var(--muted); }

/* ----------------------------- latency ----------------------------- */
.lat-title-row { display: grid; grid-template-columns: 30% 1fr; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: 10.5px; }
.lat-title-row span { display: flex; align-items: center; gap: 6px; }
.lat-row { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
.lat-cell { background: var(--card-2); border: 1px solid var(--border-soft); border-radius: 8px; padding: 6px 5px 0; min-height: 54px; display: flex; flex-direction: column; align-items: center; text-align: center; overflow: hidden; }
.lat-cell .place { display: flex; align-items: center; gap: 3px; justify-content: center; max-width: 100%; overflow: hidden; color: var(--muted); font-size: 9.5px; white-space: nowrap; }
.lat-cell .ms { font-size: 15px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.lat-cell .ms small { font-size: 9px; font-weight: 400; color: var(--muted); }
.lat-cell .bar { width: 100%; height: 3px; border-radius: 3px 3px 0 0; margin-top: auto; background: var(--card-3); }
.lat-cell .bar.good { background: var(--green); }
.lat-cell .bar.warn { background: var(--amber); }
.lat-cell .bar.bad { background: var(--red); }
.lat-cell.is-off { opacity: .55; }
.lat-tone-good { color: var(--green); }
.lat-tone-warn { color: var(--amber); }
.lat-tone-bad { color: var(--red); }
.lat-tone-plain { color: var(--muted); }

/* ------------------------------ about ------------------------------ */
.about { margin-top: 12px; }
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.about h3 { margin: 0 0 8px; font-size: 11.5px; color: var(--text-2); }
.about ul { margin: 0; padding-left: 16px; color: var(--muted); font-size: 10.5px; line-height: 1.65; }
.disclaimer { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); }
.site-footer { margin-top: 16px; padding: 12px 0 22px; color: var(--muted); font-size: 10.5px; }

/* ---------------------------- responsive ---------------------------- */
@media (max-width: 860px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .search input { flex: 1 1 auto; width: auto; }
  .grid-2 { grid-template-columns: 1fr; }
  .score-panel { grid-template-columns: 1fr; }
  .score-left { border-right: 0; border-bottom: 1px solid var(--border); }
  .source-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip-labels { display: none; }
  .bl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lat-title-row { grid-template-columns: 1fr; gap: 4px; }
  .lat-row { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .wrap { width: calc(100% - 20px); }
  .loc-top { grid-template-columns: 1fr; }
  .score-num { font-size: 44px; }
  .ip-main { font-size: 17px; }
  .lat-row { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lat-cell { padding-inline: 3px; }
  .lat-cell .place { font-size: 9px; gap: 2px; }
}
@media (max-width: 400px) {
  .mini-grid, .tiles, .asn-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
