/* 运维平台导航 —— 三套皮肤的取色沿用 dbtool（深空 / 明亮 / 护眼） */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #060a11; --panel: #0b121e; --raise: #132036;
  --line: #1a2a42; --line-hi: #27405f;
  --fg: #d6e2f0; --muted: #8497b1; --dim: #5d6f89;
  --accent: #22d3ee; --on-accent: #04121a;
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --ico-mix: 0%; --go-mix: 34%;   /* 卡片色里混入多少前景色（--fg），用来保证对比度，见下面「卡片配色」 */
  --on-bad: #140404;              /* 红色按钮上的文字：深空下的红是浅红，白字只有 2.8:1 */
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f8; --panel: #ffffff; --raise: #eef2f7;
  --line: #e3e8ef; --line-hi: #cfd7e3;
  --fg: #1d2735; --muted: #5d6b7e; --dim: #8693a5;
  --accent: #2563eb; --on-accent: #ffffff;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --shadow: 0 10px 28px rgba(29, 39, 53, .12);
  --ico-mix: 35%; --go-mix: 58%;
  --on-bad: #ffffff;
}
:root[data-theme="eye"] {
  color-scheme: light;
  --bg: #f1ead9; --panel: #f8f2e3; --raise: #ece3cf;
  --line: #e2d7bf; --line-hi: #d3c5a7;
  --fg: #3b3428; --muted: #6f634d; --dim: #9a8d72;
  --accent: #2f7d6d; --on-accent: #fbf7ec;
  --ok: #2f7d4f; --warn: #94600f; --bad: #a33b2f;
  --shadow: 0 10px 28px rgba(59, 52, 40, .14);
  --ico-mix: 44%; --go-mix: 69%;
  --on-bad: #ffffff;
}

:root {
  --font: -apple-system, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;

  /* 卡片配色（图标描边色、「进入」文字）：图标底色里卡片色占 --ico-bg，「进入」底色里卡片色占 --go-bg（悬停时 --go-bg-hover）。
   * 文字和图标的颜色是「卡片色 + 前景色」按比例混合：每个主题里的 --ico-mix（图标）和 --go-mix（「进入」文字）是前景色的占比，
   * 取的是让调色板里最难看清的颜色（黄色等）也达到 WCAG 要求（图标 3:1、文字 4.5:1）所需比例再留出余量。
   * contrast_test.go 会读取这里的数字，对调色板和 nav.json 里现有的每个颜色、每个主题逐一核对：改这些数字或者主题底色之前先跑它。 */
  --ico-bg: 15%;
  --go-bg: 14%;
  --go-bg-hover: 28%;

  --head-h: 76px;                         /* 顶栏的高度加一点空隙：跳转到分组后，组标题要露在顶栏下面；窄屏顶栏折成两行，见下面 */
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;   /* 内容不够一屏时，页脚（含备案号）也贴在窗口底部 */
  font: 14px/1.6 var(--font);
  color: var(--fg);
  background:
    radial-gradient(900px 340px at 14% -90px, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font: 11px/1 var(--mono);
  padding: 3px 6px;
  border: 1px solid var(--line-hi);
  border-radius: 5px;
  color: var(--muted);
  background: var(--raise);
}

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }
main.wrap { flex: 1 0 auto; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.bar { display: flex; align-items: center; gap: 16px; min-height: 60px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; white-space: nowrap; }
.mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  color: var(--on-accent); background: var(--accent);
}
.mark svg { width: 18px; height: 18px; }

.search {
  display: flex; align-items: center; gap: 8px;
  flex: 1; max-width: 440px; margin: 0 auto;
  height: 38px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel);
  color: var(--dim);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.search svg { width: 16px; height: 16px; flex: none; }
.search input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent; color: var(--fg);
}
.search input::placeholder { color: var(--dim); }
.search input::-webkit-search-cancel-button { display: none; }

.themes {
  display: flex; padding: 3px; gap: 2px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.themes button {
  border: 0; border-radius: 7px; padding: 5px 11px;
  font-size: 13px; color: var(--muted); background: transparent;
  transition: background .15s, color .15s;
}
.themes button:hover { color: var(--fg); }
.themes button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---------- 标题区 / 工具条 ---------- */
.hero { padding: 44px 0 22px; }
.hero h1 { margin: 0; font-size: 28px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.sub { margin: 8px 0 0; color: var(--muted); min-height: 22px; }
.sub b { color: var(--fg); font-weight: 600; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { color: var(--fg); border-color: var(--line-hi); }
.chip em { font: normal 12px var(--mono); color: var(--dim); }
.chip[aria-pressed="true"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.chip[aria-pressed="true"] em { color: inherit; }

.ghost {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: transparent; color: var(--muted);
  transition: color .15s, border-color .15s;
}
.ghost:hover { color: var(--fg); border-color: var(--line-hi); }
.ghost svg { width: 15px; height: 15px; }
.ghost.busy svg { animation: spin 0.9s linear infinite; }

/* ---------- 卡片 ----------
 * 排版按平台总数自动分三档（阈值在 js/layout.js）：rich 两列大卡片 / cozy 三列收紧 / grouped 按分类分组的紧凑卡片。
 * 网格的列数是固定的，最后一行不够时空着，卡片不会被拉宽变形。 */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid.tier-cozy { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid.tier-grouped { display: block; }                 /* 分组档：外层只是容器，列在每个分组里 */
.group { margin-top: 30px; scroll-margin-top: var(--head-h); }
.group:first-child { margin-top: 0; }
.group-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.group-title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 0 0 12px; font-size: 15px; line-height: 1.4; font-weight: 650;
  scroll-margin-top: var(--head-h);
}
.group-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.group-title em { font: normal 12px var(--mono); color: var(--muted); }
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); align-self: center; }

.card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px 22px 18px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card::before {                       /* 顶部的产品色带 */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--p); opacity: .65; transition: opacity .18s;
}
.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--p) 55%, var(--line));
  box-shadow: var(--shadow);
}
.card:hover::before { opacity: 1; }

.card-top { display: flex; align-items: center; gap: 14px; }
.ico {
  display: grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: 13px;
  color: color-mix(in srgb, var(--fg) var(--ico-mix), var(--p));
  background: color-mix(in srgb, var(--p) var(--ico-bg), var(--panel));
  border: 1px solid color-mix(in srgb, var(--p) 32%, transparent);
}
.ico svg { width: 26px; height: 26px; }

.ttl { min-width: 0; }
.ttl h2, .ttl h3 { margin: 0; font-size: 18px; line-height: 1.3; font-weight: 650; overflow-wrap: anywhere; }

/* 让整张卡片都能点：链接的伪元素铺满卡片 */
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card-link:focus-visible { outline: none; }
.card-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 16px; }

.meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; font: 12px var(--mono); color: var(--muted); }
.ver { padding: 0 6px; border-radius: 5px; background: var(--raise); color: var(--muted); }

.status {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  margin-left: auto; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; color: var(--muted);
}
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.status[data-state="online"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.status[data-state="online"] i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status[data-state="error"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.status[data-state="error"] i { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
.status[data-state="checking"] i { animation: pulse 1.1s ease-in-out infinite; }

/* 简介最多 3 行（三列档 2 行），多出的省略，悬停看全文（title）；没有简介 / 标签的卡片根本不渲染这两块，不留空白 */
.desc {
  margin: 0; color: var(--muted); line-height: 1.7; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tags li { padding: 2px 9px; border-radius: 6px; font-size: 12px; color: var(--muted); background: var(--raise); }
.tags li.more { background: transparent; border: 1px dashed var(--line-hi); padding: 1px 8px; color: var(--muted); }  /* 「+N」：多出来的标签 */

/* 三列档：卡片收紧 */
.tier-cozy .card { padding: 18px 18px 14px; gap: 12px; }
.tier-cozy .ico { width: 42px; height: 42px; border-radius: 12px; }
.tier-cozy .ico svg { width: 23px; height: 23px; }
.tier-cozy .ttl h2 { font-size: 16.5px; }
.tier-cozy .desc { -webkit-line-clamp: 2; line-clamp: 2; }
.tier-cozy .lat { display: none; }          /* 三列时每张卡片只有 300 多像素宽，优先保证地址完整；响应时间在状态的悬停提示里 */

/* 管理员模式下卡片底部多了拖动手柄和编辑按钮，一行放不下（窄窗口、三列档、分组档尤其）：所有版式都一样，
 * 地址（和响应时间）独占一行，按钮另起一行：手柄、编辑靠左，数字键、「进入」靠右 */
.foot.tools-on { flex-wrap: wrap; row-gap: 6px; }
.foot.tools-on .addr-wrap { flex: 1 0 100%; }
.foot.tools-on .go { margin-left: auto; }
.foot.tools-on .key:not(:empty) { margin-left: auto; }
.foot.tools-on .key:not(:empty) + .go { margin-left: 0; }

/* 分组档的紧凑卡片：图标、名称、状态、地址、版本、「进入」；简介（放在 title 里）和标签不显示 */
.card.compact { padding: 14px 14px 12px; gap: 10px; border-radius: 13px; }
.card.compact::before { height: 2px; }
.card.compact .card-top { gap: 10px; }
.card.compact .ico { width: 36px; height: 36px; border-radius: 10px; }
.card.compact .ico svg { width: 20px; height: 20px; }
.card.compact .ttl h3 { font-size: 15px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.card.compact .meta { font-size: 11.5px; }
.card.compact .status { padding: 2px 8px; font-size: 11.5px; }
.card.compact .foot { padding-top: 10px; gap: 6px; }
.card.compact .lat { display: none; }
.card.compact .go { padding: 3px 10px; font-size: 12.5px; }
.card.compact .card-link:focus-visible::after { border-radius: 13px; }

/* 卡片底部：地址（可复制） | 响应时间 | 编辑 | 数字键 | 进入 */
.foot {
  display: flex; align-items: center; gap: 8px;
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.addr-wrap { display: flex; align-items: center; gap: 4px; flex: 1 1 0; min-width: 0; }
.addr { font-family: var(--mono); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lat { flex: none; margin-left: auto; padding-left: 8px; font: 12px var(--mono); color: var(--muted); }  /* 在 .addr-wrap 里，靠右 */
.lat:empty { display: none; }
.key { flex: none; }
.key:empty { display: none; }

/* 复制 / 编辑按钮要盖在「整张卡片可点」的链接遮罩（z-index: 1）之上，点它们不应该触发跳转 */
.tool { position: relative; z-index: 2; }
.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; padding: 0;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--raise); color: var(--fg); border-color: var(--line); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.done { color: var(--ok); }

.go {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  color: color-mix(in srgb, var(--fg) var(--go-mix), var(--p));
  background: color-mix(in srgb, var(--p) var(--go-bg), transparent);
  transition: background .18s;
}
.go svg { width: 14px; height: 14px; transition: transform .18s; }
.card:hover .go { background: color-mix(in srgb, var(--p) var(--go-bg-hover), transparent); }
.card:hover .go svg { transform: translateX(3px); }

.empty { padding: 56px 0; text-align: center; color: var(--muted); }

.errbox {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  border-radius: 12px; background: color-mix(in srgb, var(--warn) 8%, var(--panel));
}
.errbox p { margin: 0; color: var(--muted); }
.errbox b { color: var(--warn); font-weight: 650; }
.ghost:disabled { opacity: .5; cursor: default; }

.page-foot {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding-top: 36px; padding-bottom: 32px;
  font-size: 12px; color: var(--muted);
}
.foot-hints { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; }
.page-foot .sep { color: var(--dim); }
.icp { margin: 0; }                      /* ICP 备案号：居中、低调，鼠标移上去才强调 */
.icp a { color: var(--muted); }
.icp a:hover { color: var(--fg); text-decoration: underline; }
.icp a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- 页面内编辑 ---------- */
.foot-admin { margin: 0; }                   /* 管理员登录入口：放在页脚、颜色很淡，普通访问者不会注意到 */
.foot-link {
  padding: 0; border: 0; background: none;
  font-size: 12px; color: var(--dim); text-decoration: underline; text-underline-offset: 3px;
}
.foot-link:hover { color: var(--fg); }
.foot-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.admin-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: -4px 0 16px; padding: 9px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-size: 13px; color: var(--muted);
}
.admin-bar b { color: var(--fg); font-weight: 600; }
.admin-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.ghost.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.ghost.accent:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ghost:disabled, .ghost.accent:disabled { opacity: .5; cursor: default; background: transparent; }

/* 分组档里，顶部的筛选条改成「跳转到分组」 */
.chips-label { align-self: center; margin-right: 2px; font-size: 12.5px; color: var(--muted); }

/* 调整顺序：拖动手柄（鼠标、触屏都能拖；聚焦后按方向键移动）。放手就保存。 */
.drag-handle { cursor: grab; touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.drag-handle:active { cursor: grabbing; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.card.dragging { opacity: .35; outline: 2px dashed var(--line-hi); outline-offset: -2px; }
.drag-ghost {                              /* 拖影：外层只负责定位；里面是卡片的克隆，外层带着版式的 class，.tier-cozy .card 这类规则对它也生效 */
  position: fixed; left: 0; top: 0; z-index: 90; margin: 0; pointer-events: none; will-change: transform;
}
.drag-ghost > .card { width: 100%; height: 100%; opacity: .92; box-shadow: var(--shadow); transition: none; transform: none; }
body.is-dragging .card:hover { transform: none; box-shadow: none; }
body.is-dragging .card.drop-before { box-shadow: inset 5px 0 0 var(--accent); }
body.is-dragging .card.drop-after { box-shadow: inset -5px 0 0 var(--accent); }
body.is-dragging .card.drop-before.vert { box-shadow: inset 0 5px 0 var(--accent); }
body.is-dragging .card.drop-after.vert { box-shadow: inset 0 -5px 0 var(--accent); }

/* 刚添加的卡片闪一下，方便找到 */
.card.flash { animation: flash 1.8s ease-out 1; }
@keyframes flash {
  0% { box-shadow: 0 0 0 0 var(--p); }
  25% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--p) 60%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60;
  max-width: calc(100vw - 32px); padding: 9px 16px;
  border: 1px solid var(--line-hi); border-radius: 10px;
  background: var(--panel); color: var(--fg); box-shadow: var(--shadow);
  font-size: 13px; word-break: break-all;
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog.dlg {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--line-hi); border-radius: 16px;
  background: var(--panel); color: var(--fg); box-shadow: var(--shadow);
  overflow: auto;
}
dialog.dlg::backdrop { background: rgba(0, 0, 0, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dlg form { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px 18px; }
.dlg h3 { margin: 0; font-size: 17px; line-height: 1.4; }
.form-note {
  margin: 0; padding: 8px 12px; border-radius: 9px; font-size: 12.5px; color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  background: color-mix(in srgb, var(--warn) 8%, transparent);
}
.form-err {                                   /* 保存失败的原因：显示在面板里，用户填的内容还在 */
  margin: 0; padding: 9px 12px; border-radius: 9px; font-size: 13px; line-height: 1.55; color: var(--fg);
  border: 1px solid color-mix(in srgb, var(--bad) 55%, var(--line));
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  overflow-wrap: anywhere;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--fg); font: inherit;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent);
}
.field [aria-invalid="true"] { border-color: var(--bad); }
.field input[type="color"] { width: 64px; height: 38px; padding: 3px; cursor: pointer; }
.field.inline { flex-direction: row; align-items: center; gap: 12px; }
.mono { font-family: var(--mono); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.55; }
.hint code { font: 12px var(--mono); padding: 0 4px; border-radius: 4px; background: var(--raise); }
.err { font-size: 12px; color: var(--bad); }
.err:empty { display: none; }

.dlg-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 10px; margin-top: 2px; }   /* 窄屏上放不下就换行，按钮里的字不折行 */
.dlg-actions .btn { white-space: nowrap; }
.btn {
  padding: 7px 16px; border: 1px solid var(--line); border-radius: 9px;
  background: transparent; color: var(--fg);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--raise); border-color: var(--line-hi); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn.link { margin-right: auto; border-color: transparent; color: var(--muted); }
.btn.link:hover { color: var(--fg); background: transparent; text-decoration: underline; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); text-decoration: none; }
.btn.danger.armed { color: var(--on-bad); background: var(--bad); border-color: transparent; font-weight: 600; }
.btn.danger.armed:hover { background: var(--bad); filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }

/* 添加平台：必填的三项放在外面，其余收在「更多设置」里 */
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg); cursor: pointer; }
.check input { width: auto; margin: 0; accent-color: var(--accent); }
.field > .check { font-size: 13px; }
.more { border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.more > summary { padding: 9px 0; cursor: pointer; font-size: 13px; color: var(--muted); }
.more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.more[open] > summary { color: var(--fg); border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.more-body { display: flex; flex-direction: column; gap: 14px; padding-bottom: 12px; }
.polish { align-items: flex-start; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.polish input { margin-top: 3px; }
.polish small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); line-height: 1.55; }

/* ---------- 页面水印 ----------
 * 整页的一层和每个弹窗里的一层都是 js/watermark-view.js 创建的。<dialog> 在浏览器的顶层，普通元素的 z-index 盖不住它，
 * 所以每个弹窗里各放一层。这里只是兜底的基础样式，真正生效的是脚本设在元素上的内联 !important（样式表里的规则盖不过它）。
 * 弹窗里的一层比整页的低一级，让设置面板里的预览（.wm-preview）能盖在它上面，看到的才是还没保存的那份设置。 */
.wm-layer {
  position: fixed; inset: 0; z-index: 2147483647;
  margin: 0; padding: 0; border: 0;
  pointer-events: none;
  background-repeat: repeat;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
dialog .wm-layer { z-index: 2147483646; }
@media print {                          /* 打印、导出 PDF 时每一页都带水印（背景图默认不打印，所以要明确要求） */
  .wm-layer {
    display: block !important; visibility: visible !important; opacity: 1 !important;
    position: fixed !important; inset: 0 !important;
    -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important;
  }
}

/* 水印设置面板：左边表单，右边实时预览；窄屏上下排 */
dialog.dlg.wide { width: min(940px, calc(100vw - 32px)); }
.wm-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.wm-fields { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.wm-side {                              /* sticky 会形成自己的层叠上下文，所以 z-index 要写在它上面：预览（里面的 .wm-preview）才能盖在弹窗里的水印层上 */
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
  position: sticky; top: 0; z-index: 2147483647;
}
.wm-side-title { font-size: 12.5px; color: var(--muted); }
.wm-preview {                           /* 预览框：背景用当前主题的底色，里面放两张假卡片，让预览更像真实页面 */
  position: relative; z-index: 2147483647; overflow: hidden;
  height: 300px; border: 1px solid var(--line-hi); border-radius: 12px; background: var(--bg);
}
.wm-mock::before, .wm-mock::after {
  content: ""; position: absolute; top: 12%; width: 42%; height: 36%;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.wm-mock::before { left: 5%; }
.wm-mock::after { right: 5%; }
.wm-preview-mark { position: absolute; inset: 0; pointer-events: none; }
.dirty {
  margin-left: 8px; padding: 1px 9px; border-radius: 999px; vertical-align: 2px;
  font-size: 12px; font-weight: 500; color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
}
.warn { font-size: 12px; line-height: 1.55; color: var(--warn); overflow-wrap: anywhere; }
.wm-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.chip-btn {
  padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--raise); color: var(--fg); font: 12px var(--mono);
}
.chip-btn:hover { border-color: var(--line-hi); }
.chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.sm { padding: 4px 14px; font-size: 13px; }
.field input[type="range"] { flex: 1; width: auto; min-width: 0; padding: 0; border: 0; background: transparent; accent-color: var(--accent); }
.wm-range-row { display: flex; align-items: center; gap: 12px; }
.wm-range-row output { flex: none; min-width: 60px; text-align: right; font: 13px var(--mono); color: var(--fg); }
.wm-color { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.wm-presets { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 跳转过渡 ---------- */
.jump {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade .15s ease-out;
}
.jump-box { display: flex; align-items: center; gap: 14px; padding: 16px 22px; border: 1px solid var(--line-hi); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.jump-box p { margin: 0; font-size: 15px; }
.spin { width: 22px; height: 22px; border: 3px solid var(--line-hi); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes fade  { from { opacity: 0; } }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- 小屏 ---------- */
@media (max-width: 959px) {
  .grid.tier-cozy, .group-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* 三列在这个宽度下每张卡片不到 280px，标题会被挤得只剩几个字宽 */
}
@media (max-width: 760px) {
  .grid, .grid.tier-cozy, .group-grid { grid-template-columns: 1fr; }   /* 窄屏三档都是一列 */
  .grid.tier-grouped { display: block; }
  .wm-grid { grid-template-columns: 1fr; }                              /* 水印设置面板：上下排，预览放在最上面并固定住，拖滑块时一直看得到效果 */
  .wm-side { order: -1; padding: 0 0 8px; background: var(--panel); }
  .wm-side .hint { display: none; }
  .wm-preview { height: 150px; }
  .hero { padding-top: 32px; }
  .hero h1 { font-size: 24px; }
}
@media (pointer: coarse) {
  .icon-btn { width: 36px; height: 36px; }       /* 触屏上按钮要大一点，拖动手柄尤其 */
  .icon-btn svg { width: 17px; height: 17px; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .bar { flex-wrap: wrap; gap: 10px 12px; padding-top: 10px; padding-bottom: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
  .themes { margin-left: auto; }
  .toolbar { align-items: flex-start; }
  .key { display: none; }
  .lat { display: none; }               /* 窄屏优先保证地址完整：真实的内网地址比 localhost 长得多 */
  .admin-bar { flex-direction: column; align-items: flex-start; }
  .admin-actions { width: 100%; }
  .chips-label { flex-basis: 100%; }
  :root { --head-h: 124px; }              /* 顶栏折成了两行（约 108px） */
  .foot.tools-on .key:not(:empty) + .go { margin-left: auto; }   /* 数字键提示被隐藏了，「进入」自己靠右 */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
