/* 所有可见文字不小于 12px；层级靠 12/13/14/15/16/19 拉开。 */

:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --card: #ffffff;
  --fg: #191c20;
  --muted: #626b75;
  --line: #dce0e5;
  --accent: #2f6df6;
  --accent-ink: #ffffff;
  --accent-soft: #e8efff;
  --warn-bg: #fff4d6;
  --warn-line: #e6c265;
  --warn-fg: #6b4e05;
  --ok: #167a4a;
  --err: #b23a2f;
  --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 8px 24px rgba(20, 30, 50, .05);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --card: #1b1e23;
    --fg: #e7eaee;
    --muted: #9aa4af;
    --line: #2b3037;
    --accent: #5b8cff;
    --accent-ink: #0d1220;
    --accent-soft: #1d2740;
    --warn-bg: #3a2f14;
    --warn-line: #6b5520;
    --warn-fg: #f0d79a;
    --ok: #4cc38a;
    --err: #ff8a7a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(980px, calc(100% - 32px)); margin: 0 auto; }

/* ---------------------------------------------------------------- 头部 */

.masthead {
  padding: 34px 0 18px;
  background:
    radial-gradient(700px 180px at 18% 0%, var(--accent-soft), transparent 70%),
    transparent;
}

.eyebrow {
  margin: 0 0 4px;
  font: 12px/1.4 var(--mono);
  letter-spacing: .08em;
  color: var(--muted);
  text-transform: uppercase;
}

h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.01em; }

.sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- 面板 */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 8px 0 18px;
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 30px 16px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.drop:hover, .drop:focus-visible, .drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.drop strong { font-size: 15px; font-weight: 600; }
.drop span { color: var(--muted); font-size: 13px; }
.drop-icon { color: var(--accent); margin-bottom: 2px; }

/* ---------------------------------------------------------------- 控件 */

.controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.label { font-size: 12px; color: var(--muted); letter-spacing: .02em; }

.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  background: var(--bg);
  gap: 3px;
}

.seg button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 5px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.seg button small { font-size: 12px; color: var(--muted); line-height: 1.2; }
.seg button.on { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; }
.seg button.on small { color: var(--accent); }

select {
  font: inherit;
  font-size: 13px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 43px;
}

.hint { font-size: 12px; color: var(--muted); margin: 0; }

.warn {
  margin-top: 14px;
  padding: 9px 12px;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-radius: 10px;
  font-size: 13px;
}

.advanced { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.advanced summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.adv-body { padding: 10px 2px 2px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.row input[type="range"] { flex: 1; max-width: 260px; }
.row output { font: 12px/1 var(--mono); color: var(--muted); min-width: 36px; }
.adv-body .hint { font-size: 12px; }

.actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

button.primary, button.ghost {
  font: inherit;
  font-size: 13px;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button:disabled { opacity: .45; cursor: default; }
button.primary:not(:disabled):hover { filter: brightness(1.05); }

/* ---------------------------------------------------------------- 列表 */

.list { display: flex; flex-direction: column; gap: 10px; }

.item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.thumb {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  object-fit: cover;
}

.meta { min-width: 0; }
.name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dims { font: 12px/1.5 var(--mono); color: var(--muted); }
.status { font-size: 12px; color: var(--muted); margin-top: 2px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.bar {
  height: 4px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
  margin-top: 7px;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width .15s linear;
}

.item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.item-actions button {
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
}
.item-actions button:hover { border-color: var(--accent); color: var(--accent); }

.footnote { color: var(--muted); font-size: 12px; margin: 18px 0 40px; }

/* ---------------------------------------------------------------- 对比 */

.compare {
  width: min(1000px, 94vw);
  max-height: 92vh;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--fg);
  padding: 0;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}

.compare::backdrop { background: rgba(8, 12, 20, .62); }

.cmp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.cmp-actions { display: flex; gap: 6px; }
.cmp-actions .ghost { padding: 6px 10px; font-size: 12px; }
.cmp-actions .ghost.on { border-color: var(--accent); color: var(--accent); }

.cmp-stage {
  position: relative;
  overflow: auto;
  max-height: 66vh;
  background:
    repeating-conic-gradient(rgba(127,127,127,.12) 0% 25%, transparent 0% 50%) 0 0 / 20px 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.cmp-stage canvas {
  display: block;
  position: relative;
  image-rendering: auto;
}

.cmp-stage canvas + canvas {
  position: absolute;
  inset: 0;
  margin: auto;
  clip-path: inset(0 0 0 50%);
}

.cmp-stage.fit canvas {
  width: 100% !important;
  height: auto !important;
  position: relative;
}
.cmp-stage.fit canvas + canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.cmp-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--accent);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}

.cmp-slider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 4px;
  font-size: 12px;
  color: var(--muted);
}
.cmp-slider input { flex: 1; }
.compare .hint { padding: 0 16px 12px; }

/* ---------------------------------------------------------------- 移动端 */

@media (max-width: 720px) {
  .controls { grid-template-columns: 1fr; }
  .item { grid-template-columns: 60px minmax(0, 1fr); }
  .thumb { width: 60px; height: 60px; }
  .item-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .masthead { padding-top: 24px; }
  h1 { font-size: 22px; }
}
