:root {
  --bg: #0d1114;
  --bg-2: #12171c;
  --panel: #161c22;
  --panel-2: #1b222a;
  --panel-3: #212a33;
  --line: #26313b;
  --line-soft: #1e272f;
  --ink: #e8eef4;
  --ink-2: #9aa8b6;
  --ink-3: #6b7a89;
  --brand: #16c58a;
  --brand-2: #0fa876;
  --brand-soft: rgba(22, 197, 138, .13);
  --warn: #e0a33c;
  --bad: #e05c5c;
  --radius: 10px;
  --rail-w: 86px;
  --side-w: 300px;
  --settings-w: 316px;
}

* { box-sizing: border-box; }

/* hidden 必须压过一切 display 声明（.btn 是 inline-flex，会覆盖默认的 hidden） */
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

button { font: inherit; color: inherit; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

/* ── 顶栏 ──────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 16px 11px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line-soft);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { display: flex; }
.logo svg { display: block; }
.brand h1 { font-size: 16px; letter-spacing: .3px; }
.brand p { margin: 1px 0 0; color: var(--ink-3); font-size: 11px; letter-spacing: .2px; }

.topbar-actions { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s;
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: #31404d; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn svg { flex: 0 0 auto; opacity: .9; }

.btn.run {
  background: var(--brand);
  border-color: var(--brand);
  color: #06201a;
  font-weight: 650;
  padding: 9px 18px;
}
.btn.run:hover:not(:disabled) { background: #1ad697; border-color: #1ad697; }
.btn.run:disabled { background: #1a3a31; border-color: #1a3a31; color: #4b7c6e; opacity: 1; }

.btn.small { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn.danger { color: var(--bad); border-color: #4a2b2b; background: transparent; }
.btn.danger:hover:not(:disabled) { background: #2a1a1a; }

.btn.active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 6px;
}
.link:hover:not(:disabled) { color: var(--ink); }
.link:disabled { opacity: .4; cursor: not-allowed; }
.link.danger { color: #c96a6a; }
.link.danger:hover:not(:disabled) { color: var(--bad); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── 主体三栏 + 左侧导轨 ────────────────── */
.body {
  display: grid;
  grid-template-columns: var(--rail-w) var(--settings-w) minmax(0, 1fr) var(--side-w);
  gap: 12px;
  padding: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* 左侧导轨 */
.rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 8px 6px;
  min-height: 0;
  overflow-y: auto;
}
.rail-spacer { flex: 1 1 auto; min-height: 8px; }
.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  appearance: none;
  border: 1px solid transparent;
  background: none;
  color: var(--ink-2);
  border-radius: 8px;
  padding: 9px 4px 7px;
  font-size: 11px;
  cursor: pointer;
  transition: background .14s, color .14s, border-color .14s;
}
.rail-item:hover { background: var(--panel-2); color: var(--ink); }
.rail-item.active {
  background: var(--brand-soft);
  border-color: rgba(22, 197, 138, .35);
  color: var(--brand);
  font-weight: 600;
}

/* 面板通用 */
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  min-height: 0;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-head h2 { font-size: 14px; }

/* ── 压缩设置 ──────────────────────────── */
.settings {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.settings .panel-head { margin: 0; flex: 0 0 auto; }

.settings-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-foot {
  flex: 0 0 auto;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group { display: flex; flex-direction: column; gap: 7px; }
.group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: .2px;
}

.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 12px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.6px solid var(--ink-2);
  border-bottom: 1.6px solid var(--ink-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
select {
  width: 100%;
  appearance: none;
  padding: 8px 28px 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.hint { margin: 0; font-size: 11px; color: var(--ink-3); line-height: 1.5; }

/* 分段控件 */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented label, .grid-chips label { position: relative; }
.segmented input, .grid-chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span, .grid-chips span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink-2);
  font-size: 12.5px;
  transition: all .13s;
}
.segmented input:checked + span, .grid-chips input:checked + span {
  background: var(--brand);
  border-color: var(--brand);
  color: #06201a;
  font-weight: 650;
}
.segmented input:disabled + span, .grid-chips input:disabled + span { opacity: .4; }

.grid-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.inline-input {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 0 11px;
}
.inline-input input {
  flex: 1 1 auto;
  min-width: 0;
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 8px 0;
  font-variant-numeric: tabular-nums;
}
.inline-input input:focus { outline: none; }
.inline-input span { color: var(--ink-3); font-size: 12px; }

/* 质量策略卡片 */
.options { display: flex; flex-direction: column; gap: 6px; }
.option { position: relative; }
.option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.option-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  transition: all .13s;
}
.option-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink);
}
.option-title svg { color: var(--ink-3); flex: 0 0 auto; }
.option-desc { font-size: 11px; color: var(--ink-3); padding-left: 19px; }
.option input:checked + .option-body {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.option input:checked + .option-body .option-title { color: var(--brand); }
.option input:checked + .option-body .option-title svg { color: var(--brand); }
.option input:checked + .option-body .option-desc { color: #6fc7a9; }
.option input:disabled + .option-body { opacity: .4; }

/* 开关 */
.switches { gap: 9px; }
.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
  flex: 0 0 auto;
  width: 30px;
  height: 17px;
  border-radius: 99px;
  background: #2a3540;
  border: 1px solid #35424f;
  position: relative;
  transition: background .15s, border-color .15s;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #7d8c9b;
  transition: transform .15s, background .15s;
}
.switch input:checked + i { background: var(--brand); border-color: var(--brand); }
.switch input:checked + i::after { transform: translateX(13px); background: #06201a; }
.switch input:disabled + i { opacity: .4; }
.switch input:checked ~ span { color: var(--ink); }

/* 输出行 */
.output-row { display: flex; gap: 7px; align-items: stretch; }
.path-box {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: left;
}

.badge {
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(224, 163, 60, .1);
  border: 1px solid rgba(224, 163, 60, .3);
  color: var(--warn);
  font-size: 11.5px;
  line-height: 1.5;
}

/* ── 预览区 ────────────────────────────── */
.viewer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.viewer-top {
  position: absolute;
  top: 24px; left: 26px; right: 26px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 3;
}
.viewer { position: relative; }
.pill-label {
  background: rgba(10, 14, 18, .8);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  color: var(--ink-2);
  backdrop-filter: blur(4px);
}
.pill-label.accent {
  background: var(--brand);
  border-color: var(--brand);
  color: #06201a;
  font-weight: 650;
}

.stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  display: flex;
}
.stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  border-radius: 9px;
  overflow: hidden;
  background:
    linear-gradient(45deg, #171e25 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(-45deg, #171e25 25%, transparent 25%) 0 10px / 20px 20px,
    linear-gradient(45deg, transparent 75%, #171e25 75%) 10px -10px / 20px 20px,
    linear-gradient(-45deg, transparent 75%, #171e25 75%) -10px 0 / 20px 20px,
    #10151a;
  display: grid;
  /* 固定单个网格单元等于容器尺寸，两张图共用这一格；
     否则隐式行高是 auto，img 的 max-height:100% 会失效，
     长图/竖图就会溢出被裁切，对比线也就贴不上图像。 */
  grid-template-columns: 100%;
  grid-template-rows: 100%;
  place-items: center;
  user-select: none;
}

.stage img {
  grid-area: 1 / 1;
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: 4px;
  pointer-events: none;
}

/* 100% 模式：可滚动、可拖拽平移 */
.stage.zoomed {
  display: block;
  overflow: auto;
  place-items: initial;
  cursor: grab;
}
.stage.zoomed.panning { cursor: grabbing; }
.stage.zoomed .divider,
.stage.zoomed .divider-handle { cursor: ew-resize; }
.stage.zoomed img {
  max-width: none;
  max-height: none;
  margin: auto;
}
.stage.zoomed #img-after { position: absolute; top: 0; left: 0; }

/* 分割对比：裁剪比例由 JS 的 applySplit() 按图片可见区域写入，
 * 这里不再写死 50%，避免 CSS 与运行时状态互相覆盖导致线、图错位 */
.stage.split #img-before,
.stage.split #img-after {
  will-change: clip-path;
}

.divider {
  position: absolute;
  top: 0;
  bottom: auto;
  left: 50%;
  width: 2px;
  height: 0;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 0 12px rgba(0, 0, 0, .55);
  transform: translateX(-1px);
  z-index: 4;
  cursor: ew-resize;
}
.divider-handle {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #f2f6fa;
  color: #10151a;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .5);
  cursor: ew-resize;
}

.stage-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  color: #4d5a67;
  font-size: 12.5px;
  text-align: center;
  padding: 0 20px;
}
.stage-empty svg { opacity: .7; }
.stage-empty p { margin: 0; }
.stage.has-image .stage-empty { display: none; }

/* 「压缩后」单视图下预览还没就绪时的说明条：
   此时右侧没有真实结果，用文字说清楚，
   避免把原图占位误当成“压完和原图一模一样” */
.stage-note {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(16, 21, 26, .9);
  border: 1px solid rgba(255, 255, 255, .13);
  color: #c8d4df;
  font-size: 12.5px;
  line-height: 1.2;
  white-space: nowrap;
  z-index: 5;
  pointer-events: none;
}

/* 单视图等待预览时改成居中卡片：此时画布是空的，
   底部小药丸会让人以为出错了，居中加载态更符合预期 */
.stage-note.loading {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.stage-note.loading::before {
  content: '';
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 8px;
  vertical-align: -1px;
  border: 2px solid rgba(255, 255, 255, .28);
  border-top-color: #6ee7a8;
  border-radius: 50%;
  animation: note-spin .8s linear infinite;
}
@keyframes note-spin {
  to { transform: rotate(360deg); }
}

/* 预览工具条 */
.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.bar-left, .bar-right { display: flex; align-items: center; gap: 7px; min-width: 0; flex-wrap: wrap; }

.icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--panel-3); color: var(--ink); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.zoom-select-wrap select {
  width: auto;
  padding: 6px 24px 6px 9px;
  font-size: 11.5px;
  border-radius: 7px;
}

.stage.zoomed, .stage-wrap.zoomed { }

/* ── 右栏卡片 ──────────────────────────── */
.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 13px 13px;
  flex: 0 0 auto;
}
.card h3 { font-size: 12.5px; color: var(--ink); margin-bottom: 11px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.card-head h3 { margin: 0; }

.tag {
  font-size: 10.5px;
  padding: 2.5px 8px;
  border-radius: 99px;
  background: #232c35;
  color: var(--ink-2);
  border: 1px solid #2c3843;
}
.tag.done { background: rgba(22, 197, 138, .14); color: var(--brand); border-color: rgba(22, 197, 138, .35); }
.tag.warn { background: rgba(224, 163, 60, .13); color: var(--warn); border-color: rgba(224, 163, 60, .32); }
.tag.fail { background: rgba(224, 92, 92, .13); color: var(--bad); border-color: rgba(224, 92, 92, .32); }

.file-head { display: flex; gap: 11px; }
.thumb {
  flex: 0 0 auto;
  width: 62px; height: 48px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #10151a center/cover no-repeat;
  display: grid;
  place-items: center;
  color: #3d4a57;
  font-size: 16px;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.file-meta { min-width: 0; flex: 1 1 auto; }
.file-name {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: left;
}

.kv { margin: 0; display: flex; flex-direction: column; gap: 3px; }
.kv > div { display: flex; gap: 8px; align-items: baseline; }
.kv dt { flex: 0 0 58px; margin: 0; color: var(--ink-3); font-size: 11px; }
.kv dd {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kv.wide dt { flex: 0 0 64px; font-size: 11.5px; }
.kv.wide dd { font-size: 12px; color: var(--ink); font-weight: 550; text-align: right; flex: 1 1 auto; }
.kv.wide > div { justify-content: space-between; padding: 3.5px 0; }

.ratio-bar {
  margin-top: 10px;
  height: 5px;
  border-radius: 99px;
  background: #232c35;
  overflow: hidden;
}
.ratio-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--brand);
  transition: width .3s ease;
}

.meter-list { display: flex; flex-direction: column; gap: 9px; }
.meter { display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: var(--ink-2); }
.meter > span:first-child { flex: 0 0 56px; }
.meter-track {
  flex: 1 1 auto;
  height: 5px;
  border-radius: 99px;
  background: #232c35;
  overflow: hidden;
}
.meter-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  transition: width .3s ease;
}
.meter-val {
  flex: 0 0 34px;
  text-align: right;
  color: var(--brand);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.foot-note { margin: 11px 0 0; font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }

/* ── 底部缩略图 ────────────────────────── */
.strip {
  flex: 0 0 auto;
  margin: 0 12px 12px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 10px 13px 12px;
}
.strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.strip-head h3 { font-size: 12.5px; color: var(--ink); }
.strip-tools { display: flex; align-items: center; gap: 14px; }

.sort-wrap { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); }
.sort-wrap select {
  width: auto;
  padding: 4px 24px 4px 8px;
  font-size: 11.5px;
  border-radius: 6px;
  background: transparent;
  border-color: transparent;
}
.sort-wrap select:hover { background: var(--panel-2); border-color: var(--line); }

.thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 74px;
  padding-bottom: 3px;
  scrollbar-width: thin;
}
.strip-empty { margin: 0; padding: 26px 8px; color: var(--ink-3); font-size: 12px; }

.thumb-card {
  position: relative;
  flex: 0 0 auto;
  width: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151a center/cover no-repeat;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  color: #3d4a57;
  font-size: 15px;
  transition: border-color .14s, transform .1s;
}
.thumb-card:hover { border-color: #3a4a58; }
.thumb-card[aria-selected="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}
.thumb-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-card .tc-badge {
  position: absolute;
  right: 4px; bottom: 4px;
  background: rgba(6, 10, 13, .82);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 9.5px;
  color: #b9c6d2;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(3px);
}
.thumb-card .tc-badge.ok { color: var(--brand); }
.thumb-card .tc-badge.warn { color: var(--warn); }
.thumb-card .tc-badge.fail { color: var(--bad); }
.thumb-card .tc-state {
  position: absolute;
  left: 4px; top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  background: rgba(6, 10, 13, .82);
  color: var(--ink-2);
}
.thumb-card .tc-state.done { color: var(--brand); }
.thumb-card .tc-state.fail { color: var(--bad); }
.thumb-card .tc-state.busy { color: var(--warn); }

/* ── 状态栏 ────────────────────────────── */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-2);
  border-top: 1px solid var(--line-soft);
  flex: 0 0 auto;
}
.message {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.progress {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.progress-track {
  display: block;
  width: 110px; height: 5px;
  border-radius: 99px;
  background: #232c35;
  overflow: hidden;
}
.progress-track i {
  display: block;
  height: 100%; width: 0;
  background: var(--brand);
  border-radius: 99px;
  transition: width .2s ease;
}

/* ── 拖放层 ────────────────────────────── */
.drop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 12, 10, .72);
  backdrop-filter: blur(3px);
}
.drop[hidden] { display: none; }
.drop-inner {
  padding: 26px 42px;
  border-radius: 14px;
  border: 2px dashed var(--brand);
  background: rgba(16, 24, 22, .96);
  color: var(--brand);
  font-size: 15px;
  font-weight: 600;
}

/* ── 关于弹窗 ──────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 11, .68);
  backdrop-filter: blur(3px);
}
.modal-box {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .55);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px 13px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 { font-size: 15px; }
.modal-x {
  appearance: none;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.modal-x:hover { background: var(--panel-2); color: var(--ink); }
.modal-body { padding: 14px 16px 16px; }
.about-sub { margin: 0 0 13px; font-size: 12px; color: var(--brand); font-weight: 550; }
.about-kv { margin: 0 0 14px; display: flex; flex-direction: column; gap: 7px; }
.about-kv > div { display: flex; gap: 10px; align-items: baseline; }
.about-kv dt { flex: 0 0 46px; margin: 0; font-size: 11.5px; color: var(--ink-3); }
.about-kv dd { margin: 0; font-size: 12px; color: var(--ink-2); line-height: 1.55; }
.about-note {
  margin: 0 0 9px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--ink-2);
  padding: 9px 11px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.about-note.dim { margin-bottom: 0; color: var(--ink-3); background: none; border-color: transparent; padding: 0 2px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  padding: 0 16px 15px;
}
.modal-foot .btn { min-width: 84px; justify-content: center; }

/* ── 自适应 ────────────────────────────── */
@media (max-width: 1400px) {
  :root { --settings-w: 288px; --side-w: 268px; --rail-w: 74px; }
}

@media (max-width: 1180px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .body {
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
    grid-template-areas:
      "rail viewer"
      "rail settings"
      "rail side";
    overflow: visible;
    align-items: start;
  }
  .rail { grid-area: rail; position: sticky; top: 12px; max-height: calc(100dvh - 24px); }
  .viewer { grid-area: viewer; min-height: 340px; }
  .settings { grid-area: settings; overflow: visible; }
  .side { grid-area: side; flex-direction: row; overflow: visible; flex-wrap: wrap; }
  .side .card { flex: 1 1 240px; }
  .strip { overflow: visible; }
}

@media (max-width: 760px) {
  .body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "viewer" "settings" "side" "rail";
    padding: 10px;
    gap: 10px;
  }
  .rail {
    grid-area: rail;
    flex-direction: row;
    position: static;
    max-height: none;
    overflow-x: auto;
    padding: 6px;
  }
  .rail-spacer { display: none; }
  .rail-item { flex: 0 0 auto; padding: 7px 12px; flex-direction: row; gap: 6px; }
  .rail-item span { font-size: 11.5px; }
  .topbar { flex-wrap: wrap; padding: 10px 12px; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .topbar-actions .btn { flex: 1 1 auto; justify-content: center; }
  .viewer { min-height: 300px; }
  .side { flex-direction: column; }
  .strip { margin: 0 10px 10px; }
  .statusbar { flex-wrap: wrap; }
  .message { flex: 1 1 100%; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* 屏幕高度不足时收紧纵向间距，让设置项尽量一屏可见 */
@media (max-height: 940px) and (min-width: 1181px) {
  .settings { gap: 9px; padding-bottom: 10px; }
  .panel-head { padding: 10px 14px 9px; }
  .group { gap: 5px; }
  .segmented span, .grid-chips span { padding: 6.5px 6px; }
  .option-body { padding: 7px 10px; }
  .switches { gap: 6px; }
  .inline-input input { padding: 6px 0; }
  .path-box { padding: 6px 10px; }
  .hint { font-size: 10.5px; }
  .card { padding: 10px 12px 11px; }
  .card h3 { margin-bottom: 8px; }
  .card-head { margin-bottom: 8px; }
  .side { gap: 10px; }
  .strip { padding: 8px 13px 9px; }
  .strip-head { margin-bottom: 7px; }
  .thumbs { min-height: 66px; }
  .thumb-card { width: 86px; }
}

/* 输出区在长列表滚动时保持可见 */
.output-sticky {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  padding: 8px 0 2px;
  margin-top: -2px;
  box-shadow: 0 -8px 12px -8px var(--panel);
}

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #29343f; border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #36434f; background-clip: content-box; }


/* ── 水印面板 ──────────────────────────── */

/* 打包 DejaVu 原始字体文件，避免浏览器回退替换导致字形尺寸偏差 */
@font-face {
  font-family: 'WM DejaVu';
  src: url('fonts/DejaVuSans.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'WM DejaVu';
  src: url('fonts/DejaVuSans-Bold.ttf') format('truetype');
  font-weight: 700;
}
@font-face {
  font-family: 'WM DejaVu Condensed';
  src: url('fonts/DejaVuSansCondensed.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'WM DejaVu Condensed';
  src: url('fonts/DejaVuSansCondensed-Bold.ttf') format('truetype');
  font-weight: 700;
}

/* 思源宋体 / 思源黑体完整 TTF（官方分片合并而成，全字符集覆盖，无 unicode-range 懒加载） */
@font-face {
  font-family: 'WM Noto Serif SC';
  src: url('fonts/ttf/NotoSerifSC-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'WM Noto Serif SC';
  src: url('fonts/ttf/NotoSerifSC-SemiBold.ttf') format('truetype');
  font-weight: 600;
}
@font-face {
  font-family: 'WM Noto Serif SC';
  src: url('fonts/ttf/NotoSerifSC-Bold.ttf') format('truetype');
  font-weight: 700;
}
@font-face {
  font-family: 'WM Noto Sans SC';
  src: url('fonts/ttf/NotoSansSC-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'WM Noto Sans SC';
  src: url('fonts/ttf/NotoSansSC-Medium.ttf') format('truetype');
  font-weight: 600;
}
@font-face {
  font-family: 'WM Noto Sans SC';
  src: url('fonts/ttf/NotoSansSC-Bold.ttf') format('truetype');
  font-weight: 700;
}

.wm-panel {
  grid-column: 2 / -1;
  padding: 0;
  overflow: hidden;
}
.wm-layout {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  gap: 14px;
  height: 100%;
  min-height: 0;
  padding: 14px;
}

/* 左侧步骤卡片 */
.wm-steps-card {
  align-self: start;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 14px 10px;
}
.wm-steps-h {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  margin: 0 4px 12px;
}
.wm-steps-h svg { color: var(--brand); }
.wm-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wm-steps li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .13s;
}
.wm-steps li:hover { background: var(--panel-3); }
.wm-steps li.active { background: var(--brand-soft); }
/* 步骤连接线：从上一行底部延伸到本行圆圈顶 */
.wm-steps li:not(:first-child)::before {
  content: "";
  position: absolute;
  left: 21px;
  top: -8px;
  height: calc(50% - 3px);
  width: 1px;
  background: var(--line);
}
.wm-steps i {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #232c35;
  border: 1px solid #2c3843;
  color: var(--ink-3);
  font-style: normal;
  font-size: 11px;
  font-weight: 650;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
}
.wm-steps li.active i { background: var(--brand); border-color: var(--brand); color: #06201a; }
.wm-steps li > span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.wm-steps li.active > span { color: var(--brand); }
.wm-steps em { font-style: normal; font-size: 10.5px; font-weight: 400; color: var(--ink-3); }
.wm-steps .chev { margin-left: auto; flex: 0 0 auto; color: var(--ink-3); opacity: .75; }
.wm-steps li.active .chev { color: var(--brand); opacity: 1; }

.wm-main {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 2px;
}
.wm-section {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 13px 14px 14px;
}
.wm-section.flat { background: none; border: 0; padding: 0 2px; }
.wm-h {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 11px;
}
.wm-h svg { color: var(--brand); }
.wm-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.wm-sec-head .wm-h { margin: 0; }

/* 逐行/高级 选项卡 */
.wm-tabs {
  display: flex;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: var(--panel);
  flex: 0 0 auto;
}
.wm-tabs button {
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-3);
  font-size: 11.5px;
  padding: 4px 11px;
  cursor: pointer;
}
.wm-tabs button.active { background: var(--brand); color: #06201a; font-weight: 600; }

/* 模板卡片 */
.wm-tpls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.wm-tpl {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 150px;
  padding: 26px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .14s, background .14s;
}
.wm-tpl:hover { border-color: #3a4a58; }
.wm-tpl.active { border-color: var(--brand); background: var(--brand-soft); }
.wm-tpl-tag { position: absolute; top: 9px; left: 12px; font-size: 11px; color: var(--ink-3); }
.wm-tpl-check {
  position: absolute;
  top: 8px; right: 8px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #06201a;
  display: none;
  place-items: center;
}
.wm-tpl.active .wm-tpl-check { display: grid; }
.wm-tpl-lines { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
/* 中文模板卡片预览用打包思源宋体，与画布渲染一致 */
.wm-tpl[data-tpl="moxin"] .wm-tpl-lines,
.wm-tpl[data-tpl="manuochi"] .wm-tpl-lines { font-family: "WM Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", serif; }
.wm-tpl-lines .l1 { font-size: 17px; font-weight: 800; letter-spacing: .4px; }
.wm-tpl-lines .l2 { font-size: 11.5px; color: var(--ink-2); }
.wm-tpl-lines .l4 { font-size: 11px; color: var(--ink); }
.wm-tpl-lines .l3 { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--ink-3); }
.wm-tpl-lines .l3 svg { opacity: .75; flex: 0 0 auto; }


/* 两列：左编辑/样式，右预览 */
.wm-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.wm-leftcol, .wm-rightcol { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* 内容编辑字段 */
.wm-field { display: flex; align-items: center; gap: 10px; }
.wm-field + .wm-field { margin-top: 9px; }
.wm-field-label { flex: 0 0 124px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.wm-field-input {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0 10px;
  min-width: 0;
}
.wm-field-input:focus-within { border-color: var(--brand); }
.wm-field-input input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  padding: 8px 0;
}
.wm-field-input input:focus { outline: none; }
.wm-field-input .cnt {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 10.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* 逐行设置表 */
.wm-lt { display: flex; flex-direction: column; gap: 5px; }
.wm-lt-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 128px 74px 94px;
  gap: 8px;
  align-items: center;
}
.wm-lt-row.adv { grid-template-columns: 20px minmax(0, 1fr) auto auto auto; }
.wm-lt-row.head { font-size: 10.5px; color: var(--ink-3); padding: 0 2px 2px; }
.wm-lt-row .idx {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #232c35;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 10px;
  color: var(--ink-3);
}
.wm-lt-text {
  font-size: 11.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wm-lt-row select { padding: 5px 22px 5px 8px; font-size: 11px; border-radius: 6px; }
.wm-override { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-2); cursor: pointer; }
.wm-override input { accent-color: var(--brand); margin: 0; }
.wm-override-note { font-size: 10.5px; color: var(--ink-3); min-width: 52px; }

/* 底部样式组 */
.wm-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 26px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.wm-sub { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.wm-sub h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 2px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.wm-sub h3::before { content: ""; width: 3px; height: 11px; border-radius: 2px; background: var(--brand); }
.wm-brow { display: flex; align-items: center; gap: 8px; }
.wm-blab { font-size: 11.5px; color: var(--ink-3); min-width: 52px; }
.wm-sub .inline-input { width: 96px; }
.inline-input.sm { padding: 0 8px; }
.inline-input.sm input { padding: 5px 0; font-size: 11.5px; }
.wm-gaps { display: grid; grid-template-columns: repeat(2, auto); gap: 8px 16px; }
.wm-gap { display: flex; align-items: center; gap: 8px; }
.wm-gap > span { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 30px; }
.wm-outval {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* 颜色选择 */
.wm-color { position: relative; width: 34px; height: 30px; flex: 0 0 auto; }
.wm-color.sm { width: 30px; height: 26px; }
.wm-color input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.wm-color input:disabled { cursor: default; }
.wm-color i { display: block; width: 100%; height: 100%; border-radius: 7px; border: 1px solid var(--line); }
.wm-color:focus-within i { outline: 2px solid var(--brand); outline-offset: 1px; }
.wm-color-text { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* 对齐图标分段 */
.seg-icons { display: flex; gap: 6px; }
.seg-icons label { position: relative; }
.seg-icons input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-icons span {
  display: grid;
  place-items: center;
  width: 32px; height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink-2);
  transition: all .13s;
}
.seg-icons input:checked + span { background: var(--brand); border-color: var(--brand); color: #06201a; }

/* 预览与导出 */
.wm-prev-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.wm-prev-head .wm-h { margin: 0; }
.wm-size {
  font-size: 11px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wm-stage {
  min-height: 340px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(45deg, #171e25 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(-45deg, #171e25 25%, transparent 25%) 0 10px / 20px 20px,
    linear-gradient(45deg, transparent 75%, #171e25 75%) 10px -10px / 20px 20px,
    linear-gradient(-45deg, transparent 75%, #171e25 75%) -10px 0 / 20px 20px,
    #10151a;
}
.wm-stage canvas { max-width: 100%; max-height: 320px; }
.wm-empty { margin: 0; color: #4d5a67; font-size: 12.5px; text-align: center; }
.wm-actions { display: flex; gap: 12px; margin-top: 12px; }
.wm-actions .btn { flex: 1 1 auto; justify-content: center; padding: 10px 14px; }

@media (max-width: 1400px) {
  .wm-steps em { display: none; }
  .wm-layout { grid-template-columns: 128px minmax(0, 1fr); }
  .wm-lt-row { grid-template-columns: 20px minmax(0, 1fr) 112px 66px 86px; }
}
@media (max-width: 1180px) {
  .wm-panel { grid-area: viewer; }
}
@media (max-width: 900px) {
  .wm-cols { grid-template-columns: 1fr; }
  .wm-tpls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .wm-layout { grid-template-columns: 1fr; overflow-y: auto; }
  .wm-steps-card { align-self: auto; }
  .wm-steps { flex-direction: row; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
  .wm-steps li { flex: 0 0 auto; padding: 7px 10px; }
  .wm-steps li:not(:first-child)::before { display: none; }
  .wm-steps em { display: none; }
  .wm-main { overflow: visible; }
  .wm-tpls { grid-template-columns: 1fr; }
}

/* 逐行设置：字号自由数值输入 */
.wm-lt-size { display: inline-flex; align-items: center; gap: 4px; }
.wm-lt-size input {
  width: 56px;
  padding: 5px 4px 5px 8px;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.wm-lt-size input:focus { outline: none; border-color: var(--accent); }
.wm-lt-size i { font-style: normal; font-size: 10px; color: var(--ink-3); }
