/* ===================== 基础与主题 ===================== */
:root {
  --bg: #0a0e13;
  --bg-soft: #0f151c;
  --panel: rgba(15, 21, 28, 0.88);
  --panel-solid: #111821;
  --panel-2: #16202a;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9f0f7;
  --text-2: #b9c7d4;
  --muted: #8695a3;
  --accent: #fa9549;
  --accent-2: #ffb877;
  --accent-soft: rgba(250, 149, 73, 0.14);
  --good: #7ec86a;
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;
  --topbar-h: 60px;
  --sidebar-w: 324px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #e9e6df;
  --bg-soft: #f4f1ea;
  --panel: rgba(250, 248, 243, 0.9);
  --panel-solid: #fbf9f4;
  --panel-2: #f1ede4;
  --line: rgba(20, 26, 32, 0.1);
  --line-strong: rgba(20, 26, 32, 0.2);
  --text: #1a222a;
  --text-2: #3e4b56;
  --muted: #6c7a86;
  --accent: #d96a12;
  --accent-2: #b45309;
  --accent-soft: rgba(217, 106, 18, 0.12);
  --shadow-lg: 0 24px 60px rgba(40, 30, 20, 0.18);
  --shadow-md: 0 10px 30px rgba(40, 30, 20, 0.12);
  --shadow-sm: 0 2px 10px rgba(40, 30, 20, 0.1);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* 地图页与 404 是整屏布局；工具集首页是正常滚动的文档流。 */
body.page-map,
body.page-404 { height: 100%; overflow: hidden; }
body.page-home {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

svg:not(.brand-mark svg):not(.loader-mark svg) {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

::selection { background: var(--accent-soft); }

.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;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cat-head:focus-visible { outline-offset: -2px; border-radius: var(--r-md); }
button:focus:not(:focus-visible), input:focus:not(:focus-visible) { outline: none; }

/* ===================== 布局 ===================== */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
}

/* ===================== 顶栏 ===================== */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-solid) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  z-index: 40;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  flex: 0 0 auto;
  padding: 4px 6px;
  border-radius: var(--r-md);
  transition: background 0.2s;
}
.brand:hover { background: var(--accent-soft); }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: radial-gradient(circle at 30% 20%, rgba(250, 149, 73, 0.22), transparent 70%);
  border: 1px solid rgba(250, 149, 73, 0.28);
  border-radius: 11px;
  flex: 0 0 auto;
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text .brand-name { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.brand-text small { font-size: 10.5px; color: var(--muted); letter-spacing: 2.4px; text-transform: uppercase; }

.searchbox {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 620px;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-2) 82%, transparent);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.searchbox:focus-within {
  border-color: rgba(250, 149, 73, 0.55);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--panel-solid);
}
.searchbox .icon { color: var(--muted); flex: 0 0 auto; }
.searchbox input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13.5px;
  color: var(--text);
}
.searchbox input::placeholder { color: var(--muted); }
.searchbox kbd {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 1px 6px;
  background: var(--bg-soft);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--panel-solid);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}
.sr-group {
  padding: 8px 10px 4px;
  font-size: 10.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.sr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  color: var(--text);
}
.sr-item:hover, .sr-item.active { background: var(--accent-soft); }
.sr-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--panel-solid) 70%, transparent);
}
.sr-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.sr-main b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-main small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sr-empty { padding: 18px 12px; text-align: center; color: var(--muted); font-size: 12.5px; }

.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.12s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-2); }
.icon-btn:active { transform: scale(0.94); }

/* ===================== 侧栏 ===================== */
.sidebar {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(20px) saturate(1.1);
  z-index: 30;
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 16px 10px;
}
.sidebar-head h2 { margin: 0; font-size: 14px; letter-spacing: 0.3px; }
.sidebar-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--muted); }

.filters {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 10px 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.filters::-webkit-scrollbar { width: 8px; }
.filters::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }

.cat {
  border: 1px solid transparent;
  border-radius: var(--r-md);
  margin: 2px 0 4px;
  transition: background 0.2s, border-color 0.2s;
}
.cat.is-open {
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel-2) 55%, transparent);
}
.cat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 8px;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--text);
  border-radius: var(--r-md);
}
.cat-head:hover { background: var(--accent-soft); }
.cat-chevron { color: var(--muted); transition: transform 0.22s; flex: 0 0 auto; }
.cat.is-open .cat-chevron { transform: rotate(90deg); }
.cat-icon {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}
.cat-icon svg { width: 15px; height: 15px; }
.cat-name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cat-name b { font-size: 12.8px; font-weight: 600; }
.cat-name small { font-size: 10.5px; color: var(--muted); letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-switch { flex: 0 0 auto; display: flex; align-items: center; }

.cat-body { display: none; padding: 0 8px 8px 8px; }
.cat.is-open .cat-body { display: block; }
.cat.is-off .cat-name b { color: var(--muted); }
.cat.is-off .cat-icon { color: var(--muted); background: color-mix(in srgb, var(--text) 6%, transparent); }

.item {
  padding: 7px 8px;
  border-radius: var(--r-sm);
  transition: background 0.16s;
}
.item:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.item + .item { margin-top: 2px; }
.item-row { display: flex; align-items: center; gap: 9px; }
.item-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 7%, transparent);
}
.item-name { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; }
.item-name b { font-size: 12.3px; font-weight: 500; white-space: nowrap; }
.item-name small { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-count em { font-style: normal; color: var(--good); }

.purity {
  display: flex;
  gap: 5px;
  margin: 7px 0 1px 18px;
}
.purity button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 4px;
  font-size: 10.5px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  transition: all 0.16s;
  white-space: nowrap;
}
.purity button i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.4; transition: opacity 0.16s; }
.purity button:hover { border-color: var(--line-strong); color: var(--text-2); }
.purity button.on { color: var(--text); border-color: color-mix(in srgb, var(--pc, var(--accent)) 55%, transparent); background: color-mix(in srgb, var(--pc, var(--accent)) 14%, transparent); }
.purity button.on i { opacity: 1; }
.purity button b { font-weight: 600; font-variant-numeric: tabular-nums; }
.purity button.off { opacity: 0.55; }

/* 开关 */
.switch {
  display: inline-block;
  position: relative;
  width: 30px;
  height: 17px;
  border-radius: 99px;
  background: rgba(140, 156, 170, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: background 0.2s;
  flex: 0 0 auto;
}
[data-theme="light"] .switch { background: rgba(60, 74, 86, 0.28); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.switch-row input, .item-toggle input, .cat-switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row input:focus-visible + .switch,
.item-toggle input:focus-visible + .switch,
.cat-switch input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.switch-row input:checked + .switch,
.item-toggle input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after,
.item-toggle input:checked + .switch::after { transform: translateX(13px); }

.cat-switch .switch { width: 26px; height: 15px; }
.cat-switch .switch::after { width: 11px; height: 11px; }
.cat-switch input:checked + .switch { background: var(--accent); }
.cat-switch input:checked + .switch::after { transform: translateX(11px); }

.item-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--text);
  flex: 1;
  min-width: 0;
  text-align: left;
}
.item-toggle .switch { width: 24px; height: 14px; }
.item-toggle .switch::after { width: 10px; height: 10px; }
.item-toggle input:checked + .switch { background: color-mix(in srgb, var(--accent) 75%, transparent); }
.item-toggle input:checked + .switch::after { transform: translateX(10px); }

/* 侧栏底部 */
.sidebar-foot {
  flex: 0 0 auto;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-solid) 60%, transparent);
}
.progress-card {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--panel-2) 55%, transparent);
  margin-bottom: 10px;
}
.progress-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 11.5px; color: var(--muted); }
.progress-top span small { font-size: 9.5px; color: var(--muted); opacity: 0.75; margin-left: 2px; }
.progress-top strong { color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.progress-bar { height: 4px; margin: 7px 0 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.35s ease; }
.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0; border: 0; background: none;
  font-size: 11px; color: var(--muted);
}
.link-btn:hover { color: var(--accent-2); }
.link-btn svg { width: 13px; height: 13px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 2px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  position: relative;
}
.range-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 6px 2px;
  font-size: 12px;
  color: var(--text-2);
}
.range-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-row output { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

.sidebar-home {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 11.5px;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.sidebar-home:hover { background: var(--accent-soft); border-color: rgba(250, 149, 73, 0.32); color: var(--accent-2); }
.sidebar-home svg { width: 14px; height: 14px; }

.attribution { margin: 10px 0 0; font-size: 9.5px; line-height: 1.5; color: var(--muted); opacity: 0.8; }

/* ===================== 地图 ===================== */
.map {
  grid-row: 2;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0b1418;
  touch-action: none;
  cursor: grab;
}
[data-theme="light"] .map { background: #d9e3e4; }
.map.dragging { cursor: grabbing; }
#mapCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#mapCanvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

.map-ui { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.map-ui > * { pointer-events: auto; }
.compass, .scalebar, .coord-readout, .map-hint { pointer-events: none; }

.zoom-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-md);
}
.zoom-controls .icon-btn { width: 34px; height: 34px; }

.compass {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-2);
}
.compass::before {
  content: "";
  position: absolute;
  top: 5px;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 7px solid var(--accent);
}
.compass span { margin-top: 8px; }

.minimap {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 150px;
  height: 150px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
  background: var(--bg-soft);
  cursor: crosshair;
}
.minimap canvas { width: 100%; height: 100%; display: block; }
.minimap-label {
  position: absolute;
  left: 8px; bottom: 6px;
  font-size: 9px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.62);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.scalebar {
  position: absolute;
  left: 178px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 76%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.scalebar span { display: block; height: 3px; width: 80px; border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.coord-readout {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(12px);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.coord-readout svg { width: 14px; height: 14px; color: var(--accent); }

.map-hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  padding: 7px 14px;
  font-size: 11.5px;
  color: var(--text-2);
  background: color-mix(in srgb, var(--panel) 76%, transparent);
  border: 1px solid var(--line);
  border-radius: 99px;
  backdrop-filter: blur(10px);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}
.map-hint.show { opacity: 1; }

/* 提示气泡 */
.tooltip {
  position: absolute;
  z-index: 25;
  pointer-events: none;
  padding: 6px 9px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  box-shadow: var(--shadow-sm);
  font-size: 11.5px;
  color: var(--text);
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
}
.tooltip small { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

/* 详情卡 */
.popup {
  position: absolute;
  z-index: 22;
  width: 296px;
  padding: 13px 14px 12px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, calc(-100% - 16px));
  transition: opacity 0.16s;
}
.popup::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px; height: 12px;
  background: var(--panel-solid);
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  transform: translateX(-50%) rotate(45deg);
}
.popup.below { transform: translate(-50%, 18px); }
.popup.below::after { bottom: auto; top: -7px; transform: translateX(-50%) rotate(225deg); }
.popup:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.popup-close { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; }
.popup-close svg { width: 13px; height: 13px; }
.popup-head { display: flex; align-items: flex-start; gap: 10px; padding-right: 26px; }
.popup-dot {
  width: 12px; height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 8%, transparent);
}
.popup-title h3 { margin: 0; font-size: 14.5px; line-height: 1.3; }
.popup-title p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin: 12px 0 13px;
  padding: 10px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--panel-2) 62%, transparent);
  border: 1px solid var(--line);
}
.popup-grid div { min-width: 0; }
.popup-grid dt { font-size: 9.5px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.popup-grid dd { margin: 2px 0 0; font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popup-actions { display: flex; gap: 7px; }
.popup-actions .btn { flex: 1; height: 32px; padding: 0 7px; gap: 4px; font-size: 11px; white-space: nowrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  text-decoration: none;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.12s;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: var(--line-strong); background: color-mix(in srgb, var(--text) 5%, transparent); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: transparent; color: #171008; font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { color: var(--text-2); }
.btn.is-collected { background: color-mix(in srgb, var(--good) 18%, transparent); border-color: color-mix(in srgb, var(--good) 45%, transparent); color: var(--good); }

/* ===================== 弹窗与抽屉 ===================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 7, 10, 0.66);
  backdrop-filter: blur(8px);
  animation: fade-in 0.2s ease;
}
[data-theme="light"] .modal { background: rgba(40, 34, 26, 0.4); }
.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: min(86vh, 760px);
  overflow-y: auto;
  padding: 26px 28px 20px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.modal-close { position: absolute; top: 12px; right: 12px; }
.modal-brand { display: flex; align-items: center; gap: 13px; padding-right: 28px; }
.modal-brand .brand-mark { width: 46px; height: 46px; }
.modal-brand h2 { margin: 0; font-size: 19px; letter-spacing: 0.2px; }
.modal-brand p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.help-section { margin-top: 22px; }
.help-section h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--accent-2);
}
.help-list { margin: 0; padding-left: 18px; }
.help-list li { margin: 6px 0; font-size: 12.8px; line-height: 1.65; color: var(--text-2); }
.help-list b { color: var(--text); font-weight: 600; }
.help-list code {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.key-grid { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12px; color: var(--text-2); }
.key-grid span { display: inline-flex; align-items: center; gap: 5px; }
kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--text);
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.modal-foot b { color: var(--text-2); font-weight: 500; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(4, 7, 10, 0.5);
  backdrop-filter: blur(2px);
  animation: fade-in 0.2s ease;
}

/* ===================== 加载与提示 ===================== */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  transition: opacity 0.45s ease, visibility 0.45s;
}
.loader.hide { opacity: 0; visibility: hidden; }
.loader-mark { color: var(--accent); animation: breathe 2.4s ease-in-out infinite; }
.loader-mark svg { width: 54px; height: 54px; }
.loader p { margin: 0; font-size: 12px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; }
.loader-bar { width: 160px; height: 3px; border-radius: 99px; background: var(--line); overflow: hidden; }
.loader-bar i { display: block; width: 40%; height: 100%; border-radius: 99px; background: var(--accent); animation: slide 1.4s ease-in-out infinite; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 90;
  transform: translate(-50%, 16px);
  padding: 9px 16px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.only-mobile { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.06); opacity: 1; } }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(360%); } }

/* ===================== 响应式 ===================== */
@media (max-width: 1180px) {
  :root { --sidebar-w: 296px; }
  .brand-text small { display: none; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: grid; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    width: min(340px, 88vw);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.3, 0.9, 0.35, 1), visibility 0s linear 0.28s;
    box-shadow: var(--shadow-lg);
    z-index: 36;
  }
  .sidebar.open {
    transform: none;
    visibility: visible;
    transition: transform 0.28s cubic-bezier(0.3, 0.9, 0.35, 1);
  }
  .map { grid-column: 1; }
  .topbar { gap: 10px; padding: 0 10px; }
  .brand-text .brand-name { font-size: 13.5px; }
  .brand-mark { width: 34px; height: 34px; }
  .searchbox { height: 36px; }
  .searchbox kbd { display: none; }
  .minimap { display: none; }
  .scalebar { left: 14px; }
  .map-hint { bottom: 64px; font-size: 10.5px; }
  .popup { width: min(296px, calc(100vw - 24px)); }
  .zoom-controls { top: 10px; right: 10px; }
  .compass { top: 10px; }
  .coord-readout { right: 10px; bottom: 10px; }
}

@media (max-width: 560px) {
  :root { --topbar-h: 56px; }
  .brand-text { display: none; }
  .topbar { gap: 6px; padding: 0 8px; min-width: 0; }
  .brand { padding: 0; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark svg { width: 22px; height: 22px; }
  .searchbox { height: 34px; padding: 0 10px; gap: 6px; }
  .searchbox input { font-size: 12.5px; }
  .top-actions { gap: 2px; }
  .top-actions .icon-btn { width: 32px; height: 32px; }
  .map-hint { display: none; }
  .scalebar { font-size: 10px; }
  .zoom-controls .icon-btn { width: 32px; height: 32px; }
  .modal-card { padding: 22px 18px 16px; }
  .modal-brand h2 { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media (max-height: 700px) {
  .sidebar-foot { padding: 8px 12px 10px; }
  .progress-card { padding: 8px 10px; margin-bottom: 6px; }
  .progress-bar { margin: 5px 0 6px; }
  .attribution { display: none; }
}

/* ===================== 工具集首页 ===================== */
.page-home {
  background:
    radial-gradient(880px 460px at 14% -12%, rgba(250, 149, 73, 0.13), transparent 70%),
    radial-gradient(760px 520px at 96% 2%, rgba(89, 194, 255, 0.07), transparent 72%),
    var(--bg);
}
[data-theme="light"] .page-home {
  background:
    radial-gradient(880px 460px at 14% -12%, rgba(217, 106, 18, 0.12), transparent 70%),
    radial-gradient(760px 520px at 96% 2%, rgba(64, 128, 180, 0.08), transparent 72%),
    var(--bg);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-solid) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
}
.site-header-inner {
  width: min(1120px, 100% - 48px);
  height: var(--topbar-h);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}
.site-nav a {
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.18s, color 0.18s;
}
.site-nav a:hover { background: var(--accent-soft); color: var(--accent-2); }

.home-main {
  width: min(1120px, 100% - 48px);
  margin: 0 auto;
  padding: 64px 0 56px;
  flex: 1 0 auto;
}

.hero { max-width: 780px; }
.hero-eyebrow {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 3.2px;
  text-transform: uppercase;
  color: var(--accent);
}
.hero h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.08;
  letter-spacing: -0.6px;
}
.hero-lead {
  margin: 18px 0 0;
  max-width: 660px;
  font-size: 15px;
  line-height: 1.85;
  color: var(--text-2);
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 20px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.hero-meta b { color: var(--text); font-weight: 600; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.hero-actions .btn { height: 40px; padding: 0 18px; font-size: 13px; }

.home-section { margin-top: 72px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.section-head h2 { margin: 0; font-size: 21px; letter-spacing: 0.2px; }
.section-head p { margin: 0; font-size: 12.5px; color: var(--muted); }

.tools-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}
.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
.tool-card {
  display: flex;
  flex-direction: row;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel-solid);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.tool-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-md);
}
.tool-cover {
  position: relative;
  flex: 0 0 44%;
  min-height: 210px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
}
.tool-cover img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.tool-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 15, 20, 0.68);
  color: #eef5fb;
  font-size: 10.5px;
  letter-spacing: 1px;
  backdrop-filter: blur(6px);
}
.tool-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  padding: 18px 18px 16px;
}
.tool-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  font-size: 17px;
}
.tool-title small {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}
.tool-desc { margin: 0; font-size: 13px; line-height: 1.75; color: var(--text-2); }
.tool-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tool-chips li {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel-2);
  font-size: 10.5px;
  color: var(--text-2);
}
.tool-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.tool-stats { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tool-cta { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--accent); }
.tool-cta svg { width: 14px; height: 14px; }
.tool-card:hover .tool-cta svg { transform: translateX(2px); }
.tool-cta svg { transition: transform 0.18s; }

.status-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
}
.status-card h3 { margin: 0 0 12px; font-size: 13px; letter-spacing: 0.4px; }
.status-list { display: grid; gap: 8px; margin: 0; }
.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
  font-size: 12px;
}
.status-list div:last-child { padding-bottom: 0; border-bottom: 0; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.status-card p { margin: 12px 0 0; font-size: 11px; line-height: 1.7; color: var(--muted); }

.tools-note { margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.tools-note a { color: var(--accent-2); }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.feature-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
}
.feature-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 14px;
  border: 1px solid rgba(250, 149, 73, 0.28);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.feature-icon svg { width: 18px; height: 18px; }
.feature-card h3 { margin: 0; font-size: 14px; }
.feature-card p { margin: 8px 0 0; font-size: 12.5px; line-height: 1.75; color: var(--text-2); }
.home-attribution { margin: 22px 0 0; font-size: 11px; color: var(--muted); }

.site-footer { border-top: 1px solid var(--line); background: var(--panel-solid); }
.site-footer-inner {
  width: min(1120px, 100% - 48px);
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.site-footer p { margin: 0; font-size: 11.5px; color: var(--muted); }
.site-footer nav { display: flex; gap: 14px; }
.site-footer a { font-size: 11.5px; color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--accent-2); }

@media (max-width: 900px) {
  .tools-layout { grid-template-columns: minmax(0, 1fr); }
  .home-main { padding-top: 44px; }
  .home-section { margin-top: 56px; }
}

@media (max-width: 760px) {
  .tool-card { flex-direction: column; }
  .tool-cover {
    flex: none;
    min-height: 0;
    aspect-ratio: 16 / 9;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .site-header-inner,
  .home-main,
  .site-footer-inner { width: calc(100% - 32px); }
  .site-nav a { padding: 8px 9px; font-size: 12.5px; }
  .hero h1 { font-size: 30px; }
  .hero-lead { font-size: 14px; }
  .hero-actions .btn { flex: 1 1 auto; }
  .home-section { margin-top: 48px; }
  .tool-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ===================== 无脚本提示与 404 ===================== */
.noscript {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 200;
  max-width: min(420px, calc(100vw - 40px));
  margin: 0;
  padding: 14px 18px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--panel-solid);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  text-align: center;
}

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-height: 100vh;
  padding: 24px;
  overflow-y: auto;
}
.error-card {
  width: min(520px, 100%);
  margin: auto 0;
  padding: 30px 28px 26px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--panel-solid);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.error-code {
  margin: 0;
  font-family: var(--mono);
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 4px;
  color: var(--accent);
}
.error-title { margin: 12px 0 0; font-size: 20px; letter-spacing: 0.4px; }
.error-text { margin: 10px 0 0; font-size: 13px; line-height: 1.8; color: var(--text-2); }
.error-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; }
.error-actions .btn { height: 38px; padding: 0 18px; text-decoration: none; }
.error-lang { margin: 14px 0 0; font-size: 12px; }
.error-lang a { color: var(--accent-2); }
.error-foot { margin: 0; padding-top: 18px; font-size: 11.5px; color: var(--muted); text-align: center; }

@media (max-width: 560px) {
  .error-page { padding: 18px; }
  .error-card { padding: 24px 18px 20px; }
  .error-code { font-size: 42px; }
}