/* ---------- Tokens（红/珊瑚渐变 + 白卡片 + 深色最佳路线卡） ---------- */
:root{
  --red: #F5343F;
  --red-dark: #D81F2A;
  --red-deep: #B81620;
  --coral: #F5636C;
  --pink-soft: #FBD9DB;
  --page-bg: #FFF6F6;
  --page-bg-2: #FFFFFF;

  --card-white: #FFFFFF;
  --text-dark: #201B1F;
  --text-gray: #948C93;
  --text-gray-2: #C2B9BF;
  --border: #F1E1E1;

  --entry-bg: #FDEEEF;
  --entry-icon-a: #FF8A93;
  --entry-icon-b: #FFC2C6;

  --best-bg-1: #1C1B27;
  --best-bg-2: #23222F;

  --orange: #FF5B3D;
  --orange-2: #FF3B30;
  --gold: #FFB300;

  --green: #22B573;
  --green-bg: #E5F8ED;
  --ok: #FF9A3D;
  --ok-bg: #FFF1E1;
  --bad: #A199A0;
  --bad-bg: #F1ECEE;

  --blue-tag-bg: #E8F1FF;
  --blue-tag-text: #3E7FDE;

  --font-cjk: "PingFang SC","Hiragino Sans GB","Microsoft YaHei","Segoe UI",system-ui,-apple-system,sans-serif;
  --font-mono: ui-monospace,"SF Mono","Cascadia Code","Consolas","Roboto Mono",monospace;

  --radius-l: 26px;
  --radius-m: 18px;
  --radius-s: 12px;
  --shadow-card: 0 14px 34px -20px rgba(32,20,24,.18);
  --shadow-card-hover: 0 20px 44px -18px rgba(32,20,24,.24);
  --shadow-best: 0 24px 54px -22px rgba(28,27,39,.55);
}

@media (prefers-color-scheme: dark){
  :root{
    --page-bg: #150E10; --page-bg-2: #1B1215;
    --card-white: #241A1D;
    --text-dark: #F3E9EA; --text-gray: #B29FA2; --text-gray-2: #7C6669;
    --border: #3A2528;
    --entry-bg: #2E1D20;
    --green-bg: rgba(34,181,115,.15); --ok-bg: rgba(255,154,61,.15); --bad-bg: rgba(161,153,160,.15);
    --blue-tag-bg: rgba(62,127,222,.18);
    --shadow-card: 0 14px 34px -20px rgba(0,0,0,.55);
    --shadow-card-hover: 0 20px 44px -18px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"]{
  --page-bg: #150E10; --page-bg-2: #1B1215; --card-white: #241A1D;
  --text-dark: #F3E9EA; --text-gray: #B29FA2; --text-gray-2: #7C6669; --border: #3A2528;
  --entry-bg: #2E1D20;
  --green-bg: rgba(34,181,115,.15); --ok-bg: rgba(255,154,61,.15); --bad-bg: rgba(161,153,160,.15);
  --blue-tag-bg: rgba(62,127,222,.18);
  --shadow-card: 0 14px 34px -20px rgba(0,0,0,.55);
  --shadow-card-hover: 0 20px 44px -18px rgba(0,0,0,.6);
}
:root[data-theme="light"]{
  --page-bg: #FFF6F6; --page-bg-2: #FFFFFF; --card-white: #FFFFFF;
  --text-dark: #201B1F; --text-gray: #948C93; --text-gray-2: #C2B9BF; --border: #F1E1E1;
  --entry-bg: #FDEEEF;
  --green-bg: #E5F8ED; --ok-bg: #FFF1E1; --bad-bg: #F1ECEE;
  --blue-tag-bg: #E8F1FF;
  --shadow-card: 0 14px 34px -20px rgba(32,20,24,.18);
  --shadow-card-hover: 0 20px 44px -18px rgba(32,20,24,.24);
}

*,*::before,*::after{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  background: var(--page-bg);
  color: var(--text-dark);
  font-family: var(--font-cjk);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a{ color: inherit; text-decoration: none; }
ul{ margin:0; padding:0; list-style:none; }
h1,h2,h3{ margin:0; text-wrap: balance; }
button{ font-family: inherit; }
code{ font-family: var(--font-mono); }
:focus-visible{ outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }

.container{ max-width: 1160px; margin: 0 auto; padding: 0 20px; }
@media (min-width: 768px){ .container{ padding: 0 36px; } }
@media (min-width: 1180px){ .container{ padding: 0 20px; } }

/* ---------- 顶部导航 ---------- */
.topnav{
  position: sticky; top:0; z-index: 50;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  padding-top: env(safe-area-inset-top);
}
.topnav-inner{ display:flex; align-items:center; justify-content:space-between; gap:16px; padding: 10px 0; }
.brand{ display:flex; align-items:center; min-width:0; }
.brand-mark{
  flex:none; width:110px; height:30px; overflow:hidden;
  display:flex; align-items:center; justify-content:flex-start; color:#fff;
}
.brand-mark img{ display:block; max-width:100%; max-height:100%; object-fit:contain; }
.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;
}
.topnav-actions{ display:flex; align-items:center; gap:8px; flex:none; }
.btn-kefu{
  display:flex; align-items:center; gap:6px; height:32px; padding:0 13px;
  background: rgba(255,255,255,.14); color:#fff; font-weight:700; font-size:12.5px;
  border-radius:999px; white-space:nowrap;
}
.btn-kefu svg{ width:14px; height:14px; flex:none; }
.btn-app{
  display:flex; align-items:center; gap:6px; height:32px; padding:0 15px;
  background:#fff; color: var(--red); font-weight:800; font-size:12.5px;
  border-radius:999px; white-space:nowrap;
}
.btn-app svg{ width:13px; height:13px; }

/* ---------- Banner 区（检测网址） ---------- */
.banner{
  background: linear-gradient(180deg, var(--red-dark) 0%, var(--red) 30%, var(--coral) 68%, var(--pink-soft) 100%);
  padding: 16px 0 20px;
}
.banner-card{
  max-width: 980px; margin: 0 auto;
  background: var(--card-white); border-radius: var(--radius-m);
  padding: 18px 22px 16px; box-shadow: var(--shadow-card);
}
.banner-card-head{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.banner-card-title{
  display:flex; align-items:center; gap:8px;
  font-size:15.5px; font-weight:800; color: var(--text-dark); white-space:nowrap;
}
.banner-card-title svg{ width:17px; height:17px; flex:none; color: var(--red); }
.banner-card-sub{ font-size:12px; color: var(--text-gray); white-space:nowrap; }

.entry-grid{ margin-top:12px; display:grid; grid-template-columns: repeat(3, 1fr); gap:10px; }
.entry-item{
  position:relative; background: var(--entry-bg); border-radius: 13px;
  padding: 10px 8px 8px; display:flex; align-items:center; gap:8px;
  transition: transform .15s ease, box-shadow .15s ease;
}
@media (hover:hover) and (pointer:fine){
  .entry-item:hover{ transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
}
.entry-badge{
  position:absolute; top:-6px; left:8px;
  background: var(--red); color:#fff; font-size:9.5px; font-weight:800;
  padding: 2px 7px; border-radius: 999px; letter-spacing:.2px;
}
.entry-icon{
  flex:none; width:30px; height:30px; border-radius:50%;
  background: radial-gradient(circle at 32% 28%, var(--entry-icon-b), var(--entry-icon-a));
  display:flex; align-items:center; justify-content:center; color:#fff;
}
.entry-icon svg{ width:15px; height:15px; }
.entry-body{ flex:1; min-width:0; display:flex; flex-direction:column; gap:5px; }
.entry-url{ font-size:11.5px; font-weight:700; color: var(--text-dark); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-variant-numeric: tabular-nums; }
.btn-copy-entry{
  display:flex; align-items:center; justify-content:center; gap:4px; height:30px; padding:0 11px; align-self:flex-start;
  background:#fff; color: var(--red); border:1.2px solid var(--red);
  border-radius:999px; font-size:10.5px; font-weight:700; cursor:pointer;
}
.btn-copy-entry svg{ width:10px; height:10px; }
.btn-copy-entry:hover{ background: var(--red); color:#fff; }

.banner-foot{
  margin-top:8px; padding-top:6px; border-top:1px solid var(--border);
  display:flex; flex-direction:column; gap:6px;
}
.banner-tip{ display:flex; align-items:center; gap:6px; font-size:11.5px; font-weight:700; color: var(--orange-2); line-height:1.2; }
.banner-tip svg{ width:13px; height:13px; flex:none; }
.kefu-inline{
  display:flex; align-items:center; gap:6px; font-size:11.5px; color: var(--text-gray);
  border:1px solid var(--border); border-radius:12px; padding:8px 12px; background: var(--card-white);
  width:100%; box-sizing:border-box;
}
.kefu-inline svg{ width:13px; height:13px; color: var(--red); flex:none; }
.kefu-inline a{ color: var(--text-dark); font-weight:600; }

/* ---------- 主体区 ---------- */
.main{ padding: 16px 0 0; background: var(--page-bg-2); }
.section-head{ display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.section-head-text h2{ display:flex; align-items:center; gap:7px; font-size:16.5px; font-weight:800; }
.section-head-text h2 svg{ width:16px; height:16px; color: var(--orange-2); flex:none; }
.section-head-text p{ margin:2px 0 0 23px; font-size:11px; font-weight:600; color: var(--orange-2); }
.btn-refresh{
  display:flex; align-items:center; gap:6px; height:34px; padding:0 15px;
  background: var(--entry-bg); color: var(--red); border:1px solid var(--pink-soft);
  border-radius:999px; font-size:12px; font-weight:700; cursor:pointer; flex:none;
}
.btn-refresh svg{ width:12px; height:12px; }
.btn-refresh.is-spinning svg{ animation: spin .8s linear infinite; }
@keyframes spin{ to{ transform: rotate(360deg); } }

.best-card{
  position:relative; overflow:hidden; margin-top:12px;
  background: linear-gradient(120deg, var(--best-bg-1), var(--best-bg-2));
  border-radius: var(--radius-m); padding: 10px 14px; box-shadow: var(--shadow-best);
  display:flex; flex-direction:column; gap:8px;
}
.best-top{ display:flex; align-items:center; gap:10px; }
.best-foot{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.best-icon{
  flex:none; width:34px; height:34px; border-radius:50%;
  background: radial-gradient(circle at 32% 26%, #FFB37A, var(--orange-2));
  display:flex; align-items:center; justify-content:center; color:#fff;
  box-shadow: 0 8px 18px -8px rgba(255,91,61,.7);
}
.best-icon svg{ width:16px; height:16px; }
.best-body{ flex:1; min-width:0; }
.best-crown{ display:inline-flex; align-items:center; gap:4px; font-size:10px; font-weight:800; color: var(--gold); }
.best-crown svg{ width:10px; height:10px; }
.best-title-row{ display:flex; align-items:center; gap:8px; margin-top:1px; flex-wrap:wrap; }
.best-title{ color:#fff; font-size:14.5px; font-weight:800; }
.best-tag{
  font-size:10px; font-weight:700; padding:2px 8px; border-radius:999px;
  background: rgba(255,255,255,.12); color: rgba(255,255,255,.85);
}

.best-latency-block{ flex:none; text-align:left; }
.best-metrics{ display:flex; align-items:baseline; gap:5px; justify-content:flex-start; }
.best-latency{ font-family: var(--font-mono); font-weight:800; font-size:28px; line-height:1; color: var(--orange); font-variant-numeric: tabular-nums; }
.best-unit{ font-family: var(--font-mono); font-size:11.5px; color: rgba(255,255,255,.55); font-weight:700; }
.best-fast-tag{
  margin-top:3px; display:inline-flex; align-items:center; gap:3px;
  font-size:10px; font-weight:800; color: var(--orange);
  background: rgba(255,91,61,.15); padding:2px 8px; border-radius:999px;
}
.best-fast-tag svg{ width:10px; height:10px; }

.btn-enter{
  flex:none; display:flex; align-items:center; gap:5px;
  height:44px; padding:0 20px; border-radius:999px; border:none; cursor:pointer;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  color:#fff; font-weight:800; font-size:13.5px;
  box-shadow: 0 10px 20px -10px rgba(255,59,48,.65);
}
.btn-enter svg{ width:14px; height:14px; }
.btn-enter:disabled{ opacity:.55; cursor:not-allowed; }

@media (min-width: 561px){
  .best-card{ flex-direction:row; align-items:center; padding:10px 18px; }
  .best-top{ display:contents; }
  .best-foot{ display:contents; }
  .best-latency-block{ text-align:right; margin-left:auto; }
  .best-metrics{ justify-content:flex-end; }
}

/* ---------- 其他线路 ---------- */
.other-nodes{ padding: 14px 0 0; background: var(--page-bg-2); }
.divider{ display:flex; align-items:center; gap:12px; color: var(--text-gray-2); font-size:11.5px; font-weight:600; }
.divider::before,.divider::after{ content:""; flex:1; height:1px; background: var(--border); }

.node-grid{
  margin-top:10px; display:grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap:8px;
}
.node-row{
  background: var(--card-white); border:1px solid var(--border);
  border-radius: 13px; padding: 8px 10px 8px 12px;
  display:flex; flex-direction:column; gap:6px;
  transition: transform .15s ease, box-shadow .15s ease;
  cursor:pointer;
}
@media (hover:hover) and (pointer:fine){
  .node-row:hover{ transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
}
.node-row.is-bad{ opacity:.68; cursor:default; }
.node-row-top{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.node-row-bottom{ display:flex; align-items:center; gap:8px; }
.node-latency-num{ flex:none; font-family: var(--font-mono); font-size:15px; font-weight:800; font-variant-numeric: tabular-nums; }
.node-latency-num.c-good{ color: var(--green); }
.node-latency-num.c-ok{ color: var(--ok); }
.node-latency-num.c-bad{ color: var(--bad); }
.node-latency-num span{ font-size:10px; font-weight:600; color: var(--text-gray); margin-left:1px; }
.node-tag{ flex:none; font-size:10.5px; font-weight:700; padding:3px 9px; border-radius:999px; background: var(--blue-tag-bg); color: var(--blue-tag-text); }
.node-title{ flex:1; min-width:0; font-size:13px; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.node-status{ flex:none; display:flex; align-items:center; gap:4px; font-size:11px; font-weight:700; padding:5px 10px; border-radius:999px; }
.node-status svg{ width:11px; height:11px; }
.status-good{ background: var(--green-bg); color: var(--green); }
.status-ok{ background: var(--ok-bg); color: var(--ok); }
.status-bad{ background: var(--bad-bg); color: var(--bad); }
.btn-retest{
  flex:none; width:32px; height:32px; margin-left:auto; border-radius:50%; border:1px solid var(--border);
  background:none; color: var(--text-gray); display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.btn-retest svg{ width:13px; height:13px; }
.btn-retest:hover{ border-color: var(--red); color: var(--red); }
.btn-retest.is-spinning svg{ animation: spin .8s linear infinite; }

@media (min-width: 561px){
  .node-row{ flex-direction:row; align-items:center; gap:10px; padding: 8px 10px 8px 12px; }
  .node-row-top, .node-row-bottom{ display:contents; }
  .node-latency-num{ order:1; width:44px; }
  .node-tag{ order:2; }
  .node-title{ order:3; }
  .node-status{ order:4; }
  .btn-retest{ order:5; margin-left:0; }
}

.empty-state{
  padding: 22px 16px; text-align:center; color: var(--text-gray);
  background: var(--card-white); border:1px dashed var(--border); border-radius: var(--radius-m);
  font-size:13px;
}

.site-footer{
  margin-top: 16px; padding: 12px 0 calc(16px + env(safe-area-inset-bottom));
  text-align:center; color: var(--text-gray-2); font-size:11px; background: var(--page-bg-2);
}

.toast{
  position: fixed; left:50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px);
  background: var(--text-dark); color: var(--page-bg);
  padding: 11px 18px; border-radius: 999px; font-size:13.5px; font-weight:700;
  box-shadow: 0 12px 28px -10px rgba(0,0,0,.4);
  opacity:0; pointer-events:none; transition: opacity .2s ease, transform .2s ease;
  z-index: 100; white-space:nowrap;
}
.toast.is-visible{ opacity:1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 560px){
  .container{ padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .topnav-actions .btn-kefu-text{ display:none; }
  .btn-kefu{ width:38px; height:38px; padding:0; justify-content:center; border-radius:50%; }
  .banner-card{ padding: 14px 14px 12px; border-radius: 18px; }
  .banner-card-head{ flex-direction:column; align-items:flex-start; gap:2px; }
  .banner-card-sub{ white-space:normal; }
  .entry-grid{ grid-template-columns: repeat(3, 1fr); gap:7px; }
  .entry-item{ flex-direction:column; align-items:center; text-align:center; padding:14px 4px 10px; }
  .entry-body{ align-items:center; }
  .entry-url{ font-size:10.5px; white-space:normal; word-break:break-all; }
  .btn-copy-entry{ align-self:center; }
  .node-grid{ grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce){
  .btn-refresh.is-spinning svg, .btn-retest.is-spinning svg{ animation: none; }
  .entry-item, .node-row{ transition: none; }
}
