:root {
  --bg: #f6f7f9;
  --card: #fff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1a1d23;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --line: #2b2f37;
    --accent: #5b8cff;
    --accent-soft: #1d2638;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 40px 16px 24px; }
.head { text-align: center; margin-bottom: 20px; }
.head h1 { margin: 0; font-size: 26px; letter-spacing: .5px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.tabs[hidden], .card[hidden] { display: none; }
.cats { display: flex; justify-content: center; margin-bottom: 12px; }
.cats a {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 8px 22px; cursor: pointer; font-size: 15px; text-decoration: none;
}
.cats a:first-child { border-radius: 10px 0 0 10px; }
.cats a:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.cats a.active { color: var(--text); font-weight: 600; background: var(--accent-soft); border-color: var(--accent); }
.cats a:last-child.active { border-left: 1px solid var(--accent); }
.tabs a {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 14px; text-decoration: none;
}
.tabs a:hover { border-color: var(--accent); }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.desc { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 12px;
  cursor: pointer; text-align: center; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-main { font-size: 15px; }
.drop-hint { font-size: 12px; color: var(--muted); }

.files { list-style: none; margin: 12px 0 0; padding: 0; }
.files li {
  display: flex; align-items: center; gap: 8px; padding: 7px 4px;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.files .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.files button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 2px 6px; font-size: 14px; border-radius: 6px;
}
.files button:hover { background: var(--accent-soft); color: var(--text); }
.files button:disabled { opacity: .3; cursor: default; background: transparent; }
.total { margin: 6px 0 0; font-size: 12px; color: var(--muted); text-align: right; min-height: 1em; }

.opts, .iopts { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.iopts[hidden] { display: none; }
.opts label, .iopts label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.iopts label.range { min-width: 160px; flex: 1; }
.iopts input[type=range] { accent-color: var(--accent); height: 34px; margin: 0; }
.iopts input[type=range]:disabled { opacity: .4; cursor: not-allowed; }
.iopts select {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 7px 9px; font-size: 14px;
}
.ghost {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font-size: 14px; cursor: pointer;
}
.ghost:hover { border-color: var(--accent); }
.crop-stage { margin-top: 12px; display: flex; justify-content: center; background: repeating-conic-gradient(var(--line) 0 25%, transparent 0 50%) 0 0 / 16px 16px; border-radius: 8px; overflow: hidden; }
.crop-stage[hidden] { display: none; }
.crop-stage canvas { display: block; max-width: 100%; touch-action: none; cursor: crosshair; }
.preview { display: block; max-width: 100%; max-height: 240px; margin: 0 auto 8px; border-radius: 6px; }
.files .gain { font-size: 12px; white-space: nowrap; color: var(--ok); }
.files .gain.flat { color: var(--muted); }
.files a { font-size: 13px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.opts label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.opts.grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.opts .full { grid-column: 1 / -1; }
.opts input[type=text], .opts input[type=number], .opts select {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 7px 9px; font-size: 14px; min-width: 0;
}
.opts input[type=text] { min-width: 260px; }
.opts.grid input[type=text] { min-width: 0; width: 100%; }
.opts input[type=color] { height: 36px; width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 2px; }
@media (max-width: 520px) {
  .opts.grid { grid-template-columns: repeat(2, 1fr); }
  .opts input[type=text] { min-width: 0; width: 100%; }
  .opts > label, .iopts > label { flex: 1 1 100%; }
}

.go {
  margin-top: 18px; width: 100%; padding: 11px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer;
}
.go:disabled { opacity: .45; cursor: not-allowed; }

.status { margin-top: 14px; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.bar.busy i { width: 35% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.status p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.result { margin-top: 14px; padding: 12px; border-radius: 10px; background: var(--accent-soft); text-align: center; }
.result p { margin: 0 0 8px; font-size: 14px; }
.download {
  display: inline-block; padding: 8px 20px; border-radius: 8px; background: var(--ok);
  color: #fff; text-decoration: none; font-size: 14px;
}
.error { margin: 14px 0 0; color: var(--danger); font-size: 14px; }

.foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--muted); }

.info { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.info h2 { margin: 0 0 10px; font-size: 16px; color: var(--text); font-weight: 600; }
.info h2:not(:first-child) { margin-top: 20px; }
.info p { margin: 0 0 10px; }
.info ul, .info ol { margin: 0 0 10px; padding-left: 20px; }
.info li { margin: 4px 0; }
.faq { margin: 0; }
.faq dt { color: var(--text); font-weight: 500; margin-top: 12px; }
.faq dt:first-child { margin-top: 0; }
.faq dd { margin: 4px 0 0; }
.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.tool-grid a {
  display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); text-decoration: none; color: var(--text); transition: border-color .15s;
}
.tool-grid a:hover { border-color: var(--accent); }
.tool-grid strong { display: block; font-size: 14px; font-weight: 600; }
.tool-grid span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (max-width: 520px) { .tool-grid { grid-template-columns: 1fr; } }
