/* 动作图标 —— 纯图标墙优先，界面让位给图标本身。 */

/* ------------------------------------------------------------------ 变量 */

:root {
  color-scheme: dark light;

  --bg: #0e1116;
  --bg-elev: #161b23;
  --bg-hover: #1d2430;
  --bg-sunken: #0a0d12;
  --border: #252d3a;
  --border-strong: #334052;
  --text: #e6ebf2;
  --text-dim: #9aa7b8;
  --text-faint: #66748a;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --danger: #ff5d5d;
  --ok: #3ddc97;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --topbar-h: 56px;

  /* 站点 logo（quicker 上的动作图标）。
   * 换 logo 只改这一处，顶栏和登录页会一起生效。 */
  --logo-url: url("https://files.getquicker.net/_icons/5E5C8C35FDA9E28D6E35D9C7E4EAA498A6069306.png");

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

:root[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-hover: #eef1f6;
  --bg-sunken: #e9ecf1;
  --border: #dde2ea;
  --border-strong: #c4ccd8;
  --text: #131820;
  --text-dim: #5a6779;
  --text-faint: #8b98a9;
  --accent: #2f6fe4;
  --accent-soft: rgba(47, 111, 228, 0.1);
  --shadow: 0 8px 32px rgba(16, 24, 40, 0.12);
}

/* ------------------------------------------------------------------ 基础 */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

/* `hidden` 属性必须真的隐藏元素。
 *
 * HTML 规范里 `[hidden]` 只是 `display: none` 的弱声明，任何设置了
 * `display` 的选择器（`.empty{display:grid}`、`.drawer{display:flex}` …）
 * 都会把它压掉，结果是空状态、加载提示、抽屉在页面上常驻显示。
 * 用 `!important` 兜底，省得以后每加一个布局组件都要记得配一条 `[hidden]`。 */
[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ 首页整屏布局 */

/* 顶栏 + 图标区 + 页脚：整页不滚动，只有图标区内部滚动，
 * 这样页脚始终停在视口底部。100dvh 让移动端地址栏收起时也不留空档。 */
.page-index {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.page-index .topbar {
  /* 整页都不滚了，sticky 没有意义；固定在布局顶部即可 */
  position: static;
  flex: 0 0 auto;
}

.page-index main {
  flex: 1 1 auto;
  width: 100%;
  /* flex 子项默认 min-height:auto 会撑破容器，这里必须归零才滚得起来 */
  min-height: 0;
  overflow-y: auto;
  /* 滚到底部时和页脚之间留点空隙 */
  padding-bottom: 28px;
}

/* 页脚常驻视口底部，不随图标区滚动 */
.site-footer {
  flex: 0 0 auto;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
}

.site-footer p {
  margin: 0;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
}

/* 键盘可达性：鼠标点击不显示焦点环，Tab 导航必须显示 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ 顶栏 */

/* 三栏网格：品牌 | 搜索 | 操作
 *
 * 为什么用 grid 而不是 flex + margin:auto：
 * flex 下「居中」取决于左右两侧的实际宽度，而左（品牌 22px 方块 + 文字）
 * 和右（统计文字 + 主题按钮）宽度不同，搜索框会偏。grid 用
 * `1fr auto 1fr` 让两侧都吃掉相同份额，搜索框才是真正的视觉中心。 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  /* 中间列给一个明确的上限（720px），两侧各 1fr 平分剩余空间。
   * 若中间写 auto，它会按输入框内容收缩到 ~300px，撑不起「主角」的分量。 */
  grid-template-columns: 1fr minmax(auto, 720px) 1fr;
  align-items: center;
  gap: 20px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  justify-self: start;
  color: var(--text-dim);
  transition: color 0.15s;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  /* 站点 logo：quicker 上的动作图标。
   * 用 background-image 而不是 <img>，这样它能跟着容器尺寸缩放，
   * 登录页那种放大版本也不用改 HTML。 */
  background-image: var(--logo-url);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

/* ---- 搜索框：页面主角，给足尺寸 ---- */

.search {
  position: relative;
  /* 撑满中间栏（1fr），只受 max-width 约束 ——
   * 若让它按内容收缩，宽度会退到 300px 左右，撑不起「主角」的分量 */
  justify-self: stretch;
  width: 100%;
  max-width: 720px;
  /* 中间栏是 auto 时，靠 margin 让它在 1fr 里居中 */
  margin: 0 auto;
}

.search input {
  width: 100%;
  height: 42px;
  /* 右侧留出「清空 + 提交」两个按钮的位置；左侧只需常规内边距 */
  padding: 0 76px 0 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  font-size: 14.5px;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}

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

.search input:hover {
  border-color: var(--border-strong);
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  /* 焦点时给一圈柔光，把注意力明确引到输入框 */
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.search-btn,
.clear-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.search-btn {
  right: 6px;
}

.clear-btn {
  right: 36px;
  font-size: 17px;
  line-height: 1;
}

.search-btn:hover,
.clear-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* 聚焦时放大镜跟着变亮，暗示「这里可以搜索」 */
.search:focus-within .search-btn {
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

/* 顶栏外链：胶囊比正文低调，hover 才提亮，避免和图标墙抢视线 */
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 12.5px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.stats {
  color: var(--text-faint);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ------------------------------------------------------------------ 主体 */

main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}

/* 最近更新时间：轻量的一行，不抢图标墙的视觉焦点 */
.update-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--text-faint);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.update-line .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  /* 呼吸感：暗示「数据是活的、每天在更新」 */
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent);
  animation: pulse-dot 2.4s ease-out infinite;
}

@keyframes pulse-dot {
  70% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 0%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 0%, transparent);
  }
}

.update-line time {
  color: var(--text-dim);
}

.grid-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.grid-head h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
}

.sort {
  display: flex;
  gap: 6px;
}

/* 工具栏：排序 + 展示模式，靠右对齐 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* 密度滑块：控制每行图标个数 */
.density {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.density-label {
  display: grid;
  place-items: center;
  color: var(--text-faint);
  cursor: pointer;
}

.density input[type="range"] {
  /* 用固定宽度而不是 flex:1，避免工具栏换行时滑块变形 */
  width: 108px;
  height: 4px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: var(--border);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.density input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  appearance: none;
  -webkit-appearance: none;
  cursor: grab;
  transition: transform 0.12s var(--ease);
}

.density input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.density input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: grab;
}

.density input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.density output {
  min-width: 20px;
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ------------------------------------------------------------------ 颜色筛选 */

.color-filter {
  position: relative;
}

.color-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.color-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 232px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}

.color-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s var(--ease);
}

.color-swatch:hover {
  transform: scale(1.08);
}

.color-swatch.is-active {
  border-color: var(--text);
}

.color-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.color-custom input {
  width: 40px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.color-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.color-hint {
  color: var(--text-faint);
  font-size: 11.5px;
}
.chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
}

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

.chip.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
}

/* ------------------------------------------------------------------ 图标网格 */

/* 列数由 --cols 决定（JS 根据滑块写入 10–20）。
 *
 * 为什么不用 `auto-fill minmax(...)`：那样列数由容器宽度算出，
 * 滑块就没法精确控制「一行几个」。固定列数 + `minmax(0, 1fr)` 让卡片
 * 等分宽度，无论窗口多宽都是用户指定的个数。 */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 8), minmax(0, 1fr));
  gap: 12px;
}

/* 窄屏放弃滑块设定，按可用宽度自动折行 ——
 * 一屏塞 20 列会让卡片小到看不清图标。 */
@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  }
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  }
}

/* 被搜索过滤掉的卡片：不占位、不重绘，但 DOM 常驻 */
.tile[data-hidden="1"] {
  display: none;
}

/* 卡片里的动作名：只在 hover 提示里用，卡片本身不显示文字 */
.tile-name {
  display: none;
}

/* 卡片：图标在上，复制按钮在下 */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 10px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease),
    transform 0.14s var(--ease), box-shadow 0.14s var(--ease);
  /* 只对可见区域内的卡片做渲染，长列表滚动时不卡 */
  content-visibility: auto;
  contain-intrinsic-size: 132px 132px;
}

.tile:hover,
.tile:focus-within {
  border-color: var(--border-strong);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  z-index: 1;
}

/* ---- 图标区（可点击打开详情）---- */

.tile-thumb {
  display: grid;
  place-items: center;
  /* 正方形预览区，让不同尺寸的图标看起来一样大 */
  aspect-ratio: 1;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  /* 棋盘格底：透明 PNG 在深浅两种主题下都能看清边界 */
  background-color: var(--bg-sunken);
  background-image: linear-gradient(45deg, var(--bg-elev) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg-elev) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg-elev) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg-elev) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  cursor: zoom-in;
  transition: background-color 0.14s var(--ease);
}

.tile-thumb:hover {
  background-color: color-mix(in srgb, var(--bg-sunken) 70%, var(--accent));
}

.tile-thumb img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---- 复制按钮 ---- */

.tile-copy {
  display: block;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}

.tile-copy:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.tile-copy:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 复制成功的即时反馈 */
.tile-copy.is-copied {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
}

.tile-copy.is-copy-failed {
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

/* 多个链接/动作名的角标：暗示这张图被多处引用 */
.tile[data-shared="1"]::after {
  content: attr(data-count);
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* 加载失败的图：显示占位符号而不是浏览器的碎图 */
.tile.is-broken .tile-thumb::before {
  content: "?";
  color: var(--text-faint);
  font-size: 22px;
}

.tile.is-broken .tile-thumb img {
  display: none;
}
/* 骨架屏：尺寸要贴近卡片，否则加载完成时会跳一下 */
.skeleton {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(
    100deg,
    var(--bg-elev) 30%,
    color-mix(in srgb, var(--bg-elev) 60%, var(--bg-hover)) 50%,
    var(--bg-elev) 70%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ------------------------------------------------------------------ 空态 */

.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 96px 20px;
  text-align: center;
  color: var(--text-dim);
}

.empty-icon {
  color: var(--text-faint);
  margin-bottom: 6px;
}

.empty p {
  margin: 0;
}

.empty-hint {
  color: var(--text-faint);
  font-size: 12.5px;
}

/* ------------------------------------------------------------------ 加载更多 */

.sentinel {
  height: 1px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------------ 详情抽屉 */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(420px, 100vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slide-in 0.22s var(--ease);
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 32px;
  overscroll-behavior: contain;
}

.preview {
  display: grid;
  place-items: center;
  padding: 28px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* 棋盘格：透明图标在深色抽屉里也能看出边界 */
  background-color: var(--bg-sunken);
  background-image: linear-gradient(45deg, var(--bg-elev) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg-elev) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg-elev) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg-elev) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.preview img {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 22px;
  color: var(--text-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.section {
  margin-bottom: 22px;
}

.section h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.section h3 .count {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* 详情里的主色与调色板 */
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.color-chip {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.color-palette {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.name-list li {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 12.5px;
  word-break: break-word;
}

.url-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.url-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 12px;
}

.url-list .u {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.url-list .hits {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.42);
  animation: fade-in 0.18s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* ------------------------------------------------------------------ 表单与卡片 */

.auth-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

/* 安装页要填数据库信息，字段多，放宽一些并允许纵向滚动 */
.auth-card-wide {
  max-width: 520px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.form-section {
  margin: 20px 0 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.form-section:first-of-type {
  margin-top: 4px;
}

.form-note {
  margin: -2px 0 12px;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.65;
}

.form-note b {
  color: var(--text-dim);
  font-weight: 600;
}

.form-note code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--text-dim);
}

/* 主机+端口、监听地址+端口这种一行的组合 */
.field-row {
  display: flex;
  gap: 10px;
}

.field-grow {
  flex: 1;
  min-width: 0;
}

.field-port {
  width: 92px;
}

.field-port input {
  text-align: center;
}

.auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.auth-brand .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 650;
  text-align: center;
  letter-spacing: -0.01em;
}

.auth-sub {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
  line-height: 1.6;
}

.field {
  display: block;
  margin-bottom: 13px;
}

.field span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.field input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-error {
  margin: 0 0 14px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
  font-size: 12.5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 86%, #fff);
  border-color: color-mix(in srgb, var(--accent) 86%, #fff);
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  height: 29px;
  padding: 0 11px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.inline-form {
  display: inline;
}

/* ------------------------------------------------------------------ 后台 */

.who {
  color: var(--text-dim);
  font-size: 12.5px;
}

.admin {
  display: grid;
  gap: 18px;
  max-width: 940px;
}

.admin h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.admin h3 {
  margin: 22px 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.admin p {
  margin: 0 0 14px;
}

.muted {
  color: var(--text-faint);
  font-size: 12.5px;
}

.stats-line {
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
}

.row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.row input {
  flex: 1;
  height: 36px;
  padding: 0 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.row input:focus {
  outline: none;
  border-color: var(--accent);
}

.token-reveal {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.token-warn {
  margin: 0 0 9px;
  font-size: 12.5px;
  font-weight: 600;
}

.token-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.token-box code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
}

.code {
  margin: 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  overflow-x: auto;
  line-height: 1.6;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.table th,
.table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.badge-ok {
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
}

.badge-off {
  background: color-mix(in srgb, var(--text-faint) 16%, transparent);
  color: var(--text-faint);
}

.table .actions-cell {
  text-align: right;
}

/* ------------------------------------------------------------------ Toast */

.toast {
  position: fixed;
  left: 50%;
  /* 抬到页脚之上：首页页脚常驻底部，气泡不能压在说明文字上 */
  bottom: 56px;
  z-index: 80;
  transform: translateX(-50%);
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  animation: toast-in 0.2s var(--ease);
}

.toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* ------------------------------------------------------------------ 响应式 */

@media (max-width: 720px) {
  /* 窄屏放不下「品牌 + 搜索 + 操作」三栏：
     搜索独占第二行，品牌与操作留在第一行两侧。 */
  .topbar {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "brand actions"
      "search search";
    gap: 8px 12px;
    height: auto;
    padding: 8px 12px 10px;
  }

  .brand {
    grid-area: brand;
  }

  .topbar-right {
    grid-area: actions;
  }

  .search {
    grid-area: search;
    max-width: none;
  }

  .search input {
    height: 40px;
    font-size: 14px;
  }

  .brand span:last-child {
    display: none;
  }

  .stats {
    display: none;
  }

  main {
    padding: 14px 12px;
  }

  .grid {
    /* 手机上按可用宽度自动折行，滑块设定让位给可读性 */
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 8px;
  }

  .tile {
    padding: 8px 8px 8px;
  }

  .drawer {
    width: 100vw;
  }
}

/* 系统级「减少动态效果」：关掉所有装饰性动画 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
