/* 轱辘压图 · 视觉无损图片压缩工具样式 */
/* hidden 属性强制生效，防止被 display: flex 覆盖 */
[hidden] { display: none !important; }

:root {
  --paper: #f3f2ed;
  --ink: #111;
  --muted: #8a877f;
  --line: #d8d5cc;
  --accent: #6c5ce7;
  --accent-soft: #a29bfe;
  --green: #27ae60;
  --red: #c3352b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.compress-shell { min-height: 100dvh; display: flex; flex-direction: column; }

/* 顶栏 */
.topbar {
  height: 72px; padding: 0 clamp(18px, 4vw, 58px);
  display: flex; align-items: center; gap: 28px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  background: rgba(243, 242, 237, .88);
  backdrop-filter: blur(18px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; letter-spacing: -.055em; font-size: 22px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand-dot { color: var(--accent); }
.topnav { display: flex; gap: 6px; margin-left: auto; }
.topnav a { padding: 9px 13px; border-radius: 999px; color: #666; font-size: 14px; text-decoration: none; transition: background .2s, color .2s; }
.topnav a:hover { background: #111; color: #fff; }

/* 右上角永久累计统计 */
.total-stats { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-radius: 999px; background: #111; color: rgba(255,255,255,.82); font-size: 13px; white-space: nowrap; }
.total-stats strong { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-stat-divider { width: 1px; height: 14px; background: rgba(255,255,255,.25); }

/* 页面 */
.compress-page { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0 72px; flex: 1; }

.compress-intro { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); align-items: end; gap: 48px; padding: 18px 0 40px; border-bottom: 1px solid var(--line); }
.gallery-index { margin: 0 0 16px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .16em; }
.compress-intro h1 { max-width: 800px; margin: 0; font-size: clamp(52px, 7.5vw, 110px); letter-spacing: -.08em; line-height: .85; }
.intro-desc { max-width: 54ch; margin: 22px 0 0; color: #666; font-size: 15px; line-height: 1.75; }

.compress-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; padding-top: 14px; }
.compress-metrics .metric { display: grid; gap: 3px; }
.compress-metrics .metric strong { font-size: 22px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.compress-metrics .metric span { color: var(--muted); font-size: 11px; }

/* 模式切换 */
.mode-tabs { display: flex; gap: 4px; margin: 24px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.5); width: fit-content; }
.mode-tab { padding: 9px 20px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; transition: all .18s; }
.mode-tab:hover { color: var(--ink); }
.mode-tab.active { background: var(--ink); color: #fff; }

/* 上传区 */
.compress-upload { display: grid; grid-template-columns: 1fr 300px; gap: 24px; margin: 30px 0; }
.upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 46px 24px; border: 2px dashed var(--line); border-radius: 16px;
  background: rgba(255, 255, 255, .6); cursor: pointer; transition: border-color .2s, background .2s; text-align: center;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: rgba(108, 92, 231, .05); }
.upload-icon { font-size: 40px; line-height: 1; color: var(--accent); }
.upload-zone strong { font-size: 16px; }
.upload-zone small { color: var(--muted); font-size: 13px; max-width: 40ch; }

.quality-control { display: flex; flex-direction: column; gap: 10px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .6); align-self: center; }
.quality-control label { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.quality-control output { color: var(--accent); font-weight: 700; }
.quality-control input[type="range"] { width: 100%; accent-color: var(--accent); }
.quality-control small { color: var(--muted); font-size: 12px; }

/* 尺寸选择器 */
.size-selector { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.size-selector label { font-weight: 600; font-size: 14px; }
.size-btns { display: flex; gap: 6px; }
.size-btn { flex: 1; padding: 8px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 13px; font-weight: 600; transition: all .15s; }
.size-btn:hover { border-color: #777; color: var(--ink); }
.size-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* GIF 抽帧选择器 */
.frame-selector { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.frame-selector label { font-weight: 600; font-size: 14px; }
.frame-btns { display: flex; gap: 6px; }
.frame-btn { flex: 1; padding: 8px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 13px; font-weight: 600; transition: all .15s; }
.frame-btn:hover { border-color: #777; color: var(--ink); }
.frame-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.pure-frame-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; padding: 10px 14px;
  border: 1.5px dashed var(--accent-soft); border-radius: 10px;
  background: rgba(108, 92, 231, .07);
  color: var(--accent); font-weight: 700 !important; font-size: 14px !important;
  cursor: pointer; user-select: none; transition: all .15s;
}
.pure-frame-row:hover { border-color: var(--accent); background: rgba(108, 92, 231, .12); }
.pure-frame-row input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.pure-frame-row:has(input:checked) {
  border-style: solid; border-color: var(--accent);
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 10px rgba(108, 92, 231, .35);
}
.pure-frame-row:has(input:checked) input { accent-color: #fff; }
.pure-frame-row[hidden] { display: none !important; }

/* 二维码面板 */
.qr-panel { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 24px; margin: 30px 0; align-items: start; }
.qr-input-card { display: flex; flex-direction: column; gap: 14px; padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .6); }
.qr-input-card > label { font-weight: 700; font-size: 15px; }
.qr-url-row { display: flex; gap: 10px; }
.qr-url-row input {
  flex: 1; min-width: 0; padding: 0 14px; min-height: 40px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 14px; outline: none; transition: border-color .15s;
}
.qr-url-row input:focus { border-color: var(--accent); }
.qr-hint { color: var(--muted); font-size: 12px; }
.qr-options { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.qr-options label { font-weight: 600; font-size: 14px; }
.qr-color-row { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.qr-color-row small { color: var(--muted); font-size: 12px; }
.qr-color-picker { display: flex; gap: 8px; align-items: center; }
.qr-swatch {
  width: 30px; height: 30px; border-radius: 8px;
  border: 2px solid var(--line); cursor: pointer; padding: 0;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.qr-swatch:hover { transform: scale(1.1); }
.qr-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(108, 92, 231, .3); transform: scale(1.08); }
.qr-color-picker input[type="color"] {
  width: 30px; height: 30px; padding: 0; border: 2px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.qr-color-picker input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.qr-color-picker input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
.qr-result { display: flex; flex-direction: column; gap: 14px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .6); align-items: center; }
.qr-result canvas {
  width: 100%; max-width: 320px; height: auto;
  border: 1px solid var(--line); border-radius: 10px;
  /* 棋盘格背景示意透明区域 */
  background-image:
    linear-gradient(45deg, #e8e6df 25%, transparent 25%, transparent 75%, #e8e6df 75%),
    linear-gradient(45deg, #e8e6df 25%, #fff 25%, #fff 75%, #e8e6df 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.qr-result-info { display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; word-break: break-all; }
.qr-result-info strong { font-size: 13px; }
.qr-result-info span { color: var(--muted); font-size: 12px; }
.qr-result-info .btn { margin-top: 8px; width: 100%; }

/* 进度条 */
.progress-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; padding: 0 4px; }
.progress-track { flex: 1; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 999px; background: var(--accent); transition: width .3s ease; }
.progress-label { color: var(--accent); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 文件列表 */
.compress-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

/* 批次分隔条 */
.batch-divider {
  display: flex; align-items: center; gap: 14px;
  margin: 8px 0 4px; padding: 14px 18px;
  border-radius: 12px; background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff; box-shadow: 0 2px 12px rgba(108, 92, 231, .25);
}
.batch-divider:not(:first-child) { margin-top: 28px; }
.batch-line { display: none; }
.batch-info { display: flex; align-items: center; gap: 14px; flex: 1; flex-wrap: wrap; }
.batch-num { font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
.batch-mode { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,.25); }
.batch-time { font-size: 13px; opacity: .85; font-variant-numeric: tabular-nums; }
.batch-count { font-size: 13px; font-weight: 600; opacity: .9; }
.batch-actions { display: flex; gap: 8px; }
.batch-actions .btn { background: rgba(255,255,255,.9); border: none; color: #6c5ce7; font-weight: 600; }
.batch-actions .btn:hover { background: #fff; }
.batch-actions .btn:disabled { opacity: .4; cursor: not-allowed; }
.batch-actions .btn-ghost { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.batch-actions .btn-ghost:hover { background: rgba(255,255,255,.25); }

.compress-item {
  display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .8);
}
.compress-item.error { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.item-preview { width: 88px; height: 88px; border-radius: 10px; overflow: hidden; background: #eee; display: flex; align-items: center; justify-content: center; }
.item-preview img { width: 100%; height: 100%; object-fit: cover; }
.item-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.item-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-dims { color: var(--muted); font-size: 12px; }
.item-size-row { display: flex; gap: 12px; align-items: center; font-size: 12px; margin-top: 2px; }
.size-orig { color: var(--muted); }
.size-result { color: var(--green); font-weight: 700; }
.size-saved { color: var(--green); font-weight: 700; background: color-mix(in srgb, var(--green) 14%, transparent); padding: 1px 8px; border-radius: 999px; }
.size-saved.neg { color: var(--muted); background: transparent; }
.item-actions { display: flex; gap: 8px; align-items: center; }
.err-msg { color: var(--red); font-size: 12px; }
.processing { color: var(--accent); font-size: 13px; font-weight: 600; }
.pending { color: var(--muted); font-size: 13px; }

/* 按钮 */
.btn { min-height: 40px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); padding: 0 16px; font-size: 14px; transition: all .15s; }
.btn:hover { border-color: #777; }
.btn-dark { background: #111; color: #fff; border-color: #111; }
.btn-dark:hover { background: #333; }
.btn-dark:disabled { background: #aaa; border-color: #aaa; cursor: not-allowed; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-ghost { background: transparent; }

.compress-actions { display: flex; justify-content: flex-end; }

.compress-foot { padding: 28px clamp(18px, 4vw, 58px); border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #111; color: #fff; padding: 12px 22px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 移动端 */
@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 16px; gap: 8px; }
  .total-stats { padding: 6px 12px; font-size: 11px; gap: 8px; }
  .compress-page { width: calc(100% - 28px); padding-top: 24px; }
  .compress-intro { grid-template-columns: 1fr; gap: 20px; padding-bottom: 28px; }
  .compress-intro h1 { font-size: clamp(46px, 16vw, 72px); }
  .compress-metrics { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .compress-upload { grid-template-columns: 1fr; }
  .qr-panel { grid-template-columns: 1fr; }
  .qr-url-row { flex-direction: column; }
  .mode-tabs { width: 100%; }
  .mode-tab { flex: 1; text-align: center; }
  .compress-item { grid-template-columns: 64px minmax(0, 1fr); }
  .item-preview { width: 64px; height: 64px; }
  .item-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .compress-foot { flex-direction: column; gap: 4px; }
}
