/* ===== IP 属地查询样式（独立；色板与科研导航站、TextDiff、ZHConvert 保持一致） =====
   结果卡是本页主角：IP 与属地在浅色/深色下都要一眼可读。 */
:root {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-hover: #f0f2f5;
  --text: #2c3e50;
  --text-sub: #7f8c9b;
  --border: #e8ebef;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, .1);
  --accent-text: #fff;
  --danger: #e2544d;
  --shadow: 0 2px 8px rgba(30, 40, 60, .06);
  --bar-bg: #f7f8fa;
  --code-bg: #f4f6f9;
  --tag-bg: #eef2f7;
  --loc-bg: #eef5ff;
}

html[data-theme="dark"] {
  --bg: #060a17;
  --bg-card: #0d1424;
  --bg-hover: #1a2336;
  --text: #dce3ec;
  --text-sub: #8794a8;
  --border: #1e2a44;
  --accent: #4d94ff;
  --accent-soft: rgba(77, 148, 255, .16);
  --danger: #ff6b64;
  --shadow: 0 2px 10px rgba(0, 0, 0, .5);
  --bar-bg: #0a1120;
  --code-bg: #101a30;
  --tag-bg: #16213a;
  --loc-bg: #0e1c33;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  transition: background .25s, color .25s;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace; }

/* ===== 顶栏（与 TextDiff 同构） ===== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 20px;
  background: color-mix(in srgb, var(--bg-card) 82%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.back { font-size: 13px; color: var(--text-sub); white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; display: block; flex: none; }
.brand-mark img { width: 100%; height: 100%; display: block; border-radius: 9px; }
.brand-text h1 { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text p { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.top-control {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.top-control:hover { background: var(--bg-hover); border-color: var(--accent); }
.icon-btn { width: 34px; text-align: center; }
.lang-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); }
.lang-btn {
  border: 0; background: transparent; color: var(--text-sub);
  padding: 5px 9px; border-radius: 7px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--accent); color: var(--accent-text); }

/* ===== 通用控件 ===== */
main { padding: 14px 20px 60px; max-width: 980px; margin: 0 auto; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px;
}
.btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); border-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--text-sub); }

/* ===== 搜索区 ===== */
.search-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-bar .hint { flex-basis: 100%; margin-bottom: 2px; }
#ipInput {
  flex: 1; min-width: 220px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 9px 12px; font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
}
#ipInput:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* ===== 结果卡 ===== */
#resultCard.pop { animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.985); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.res-head { font-size: 13px; color: var(--text-sub); margin-bottom: 10px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-sub); font-size: 13.5px; padding: 18px 0; }
.spin {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.err { color: var(--danger); font-size: 13.5px; display: grid; gap: 4px; padding: 6px 0; }

.headline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.headline .flag { font-size: 30px; line-height: 1; }
.headline .ip { font-size: 26px; font-weight: 700; letter-spacing: .3px; word-break: break-all; }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: var(--tag-bg); color: var(--text-sub); font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.tag.self { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.loc {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  background: var(--loc-bg); border-radius: 9px; padding: 9px 13px; margin-bottom: 8px;
}
.loc-label { font-size: 12px; color: var(--text-sub); flex: none; }
.loc b { font-size: 16.5px; font-weight: 650; }

.detail {
  display: grid; grid-template-columns: auto 1fr; gap: 7px 18px;
  margin: 14px 0 4px; font-size: 13.5px;
}
.detail dt { color: var(--text-sub); white-space: nowrap; }
.detail dd { min-width: 0; word-break: break-word; }
.detail dd code { background: var(--code-bg); border-radius: 5px; padding: 1px 7px; }

.actions { display: flex; gap: 8px; margin-top: 12px; }

/* ===== 最近查询 ===== */
.hist-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.hist-head h2 { font-size: 14px; }
.hist-head .btn { padding: 3px 10px; font-size: 12px; }
.hist-list { display: flex; flex-wrap: wrap; gap: 8px; }
.hist-empty { color: var(--text-sub); font-size: 12.5px; }
.hist-chip {
  display: inline-flex; align-items: baseline; gap: 8px; max-width: 100%;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer;
}
.hist-chip:hover { background: var(--bg-hover); border-color: var(--accent); }
.hist-chip code { font-size: 12.5px; }
.hist-chip span { color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 说明区（给使用者和搜索引擎） ===== */
.doc h2 { font-size: 17px; margin: 20px 0 10px; }
.doc p, .doc li { font-size: 13.5px; line-height: 1.75; color: var(--text); }
.doc p { margin-bottom: 8px; }
.doc ul, .doc ol { padding-left: 22px; margin-bottom: 8px; }
.doc li { margin-bottom: 4px; }
.doc li b { margin-right: 6px; }
.doc .faq dt { font-size: 13.5px; font-weight: 650; margin-top: 10px; }
.doc .faq dd { font-size: 13px; color: var(--text-sub); line-height: 1.7; margin-left: 0; margin-top: 3px; }
.ver { margin-top: 18px; font-size: 12px; color: var(--text-sub); }

/* ===== 提示条 ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: var(--text); color: var(--bg-card);
  font-size: 13px; padding: 8px 16px; border-radius: 9px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: min(86vw, 520px); text-align: center; z-index: 200;
}
.toast:not(:empty) { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 窄屏 ===== */
@media (max-width: 640px) {
  main { padding: 10px 12px 50px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .headline .ip { font-size: 21px; }
  .detail { grid-template-columns: 1fr; gap: 2px 0; }
  .detail dt { margin-top: 7px; }
  .loc b { font-size: 15px; }
}
