/* ============================================================
   在线工具箱 全局样式
   支持浅色/深色双主题：通过 <html data-theme="dark"> 切换
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-soft: #eff6ff;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --header-bg: #ffffff;
  --border: #e5e7eb;
  --hover-bg: #eef2f7;
  --checker-a: #ffffff;
  --checker-b: #eef2f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 8px 20px rgba(15, 23, 42, 0.13);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --primary-light: #1e3a8a;
  --primary-soft: #172554;
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --header-bg: #0f172a;
  --border: #334155;
  --hover-bg: #334155;
  --checker-a: #2c3545;
  --checker-b: #252d3c;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; /* 🚀 LCP优化：优先使用system-ui，减少字体FOIT */
  font-display: swap; /* 确保文本即时可见 */
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* 防止页面级横向滚动条 */
  scrollbar-gutter: stable; /* 🚀 CLS修复：滚动条出现/消失时内容宽度稳定，避免水平跳动 */
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 无障碍：键盘操作焦点明显（非鼠标点击） */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 🚀 全局图片防布局偏移 (CLS) 核心修复 */
img {
  max-width: 100%;
  height: auto;
}

/* Header */
.header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  contain: layout; /* 🚀 INP/CLS优化：隔离渲染层 */
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  contain: content; /* 🚀 CLS修复：头部始终位于首屏，content-visibility 无收益且缺 intrinsic-size 易致布局偏移 */
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.logo:hover { text-decoration: none; }
.logo-icon { font-size: 24px; }
.search-box {
  flex: 1;
  max-width: 480px;
  margin: 0 24px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 9px 16px 9px 40px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg);
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-light); opacity: 0.8; }
.search-box input:focus { border-color: var(--primary); background: var(--card-bg); }
.search-box::before {
  content: "🔍";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.5;
}
.header-nav { display: flex; gap: 14px; align-items: center; }
.header-nav a {
  font-size: 14px;
  color: var(--text-light);
  min-height: 24px; /* 🚀 CLS修复：导航链接高度固定 */
  display: inline-flex;
  align-items: center;
  touch-action: manipulation; /* 🚀 INP优化：移动端快速响应 */
}
.header-nav a:hover { color: var(--primary); text-decoration: none; }

/* 主题切换按钮 */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  padding: 0;
  transition: border-color 0.2s, transform 0.2s;
  touch-action: manipulation;
}
.theme-toggle:hover { border-color: var(--primary); transform: scale(1.06); }

/* Category Tabs：左侧“全部工具”上下居中，右侧分类按钮分两行排布 */
.category-tabs {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 60px; /* 紧贴 header（高60px）下方固定 */
  z-index: 99; /* 低于 header 的 100 */
  contain: layout;
}
.category-tabs-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 12px;
  display: flex;
  gap: 14px;
  align-items: stretch;
}
/* 左侧：“全部工具”胶囊按钮，垂直上下居中 */
.cat-aside {
  display: flex;
  align-items: center; /* 🚀 全部工具上下居中 */
  flex: 0 0 auto;
  padding-right: 14px;
  border-right: 1px solid var(--border);
}
.cat-aside .cat-tab {
  padding: 9px 18px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.cat-aside .cat-tab.active {
  background: var(--primary);
  color: #fff;
  border-bottom-color: transparent;
}
/* 右侧：分类项两行网格，全部可见无需横向滚动 */
.cat-grid {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px 4px;
  align-content: center;
}
.cat-grid .cat-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 6px;
  font-size: 13px;
  border-radius: 6px;
}
.cat-tab {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  background: none;
  touch-action: manipulation;
  flex-shrink: 0;
}
.cat-tab:hover { color: var(--primary); background: var(--primary-soft); text-decoration: none; }
.cat-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Main */
.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  width: 100%;
}

/* ---------- 首页 Hero：标题 + 特点徽章 ---------- */
.hero {
  text-align: center;
  padding: 8px 20px 30px;
  max-width: 860px;
  margin: 0 auto;
}
.hero-title {
  font-size: clamp(26px, 3.4vw, 34px);
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0 0 12px;
}
.hero-sub {
  color: var(--text-light);
  font-size: 15px;
  line-height: 1.7;
  max-width: 620px;
  margin: 0 auto 22px;
}
.hero-feats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
}
.hero-feat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-light);
  border-radius: 999px;
  white-space: nowrap;
}
/* Tool Grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s; /* 🚀 INP优化：仅动画可合成属性 */
  cursor: pointer;
  display: block;
  color: var(--text);
  height: 128px; /* 🚀 CLS修复：卡片高度固定，网格行高稳定，避免字体/内容变化导致整段section高度抖动 */
  contain: content; /* 🚀 重绘/回流隔离 */
}
.tool-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
  transform: translateY(-3px);
  text-decoration: none;
}
.tool-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.tool-card-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 10px;
  flex-shrink: 0;
}
.tool-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap; /* 🚀 CLS修复：名称单行，防止长名称换行撑高卡片 */
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-card-cat {
  font-size: 12px;
  color: var(--text-light);
}
.tool-card-desc {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tool Page */
.tool-page-header {
  margin-bottom: 24px;
}
.tool-page-title {
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.tool-page-title .icon {
  font-size: 32px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 12px;
}
.tool-page-desc {
  font-size: 15px;
  color: var(--text-light);
  max-width: 1080px;
  line-height: 1.7;
}
.breadcrumb {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--primary); }

/* Tool Workspace */
.workspace {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  min-height: 300px; /* 🚀 CLS修复：工具JS延迟注入前预留空间，避免下方内容上移 */
}
.workspace-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s; /* 🚀 INP优化：只动画GPU友好属性 */
  margin-bottom: 16px;
  min-height: 140px; /* 🚀 CLS修复：预留最小高度，防止动态注入时布局跳动 */
  contain: layout paint; /* 🚀 隔离绘制区域 */
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.upload-zone-icon { font-size: 40px; margin-bottom: 8px; }
.upload-zone-text { font-size: 14px; color: var(--text-light); }
.upload-zone-text strong { color: var(--primary); }
.file-list {
  margin-bottom: 16px;
  min-height: 0; /* 🚀 CLS修复：初始占位，后续填充 */
  contain: layout;
}
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  min-height: 40px; /* 🚀 CLS修复：行高固定，防止删除/添加项跳动 */
}
.file-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .size { color: var(--text-light); margin-left: 12px; }
.file-item .remove {
  color: var(--danger);
  cursor: pointer;
  margin-left: 12px;
  background: none;
  border: none;
  font-size: 14px;
}
/* 带缩略图文件卡片（图片 / PDF 首页预览） */
.file-item.has-thumb { padding: 8px 10px; }
.file-item .file-thumb {
  width: 52px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  flex: 0 0 auto;
  cursor: zoom-in;
  box-shadow: var(--shadow);
}
.file-item .file-thumb:hover { transform: scale(1.05); }
.file-item .file-info { flex: 1; min-width: 0; margin-left: 12px; }
.file-item .file-info .name { flex: none; font-weight: 600; }
.file-item .file-info .meta { font-size: 12px; color: var(--text-light); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* PDF 首页预览缩略图占位（渲染完成前） */
.file-item .file-thumb.is-loading {
  background: #e8ecf3;
  animation: thumb-pulse 1.1s ease-in-out infinite;
}
@keyframes thumb-pulse { 50% { opacity: 0.55; } }
/* 全屏图片预览灯箱 */
.app-lightbox {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.app-lightbox.hidden { display: none; }
.lb-open { overflow: hidden; }
.app-lightbox .lb-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.72); backdrop-filter: blur(2px); }
.app-lightbox .lb-box {
  position: relative; max-width: 92vw; max-height: 90vh;
  background: var(--card-bg); border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}
.app-lightbox .lb-close {
  position: absolute; top: 8px; right: 10px; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text); border: none; border-radius: 50%;
  cursor: pointer; font-size: 14px; z-index: 2;
}
.app-lightbox .lb-close:hover { background: var(--primary); color: #fff; }
.app-lightbox .lb-title {
  font-size: 13px; color: var(--text-light); margin-bottom: 8px;
  max-width: 80vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-lightbox .lb-img {
  max-width: 88vw; max-height: 78vh; object-fit: contain;
  border-radius: 8px; background: #fff; transition: opacity 0.15s;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s; /* 🚀 INP优化：快速反馈 */
  min-height: 40px; /* 🚀 CLS修复：按钮尺寸固定 */
  touch-action: manipulation; /* 🚀 INP优化：移动端快速响应 */
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-primary:disabled { background: var(--text-light); cursor: not-allowed; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--hover-bg); }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  background: var(--card-bg);
}
/* 参数区：等宽网格，控件底部对齐，避免长短标签/不同控件高度造成的参差 */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; align-items: end; }
.form-row .form-group { flex: none; min-width: 0; margin-bottom: 0; }
/* 表单/参数控件之后紧跟的操作按钮行：与上方控件拉开间距，避免贴得太近不美观 */
.form-row + .btn-group,
.form-group + .btn-group { margin-top: 16px; }
textarea.code-input {
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  min-height: 160px;
}
.output-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: 13px;
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 12px;
  color: var(--text);
}
.result-info {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.result-info .item {
  font-size: 13px;
  color: var(--text-light);
}
.result-info .item strong { color: var(--text); }

/* Category Section on Homepage */
/* 🚀 渲染性能：content-visibility 跳过首屏下方的分类区布局/绘制；
   contain-intrinsic-size 提供首猜高度，滚动到位后再精确布局，避免跳动。 */
.cat-section {
  margin-bottom: 36px;
  content-visibility: auto;
  contain-intrinsic-size: auto 680px;
}
.cat-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cat-section-title {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* SEO content block */
.seo-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.seo-content h2 { font-size: 18px; margin-bottom: 12px; }
.seo-content h3 { font-size: 16px; margin: 16px 0 8px; }
.seo-content p { font-size: 14px; color: var(--text-light); margin-bottom: 10px; line-height: 1.8; }
.seo-content ul { padding-left: 20px; margin-bottom: 10px; }
.seo-content li { font-size: 14px; color: var(--text-light); margin-bottom: 4px; line-height: 1.7; }
.seo-content code, .output-box code { background: var(--hover-bg); padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }

/* Footer */
.footer {
  background: var(--header-bg);
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  text-align: center;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.footer-links a { font-size: 13px; color: var(--text-light); }
.footer-links a:hover { color: var(--primary); }
.footer-copy {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.8;
}
.footer-copy a { color: var(--text-light); }
.police-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 20px; /* 🚀 CLS修复：police图片加载前预留高度 */
}

/* Toast */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827; /* 深浅主题下均为深色提示 */
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  min-height: 40px; /* 🚀 CLS修复：toast首次创建不跳布局 */
  white-space: nowrap;
  will-change: opacity; /* 🚀 GPU优化 */
}
.toast.show { opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Hidden */
.hidden { display: none !important; }

/* 🚀 固定宽高比容器（用于动态图片，防止 CLS） */
.img-ratio-16-9 { aspect-ratio: 16 / 9; width: 100%; overflow: hidden; }
.img-ratio-4-3 { aspect-ratio: 4 / 3; width: 100%; overflow: hidden; }
.img-ratio-1-1 { aspect-ratio: 1 / 1; width: 100%; overflow: hidden; }
.img-ratio-16-9 img, .img-ratio-4-3 img, .img-ratio-1-1 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 🚀 CLS修复：编辑器和查看器容器预留最小空间，防止首次显示跳布局 */
#editor, #viewer {
  min-height: 200px;
  contain: layout;
}

/* 🚀 CLS修复：Canvas渲染容器固定尺寸基线，默认透明背景防止闪烁 */
canvas {
  display: block;
  background: transparent;
}

/* ===== 处理进度条（图片去污渍等批量处理工具） ===== */
.progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 4px;
  transition: width .15s ease;
}

/* ===== 分段按钮切换（如 输出背景：透明底/白底） ===== */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg);
}
.seg button {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-light);
  transition: background .15s, color .15s;
  touch-action: manipulation;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { color: var(--primary); }
.seg button.active { background: var(--primary); color: #fff; }
/* 参数区内分段按钮拉满整格，与下拉框等宽对齐 */
.form-group .seg { display: flex; width: 100%; }
.form-group .seg button { flex: 1; white-space: nowrap; padding-left: 6px; padding-right: 6px; }

/* ===== 处理结果网格（结果展示在页面下方，右键可另存） ===== */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.result-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: 8px;
  box-shadow: var(--shadow);
}
.result-item img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: contain;
  border-radius: 6px;
  /* 透明底棋盘格，便于识别透明区域 */
  background: conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%, var(--checker-a) 0 75%, var(--checker-b) 0) 0 0 / 16px 16px;
}
.result-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
  cursor: pointer;
}
.result-name {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 首页搜索空结果提示 */
.search-empty {
  text-align: center;
  color: var(--text-light);
  padding: 48px 0;
  font-size: 14px;
}

/* ===== 金融财税计算器 ===== */
.calc-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.calc-tab {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.calc-tab:hover { border-color: var(--primary); color: var(--primary); }
.calc-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.calc-panel { animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.calc-result {
  margin-top: 18px;
  padding: 18px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.calc-result h4 { margin: 0 0 10px; font-size: 14px; color: var(--text-light); }
.result-card { margin-bottom: 12px; }
.result-head { text-align: center; margin-bottom: 14px; }
.result-item-big { font-size: 32px; font-weight: 700; color: var(--primary); }
.result-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.result-cell { text-align: center; padding: 10px; background: var(--bg); border-radius: 8px; }
.result-cell-val { font-size: 18px; font-weight: 600; color: var(--text); }
.result-cell-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.result-detail { margin-top: 12px; }
.result-detail summary { cursor: pointer; font-size: 13px; color: var(--primary); padding: 6px 0; }
.result-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.result-table th, .result-table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); }
.result-table th:first-child, .result-table td:first-child { text-align: left; }
.result-table th { background: var(--bg); font-weight: 600; color: var(--text-light); }
.result-table tbody tr:hover { background: var(--bg); }

/* 🚀 INP优化：搜索框/输入框 focus 仅换边框色，无需 will-change（避免多余合成层拖慢首交互） */

/* Responsive */
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  /* 移动端 header 高度随换行变化，分类栏不再吸顶，避免遮挡 */
  .category-tabs { position: static; }
  .category-tabs-inner { justify-content: flex-start; }
  .search-box { order: 3; max-width: 100%; margin: 0; flex-basis: 100%; }
  .tool-grid { grid-template-columns: 1fr; }
  .workspace { padding: 16px; }
  .tool-page-title { font-size: 20px; }

  /* 🚀 移动端图片自适应强化 */
  img { max-width: 100%; height: auto; }
}

/* 🚀 平板及以下：分类多放不开两行，恢复单行横向滑动（全部工具置最前） */
@media (max-width: 1000px) {
  .category-tabs-inner {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 12px;
    min-height: 45px;
    gap: 2px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;
  }
  .category-tabs-inner::-webkit-scrollbar { display: none; }
  .cat-aside {
    border-right: none;
    padding-right: 0;
  }
  .cat-aside .cat-tab,
  .cat-grid .cat-tab {
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 0;
  }
  .cat-aside .cat-tab {
    background: none;
    font-weight: 400;
  }
  .cat-aside .cat-tab.active {
    background: none;
    color: var(--primary);
  }
  .cat-grid {
    display: flex;
    flex: 0 0 auto;
  }
  .cat-grid .cat-tab { justify-content: flex-start; }
}

/* ============================================================
   桌面端（≥1101px）：分类导航移到左侧，纵向排列；高度不足自动滚动
   内容区右移让位；≤1100px 时自动回落为顶部横向导航
   ============================================================ */
@media (min-width: 1101px) {
  /* 左侧固定分类栏：位于 header(60px) 下方，占满剩余视口高度 */
  .category-tabs {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 240px;
    z-index: 90;
    border-bottom: none;
    border-right: 1px solid var(--border);
    background: var(--header-bg);
    overflow-y: auto;   /* 🚀 高度不足时可独立滚动 */
    overflow-x: hidden;
    contain: layout;
  }
  .category-tabs-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    height: auto;
    max-width: none;
    margin: 0;
    padding: 14px 12px 20px;
  }
  /* “全部工具”整宽按钮，与下方分类列表用分隔线隔开 */
  .cat-aside {
    border-right: none;
    padding-right: 0;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .cat-aside .cat-tab {
    width: 100%;
    justify-content: center;
    padding: 9px 18px;
    border-radius: 10px;
  }
  /* 分类列表：单列纵向、左对齐 */
  .cat-grid {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    flex: none;
  }
  .category-tabs .cat-tab {
    width: 100%;
    justify-content: flex-start;
    padding: 9px 14px;
    font-size: 14px;
    border-radius: 8px;
    border-bottom: none;
    border-left: 3px solid transparent;
    color: var(--text-light);
    flex-shrink: 0;
  }
  .category-tabs .cat-tab:hover {
    background: var(--hover-bg);
    color: var(--primary);
  }
  .category-tabs .cat-tab.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
  }
  .cat-aside .cat-tab.active {
    background: var(--primary);
    color: #fff;
    border-left-color: transparent;
  }
  /* 内容区让位：右移 240px（含间距由右侧空白吸收，内容不溢出） */
  .main {
    width: calc(100% - 240px);
    margin-left: 240px;
    margin-right: 0;
  }
  /* 页脚内容避开左侧栏（背景色仍可整宽铺满） */
  .footer {
    padding-left: 240px;
  }
}

@media (max-width: 420px) {
  .tool-card { height: auto; }
  .footer-links { gap: 14px; }
}

/* ============================================================
   上传文件统计信息 & 「本页生成的文件」浮层
   （文件列表 meta 行 / 灯箱 PDF·文本 / 右下角结果浮层）
   ============================================================ */
/* 无缩略图的文件卡：名称+统计信息纵向排列，去掉左侧缩进 */
.file-item .file-info { min-width: 0; }
.file-item:not(.has-thumb) .file-info { margin-left: 0; }
.file-item .file-info .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.file-item .meta {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 灯箱：PDF 内嵌 / 文本内容 */
.app-lightbox .lb-frame {
  width: min(88vw, 900px);
  height: 76vh;
  border: 0;
  border-radius: 8px;
  background: #fff;
}
.app-lightbox .lb-txt {
  max-width: min(88vw, 900px);
  max-height: 76vh;
  min-width: min(80vw, 520px);
  overflow: auto;
  margin: 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}
.app-lightbox .lb-body {
  max-width: 92vw;
  display: flex;
  justify-content: center;
}

/* 右下角结果浮层 */
.out-shell {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-size: 13px;
}
.out-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 13px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.out-toggle:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18); }
.out-toggle .out-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.out-panel {
  width: min(380px, calc(100vw - 32px));
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}
.out-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.out-clear {
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
}
.out-clear:hover { color: var(--danger); }
.out-list { overflow-y: auto; padding: 6px; }
.dl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 8px;
}
.dl-item:hover { background: var(--hover-bg, var(--primary-soft)); }
.dl-item + .dl-item { border-top: 1px dashed var(--border); }
.dl-ico { font-size: 20px; flex: none; }
.dl-info { flex: 1; min-width: 0; }
.dl-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dl-meta { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.dl-btns { display: flex; align-items: center; gap: 4px; flex: none; }
.dl-btn {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.dl-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.dl-btn:hover { opacity: 0.88; }
.dl-x {
  border: none;
  background: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 12px;
  padding: 4px;
}
.dl-x:hover { color: var(--danger); }
@media (max-width: 768px) {
  .out-shell { right: 10px; bottom: 10px; }
  .out-panel { max-height: 55vh; }
}

/* ============================================================
   「处理结果」面板增强：预览→确认→按需下载 交互模型
   ============================================================ */
.out-panel { width: min(430px, calc(100vw - 28px)); max-height: min(72vh, 620px); }
.out-head { flex-wrap: wrap; row-gap: 6px; }
.out-title { display: inline-flex; align-items: center; gap: 6px; }
.out-acts { display: flex; align-items: center; gap: 4px; }
.out-acts .dl-btn, .out-head .dl-btn { padding: 3px 8px; font-size: 12px; }
.out-hint {
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-light);
  background: var(--primary-soft);
  border-bottom: 1px solid var(--border);
}
/* zip 解包组 */
.dl-item-zip { background: var(--primary-soft); margin-top: 6px; border: 1px dashed var(--border); }
.dl-item-zip:first-child { margin-top: 0; }
.dl-item-zip .dl-name { font-weight: 600; }
.dl-subs {
  margin: 0 0 8px 12px;
  padding-left: 10px;
  border-left: 1px dashed var(--border);
}
.dl-item-sub { padding: 6px 8px 6px 2px; }
.dl-item-sub + .dl-item-sub { border-top: 1px dashed var(--border); }
.dl-item-sub .dl-name { font-size: 12px; }
.dl-item-sub .dl-ico { font-size: 16px; }
/* 行内按钮过多时允许换行（如 zip 头行的 下载ZIP + 展开/收起） */
.dl-btns { flex-wrap: wrap; justify-content: flex-end; }
.dl-item-zip .dl-btn:not(.primary) { background: transparent; }
.dl-item-sub .dl-btns { gap: 2px; }

/* 批量网格结果卡：放大预览 + 单文件下载 */
.result-item img { cursor: zoom-in; }
.result-acts {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.result-acts .res-btn {
  flex: 1;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.result-acts .res-btn:hover { opacity: 0.88; }
.result-acts .res-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.result-item:not(:has(.result-acts)) img { cursor: zoom-in; }

/* ===== PDF 裁剪：模式切换（快速/手动）+ 手动拖拽裁剪 ===== */
.tool-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}
.tool-seg > button {
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 36px;
  transition: color .15s, background .15s;
}
.tool-seg > button:hover { background: var(--hover-bg); }
.tool-seg > button.active { background: var(--primary); color: #fff; font-weight: 500; }
.crop-pane { min-width: 0; }
.crop-loading {
  font-size: 13px;
  color: var(--text-light);
  padding: 12px 0;
  line-height: 1.7;
}
.crop-tip {
  font-size: 13px;
  color: var(--text-light);
  margin: -4px 0 14px;
  line-height: 1.9;
}
.crop-tip b { color: var(--text); font-weight: 600; }
.crop-filebar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 6px 0 14px;
}
.crop-filebar .crop-fname {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crop-filebar .btn { min-height: 34px; padding: 6px 14px; font-size: 13px; }
.crop-tiles {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 8px;
}
.crop-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.crop-tile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.crop-tile-head .crop-title { font-size: 13px; font-weight: 600; }
.crop-tile-head .crop-sub { font-size: 12px; color: var(--text-light); }
.crop-tile-head .crop-acts { margin-left: auto; display: flex; gap: 6px; }
.crop-mini {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-light);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.4;
}
.crop-mini:hover { color: var(--primary); border-color: var(--primary); }
.crop-tile-body {
  text-align: center;
  overflow-x: auto;
  overflow-y: hidden;
}
.crop-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: hidden;
  background: #ffffff;
}
.crop-stage canvas { display: block; background: #ffffff; }
.crop-stage .crop-over {
  position: absolute;
  left: 0;
  top: 0;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: transparent;
}
.crop-foot { margin-top: 18px; }

/* ============================================================
   工具页「使用反馈」区块（FormSubmit 转发至站长邮箱，纯前端）
   ============================================================ */
.tool-feedback { margin-top: 18px; }
.tool-feedback .fb-inner { display: flex; flex-direction: column; gap: 4px; }
.fb-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.fb-head .fb-title { font-size: 16px; font-weight: 700; }
.fb-head .fb-sub { font-size: 12px; color: var(--text-light); }
.fb-note { font-size: 12px; color: var(--text-light); line-height: 1.7; margin: 2px 0 10px; }
.fb-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 10px; }
.fb-field { display: flex; flex-direction: column; gap: 5px; }
.fb-field label { font-size: 13px; color: var(--text); font-weight: 500; }
.fb-field label .opt { font-weight: 400; color: var(--text-light); }
.fb-field select, .fb-field input, .fb-field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 13px; outline: none; box-sizing: border-box;
}
.fb-field select:focus, .fb-field input:focus, .fb-field textarea:focus { border-color: var(--primary); }
.fb-field textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.fb-field.full { grid-column: 1 / -1; }
.fb-rows { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.fb-rate { display: inline-flex; gap: 2px; font-size: 20px; line-height: 1; }
.fb-rate button {
  border: none; background: none; cursor: pointer; padding: 0 1px; font-size: 20px;
  filter: grayscale(1); opacity: 0.45; transition: filter .15s, opacity .15s;
}
.fb-rate button.on { filter: none; opacity: 1; }
.fb-attach { display: inline-flex; flex-direction: column; gap: 6px; }
.fb-attach .fb-prevs { display: flex; gap: 8px; flex-wrap: wrap; }
.fb-attach .fb-prev { position: relative; width: 64px; height: 64px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.fb-attach .fb-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fb-attach .fb-prev .x {
  position: absolute; right: 2px; top: 2px; width: 18px; height: 18px; line-height: 18px;
  text-align: center; font-size: 12px; color: #fff; background: rgba(0,0,0,.6);
  border-radius: 50%; cursor: pointer; border: none;
}
.fb-attach .btn-file {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-size: 13px; border: 1px dashed var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text-light); cursor: pointer;
}
.fb-attach .btn-file:hover { color: var(--primary); border-color: var(--primary); }
.fb-hp { position: absolute !important; left: -9999px !important; opacity: 0 !important; height: 0 !important; width: 0 !important; }
.fb-submit-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.fb-state { font-size: 13px; color: var(--text-light); }
.fb-state.ok { color: var(--primary); }
.fb-state.err { color: var(--danger); }
.fb-btn { min-height: 40px; padding: 9px 22px; }
.fb-btn[disabled] { opacity: .55; cursor: not-allowed; }
.fb-ok-box { border: 1px solid var(--border); border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.8; margin-top: 10px; color: var(--text); }
.fb-ok-box b { color: var(--primary); }
.fb-disabled-box { font-size: 13px; color: var(--text-light); line-height: 1.8; }
@media (max-width: 720px) { .fb-fields { grid-template-columns: 1fr; } }
