/* ============================================================
   Claude AI IP 检测 —— 样式表
   设计基调：GitHub 风格中性色 + 暖橙强调色，支持浅色 / 深色双主题
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #f8f9fb;
  --bg-card: #ffffff;
  --bg-hover: #eef1f5;
  --text: #1a1a1a;
  --text-soft: #57606a;
  --text-muted: #8b949e;
  --border: #e1e4e8;
  --border-strong: #d8dce0;
  --accent: #cc785c;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
}

[data-theme='dark'] {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-card: #161b22;
  --bg-hover: #21262d;
  --text: #e6edf3;
  --text-soft: #c9d1d9;
  --text-muted: #8b949e;
  --border: #30363d;
  --border-strong: #444c56;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0d1117;
    --bg-soft: #161b22;
    --bg-card: #161b22;
    --bg-hover: #21262d;
    --text: #e6edf3;
    --text-soft: #c9d1d9;
    --text-muted: #8b949e;
    --border: #30363d;
    --border-strong: #444c56;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-y: scroll; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
.container { max-width: 1000px; margin: 0 auto; padding: 24px 20px; }

/* ---------- 导航 + 主题切换 ---------- */
.nav {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  font-size: 0.9em;
  align-items: center;
}
.nav a {
  color: var(--text-soft);
  text-decoration: none;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }

/* 「返回门户」按钮：在导航中作为主操作突出显示 */
.nav .portal-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.nav .portal-btn:hover { background: var(--accent); color: #fff; }
.nav .portal-btn.hidden { display: none; }
@media (max-width: 420px) {
  .nav .portal-btn { padding: 3px 9px; font-size: 0.92em; }
}

.ts-wrap { position: relative; margin-left: auto; }
.ts-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--bg-card);
  color: var(--text); display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.ts-btn:hover { background: var(--bg-hover); }
.ts-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.ts-menu {
  position: absolute; top: 34px; right: 0; min-width: 130px; z-index: 100;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 4px; display: none;
}
.ts-menu.open { display: block; }
.ts-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; background: transparent; border: none;
  color: var(--text); font: inherit; font-size: 14px;
  border-radius: 6px; cursor: pointer; text-align: left;
}
.ts-item:hover { background: var(--bg-hover); }
.ts-item[aria-current='true'] { background: var(--bg-hover); font-weight: 600; }

/* ---------- 标题区 ---------- */
h1 { font-size: 1.6em; font-weight: 700; letter-spacing: -0.2px; }
.ip-section-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 6px;
}
.desc { color: var(--text-soft); font-size: 0.9em; max-width: 720px; }

.ip-mask-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex-shrink: 0; }
.ip-mask-toggle-label { font-size: 0.82em; color: var(--text-soft); }
.ip-mask-toggle input { display: none; }
.ip-mask-toggle-slider {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--border-strong); position: relative; transition: background 0.2s;
}
.ip-mask-toggle-slider::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform 0.2s;
}
.ip-mask-toggle input:checked + .ip-mask-toggle-slider { background: var(--accent); }
.ip-mask-toggle input:checked + .ip-mask-toggle-slider::after { transform: translateX(18px); }

.ipv6-warn {
  display: none; margin-top: 14px; padding: 10px 14px;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px;
  color: #92400e; font-size: 0.85em;
}
[data-theme='dark'] .ipv6-warn { background: #3b2a12; border-color: #7c4a10; color: #fbbf24; }
.ipv6-warn.show { display: block; }

/* ---------- 出口 IP 卡片 ---------- */
.ip-dual {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin: 18px 0 22px;
}
.ip-hero {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; box-shadow: var(--shadow);
}
.ip-hero .label { font-size: 0.78em; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.ip-hero .ip-addr {
  font-size: 1.18em; font-weight: 700; margin-top: 8px;
  word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ip-hero .ip-geo { font-size: 0.8em; color: var(--text-muted); margin-top: 4px; min-height: 1.2em; }
.ip-hero.primary { border-color: var(--accent); }
.ip-hero a { color: inherit; text-decoration: none; }
.ip-hero a:hover { color: var(--accent); }
.flag {
  width: 24px; height: auto; border-radius: 2px;
  vertical-align: middle; margin-right: 5px;
}

/* ---------- 卡片布局 ---------- */
.cards {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-bottom: 14px;
}
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.card-title {
  font-size: 0.8em; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px;
}
.title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.title-sub { font-size: 0.7em; color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.mini-btn {
  font-size: 0.72em; color: var(--text-soft); cursor: pointer; font-weight: 400;
  padding: 2px 8px; border: 1px solid var(--border-strong);
  border-radius: 6px; flex-shrink: 0; text-transform: none; letter-spacing: 0;
}
.mini-btn:hover { background: var(--bg-hover); }

.risk-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border);
  font-size: 0.9em;
}
.risk-row:last-child { border-bottom: none; }
.risk-label { color: var(--text-muted); flex-shrink: 0; font-size: 0.92em; }
.risk-value { text-align: right; font-weight: 500; word-break: break-all; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 0.78em; font-weight: 600; line-height: 1.7; white-space: nowrap;
}
.tag-safe { background: #dcfce7; color: #15803d; }
.tag-safe-dark { background: #bbf7d0; color: #14532d; }
.tag-warn { background: #fef3c7; color: #a16207; }
.tag-danger { background: #fee2e2; color: #b91c1c; }
.tag-info { background: #dbeafe; color: #1d4ed8; }
.tag-neutral { background: var(--bg-hover); color: var(--text-muted); }
[data-theme='dark'] .tag-safe { background: #14532d; color: #86efac; }
[data-theme='dark'] .tag-safe-dark { background: #166534; color: #bbf7d0; }
[data-theme='dark'] .tag-warn { background: #713f12; color: #fde68a; }
[data-theme='dark'] .tag-danger { background: #7f1d1d; color: #fecaca; }
[data-theme='dark'] .tag-info { background: #1e3a8a; color: #bfdbfe; }

/* ---------- 评分仪表 ---------- */
.gauge-wrap { text-align: center; }
.gauge-score { font-size: 2.4em; font-weight: 800; line-height: 1.1; }
.gauge-text { font-size: 0.82em; color: var(--text-muted); margin: 4px 0 12px; min-height: 2.4em; }
.gauge-bar {
  position: relative; height: 8px; border-radius: 4px; margin: 6px 0 6px;
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 40%, #84cc16 65%, #22c55e 100%);
}
.gauge-pointer {
  position: absolute; top: -4px; width: 4px; height: 16px;
  border-radius: 2px; background: var(--text); transform: translateX(-2px);
  transition: left 0.4s ease;
}
.gauge-labels {
  display: flex; justify-content: space-between;
  font-size: 0.68em; color: var(--text-muted); margin-top: 4px;
}
.trust-score-filler { flex: 1; min-height: 8px; }
.region-warn {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  background: #fee2e2; color: #b91c1c; font-size: 0.82em; text-align: left;
}
[data-theme='dark'] .region-warn { background: #7f1d1d; color: #fecaca; }

/* ---------- 提示气泡 ---------- */
.tip-wrap { position: relative; display: inline-block; cursor: help; color: var(--text-muted); font-weight: 400; text-transform: none; }
.tip-text {
  display: none; position: absolute; left: 0; top: 20px; z-index: 50;
  width: 240px; padding: 8px 10px; border-radius: 8px;
  background: var(--bg-card); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); color: var(--text-soft);
  font-size: 0.78em; font-weight: 400; line-height: 1.5; text-transform: none; letter-spacing: 0;
}
.tip-wrap:hover .tip-text { display: block; }

/* ---------- 历史记录 ---------- */
.history-grid { display: flex; flex-direction: column; gap: 2px; font-size: 0.88em; }
.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px dashed var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-time { color: var(--text-muted); font-size: 0.85em; flex-shrink: 0; min-width: 130px; }

/* ---------- 说明区 / 页脚 ---------- */
.notes {
  margin-top: 24px; padding: 14px 18px;
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow);
}
.notes-title { font-size: 0.82em; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.notes ul { padding-left: 18px; }
.notes li { font-size: 0.82em; color: var(--text-soft); margin-bottom: 4px; }

footer {
  text-align: center; padding: 30px 0 24px;
  color: var(--text-muted); font-size: 0.82em;
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--accent); }

/* ---------- 骨架屏 ---------- */
.loading-bar {
  height: 14px; border-radius: 4px; display: inline-block;
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .ip-dual { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .container { padding: 16px 14px; }
  .cards { grid-template-columns: 1fr; }
  .tip-text { width: 200px; left: auto; right: 0; }
  .gauge-score { font-size: 2em; }
}
