/* =========================================================
   Color Card · 全局样式
   ========================================================= */

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

:root {
  --bg: #f5f6fa;
  --bg-elev: #ffffff;
  --bg-soft: #f0f2f7;
  --line: #e2e5ec;
  --text: #1f2330;
  --text-muted: #6b7080;
  --text-faint: #9aa0ac;
  --primary: #2c6cf6;
  --primary-hover: #1f57d8;
  --primary-soft: #e8f0ff;
  --danger: #e0445b;
  --success: #21a85a;
  --warn: #f3a93b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 32, 0.05);
  --shadow-md: 0 6px 18px rgba(20, 23, 32, 0.06);
  --shadow-lg: 0 16px 40px rgba(20, 23, 32, 0.08);
  --top-h: 64px;
  /* 灯箱主色区最小高度（改色图 / lab 色块共用），实际高度由 flex 弹性分配 */
  --lb-media-min: 120px;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.28);
}

/* =========================================================
   通用 utilities
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 14px;
  background: var(--bg-soft);
  color: var(--text);
  transition: background 0.15s ease, transform 0.05s ease;
  border: 1px solid transparent;
}
.btn:hover {
  background: #e7eaf2;
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover {
  background: var(--primary-hover);
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}
.btn.ghost:hover {
  background: var(--bg-soft);
}
.btn.danger {
  background: #fde9eb;
  color: var(--danger);
}
.btn.danger:hover {
  background: #fbd5da;
}
.btn.sm {
  padding: 5px 12px;
  font-size: 12px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 108, 246, 0.15);
}
.textarea {
  min-height: 80px;
  resize: vertical;
}
/* 表格内联小号下拉（后台标签：相似色匹配默认标签） */
.select-sm {
  width: auto;
  min-width: 150px;
  max-width: 220px;
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.muted {
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

/* =========================================================
   应用骨架
   ========================================================= */

.app {
  height: 100vh;
  overflow: hidden;
}

/* 主体 */
.main {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* 顶部 topbar（v1.16.0：主页/搜索/收藏夹移到底部 dock，顶栏仅留后台入口 + 语言切换） */
.topbar {
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.topbar .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.topbar .icon-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.topbar .icon-btn svg {
  width: 22px;
  height: 22px;
}

.search {
  flex: 1;
  position: relative;
  max-width: 540px;
}
.search input {
  width: 100%;
  padding: 10px 44px 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.search input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 108, 246, 0.15);
}
.search .search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search .search-btn:hover {
  background: #000;
}
.search .search-btn svg {
  width: 16px;
  height: 16px;
}

.topbar .spacer {
  flex: 1;
}
/* .btn 的 display:inline-flex 会覆盖 UA 的 [hidden]，需显式隐藏 */
.topbar .admin-entry[hidden] {
  display: none;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 4px;
  font-size: 13px;
}
.lang-switch button {
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 500;
}
.lang-switch button.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* =========================================================
   内容区域
   ========================================================= */

.content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  /* v1.16.7：内边距移到 .content-inner —— 顶栏现在是本容器的第一个子元素，
     需要通栏（背景 + 下边框铺满全宽），所以 .content 自身不能再吃左右内边距，
     同时顶栏会随内容一起滚出视口（不再常驻） */
  padding: 0;
}

/* 内容内衬：承接内边距（上 10 / 左右 28 / 下留 dock 高度 96 + 安全区）
   顶栏被排除在外，因此它是通栏的
   v1.16.8：顶距 22 → 10，配合标签行下距收紧，缩短「顶栏 → 色卡展示区」的空白带 */
.content-inner {
  padding: 10px 28px calc(96px + env(safe-area-inset-bottom, 0px));
}

/* 标签栏行：滚动时吸附在内容区顶部悬浮（v1.16.6）
   左对齐（v1.16.8 撤销 v1.16.7 的水平居中回到原位；
   v1.16.9 又删掉了右侧数量徽标 → 本行只剩 .cat-wrap 一个子元素，
   `space-between` 此时等价于 flex-start，保留以兼容日后可能再加的第二个子元素）
   ---------------------------------------------------------
   · `.content` 才是滚动容器（body 不滚），它同时是最近滚动端口，
     而 `.filter-row` 是它的后代 → sticky 天然生效
   · `z-index:20` 必须显式给：`.card{position:relative}`、
     `.card:hover{transform}` 都会让卡片参与定位层绘制，
     不给 z-index 的话卡片会盖住吸附中的胶囊
   · 层级：卡片(0) < 本行(20) < .cat-panel(30) < dock(45)/回到顶部(40) < 灯箱(90)
   · `top:12px` 留一点呼吸位，胶囊与徽标都悬浮在滚动的色卡之上
   · 下距 12（v1.16.8：18 → 12，收紧到色卡展示区的空白；与 #card-grid 的
     margin-top 同级，二者发生外边距合并 → 实际间距取 12） */
.filter-row {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

/* 顶栏：收藏夹入口（位于语言切换按钮左边） */
.fav-entry {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.fav-entry:hover {
  border-color: #c5cad6;
}
.fav-entry svg {
  width: 16px;
  height: 16px;
}
.fav-entry.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.fav-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fav-count[hidden] {
  display: none;
}
.fav-entry.active .fav-count {
  background: #fff;
}

/* 管理后台入口：任何视口下都只显示图标
   （文字节点保留供 i18n / 无障碍使用，视觉上不展示）
   高度与收藏夹入口胶囊统一 38px，11px 侧内边距 → 近似圆形的图标胶囊 */
.admin-entry {
  height: 38px;
  padding: 0 11px;
}
.admin-entry .admin-label {
  display: none;
}
.admin-entry .admin-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.admin-entry .admin-icon svg {
  width: 16px;
  height: 16px;
}

/* 移动端：收藏夹入口收起文字，只留图标 + 数量徽标
   同时收紧顶栏间距，把省下的宽度让给搜索框 */
@media (max-width: 640px) {
  .topbar {
    gap: 10px;
    padding: 0 14px;
  }
  .lang-switch button {
    padding: 5px 9px;
  }
  .fav-entry {
    gap: 6px;
    padding: 0 11px;
  }
  .fav-entry .fav-label {
    display: none;
  }
}

/* 收藏夹页：标签 chip 内的收藏数量徽标 */
.chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip.active .chip-count {
  background: var(--primary);
  color: #fff;
}
/* 0 条收藏的标签置灰（仍可点击） */
.chip-empty {
  color: var(--text-faint);
}
.chip-empty .chip-count {
  color: var(--text-faint);
}

/* 灯箱主图右下角的收藏按钮
   视觉与顶栏胶囊（.fav-entry / .chip）保持一致：
   默认 = 白底 + 细边框(--line) + 正文色；hover 只换边框色；
   已收藏 = 主色浅底 + 主色描边 + 主色图标（对应胶囊的选中态） */
.lightbox-fav {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: border-color 0.15s ease, background 0.15s ease,
    color 0.15s ease;
}
.lightbox-fav svg {
  width: 20px;
  height: 20px;
}
/* 图标容器用 flex 居中，line-height 归零：
   否则 span 会因内联 SVG 的行盒基线产生约 2.5px 的垂直偏移（爱心看起来偏上） */
.lightbox-fav .i-off,
.lightbox-fav .i-on {
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.lightbox-fav .i-off {
  display: flex;
}
.lightbox-fav:hover {
  border-color: #c5cad6;
}
.lightbox-fav.on {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.lightbox-fav.on .i-off {
  display: none;
}
.lightbox-fav.on .i-on {
  display: flex;
}

/* 「回到顶部」按钮：滚动超过阈值后淡入，贴屏幕右侧、与底部 dock 同一水平线
   ---------------------------------------------------------
   · 横向：沿用原来「贴右边」的落点（桌面 24px / ≤640px 14px），
     不去和居中的 dock 争位置
   · 纵向：与 dock 的**中心线**对齐 ——
     dock 底边 20px、高 60px → 中心在视口下沿 50px 处；
     本按钮高 50px，故 `bottom = 50 - 25 = 25px`（比旧的 24px 略下移 1px，
     同时因按钮由 44 → 50px，视觉重心比改前低约 4px，正好落在 dock 中线上）
     底部表达式**与 .dock 共用 `--dock-lift`**：iOS 键盘抬起时两者一起走
   · 尺寸 50px / 图标 22px / 色 `--text-muted`（hover 转 `--text`）
     —— 全部照 .dock-btn 取值
   · 视觉与 .dock **完全同一套毛玻璃**：半透明白 + blur(24px) saturate(180%)
     + 同款边框与投影。它不在 dock 内，无嵌套 backdrop-filter 问题，可直接用
   ⚠️ 展开搜索时 dock 变宽到 343px，窄屏仍可能压到本按钮 →
      dock.js 给 <html> 加 .dock-searching，下面据此淡出
   visibility 参与过渡：隐藏时不进入 tab 序列，也不拦截点击 */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: calc(25px + env(safe-area-inset-bottom, 0px) + var(--dock-lift, 0px));
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(20, 23, 32, 0.07);
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(20, 23, 32, 0.14);
  /* 低于 dock(45)/灯箱(90)/弹窗(100)，避免盖住遮罩层 */
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease,
    border-color 0.15s ease;
}
.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  color: var(--text);
  border-color: #c5cad6;
}
.back-to-top svg {
  width: 22px;
  height: 22px;
}
/* dock 展开搜索时变宽（343px）会与本按钮重叠 → 整片淡出并停止接收点击。
   选择器权重 (0,2,1) 高于 .back-to-top.show (0,2,0)，无需 !important */
html.dock-searching .back-to-top {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
}
/* 移动端：贴右边更近一点（沿用原落点），纵向仍与 dock 中心线对齐 */
@media (max-width: 640px) {
  .back-to-top {
    right: 14px;
  }
}

/* =========================================================
   底部居中悬浮导航栏 dock（v1.16.0）
   玻璃胶囊 168×60：主页 · 搜索 · 收藏夹
   - 搜索展开后宽度 343px（主页/收藏夹暂时隐藏），主色聚焦光晕
   - z-index 45：高于回到顶部(40)，低于灯箱/弹窗(90)
   - --dock-lift 由 dock.js 依据 visualViewport 写入（iOS 键盘避让）
   ========================================================= */
.dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px) + var(--dock-lift, 0px));
  width: 168px;
  height: 60px;
  padding: 5px 9px;
  display: flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(20, 23, 32, 0.07);
  box-shadow: 0 12px 32px rgba(20, 23, 32, 0.14);
  z-index: 45;
  transition: width 0.22s cubic-bezier(0.2, 0.7, 0.3, 1),
    box-shadow 0.18s ease, border-color 0.18s ease;
}
.dock-btns {
  display: flex;
  align-items: center;
  gap: 0;
}
.dock.searching .dock-btns {
  display: none;
}
.dock-btn {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.dock-btn svg {
  width: 22px;
  height: 22px;
}
.dock-btn:hover {
  color: var(--text);
}
/* 选中态：主色系「毛玻璃片」，而不再是 --primary-soft 实色底。
   ⚠️ 玻璃感由「半透明主色底 + 顶部高光 + 主色内描边」承担，
   backdrop-filter 只作增强：dock 自身已是 backdrop root，
   Safari 对嵌套 backdrop-filter 处理不一致，缺失时退化为半透明片，
   视觉仍是玻璃而非实色 —— 所以底不能写回不透明色。 */
.dock-btn.active {
  background: rgba(44, 108, 246, 0.16);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  backdrop-filter: blur(14px) saturate(180%);
  color: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 0 0 1px rgba(44, 108, 246, 0.18),
    0 2px 8px rgba(44, 108, 246, 0.12);
}
/* 收藏数量徽标：贴右上角，白描边与胶囊底分离 */
.dock-count {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
/* .dock-count 是 flex 容器，需显式覆盖 UA 的 [hidden] */
.dock-count[hidden] {
  display: none;
}

/* 展开态：输入框铺满胶囊 */
.dock-search {
  display: none;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 4px;
}
.dock.searching .dock-search {
  display: flex;
}
.dock.searching {
  width: 343px;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 108, 246, 0.15),
    0 12px 32px rgba(20, 23, 32, 0.14);
}
.dock-search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
  color: var(--text-faint);
}
.dock-search-icon svg {
  width: 18px;
  height: 18px;
}
.dock-search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 2px;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
}
.dock-search input::placeholder {
  color: var(--text-faint);
}
.dock-search-clear {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--text-muted);
  line-height: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.dock-search-clear:hover {
  background: rgba(20, 23, 32, 0.07);
  color: var(--text);
}
.dock-search-clear svg {
  width: 15px;
  height: 15px;
}

/* 极窄屏：展开态收敛到视口内，避免 343px 溢出 */
@media (max-width: 380px) {
  .dock.searching {
    width: calc(100vw - 28px);
  }
}
/* 移动端输入字号提到 16px —— iOS Safari 对 <16px 的输入框聚焦时会自动放大页面 */
@media (max-width: 640px) {
  .dock-search input {
    font-size: 16px;
  }
}

/* 收藏夹空状态 */
.fav-empty {
  padding: 64px 20px;
  text-align: center;
}
.fav-empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.fav-empty-icon svg {
  width: 24px;
  height: 24px;
}
.fav-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.fav-empty-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.fav-empty .btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.chip-row {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
  gap: 10px;
}
.chip {
  padding: 8px 18px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.chip:hover {
  border-color: #c5cad6;
}
.chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* =========================================================
   标签：可收起下拉胶囊（v1.16.0）
   收起态只显示当前标签名 + 箭头，点开在下方浮出面板；
   面板 absolute 定位（position:relative 落在 .cat-wrap 上），
   不撑开内容、不改变 .filter-row 高度。
   ========================================================= */
.cat-wrap {
  position: relative;
  min-width: 0;
  max-width: 100%;
}

/* 收起态胶囊：尺寸照原样，视觉与 .dock 用**同一套毛玻璃**（v1.16.6）
   ⚠️ 底必须是半透明：胶囊吸附后会压住滚动的色卡，且这里同样不能依赖
      backdrop-filter（它在 sticky 祖先内、Safari 行为不一致）
      → 玻璃感由 `rgba(255,255,255,.78)` 承担，blur 只作增强 */
.cat-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  max-width: 100%;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(20, 23, 32, 0.07);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(20, 23, 32, 0.14);
  transition: border-color 0.15s ease, background 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}
.cat-select:hover {
  border-color: #c5cad6;
}
.cat-select-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-caret {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.cat-caret svg {
  width: 16px;
  height: 16px;
}
/* 展开态：沿用 .dock-btn.active 那套「主色半透明玻璃」，
   不再用不透明的 --primary-soft，保持整站玻璃语言一致 */
.cat-wrap.open .cat-select {
  background: rgba(44, 108, 246, 0.16);
  border-color: var(--primary);
  color: var(--primary);
}
.cat-wrap.open .cat-caret {
  transform: rotate(180deg);
  color: var(--primary);
}

/* 浮层面板：宽 220，圆角 18px；限高取到能整行放下条目，
   避免底部半截项与面板圆角叠在一起显得「重叠」 */
.cat-panel {
  position: absolute;
  top: calc(100% + 8px);
  /* v1.16.8：胶囊回左对齐 → 面板也回左对齐（与胶囊左缘齐平） */
  left: 0;
  width: 220px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(260px, 42vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border-radius: 18px;
  /* 与胶囊 / dock 同一套玻璃：半透明白 + 大半径模糊，
     面板浮在色卡之上时透出卡片色但文字仍清晰 */
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(20, 23, 32, 0.07);
  box-shadow: 0 12px 32px rgba(20, 23, 32, 0.14);
  z-index: 30;
  animation: pop 0.14s ease;
}
.cat-panel[hidden] {
  display: none;
}
.cat-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.cat-item:hover {
  background: var(--bg-soft);
}
.cat-item-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
/* 面板项里的数量徽标复用 .chip-count（收藏夹页用），去掉胶囊带来的左外边距 */
.cat-item .chip-count {
  margin-left: 0;
  flex: 0 0 auto;
}
.cat-item.active .chip-count {
  background: var(--primary);
  color: #fff;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 18px 14px;
}

@media (max-width: 1280px) {
  .card-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
@media (max-width: 960px) {
  .card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.card {
  position: relative;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
}
.card .swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: var(--bg-soft);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.card .swatch img.lazy {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.card .swatch img.lazy.loaded {
  opacity: 1;
}
.card .code {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  text-align: center;
  padding: 60px 0;
  color: var(--text-faint);
}

/* =========================================================
   分页器：与标签栏同源的胶囊风格
   ========================================================= */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 28px;
  padding-bottom: 6px;
}
.pager[hidden] {
  display: none;
}
.pager-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: all 0.15s ease;
}
.pager-btn:hover:not(:disabled):not(.active) {
  border-color: #c5cad6;
}
.pager-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pager-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.pager-btn svg {
  width: 16px;
  height: 16px;
}
.pager-ellipsis {
  min-width: 22px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 13px;
  user-select: none;
}

@media (max-width: 640px) {
  .pager {
    gap: 5px;
    margin-top: 22px;
  }
  .pager-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }
  .pager-ellipsis {
    min-width: 18px;
    height: 32px;
  }
}

/* =========================================================
   弹层：Modal
   ========================================================= */

@keyframes pop {
  from {
    transform: translateY(-4px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 32, 0.4);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade 0.15s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.18s ease;
}
.modal .modal-head {
  padding: 18px 22px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal .modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.modal .modal-head .close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
}
.modal .modal-head .close:hover {
  background: var(--bg-soft);
}
.modal .modal-body {
  padding: 14px 22px;
  max-height: 70vh;
  overflow: auto;
}
.modal .modal-foot {
  padding: 12px 22px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* =========================================================
   灯箱：TrueColor™ 改色图 + 色彩采样 + 相似色匹配
   同一滚动容器，纵向可滑动
   ========================================================= */
.lightbox {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 860px;
  /* 固定高度：改色图 / 色彩采样两态共用同一容器高度，切换不塌陷、不跳动 */
  height: calc(100vh - 32px);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  animation: pop 0.18s ease;
  overflow: hidden;
}
.lightbox-head {
  flex: 0 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.lightbox-title {
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lightbox-head .close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
}
.lightbox-head .close:hover {
  background: var(--bg-soft);
}
/* 头部右侧操作区：TrueColor™ 开关 + 关闭按钮 */
.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
/* ===== TrueColor™ 开关 ===== */
/* 外层仅作排布容器：文案不可点击，只有 .tc-switch-toggle（开关本体）可点 */
.tc-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
/* TrueColor™ 开关文案：字号与灯箱编号、相似色匹配统一（15px） */
.tc-switch-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.2px;
  white-space: nowrap;
  cursor: default;
  pointer-events: none;
}
.tc-switch-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.tc-switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.tc-switch-track {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #d4d8e1;
  transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.tc-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 23, 32, 0.25);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.tc-switch-input:checked + .tc-switch-track {
  background: var(--primary);
}
.tc-switch-input:checked + .tc-switch-track .tc-switch-thumb {
  transform: translateX(18px);
}
.tc-switch-input:focus-visible + .tc-switch-track {
  box-shadow: 0 0 0 3px var(--primary-soft);
}
/* 文案为静态展示：不可点击，也不随鼠标悬停变色 */
/* 内容区：主色区弹性吸收剩余高度，相似色区固定不压缩 —— 移动端同屏看完不滚动 */
.lightbox-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  /* 仅在可用高度低于主色区 min-height 的极矮屏上才出现滚动 */
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.lightbox-panel {
  flex: 1 1 auto;
  /* 媒体区最小高度，防止主色区被压扁 */
  min-height: var(--lb-media-min);
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* 收藏按钮绝对定位的参照（主图右下角） */
  position: relative;
}
/* 主色区媒体：改色图与 lab 色块填满弹性区域，切换不跳动 */
.lightbox-color {
  flex: 1 1 auto;
  width: 100%;
  min-height: var(--lb-media-min);
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.lightbox-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: var(--bg-soft);
}
.recolor-slot {
  flex: 1 1 auto;
  width: 100%;
  min-height: var(--lb-media-min);
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.recolor-slot .lightbox-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.recolor-loading,
.recolor-error {
  font-size: 13px;
  color: var(--text-muted);
}
.recolor-error {
  color: #c0392b;
}
/* 后台：分类改色源图单元格 */
.cat-src {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
}
.cat-src-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--bg-soft);
  flex-shrink: 0;
}
.cat-src-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 3px 8px;
  flex-shrink: 0;
}
.cat-src-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.cat-src-actions .btn {
  font-size: 12px;
  padding: 2px 8px;
}
/* 后台：标题栏操作按钮组 */
.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 后台：色卡批量操作栏 ===== */
/* 后台色卡列表：按标签筛选（复用前台 .chip 胶囊语言，尺寸收小） */
.admin-filter {
  margin-bottom: 12px;
  gap: 8px;
}
.admin-filter:empty {
  display: none;
}
.admin-filter .chip {
  padding: 5px 14px;
  font-size: 12px;
}

/* 批量选择模式：默认折叠复选框列，点「批量选择」后才展开 */
#panel-cards .col-check {
  display: none;
}
#panel-cards.bulk-mode .col-check {
  display: table-cell;
}

.bulk-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid #d3e0ff;
}
.bulk-bar[hidden] {
  display: none;
}
.bulk-bar .spacer {
  flex: 1;
}
.bulk-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  user-select: none;
}
.bulk-all input[type='checkbox'],
.table input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
}
/* 已选中的行做浅色高亮，便于核对 */
.table tr.row-selected > td {
  background: #f5f8ff;
}
/* 后台：CSV 导入弹窗 */
.csv-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.csv-text {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  overflow: auto;
}
.csv-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}
.csv-modes .radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.csv-report {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.7;
}
.csv-report.ok {
  color: #1a7f37;
}
.csv-report.warn {
  color: #9a6700;
}
.csv-report.error {
  color: #c0392b;
}
.csv-errors {
  margin: 6px 0 0;
  padding-left: 18px;
  color: #c0392b;
  font-size: 12px;
  max-height: 130px;
  overflow: auto;
}
.csv-errors li {
  margin: 2px 0;
}

/* 后台：分类种子色单元格 */
.cat-default {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.cat-default input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.cat-default-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #d3e0ff;
  border-radius: 999px;
  padding: 1px 8px;
}
.cat-default-text:empty {
  display: none;
}

.cat-seed {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
}
.cat-seed-dot {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}
.cat-seed-val {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
/* 种子色取色弹窗 */
.seed-picker {
  position: relative;
  width: 100%;
  max-height: 46vh;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}
.seed-picker canvas {
  display: block;
  max-width: 100%;
  cursor: crosshair;
}
.seed-picker .seed-fallback {
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
}
.seed-cursor {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.seed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.seed-preview {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgb(128 128 128);
}
.seed-in {
  width: 82px;
}
.lightbox-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ===== 相似色匹配（固定于底部，六格永不压缩） ===== */
.similar {
  flex: 0 0 auto;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin-top: 14px;
  padding-top: 14px;
}
.similar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
/* 相似色匹配标题：字号与灯箱编号、TrueColor™ 文案统一（15px） */
.similar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}
.similar-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* 标签下拉选择框 */
.similar-select {
  appearance: none;
  -webkit-appearance: none;
  min-width: 132px;
  max-width: 190px;
  padding: 6px 30px 6px 12px;
  border-radius: 999px;
  background-color: #fff;
  /* 右侧箭头（内联 SVG，避免额外请求） */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7080' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.similar-select:hover {
  border-color: #c5cad6;
}
.similar-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.similar-select option {
  color: var(--text);
  background: #fff;
}
.similar-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.similar-item {
  position: relative;
  display: block;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}
.similar-swatch {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: var(--shadow-sm);
  background-color: var(--bg-soft);
  background-size: cover;
  background-position: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
/* TrueColor™ 模式：改色图加载中的骨架占位 */
.similar-swatch.is-tc:not(.loaded) {
  background-image: linear-gradient(
    100deg,
    #eef1f6 30%,
    #f7f9fc 50%,
    #eef1f6 70%
  );
  background-size: 220% 100%;
  animation: swatchShimmer 1.1s linear infinite;
}
.similar-swatch.is-tc.failed {
  background-image: none;
  background-color: #f3d9d9;
}
@keyframes swatchShimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}
.similar-item:hover .similar-swatch {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
/* 色号：叠加在色块底部，不占额外纵向空间 */
.similar-code {
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  max-width: calc(100% - 8px);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
  color: #fff;
  background: rgba(20, 23, 32, 0.58);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.similar-hint {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0;
}
.similar-hint.error {
  color: #c0392b;
}

/* ===== 灯箱响应式 ===== */
/* 中等屏幕：相似色转 3 列两行 */
@media (max-width: 900px) {
  .similar-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* 平板 / 窄窗（641~900px）：保持 3 列两行的结构不变，仅压扁色块比例 + 紧凑间距。
   该区间 3 列正方形色块单格可达 200~270px，两行相似区高达 470~600px，
   主色区被压到最小 120px（占比仅 18%~46%），故改 2:1 横图回收纵向空间
   （实测主色占比提升到 51%~63%，结构仍为 3 列两行） */
@media (min-width: 641px) and (max-width: 900px) {
  .similar {
    margin-top: 10px;
    padding-top: 10px;
  }
  .similar-head {
    margin-bottom: 8px;
  }
  .similar-grid {
    gap: 8px;
  }
  .similar-swatch {
    aspect-ratio: 2 / 1;
    border-radius: 8px;
  }
  .similar-code {
    bottom: 4px;
    font-size: 10px;
    padding: 1px 6px;
  }
}
/* 移动端：灯箱近似全屏，单列纵向排列，主色区弹性 + 六色固定同屏 */
@media (max-width: 640px) {
  .lightbox-mask {
    padding: 0;
    align-items: stretch;
  }
  .lightbox {
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    animation: none;
  }
  .lightbox-head {
    padding: 12px 14px;
    background: #fff;
  }
  .lightbox-body {
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  }
  /* 窄屏下开关文案保留（用户要求显示当前模式名），标题过长时截断
     字号不再单独收窄：与灯箱编号、相似色匹配统一 15px */
  .lightbox-title {
    flex: 0 1 auto;
    min-width: 0;
  }
  .lightbox-actions {
    flex: 0 0 auto;
  }
  /* 相似色模块收窄：缩略图改横向 3:2 + 紧凑间距，主色区占据主要篇幅 */
  .similar {
    margin-top: 10px;
    padding-top: 10px;
  }
  .similar-head {
    margin-bottom: 8px;
  }
  .similar-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .similar-swatch {
    aspect-ratio: 3 / 2;
    border-radius: 8px;
  }
  .similar-code {
    bottom: 4px;
    font-size: 10px;
    padding: 1px 6px;
  }
}
/* 短屏（iPhone SE 等 ≤700px 高）：进一步压缩相似色模块，主色区优先 */
@media (max-width: 640px) and (max-height: 700px) {
  .lightbox-head {
    padding: 10px 12px;
  }
  .lightbox-body {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .similar {
    margin-top: 8px;
    padding-top: 8px;
  }
  .similar-head {
    margin-bottom: 6px;
  }
  .similar-grid {
    gap: 5px;
  }
  .similar-swatch {
    aspect-ratio: 2 / 1;
  }
  .similar-code {
    bottom: 3px;
    font-size: 9px;
    padding: 1px 5px;
  }
}

.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 23, 32, 0.92);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================
   登录 / 后台
   ========================================================= */

.auth-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef1f8 0%, #f7f8fc 100%);
  padding: 24px;
}
.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.auth-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
}
.auth-card .sub {
  color: var(--text-muted);
  margin-bottom: 22px;
  font-size: 13px;
}
.auth-card .foot {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-card .foot a {
  color: var(--primary);
  font-weight: 500;
}

.admin-shell {
  display: grid;
  grid-template-rows: var(--top-h) 1fr;
  height: 100vh;
}
.admin-shell > .topbar {
  border-bottom: 1px solid var(--line);
}
.admin-body {
  overflow: auto;
  padding: 22px 28px 60px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  padding: 10px 16px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
  font-size: 14px;
}
.tabs button:hover {
  color: var(--text);
}
.tabs button.active {
  color: var(--primary);
  border-color: var(--primary);
}

.section {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.section h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--bg-soft);
}
.table tr:last-child td {
  border-bottom: none;
}
.table .row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* 后台标签：拖动排序 */
.drag-cell {
  width: 52px;
  padding-right: 0 !important;
}
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  color: var(--text-faint);
  cursor: grab;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.drag-handle:hover {
  background: var(--bg-soft);
  color: var(--text-muted);
}
.drag-handle:active {
  cursor: grabbing;
}
.drag-handle svg {
  width: 15px;
  height: 15px;
}
.table tr.dragging {
  opacity: 0.45;
}
.table tr.drag-over > td {
  box-shadow: inset 0 2px 0 0 var(--primary);
}
.color-dot {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.06);
  margin-right: 8px;
}
.image-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--line);
}

.lab-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lab-preview {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: lab(50 0 0);
}
.lab-in {
  width: 88px;
}

.preview-card {
  width: 90px;
  height: 90px;
  border-radius: 12px;
  background: var(--bg-soft);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--line);
}
