/* ============================================
   图片压缩工具 - 原生现代 CSS
   无任何框架依赖 · 支持暗色模式
   ============================================ */

/* ---------- CSS 变量（亮色） ---------- */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-hint: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --nav-height: 64px;
  --transition: 0.2s ease;
  --checker-bg: repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}

/* ---------- 暗色模式 ---------- */
[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e3a5f;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-hint: #64748b;
  --border: #334155;
  --border-light: #273449;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --checker-bg: repeating-conic-gradient(#273449 0% 25%, #1e293b 0% 50%) 50% / 16px 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e3a5f;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-hint: #64748b;
    --border: #334155;
    --border-light: #273449;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --checker-bg: repeating-conic-gradient(#273449 0% 25%, #1e293b 0% 50%) 50% / 16px 16px;
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden; /* 全局禁止横向溢出 */
  transition: background var(--transition), color var(--transition);
}

h1, h2, h3 { font-weight: 600; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; font-size: inherit; }
img { display: block; max-width: 100%; }

/* ---------- 顶部导航 ---------- */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--nav-height); padding: 0 24px;
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm); transition: background var(--transition);
}
.nav-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  cursor: pointer; border: 2px solid var(--primary-light);
  transition: transform var(--transition); flex-shrink: 0;
}
.avatar:hover { transform: scale(1.08); }
.nav-info { min-width: 0; }
.site-title { font-size: 1.15rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.author-name { font-size: 0.8rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.nav-link { color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; transition: color var(--transition); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link:hover { color: var(--primary); }
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; background: var(--border-light);
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
}
.theme-toggle:hover { background: var(--primary-light); transform: rotate(20deg); }
.follow-btn {
  padding: 7px 18px; background: var(--primary); color: #fff;
  border-radius: 20px; font-size: 0.85rem; font-weight: 500;
  transition: background var(--transition), transform var(--transition);
}
.follow-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }

/* ---------- 主体布局 ---------- */
.main-container {
  display: grid; grid-template-columns: 420px 1fr; gap: 20px;
  padding: 20px; max-width: 1600px; margin: 0 auto; align-items: start;
}

/* ---------- 步骤卡片 ---------- */
.control-panel { display: flex; flex-direction: column; gap: 16px; }
.step-card {
  background: var(--card-bg); border-radius: var(--radius-md); padding: 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
  transition: background var(--transition);
}
.step-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.step-number {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; background: var(--primary); color: #fff;
  border-radius: 50%; font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.step-title { font-size: 1rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 拖拽上传区 ---------- */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-md);
  padding: 24px 16px; text-align: center; cursor: pointer;
  transition: all var(--transition); background: var(--border-light);
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: var(--primary-light); }
.drop-inner { pointer-events: none; }
.drop-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.drop-text { font-size: 0.95rem; font-weight: 500; color: var(--text); }
.drop-hint { font-size: 0.75rem; color: var(--text-hint); margin-top: 4px; }
.drop-hint strong { color: var(--text-secondary); }

/* ---------- 文件列表 ---------- */
.file-list-wrap { margin-top: 14px; }
.file-list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 0.85rem; color: var(--text-secondary); }
.file-count { color: var(--primary); font-weight: 600; }
.clear-btn { font-size: 0.8rem; color: var(--danger); opacity: 0.7; transition: opacity var(--transition); }
.clear-btn:hover { opacity: 1; }
.file-list { list-style: none; max-height: 160px; overflow-y: auto; border: 1px solid var(--border-light); border-radius: var(--radius-sm); }
.file-list:empty { display: none; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border-light); font-size: 0.8rem; }
.file-item:last-child { border-bottom: none; }
.file-item-icon { flex-shrink: 0; }
.file-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.file-item-size { flex-shrink: 0; color: var(--text-secondary); font-size: 0.75rem; }
.file-item-remove { flex-shrink: 0; color: var(--text-hint); font-size: 1rem; line-height: 1; transition: color var(--transition); }
.file-item-remove:hover { color: var(--danger); }

/* 处理完成后的文件项 */
.file-item.processed {
  background: var(--border-light);
}
.file-item.processed .file-item-name {
  text-decoration: line-through;
  text-decoration-color: var(--danger);
  color: var(--text-secondary);
}
.file-item-sizes {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0; font-size: 0.75rem;
}
.orig-size {
  text-decoration: line-through;
  color: var(--text-hint);
}
.size-arrow { color: var(--text-hint); font-size: 0.7rem; }
.comp-size {
  color: var(--danger);
  font-weight: 700;
}

/* ---------- 表单元素 ---------- */
.form-row { margin-top: 14px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-select, .form-input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card-bg); color: var(--text);
  font-size: 0.85rem; transition: border-color var(--transition);
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.form-select:focus, .form-input:focus { outline: none; border-color: var(--primary); }
.form-input::placeholder { color: var(--text-hint); }
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-group.radio-inline { flex-direction: row; flex-wrap: wrap; gap: 12px; }
.radio-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text); cursor: pointer; padding: 4px 0; }
.radio-item input[type="radio"] { accent-color: var(--primary); width: 15px; height: 15px; }
.hint-text { font-size: 0.72rem; color: var(--text-hint); margin-top: 6px; line-height: 1.5; }
.format-hint {
  margin-top: 6px; font-size: 0.75rem; color: #d97706;
  line-height: 1.5; padding: 7px 10px; background: rgba(217,119,6,0.08);
  border-radius: var(--radius-sm); border-left: 3px solid #d97706;
}

/* ---------- 高级选项 ---------- */
.option-block { padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.option-block:last-child { border-bottom: none; }
.option-block.disabled { opacity: 0.4; pointer-events: none; }
.option-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.option-label-row label { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.quality-value { font-size: 0.9rem; font-weight: 700; color: var(--primary); min-width: 42px; text-align: right; }

/* 滑块 */
.range-slider {
  width: 100%; height: 6px; -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 3px; outline: none;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px;
  background: var(--primary); border-radius: 50%; cursor: pointer;
  border: 2px solid var(--card-bg); box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform var(--transition);
}
.range-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.range-slider::-moz-range-thumb {
  width: 18px; height: 18px; background: var(--primary); border-radius: 50%;
  cursor: pointer; border: 2px solid var(--card-bg); box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* 滑块刻度 —— 按滑块实际范围(10-100)精确定位，非均匀分布 */
.range-ticks { position: relative; height: 16px; margin-top: 4px; }
.range-ticks span {
  position: absolute; top: 0; transform: translateX(-50%);
  font-size: 0.7rem; color: var(--text-hint); white-space: nowrap;
}
.range-ticks .tick-start { left: 0; transform: translateX(0); }
.range-ticks .tick-end { left: 100%; transform: translateX(-100%); }

.checkbox-block { padding: 10px 0; }
.checkbox-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text); cursor: pointer; }
.checkbox-item input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; }

/* ---------- 尺寸调整 ---------- */
.resize-inputs { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.resize-inputs .form-input { flex: 1; min-width: 0; }
.resize-x { color: var(--text-hint); font-size: 0.9rem; flex-shrink: 0; }

/* ---------- 处理按钮 & 进度 ---------- */
.process-btn {
  width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border-radius: var(--radius-sm); font-size: 0.95rem; font-weight: 600;
  transition: all var(--transition); display: flex; align-items: center; justify-content: center; gap: 6px;
}
.process-btn:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.process-btn:disabled { background: var(--border); color: var(--text-hint); cursor: not-allowed; }
.process-btn.processing { background: var(--warning); pointer-events: none; }
.progress-wrap { margin-top: 14px; }
.progress-bar { width: 100%; height: 8px; background: var(--border-light); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); border-radius: 4px; transition: width 0.3s ease; width: 0%; }
.progress-text { display: block; text-align: center; font-size: 0.8rem; color: var(--text-secondary); margin-top: 6px; }
.stats-bar { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-light); font-size: 0.8rem; color: var(--text-secondary); }
.stats-bar strong { color: var(--primary); }
.stats-sep { color: var(--border); }

/* ---------- 右侧预览区 ---------- */
.preview-panel {
  background: var(--card-bg); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  position: sticky; top: calc(var(--nav-height) + 20px);
  max-height: calc(100vh - var(--nav-height) - 40px);
  transition: background var(--transition);
  min-width: 0; /* 防止 grid 子项被内容撑开导致页面横向溢出 */
}
.preview-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-light); }
.preview-header h2 { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.download-long-btn {
  padding: 7px 16px; background: var(--success); color: #fff;
  border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 500;
  transition: all var(--transition); white-space: nowrap; flex-shrink: 0;
}
.download-long-btn:hover:not(:disabled) { background: #059669; transform: translateY(-1px); }
.download-long-btn:disabled { background: var(--border); color: var(--text-hint); cursor: not-allowed; }
.preview-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px;
  min-width: 0; /* 防止 flex 子项被内容撑开 */
}
.preview-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 300px; color: var(--text-hint); text-align: center; }
.placeholder-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }

/* ---------- before/after 对比滑块 ---------- */
.compare-wrap { width: 100%; min-width: 0; box-sizing: border-box; }
.compare-container {
  position: relative; width: 100%; overflow: hidden;
  border-radius: var(--radius-sm); border: 1px solid var(--border-light);
  user-select: none; background: var(--checker-bg); line-height: 0;
  min-height: 200px;
}
.compare-base { display: block; width: 100%; height: auto; max-height: 420px; min-height: 200px; object-fit: contain; pointer-events: none; margin: 0 auto; }
.compare-overlay { position: absolute; top: 0; left: 0; height: 100%; width: 50%; overflow: hidden; pointer-events: none; }
.compare-overlay-img { display: block; height: 100%; width: auto; max-width: none; object-fit: contain; }
.compare-divider {
  position: absolute; top: 0; left: 50%; width: 2px; height: 100%;
  background: #fff; cursor: ew-resize; transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(0,0,0,0.4); z-index: 2;
}
.compare-handle {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 38px; height: 38px; background: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35); font-size: 15px; color: var(--text); cursor: ew-resize;
}
.compare-labels { display: flex; justify-content: space-between; margin-top: 8px; font-size: 0.78rem; font-weight: 600; }
.compare-label-left { color: var(--text-secondary); }
.compare-label-right { color: var(--success); }
.compare-meta {
  display: flex; justify-content: space-around; margin-top: 10px;
  padding: 10px; background: var(--border-light); border-radius: var(--radius-sm);
  font-size: 0.78rem; color: var(--text-secondary); text-align: center; gap: 8px;
}
.compare-meta > div { flex: 1; min-width: 0; }
.compare-meta span { display: block; font-size: 0.68rem; }
.compare-meta strong { color: var(--text); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* ---------- 单图预览 ---------- */
.preview-result { width: 100%; min-width: 0; }
.preview-image-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--checker-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  min-height: 200px;
  overflow: hidden;
}
.preview-image {
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 0.12s ease-out;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.preview-image.panning { cursor: grabbing !important; }

/* 缩放控制条（位于预览标题栏） */
.preview-header .zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--border-light);
  padding: 4px 8px;
  border-radius: 20px;
  margin-left: auto;
  margin-right: 10px;
  flex-shrink: 0;
}
.preview-header .zoom-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 15px;
  border-radius: 50%;
  transition: all var(--transition);
  line-height: 1;
}
.preview-header .zoom-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.preview-header .zoom-level {
  color: var(--text-secondary);
  font-size: 11px;
  min-width: 38px;
  text-align: center;
  font-weight: 500;
}
.preview-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.preview-meta > div {
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
}
.preview-meta span {
  font-size: 0.7rem;
  color: var(--text-hint);
  margin-right: 4px;
}
.preview-meta strong {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-meta .meta-red { color: var(--danger); font-weight: 700; }

/* ---------- 图片放大灯箱 ---------- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.lightbox.active { display: flex; }
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-out;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 2rem;
  color: #fff;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  transition: background var(--transition);
  line-height: 1;
  z-index: 3001;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* ---------- 缩略图条 ---------- */
.thumb-strip {
  display: flex; gap: 10px; overflow-x: auto; overflow-y: visible;
  padding: 12px 4px 16px;
  margin-top: 12px; border-top: 1px solid var(--border-light);
  min-width: 0; width: 100%; box-sizing: border-box;
  align-items: flex-start;
}
.thumb-item {
  position: relative; flex-shrink: 0; width: 76px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer;
}
.thumb-img-wrap {
  position: relative; width: 60px; height: 60px;
  border-radius: 6px; overflow: hidden;
  border: 2px solid transparent; transition: border-color var(--transition), transform var(--transition);
  background: var(--checker-bg);
}
.thumb-item:hover .thumb-img-wrap { transform: translateY(-2px); }
.thumb-item.active .thumb-img-wrap { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.thumb-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.thumb-badge {
  position: absolute; bottom: 2px; right: 2px;
  background: rgba(0,0,0,0.65); color: #fff; font-size: 0.62rem;
  padding: 1px 5px; border-radius: 3px; font-weight: 600;
}
.thumb-item.processing .thumb-img-wrap { opacity: 0.5; }
.thumb-item.processing .thumb-img-wrap::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: thumbShimmer 1.2s infinite;
}
@keyframes thumbShimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
/* 缩略图下方下载按钮（图外，常显，比图宽） */
.thumb-download {
  width: 76px;
  padding: 5px 0;
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all var(--transition);
  text-align: center;
  line-height: 1;
  cursor: pointer;
}
.thumb-download:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---------- 预览汇总（标题栏内） ---------- */
.preview-header .preview-summary {
  display: flex; gap: 16px; padding: 0;
  border-top: none; background: none;
  flex: 1; justify-content: center;
  margin: 0 10px; min-width: 0;
}
.preview-header .summary-item { text-align: center; flex: none; white-space: nowrap; min-width: 0; }
.preview-header .summary-label { font-size: 0.65rem; color: var(--text-hint); margin-right: 4px; }
.preview-header .summary-value { font-size: 0.82rem; font-weight: 700; color: var(--text); }
.preview-header .summary-item.highlight .summary-value { color: var(--success); }
.preview-header .summary-item.highlight-red .summary-value { color: var(--danger); }

/* ---------- 弹窗 ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 1000; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: 28px 24px;
  max-width: 360px; width: 100%; text-align: center; position: relative;
  box-shadow: var(--shadow-lg); animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-close {
  position: absolute; top: 12px; right: 14px; font-size: 1.4rem; color: var(--text-hint);
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all var(--transition); line-height: 1;
}
.modal-close:hover { background: var(--border-light); color: var(--text); }
.modal-title { font-size: 1.1rem; margin-bottom: 4px; color: var(--text); }
.modal-subtitle { font-size: 0.85rem; color: var(--primary); font-weight: 600; margin-bottom: 16px; }
.qr-wrap { display: flex; justify-content: center; margin: 12px 0; }
.qr-img { width: 180px; height: 180px; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; }
.modal-footer-text { font-size: 0.8rem; color: var(--text-secondary); margin-top: 8px; }

/* ---------- 广告弹窗 ---------- */
.ad-modal-box { max-width: 380px; }
.cat-emoji { font-size: 2.2rem; margin-bottom: 12px; }
.ad-modal-text { font-size: 0.88rem; color: var(--text); line-height: 1.7; margin-bottom: 12px; text-align: left; }
.ad-close-btn {
  width: 100%; padding: 11px; background: var(--border); color: var(--text-hint);
  border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500;
  transition: all var(--transition); margin-top: 8px;
}
.ad-close-btn:not(:disabled) { background: var(--primary); color: #fff; cursor: pointer; }
.ad-close-btn:not(:disabled):hover { background: var(--primary-hover); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31,41,55,0.92); color: #fff;
  padding: 10px 22px; border-radius: 24px; font-size: 0.85rem;
  z-index: 2000; opacity: 0; pointer-events: none;
  transition: all 0.3s ease; max-width: 80vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(239,68,68,0.92); }
.toast.success { background: rgba(16,185,129,0.92); }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-hint); }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .main-container { grid-template-columns: 380px 1fr; }
}
@media (max-width: 900px) {
  .main-container { grid-template-columns: 1fr; }
  .preview-panel { position: static; max-height: none; }
  .preview-image { max-height: 360px; }
}
@media (max-width: 600px) {
  .navbar { padding: 0 12px; height: 56px; }
  .nav-link { display: none; }
  .avatar { width: 34px; height: 34px; }
  .site-title { font-size: 0.95rem; }
  .author-name { font-size: 0.72rem; }
  .follow-btn { padding: 6px 12px; font-size: 0.78rem; }
  .theme-toggle { width: 32px; height: 32px; }
  .main-container { padding: 10px; gap: 12px; }
  .step-card { padding: 14px; }
  .step-title { font-size: 0.92rem; }
  .drop-zone { padding: 18px 12px; }
  .drop-text { font-size: 0.88rem; }
  .drop-hint { font-size: 0.68rem; }
  .radio-group.radio-inline { flex-direction: column; gap: 6px; }
  .file-item { padding: 7px 8px; font-size: 0.75rem; }
  .file-item-sizes { font-size: 0.68rem; gap: 4px; }
  .process-btn { padding: 11px; font-size: 0.9rem; }
  .preview-header { padding: 12px 14px; }
  .preview-header h2 { font-size: 0.92rem; }
  .export-btn, .download-long-btn { padding: 6px 12px; font-size: 0.78rem; }
  .preview-scroll { padding: 14px; }
  .preview-image { max-height: 280px; }
  .preview-meta { padding: 6px 8px; gap: 3px; font-size: 0.72rem; }
  .preview-meta span { font-size: 0.65rem; }
  .preview-meta strong { font-size: 0.75rem; }
  .thumb-item { width: 64px; gap: 6px; }
  .thumb-img-wrap { width: 52px; height: 52px; }
  .thumb-download { width: 64px; font-size: 0.68rem; padding: 4px 0; }
  .preview-header .preview-summary { gap: 8px; margin: 0 6px; }
  .preview-header .summary-label { font-size: 0.58rem; }
  .preview-header .summary-value { font-size: 0.72rem; }
  .lightbox { padding: 20px; }
  .lightbox-close { top: 10px; right: 12px; width: 38px; height: 38px; font-size: 1.6rem; }
  .zoom-controls { opacity: 1; }
  .modal-box { padding: 22px 18px; max-width: 320px; }
  .qr-img { width: 150px; height: 150px; }
}
