:root,
[data-theme="light"] {
  --bg: #f3f1ec;
  --surface: #faf9f6;
  --elevated: #ffffff;
  --fg: #1c1916;
  --muted: #6f6a63;
  --subtle: #9a948b;
  --border: color-mix(in oklab, #1c1916 12%, transparent);
  --hairline: color-mix(in oklab, #1c1916 8%, transparent);
  --accent: #2c2a27;
  --accent-fg: #f6f4ef;
  --good: #3f6b52;
  --warn: #9a6b2f;
  --bad: #9a3f3a;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Sarasa Mono SC", Consolas, ui-monospace, monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 28px;
}

[data-theme="dark"] {
  --bg: #0c0c0e;
  --surface: #121214;
  --elevated: #18181b;
  --fg: #f4f1ea;
  --muted: #a3a099;
  --subtle: #73716c;
  --border: color-mix(in oklab, #f4f1ea 12%, transparent);
  --hairline: color-mix(in oklab, #f4f1ea 8%, transparent);
  --accent: #ece8df;
  --accent-fg: #121214;
  --good: #8fb89a;
  --warn: #d4b07a;
  --bad: #d08982;
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #0c0c0e;
    --surface: #121214;
    --elevated: #18181b;
    --fg: #f4f1ea;
    --muted: #a3a099;
    --subtle: #73716c;
    --border: color-mix(in oklab, #f4f1ea 12%, transparent);
    --hairline: color-mix(in oklab, #f4f1ea 8%, transparent);
    --accent: #ece8df;
    --accent-fg: #121214;
    --good: #8fb89a;
    --warn: #d4b07a;
    --bad: #d08982;
  }
}

@media (prefers-color-scheme: light) {
  [data-theme="auto"] {
    --bg: #f3f1ec;
    --surface: #faf9f6;
    --elevated: #ffffff;
    --fg: #1c1916;
    --muted: #6f6a63;
    --subtle: #9a948b;
    --border: color-mix(in oklab, #1c1916 12%, transparent);
    --hairline: color-mix(in oklab, #1c1916 8%, transparent);
    --accent: #2c2a27;
    --accent-fg: #f6f4ef;
    --good: #3f6b52;
    --warn: #9a6b2f;
    --bad: #9a3f3a;
  }
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; }
html { background: var(--bg); color: var(--fg); -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; }
button:not(:disabled) { cursor: pointer; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { text-wrap: pretty; }

.wrap {
  width: 100%;
  max-width: 1152px;
  min-width: 0;
  margin: 0 auto;
  padding: 32px 16px 48px;
  overflow-x: hidden;
}
@media (min-width: 640px) {
  .wrap { padding: 40px 24px 64px; }
}

.header {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--hairline);
}
@media (min-width: 640px) {
  .header { flex-direction: row; align-items: flex-end; justify-content: space-between; margin-bottom: 40px; }
}
.kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--subtle);
}
.header h1 {
  margin-top: 8px;
  font-size: clamp(2.25rem, 4vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.lede {
  max-width: 36rem;
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}
.header-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--elevated);
  color: var(--fg);
  font-size: 14px;
}
.btn:hover { background: var(--surface); }

.theme-switch {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--elevated);
}
.theme-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--subtle);
}
.theme-btn[aria-checked="true"] {
  background: var(--surface);
  color: var(--fg);
}

.stack { display: flex; flex-direction: column; gap: 24px; }

.panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
}
@media (min-width: 768px) { .panel { padding: 24px; } }

.panel-head { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
@media (min-width: 1024px) {
  .panel-head { flex-direction: row; align-items: flex-end; justify-content: space-between; }
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--subtle);
}
.panel h2 { margin-top: 8px; font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.sub { margin: 4px 0 0; font-size: 14px; color: var(--muted); }

.tabs {
  display: flex;
  width: 100%;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--elevated);
}
@media (min-width: 1024px) { .tabs { width: auto; } }
.tab {
  min-height: 40px;
  flex: 1;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}
@media (min-width: 1024px) { .tab { flex: none; } }
.tab.is-active { background: var(--accent); color: var(--accent-fg); }

.purity-grid { display: grid; gap: 24px; }
@media (min-width: 1024px) {
  .purity-grid { grid-template-columns: auto 1fr minmax(220px, 0.9fr); align-items: center; }
}

.ring { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-score { font-family: var(--font-mono); font-size: 30px; font-weight: 500; font-variant-numeric: tabular-nums; }
.ring-unit { margin-top: 2px; font-size: 12px; color: var(--subtle); }

.grade-title { margin: 4px 0 0; font-size: 30px; font-weight: 500; letter-spacing: -0.03em; }
.grade-kind { margin-left: 12px; font-size: 16px; font-weight: 400; color: var(--muted); }
.grade-hint { max-width: 36rem; margin: 12px 0 0; font-size: 14px; line-height: 1.6; color: var(--muted); }
.mono { font-family: var(--font-mono); }
.ip-line { margin: 16px 0 0; font-size: 14px; }
.geo-line { margin: 4px 0 0; font-size: 14px; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flag-box { padding: 8px 16px; border-radius: var(--radius-sm); background: var(--elevated); }
.flag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
}
.flag-row:last-child { border-bottom: 0; }
.flag-row span:first-child { color: var(--muted); }
.flag-on { color: var(--bad); }
.flag-off { color: var(--good); }
.flag-warn { color: var(--warn); }

.ip-grid { display: grid; gap: 16px; }
@media (min-width: 768px) { .ip-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.ip-card {
  display: flex;
  min-width: 0;
  min-height: 200px;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.ip-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
}
.ip-card h3 { font-size: 16px; font-weight: 500; }
.source { margin: 2px 0 0; font-size: 12px; color: var(--subtle); }
.dot { width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
.dot.is-ok { background: var(--good); animation: none; }
.dot.is-err { background: var(--bad); animation: none; }
.dot.is-load { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.ip-card__body {
  flex: 1;
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--elevated);
}
.ip-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ip-value { margin: 0; font-size: 18px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ip-value.is-err { color: var(--bad); }
.copy {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--subtle);
}
.copy:hover { background: var(--surface); color: var(--fg); }
.loc { margin: 8px 0 0; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { margin: 16px 0 0; font-size: 12px; color: var(--subtle); }

.latency-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .latency-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1280px) { .latency-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.lat-card {
  position: relative;
  isolation: isolate;
  display: flex;
  height: 80px;
  align-items: center;
  padding: 0 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.lat-card svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.7;
  pointer-events: none;
}
.lat-inner {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lat-name { margin: 0; font-size: 14px; font-weight: 500; }
.lat-tag { margin: 0; font-size: 12px; color: var(--subtle); }
.lat-ms { margin: 0; font-family: var(--font-mono); font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.tone-fast { color: var(--good); }
.tone-medium { color: var(--fg); }
.tone-slow { color: var(--warn); }
.tone-bad { color: var(--bad); }
.tone-pending { color: var(--subtle); }

.egress-list {
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--elevated);
}
.egress-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
}
.egress-item:last-child { border-bottom: 0; }
@media (min-width: 640px) {
  .egress-item { flex-direction: row; align-items: center; justify-content: space-between; }
}
.egress-left { display: flex; min-width: 0; align-items: center; gap: 12px; }
.badge { width: 96px; flex-shrink: 0; font-size: 14px; font-weight: 500; }
.egress-ip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.egress-right { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
@media (min-width: 640px) { .egress-right { justify-content: flex-end; } }
.egress-geo {
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--subtle);
}
@media (min-width: 640px) { .egress-geo { max-width: 20rem; } }
.egress-ms { width: 64px; text-align: right; font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; }

.faq details { padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  list-style: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.faq summary::-webkit-details-marker { display: none; }
.faq details[open] summary span { transform: rotate(45deg); }
.faq summary span { color: var(--subtle); transition: transform 150ms ease; }
.faq p { max-width: 48rem; margin: 8px 0 0; font-size: 14px; line-height: 1.65; color: var(--muted); }

.footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--subtle);
}

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