/* ============================================================
   polish.css — 质感打磨增强层（v3.6.8）
   ------------------------------------------------------------
   职责：在不改变任何主色 / 布局的前提下，补足"精致感"细节。
     - 图片加载淡入（懒加载图不再"啪"地闪现）
     - 卡片 hover 光泽扫过（微弱高光，非霓虹）
     - 主按钮按压质感 + 光泽
     - 骨架屏 shimmer（供 .skeleton / .sk-* 复用）
     - 数字等宽对齐（统计/金额不再跳动）
     - 输入框 focus 光晕柔和化
     - 文本选中色统一
     - 尊重 prefers-reduced-motion（无障碍）

   设计约束（重要）：
     1) 只用现有 token（--primary / --color-* / --card / --border ...），
        不引入新的硬编码品牌色，明暗主题自动适配。
     2) 纯增强：任何规则缺失时页面照常显示，无 JS 依赖。
     3) 加载顺序：必须是 CSS 链最后一个（neon.css 之后），
        且选择器特异性克制，只做"补充"不做"覆盖主视觉"。
     4) 高特异性暗色选择器由 dark.css / neon.css 负责，本层不碰背景色。
   ============================================================ */

/* ---------- 1. 图片加载淡入 ---------- */
/* 懒加载图：加载完成前微透明，完成后淡入；已加载/无 lazy 的不受影响 */
img[loading="lazy"] {
  animation: polish-img-in .5s ease both;
}
@keyframes polish-img-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- 2. 卡片 hover 光泽扫过 ---------- */
/* 仅作用于已知卡片容器；::after 高光层 pointer-events:none 不挡点击 */
.work-card,
.tpl-card,
.admin-card,
.s-card,
.db-card,
.provider-card,
.hp-gallery-item,
.polish-sheen {
  position: relative;
}
.work-card::after,
.tpl-card::after,
.provider-card::after,
.hp-gallery-item::after,
.polish-sheen::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 20%,
    rgba(255, 255, 255, .14) 48%,
    transparent 76%
  );
  background-size: 240% 100%;
  background-position: 130% 0;
  opacity: 0;
  transition: background-position .6s ease, opacity .3s ease;
}
.work-card:hover::after,
.tpl-card:hover::after,
.provider-card:hover::after,
.hp-gallery-item:hover::after,
.polish-sheen:hover::after {
  opacity: 1;
  background-position: -60% 0;
}
/* 暗色下光泽更克制，避免过曝 */
:root[data-theme="dark"] .work-card::after,
:root[data-theme="dark"] .hp-gallery-item::after,
:root[data-theme="dark"] .polish-sheen::after {
  background: linear-gradient(
    115deg,
    transparent 20%,
    rgba(255, 255, 255, .07) 48%,
    transparent 76%
  );
  background-size: 240% 100%;
}

/* ---------- 3. 主按钮质感 ---------- */
/* 主色按钮：轻微内高光 + 按压下沉，手感更"实" */
.btn-primary,
.hp-btn-primary,
.hp-btn-outline,
.hp-btn {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary::before,
.hp-btn-primary::before {
  content: "";
  position: absolute;
  inset: 0 0 50% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .18), transparent);
  pointer-events: none;
  border-radius: inherit;
}
.btn-primary:active,
.hp-btn-primary:active {
  transform: translateY(1px) scale(.985);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .18);
}

/* ---------- 4. 骨架屏 shimmer ---------- */
/* 用法：<div class="skeleton" style="width:80px;height:16px"></div> */
.skeleton,
.sk-line,
.sk-card {
  background: linear-gradient(
    90deg,
    var(--color-bg-alt, #f1f5f9) 25%,
    var(--color-border, #e2e8f0) 37%,
    var(--color-bg-alt, #f1f5f9) 63%
  );
  background-size: 400% 100%;
  animation: polish-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm, 4px);
}
@keyframes polish-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---------- 5. 数字等宽对齐 ---------- */
/* 统计数字 / 金额 / 倒计时用等宽数字，刷新时不再左右跳动 */
.num,
.stat-number,
.hp-stat .num,
.credits-num,
.amount,
.price,
[data-count] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ---------- 6. 输入框 focus 光晕柔和化 ---------- */
/* 兼容已有 focus 规则：仅在未单独设置 box-shadow 的控件补充 */
.auth-wrap form input:focus-visible,
.hp-input:focus-visible {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .22);
}

/* ---------- 7. 文本选中色统一 ---------- */
::selection {
  background: rgba(16, 185, 129, .24);
}
:root[data-theme="dark"] ::selection {
  background: rgba(52, 211, 153, .3);
}

/* ---------- 8. 平滑滚动（锚点导航） ---------- */
/* 仅对显式声明的容器生效，避免全局 scroll-behavior 影响交互 */
.polish-smooth { scroll-behavior: smooth; }

/* ---------- 9. 减少动画偏好（无障碍） ---------- */
/* 系统开启"减少动态效果"时，关闭本层所有装饰性动画 */
@media (prefers-reduced-motion: reduce) {
  img[loading="lazy"],
  .skeleton,
  .sk-line,
  .sk-card {
    animation: none !important;
  }
  .work-card::after,
  .tpl-card::after,
  .provider-card::after,
  .hp-gallery-item::after,
  .polish-sheen::after {
    display: none !important;
  }
  .polish-smooth { scroll-behavior: auto; }
}

/* ============================================================
 * 10. 顶栏 / 底栏布局打磨（v3.6.9）
 * ------------------------------------------------------------
 * 问题来源（用户真机反馈 2026-11-21）：
 *  A) PC 版 header 在 ≤480px 窄屏下，".nav-cta / 用户菜单"被 flex 挤压
 *     成竖排文字（"开始生图"逐字竖排）——根因是这些行内元素缺少
 *     white-space:nowrap + flex-shrink:0，在 nav-right 空间不足时换行。
 *  B) m.php 顶栏元素过密；底栏第 8 个"主题"按钮既没有 data-module
 *     （点击会被 tab 逻辑清掉所有 active 面板），其 label 又被 theme.js
 *     的 textContent 覆盖抹掉。已将主题/电脑版移入顶栏为紧凑图标按钮。
 * 本层为最后加载，特异性克制，仅修复布局，不改配色主题。
 * ============================================================ */

/* ---- A. PC 顶栏：行内元素禁止竖排 ---- */
.brand, .nav-cta, .nav-credits, .user-trigger, .nav-feedback {
  white-space: nowrap;
  flex-shrink: 0;
}
/* 极窄屏（≤560px）：只保留算力 + 用户头像 + 汉堡；主 CTA 收进折叠菜单，
   主题按钮隐藏（顶栏已有其它主题入口时不重复），保证一行放得下。 */
@media (max-width: 560px) {
  .nav { gap: 8px; }
  .nav-right > .nav-cta { display: none !important; }
  .nav-right > #theme-toggle { display: none !important; }
  .brand { font-size: 15px; padding: 6px 4px; }
  .brand-ico { font-size: 18px; }
  .nav-credits { padding: 5px 9px; font-size: 12px; }
  /* 顶栏 CTA 隐藏后，折叠菜单里的补充入口显示 */
  .nav-main > .nav-cta-fallback { display: block; color: var(--primary); font-weight: 700; }
}
/* 默认不显示（>560px 顶栏已有 CTA） */
.nav-main > .nav-cta-fallback { display: none; }

/* ---- B. 移动端 m.php 顶栏工具按钮 + 底栏 7 项均分 ---- */
.h5-header .user-info { gap: 6px; }
.h5-header .m-tool-btn {
  width: 30px; height: 30px; flex-shrink: 0;
  border: 0; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .18); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; cursor: pointer;
  min-width: 0; min-height: 0; /* 覆盖 mobile-first.css 的 44px 触摸下限 */
  -webkit-tap-highlight-color: transparent;
}
.h5-header .m-tool-btn .ico { font-size: 14px; line-height: 1; }
.h5-header .m-tool-btn:active { transform: scale(.92); }
/* 7 个功能 tab 均分，图标与文字略放大，去掉拥挤感 */
.h5-tabbar .tab-item { flex: 1 1 0; min-width: 0; padding: 7px 2px 5px; }
.h5-tabbar .tab-item .ico { font-size: 21px; }
.h5-tabbar .tab-item .label { font-size: 9px; }
/* 超窄屏（≤360px）字体再收一档，避免 7 个中文 tab 换行 */
@media (max-width: 360px) {
  .h5-tabbar .tab-item .label { font-size: 8px; letter-spacing: 0; }
  .h5-header .logo-wrap h1 { font-size: 14px; }
  .h5-header .logo-wrap h1 span { font-size: 11px; }
}

/* ---- C. 顶栏动图开关移入参数区（v3.6.9 工作台打磨）----
 * 原顶栏 6 元素（动图/积分/充值/头像/主题/电脑版）在 400px 真机
 * 右侧溢出，主题与电脑版按钮被挤出屏幕。动图开关本质是生成参数，
 * 移入「描述提示词」卡片，与 PC 版参数区一致；JS 按 id 绑定不变。 */
.h5-header .user-info { gap: 7px; }
.h5-gif.h5-gif-inline {
  margin-top: 10px;
  display: none; /* 由 wsRefreshGifToggle() 设 flex；不支持的模型保持隐藏 */
  width: 100%;
  justify-content: flex-start;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--card, #fff);
  color: var(--text, #374151);
  font-size: 12px;
}
.h5-gif.h5-gif-inline.on {
  background: rgba(16, 185, 129, .10);
  border-color: #10B981;
  color: #047857;
}
.h5-gif.h5-gif-inline span { color: inherit; }
/* 顶栏不再有动图开关，保留一句说明防止旧缓存误判 */
.h5-header .h5-gif { display: none !important; }

/* ============================================================
 * 11. 后台框架规整化（v3.6.9）
 * ------------------------------------------------------------
 * 用户反馈：后台"有点乱、不规整"。实测截图定位：
 *  A) 侧栏分组标题（📁内容/💰商业/⚙️系统）与菜单项层级接近，
 *     像一长串平铺菜单，扫读困难。
 *  B) 控制台 7 个 KPI 卡用 auto-fit minmax(180px)，1440px 下
 *     一行只放 6 个，第 7 个"任务状态"单独掉第二行、右侧留白。
 *  C) 表格窄列（状态/类型）文字竖排（success / 未发布 / 生图）。
 * 本层最后加载，用 .admin-body 提升特异性，只调布局层次，不改配色。
 * ============================================================ */

/* ---- A. 侧栏：分组标题与菜单项拉开层级 ---- */
.admin-body .admin-menu-group { margin-bottom: 6px; }
.admin-body .admin-menu-label {
  font-size: 11px; letter-spacing: 1.5px; font-weight: 700;
  color: var(--text-subtle, #94a3b8);
  padding: 14px 14px 6px;
  border-top: 1px solid var(--border, #e5e7eb);
  margin-top: 4px;
  opacity: 1;
}
.admin-body .admin-menu-group:first-child .admin-menu-label { border-top: 0; }
.admin-body .admin-menu-items { padding-left: 6px; }
.admin-body .admin-menu-group .admin-menu-items a {
  margin: 1px 6px; padding: 8px 12px; border-radius: 8px;
}
.admin-body .admin-menu-group .admin-menu-items a.active {
  margin: 1px 6px; border-radius: 8px;
}
/* 顶部单项（控制台）与分组标题同高对齐 */
.admin-body .admin-menu a.admin-menu-top { margin: 2px 6px; }

/* ---- B. 控制台 KPI：7 卡宽屏一行，窄屏规整换行 ---- */
.admin-body .stat-card-grid-main {
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
}
.admin-body .stat-card-grid-main .stat-card {
  min-height: 118px;
  display: flex; flex-direction: column; align-items: flex-start;
}
.admin-body .stat-card-grid-main .stat-card .num,
.admin-body .stat-card-grid-main .stat-card .lab {
  white-space: nowrap;
}
/* tip 单行省略：长提示（如"最近运行…已超时N分钟"）不得撑出卡片 */
.admin-body .stat-card-grid-main .stat-card .tip {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}

/* ---- C. 表格：窄列文字不竖排 ---- */
.admin-body table td,
.admin-body table th { vertical-align: middle; }
.admin-body table td .pill,
.admin-body table td .badge,
.admin-body table td .status,
.admin-body table td select,
.admin-body table td .btn-sm { white-space: nowrap; }

/* ---- D. 表格长文本列省略：避免撑宽把"操作"列挤出视口 ----
 * works 表第 6 列是「提示词/标题」，内容最长；限制其宽度并省略，
 * 让右侧「操作」列能在 1440px 下完整显示。其它宽表同样受益。 */
.admin-body table.table td:nth-child(6),
.admin-body table.table th:nth-child(6) {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- E. 主内容区：卡片高度一致、标题区留白统一 ---- */
.admin-body .dash-grid-2-1 > * { min-width: 0; }
.admin-body .admin-main h1,
.admin-body .admin-main h2,
.admin-body .admin-main .page-title { margin-top: 0; }

/* ============================================================
 * §12 后台框架精简（第二批）—— 只减视觉噪音，不改配色/功能
 * 背景：截图复查发现三个系统性问题：
 *   1) 顶栏每页重复 4 个统计徽章（3 个 24h + 运行正常），与当前页无关，
 *      且控制台 KPI 已覆盖这些数据 → 只留"总用户数"一个胶囊；
 *   2) 侧栏分组标题与菜单项混排、部分带 emoji，层级参差 → 统一缩进/行高，
 *      emoji 保留在 HTML（不篡改内容）但用统一宽度使其对齐；
 *   3) 页头标题 + 副标题 + 角标三层叠加显重 → 收紧行高、副标题限单行省略。
 * 全部用 .admin-body 提升特异性，放在本层最后，压过 style/tech-admin 的分散定义。
 * ============================================================ */

/* ---- A. 顶栏：只留一个总览胶囊，去掉重复的运行状态 ---- */
.admin-body .admin-topbar-right .admin-stat:nth-child(n+2) { display: none; }
.admin-body .admin-topbar-right .admin-status { display: none; }
.admin-body .admin-topbar-right .admin-stat:first-child {
  padding: 4px 10px; border: 1px solid var(--line, rgba(16,185,129,.25));
  border-radius: 999px; background: var(--primary-soft, rgba(16,185,129,.08));
  font-size: 12px; font-weight: 700;
}
/* 主题按钮与管理员之间加细分割，避免挤成一坨 */
.admin-body .admin-topbar-right #theme-toggle { margin-left: 4px; }

/* ---- B. 侧栏：分组标题与菜单项统一节奏 ---- */
.admin-body .admin-menu-label {
  font-size: 12px; letter-spacing: .04em; text-transform: none;
  padding: 10px 14px 6px; opacity: .9;
}
.admin-body .admin-menu-group .admin-menu-items a {
  padding: 7px 16px 7px 28px; line-height: 1.5; font-size: 13px;
}
.admin-body .admin-menu-top { padding: 9px 14px; }
.admin-body .admin-brand { font-size: 15px; font-weight: 800; letter-spacing: .02em; }

/* ---- C. 页头：收紧标题区，副标题单行省略，角标降级 ---- */
.admin-body .admin-section-head { align-items: flex-start; margin: 2px 0 14px; }
.admin-body .admin-section-head h2 { font-size: 20px; line-height: 1.35; }
.admin-body .admin-section-head .sub {
  font-size: 12.5px; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.admin-body .admin-section-head h2 .badge-success,
.admin-body .admin-section-head h2 .badge,
.admin-body .admin-section-head h2 [class*="badge"] {
  font-size: 10px !important; font-weight: 600; vertical-align: 2px; opacity: .85;
}

/* ---- D. KPI 卡：彩色左侧条来自 ::before（非 border-left），统一为中性主色 ---- */
.admin-body .stat-card::before,
.admin-body .stat-card-primary::before,
.admin-body .stat-card-success::before,
.admin-body .stat-card-warn::before,
.admin-body .stat-card-info::before {
  background: var(--primary, #10b981) !important;
}
/* 顶栏紧凑：统计胶囊 + 主题 + 用户 + 退出 不换行 */
.admin-body .admin-topbar-right { flex-wrap: nowrap; gap: 10px; }

/* ---- E. 用户管理：操作列给足宽度，让"编辑/账单"横排不换行 ---- */
.admin-body .users-actions { flex-wrap: nowrap; white-space: nowrap; }
.admin-body table td:has(.users-actions),
.admin-body table th:last-child { min-width: 150px; }

/* ============================================================
 * §13 后台标签页（设置页 / API 页共用）
 * 目标：一屏只显示一个板块，避免长表单无限下拉；不拆路由、不改提交。
 * ============================================================ */
.admin-body .admin-tabcrumb {
  font-size: 12px; color: var(--muted, #78716c); margin: 0 2px 8px;
}
.admin-body .admin-tabcrumb b { color: var(--primary, #10b981); }
.admin-body .admin-tabbar {
  display: flex; gap: 6px; align-items: center; margin: 0 0 18px;
  padding: 6px; background: var(--panel, #fff);
  border: 1px solid var(--line, rgba(16,185,129,.25));
  border-radius: 12px; box-shadow: var(--shadow-sm, 0 2px 8px rgba(15,23,42,.06));
  overflow-x: auto; scrollbar-width: thin;
}
.admin-body .admin-tabbar a {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 8px; text-decoration: none;
  font-size: 13px; font-weight: 600; color: var(--muted, #78716c);
  white-space: nowrap; transition: background .16s, color .16s;
}
.admin-body .admin-tabbar a:hover {
  background: var(--primary-soft, rgba(16,185,129,.08));
  color: var(--primary, #10b981);
}
.admin-body .admin-tabbar a.active {
  background: var(--primary, #10b981); color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,.22);
}
.admin-body .admin-tabpane[hidden] { display: none !important; }
/* 低频高级配置默认收起，减少首屏高度（展开后控件仍在表单内，照常提交） */
.admin-body details.api-advanced {
  margin: 16px 0; padding: 10px 14px;
  border: 1px dashed var(--line, rgba(16,185,129,.3)); border-radius: 10px;
}
.admin-body details.api-advanced > summary {
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--muted, #78716c); list-style: none;
}
.admin-body details.api-advanced > summary::-webkit-details-marker { display: none; }
.admin-body details.api-advanced > summary::before { content: '▸ '; color: var(--primary, #10b981); }
.admin-body details.api-advanced[open] > summary::before { content: '▾ '; }
.admin-body details.api-advanced > summary:hover { color: var(--primary, #10b981); }
.admin-body .admin-tabpane > .s-card:last-child,
.admin-body .admin-tabpane > .api-section:last-child { margin-bottom: 0; }
@media (max-width: 720px) {
  .admin-body .admin-tabbar { margin-left: -4px; margin-right: -4px; }
  .admin-body .admin-tabbar a { padding: 8px 11px; font-size: 12px; }
}


