/* ==========================================================================
   IP 查询 · Cloudflare Pages
   视觉：Discord 社群风 —— 服务器栏 / 频道栏 / 内容区 三层深灰
   主题：默认深色，可手动切浅色，选择记在 localStorage
   ========================================================================== */

html[data-theme="dark"] {
  --shell: #1e1f22;
  --nav: #2b2d31;
  --main: #313338;
  --card: #2b2d31;
  --card-hover: #35373c;
  --line: rgba(255, 255, 255, 0.055);
  --line-2: rgba(255, 255, 255, 0.09);
  --txt: #f2f3f5;
  --txt-2: #dbdee1;
  --dim: #949ba4;
  --muted: #80848e;
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green: #23a55a;
  --yellow: #f0b132;
  --red: #f23f43;
  --chip: rgba(88, 101, 242, 0.16);
  --chip-txt: #c9cdfb;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  --raw-bg: rgba(0, 0, 0, 0.18);
}

html[data-theme="light"] {
  --shell: #f2f3f5;
  --nav: #f2f3f5;
  --main: #ffffff;
  --card: #f2f3f5;
  --card-hover: #e9eaec;
  --line: rgba(0, 0, 0, 0.055);
  --line-2: rgba(0, 0, 0, 0.09);
  --txt: #060607;
  --txt-2: #313338;
  --dim: #5c5e66;
  --muted: #6d6f78;
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green: #1a8b4a;
  --yellow: #c48a12;
  --red: #d83c3e;
  --chip: rgba(88, 101, 242, 0.1);
  --chip-txt: #4752c4;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --raw-bg: rgba(0, 0, 0, 0.035);
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  /* 锁死视口高度：整页不滚动，滚动只发生在内容区（.scroll）内部。
     左右两栏因此始终固定在原位，不会跟着内容上下跑。
     dvh 见下方 .app 的说明。 */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--shell);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* height（不是 min-height）才是关键：
   min-height 会让容器随内容长高，左侧两栏被拉伸到整篇内容的高度，
   于是跟着文档一起滚动。锁成 100% 视口高度后，只有 .scroll 内部滚动。
   dvh 是给移动端的：100vh 在手机上含地址栏区域，底部会被裁掉一截；
   不认识的浏览器自动落回上一行的 100vh。 */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ==========================================================================
   左：服务器图标栏
   ========================================================================== */

.rail {
  flex: none;
  width: 72px;
  /* 别让内容把栏撑高，否则会顶破 100vh 的容器 */
  min-height: 0;
  background: var(--shell);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
}

.rail-btn {
  position: relative;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 16px;
  background: var(--nav);
  color: var(--txt-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  transition: border-radius 0.18s, background 0.18s, color 0.18s;
}

.rail-btn:hover { border-radius: 14px; background: var(--blurple); color: #fff; }
.rail-btn.on { border-radius: 14px; background: var(--blurple); color: #fff; }

.rail-btn.on::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 4px;
  height: 26px;
  margin-top: -13px;
  border-radius: 0 4px 4px 0;
  background: var(--txt);
}

.rail-btn svg { width: 22px; height: 22px; }
.rail-sep { width: 32px; height: 1px; background: var(--line-2); margin: 4px 0; }

/* ==========================================================================
   中：频道栏
   ========================================================================== */

.side {
  flex: none;
  width: 240px;
  min-height: 0;
  background: var(--nav);
  display: flex;
  flex-direction: column;
  border-radius: 8px 0 0 8px;
}

.side-head {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 1px 0 var(--line);
  font-weight: 650;
  font-size: 15.5px;
  letter-spacing: -0.005em;
}

.side-body { flex: 1; overflow-y: auto; padding: 16px 8px 8px; }

.grp {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 16px 8px 4px;
}

.grp:first-child { padding-top: 0; }

.ch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin-bottom: 2px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.ch:hover { background: var(--card-hover); color: var(--txt-2); }
.ch.on { background: var(--card-hover); color: var(--txt); font-weight: 600; }
.ch svg { width: 20px; height: 20px; flex: none; opacity: 0.8; }

.side-foot {
  padding: 10px 12px;
  background: var(--shell);
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blurple), #8b6bff);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}

.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who b { display: block; font-size: 13.5px; color: var(--txt); font-weight: 600; }
.side-foot .who span {
  color: var(--muted);
  font-size: 11.5px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   右：主内容
   ========================================================================== */

.main {
  flex: 1;
  min-width: 0;
  /* 关键：flex 子项默认 min-height:auto，不收缩会让 .scroll 的
     overflow-y:auto 形同虚设（内容把容器顶高，由整页来滚动）。
     显式置 0 才能让 .scroll 真正成为唯一的滚动容器。 */
  min-height: 0;
  background: var(--main);
  border-radius: 8px 0 0 8px;
  display: flex;
  flex-direction: column;
}

.top {
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  box-shadow: 0 1px 0 var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--main);
}

.top .hash { color: var(--muted); font-size: 22px; line-height: 1; }
.top .t { font-weight: 650; font-size: 15.5px; }
.top .divider { width: 1px; height: 22px; background: var(--line-2); margin: 0 2px; }
.top .d { color: var(--muted); font-size: 13.5px; }
.top .spacer { flex: 1; }

.tbtn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.tbtn:hover { background: var(--card-hover); color: var(--txt-2); }
.tbtn svg { width: 19px; height: 19px; }
.tbtn:disabled { opacity: 0.5; cursor: default; }

/* 主题按钮：按当前主题显示对应图标 */
html[data-theme="dark"] .i-sun { display: none; }
html[data-theme="light"] .i-moon { display: none; }

/* --gut 是内容区左右内边距，同时被 Hero 卡片用来做「负 margin 撑满」。
   想改留白只改这里一处，Hero 会自动跟着对齐，不会再出现溢出。 */
.scroll { flex: 1; overflow-y: auto; padding: 24px var(--gut) 32px; --gut: 20px; }

/* ------------------------------------------------------------- 消息式 Hero */

.msg { display: flex; gap: 14px; margin-bottom: 8px; }
.msg .avatar { width: 42px; height: 42px; font-size: 13px; }
.msg-body { flex: 1; min-width: 0; }

.msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.msg-meta .n { font-weight: 650; color: var(--txt); font-size: 15.5px; }

.msg-meta .badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--blurple);
  color: #fff;
  letter-spacing: 0.01em;
}

.msg-meta .ts { color: var(--muted); font-size: 12px; }

.ipbox {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  /* 下方紧跟状态胶囊，留 8px 让它们读作一组（原来跟的是正文，所以是 12px） */
  margin: 6px 0 8px;
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  max-width: 100%;
}

.ipbox .ip {
  font-family: var(--mono);
  font-size: clamp(19px, 4.2vw, 30px);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--txt);
  word-break: break-all;
}

.ipbox .ip.pending { color: var(--muted); font-weight: 600; }

.ibtn {
  flex: none;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--txt-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

html[data-theme="light"] .ibtn { background: rgba(0, 0, 0, 0.05); }
.ibtn:hover { background: var(--blurple); color: #fff; }
.ibtn svg { width: 18px; height: 18px; }

/* 地理位置 / 网络出口各占一行，行距收紧让它们读作一组。
   注意别用 :last-of-type —— 它对 .msg-ts 那个 <p> 也成立，
   选不到这里的最后一行。直接用相邻兄弟选择器。 */
.msg-line { color: var(--dim); font-size: 14.5px; margin: 0 0 3px; }
.msg-line .k { color: var(--txt-2); font-weight: 600; }
.msg-line + .msg-line { margin-bottom: 10px; }   /* 收尾留白只加在最后一行 */

/* 解析时间：紧跟在地理位置下面，比正文弱一档 */
.msg-ts { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.msg-ts .ts { color: var(--txt-2); }

/* 状态胶囊紧跟 IP 框（它描述的就是这个 IP 的解析状态），
   和下方的「您来自 / 网络出口在」之间留出段落间距。 */
.pills { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--chip-txt);
  font-size: 12.5px;
  font-weight: 600;
}

.pill.g { background: rgba(35, 165, 90, 0.15); color: #57f287; }
html[data-theme="light"] .pill.g { color: #1a8b4a; }

/* 轻提示 / 出错时的橙色态 */
.pill.warn { background: rgba(240, 177, 50, 0.15); color: #f0b132; }

.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill[hidden] { display: none; }

.pill.g .dot { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* 错误提示 */
.err {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  margin-top: 12px;
  padding: 12px 15px;
  border-radius: 9px;
  background: rgba(242, 63, 67, 0.1);
  border: 1px solid rgba(242, 63, 67, 0.28);
  font-size: 13px;
  color: var(--dim);
}

.err[hidden] { display: none; }
.err b { color: #f88; font-weight: 650; }
html[data-theme="light"] .err b { color: #c22a2d; }

/* ------------------------------------------------------------- 分隔线 */

.divider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 16px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.divider-row::before,
.divider-row::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }

/* ------------------------------------------------------------- 频道式卡片 */

/* 吸顶栏高 48px，锚点跳转时留出这段高度，别让标题被盖住。
   注意要加在**真正的锚点目标**上（#overview / #geo / #net / #raw 所在的元素），
   加在 .entry 上是无效的 —— 那些 id 并不在 .entry 上。 */
#overview, #geo, #net, #raw { scroll-margin-top: 56px; }

.list { display: grid; gap: 8px; }

@media (min-width: 760px) { .list { grid-template-columns: 1fr 1fr; } }

.entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 9px;
  background: var(--card);
  border: 1px solid transparent;
  transition: background 0.14s, border-color 0.14s;
}

.entry:hover { background: var(--card-hover); border-color: var(--line-2); }

.entry .ico {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(88, 101, 242, 0.14);
  color: var(--blurple);
  display: grid;
  place-items: center;
}

html[data-theme="light"] .entry .ico { color: #4752c4; }
.entry .ico svg { width: 19px; height: 19px; }

.entry .meta { min-width: 0; flex: 1; }

.entry .meta .lb {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.entry .meta .vl {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--txt-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry .meta .vl.mono { font-family: var(--mono); font-size: 13px; }

/* ------------------------------------------------------------- 原始数据 */

.raw {
  margin-top: 24px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  overflow: hidden;   /* 吸顶偏移统一由上方 #raw 那条规则给 */
}

.raw-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  border: none;
  background: transparent;
  color: var(--txt-2);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.raw-toggle:hover { background: var(--card-hover); }
.raw-toggle small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.raw-toggle .h { font-size: 12px; color: var(--muted); font-weight: 500; flex: none; }

.raw-body {
  display: none;
  margin: 0;
  padding: 14px 15px;
  border-top: 1px solid var(--line);
  background: var(--raw-bg);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--dim);
  overflow-x: auto;
  white-space: pre;
}

.raw-body.open { display: block; }

.foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 880px) {
  .side { display: none; }
  .rail { width: 60px; }
  .rail-btn { width: 42px; height: 42px; border-radius: 14px; }
  .rail-btn.on::before { left: -10px; }
}

@media (max-width: 560px) {
  .rail { display: none; }
  .main { border-radius: 0; }
  .scroll { padding: 18px var(--gut) 28px; --gut: 14px; }
  .msg .avatar { width: 38px; height: 38px; }
  .ipbox { width: 100%; justify-content: space-between; padding: 13px 15px; }
  .list { grid-template-columns: 1fr; }
  .top .d { display: none; }
  .entry .meta .vl { white-space: normal; }
}

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

/* ==========================================================================
   背景装饰
   --------------------------------------------------------------------------
   原则：只做「局部点缀」——背景元素仅出现在左侧图标栏和 Hero 消息卡片，
        内容区和信息卡保持完全干净。原因是本页文字密度高（10 张卡 + 原始
        数据面板），背景一旦铺到内容区底下会拉低峰值对比度，暗色模式下尤其
        容易出现「字发灰」。

   实现：全部用 CSS 渐变 + 内联 SVG data URI，**零外部图片请求**，
        任意分辨率都不糊，也不占用额外网络往返。
   ========================================================================== */

/* ---- 图标栏：底部一段电路走线 ---- */
.rail {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='420' viewBox='0 0 72 420'%3E%3Cg fill='none' stroke='%235865f2' stroke-opacity='.22' stroke-width='1.4'%3E%3Cpath d='M36 0v52h-14v40h14v56M36 52h16v44h-16M22 148h-8v60h22M52 96v70h-12'/%3E%3C/g%3E%3Cg fill='%235865f2' fill-opacity='.38'%3E%3Ccircle cx='36' cy='52' r='2.6'/%3E%3Ccircle cx='22' cy='148' r='2.6'/%3E%3Ccircle cx='52' cy='96' r='2.6'/%3E%3Ccircle cx='14' cy='208' r='2.6'/%3E%3Ccircle cx='40' cy='166' r='2.6'/%3E%3C/g%3E%3C/svg%3E");
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: 72px 260px;
}

/* 浅色模式下把线条压淡一点，避免在浅底上过重 */
html[data-theme="light"] .rail {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='420' viewBox='0 0 72 420'%3E%3Cg fill='none' stroke='%235865f2' stroke-opacity='.16' stroke-width='1.4'%3E%3Cpath d='M36 0v52h-14v40h14v56M36 52h16v44h-16M22 148h-8v60h22M52 96v70h-12'/%3E%3C/g%3E%3Cg fill='%235865f2' fill-opacity='.26'%3E%3Ccircle cx='36' cy='52' r='2.6'/%3E%3Ccircle cx='22' cy='148' r='2.6'/%3E%3Ccircle cx='52' cy='96' r='2.6'/%3E%3Ccircle cx='14' cy='208' r='2.6'/%3E%3Ccircle cx='40' cy='166' r='2.6'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---- Hero 卡片：右上角网络拓扑连线 ---- */

/* 卡片要「撑满」内容区（让背景层贴边），但对齐必须跟着 .scroll 的内边距走。
   所以这里不写死像素，而是用变量 —— 见下方 .scroll 的 --gut 定义。
   写死 -18px 会在移动端翻车：那里 .scroll 只有 14px 内边距，-18px 会溢出 4px。 */
.msg {
  position: relative;
  padding: 18px var(--gut) 16px;
  margin: 0 calc(var(--gut) * -1) 8px;
  border-radius: 12px;
  overflow: hidden;
}

.msg::before {
  content: "";
  position: absolute;
  right: -30px;
  top: -20px;
  width: 320px;
  height: 240px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='240' viewBox='0 0 320 240'%3E%3Cg fill='none' stroke='%235865f2' stroke-opacity='.2' stroke-width='1.2'%3E%3Cpath d='M40 200 120 130l70 40 90-100'/%3E%3Cpath d='M120 130 150 60M190 170l60 40'/%3E%3C/g%3E%3Cg fill='%235865f2' fill-opacity='.34'%3E%3Ccircle cx='40' cy='200' r='2.8'/%3E%3Ccircle cx='120' cy='130' r='3.4'/%3E%3Ccircle cx='190' cy='170' r='2.8'/%3E%3Ccircle cx='280' cy='70' r='3.4'/%3E%3Ccircle cx='150' cy='60' r='2.4'/%3E%3Ccircle cx='250' cy='210' r='2.4'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
}

html[data-theme="light"] .msg::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='240' viewBox='0 0 320 240'%3E%3Cg fill='none' stroke='%235865f2' stroke-opacity='.15' stroke-width='1.2'%3E%3Cpath d='M40 200 120 130l70 40 90-100'/%3E%3Cpath d='M120 130 150 60M190 170l60 40'/%3E%3C/g%3E%3Cg fill='%235865f2' fill-opacity='.24'%3E%3Ccircle cx='40' cy='200' r='2.8'/%3E%3Ccircle cx='120' cy='130' r='3.4'/%3E%3Ccircle cx='190' cy='170' r='2.8'/%3E%3Ccircle cx='280' cy='70' r='3.4'/%3E%3Ccircle cx='150' cy='60' r='2.4'/%3E%3Ccircle cx='250' cy='210' r='2.4'/%3E%3C/g%3E%3C/svg%3E");
}

/* 拓扑图只是装饰，别挡住文字交互 */
.msg-body { position: relative; z-index: 1; }

/* 窄屏时拓扑图会跟文字打架，直接收掉 */
@media (max-width: 880px) {
  .msg::before { opacity: .55; }
}
@media (max-width: 640px) {
  .msg::before { display: none; }
}

/* 省电模式 / 低电量下也省掉装饰层 */
@media (prefers-reduced-data: reduce) {
  .rail { background-image: none; }
  .msg::before { display: none; }
}

