:root {
  --bg: #f4f8fb;
  --panel: #ffffff;
  --panel-2: #eef4f8;
  --line: #cddde7;
  --text: #00171f;
  --muted: #557687;
  --accent: #007ea7;
  --accent-2: #00a7e1;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }

/* Hide every visible scrollbar while keeping scroll (wheel/touch) working.
   Covers the document and any inner scroll container. */
html { scrollbar-width: none; -ms-overflow-style: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }
::-webkit-scrollbar { width: 0; height: 0; display: none; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans", "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.top {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f4f8fb);
  position: sticky; top: 0; z-index: 20;
}
.top-inner {
  max-width: 1500px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) calc(28px + env(safe-area-inset-right)) 14px calc(28px + env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.top-nav { display: flex; gap: 8px; }
.tag {
  font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 12px; background: var(--panel-2); white-space: nowrap;
}
.page { max-width: 1500px; margin: 0 auto; width: 100%; }
.site-footer {
  width: 100%; border-top: 1px solid var(--line); margin-top: 4px;
  padding: 14px max(14px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  color: var(--muted); font-size: 11.5px;
}
.site-footer-inner {
  max-width: 1500px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.footer-credit { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.footer-credit strong { color: var(--text); font-size: 12px; }
.mask-quality-controls { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--panel) 72%, var(--accent) 8%); }
.mask-quality-controls strong { display: block; font-size: 13px; }
.mask-quality-controls p { margin: 2px 0 8px; font-size: 12px; color: var(--muted); }
.mask-quality-controls .check { margin-top: 6px; font-size: 12px; }
.site-footer p { margin: 0; }
.footer-links { display: flex; gap: 12px; }
.footer-links a { color: var(--accent-2); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
@media (max-width: 760px) { .top-nav { display: none; } }
@media (max-width: 760px) {
  .site-footer-inner { align-items: flex-start; flex-direction: column; gap: 7px; }
}
.workflow {
  display: flex; align-items: center; gap: 14px; padding: 11px 14px 0;
  color: var(--muted); overflow-x: auto; scrollbar-width: none;
}
.workflow::-webkit-scrollbar { display: none; }
.workflow-title { flex: 0 0 auto; font-size: 11.5px; font-weight: 600; color: var(--text); }
.workflow ol { display: flex; flex: 1; gap: 8px; padding: 0; margin: 0; list-style: none; min-width: max-content; }
.workflow li {
  display: flex; align-items: center; gap: 6px; font-size: 11.5px; white-space: nowrap;
  color: var(--muted); transition: color .2s;
}
.workflow li span {
  width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%;
  font-size: 10px; border: 1px solid var(--line); background: var(--panel-2);
}
.workflow li.done { color: #a6ddf3; }
.workflow li.done span { border-color: #007ea7; background: #dbeff8; font-size: 0; }
.workflow li.done span::after { content: '✓'; font-size: 11px; }
.workflow li.current { color: var(--text); }
.workflow li.current span { border-color: var(--accent-2); color: #fff; background: #007ea7; }
.workflow em { font-style: normal; font-size: 9.5px; color: var(--muted); }

.logo {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}
.top h1 { margin: 0; font-size: 18px; letter-spacing: .5px; }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  gap: 14px;
  padding: 14px calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  min-height: 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

/* 输入区 */
.drop {
  position: relative;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  min-height: 120px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s;
  background: var(--panel-2);
}
.drop:hover, .drop.dragover { border-color: var(--accent-2); background: #e7f0f6; }
.drop-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; pointer-events: none; text-align: center; padding: 8px;
}
.drop-inner strong { font-size: 13.5px; }
.hint { color: var(--muted); font-size: 11.5px; }
.thumb { width: 100%; height: 160px; object-fit: cover; display: block; }
.drop:has(.thumb:not([hidden])) .drop-inner {
  background: linear-gradient(0deg, rgba(0,0,0,.6), transparent 55%);
  justify-content: flex-end; align-items: flex-start; padding: 10px;
}
/* 载图后标签压在深色渐变上，强制白字（白底主题默认是深字，会看不清） */
.drop:has(.thumb:not([hidden])) .drop-inner strong,
.drop:has(.thumb:not([hidden])) .hint { color: #fff; }

/* ---------- 阶段化界面（progressive disclosure） ----------
   setup：两张图还没凑齐 —— 素材区是主角，右侧调色控件先淡出，别抢注意力。
   edit ：两张图都到位 —— 上传框收成小缩略图（大概率不再点），把最常调的
          「强度 / 迁移模式」上浮强调，用户一眼看到该玩哪儿。 */
.layout { transition: none; }
/* setup：右侧调色栏还用不上，淡出且不可点，视线自然落到素材区 */
[data-phase="setup"] .controls { opacity: .5; }
[data-phase="setup"] .controls .sec:first-child { pointer-events: none; }
/* edit：两个上传框收窄成一行小图，仍可点击更换 */
[data-phase="edit"] .inputs .drop { min-height: 0; }
[data-phase="edit"] .inputs .thumb { height: 84px; }
[data-phase="edit"] .inputs .drop:not(:has(.thumb:not([hidden]))) { min-height: 84px; }
/* edit：动画主色是参考信息，收起省空间（悬停素材区可临时看） */
[data-phase="edit"] .inputs .palette-box { display: none; }
/* edit：强调最常用的调色控件——强度那一组加浅蓝卡片和更粗的滑轨 */
[data-phase="edit"] .controls .sec:first-child > .sec-title + .ctrl-group {
  background: #e6f5fc;
  border: 1px solid #9fd7ee;
  border-radius: 10px; padding: 10px 12px; margin: 0 -2px 4px;
}
[data-phase="edit"] .controls .sec:first-child > .sec-title + .ctrl-group input[type=range] { height: 30px; }
[data-phase="edit"] .controls .sec:first-child > .sec-title + .ctrl-group label { color: var(--text); font-weight: 600; }

.palette-box label, .ctrl-group label {
  font-size: 12px; color: var(--muted); display: block; margin-bottom: 8px;
}
.palette { display: flex; gap: 6px; flex-wrap: wrap; min-height: 34px; }
.swatch {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
  position: relative;
}
.swatch::after {
  content: attr(data-hex);
  position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%);
  font-size: 8.5px; color: var(--muted); white-space: nowrap; opacity: 0;
  transition: opacity .15s;
}
.swatch:hover::after { opacity: 1; }

.extract-box { display: flex; flex-direction: column; gap: 8px; }

/* 抠图按钮 + ⓘ 说明气泡 */
.extract-row { display: flex; align-items: center; gap: 8px; position: relative; }
.extract-row > .ghost { flex: 1; }
.button-load-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.button-load-row .shoot-btn { flex: 1; margin: 0; }
.match-entry { display: flex; flex-direction: column; }
.match-help { margin: 3px 2px 0; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.button-load {
  flex: 0 1 132px; color: var(--accent-2); font-size: 10.5px; line-height: 1.25;
  overflow-wrap: anywhere;
}
.button-load::before { content: '◌ '; }
.info-tip {
  flex: 0 0 auto;
  width: 22px; height: 22px; min-height: 22px; padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  background: none; color: var(--muted);
  font-size: 12px; font-style: normal; font-family: inherit; font-weight: 700;
  line-height: 1; cursor: help;
}
.info-tip:hover, .info-tip.open { border-color: var(--accent-2); color: var(--accent-2); }
.info-tip::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  right: 0; bottom: calc(100% + 6px);
  z-index: 30;
  width: min(240px, 72vw);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4f8;
  color: var(--text);
  font-size: 12px; font-style: normal; font-family: inherit;
  line-height: 1.55; text-align: left; white-space: normal;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.info-tip:hover::after, .info-tip.open::after { display: block; }
button.ghost {
  border: 1px solid var(--accent-2);
  background: rgba(0, 167, 225, .08);
  color: var(--accent-2);
}
button.ghost.ai {
  border-color: var(--accent);
  background: rgba(0, 126, 167, .08);
  color: var(--accent);
}
.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text); cursor: pointer; margin: 0; }
.check.compact { margin-top: -7px; font-size: 11.5px; color: var(--muted); }
.check input { accent-color: var(--accent); width: auto; }
.extract-status { font-size: 11px; color: var(--muted); }
.char-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.char-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--text); cursor: pointer;
  border: 1px solid var(--line); border-radius: 20px;
  padding: 4px 10px 4px 7px; background: var(--panel-2);
  transition: border-color .15s;
}
.char-chip:hover { border-color: var(--accent); }
.char-chip input { accent-color: var(--accent); width: auto; margin: 0; }
.char-chip.empty { opacity: .45; cursor: default; }
.mini { font-size: 11.5px; color: var(--muted); margin: 2px 0 0; }
.mini #harmonizeVal { color: var(--accent-2); float: right; }
.extract-box input[type=range] { width: 100%; accent-color: var(--accent); }
.compare.grabbing { cursor: grabbing; }

/* 预览区 */
.preview { padding: 0; overflow: hidden; }
.compare {
  position: relative; flex: 1; width: 100%;
  display: grid; place-items: center;
  background:
    repeating-conic-gradient(#e7f0f6 0% 25%, #eef4f8 0% 50%) 50% / 22px 22px;
  overflow: hidden;
  /* pan-y：页面竖向滚动仍交给浏览器，横向拖拽与双指捏合交给我们 */
  touch-action: pan-y;
}

/* 预览正下方的大号角色缩放条 */
.char-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; /* 窄屏时按钮换行，不挤出屏外 */
  padding: 10px 14px;
  background: var(--panel-2);
  border-top: 1px solid var(--line);
}
.char-bar-label { font-size: 13px; white-space: nowrap; }
.char-bar input[type="range"] { flex: 1 1 140px; height: 28px; }
.char-bar-val { font-size: 13px; color: var(--accent-2); min-width: 44px; text-align: right; }
.char-bar button { white-space: nowrap; }
.char-bar .lock-on { border-color: var(--accent); color: var(--accent); }
.compare-stack { position: absolute; inset: 0; display: grid; place-items: center; }
.stack-panel { position: absolute; inset: 0; display: grid; place-items: center; }
.stack-label { display: none; }
#canvasAnimeOverlay { pointer-events: none; }
.compare canvas { position: absolute; max-width: 100%; max-height: 100%; }
.compare-clip {
  position: absolute; inset: 0; overflow: hidden;
  display: grid; place-items: center;
  clip-path: inset(0 50% 0 0);
}
.compare-stack-mode .compare-stack {
  position: relative; inset: auto; width: 100%; height: 100%; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; overflow: hidden;
}
.compare-stack-mode .stack-panel {
  position: relative; inset: auto; flex: 0 0 auto; min-height: 0;
  display: grid; place-items: center; background: transparent; border: 0; border-radius: 0;
}
.compare-stack-mode #stackAnimePanel { order: -1; }
.compare-stack-mode .stack-panel canvas {
  position: static;
  max-width: 100%; max-height: 100%;
}
.compare-stack-mode .stack-label {
  display: block; position: absolute; top: 7px; left: 8px; z-index: 1;
  padding: 2px 7px; border-radius: 12px; background: rgba(0, 0, 0, .58); color: #fff; font-size: 10px;
}
.compare-modes {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel-2);
  color: var(--muted); font-size: 11.5px;
}
.compare-mode { min-height: 28px; padding: 4px 9px; border-radius: 14px; font-size: 11.5px; }
.compare-mode.on { border-color: var(--accent-2); color: #fff; background: rgba(0, 167, 225, .2); }
.overlay-opacity { display: flex; align-items: center; gap: 5px; margin-left: auto; white-space: nowrap; }
.overlay-opacity span { color: var(--accent-2); }
.overlay-opacity input { width: 92px; }
@media (max-width: 600px) {
  .overlay-opacity { width: 100%; margin-left: 0; }
  .overlay-opacity input { flex: 1; width: auto; }
}
.handle {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; background: #fff; transform: translateX(-1px);
  cursor: ew-resize; z-index: 5;
}
.handle span {
  position: absolute; top: 50%; left: 50%;
  width: 30px; height: 30px; transform: translate(-50%, -50%);
  background: #fff; border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.handle span::before, .handle span::after {
  content: '‹'; position: absolute; top: 50%; transform: translateY(-50%);
  color: #111; font-size: 16px; font-weight: 700;
}
.handle span::before { left: 6px; }
.handle span::after { content: '›'; right: 6px; }
.badge {
  position: absolute; top: 10px; z-index: 6;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11px;
  padding: 3px 9px; border-radius: 20px; backdrop-filter: blur(4px);
}
.badge.left { left: 10px; }
.badge.right { right: 10px; }
.empty {
  position: absolute; z-index: 7; color: var(--muted); font-size: 13px;
  pointer-events: none;
}

/* 控制区 */
.ctrl-group select, .ctrl-group input[type=range] { width: 100%; }
.ctrl-group select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 13px;
}
.preset-row { display: flex; gap: 6px; margin-top: 6px; }
.preset-row select, .preset-row input { min-width: 0; flex: 1; }
.preset-row input {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 8px; font-size: 12px;
}
.compare-meta { display: grid; grid-template-columns: 1fr; gap: 6px; }
.compare-meta input {
  width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 8px; font-size: 12px;
}
.model-cache {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px;
  display: flex; flex-direction: column; gap: 7px; font-size: 11px; color: var(--muted);
}
.model-cache button { width: 100%; }
.download-probe {
  padding: 8px 9px; border-radius: 7px;
  background: rgba(0, 0, 0, .18); border: 1px solid var(--line);
  color: var(--muted); font-size: 11px; line-height: 1.55; white-space: pre-line;
}
.download-probe.ok { border-color: rgba(0, 167, 225, .65); color: #cdeaf7; }
.download-probe.problem { border-color: rgba(0, 126, 167, .7); color: #bce2ef; }
#btnClearModelCache { color: var(--muted); }
.thumb { image-orientation: from-image; }
input[type=range] { accent-color: var(--accent); }
#strengthVal { color: var(--accent-2); float: right; }
#satBoostVal, #bloomVal { color: var(--accent-2); float: right; }

.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
button {
  padding: 10px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 13px; cursor: pointer;
  transition: filter .15s, opacity .15s;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
button:hover:not(:disabled) { filter: brightness(1.25); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #fff; font-weight: 600;
}
.status {
  margin-top: auto; font-size: 11.5px; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 10px;
}
.export-note { font-size: 10.5px; line-height: 1.45; color: var(--muted); margin-top: -5px; }

/* ---------- 导出选择面板 ---------- */
.export-hub { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 5vh 6vw; background: rgba(6, 8, 4, .78); }
.export-hub[hidden] { display: none; }
.export-hub-dialog { width: min(1120px, 88vw); height: min(80vh, 820px); overflow: auto; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 22px 80px rgba(0,0,0,.5); }
.export-hub-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.export-hub-head h2 { margin: 0; font-size: 20px; }
.export-hub-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.export-hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 14px; }
.export-card { min-height: 0; padding: 0 0 12px; overflow: hidden; text-align: left; background: var(--panel-2); border-color: var(--line); }
.export-card canvas, .export-card-text i { display: block; width: 100%; height: 150px; margin: 0 0 10px; background: #f4f8fb; object-fit: contain; }
.export-card b, .export-card span { display: block; padding: 0 12px; }
.export-card b { color: var(--text); font-size: 14px; }
.export-card span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.export-card-text i { display: grid; place-items: center; margin: 0 0 10px; color: var(--accent-2); font-style: normal; font-size: 34px; font-weight: 700; }
@media (max-width: 600px) {
  .export-hub { padding: 3vh 3vw; }
  .export-hub-dialog { width: 94vw; height: 82vh; padding: 14px; }
  .export-hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .export-card canvas, .export-card-text i { height: 105px; }
  .export-card { min-height: 0; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .compare { min-height: 320px; }
}

@media (max-width: 900px), (pointer: coarse) {
  button, select, .preset-row input { min-height: 44px; }
  /* 通用 44px 按钮规则不能把圆形说明按钮拉成竖椭圆。 */
  .extract-row .info-tip {
    width: 32px; height: 32px; min-height: 32px; padding: 0;
    font-size: 14px; line-height: 32px;
  }
  .info-tip::after { width: min(260px, calc(100vw - 56px)); }
  input[type=range] { min-height: 34px; }
  .handle span { width: 40px; height: 40px; }
}

/* ---------- 构图对齐（洋葱皮） ---------- */
.align-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 8px;
  background: var(--panel, #ffffff); border: 1px solid var(--line, #e0eaf1); border-radius: 10px;
}
.align-bar .align-tip { font-size: 12px; color: var(--muted, #557687); }
.align-bar input[type="range"] { width: 120px; }
.align-bar .mini.inline { margin: 0; white-space: nowrap; }
button.small { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.preview-actions { margin-top: 8px; display: flex; gap: 8px; }
#alignGhost {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  opacity: .5; pointer-events: none; z-index: 6;
}
.compare.align-on { cursor: grab; }
.compare.align-on .compare-clip,
.compare.align-on .handle,
.compare.align-on .badge { display: none; }

/* ---------- 圈选抠图 ---------- */
.lasso-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(255, 255, 255, .94);
  display: flex; flex-direction: column;
}
.lasso-modal[hidden] { display: none; }
.lasso-head {
  display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 16px; color: var(--muted, #557687); font-size: 13px;
}
.lasso-guide { display: flex; width: 100%; gap: 12px; flex-wrap: wrap; color: #557687; font-size: 12px; }
.lasso-guide b { color: var(--text); }
.lasso-guide .active { color: #cdeaf7; }
.lasso-actions { display: flex; gap: 8px; }
.lasso-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0 12px 12px; }
#lassoCanvas { max-width: 100%; max-height: 100%; touch-action: none; cursor: crosshair; border-radius: 8px; }
.lasso-shapes { display: flex; gap: 6px; }
.lasso-shapes button { white-space: nowrap; }
.lasso-shapes .shape-on { border-color: var(--accent); color: var(--accent); }
.lasso-keep { display: flex; align-items: center; gap: 6px; }
.lasso-keep #btnLassoKeep.keep-on { border-color: #33b8e7; color: #cdeaf7; background: rgba(0, 167, 225, .18); }
#lassoKeepSize { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
#lassoKeepBrush { width: 92px; accent-color: #33b8e7; }
@media (max-width: 600px) { .lasso-guide { gap: 5px; } }

/* 相机探针入口（临时诊断用） */
.probe-entry {
  display: block; text-align: center; margin: 0 0 10px;
  padding: 11px 14px; border-radius: 10px;
  background: #cddde7; border: 1px solid #007ea7; color: #66caee;
  font-size: 14px; text-decoration: none;
}
.probe-entry:active { background: #e7f0f6; }

/* 现场取景按钮 */
.shoot-btn { width: 100%; margin: 8px 0 0; border-color: #007ea7; color: #66caee; }
.shoot-btn:not(:disabled):active { background: #cddde7; }

.match-results { margin-top: 10px; }
.match-results > label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 8px; }
.match-grid {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(112px, 145px); gap: 6px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  padding: 1px 1px 7px; scrollbar-color: var(--line) transparent;
}
.match-item {
  position: relative;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .15s;
  scroll-snap-align: start;
}
.match-item:hover { border-color: var(--accent-2); }
.match-item.selected { border-color: var(--accent); }
.match-item canvas { width: 100%; height: 72px; object-fit: cover; display: block; }
.match-item span {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 2px 4px;
  font-size: 10px; color: #fff; text-align: center;
  background: rgba(0, 0, 0, .55);
}

/* ==================== UI/UX 重构：分区 + 折叠 + 并列输入 ==================== */

/* 分区标题 */
.sec { display: flex; flex-direction: column; gap: 12px; }
.sec-title {
  font-size: 12px; font-weight: 600; letter-spacing: .05em; color: var(--text);
  display: flex; align-items: center; gap: 8px; margin: 0;
}
.sec-title::before {
  content: ''; width: 3px; height: 13px; border-radius: 2px;
  background: linear-gradient(var(--accent), var(--accent-2));
}

/* 两张输入图并列 */
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input-row .drop { min-height: 104px; }
.input-row .thumb { height: 104px; }
.input-row .drop-inner strong { font-size: 12.5px; }

/* 折叠区（原生 details） */
details.adv, details.sec-d {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); overflow: hidden;
}
details.adv > summary, details.sec-d > summary {
  list-style: none; cursor: pointer; padding: 11px 12px;
  font-size: 12.5px; display: flex; align-items: center; gap: 8px;
  -webkit-user-select: none; user-select: none; min-height: 42px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: '›'; margin-left: auto; font-size: 17px; line-height: 1;
  color: var(--muted); transition: transform .2s;
}
details[open] > summary::after { transform: rotate(90deg); }
details.adv > summary { color: var(--muted); }
details.sec-d > summary { color: var(--text); font-weight: 600; }
details[open].adv > summary, details[open].sec-d > summary { border-bottom: 1px solid var(--line); }
.d-body { padding: 12px; display: flex; flex-direction: column; gap: 11px; }
/* 嵌套的角色微调折叠，去掉外层内边距叠加 */
.extract-box details.adv { margin-top: 2px; }

/* 角色合成整块折叠时，内层 extract-box 不再重复外框 */
details.sec-d .extract-box { gap: 8px; }

/* 核心玩法：即使尚未上传素材，也要让用户一眼看到角色合成入口 */
details.character-section {
  border-color: rgba(0, 126, 167, .62);
  background:
    linear-gradient(135deg, rgba(0, 126, 167, .14), rgba(0, 167, 225, .12)),
    var(--panel-2);
  box-shadow: 0 0 0 1px rgba(0, 167, 225, .12), 0 8px 22px rgba(0, 0, 0, .18);
}
details.character-section > summary {
  min-height: 58px;
  padding: 10px 12px;
}
.character-reset { margin-left: auto; padding: 6px 8px; font-size: 11px; }
details.character-section > summary::after { margin-left: 8px; }
.character-summary-copy { display: flex; flex-direction: column; gap: 3px; }
.character-summary-title { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.character-summary-subtitle { color: #557687; font-size: 11px; font-weight: 400; }
details.character-section[open] > summary { background: rgba(0, 23, 31, .18); }

/* 空预览态的流程指引 */
.empty-flow {
  display: flex; flex-direction: column; gap: 7px; text-align: left;
  max-width: 300px; padding: 20px 22px;
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(2px);
}
.empty-flow b { font-size: 13.5px; color: var(--text); margin-bottom: 3px; }
.empty-flow span { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* 移动端：折叠标题更好点，输入图不至于太小 */
@media (max-width: 900px) {
  .workflow { padding-top: 9px; }
  .input-row .drop { min-height: 128px; }
  .input-row .thumb { height: 128px; }
  .button-load-row { align-items: flex-start; }
  .button-load { flex-basis: 108px; }
}

/* ==================== 户外强光模式 ==================== */
.top-actions { display: flex; align-items: center; gap: 10px; }
.sun-toggle {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 20px; padding: 7px 14px; font-size: 12.5px; white-space: nowrap;
}
.sun-toggle[aria-pressed="true"] {
  background: #003459; border-color: #003459; color: #e6eef4; font-weight: 700;
}

/* 强光模式：整体拉高界面亮度与对比、加粗描边、放大控件。
   刻意不碰 .compare 里的调色预览画布——预览必须显示真实调色结果，
   一旦为了"看清"而提亮，用户在阳光下判断的就不是真实色彩了。 */
/* 白底主题下的强光模式 = 更高对比：纯白底、近黑字、更深的蓝与更重的描边 */
:root.sunlight {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #e6eef4;
  --line: #003459;
  --text: #00171f;
  --muted: #003459;
  --accent: #006287;
  --accent-2: #007ea7;
}
.sunlight body { font-weight: 500; }
.sunlight .top { background: linear-gradient(180deg, #ffffff, #eef4f8); }
.sunlight .sec-title, .sunlight h1, .sunlight .char-chip { color: #00171f; }
.sunlight .badge { color: #fff; }
.sunlight button { border-width: 1.5px; font-weight: 600; }
.sunlight details.adv > summary, .sunlight details.sec-d > summary { color: #00171f; }
.sunlight .drop { border-width: 2px; }
.sunlight input[type=range] { filter: contrast(1.15); }
.sunlight .workflow li { color: #00171f; }
/* 对比条把手在强光下更醒目 */
.sunlight .handle { width: 3px; }
.sunlight .badge { background: rgba(0,0,0,.78); }
@media (pointer: coarse) {
  .sunlight button, .sunlight select { min-height: 50px; }
  .sunlight input[type=range] { min-height: 40px; }
}
