/* ============================================================
 * 资源分享站 —— 全局样式（浅色主题 / 移动端优先）
 * ============================================================ */

/* ============================================================
 * 主题变量
 * 默认紫罗兰；切换 data-theme 即整体换肤（含 Hero 渐变与光斑）
 * ============================================================ */
:root {
  /* 更简洁耐看的中文字体栈：优先苹方 / 鸿蒙 / 雅黑，回退系统 UI 字体 */
  --font-sans: 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', 'Hiragino Sans GB',
               system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  /* 这里的默认值 = 「默认」主题（亮色）。
   * 为什么不只写在 [data-theme="mixue-luckin"] 里：HTML 解析到 JS 应用主题之间有几十毫秒，
   * 这期间页面用的就是 :root 的值。之前这里还留着旧版紫色，所以打开首页会"闪一下旧界面"。
   * 保持与「默认」主题一致，首帧就是正确配色。 */
  --brand: #002d62;
  --brand-2: #1565c0;
  --accent: #e60012;
  --brand-soft: #e8eef7;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --line: #e6e8f0;
  --text: #1a1c25;
  --text-2: #5b6070;
  --text-3: #8b90a0;
  --danger: #e11d48;
  --success: #059669;
  --hero-a: #eaf1fb;
  --hero-b: #fdeef2;
  --glow-1: #4a7fd4;
  --glow-2: #ffc72c;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 4px 12px rgba(16, 24, 40, .08), 0 16px 40px rgba(16, 24, 40, .10);
  --maxw: 1080px;
}

/* 「默认」主题（id 沿用 mixue-luckin）
 * 品牌色融合了蜜雪与瑞幸：两个品牌的共同色是「蓝」（瑞幸深蓝 / 雪王蓝圆底），
 * 故以蓝为主调（深蓝 → 亮蓝，主按钮与 Hero 渐变干净高级），
 * accent 取蜜雪红作为渐变尾段与装饰线，红蓝对比一眼认得出；
 * 光斑用金 / 冰淇淋黄，Hero 背景微微发暖。
 * 对比度：#002d62 对白字约 13:1（远优于 AA 4.5:1） */
[data-theme="mixue-luckin"] {
  --brand: #002d62; --brand-2: #1565c0; --accent: #e60012;
  --brand-soft: #e8eef7;
  --bg: #f4f7fb;
  /* Hero 渐变：左上淡蓝 → 右下淡粉 */
  --hero-a: #eaf1fb; --hero-b: #fdeef2;
  --glow-1: #4a7fd4; --glow-2: #ffc72c;
}

/* 「暗夜」主题（id 沿用 graphite）
 * 它是「默认」主题的深色版，所以品牌色同样走蓝 + 红，而不是旧版的紫罗兰——
 * 两套主题看起来才像同一个站点的日间 / 夜间模式。
 * 文字刻意提亮：旧版 --text-2 #aab0c0 / --text-3 #7d8393 在深底上发灰，
 * 现在分别为 #ccd3e2 / #9aa3b5（对背景约 11:1 与 6.5:1，都高于 AA 要求）。 */
[data-theme="graphite"] {
  --brand: #6ea8fe; --brand-2: #4f8ef7; --accent: #f4614f;
  --brand-soft: #1c2438;
  --bg: #0f131a;
  --surface: #161b24;
  --line: #2a3140;
  --text: #f5f7fb;
  --text-2: #ccd3e2;
  --text-3: #9aa3b5;
  --danger: #f87171;
  --success: #4ade80;
  --hero-a: #141a26; --hero-b: #1b1622;
  --glow-1: #4f8ef7; --glow-2: #f4614f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

/* 兜底：HTML 的 hidden 属性只是 UA 样式里的 display:none，
 * 任何组件一旦声明了自己的 display（如 .cat-more { display:inline-flex }）就会把它盖掉，
 * 于是出现「元素明明显示着，JS 里的 el.hidden 却是 true」这种自相矛盾的状态——
 * 分类栏的「更多」按钮点击无反应就是这么来的（按钮显示着，但处理函数一开头
 * 就 if (moreBtn.hidden) return 直接返回了）。这条规则保证 hidden 永远说了算。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* 让页脚始终贴在页面底部：内容不足一屏时也不会上浮 */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
/* 内容区占据剩余高度（隐藏的视图不参与布局） */
body > main:not([hidden]) { flex: 1 0 auto; }
.site-footer { flex: none; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

/* 移动端安全区：iOS 刘海屏左右留白 */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
  /* 内容层级高于背景装饰层 */
  position: relative;
  z-index: 1;
}

/* ---------------- 顶部导航 ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
}

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

.brand-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.brand-logo img { width: 100%; height: 100%; object-fit: cover; }

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: .18s;
  white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------- 公告条 ---------------- */
.notice {
  background: linear-gradient(90deg, var(--brand-soft), #faf5ff);
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  font-size: 13px;
  padding: 9px 0;
}
.notice .wrap { display: flex; gap: 8px; align-items: flex-start; }
.notice svg { flex: 0 0 16px; margin-top: 3px; color: var(--brand); }

/* ---------------- 手绘简笔画装饰 ---------------- */

/* 视口两侧的常驻装饰层：固定在背景，不拦截点击 */
.doodle-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.doodle-layer .doodle {
  position: absolute;
  color: var(--brand);
  opacity: .2;
}
[data-theme="graphite"] .doodle-layer .doodle { opacity: .26; }

/* 卡片 / Hero 内部的装饰（相对宿主容器定位） */
.doodle-box {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.doodle-box .doodle {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  color: var(--brand);
  opacity: .3;
}
[data-theme="graphite"] .doodle-box .doodle { opacity: .34; }

.doodle svg { width: 100%; height: 100%; display: block; }

/* 背景装饰以 x/y 百分比为中心定位（translate -50%），全部视口可见 */
.doodle-layer .doodle {
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
}

/* 首次载入的描边绘制动画：用 backwards 填充，动画未播放/结束时
   图形都完整显示（dash 只存在于动画过程中），不会因环境差异消失 */
.doodle svg > * {
  animation: doodleDraw 2.2s ease backwards;
  animation-delay: var(--delay, 0s);
}
@keyframes doodleDraw {
  from { stroke-dasharray: 100; stroke-dashoffset: 100; }
  to { stroke-dasharray: 100; stroke-dashoffset: 0; }
}

/* 持续动效：漂浮 / 摆动 / 闪烁 / 漂移 */
.d-anim-float {
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  animation: doodleFloat var(--dur, 9s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.d-anim-swing {
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  animation: doodleSwing var(--dur, 10s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.d-anim-twinkle {
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1);
  animation: doodleTwinkle var(--dur, 5s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.d-anim-drift {
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  animation: doodleDrift var(--dur, 10s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes doodleFloat {
  0%, 100% { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); }
  50% { transform: translate(-50%, calc(-50% - 14px)) rotate(calc(var(--rot, 0deg) + 3deg)); }
}
@keyframes doodleSwing {
  0%, 100% { transform: translate(-50%, -50%) rotate(calc(var(--rot, 0deg) - 6deg)); }
  50% { transform: translate(-50%, -50%) rotate(calc(var(--rot, 0deg) + 6deg)); }
}
@keyframes doodleTwinkle {
  0%, 100% { opacity: .3; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(.9); }
  50% { opacity: .95; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.08); }
}
@keyframes doodleDrift {
  0%, 100% { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); }
  33% { transform: translate(calc(-50% + 8px), calc(-50% - 10px)) rotate(calc(var(--rot, 0deg) + 4deg)); }
  66% { transform: translate(calc(-50% - 6px), calc(-50% + 6px)) rotate(calc(var(--rot, 0deg) - 3deg)); }
}

/* 窄屏：内容占满视口，装饰大部分被卡片盖住，降低透明度避免杂乱 */
@media (max-width: 1280px) {
  .doodle-layer .doodle { opacity: .16; }
}
@media (max-width: 640px) {
  .hero .doodle-box { display: none; }
  .doodle-layer .doodle { opacity: .12; }
  .doodle-box .doodle { opacity: .13; }
}

/* 系统开启「减少动效」时关闭所有装饰动画 */
@media (prefers-reduced-motion: reduce) {
  .doodle svg > *,
  .d-anim-float, .d-anim-swing, .d-anim-twinkle, .d-anim-drift { animation: none; }
}

/* ---------------- Hero 横幅（含搜索，位于分类上方） ---------------- */
.hero {
  position: relative;
  margin: 18px 0 16px;
  padding: 36px 24px 28px;
  border-radius: 22px;
  background:
    radial-gradient(120% 140% at 15% 0%, var(--hero-a) 0%, rgba(255, 255, 255, 0) 55%),
    radial-gradient(120% 140% at 85% 100%, var(--hero-b) 0%, rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, var(--surface) 0%, var(--brand-soft) 55%, var(--brand-soft) 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: center;
  transition: background .3s, border-color .3s;
}

.hero-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(52px);
  opacity: .5;
  pointer-events: none;
}
.hero-glow-1 {
  width: 280px; height: 280px;
  background: var(--glow-1);
  top: -130px; left: -70px;
  animation: heroFloat1 9s ease-in-out infinite;
}
.hero-glow-2 {
  width: 240px; height: 240px;
  background: var(--glow-2);
  bottom: -120px; right: -50px;
  animation: heroFloat2 11s ease-in-out infinite;
}
@keyframes heroFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, 20px) scale(1.08); }
}
@keyframes heroFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-26px, -18px) scale(1.06); }
}

/* Hero 上的细网格纹理，四周渐隐，增加质感 */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(124, 58, 237, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 58, 237, .07) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(78% 72% at 50% 42%, #000 35%, transparent 100%);
  mask-image: radial-gradient(78% 72% at 50% 42%, #000 35%, transparent 100%);
  pointer-events: none;
}

.hero-inner { position: relative; max-width: 700px; margin: 0 auto; }

/* Hero 数据统计胶囊 */
.hero-stats {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 0 18px;
}
.hero-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hero-stat b {
  color: var(--brand);
  font-size: 13.5px;
  font-weight: 700;
}

.hero-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: .5px;
  margin: 0 0 8px;
  background: linear-gradient(120deg, var(--brand) 10%, var(--brand-2) 45%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--brand);
}

.hero-sub {
  color: var(--text-2);
  font-size: 15px;
  margin: 0 0 20px;
}

/* Hero 内的工具栏（搜索 + 排序），居中展示 */
.hero .toolbar {
  justify-content: center;
  padding: 0;
  flex-wrap: nowrap;
}

.hero .search-box { flex: 1 1 320px; }

.hero .search-box input {
  height: 46px;
  border-radius: 14px;
  padding-left: 42px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(124, 58, 237, .18);
  box-shadow: 0 4px 18px rgba(79, 70, 229, .10);
  font-size: 14.5px;
}
.hero .search-box input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .14), 0 8px 26px rgba(79, 70, 229, .16);
}
.hero .search-box svg { left: 15px; width: 18px; height: 18px; color: var(--brand); }

.hero .sort-tabs {
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(124, 58, 237, .18);
  box-shadow: 0 4px 18px rgba(79, 70, 229, .10);
}
.hero .sort-tab.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 3px 12px rgba(124, 58, 237, .35);
}

/* ---------------- 分类横滑栏 ---------------- */
.cat-section { position: relative; padding-top: 2px; }

/* 左右渐隐，暗示还可以横滑 */
.cat-section::before,
.cat-section::after {
  content: '';
  position: absolute;
  top: 0; bottom: 12px;
  width: 26px;
  pointer-events: none;
  z-index: 2;
}
.cat-section::before { left: -16px; background: linear-gradient(90deg, var(--bg), rgba(245, 246, 250, 0)); }
.cat-section::after { right: -16px; background: linear-gradient(270deg, var(--bg), rgba(245, 246, 250, 0)); }

.cat-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 16px 14px;
  margin: 0 -16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cat-bar::-webkit-scrollbar { display: none; }

.cat-item {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 68px;
  padding: 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s, background .2s;
}
.cat-item:hover {
  border-color: rgba(124, 58, 237, .4);
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(79, 70, 229, .14);
}
.cat-item.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 24px rgba(124, 58, 237, .38);
}

.cat-item .ci-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
  overflow: hidden;
  transition: background .2s, color .2s, transform .2s;
}
.cat-item:hover .ci-icon { transform: scale(1.06); }
.cat-item.active .ci-icon { background: rgba(255, 255, 255, .24); color: #fff; }
.cat-item .ci-icon img { width: 100%; height: 100%; object-fit: cover; }

.cat-item .ci-name {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .3px;
  color: var(--text);
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .2s;
}
.cat-item:hover .ci-name { color: var(--brand); }
.cat-item.active .ci-name { color: #fff; font-weight: 600; }

/* 资源数量：与名称明显区分的小胶囊，数字等宽避免跳动 */
.cat-item .ci-count {
  margin-top: 2px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .2px;
  font-variant-numeric: tabular-nums;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid rgba(124, 58, 237, .16);
  transition: color .2s, background .2s, border-color .2s;
}
.cat-item.active .ci-count {
  color: var(--brand);
  background: #fff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}

/* ---------------- 工具栏：搜索 + 排序 ---------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
}
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  outline: none;
  transition: .18s;
}
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }

.sort-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.sort-tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: .18s;
  white-space: nowrap;
}
.sort-tab.active { background: var(--brand); color: #fff; font-weight: 600; }

/* ---------------- 资源列表（单列） ---------------- */
/* 切换分类 / 搜索 / 排序时：列表由上向下展开，卡片依次淡入 */
@keyframes listReveal {
  from { clip-path: inset(0 0 100% 0); opacity: .35; }
  to { clip-path: inset(0 0 0 0); opacity: 1; }
}
.res-list.list-reveal {
  animation: listReveal .42s cubic-bezier(.22, .9, .3, 1);
}
@keyframes cardReveal {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: none; }
}
.res-card.card-reveal {
  animation: cardReveal .4s cubic-bezier(.22, .9, .3, 1) backwards;
}

/* 打开资源详情时的快速展开：内容自上而下展开，各区块依次淡入
   注意：详情容器是 #detail-body（class 为 detail-wrap），选择器用 id */
#detail-body.detail-reveal {
  animation: listReveal .36s cubic-bezier(.22, .9, .3, 1);
}
#detail-body.detail-reveal > * {
  animation: cardReveal .38s cubic-bezier(.22, .9, .3, 1) backwards;
}
#detail-body.detail-reveal > *:nth-child(1) { animation-delay: .02s; }
#detail-body.detail-reveal > *:nth-child(2) { animation-delay: .09s; }
#detail-body.detail-reveal > *:nth-child(3) { animation-delay: .16s; }
#detail-body.detail-reveal > *:nth-child(4) { animation-delay: .23s; }
#detail-body.detail-reveal > *:nth-child(5) { animation-delay: .3s; }
@media (prefers-reduced-motion: reduce) {
  .res-list.list-reveal,
  .res-card.card-reveal,
  #detail-body.detail-reveal,
  #detail-body.detail-reveal > * { animation: none; }
}

.res-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* 与 Hero 横幅完全同宽，上下左右对齐 */
  max-width: none;
  margin: 0;
  padding-bottom: 40px;
}

.res-card {
  position: relative;
  display: flex;
  gap: 16px;
  padding: 16px 18px 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  overflow: hidden;
  transition: transform .22s, box-shadow .22s, border-color .22s;
}
/* 左侧渐变竖条 */
.res-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2), #db2777);
  opacity: 0;
  transition: opacity .22s;
}
/* 不再使用悬停扫光：只在悬停时做光晕与边框变化，避免来回扫动的干扰 */
/* 悬停光晕：只改阴影/边框，不再整体位移。
   之前 hover 时 translateY 会让卡片从鼠标下方“跑开”，
   鼠标在边缘时反复触发 hover，造成闪烁抖动。 */
.res-card:hover {
  border-color: rgba(124, 58, 237, .45);
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, .18),
    0 8px 20px rgba(79, 70, 229, .10),
    0 18px 44px rgba(79, 70, 229, .18);
  background: linear-gradient(180deg, rgba(124, 58, 237, .035), rgba(124, 58, 237, 0) 60%), var(--surface);
}
.res-card:hover::before { opacity: 1; }
/* 悬停时内部元素微动，制造“浮起”的观感而不改变卡片自身位置 */
.res-card:hover .res-thumb { transform: scale(1.04); }
.res-card:hover .res-title { color: var(--brand); }
.res-arrow { transition: transform .22s, background .22s, color .22s; }
.res-card:hover .res-arrow {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  transform: translateX(3px);
}
.res-thumb { transition: transform .28s cubic-bezier(.22, .9, .3, 1); }

.res-thumb {
  position: relative;
  flex: 0 0 116px;
  width: 116px;
  height: 116px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand-soft), var(--bg));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(124, 58, 237, .06);
}
.res-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* 热度榜前三角标 */
.res-rank {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 3;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .3px;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 2px 8px rgba(239, 68, 68, .35);
}
.res-rank.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); box-shadow: 0 2px 8px rgba(100, 116, 139, .3); }
.res-rank.rank-3 { background: linear-gradient(135deg, #d97706, #b45309); box-shadow: 0 2px 8px rgba(180, 83, 9, .3); }

.res-arrow {
  flex: 0 0 26px;
  align-self: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  background: var(--bg);
  transition: transform .22s, background .22s, color .22s;
}
.res-card:hover .res-arrow {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  transform: translateX(3px);
}

.res-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }

.res-title {
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.45;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color .2s;
}
.res-card:hover .res-title { color: var(--brand); }

.res-summary {
  font-size: 13.5px;
  color: var(--text-2);
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.res-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-3);
  margin-top: auto;
  flex-wrap: wrap;
}

.res-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.res-hot { display: inline-flex; align-items: center; gap: 3px; color: var(--danger); }

/* ---------------- 详情页 ---------------- */
.detail-wrap { max-width: 780px; padding: 18px 16px 40px; }

/* 返回列表：做成醒目的渐变胶囊按钮 */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  margin-bottom: 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(124, 58, 237, .28);
  transition: transform .2s, box-shadow .2s;
}
.back-link:hover {
  color: #fff;
  transform: translateX(-4px);
  box-shadow: 0 10px 26px rgba(124, 58, 237, .4);
}
.back-link:active { transform: translateX(0) scale(.98); }
.back-link svg { flex: 0 0 auto; }

.detail-head {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 18px 16px;
  margin-bottom: 14px;
}
.detail-head::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--accent));
}

.detail-title {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 12px;
}

.detail-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------------- 一键排版：统一文章版式（后台编辑器与前台详情共用，所见即所得） ---------------- */
.article-body {
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: .2px;
  color: #33353d;
  font-family: var(--font-sans);
}
[data-theme="graphite"] .article-body { color: var(--text); }

.article-body > *:first-child { margin-top: 0 !important; }
.article-body > *:last-child { margin-bottom: 0 !important; }

.article-body p {
  margin: 0 0 1.05em;
  text-align: justify;
  word-break: break-word;
}

.article-body h1, .article-body h2, .article-body h3, .article-body h4 {
  font-weight: 700;
  line-height: 1.45;
  margin: 1.5em 0 .75em;
  color: #1f2130;
}
[data-theme="graphite"] .article-body h1,
[data-theme="graphite"] .article-body h2,
[data-theme="graphite"] .article-body h3,
[data-theme="graphite"] .article-body h4 { color: var(--text); }

.article-body h2 {
  font-size: 19px;
  padding-left: 12px;
  border-left: 4px solid var(--brand);
}
.article-body h3 { font-size: 17px; }
.article-body h4 { font-size: 16px; }

.article-body img.art-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.3em auto;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(16, 24, 40, .08);
}

.article-body blockquote {
  margin: 1.3em 0;
  padding: .85em 1.1em;
  background: var(--brand-soft);
  border-left: 4px solid var(--brand);
  border-radius: 0 10px 10px 0;
  color: var(--text-2);
}

.article-body ul, .article-body ol { margin: 0 0 1.1em; padding-left: 1.6em; }
.article-body li { margin: .35em 0; }

.article-body a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-body strong, .article-body b { font-weight: 700; color: #1f2130; }
[data-theme="graphite"] .article-body strong,
[data-theme="graphite"] .article-body b { color: var(--text); }

.article-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

/* 后台编辑区头部：标题与「一键排版」按钮同一行 */
.ed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

/* 富文本正文 */
.rich-body {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  overflow-wrap: break-word;
}
.rich-body p { margin: 0 0 .9em; }
.rich-body ul, .rich-body ol { margin: 0 0 .9em; padding-left: 1.6em; }
.rich-body li { margin-bottom: .35em; }
.rich-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 10px 0;
}
.rich-body blockquote {
  margin: 0 0 1em;
  padding: 10px 14px;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 8px 8px 0;
  color: var(--text-2);
}
.rich-body pre {
  background: #1e2130;
  color: #e6e8f0;
  padding: 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
}
.rich-body a { color: var(--brand); text-decoration: underline; }
.rich-body table { border-collapse: collapse; width: 100%; margin-bottom: 1em; }
.rich-body th, .rich-body td { border: 1px solid var(--line); padding: 8px 10px; }

/* 下载区 */
.dl-box {
  position: relative;
  background:
    linear-gradient(180deg, var(--brand-soft) 0%, rgba(255, 255, 255, 0) 120px),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}
.dl-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dl-tip { font-size: 12px; color: var(--text-3); margin: 0 0 14px; }

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

.dl-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #fafbff, #f6f7ff);
  cursor: pointer;
  text-align: left;
  transition: .18s;
  width: 100%;
}
.dl-btn:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 14px rgba(79, 70, 229, .14);
  transform: translateY(-2px);
}
.dl-btn:active { transform: translateY(0) scale(.99); }

.dl-btn .d-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* 上传的图标一律铺满所在图标框（覆盖 Icons.render 生成的内联尺寸） */
.dl-btn .d-icon img,
.mini-icon img,
.icon-preview img,
.cat-item .ci-icon img,
.brand-logo img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.dl-btn .d-text { min-width: 0; flex: 1; }
.dl-btn .d-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dl-btn .d-code { font-size: 11px; color: var(--text-3); }

.dl-open {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  cursor: pointer;
}
.dl-open:hover { color: var(--brand); border-color: var(--brand); }

/* ---------------- 空态 / 加载 ---------------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty svg { opacity: .5; margin-bottom: 12px; }

/* ---------------- Toast ---------------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  background: rgba(26, 28, 37, .94);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  transition: .26s cubic-bezier(.2, .8, .3, 1);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: linear-gradient(135deg, #059669, #10b981); }
.toast-error { background: linear-gradient(135deg, #e11d48, #f43f5e); }

/* ---------------- 图标占位 ---------------- */
/* 自定义上传的图标：铺满整个图标框（配合上传时的裁剪编辑器，保证主体居中） */
.img-icon { object-fit: cover; border-radius: 6px; display: block; }
.txt-icon {
  display: inline-block;
  text-align: center;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}

/* ---------------- 页脚 ---------------- */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  padding: 22px 0 30px;
  color: var(--text-3);
  font-size: 12.5px;
  text-align: center;
  background: var(--surface);
}

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .wrap { padding: 0 12px; }

  .hero { margin: 12px 0 12px; padding: 24px 14px 20px; border-radius: 18px; }
  .hero-title { font-size: 24px; }
  .hero-sub { font-size: 13.5px; margin-bottom: 16px; }
  .hero .toolbar { flex-wrap: wrap; gap: 8px; }
  .hero .search-box { flex: 1 1 100%; }
  .hero .search-box input { height: 44px; border-radius: 12px; }
  .hero .sort-tabs { flex: 1 1 100%; justify-content: center; }

  .hero-stats { gap: 6px; }
  .hero-stat { padding: 4px 10px; font-size: 12px; }
  .res-list { gap: 12px; }
  .res-card { padding: 13px 14px 13px 16px; gap: 12px; }
  .res-thumb { flex-basis: 88px; width: 88px; height: 88px; }
  .res-title { font-size: 15.5px; }
  .detail-title { font-size: 19px; }
  .rich-body { padding: 16px; }
  .dl-grid { grid-template-columns: 1fr; }
  .brand-name { font-size: 16px; }
  .toast { font-size: 13.5px; padding: 10px 16px; }
}

/* ---------------- 风格选择（主题切换） ---------------- */
.theme-switch { position: relative; }

.theme-menu {
  position: absolute;
  right: 0;
  top: 44px;
  width: 196px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 80;
  animation: menuIn .18s ease;
}
.theme-menu[hidden] { display: none; }

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  transition: .16s;
}
.tm-item:hover { background: var(--bg); color: var(--text); }
.tm-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tm-check { margin-left: auto; font-size: 12px; opacity: .85; }
.tm-swatch {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, .06);
}

/* ---------------- 深色主题（石墨黑）下的局部适配 ---------------- */
[data-theme="graphite"] .site-header { background: rgba(23, 26, 33, .9); }
[data-theme="graphite"] .hero .search-box input,
[data-theme="graphite"] .hero .sort-tabs { background: rgba(23, 26, 33, .72); color: var(--text); border-color: var(--line); }
[data-theme="graphite"] .notice { background: linear-gradient(90deg, #212634, #241a2c); }
[data-theme="graphite"] .btn-ghost { background: var(--surface); border-color: var(--line); }
[data-theme="graphite"] .res-thumb { background: linear-gradient(135deg, #23273a, #1f2230); }
[data-theme="graphite"] .hero-stat { background: rgba(23, 26, 33, .75); }
[data-theme="graphite"] .hero::before {
  background-image:
    linear-gradient(rgba(139, 92, 246, .10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 92, 246, .10) 1px, transparent 1px);
}
[data-theme="graphite"] .toast { background: #e9ebf2; color: #111319; }
[data-theme="graphite"] .admin-body { background: #0e1014; }
[data-theme="graphite"] .admin-side { background: var(--surface); border-color: var(--line); }
[data-theme="graphite"] .icon-grid { background: #14171e; }
[data-theme="graphite"] .input,
[data-theme="graphite"] .select,
[data-theme="graphite"] .textarea { background: #14171e; color: var(--text); }
[data-theme="graphite"] .icon-cell { background: #1b1f27; color: var(--text-2); }
[data-theme="graphite"] .editor-toolbar { background: #14171e; border-color: var(--line); }
[data-theme="graphite"] .login-mask { background: linear-gradient(135deg, #12161f, #171b26); }
[data-theme="graphite"] .modal,
[data-theme="graphite"] .login-card { background: var(--surface); }

/* ---------------- 图片裁剪编辑器 ---------------- */
#img-editor-wrap {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ie-mask {
  position: absolute;
  inset: 0;
  background: rgba(17, 19, 25, .5);
}
.ie-card {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-width: 94vw;
  max-height: 94vh;
  overflow: auto;
  animation: menuIn .18s ease;
}
.ie-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.ie-body { display: flex; gap: 18px; padding: 18px; flex-wrap: wrap; }
.ie-stage {
  border-radius: 12px;
  overflow: hidden;
  background: #f4f5f9;
  cursor: grab;
  touch-action: none;
  flex: 0 0 auto;
}
.ie-stage:active { cursor: grabbing; }
.ie-side { width: 180px; }
.ie-preview-title { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.ie-preview {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.ie-ctrl { margin-top: 14px; }
.ie-ctrl label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.ie-ctrl input[type="range"] { width: 100%; }
.ie-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.ie-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}
@media (max-width: 640px) {
  .ie-body { padding: 12px; }
  .ie-side { width: 100%; }
}

/* ---------------- 后台公共组件 ---------------- */
.admin-body { background: #f4f5f9; }

.admin-shell { display: flex; min-height: 100vh; }

.admin-side {
  width: 210px;
  flex: 0 0 210px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.admin-side h2 {
  font-size: 13px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 18px 0 8px;
  padding-left: 10px;
}
.admin-side h2:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: .16s;
}
.nav-item:hover { background: #f3f4f8; color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.admin-main { flex: 1; min-width: 0; padding: 22px 26px 60px; }

.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-desc { color: var(--text-3); font-size: 13px; margin: 0 0 18px; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; }

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-2);
}
.form-row .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: #fff;
  outline: none;
  transition: .16s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}
.textarea { min-height: 84px; resize: vertical; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: .16s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { opacity: .92; color: #fff; }
.btn-danger { color: var(--danger); border-color: #f5c9d3; }
.btn-danger:hover { background: #fff1f4; color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-weight: 600; font-size: 14px; }
.list-row .lr-sub { font-size: 12px; color: var(--text-3); }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.mini-icon {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.mini-icon img { width: 100%; height: 100%; object-fit: cover; }

/* 图标选择器 */
.icon-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.icon-preview {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--brand-soft);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex: 0 0 44px;
}
.icon-preview img { width: 100%; height: 100%; object-fit: cover; }

/* 图标面板：作为行内元素排在图标预览的右侧，一行固定 10 个图标。
   不用浮层/绝对定位，避免遮挡下方的操作按钮与表单。 */
.icon-grid {
  flex: 1 1 380px;
  max-width: 424px;
  align-self: flex-start;
  display: grid;
  grid-template-columns: repeat(10, 34px);
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 1px 3px rgba(16, 24, 40, .04);
}
.icon-cell {
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-cell:hover { border-color: var(--brand); }
.icon-cell.selected { background: var(--brand); color: #fff; border-color: var(--brand); }

/* 富文本编辑器 */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: #fbfbfe;
  align-items: center;
}
.ed-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: .14s;
}
.ed-btn:hover { background: #efeff5; color: var(--text); }
.ed-btn.active { background: var(--brand-soft); color: var(--brand); }
.ed-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.ed-select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 6px;
  background: #fff;
  font-size: 13px;
  max-width: 118px;
}
.ed-color {
  width: 32px; height: 32px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.editor-area {
  min-height: 320px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
  background: #fff;
  outline: none;
  overflow-wrap: break-word;
}
.editor-area:focus { border-color: var(--brand); }
.editor-area img { max-width: 100%; height: auto; border-radius: 8px; margin: 6px 0; }
.editor-area:empty::before {
  content: attr(data-placeholder);
  color: var(--text-3);
}

/* 登录遮罩 */
.login-mask {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #eef0ff, #faf5ff);
  /* 默认隐藏：由 JS 确认需要登录/设置口令时才加 .show 显示，
     这样即使脚本初始化出错，也不会只剩一层浅色遮罩（看起来像白屏） */
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.login-mask.show { display: flex; }
.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-card h1 { font-size: 19px; margin: 12px 0 4px; }
.login-card p { color: var(--text-3); font-size: 13px; margin: 0 0 20px; }
.login-card .input { text-align: center; margin-bottom: 12px; }

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 32, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 300;
}
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 20px;
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }

/* ---------------- 后台：资源筛选栏与批量操作条 ---------------- */
.res-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.res-filter .input,
.res-filter .select {
  width: auto;
  min-width: 132px;
}
.res-filter #f-kw { flex: 1 1 220px; min-width: 180px; }
.res-filter .f-num { min-width: 92px; }
.res-filter .f-sep {
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--text-2);
}
.bulk-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.bulk-count { flex: 1; }
.res-check,
.bulk-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}
.lr-select {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding-right: 2px;
}

@media (max-width: 640px) {
  .res-filter .input,
  .res-filter .select { min-width: 120px; flex: 1 1 140px; }
}

/* 服务器共享数据模式提示条 */
.remote-banner {
  background: linear-gradient(135deg, #eef2ff, #fdf4ff);
  border: 1px solid rgba(124, 58, 237, .25);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-2);
}
.remote-banner .rb-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 4px;
  font-size: 13.5px;
}
.remote-banner code {
  background: rgba(79, 70, 229, .1);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-side {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .admin-side h2 { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .admin-main { padding: 16px 14px 60px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  /* 窄屏放不下 10 列时自动换行到下一行，并减少每行个数 */
  .icon-grid { grid-template-columns: repeat(6, 34px); max-width: 100%; }
}

@media (max-width: 640px) {
  .icon-grid { grid-template-columns: repeat(5, 32px); }
}

/* ============================================================
 * 设计系统精修层（Design Polish）
 *
 * 目的：在不改动结构的前提下提升视觉品质与一致性：
 *   1. 补全设计令牌（间距 / 圆角 / 阴影 / 动效 / 焦点环）
 *   2. 强化视觉层次（卡片、Hero、分类、详情）
 *   3. 补齐无障碍（键盘焦点可见、触摸目标 ≥44px、文字对比度 AA）
 *   4. 统一深色主题表现（后台卡片/输入框改用语义色而非硬编码白）
 *
 * 本层位于文件末尾用于覆盖上方基础样式；如需回滚，删除本区块即可。
 * ============================================================ */

/* ---------- 1. 设计令牌 ---------- */
:root {
  /* 间距：4pt 网格 */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* 圆角阶梯 */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;

  /* 阴影层级（三层，对应静态 / 悬停 / 浮起） */
  --e-1: 0 1px 2px rgba(16, 24, 40, .05);
  --e-2: 0 2px 8px rgba(16, 24, 40, .06), 0 10px 26px rgba(16, 24, 40, .07);
  --e-3: 0 4px 14px rgba(16, 24, 40, .08), 0 18px 44px rgba(16, 24, 40, .11);

  /* 动效 */
  --t-fast: .16s cubic-bezier(.4, 0, .2, 1);
  --t-base: .24s cubic-bezier(.22, .9, .3, 1);

  /* 焦点环：键盘操作必须可见（WCAG 2.4.7） */
  --ring: 0 0 0 3px rgba(79, 70, 229, .32);

  /* 次级文字提深：#8b90a0 在白底仅约 3.4:1，未达 AA 4.5:1 */
  --text-3: #6f7484;

  /* 西文优先 San Francisco（iPhone 同款），中文自动回退到系统字体 */
  --font-sf: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
             'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
[data-theme="graphite"] {
  --e-1: 0 1px 2px rgba(0, 0, 0, .35);
  --e-2: 0 2px 8px rgba(0, 0, 0, .4), 0 10px 26px rgba(0, 0, 0, .42);
  --e-3: 0 4px 14px rgba(0, 0, 0, .45), 0 18px 44px rgba(0, 0, 0, .5);
  --ring: 0 0 0 3px rgba(129, 140, 248, .4);
}

/* ---------- 2. 焦点可见性：键盘可达 ---------- */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
.res-card:focus-visible,
.cat-item:focus-visible,
.sort-tab:focus-visible,
.dl-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- 3. 按钮：统一高度、按压反馈、主按钮光晕 ---------- */
.btn {
  min-height: 40px;
  border-radius: var(--r-md);
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast),
              border-color var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { box-shadow: var(--e-1); }
.btn:active { box-shadow: inset 0 2px 4px rgba(16, 24, 40, .08); }

.btn-primary {
  box-shadow: 0 2px 8px rgba(124, 58, 237, .26);
}
.btn-primary:hover {
  opacity: 1;
  filter: brightness(1.05);
  box-shadow: 0 6px 18px rgba(124, 58, 237, .36);
}
.btn-primary:active { box-shadow: 0 2px 6px rgba(124, 58, 237, .28); }

.btn-sm { min-height: 32px; }
/* 触摸设备上放大到易于点击（≥40px 接近 44px 标准） */
@media (hover: none) {
  .btn-sm { min-height: 40px; padding: 9px 14px; }
  .cat-item { min-height: 44px; }
}

/* ---------- 4. 资源卡片：紧凑横排（约为原高度的 3/5） ---------- */
.res-card {
  gap: var(--sp-3);
  padding: 10px 14px;
  border-radius: var(--r-lg);
  box-shadow: var(--e-1);
  transition: box-shadow var(--t-base), border-color var(--t-base), background var(--t-base);
}
.res-card:hover {
  box-shadow: var(--e-3);
}
/* 按压反馈：让点击有实感（不影响命中区域，不会抖动） */
.res-card:active { box-shadow: var(--e-1); }

.res-thumb {
  flex: 0 0 84px;
  width: 84px;
  height: 84px;
  border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px rgba(124, 58, 237, .08), 0 2px 8px rgba(16, 24, 40, .06);
}

.res-title {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -.1px;
  margin-bottom: 3px;
  -webkit-line-clamp: 1;
  line-clamp: 1;              /* 标题只占一行，卡片更矮更整齐 */
}
.res-summary { font-size: 12.5px; line-height: 1.5; margin-bottom: 6px; }

.res-meta { gap: 8px; row-gap: 3px; font-size: 11px; }
.res-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.res-arrow { width: 24px; height: 24px; flex: 0 0 24px; }

.res-tag { border-radius: var(--r-sm); font-weight: 500; }

/* ---------- 5. Hero：更大更有层次 ---------- */
.hero {
  padding: 44px 28px 32px;
  border-radius: var(--r-xl);
  box-shadow: var(--e-2);
}
.hero-title {
  font-size: clamp(28px, 4.2vw, 40px);
  line-height: 1.22;
  letter-spacing: -.6px;
}
.hero-sub {
  font-size: 15.5px;
  line-height: 1.7;
  max-width: 46ch;
  margin: 0 auto 22px;
}
.hero-stat {
  padding: 6px 14px;
  font-weight: 500;
  box-shadow: var(--e-1);
}
.hero-stat b { font-size: 14px; }
@media (max-width: 640px) {
  .hero { padding: 32px 18px 26px; }
  .hero-title { letter-spacing: -.2px; }
}

/* ---------- 6. 分类按钮：椭圆胶囊形（图标 / 名称 / 数量横排） ---------- */
.cat-item {
  width: auto;
  height: 38px;                 /* 固定高度，一行内高度整齐 */
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 0 13px 0 8px;
  border-radius: var(--r-full);
  box-shadow: var(--e-1);
  transition: transform var(--t-fast), box-shadow var(--t-fast),
              border-color var(--t-fast), background var(--t-fast);
}
.cat-item:hover {
  transform: scale(1.03);
  box-shadow: var(--e-2);
}
.cat-item:active { transform: scale(.98); }
.cat-item .ci-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 999px;
}
.cat-item .ci-name {
  width: auto;              /* 覆盖竖排时的 width:100% */
  font-size: 13.5px;
  text-align: left;
}
.cat-item .ci-count { margin-top: 0; }
.cat-item.active { box-shadow: 0 6px 18px rgba(124, 58, 237, .32); }

/* 分类栏：单行排列，放不下的收进右侧「更多」弹层（见 app.js renderCategories） */
.cat-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.cat-bar {
  flex: 1 1 auto;
  min-width: 0;                 /* 允许被压缩，宽度才能算准 */
  gap: 8px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  flex-wrap: nowrap;
}
.cat-section::before,
.cat-section::after { display: none; }

/* 「更多」按钮：与分类胶囊同高，视觉上属于同一排 */
.cat-more {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--e-1);
  transition: color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.cat-more:hover { color: var(--brand); border-color: rgba(124, 58, 237, .4); }
.cat-more:active { box-shadow: var(--e-1); }
.cat-more-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform var(--t-fast);
}
.cat-more.open { color: var(--brand); border-color: rgba(124, 58, 237, .4); }
.cat-more.open .cat-more-caret { transform: rotate(180deg); }

/* 「更多」弹层：网格展示被收起的分类，超长可滚动 */
.cat-pop {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-height: 302px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--e-3);
  animation: catPopIn .16s ease both;
}
.cat-pop[hidden] { display: none; }
@keyframes catPopIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.cat-pop .cat-item { width: 100%; min-width: 0; }
.cat-pop .cat-item .ci-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 7. 详情页：标题层级与下载区质感 ---------- */
.detail-title {
  font-size: clamp(22px, 2.8vw, 27px);
  font-weight: 800;
  line-height: 1.32;
  letter-spacing: -.3px;
}
.dl-btn {
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--e-1);
  transition: box-shadow var(--t-base), border-color var(--t-base);
}
.dl-btn:hover {
  transform: none;              /* 去掉位移，避免指针“追不上”按钮 */
  border-color: var(--brand);
  box-shadow: var(--e-2);
}
.dl-btn:hover .d-icon { transform: scale(1.06); }
.dl-btn .d-icon { transition: transform var(--t-base); }
.dl-btn:active { box-shadow: var(--e-1); }

/* ---------- 8. 后台一致性：改用语义色，深色主题不再“白得刺眼” ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
  box-shadow: var(--e-1);
}
.input, .select, .textarea {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 10px var(--sp-3);
  min-height: 40px;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: var(--ring);
}
/* 后台列表行：更清晰的分割与留白 */
.list-row {
  padding: 12px 0;
  gap: var(--sp-3);
}
.list-row .lr-title { font-size: 14.5px; font-weight: 600; }

/* ============================================================
 * 启动闪屏（Splash）
 * 打开首页时：透明浮层 + 品牌文字（颜色随主题变化），约 2 秒渐渐消失。
 * 背景完全透明，只让文字浮在页面上；文字内容取自后台站点设置。
 * ============================================================ */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: transparent;          /* 其余部分透明 */
  color: var(--brand);              /* 文字跟随主题色 */
  /* 淡入 0.45s → 停留至 0.55s → 淡出 1.4s，总时长约 2s */
  animation: splashOut 1.4s ease .55s forwards;
}
@keyframes splashOut {
  to { opacity: 0; visibility: hidden; }
}

.splash-brand {
  padding: 0 22px;
  max-width: 92vw;
  animation: splashIn .45s cubic-bezier(.22, .9, .3, 1) both;
}
@keyframes splashIn {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: none; }
}

/* 站点名：字号放大一倍，San Francisco 字体，颜色与标语保持同一色系 */
.splash-name {
  font-family: var(--font-sf);
  font-size: clamp(38px, 12vw, 88px);
  font-weight: 800;
  letter-spacing: .5px;
  line-height: 1.25;
  color: var(--brand);
  word-break: break-word;
}
/* 标语：与标题同色（略淡），保持视觉一致 */
.splash-slogan {
  margin-top: 14px;
  font-family: var(--font-sf);
  font-size: clamp(16px, 4.4vw, 30px);
  font-weight: 500;
  letter-spacing: .3px;
  color: var(--brand);
  opacity: .78;
}

/* 系统开启「减少动效」时不展示闪屏（由 JS 直接移除，这里做兜底） */
@media (prefers-reduced-motion: reduce) {
  .splash { display: none; }
}

/* ---------- 9. 降低动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .btn, .btn-primary, .res-card, .cat-item, .dl-btn, .dl-btn .d-icon {
    transition: none !important;
  }
  .cat-item:hover, .cat-item:active { transform: none !important; }
}

/* ---------- 10. 移动端适配（主页 / 详情页） ---------- */
@media (max-width: 640px) {
  /* --- 主页：列表与卡片更紧凑 --- */
  .res-list { gap: 12px; padding-bottom: 28px; }
  .res-card { padding: 10px 12px; gap: 12px; }
  .res-thumb { flex: 0 0 72px; width: 72px; height: 72px; border-radius: var(--r-sm); }
  .res-title { font-size: 15px; }
  .res-summary { font-size: 12px; margin-bottom: 5px; }
  .res-meta { font-size: 10.5px; gap: 7px; }
  .res-arrow { width: 22px; height: 22px; flex: 0 0 22px; }

  /* --- Hero --- */
  .hero-stat { padding: 5px 11px; font-size: 12px; }
  .hero-stat b { font-size: 13px; }
  .hero .search-box input { height: 44px; font-size: 14px; }

  /* --- 分类：单行 + 「更多」
   * 手机上分类往往十几个，铺开会把资源列表挤到屏幕外。
   * 主栏只留「名称」——去掉图标与数量后每个胶囊窄一大截，
   * 一行能多放 1~2 个；完整信息（图标/数量）放「更多」弹层里看。 */
  .cat-row { gap: 6px; }
  .cat-bar { gap: 6px; }
  .cat-item {
    height: 34px;
    min-height: 34px;
    gap: 0;
    padding: 0 11px;
  }
  .cat-item .ci-icon { display: none; }
  .cat-item .ci-name { font-size: 12.5px; }
  .cat-item .ci-count { display: none; }
  .cat-more { height: 34px; padding: 0 11px; font-size: 12.5px; }

  /* 弹层：2 列网格，图标与数量都补回来（这里空间够） */
  .cat-pop {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 10px;
    max-height: 268px;
  }
  .cat-pop .cat-item { height: 34px; min-height: 34px; gap: 6px; padding: 0 9px 0 6px; }
  .cat-pop .cat-item .ci-icon { display: inline-flex; width: 20px; height: 20px; flex: 0 0 20px; }
  .cat-pop .cat-item .ci-name { font-size: 12px; }
  .cat-pop .cat-item .ci-count { display: inline-flex; font-size: 9.5px; padding: 1px 5px; }

  /* --- 详情页：单列、留白收紧 --- */
  .detail-wrap { padding: 14px 12px 32px; }
  .back-link { padding: 9px 16px; font-size: 13.5px; margin-bottom: 12px; }
  .detail-head { padding: 16px 14px 13px; margin-bottom: 12px; }
  .detail-title { font-size: 21px; }
  .detail-sub { font-size: 11.5px; gap: 8px; }
  .rich-body { padding: 14px; }
  .article-body { font-size: 15.5px; line-height: 1.75; }
  .article-body h2 { font-size: 18px; }
  .dl-box { padding: 14px; }
  .dl-grid { grid-template-columns: 1fr; }   /* 下载按钮单列，更好点 */
  .dl-btn { padding: 11px 13px; }
  .dl-title { font-size: 15px; }
}

/* ============================================================
 * 后台：分类「显示优先级」输入框
 * 数值越小越靠前；数字等宽避免跳动，宽度固定让每行对齐
 * ============================================================ */
.order-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}
.order-input {
  width: 68px;
  height: 34px;
  padding: 0 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* ============================================================
 * 设计稿还原层（Editorial 版式）
 * 按用户提供的设计稿重做前台版式：深色顶条 + 白底顶栏 + 公告条 +
 * 居中 Hero（统计胶囊 / 搜索行 / 右上加号）+ 分类胶囊 + 图标式资源卡 + 深蓝页脚。
 * 集中放在文件末尾以便整体覆盖前面的规则，需要回滚时整段删除即可。
 * ============================================================ */

/* ---------- 顶部深色细条 ---------- */
body::before {
  content: '';
  display: block;
  flex: 0 0 auto;
  height: 6px;
  background: color-mix(in srgb, var(--brand) 88%, #000);
}

/* ---------- 顶栏 ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  backdrop-filter: none;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand);
  overflow: hidden;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -.2px; }
.brand-tagline { font-size: 11px; color: var(--text-3); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions .btn-ghost {
  height: 34px;
  padding: 0 12px;
  gap: 6px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 13px;
}
.header-actions .btn-ghost:hover { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }

/* ---------- 公告条 ---------- */
.notice {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.notice .wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  font-size: 13px;
  color: var(--text-2);
}
.notice-icon { display: inline-flex; color: var(--accent); flex: 0 0 auto; }
.notice-link {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 13px;
}
.notice-link:hover { text-decoration: underline; }

/* ---------- 内容区宽度 ---------- */
.wrap { max-width: 780px; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  margin: 18px 0 14px;
  padding: 34px 30px 30px;
  border-radius: 20px;
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--brand) 10%, transparent);
  background: linear-gradient(135deg, var(--hero-a) 0%, var(--hero-b) 100%);
  overflow: visible;
}
.hero-glow { display: none; }        /* 旧版光斑在新版式里不要 */
/* 旧版的 28px 网格纹理也不要在（设计稿是干净的渐变卡片） */
.hero::before, .hero::after { display: none; }
/* 背景装饰：小尺寸 + 更淡，不与正文抢注意力 */
.doodle-layer .doodle { opacity: .17; }
.hero-inner { position: relative; z-index: 1; }
.hero-title {
  margin: 0 0 16px;
  font-size: clamp(22px, 2.4vw, 27px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.3px;
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--brand);
}
.hero-plus {
  position: absolute;
  top: 14px; right: 14px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-3);
  font-size: 17px; line-height: 1;
  display: grid; place-items: center;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
.hero-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.hero-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 12%, transparent);
  font-size: 12.5px;
  color: var(--text-2);
}
.hero-stat svg { color: var(--brand); }
.hero-stat b { color: var(--text); font-weight: 600; }

/* Hero 搜索行 */
.hero .toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.hero .search-box {
  flex: 1 1 auto;
  max-width: 340px;
  min-width: 0;
  height: 42px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--brand) 10%, var(--line));
  box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
}
.hero .search-box input { height: 100%; font-size: 13.5px; }
.hero .search-box svg { color: var(--text-3); }
.hero-search-btn {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 13.5px;
}
.hero .sort-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  box-shadow: none;
}
.hero .sort-tab {
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--brand) 10%, var(--line));
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.hero .sort-tab.active {
  background: var(--surface);
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}
.hero-icon-btn {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--brand) 10%, var(--line));
  color: var(--brand);
  cursor: pointer;
}
.hero-icon-btn:hover { background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }

/* ---------- 分类胶囊：彩色图标 ---------- */
.cat-section { margin: 0 0 14px; }
.cat-item .ci-icon {
  background: color-mix(in srgb, var(--cat-color, var(--brand)) 14%, var(--surface));
  color: var(--cat-color, var(--brand));
}
.cat-item.active {
  background: var(--cat-color, var(--brand));
  border-color: transparent;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--cat-color, var(--brand)) 34%, transparent);
}
.cat-item.active .ci-icon { background: rgba(255, 255, 255, .24); color: #fff; }
.cat-item .ci-count {
  background: color-mix(in srgb, var(--cat-color, var(--brand)) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--cat-color, var(--brand)) 18%, transparent);
  color: var(--cat-color, var(--brand));
}
.cat-item.active .ci-count { background: #fff; color: var(--cat-color, var(--brand)); border-color: transparent; }

/* ---------- 资源卡片：图标式 ---------- */
.res-list { gap: 10px; }
.res-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}
.res-card:hover {
  border-color: color-mix(in srgb, var(--cat-color, var(--brand)) 34%, var(--line));
  box-shadow: 0 6px 18px rgba(16, 24, 40, .07);
  transform: none;
}
.res-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 58px;
  flex: 0 0 58px;
}
.res-cat-tag {
  max-width: 100%;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--cat-color, var(--brand));
  background: color-mix(in srgb, var(--cat-color, var(--brand)) 12%, var(--surface));
}
.res-cat-tag.is-empty { color: var(--text-3); background: var(--bg); }
.res-icon {
  position: relative;
  width: 58px; height: 58px;
  border-radius: 15px;
  display: grid; place-items: center;
  overflow: hidden;
  color: var(--cat-color, var(--brand));
  background: color-mix(in srgb, var(--cat-color, var(--brand)) 13%, var(--surface));
}
.res-icon img { width: 100%; height: 100%; object-fit: cover; }
.res-rank {
  position: absolute;
  top: 3px; right: 3px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  display: grid; place-items: center;
}
.res-rank.rank-1 { background: #e11d48; }
.res-rank.rank-2 { background: #ea580c; }
.res-rank.rank-3 { background: #ca8a04; }
.res-main { min-width: 0; }
.res-title {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.res-summary {
  margin: 0 0 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.res-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--text-3); }
.res-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.res-arrow {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg);
  color: var(--text-3);
}
.res-card:hover .res-arrow { background: color-mix(in srgb, var(--cat-color, var(--brand)) 12%, var(--bg)); color: var(--cat-color, var(--brand)); }

/* ---------- 页脚：深色 ---------- */
.site-footer {
  margin-top: 30px;
  padding: 30px 0 18px;
  background: #16244c;
  background: color-mix(in srgb, var(--brand) 88%, #000);
  border-top: 0;
  color: #fff;
}
.site-footer .wrap { display: block; text-align: center; }
.footer-brand { display: flex; align-items: center; justify-content: center; gap: 9px; }
.footer-logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .16);
  overflow: hidden;
}
.footer-logo img { width: 100%; height: 100%; object-fit: cover; }
.footer-name { font-size: 16px; font-weight: 700; color: #fff; }
.footer-desc {
  margin: 10px auto 0;
  max-width: 520px;
  font-size: 12px;
  line-height: 1.7;
  color: rgba(255, 255, 255, .62);
}
.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: 11.5px;
  color: rgba(255, 255, 255, .5);
}
.footer-links { display: flex; gap: 18px; }
.footer-links a, .footer-links button {
  color: rgba(255, 255, 255, .68);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.footer-links a:hover, .footer-links button:hover { color: #fff; }

/* ---------- 设计稿还原层的响应式 ---------- */
/* 中等宽度：Hero 搜索行折成两行（搜索框一行、排序一行），避免拥挤 */
@media (max-width: 860px) {
  .hero .toolbar { flex-wrap: wrap; row-gap: 8px; }
  .hero .search-box { flex: 1 1 160px; max-width: none; }
  .hero .sort-tabs { flex: 1 1 100%; }
  .hero .sort-tab { flex: 1 1 0; justify-content: center; }
}

@media (max-width: 640px) {
  .site-header .wrap { height: 56px; }
  .brand-logo { width: 30px; height: 30px; flex-basis: 30px; border-radius: 9px; }
  .brand-name { font-size: 15.5px; }
  .brand-tagline { font-size: 10px; }
  .header-actions { gap: 6px; }
  .header-actions .btn-ghost { padding: 0 11px; height: 34px; font-size: 12.5px; gap: 5px; }

  .notice .wrap { height: 40px; font-size: 12px; gap: 6px; }
  .notice-link { font-size: 12px; }

  .hero { margin: 12px 0 12px; padding: 22px 16px 20px; border-radius: 16px; }
  .hero-title { font-size: 20px; margin-bottom: 12px; }
  .hero-plus { display: none; }
  .hero-stats { gap: 6px; margin-bottom: 14px; }
  .hero-stat { padding: 4px 10px; font-size: 11.5px; }
  .hero .search-box { height: 40px; flex: 1 1 100%; }
  .hero-search-btn { height: 40px; padding: 0 18px; flex: 1 1 auto; }
  .hero .sort-tab { height: 38px; font-size: 12.5px; }
  .hero-icon-btn { display: none; }

  .res-list { gap: 9px; }
  .res-card { padding: 10px 12px; gap: 11px; border-radius: 13px; }
  .res-left { width: 50px; flex-basis: 50px; gap: 5px; }
  .res-icon { width: 50px; height: 50px; border-radius: 13px; }
  .res-cat-tag { font-size: 9.5px; padding: 1px 5px; }
  .res-title { font-size: 14.5px; }
  .res-summary { font-size: 12px; margin-bottom: 6px; }
  .res-meta { gap: 10px; font-size: 11px; }
  .res-arrow { width: 26px; height: 26px; }

  .site-footer { padding: 24px 0 16px; }
  .footer-bottom { flex-direction: column; gap: 10px; }
  .footer-links { gap: 14px; }
}

/* ============================================================
 * 分类标签：去掉图标，只留「名称 + 数量」
 * 图标每个要占 26px + 8px 间距（约 34px/个），去掉后同一行能多放 1~2 个，
 * 标签本身也更轻。高度保持 36/34px 不缩水——点击区域靠高度和整块胶囊撑住，
 * 不能为了"小"把可点面积也压掉。
 * ============================================================ */
.cat-bar { gap: 6px; }
.cat-row { gap: 6px; }
.cat-item {
  height: 36px;
  gap: 5px;
  padding: 0 10px;
}
.cat-item .ci-icon { display: none; }
.cat-item .ci-name { font-size: 12.5px; letter-spacing: 0; }
.cat-item .ci-count { font-size: 9.5px; padding: 1px 5px; }
.cat-more { height: 36px; padding: 0 11px; }

/* 弹层里也一致去图标，一屏能看到更多分类（数量保留，信息完整） */
.cat-pop { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 7px; }
.cat-pop .cat-item { height: 34px; padding: 0 11px; }
.cat-pop .cat-item .ci-icon { display: none; }
.cat-pop .cat-item .ci-name { font-size: 12.5px; }

@media (max-width: 640px) {
  .cat-bar { gap: 5px; }
  .cat-row { gap: 5px; }
  .cat-item {
    height: 34px;
    min-height: 34px;
    gap: 0;
    padding: 0 10px;
  }
  .cat-item .ci-name { font-size: 12.5px; }
  /* 手机屏窄，标签里再放数字就少显示一个分类；数量在「更多」弹层里照样能看到 */
  .cat-item .ci-count { display: none; }
  .cat-more { height: 34px; padding: 0 10px; }
  .cat-pop { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .cat-pop .cat-item { height: 32px; min-height: 32px; padding: 0 8px; gap: 4px; }
  .cat-pop .cat-item .ci-name { font-size: 12px; }
  .cat-pop .cat-item .ci-count { display: inline-flex; font-size: 9.5px; padding: 1px 5px; }
}

/* ============================================================
 * 主题变量修正（必须放在最后）
 *
 * 背景：设计系统精修层里有一处 `:root { --text-3: #6f7484 }`（为浅色主题
 * 提升次要文字对比度加的）。它和 `[data-theme="xx"]` 选择器**优先级相同**，
 * 但位置更靠后 —— 于是把每个主题自己定义的 --text-3 统统盖掉了。
 * 表现就是「暗夜主题下副标题、资源元信息仍然发灰」，改主题色也无效。
 * 这里在文件最末重新声明，确保深色主题的辅助文字足够亮。
 * ============================================================ */

/* 暗夜：辅助文字明显提亮（旧值 #6f7484 在深底上只有约 3.9:1，显得脏灰） */
[data-theme="graphite"] {
  --text-3: #9aa3b5;                       /* 对 #0f131a 约 7.4:1 */
  --ring: 0 0 0 3px rgba(110, 168, 254, .42);
}

/* 默认（浅色）：焦点环跟随品牌深蓝，而不是旧版留下的紫色 */
[data-theme="mixue-luckin"] {
  --ring: 0 0 0 3px rgba(21, 101, 192, .3);
}

/* ============================================================
 * 主题变量修正（必须放在最后）
 *
 * 背景：设计系统精修层里有一处 `:root { --text-3: #6f7484 }`（为浅色主题
 * 提升次要文字对比度加的）。它和 `[data-theme="xx"]` 选择器**优先级相同**，
 * 但位置更靠后 —— 于是把每个主题自己定义的 --text-3 统统盖掉了。
 * 表现就是「暗夜主题下副标题、资源元信息仍然发灰」，改主题色也无效。
 * 这里在文件最末重新声明，确保深色主题的辅助文字足够亮。
 * ============================================================ */

/* 暗夜：辅助文字明显提亮（旧值 #6f7484 在深底上只有约 3.9:1，显得脏灰） */
[data-theme="graphite"] {
  --text-3: #9aa3b5;                       /* 对 #0f131a 约 7.4:1 */
  --ring: 0 0 0 3px rgba(110, 168, 254, .42);
}

/* 默认（浅色）：焦点环跟随品牌深蓝，而不是旧版留下的紫色 */
[data-theme="mixue-luckin"] {
  --ring: 0 0 0 3px rgba(21, 101, 192, .3);
}

/* ============================================================
 * 反馈弹窗 / 主题菜单文字统一 / 顶栏长按钮
 * ============================================================ */

/* 主题菜单：各项文字统一用正文色。
 * 之前选中项是品牌色、其他项是次要灰，看起来「颜色不一致」，
 * 其中非选中的「暗夜」那项就显得发灰。改为统一颜色，选中态靠底色 + 对勾区分。 */
.theme-menu .tm-item,
.theme-menu .tm-item.active { color: var(--text); }
.theme-menu .tm-item.active { font-weight: 600; }
.theme-menu .tm-item:hover { background: var(--bg); color: var(--text); }

/* 顶栏按钮：宽屏显示完整文案「求资源/问题反馈」，窄屏换短文案。
 * 短文案用「求资源/反馈」而不是只留「反馈」——只留两个字会让人以为是
 * 被截断了的残缺文案，而且看不出"求资源"这个主要用途。
 * 断点从 900px 收到 640px：手机才需要缩短，平板/小笔记本放得下完整文案。 */
.fb-btn-text-short { display: none; }
@media (max-width: 640px) {
  .fb-btn-text { display: none; }
  .fb-btn-text-short { display: inline; }
}

/* ---------- 反馈弹窗 ---------- */
.fb-mask {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 24, 40, .48);
}
.fb-mask[hidden] { display: none; }
.fb-card {
  width: 100%;
  max-width: 460px;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--e-3, 0 18px 44px rgba(0, 0, 0, .18));
  animation: fbIn .18s ease both;
}
@keyframes fbIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.fb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.fb-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
.fb-close {
  width: 30px; height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.fb-close:hover { background: var(--bg); color: var(--text); }
.fb-text {
  width: 100%;
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
}
.fb-text:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.fb-text::placeholder { color: var(--text-3); }
.fb-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.fb-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* 后台反馈列表：保留换行，长内容能换行显示 */
.fb-content { white-space: pre-wrap; word-break: break-word; }

@media (max-width: 640px) {
  .fb-card { padding: 16px; border-radius: 14px; }
  .fb-text { min-height: 116px; font-size: 14px; }
}

/* ============================================================
 * 顶栏功能按钮：按主题填充颜色
 *
 * 原来「反馈」和「风格」都是白底 + 灰字 + 浅边框，在顶栏上几乎看不出是可点的
 * 功能入口。现在：
 *   「反馈」= 品牌色渐变实底（主操作，白/深字由 --on-brand 决定）
 *   「风格」= 强调色（蜜雪红）淡底 + 强调色文字，与反馈区分但同样醒目
 * 两个都跟随主题切换，暗夜主题下自动换成深色文字，保证对比度。
 * ============================================================ */
:root { --on-brand: #ffffff; }
[data-theme="graphite"] { --on-brand: #0f131a; }

.header-actions { flex: 0 0 auto; }          /* 按钮永不被左侧站名挤压 */
.brand { min-width: 0; }
.brand-text { min-width: 0; }
.brand-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;                   /* 站名过长时省略，而不是把按钮挤变形 */
}
.header-actions .btn-ghost {
  white-space: nowrap;                       /* 文案绝不允许折行（折行会被固定高度裁掉） */
  font-weight: 600;
}
.header-actions .btn-ghost svg { flex: 0 0 auto; }

#feedback-btn {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: var(--on-brand);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--brand) 32%, transparent);
}
#feedback-btn:hover {
  color: var(--on-brand);
  border-color: transparent;
  filter: brightness(1.07);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--brand) 42%, transparent);
}
#feedback-btn:active { transform: translateY(1px); }

#theme-btn {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  color: var(--accent);
}
#theme-btn:hover {
  background: color-mix(in srgb, var(--accent) 24%, var(--surface));
  border-color: var(--accent);
  color: var(--accent);
}
#theme-btn:active { transform: translateY(1px); }

/* ============================================================
 * 分类栏：剩下的标签等比拉伸铺满整行
 *
 * 截断逻辑只保证"装得下"，不再拉伸的话行尾会剩几十像素空白，
 * 看起来像没排满、也浪费空间。这里让留下的标签按剩余空间等比变宽，
 * 整行正好排满，「更多」被顶到最右端。
 * 注意：测量阶段不能带这个类，否则量到的宽度是被拉伸后的，会少放好几个。
 * ============================================================ */
.cat-bar.filled { flex: 1 1 auto; }
.cat-bar.filled .cat-item {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
}
.cat-bar.filled .cat-item .ci-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 移动端：标签再瘦一点，一行能多放一个（高度不动，点击区域不缩水） */
@media (max-width: 640px) {
  .cat-bar.filled .cat-item { padding: 0 8px; }
  .cat-item .ci-name { font-size: 12px; }
}

/* ============================================================
 * 后台「数据概览」看板
 * ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.stat-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.stat-label { font-size: 12.5px; color: var(--text-3); }
.stat-value {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.stat-sub { margin-top: 3px; font-size: 11.5px; color: var(--text-3); }

/* 访问趋势柱状图（纯 CSS，无第三方库） */
.trend-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding: 6px 0 0;
}
.trend-col { flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; }
.trend-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  transition: filter .15s;
}
.trend-col:hover .trend-bar { filter: brightness(1.15); }
.trend-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-3);
}

/* 分类分布条 */
.dist-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}
.dist-name {
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dist-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}
.dist-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}
.dist-val {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 键值行 */
.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.kv-row:last-child { border-bottom: 0; }
.kv-row span { color: var(--text-3); flex: 0 0 auto; }
.kv-row b { color: var(--text); font-weight: 600; text-align: right; word-break: break-all; }

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 20px; }
  .dist-row { grid-template-columns: 70px minmax(0, 1fr); row-gap: 2px; }
  .dist-val { grid-column: 2; text-align: right; }
  .trend-bars { height: 96px; }
}

/* 趋势图：给每一天画一条浅色"轨道" + 底部基线。
 * 只有一两天有数据时，其余 28 天的柱子高度为 0，整张图会看起来像一条线、
 * 甚至以为没渲染出来。加上轨道就能一眼看出"这是一个 30 天的图表，
 * 只是前面都没有访问"，柱子也才有"从底部长上来"的感觉。
 *
 * 注意 .trend-col 必须显式 height:100%——柱子用的是百分比高度，
 * 父级高度为 auto 时百分比会失效（柱高恒为 0，整张图空白）。 */
.trend-bars { border-bottom: 1px solid var(--line); }
.trend-col { position: relative; height: 100%; }
.trend-col::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px 3px 0 0;
  background: color-mix(in srgb, var(--brand) 6%, transparent);
}
.trend-bar { position: relative; z-index: 1; }

/* ============================================================
 * 后台「访问统计」面板
 * 时间段切换（分段控件）+ 搜索排序 + 指标卡 + 资源明细行
 * ============================================================ */
.traffic-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}
.seg-btn {
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--brand); }
.seg-btn.active {
  background: var(--brand);
  color: var(--on-brand, #fff);
  font-weight: 600;
}
.tr-custom { display: inline-flex; align-items: center; gap: 6px; }
.tr-custom[hidden] { display: none; }
.tr-custom .input { width: auto; padding: 7px 10px; font-size: 13px; }
.tr-tools { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.tr-tools .input { width: 180px; }
.tr-tools .select { width: auto; }

#tr-cards { margin-top: 12px; }

.traffic-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.traffic-actions { display: flex; align-items: center; gap: 10px; }

/* 一键清理条 */
.traffic-clean {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 12px;
  margin-bottom: 12px;
  border: 1px dashed color-mix(in srgb, var(--danger) 40%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 5%, var(--surface));
  font-size: 12.5px;
  color: var(--text-2);
}
.input-sm, .select-sm { padding: 5px 8px; font-size: 12.5px; border-radius: 8px; }
.input-sm { width: 72px; }
.select-sm { width: auto; }

/* 明细行 */
.tr-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 150px 150px 62px auto;
  align-items: center;
  gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
}
.tr-row:last-child { border-bottom: 0; }
.tr-row:hover { background: var(--bg); }
.tr-row.cold .tr-title { color: var(--text-3); }
.tr-check { display: flex; align-items: center; }
.tr-main { min-width: 0; }
.tr-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tr-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tr-metric { display: block; }
.tr-bar-label {
  display: block;
  font-size: 11.5px;
  color: var(--text-3);
  margin-bottom: 3px;
}
.tr-bar-label b { color: var(--text); font-variant-numeric: tabular-nums; }
.tr-bar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}
.tr-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}
.tr-bar.tr-bar-get i {
  background: linear-gradient(90deg, var(--success), color-mix(in srgb, var(--success) 55%, var(--brand-2)));
}
.tr-rate {
  font-size: 12.5px;
  color: var(--text-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .traffic-bar { gap: 8px; }
  .seg { width: 100%; overflow-x: auto; }
  .tr-tools { margin-left: 0; width: 100%; }
  .tr-tools .input, .tr-tools .select { flex: 1 1 140px; width: auto; }
  .tr-row {
    grid-template-columns: 22px minmax(0, 1fr) 76px 76px;
    row-gap: 6px;
  }
  .tr-row .tr-rate, .tr-row .row-actions { grid-column: 2 / -1; }
  .tr-row .row-actions { justify-content: flex-end; display: flex; }
  .tr-rate { text-align: left; }
}

/* 明细列表表头：与 .tr-row 用同一套栅格，让"访问量 / 获取量 / 获取率"有明确指向 */
.tr-head-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 150px 150px 62px auto;
  align-items: center;
  gap: 12px;
  padding: 0 4px 7px;
  margin-bottom: 3px;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-3);
}
@media (max-width: 900px) {
  .tr-head-row { display: none; }   /* 窄屏行内已有"访问 / 获取"标签，表头会重复 */
}
