:root {
  color-scheme: light;
  --background: #f7f8fb;
  --surface: #fff;
  --surface-soft: #f2f5fb;
  --surface-hover: #f8faff;
  --text: #172033;
  --text-soft: #5f6b7d;
  --text-faint: #8791a2;
  --border: #e2e7f0;
  --border-strong: #cbd3df;
  --primary: #4f6ef7;
  --primary-strong: #3b57dc;
  --primary-soft: #edf1ff;
  --success: #168a61;
  --success-soft: #e7f8f1;
  --warning: #a96808;
  --warning-soft: #fff4db;
  --danger: #c43b4d;
  --danger-soft: #ffedf0;
  --shadow: 0 16px 40px rgb(29 45 84 / 8%);
  --shadow-small: 0 6px 18px rgb(29 45 84 / 7%);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sans: Inter, "SF Pro Text", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-family: var(--sans);
  background: var(--background);
  color: var(--text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #0b1020;
  --surface: #141b2d;
  --surface-soft: #10182a;
  --surface-hover: #192238;
  --text: #f3f6fc;
  --text-soft: #aab4c5;
  --text-faint: #7d899d;
  --border: #25304a;
  --border-strong: #34415e;
  --primary: #7088ff;
  --primary-strong: #8da0ff;
  --primary-soft: #202d59;
  --success: #35c78a;
  --success-soft: #12372e;
  --warning: #f0b35a;
  --warning-soft: #3a2c16;
  --danger: #ff7e8e;
  --danger-soft: #41222b;
  --shadow: 0 18px 48px rgb(0 0 0 / 25%);
  --shadow-small: 0 8px 22px rgb(0 0 0 / 20%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #0b1020;
    --surface: #141b2d;
    --surface-soft: #10182a;
    --surface-hover: #192238;
    --text: #f3f6fc;
    --text-soft: #aab4c5;
    --text-faint: #7d899d;
    --border: #25304a;
    --border-strong: #34415e;
    --primary: #7088ff;
    --primary-strong: #8da0ff;
    --primary-soft: #202d59;
    --success: #35c78a;
    --success-soft: #12372e;
    --warning: #f0b35a;
    --warning-soft: #3a2c16;
    --danger: #ff7e8e;
    --danger-soft: #41222b;
    --shadow: 0 18px 48px rgb(0 0 0 / 25%);
    --shadow-small: 0 8px 22px rgb(0 0 0 / 20%);
  }
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--background);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  padding-inline: clamp(1rem, 4vw, 3rem);
  background: radial-gradient(circle at 20% 0%, rgb(79 110 247 / 7%), transparent 26rem), var(--background);
  color: var(--text);
  transition: background-color 220ms ease, color 220ms ease;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { color: var(--primary-strong); }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: .75rem;
  left: .75rem;
  padding: .75rem 1rem;
  transform: translateY(-160%);
  border-radius: 10px;
  background: var(--text);
  color: var(--surface);
  font-size: .82rem;
  font-weight: 700;
}
.skip-link:focus { transform: translateY(0); }

.masthead, main, footer { width: min(76rem, 100%); margin-inline: auto; }
.masthead { display: flex; min-height: 5.5rem; align-items: center; gap: 1rem; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; flex: 0 0 auto; align-items: center; gap: .75rem; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #7890ff, var(--primary));
  box-shadow: 0 7px 18px rgb(79 110 247 / 24%);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
}
.brand-copy { display: grid; gap: .1rem; }
.brand-copy strong { font-size: 1.05rem; letter-spacing: .02em; }
.brand-copy span, .today { color: var(--text-soft); font-size: .72rem; }

.primary-nav {
  display: flex;
  align-items: center;
  gap: .2rem;
  margin-left: clamp(.5rem, 3vw, 2.5rem);
  padding: .3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
}
.nav-link {
  display: inline-flex;
  min-height: 2.25rem;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding-inline: 1rem;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
}
.nav-link:hover { color: var(--text); }
.nav-link.is-active { background: var(--surface); box-shadow: var(--shadow-small); color: var(--primary-strong); }
.nav-index { display: none; }

.header-actions { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.today { margin: 0; text-align: right; }
.theme-toggle {
  position: relative;
  display: grid;
  width: 3.25rem;
  height: 2rem;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-soft);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}
.theme-toggle::after {
  content: "";
  position: absolute;
  left: .2rem;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 7px rgb(22 32 51 / 16%);
  transition: transform 200ms ease;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }
.theme-toggle svg { position: absolute; z-index: 1; width: .9rem; height: .9rem; pointer-events: none; }
.sun-icon { left: .47rem; }
.moon-icon { right: .47rem; opacity: 0; }
:root[data-theme="dark"] .theme-toggle::after { transform: translateX(1.2rem); }
:root[data-theme="dark"] .sun-icon { opacity: 0; }
:root[data-theme="dark"] .moon-icon { opacity: 1; }

main { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.page-view[hidden] { display: none; }
.intro { padding-bottom: clamp(1.75rem, 4vw, 2.75rem); }
.kicker { margin: 0 0 .8rem; color: var(--primary-strong); font-size: .68rem; font-weight: 800; letter-spacing: .18em; }
.title-line { display: flex; align-items: center; gap: 1rem; }
h1 { max-width: 22ch; margin: 0; font-size: clamp(2.25rem, 5vw, 4.4rem); font-weight: 750; letter-spacing: -.055em; line-height: 1.08; }
.network-intro h1 { max-width: 20ch; }
.live-badge {
  display: inline-flex;
  min-height: 1.75rem;
  flex: 0 0 auto;
  align-items: center;
  gap: .45rem;
  padding-inline: .75rem;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: .72rem;
  font-weight: 750;
}
.live-badge > span { width: .42rem; height: .42rem; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 14%, transparent); }
.summary { max-width: 38rem; margin: 1rem 0 0; color: var(--text-soft); font-size: clamp(.95rem, 2vw, 1.05rem); line-height: 1.75; }

.overview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.overview-card {
  display: flex;
  min-height: 6.5rem;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}
.overview-icon, .panel-icon { display: grid; flex: 0 0 auto; place-items: center; color: var(--primary); }
.overview-icon { width: 2.75rem; height: 2.75rem; border-radius: 11px; background: var(--primary-soft); }
.overview-card-accent .overview-icon { background: var(--success-soft); color: var(--success); }
.overview-copy { display: grid; min-width: 0; gap: .35rem; }
.overview-copy strong { overflow: hidden; color: var(--text); font-size: 1.05rem; text-overflow: ellipsis; white-space: nowrap; }
.overview-copy span { overflow: hidden; color: var(--text-soft); font-size: .75rem; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }

.toolbar { display: flex; min-height: 3.75rem; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.status { margin: 0; color: var(--text-soft); font-size: .78rem; }
.status[data-tone="warning"] { color: var(--danger); }
.refresh-button {
  display: inline-flex;
  min-height: 2.5rem;
  flex: 0 0 auto;
  align-items: center;
  gap: .5rem;
  padding: .55rem .9rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: 700 .76rem/1 var(--sans);
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}
.refresh-button:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.refresh-button:disabled { cursor: wait; opacity: .55; }
.refresh-button.is-spinning svg { animation: spin 900ms linear infinite; }

.briefing, .network-panel { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { display: flex; min-height: 4rem; align-items: center; gap: .65rem; padding-inline: clamp(1.25rem, 3vw, 2rem); border-bottom: 1px solid var(--border); }
.panel-heading h2 { margin: 0; font-size: .95rem; }
.news-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; counter-reset: briefing; }
.news-list > li {
  position: relative;
  min-height: 7.25rem;
  padding: 1.5rem 1.5rem 1.5rem 4.6rem;
  border-bottom: 1px solid var(--border);
  counter-increment: briefing;
  font-size: clamp(.92rem, 1.6vw, 1.02rem);
  font-weight: 600;
  line-height: 1.7;
  transition: background-color 180ms ease;
}
.news-list > li:nth-child(odd) { border-right: 1px solid var(--border); }
.news-list > li:hover { background: var(--surface-hover); }
.news-list > li::before {
  content: counter(briefing);
  position: absolute;
  top: 1.45rem;
  left: 1.45rem;
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: .78rem;
  font-weight: 800;
}
.news-list .notice-item { grid-column: 1 / -1; border-right: 0; color: var(--text-soft); text-align: center; }
.news-list .notice-item::before, .news-list .skeleton::before { content: ""; }
.news-list .skeleton { display: flex; align-items: center; padding-left: 1.5rem; }
.skeleton span { display: block; width: min(100%, 29rem); height: 1rem; border-radius: 999px; background: linear-gradient(90deg, var(--surface-soft) 25%, var(--border) 50%, var(--surface-soft) 75%) 0 0 / 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }

.daily-note, .method-note { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: clamp(1rem, 4vw, 3rem); margin-top: 1.25rem; padding: clamp(1.25rem, 3vw, 1.75rem); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-soft); }
.daily-note-label { margin: 0; color: var(--primary-strong); font-size: .7rem; font-weight: 800; letter-spacing: .12em; }
.daily-note blockquote { margin: 0; color: var(--text); font-size: clamp(1rem, 2.5vw, 1.35rem); font-weight: 600; line-height: 1.65; }

.network-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.network-summary > div { display: grid; min-height: 7rem; align-content: center; gap: .5rem; padding: 1.25rem clamp(1rem, 3vw, 2rem); }
.network-summary > div + div { border-left: 1px solid var(--border); }
.network-summary span, .latency-host, .latency-state, .method-note p:last-child { color: var(--text-soft); font-size: .74rem; }
.network-summary strong { overflow: hidden; color: var(--text); font-size: clamp(1.05rem, 2vw, 1.35rem); text-overflow: ellipsis; white-space: nowrap; }
.latency-groups { min-height: 12rem; }
.region-group + .region-group { border-top: 1px solid var(--border); }
.region-heading { display: flex; min-height: 4rem; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem clamp(1.25rem, 3vw, 2rem); border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.region-heading h3 { margin: 0; font-size: .95rem; }
.region-heading span { color: var(--text-soft); font-size: .72rem; }
.latency-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.latency-card, .latency-placeholder { min-height: 11rem; padding: 1.35rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.latency-card:nth-child(3n), .latency-placeholder:nth-child(3n) { border-right: 0; }
.latency-card { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto 1fr auto; gap: .45rem 1rem; transition: background-color 180ms ease; }
.latency-card:hover { background: var(--surface-hover); }
.latency-name { margin: 0; font-size: 1rem; }
.latency-host { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latency-value { grid-row: 1 / span 2; grid-column: 2; color: var(--text); font-size: clamp(1.4rem, 2.5vw, 1.85rem); font-weight: 750; line-height: 1; text-align: right; }
.latency-value small { margin-left: .2rem; color: var(--text-soft); font-size: .6rem; font-weight: 600; }
.sample-results { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .3rem; align-self: end; margin: .7rem 0 0; padding: 0; list-style: none; }
.sample-result { display: grid; min-width: 0; gap: .2rem; justify-items: center; padding: .42rem .15rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-soft); color: var(--text-soft); text-align: center; }
.sample-result span { font-size: .55rem; line-height: 1; }
.sample-result strong { overflow: hidden; max-width: 100%; font-size: .68rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.sample-result[data-tone="fast"] { border-color: color-mix(in srgb, var(--success) 42%, var(--border)); background: var(--success-soft); color: var(--success); }
.sample-result[data-tone="normal"] { border-color: color-mix(in srgb, var(--warning) 42%, var(--border)); background: var(--warning-soft); color: var(--warning); }
.sample-result[data-tone="slow"], .sample-result[data-tone="error"] { border-color: color-mix(in srgb, var(--danger) 42%, var(--border)); background: var(--danger-soft); color: var(--danger); }
.latency-state { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: .45rem; }
.latency-state::before { content: ""; width: .45rem; height: .45rem; flex: 0 0 auto; border-radius: 50%; background: var(--text-faint); }
.latency-card[data-tone="fast"] .latency-state::before { background: var(--success); }
.latency-card[data-tone="normal"] .latency-state::before { background: var(--warning); }
.latency-card[data-tone="slow"] .latency-state::before, .latency-card[data-tone="error"] .latency-state::before { background: var(--danger); }
.latency-card[data-tone="error"] .latency-value { color: var(--text-soft); font-size: .9rem; }
.latency-placeholder { display: flex; grid-column: 1 / -1; align-items: center; justify-content: center; margin: 0; color: var(--text-soft); font-size: .8rem; }
.latency-placeholder.is-loading::before { content: ""; width: .8rem; height: .8rem; margin-right: .65rem; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 700ms linear infinite; }

.method-note p { margin: 0; }
.method-note p:last-child { max-width: 48rem; font-size: .8rem; line-height: 1.75; }
footer { display: flex; justify-content: space-between; gap: 1rem; padding-block: 1.5rem 2.5rem; border-top: 1px solid var(--border); color: var(--text-soft); font-size: .72rem; }
footer p { margin: 0; }
.notice { margin: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .brand-copy span, .today { display: none; }
  .overview-grid, .latency-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-card:last-child { grid-column: 1 / -1; }
  .latency-card:nth-child(3n) { border-right: 1px solid var(--border); }
  .latency-card:nth-child(2n) { border-right: 0; }
}

@media (max-width: 720px) {
  body { padding-inline: 1rem; }
  .masthead { flex-wrap: wrap; padding-block: .85rem; }
  .brand-copy strong { font-size: .95rem; }
  .primary-nav { order: 3; width: 100%; margin: 0; }
  .nav-link { flex: 1; }
  main { padding-block: 2.5rem; }
  .title-line { align-items: flex-start; flex-direction: column; gap: .8rem; }
  h1 { font-size: clamp(2.1rem, 11vw, 3.2rem); }
  .overview-grid, .news-list, .latency-grid { grid-template-columns: 1fr; }
  .overview-card:last-child { grid-column: auto; }
  .news-list > li:nth-child(odd), .latency-card, .latency-card:nth-child(2n), .latency-card:nth-child(3n) { border-right: 0; }
  .network-summary { grid-template-columns: 1fr; }
  .network-summary > div { min-height: 5.5rem; }
  .network-summary > div + div { border-top: 1px solid var(--border); border-left: 0; }
  .daily-note, .method-note { grid-template-columns: 1fr; gap: .75rem; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 420px) {
  .brand-mark { width: 2.5rem; height: 2.5rem; }
  .nav-link { padding-inline: .65rem; }
  .news-list > li { padding: 1.25rem 1.1rem 1.25rem 3.9rem; }
  .news-list > li::before { top: 1.2rem; left: 1.1rem; }
  .toolbar { align-items: flex-start; }
  .refresh-button span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
