:root {
  --bg-color: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: rgba(0, 0, 0, 0.08); /* 极细边框 */
  --card-bg: #ffffff;
}

[data-theme="dark"] {
  --bg-color: #111827;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --border-color: rgba(255, 255, 255, 0.1);
  --card-bg: #1f2937;
}

/* 全局交互优化：移除蓝色阴影与点击高亮 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击蓝色背景 */
}

a, button, div, span {
    outline: none !important;
    -webkit-user-select: none;
    user-select: none;
}
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg-color); color: var(--text-primary); padding-top: 80px; -webkit-font-smoothing: antialiased; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }

/* 导航相关 */
/* 导航重塑：保持扁平的独立大胶囊 */
.navbar {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2.5rem);
  max-width: 1280px;
  height: 52px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 40px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.nav-content { width: 100%; padding: 0 6px; height: 52px; display: flex; align-items: center; }

.navbar-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-links-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.nav-item {
  text-decoration: none;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 1rem;
  height: 36px; /* 压扁 */
  display: flex;
  align-items: center;
  border-radius: 20px;
  transition: all 0.2s;
  white-space: nowrap;
}

/* 激活项的小胶囊背景 */
.active-pill {
  background: #f3f4f6;
  color: var(--text-primary) !important;
  font-weight: 800;
}

/* 右侧圆形切换按钮 */
.nav-theme-circle {
  width: 36px;
  height: 36px;
  background: #f3f4f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  margin-right: 4px;
}

[data-theme="dark"] .active-pill,
[data-theme="dark"] .nav-theme-circle {
  background: #1f2937;
}

[data-theme="dark"] .navbar,
[data-theme="dark"] .mobile-nav-card {
  background: var(--card-bg); /* 夜晚模式也使用实色背景 */
}

/* 移动端独立菜单卡片 (衔接式设计) */
.mobile-nav-card {
  display: none; /* 默认隐藏 */
  position: absolute;
  top: 60px; /* 位于 navbar 下方 */
  left: 0;
  width: 100%;
  background: var(--card-bg); /* 改为实色背景 */
  border: 1px solid var(--border-color);
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); /* 增强阴影 */
  padding: 0.75rem;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

/* 展现动画 */
.navbar.is-open .mobile-nav-card {
  display: flex;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-card-item {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 0.85rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 16px;
  transition: background 0.2s;
}

.nav-card-item.active {
  background: var(--card-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .nav-card-item.active { 
  background: #1f2937; 
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav-card-item:active {
  background: #f3f4f6;
}

.navbar.is-open #menu-arrow { transform: rotate(180deg); transition: transform 0.3s; }

/* 移动端逻辑 */
.desktop-only { display: flex; }
.mobile-only { display: none; }

@media (max-width: 1024px) {
  .desktop-only { display: none; }
  .mobile-only { display: flex; }
  .nav-links-wrapper { flex: 1; } /* 关键：拉伸链接区域 */
  .navbar { top: 1rem; width: calc(100% - 1.5rem); }
}
.nav-links a { text-decoration: none; color: var(--text-secondary); margin-right: 24px; font-size: 0.875rem; font-weight: 500; }
.nav-links a.active { color: var(--text-primary); font-weight: 700; }

/* 核心布局网格 */
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.big-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.04); display: flex; flex-direction: column; }
.card-inner { padding: 2.5rem; flex: 1; }

/* 左侧主卡片细节重组 */
.flag-wrapper { position: absolute; top: 2rem; right: 2rem; }
.field { margin-bottom: 1.25rem; }
.field label { font-size: 0.8rem; color: var(--text-muted); display: block; margin-bottom: 0.25rem; font-weight: 500; }
.field-val { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
.ip-main-val { font-family: 'JetBrains Mono', monospace; font-size: 1.15rem; font-weight: 700; color: var(--text-primary); }
.val-with-icon { display: flex; align-items: center; gap: 10px; }
.copy-btn { color: var(--text-muted); cursor: pointer; }
.ip-divider { height: 1px; background: var(--border-color); margin: 1rem -2.5rem 2rem; }

.v6-empty-container { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 1rem; }
.v6-msg { font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 1rem; }
.btn-retry-modern { background: #fff; color: #111; border: 1px solid var(--border-color); padding: 6px 20px; border-radius: 12px; font-weight: 700; font-size: 0.85rem; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

/* ！！！右侧卡片由网格改为垂直列表模式 ！！！ */
.sources-card { display: flex; flex-direction: column; }
.sources-list { flex: 1; display: flex; flex-direction: column; }
.source-row { 
  padding: 1.25rem 2rem; 
  border-bottom: 1px solid var(--border-color); 
  display: flex; 
  flex-direction: column; 
  gap: 4px;
}
.source-row:last-child { border-bottom: none; }

.s-name-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.s-name { font-size: 0.875rem; font-weight: 700; color: var(--text-primary); }
.s-ip-row { display: flex; gap: 6px; font-family: 'JetBrains Mono'; font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.s-label { color: var(--text-muted); font-weight: 500; }
.s-loc-row { font-size: 0.8rem; color: var(--text-secondary); }

.card-footer-tip { padding: 0.75rem 2rem; background: var(--muted-bg); font-size: 0.75rem; color: var(--text-muted); border-top: 1px solid var(--border-color); }

/* 胶囊标签样式 */
.badge-cn, .badge-intl { padding: 1px 10px; border-radius: 100px; font-size: 11px; font-weight: 700; }
.badge-cn { background: #eef2ff !important; color: #4338ca !important; }
.badge-intl { background: #f0fdfa !important; color: #0d9488 !important; }

/* 连通性相关 */
.latency-container { padding: 2.5rem 2rem; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2.5rem; }
.latency-node { display: flex; flex-direction: column; gap: 8px; }
.node-top { display: flex; align-items:center; }
.node-title { font-weight:700; display:flex; align-items:center; gap:8px; font-size:0.9rem; }
.node-bottom { display: flex; align-items:center; gap: 10px; }
.latency-val { font-weight:800; font-size:0.9rem; width:45px; }
.dots-row { display: flex; gap: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #e5e7eb; transition: transform 0.2s, background-color 0.3s; }
.dot.pending { background: #f3f4f6; animation: pulse-gray 1.5s infinite; }
.dot.fast { background: #16a34a; box-shadow: 0 0 6px rgba(22, 163, 74, 0.2); }
.dot.med { background: #eab308; }
.dot.slow { background: #f97316; }
.dot.error { background: #ef4444; opacity: 0.5; }
.dot:hover { transform: scale(1.3); cursor: help; }

@keyframes pulse-gray {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* 隐私控制长条卡片 (深度校准) */
.toolbar-card {
  display: flex !important;
  flex-direction: row !important; /* 强制水平排列 */
  align-items: center !important; /* 强制垂直居中 */
  justify-content: space-between !important; /* 图标居左，开关居右 */
  padding: 0 2rem !important; 
  margin-top: 1.5rem;
  min-height: 48px;
}

.toolbar-left { color: var(--text-muted); display: flex; align-items: center; }

.toolbar-right { display: flex; gap: 24px; align-items: center; }

/* 现代 iOS 风格开关 */
.switch-group { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-label { font-size: 0.8rem; font-weight: 700; color: var(--text-primary); }

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #f3f4f6;
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 2px; bottom: 2px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

input:checked + .slider { background-color: #111; }
[data-theme="dark"] input:checked + .slider { background-color: #f9fafb; }
[data-theme="dark"] input:checked + .slider:before { background-color: #111; }

input:checked + .slider:before { transform: translateX(16px); }

@media (max-width: 1024px) {
  .hero-grid { grid-template-columns: 1fr; }
  .latency-container { grid-template-columns: repeat(2, 1fr); padding: 1.5rem 1.25rem; }
  .toolbar-right { gap: 16px; }
}

/* --- SPA Page Transitions --- */
.page-content {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.page-content.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* --- Split Tunnel Table --- */
.split-table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.split-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    text-align: left;
}

.split-table th {
    background: var(--card-bg);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.split-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.split-table tr:last-child td {
    border-bottom: none;
}

.split-table tr {
    transition: background 0.2s ease;
}

.split-table tr:hover td {
    background: rgba(var(--primary-rgb), 0.04);
}


.split-target-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}

.split-target-name {
    font-weight: 600;
    color: var(--text-primary);
}

.split-target-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: contain;
}

.split-flag-icon {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    border: 1px solid var(--border-color);
    margin-right: 8px;
    vertical-align: middle;
}

.split-cat-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.cat-国内 { background: rgba(0, 200, 210, 0.12); color: #00c8d2; }
.cat-国际 { background: rgba(50, 83, 220, 0.12); color: #3253dc; }
.cat-ai { background: rgba(116, 170, 156, 0.12); color: #74AA9C; }
.cat-nsfw { background: rgba(254, 98, 142, 0.12); color: #fe628e; }
.cat-crypto { background: rgba(0, 82, 255, 0.12); color: #0052ff; }
.cat-static { background: rgba(128, 128, 128, 0.12); color: var(--text-secondary); }

[data-theme="dark"] .cat-国内 { background: rgba(0, 200, 210, 0.2); }
[data-theme="dark"] .cat-国际 { background: rgba(50, 83, 220, 0.2); }
[data-theme="dark"] .cat-ai { background: rgba(116, 170, 156, 0.2); }
[data-theme="dark"] .cat-nsfw { background: rgba(254, 98, 142, 0.2); }
[data-theme="dark"] .cat-crypto { background: rgba(0, 82, 255, 0.2); }

.split-ip-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.split-loc-val {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.split-latency-cell {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
}

.split-avg-lat {
    font-weight: 700;
    font-size: 0.95rem;
}

/* 响应式调整 */
@media (max-width: 768px) {
    /* 移除之前的隐藏逻辑，现在手机端也显示地理位置 */
}

@media (max-width: 640px) {
  .card-inner { padding: 1.5rem; }
  .source-row { padding: 1rem 1.25rem; }
  
  /* 手机端全局字体缩小 (除导航栏) */
  h1 { font-size: 1.5rem !important; }
  header p { font-size: 0.8rem !important; }

  .field label { font-size: 0.7rem !important; }
  .ip-main-val { font-size: 1rem !important; }
  .field-val { font-size: 0.85rem !important; }
  
  .s-name { font-size: 0.8rem !important; }
  .s-ip-row { font-size: 0.75rem !important; }
  .s-loc-row { font-size: 0.75rem !important; }
  .badge-cn, .badge-intl { font-size: 10px !important; padding: 0 8px !important; }

  .node-title { font-size: 0.8rem !important; }
  .latency-val { font-size: 0.8rem !important; }
  
  /* 隐藏信息卡片优化 */
  .toolbar-card { 
      padding: 0.75rem 1rem !important; 
      min-height: auto; 
      flex-wrap: wrap; 
      gap: 12px;
  }
  .toolbar-left { display: none !important; }
  .toolbar-right { 
      flex: 1; 
      justify-content: space-between; 
      gap: 8px; 
      width: 100%;
  }
  .switch-group { gap: 6px; }
  .switch-label { font-size: 11px; white-space: nowrap; }

  /* 延迟探测矩阵优化 */
  .latency-container { 
      grid-template-columns: 1fr; 
      gap: 1.5rem; 
      padding: 1.5rem 1.25rem;
  }
  .latency-node {
      border-bottom: 1px solid var(--border-color);
      padding-bottom: 1rem;
  }
  .latency-node:last-child { border-bottom: none; padding-bottom: 0; }
  .latency-val { width: 40px; font-size: 0.85rem; }
}

/* CDN Grid Styles */
.cdn-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 3rem;
}

.cdn-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.cdn-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
    border-color: rgba(0,0,0,0.1);
}

.cdn-card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    width: 100%;
}

.cdn-logo {
    height: 24px;
    object-fit: contain;
    margin-bottom: 4px;
}

.cdn-card-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.cdn-node-pill {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    word-break: break-all;
}

.cdn-card-footer {
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
    width: 100%;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

[data-theme="dark"] .cdn-card {
    background: #18191a;
    border-color: #2f2f2f;
}

[data-theme="dark"] .cdn-card-footer {
    border-top-color: #2f2f2f;
}

@media (max-width: 1024px) {
    .cdn-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .cdn-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .cdn-card { padding: 1rem 0.75rem; }
    .cdn-node-pill { font-size: 0.9rem; }
    .cdn-card-footer { font-size: 0.7rem; }
}

@media (max-width: 480px) {
    .cdn-grid { gap: 0.5rem; }
    .cdn-card { padding: 0.75rem 0.5rem; border-radius: 8px; }
    .cdn-logo { height: 20px; }
    .cdn-card-name { font-size: 0.7rem; }
}
