/* ============================================================
   PanoCraft 全景工坊 — 界面样式
   深色 · 克制的单一强调色 · 发丝级描边
   ============================================================ */

:root {
  --bg:        #0a0d12;
  --bg-soft:   #0e1218;
  --panel:     #11161e;
  --panel-2:   #141a23;
  --line:      #1e2632;
  --line-2:    #2a3441;
  --txt:       #e8edf4;
  --txt-2:     #aab4c2;
  --dim:       #75808f;
  --accent:    #5fa8ff;
  --accent-d:  #3d84e0;
  --ok:        #4ecb8f;
  --warn:      #e5b567;
  --err:       #ef6b6b;
  --r-sm: 7px;
  --r:    10px;
  --r-lg: 14px;
  --sh: 0 8px 30px rgba(0, 0, 0, .45);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  /* 应用是「满屏不滚动」布局：html 也要锁住，否则隐藏控件获得焦点时
     浏览器会把整个文档滚走（表现为点击开关后界面整体上移错位） */
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--txt);
  font: 400 13.5px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

::selection { background: rgba(95, 168, 255, .28); }

/* 细滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #3a4656; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------- 顶栏 */
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0f141c, #0c1016);
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 26px; height: 26px; color: var(--accent); flex: none; }
.brand-txt { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.brand-txt b { font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.brand-txt span { font-size: 12.5px; color: var(--dim); letter-spacing: 1.2px; }

.topbar-mid {
  flex: 1;
  min-width: 0;
  color: var(--dim);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  white-space: nowrap;
}
.topbar-mid b { color: var(--txt-2); font-weight: 550; }
.topbar-mid .sep { width: 1px; height: 12px; background: var(--line-2); flex: none; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.only-narrow { display: none; }

/* ---------------------------------------------------------- 按钮 */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--txt);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  /* 只过渡背景与文字色。悬停时改 border-color 会让每一个相邻控件的描边
     轮流亮起——鼠标快速划过一列按钮/卡片时，观感就是「一闪一闪」。
     过渡时长压到 100ms：再长就等于把一个「跨越边界」的事件放大成十帧重绘。 */
  transition: background .1s, color .1s, transform .06s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover:not(:disabled) { background: #18202b; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid rgba(95, 168, 255, .55); outline-offset: 1px; }

.btn.primary {
  background: linear-gradient(180deg, #67adff, #3d84e0);
  border-color: #2f6fbd;
  color: #04101f;
  font-weight: 620;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 4px 14px rgba(61, 132, 224, .28);
}
.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #7cbaff, #4a8fe8);
}
.btn.ghost { background: transparent; border-color: transparent; color: var(--txt-2); }
.btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .05); color: var(--txt); }
.btn.mini { height: 28px; padding: 0 9px; font-size: 12px; gap: 5px; }
.btn.block { width: 100%; }
.btn.on { border-color: var(--accent-d); color: var(--txt); background: rgba(95, 168, 255, .12); }

.ic { width: 16px; height: 16px; flex: none; }
.btn.mini .ic { width: 14px; height: 14px; }

.spinner {
  width: 13px; height: 13px;
  border: 1.6px solid rgba(4, 16, 31, .35);
  border-top-color: #04101f;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link {
  background: none; border: 0; padding: 0;
  color: var(--accent); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.link:hover { color: #86c0ff; }

/* ---------------------------------------------------------- 布局 */
.workspace {
  height: calc(100% - 58px);
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 322px;
}

.panel {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
.panel-left { border-right: 1px solid var(--line); contain: paint; }
.panel-right {
  border-left: 1px solid var(--line);
  /* 把重绘与光栅范围锁在本栏：栏内悬停过渡只脏自己这一块，
     脏区不会扩散到整页、逼着主图层整层重放。
     全站已无 backdrop-filter（见 .stage-toolbar 注释），所以不需要 isolation。 */
  contain: paint;
}

.panel-head {
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--dim);
  display: flex; align-items: center; gap: 7px;
}
.panel-head h2 em {
  font-style: normal;
  color: var(--txt-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 7px;
  font-size: 11px;
  letter-spacing: 0;
  line-height: 16px;
}
.panel-head-actions { display: flex; gap: 2px; }
.panel-head-actions .btn { min-width: 42px; text-align: center; }

/* ---------------------------------------------------------- 拖放区 */
.dropzone {
  margin: 12px;
  padding: 20px 14px;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r);
  text-align: center;
  color: var(--dim);
  transition: background .12s, color .12s;
  cursor: pointer;
}
.dropzone:hover { background: rgba(95, 168, 255, .028); }
.dropzone.drag {
  border-color: var(--accent);
  background: rgba(95, 168, 255, .08);
  color: var(--txt);
}
.dz-ic { width: 40px; height: 40px; color: var(--accent); opacity: .75; margin-bottom: 4px; }
.dz-t { margin: 6px 0 3px; font-size: 13px; color: var(--txt-2); }
.dz-s { margin: 0; font-size: 11.5px; color: var(--dim); line-height: 1.5; }

/* ---------------------------------------------------------- 缩略图列表 */
.thumblist {
  list-style: none;
  margin: 0;
  padding: 0 10px 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.thumb {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: grab;
  position: relative;
  transition: background .12s;
}
.thumb:hover { background: var(--panel-2); }
.thumb.dragging { opacity: .45; }
.thumb.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.thumb.drop-after  { box-shadow: 0 2px 0 var(--accent); }
.thumb img {
  width: 58px; height: 42px;
  object-fit: cover;
  border-radius: 4px;
  background: #000;
  flex: none;
  border: 1px solid var(--line);
}
.thumb .tinfo { min-width: 0; flex: 1; }
.thumb .tname {
  font-size: 12px;
  color: var(--txt-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb .tsub { font-size: 11px; color: var(--dim); font-family: var(--mono); }
.thumb .tnum {
  position: absolute; left: 4px; top: 4px;
  font-size: 10px; font-family: var(--mono);
  background: rgba(0, 0, 0, .66);
  border-radius: 4px;
  padding: 0 4px;
  color: #cfe0f5;
  line-height: 14px;
}
.thumb .tdel {
  opacity: 0;
  transition: opacity .14s;
  color: var(--dim);
  background: none; border: 0; cursor: pointer;
  padding: 4px; border-radius: 5px;
  display: flex;
}
.thumb:hover .tdel { opacity: 1; }
.thumb .tdel:hover { color: var(--err); background: rgba(239, 107, 107, .1); }
.thumb .tdel svg { width: 14px; height: 14px; }

.panel-foot {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  font-size: 11.5px;
  color: var(--dim);
  font-family: var(--mono);
  line-height: 1.7;
}
.panel-foot b { color: var(--txt-2); font-weight: 500; }

/* ---------------------------------------------------------- 舞台 */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(95, 168, 255, .07), transparent 70%),
    var(--bg);
}

.stage-canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  /* 这里曾经为了圈住工具条的 backdrop root 而写了 isolation: isolate。
     工具条的 backdrop-filter 已去掉（模糊每帧重采样 = 左侧闪屏根源），
     isolation 也就没有存在意义，去掉可以少一层离屏表面。 */
}
.stage-canvas-wrap.can-pan { cursor: grab; }
.stage-canvas-wrap.panning { cursor: grabbing; }
#preview {
  display: block;
  image-rendering: auto;
  max-width: 100%;
  max-height: 100%;
  opacity: 0;
  transition: opacity .3s;
}
#preview.ready { opacity: 1; }

.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--dim);
  pointer-events: none;
  text-align: center;
}
.se-ic { width: 132px; height: 70px; color: var(--accent); opacity: .55; margin-bottom: 8px; }
.stage-empty p { margin: 2px 0; font-size: 14px; color: var(--txt-2); }
.stage-empty .se-sub { font-size: 12px; color: var(--dim); }

.stage-toolbar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 11px;
  /* 这里曾经是 rgba(14,19,26,.84) + backdrop-filter: blur(14px)。
     模糊层每一帧「提交新帧」都要重新采样背后那张画布并重跑一次模糊 pass，
     而右栏的悬停过渡恰好每帧都在提交 —— 表现就是鼠标划过右栏时左侧浮层/画布闪。
     改成近乎不透明的实色：观感几乎一致（本来就是深底压在照片上），零模糊开销。 */
  background: linear-gradient(180deg, rgba(17, 23, 31, .96), rgba(11, 15, 21, .96));
  border: 1px solid var(--line-2);
  box-shadow: var(--sh);
  z-index: 5;
}
.zoomlab {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--txt-2);
  padding: 0 8px 0 4px;
  min-width: 46px;
  text-align: right;
  cursor: pointer;
  user-select: none;
}
.zoomlab:hover { color: var(--txt); }

.stage-badge {
  position: absolute;
  left: 14px;
  top: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--txt-2);
  /* 同上：不叠 backdrop-filter，避免每帧重算模糊 */
  background: rgba(12, 16, 22, .93);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 3px 8px;
  pointer-events: none;
}

/* 分段控件 */
.seg {
  display: inline-flex;
  background: #0c1016;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: background .14s, color .14s;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--txt-2); }
.seg-btn.active { background: var(--panel-2); color: var(--txt); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }
.seg-wide { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; max-width: 440px; }
.seg-wide .seg-btn { text-align: center; padding: 5px 2px; font-size: 11.5px; }

/* ---------------------------------------------------------- 状态栏 */
.statusbar {
  flex: none;
  height: 40px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 16px;
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--dim);
}
.statusmsg { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.statusmsg.ok { color: var(--ok); }
.statusmsg.err { color: var(--err); }

.progress { display: flex; align-items: center; gap: 9px; min-width: 210px; }
.progress-bar {
  width: 160px; height: 4px;
  background: #1a212b;
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-d), var(--accent));
  border-radius: 3px;
  transition: width .2s ease;
}
.progress-pct { font-family: var(--mono); font-size: 11.5px; color: var(--txt-2); min-width: 34px; }

/* ---------------------------------------------------------- 设置面板 */
.settings {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 0 0 26px;
  scroll-behavior: smooth;
  /* 滚到两端时把滚动留在面板内，别把滚动链传给外层（外层是满屏锁定） */
  overscroll-behavior: contain;
}

/* 分组快捷导航：吸顶一行 chips，点击跳到对应分组 */
/* 注意：这里不要用 backdrop-filter —— sticky 元素滚动时每帧都要重算模糊，
   面板背景本就不透明（.94），模糊几乎看不出来，纯属白烧 GPU。 */
.grp-nav {
  position: sticky;
  top: 0;
  z-index: 8;
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.grp-nav button {
  width: 100%;
  font: inherit;
  font-size: 10.5px;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 2px;
  cursor: pointer;
  /* 8 个 chip 紧挨着排成 4×2，鼠标横扫时若改 border-color，
     相邻 chip 的描边会轮流亮起，整块导航像在「闪」。只改底色。 */
  transition: color .1s, background .1s;
}
.grp-nav button:hover { color: var(--txt-2); background: #18202b; }
.grp-nav button.active {
  color: #cfe4ff;
  border-color: var(--accent-d);
  background: rgba(95, 168, 255, .14);
}

/* 分组：标题即折叠开关 */
.set-group {
  padding: 0;
  border-bottom: 1px solid var(--line);
}
.set-group:last-child { border-bottom: 0; }
.set-group > h3 {
  margin: 0;
  padding: 12px 15px 11px 16px;
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}
.set-group > h3:hover { color: var(--txt-2); }
/* 右侧折叠箭头 */
.set-group > h3::after {
  content: "";
  margin-left: auto;
  flex: none;
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  opacity: .55;
  transition: transform .2s ease;
}
.set-group.collapsed > h3::after { transform: rotate(-45deg) translate(-1px, 1px); }
.set-group.collapsed > .grp-body { display: none; }
.grp-body { padding: 0 16px 16px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; }
.row:first-child { margin-top: 0; }
.row:last-child { margin-bottom: 0; }
.row.col { flex-direction: column; align-items: stretch; gap: 7px; margin: 14px 0; }
.row.btns { flex-direction: column; align-items: stretch; gap: 8px; margin-top: 16px; }
/* 分组第一行贴紧标题（.row.col 的 14px 上边距会与标题挤在一起显空） */
.grp-body > .row:first-child { margin-top: 0; }
.lbl {
  font-size: 12.5px;
  color: var(--txt-2);
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-width: 0;
}
/* 竖排行：标签占满整行，数值徽章贴右，保证所有数值右边缘对齐 */
.row.col > .lbl { width: 100%; justify-content: space-between; }
.lbl em {
  font-style: normal;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  line-height: 1;
  color: var(--txt-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 7px;
  min-width: 44px;
  text-align: right;
}
.row.col > .lbl em { margin-left: auto; }
/* 影调汇总徽章：还没拼出结果时显示「待拼接」——否则拖了滑杆画面不动，
   只有一个「未调整」的大字，看起来就像功能坏了 */
.lbl em.pending {
  color: var(--warn);
  border-color: rgba(229, 181, 103, .38);
  background: rgba(229, 181, 103, .1);
}
.inline { display: flex; align-items: center; gap: 8px; }

/* 投影选择卡 */
.projlist {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.proj { position: relative; display: block; cursor: pointer; }
/* 视觉隐藏但保留键盘可达：必须 fixed 到视口左上角（1×1），
   否则元素落在面板下方，focus 时浏览器会滚动页面去找它 */
.sr-only,
.proj input,
.switch input {
  position: fixed;
  top: 0; left: 0;
  width: 1px; height: 1px;
  margin: 0; padding: 0; border: 0;
  opacity: 0;
  pointer-events: none;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.pj-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 4px 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #0d1117;
  transition: background .1s;
  text-align: center;
}
.pj-ic { width: 38px; height: 25px; color: var(--dim); transition: color .1s; }
.pj-body b { font-size: 12px; font-weight: 550; color: var(--txt-2); }
.pj-body em { font-style: normal; font-size: 10px; color: var(--dim); letter-spacing: .2px; }
/* 2×2 卡片紧贴，悬停只提一档底色；描边留给「已选中」状态独占，
   否则鼠标在两列之间来回就会看到两道边框交替闪 */
.proj:hover .pj-body { background: #111823; }
.proj input:checked + .pj-body {
  border-color: var(--accent-d);
  background: rgba(95, 168, 255, .1);
}
.proj input:checked + .pj-body .pj-ic { color: var(--accent); }
.proj input:checked + .pj-body b { color: var(--txt); }
.proj input:focus-visible + .pj-body { outline: 2px solid rgba(95,168,255,.5); outline-offset: 1px; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; color: var(--txt-2); user-select: none; }
/* 见上方 .sr-only：开关的 <input> 同样视觉隐藏（fixed 到视口左上角） */
.switch i {
  width: 32px; height: 18px;
  border-radius: 10px;
  background: #1c242f;
  border: 1px solid var(--line-2);
  position: relative;
  transition: background .18s, border-color .18s;
  flex: none;
}
.switch i::after {
  content: "";
  position: absolute;
  left: 2px; top: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #6c7788;
  transition: transform .18s, background .18s;
}
.switch input:checked + i { background: var(--accent-d); border-color: var(--accent-d); }
.switch input:checked + i::after { transform: translateX(14px); background: #fff; }
.switch input:focus-visible + i { outline: 2px solid rgba(95,168,255,.5); outline-offset: 2px; }

/* 输入 */
.sel, .num {
  height: 30px;
  background: #0d1117;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  color: var(--txt);
  font: inherit;
  font-size: 12.5px;
  padding: 0 8px;
  min-width: 0;
}
.sel { flex: 1; max-width: 150px; cursor: pointer; }
.num { width: 92px; font-family: var(--mono); }
/* 竖排行里下拉 / 数字框撑满，避免右边留一大块空白显错位 */
.row.col > .sel, .row.col > .num { width: 100%; max-width: none; flex: none; }
.sel:focus, .num:focus { outline: none; border-color: var(--accent-d); }
.num:disabled { opacity: .45; }
.sel option { background: #11161e; }

/* 滑杆 */
/* 关键：元素本体 20px 高（= 真实可点击区），轨道 4px 只是视觉；
   之前写成 height:4px，拇指溢出但命中区只有 4px，滑杆几乎拖不动。 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 20px;
  width: 100%;
  min-width: 90px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg,
    var(--accent-d) 0, var(--accent) var(--p),
    #1c242f var(--p), #1c242f 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  margin-top: -5px;                       /* (14 - 4) / 2，让拇指骑在轨道上 */
  border-radius: 50%;
  background: #eaf2ff;
  border: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .6), 0 0 0 1px rgba(10, 13, 18, .75);
  transition: box-shadow .1s, background .1s;
}
/* 注意：::-webkit-slider-thumb:hover 在 Chrome 里根本不生效，必须挂在 input 上。
   这里只提亮 + 一圈柔光，不做 scale —— 影调组是 5 条紧凑滑杆，
   拇指忽大忽小在鼠标扫过时最刺眼，也最容易让人误以为「界面在闪」。 */
input[type="range"]:hover::-webkit-slider-thumb {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .6), 0 0 0 1px rgba(10, 13, 18, .75), 0 0 0 3px rgba(95, 168, 255, .13);
}
input[type="range"]:active::-webkit-slider-thumb {
  box-shadow: 0 1px 4px rgba(0, 0, 0, .6), 0 0 0 1px rgba(10, 13, 18, .75), 0 0 0 4px rgba(95, 168, 255, .2);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: #1c242f; }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border: 0; border-radius: 50%;
  background: #eaf2ff; box-shadow: 0 1px 4px rgba(0,0,0,.6);
}
input[type="range"]:focus { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(95, 168, 255, .35), 0 1px 4px rgba(0, 0, 0, .6);
}
/* 横向行：滑杆吃掉剩余宽度；竖排行不能给 flex —— flex-basis:0% 在 column
   方向是被当成「高度」的，会把滑杆压成一条线（这正是之前拖不动的根因） */
.row:not(.col) > input[type="range"] { flex: 1; min-width: 60px; }
.row.col > input[type="range"] { flex: none; max-width: none; height: 20px; }

.slide3 { display: flex; flex-direction: column; gap: 3px; }
.sl { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 10px; }
.sl span { font-size: 11px; color: var(--dim); text-align: right; }
.sl input { width: 100%; }
/* 带数值徽章的滑杆行（影调组）：三列，第三列定宽让各行滑杆右端严格对齐 */
.sl.has-val { grid-template-columns: 40px minmax(0, 1fr) 60px; }
.sl > em {
  font-style: normal;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  line-height: 1;
  color: var(--txt-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 5px;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
}

/* 结果读数 */
.readout { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.readout > div { min-width: 0; }
.readout dt { font-size: 11px; color: var(--dim); margin: 0 0 1px; }
.readout dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--txt);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------------------------------------------------------- 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* 全屏遮罩也不用模糊：它压在整页（含画布）之上，模糊会把整页每帧重采样一遍 */
  background: rgba(4, 7, 11, .8);
  animation: fadein .16s ease;
}
@keyframes fadein { from { opacity: 0; } }
/* [hidden] 必须全局生效：.stage-empty / .modal 等类规则与 [hidden] 同为 (0,1,0)，
   一旦排在后面就会把它盖掉 —— 那会让空状态提示永远压在画布上，弹窗也一直挡着页面 */
[hidden] { display: none !important; }

.modal-box {
  width: min(640px, 100%);
  max-height: min(84vh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
  overflow: hidden;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }
.modal-box.wide { width: min(1180px, 100%); }

.modal-head {
  height: 50px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .2px; }
.modal-head-actions { display: flex; align-items: center; gap: 12px; }
.hint { font-size: 11px; line-height: 1.62; color: var(--dim); margin: 0; }
.grp-body .hint { margin-top: 1px; }
.grp-tag {
  margin-left: 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .5px;
  color: var(--accent);
  background: rgba(95, 168, 255, .12);
  border: 1px solid rgba(95, 168, 255, .3);
  border-radius: 5px;
  padding: 1px 5px;
  vertical-align: 1px;
}

.modal-body { padding: 18px 20px 22px; overflow-y: auto; }
.modal-body.no-pad { padding: 0; }
.modal-body.help { font-size: 13px; color: var(--txt-2); line-height: 1.72; }
.modal-body.help h4 {
  margin: 16px 0 6px;
  font-size: 12.5px;
  color: var(--txt);
  letter-spacing: .4px;
}
.modal-body.help h4:first-child { margin-top: 0; }
.modal-body.help ol, .modal-body.help ul { margin: 0; padding-left: 20px; }
.modal-body.help li { margin: 3px 0; }
.modal-body.help b { color: var(--txt); font-weight: 600; }

#viewerCanvas {
  display: block;
  width: 100%;
  height: min(70vh, 620px);
  background: #05080c;
  cursor: grab;
  touch-action: none;
}
#viewerCanvas.dragging { cursor: grabbing; }

.log {
  margin: 0;
  font: 11.5px/1.65 var(--mono);
  color: var(--txt-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow: auto;
}

/* 导出面板内容 */
.exp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 4px; }
.exp-item { background: #0d1117; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.exp-item dt { font-size: 11px; color: var(--dim); margin-bottom: 2px; }
.exp-item dd { margin: 0; font-family: var(--mono); font-size: 13px; color: var(--txt); }
.exp-note { font-size: 12px; color: var(--dim); margin: 12px 0 16px; line-height: 1.6; }
.exp-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------------------------------------------------- 控制点编辑器 */
.cp-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.cp-sel { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); }
.cp-sel select {
  background: #0d1117;
  color: var(--txt);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  max-width: 190px;
}
.cp-hint { font-size: 11.5px; color: var(--dim); }
.cp-spacer { flex: 1; }
.cp-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  background: #05080c;
  flex: 1;
  min-height: 0;
}
.cp-pane {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #05080c;
}
.cp-pane canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}
.cp-pane canvas.dragging { cursor: grabbing; }
.cp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--txt-2);
}

/* ---------------------------------------------------------- Toast */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 62px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: #171f29;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 9px 15px;
  font-size: 12.5px;
  color: var(--txt);
  box-shadow: var(--sh);
  animation: toastin .2s ease;
  max-width: 78vw;
}
.toast.ok { border-color: rgba(78, 203, 143, .4); }
.toast.err { border-color: rgba(239, 107, 107, .45); }
.toast.warn { border-color: rgba(229, 181, 103, .45); }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } }

/* 队列折叠（宽屏）：面板隐藏、让中栏吃满 */
.workspace.qhide { grid-template-columns: 0 minmax(0, 1fr) 322px; }
.workspace.qhide .panel-left { display: none; }
@media (max-width: 1180px) {
  .workspace.qhide { grid-template-columns: 0 minmax(0, 1fr) 300px; }
}

/* ---------------------------------------------------------- 画布编辑工具条 */
/* 与 .stage-toolbar 同理：不用 backdrop-filter —— 只支持「不透明的深色玻璃」，
   模糊会在每一次合成时重采样背后的画布，是左侧闪屏的最后一处来源。 */
.edit-bar,
.edit-sub {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(17, 23, 31, .96), rgba(11, 15, 21, .96));
  border: 1px solid var(--line-2);
  box-shadow: var(--sh);
  z-index: 6;
  white-space: nowrap;
}
.edit-bar { top: 12px; }
.edit-sub { top: 52px; padding: 5px 10px; }
.eb-title {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 2px;
  padding-right: 2px;
}
.eb-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 2px; }
.eb-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--txt-2);
  font-size: 12.5px;
  cursor: pointer;
}
.eb-tool:hover { color: var(--txt); background: rgba(255, 255, 255, .05); }
.eb-tool.on {
  color: var(--accent);
  background: rgba(95, 168, 255, .12);
  border-color: rgba(95, 168, 255, .35);
}
.eb-tool .ic { width: 15px; height: 15px; }
.es-lbl { font-size: 12px; color: var(--dim); }
.es-hint { font-size: 12px; color: var(--txt-2); }
.es-info { font-family: var(--mono); font-size: 11.5px; color: var(--accent); }

/* 预览上的编辑光标 */
.stage-canvas-wrap.tool-crop,
.stage-canvas-wrap.tool-heal { cursor: crosshair; }
.stage-canvas-wrap.tool-straighten { cursor: ns-resize; }
.stage-canvas-wrap.editing .stage-toolbar { opacity: .35; pointer-events: none; }
/* 抓手 / 空格临时抓手：优先于编辑工具的十字光标 */
.stage-canvas-wrap.pan-mode,
.stage-canvas-wrap.grab { cursor: grab; }
.stage-canvas-wrap.panning { cursor: grabbing; }

/* 直方图 */
.hist-wrap { position: relative; }
.hist-ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--dim);
  pointer-events: none;
}
.hist {
  width: 100%;
  height: 64px;
  display: block;
  border-radius: 8px;
  background: #0c1016;
  border: 1px solid var(--line);
}
.num.wide { width: 108px; }

/* ---------------------------------------------------------- 响应式 */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 232px minmax(0, 1fr) 300px; }
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .panel-left {
    position: fixed;
    left: 0; top: 58px; bottom: 0;
    width: 272px;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--sh);
  }
  .panel-left.open { transform: none; }
  .only-narrow { display: inline-flex; }
  .brand-txt span { display: none; }
  .workspace.qhide { grid-template-columns: 1fr; }
  .panel-right {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 46vh;
  }
  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 46vh); }
  .stage { order: -1; }
  /* 窄屏面板横跨整个宽度：分组导航排成一行 8 个，否则每个 chip 会被拉到 250px 宽 */
  .grp-nav { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  /* 面板变宽后投影卡也排成一行，避免两张卡被拉成大长条 */
  .projlist { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
