/* ==========================================================================
   站点面板 · 样式
   配色靠 CSS 变量驱动，data-theme 在 dark / light 之间切换。
   ========================================================================== */

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f16;
  --bg-2: #0e1420;
  --panel: rgba(18, 25, 36, .78);
  --card: #141b26;
  --card-hover: #18222f;
  --line: #23303f;
  --line-soft: #1a2431;
  --text: #e8eefb;
  --muted: #93a2ba;
  --dim: #64748b;
  --accent: #4d9dff;
  --accent-2: #8b5cf6;
  --ok: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --chip: #16202e;
  --halo-1: rgba(77, 157, 255, .16);
  --halo-2: rgba(139, 92, 246, .14);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f8fc;
  --bg-2: #eef3fa;
  --panel: rgba(255, 255, 255, .82);
  --card: #ffffff;
  --card-hover: #ffffff;
  --line: #e3eaf3;
  --line-soft: #eef2f8;
  --text: #0f1b2d;
  --muted: #5b6b82;
  --dim: #8b9bb4;
  --accent: #1f6feb;
  --accent-2: #7c3aed;
  --ok: #0f9d58;
  --bad: #d93025;
  --warn: #b45309;
  --chip: #eef3fa;
  --halo-1: rgba(31, 111, 235, .12);
  --halo-2: rgba(124, 58, 237, .10);
  --shadow: 0 10px 28px rgba(15, 27, 45, .10);
  --shadow-sm: 0 1px 4px rgba(15, 27, 45, .07);
}

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

/* hidden 属性必须压过 .banner / .empty 这类声明了 display:flex 的类 */
[hidden] { display: none !important; }

:root {
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
          "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas,
          "Liberation Mono", "Courier New", monospace;
}

html, body { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 背景光晕 + 网格 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 10% -12%, var(--halo-1), transparent 62%),
    radial-gradient(820px 520px at 92% -6%, var(--halo-2), transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .5;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 72%);
          mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 72%);
}

a { color: var(--accent); text-decoration: none; }
code { font-family: var(--mono); }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
          backdrop-filter: saturate(160%) blur(14px);
}

.topbar-inner {
  width: min(1240px, 100% - 40px);
  margin: 0 auto;
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 19px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px var(--halo-1);
}

.brand-text { min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 680;
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-tools { display: flex; align-items: center; gap: 10px; }

/* 内网 IP 指示器：自动检测的结果 + 来源标签 */
.host-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: nowrap;
  cursor: default;
}

.host-chip b { font-weight: 600; color: var(--text); }

.host-chip span {
  padding: 0 5px;
  font-family: var(--font);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--accent);
  background: var(--halo-1);
  border-radius: 4px;
}

/* 分段控件：地址模式 */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip);
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .16s, background .16s;
}

.seg button:hover:not([aria-pressed="true"]):not(:disabled) { color: var(--text); }

.seg button[aria-pressed="true"] {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-sm);
}

.seg button:disabled { opacity: .4; cursor: not-allowed; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--muted);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: color .16s, border-color .16s, transform .16s;
}

.icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------------------------------------------------------------- 布局 */
.wrap {
  width: min(1240px, 100% - 40px);
  margin: 0 auto;
  padding: 22px 0 8px;
  flex: 1;
}

/* 提示条 */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--muted);
  background: linear-gradient(180deg, var(--halo-1), transparent), var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}

.banner code {
  padding: 1px 5px;
  font-size: 12px;
  color: var(--text);
  background: var(--chip);
  border-radius: 5px;
}

.banner-icon { color: var(--accent); }

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search {
  position: relative;
  flex: 1 1 320px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 13px;
  font-size: 16px;
  color: var(--dim);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 10px 44px 10px 38px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

.search input::placeholder { color: var(--dim); }

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--halo-1);
}

.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search kbd {
  position: absolute;
  right: 11px;
  padding: 1px 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 5px;
  pointer-events: none;
}

.toolbar-actions { display: flex; gap: 8px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .16s, background .16s, color .16s, transform .12s, box-shadow .16s;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }

.btn.sm { padding: 7px 12px; font-size: 12.5px; }

.btn.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px var(--halo-1);
}

.btn.primary:hover { color: #fff; filter: brightness(1.08); }

.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--accent); background: var(--chip); }

.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* 分组筛选 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color .16s, border-color .16s, background .16s;
}

.chip:hover { color: var(--text); border-color: var(--accent); }

.chip[aria-pressed="true"] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.chip .n {
  font-size: 11.5px;
  opacity: .75;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 卡片 */
.sites { display: flex; flex-direction: column; gap: 26px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}

.group-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .4px;
  color: var(--muted);
  text-transform: none;
}

.group-head .count {
  padding: 1px 8px;
  font-size: 11.5px;
  color: var(--dim);
  background: var(--chip);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.group-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 15px 16px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, border-color .16s, box-shadow .16s, background .16s;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity .16s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--card-hover);
  box-shadow: var(--shadow);
}

.card:hover::before { opacity: 1; }

.c-head { display: flex; align-items: center; gap: 10px; min-width: 0; }

.c-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: var(--chip);
  border-radius: 10px;
}

.c-title { min-width: 0; flex: 1; }

.c-name {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.c-sub {
  display: block;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 状态灯 */
.dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--dim);
  opacity: .5;
  transition: background .2s, opacity .2s, box-shadow .2s;
}

.dot[data-status="up"] {
  background: var(--ok);
  opacity: 1;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}

.dot[data-status="down"] {
  background: var(--bad);
  opacity: 1;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent);
}

.dot[data-status="checking"] { background: var(--warn); opacity: 1; animation: pulse 1s infinite; }

@keyframes pulse { 50% { opacity: .35; } }

.c-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.c-tags { display: flex; flex-wrap: wrap; gap: 5px; }

.tag {
  padding: 1px 7px;
  font-size: 11px;
  color: var(--dim);
  background: var(--chip);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
}

.c-addr {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  padding: 5px 8px;
  background: var(--chip);
  border: 1px solid var(--line-soft);
  border-radius: 7px;
}

.c-addr code {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy {
  flex: 0 0 auto;
  width: 22px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--dim);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  transition: color .15s, background .15s;
}

.copy:hover { color: var(--accent); background: var(--card); }

.c-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

/* 列表视图 */
.sites.view-list .grid { grid-template-columns: 1fr; gap: 8px; }

.sites.view-list .card {
  display: grid;
  grid-template-columns: minmax(180px, 1.05fr) minmax(0, 2.1fr) minmax(150px, .95fr) 300px;
  grid-template-areas: "head desc addr actions";
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
}

.sites.view-list .c-head { grid-area: head; }
.sites.view-list .c-desc { grid-area: desc; -webkit-line-clamp: 1; }
.sites.view-list .c-tags { display: none; }
.sites.view-list .c-addr { grid-area: addr; margin: 0; }
.sites.view-list .c-actions {
  grid-area: actions;
  margin: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* 列表模式下主按钮永远贴右，位置不随入口数量变化 */
.sites.view-list .c-actions .btn.primary { order: 2; }

/* 空状态 */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 56px 0;
  color: var(--muted);
  text-align: center;
}

.empty-icon { font-size: 34px; opacity: .7; }
.empty p { margin: 0 0 6px; }

/* 常用工具 */
.quick { margin-top: 30px; }

.section-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .4px;
  color: var(--muted);
}

.quick-list { display: flex; flex-wrap: wrap; gap: 10px; }

.quick-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .16s, transform .12s, color .16s;
}

.quick-item:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* 页脚 */
.foot {
  width: min(1240px, 100% - 40px);
  margin: 26px auto 0;
  padding: 14px 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--dim);
  border-top: 1px solid var(--line-soft);
}

.foot-tools { display: inline-flex; align-items: center; gap: 8px; }

.link-btn {
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  border-bottom: 1px dashed var(--line);
}

.link-btn:hover { color: var(--accent); border-color: var(--accent); }

.dot-sep { opacity: .5; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 60;
  padding: 9px 16px;
  font-size: 13px;
  color: #fff;
  background: rgba(20, 27, 38, .95);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transform: translate(-50%, 14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 焦点可见性 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 响应式 */
@media (max-width: 860px) {
  .topbar-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .topbar-tools { justify-content: space-between; flex-wrap: wrap; }
  .grid { grid-template-columns: 1fr; }
  .sites.view-list .card {
    grid-template-columns: 1fr auto;
    grid-template-areas: "head addr" "desc desc" "actions actions";
    row-gap: 8px;
  }
  .wrap, .foot, .topbar-inner { width: min(1240px, 100% - 24px); }
}

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