:root {
  --sidebar-w: min(320px, 30vw);
  --bg-page: #e8eaed;
  --bg-sidebar: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --radius-panel: 12px;
  --shadow-canvas: 0 8px 30px rgba(15, 23, 42, 0.08);
  --sidebar-pad-x: 14px;
  --sidebar-pad-y: 16px;
  --sidebar-section-gap: 20px;
  --sidebar-block-gap: 12px;
  --sidebar-label-gap: 6px;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--text);
  background: var(--bg-page);
}

.app {
  display: flex;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  min-width: 280px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: var(--sidebar-pad-y) var(--sidebar-pad-x) calc(var(--sidebar-pad-y) + 8px);
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100%;
  min-height: 0;
}

/* stitch/icon：侧栏内套一层滚动区。整页带 transform 时，部分 WebKit 在 aside 上画滚动条但触摸不跟手，内层 div 滚动更稳 */
.pich-tool-view .sidebar {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.pich-tool-view .sidebar > .pich-sidebar-scroll {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--sidebar-pad-y) var(--sidebar-pad-x) calc(var(--sidebar-pad-y) + 8px);
}

.panel {
  margin-bottom: var(--sidebar-section-gap);
}

.panel:last-child {
  margin-bottom: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 var(--sidebar-block-gap);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.panel-title .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
  border: 2px dashed #d1d5db;
  border-radius: var(--radius-panel);
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* `hidden` 默认 display:none 会被上面的 .upload-zone { display:flex } 盖掉，需显式收回布局 */
.upload-zone[hidden] {
  display: none !important;
}

.upload-icon {
  font-size: 28px;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1;
}

.upload-text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
}

.upload-feedback {
  margin: var(--sidebar-block-gap) 0 0;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
}

.upload-feedback.is-error {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.field {
  margin-bottom: var(--sidebar-block-gap);
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  margin-bottom: var(--sidebar-label-gap);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.35;
}

.field-bg .field-label {
  margin-bottom: 8px;
}

.hint {
  margin: var(--sidebar-label-gap) 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
}

.hint.subtle {
  margin-top: 8px;
  margin-bottom: 0;
}

.mode-toggle {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mode-btn {
  flex: 1;
  min-width: 0;
  padding: 8px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.mode-btn:hover {
  border-color: #cbd5e1;
}

.mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mode-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 var(--sidebar-block-gap);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
}

.panel .checkbox-row:last-child {
  margin-bottom: 0;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.slider-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.slider-field .value {
  font-weight: 600;
  color: var(--accent);
}

.bg-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.bg-preset {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.bg-preset:hover {
  border-color: #9ca3af;
}

.bg-preset.active,
.bg-preset.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.bg-preset-transparent {
  background-color: #fff !important;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

.color-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.sidebar-tips {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 14px;
  padding: 10px 10px 10px 8px;
  border-radius: 8px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.sidebar-tips-icon {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  margin-top: 2px;
}

.sidebar-tips-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

#bgColorPicker {
  width: 44px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.input-hex {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
  text-transform: uppercase;
}

.btn-download {
  width: 100%;
  margin-top: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-download:hover:not(:disabled) {
  opacity: 0.92;
}

.btn-download:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-new-project {
  width: 100%;
  margin-top: 0;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  cursor: pointer;
}

.btn-new-project:hover {
  color: var(--text);
  border-color: #9ca3af;
  background: #f3f4f6;
}

.btn-new-project:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.preview-bottom-bar[hidden] {
  display: none !important;
}

.preview-bottom-bar {
  position: fixed;
  z-index: 40;
  left: calc(20px + env(safe-area-inset-left, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  pointer-events: none;
}

.preview-bottom-bar > * {
  pointer-events: auto;
}

.task-strip-host {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
}

.task-strip-host[hidden] {
  display: none !important;
}

.task-strip-tabs {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.task-strip-host .task-num-tab.btn-new-project.btn-fab-icon {
  flex: none;
  width: auto;
  min-width: 44px;
  margin-top: 0;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  background: #fff;
  border-style: solid;
  border-color: var(--border);
  color: #4b5563;
}

.task-strip-host .task-num-tab.btn-new-project.btn-fab-icon:hover:not(:disabled) {
  color: var(--text);
  border-color: #9ca3af;
  background: #f3f4f6;
}

.task-strip-host .task-num-tab.btn-new-project.btn-fab-icon.is-active-task {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.preview-fab-actions {
  position: static;
  z-index: auto;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  width: min(252px, 42vw);
  flex-shrink: 0;
}

.preview-fab-actions .btn-download,
.preview-fab-actions .btn-new-project {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

.preview-fab-actions .btn-download {
  flex: 2;
}

.preview-fab-actions .btn-new-project {
  background: #fff;
  border-style: solid;
  border-color: var(--border);
  color: #4b5563;
}

.btn-fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
}

.preview-fab-actions .btn-new-project.btn-fab-icon {
  padding: 0 8px;
}

.preview-fab-split {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  background: #fff;
}

.preview-fab-split__btn {
  flex: 1;
  min-width: 0;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  margin: 0 !important;
}

.preview-fab-split__btn + .preview-fab-split__btn {
  border-left: 1px solid var(--border) !important;
}

.preview-fab-actions .preview-fab-split .preview-fab-split__btn {
  padding: 0 10px;
}

.btn-fab-icon--muted {
  color: #64748b;
  background: #fff;
}

.btn-fab-icon--muted:hover:not(:disabled) {
  color: var(--text);
  background: #f8fafc;
}

.pip-bg-replace-panel {
  width: 100%;
  box-sizing: border-box;
}

.pip-guide-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
  overflow: visible;
}

.pip-guide-line {
  stroke: #16f2f0;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  shape-rendering: crispEdges;
}

.pip-drag-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  touch-action: none;
  cursor: grab;
  background: transparent;
  z-index: 2;
}

.pip-drag-overlay:active {
  cursor: grabbing;
}

.pip-drag-marquee {
  position: absolute;
  box-sizing: border-box;
  border: 1px dashed rgba(37, 99, 235, 0.85);
  background: rgba(37, 99, 235, 0.08);
  pointer-events: none;
  z-index: 25;
  border-radius: 2px;
}

.pip-replace-bg-pick-again {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
  font: inherit;
  cursor: pointer;
}

.pip-replace-bg-preview-wrap {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 10px;
}

.pip-replace-bg-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  touch-action: none;
  cursor: grab;
  background: #e2e8f0;
}

.pip-replace-bg-actions {
  justify-content: flex-end;
  gap: 10px;
}

.pip-asset-style-swatch__face--glass {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.75) 0%,
    rgba(255, 255, 255, 0.18) 42%,
    rgba(180, 200, 230, 0.35) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    0 6px 16px rgba(15, 23, 42, 0.12),
    0 2px 4px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.pip-asset-style-swatch.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.fab-svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.preview-fab-actions .btn-download .fab-svg {
  width: 24px;
  height: 24px;
}

.preview-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background-color: #ffffff;
  background-image: radial-gradient(circle at center, #c4cad4 1px, transparent 1.05px);
  background-size: 26px 26px;
  background-position: 0 0;
}

.preview-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: transparent;
  border-radius: 0;
}

/* 顶栏：透明浮在点阵画布上；画布在 .canvas-shell 内滚动，顶栏不跟着滚 */
.preview-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 12px 6px;
  flex-shrink: 0;
  min-width: 0;
  position: sticky;
  top: 0;
  z-index: 4;
  background: transparent;
  border: none;
  font-size: 12px;
  color: var(--text-muted);
}

.preview-toolbar-left {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
}

/* 缩放条吃掉左侧剩余宽度，避免与右侧工具导航抢行 */
.preview-zoom-slider-host {
  flex: 1 1 56px;
  min-width: 0;
  max-width: 200px;
  display: flex;
  align-items: center;
}

.preview-toolbar-label {
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

@media (max-width: 380px) {
  .preview-toolbar-label {
    display: none;
  }
}

.preview-toolbar .preview-zoom-slider-host #zoomSlider {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

.preview-toolbar-value {
  font-weight: 600;
  color: var(--accent);
  min-width: 2.5ch;
  text-align: right;
}

.preview-toolbar-unit {
  margin-left: -4px;
}

/* 问候语独立于画布缩放链，避免 fit-content / line-height:0 等牵连排版 */
.preview-greet {
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.preview-greet[hidden] {
  display: none !important;
}

.preview-greet .placeholder {
  margin: 0;
  padding: 14px 20px 16px;
  text-align: center;
  font-size: 14px;
  line-height: normal;
  color: var(--text-muted);
}

.preview-toolbar-hint {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  color: #9ca3af;
}

@media (min-width: 1100px) {
  .preview-toolbar-hint {
    margin-top: 0;
  }
}

.btn-zoom-reset,
.btn-zoom-fit {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-zoom-fit {
  border-color: #bfdbfe;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.btn-zoom-reset:hover,
.btn-zoom-fit:hover {
  border-color: #93c5fd;
}

.canvas-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: transparent;
}

/* 抠图进行中：仅盖住 .zoom-wrapper（与缩放后的画布同尺寸），不铺满整片滚动区 */
.edit-matting-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 16px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
}

.edit-matting-overlay[hidden] {
  display: none !important;
}

.edit-matting-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.edit-matting-stars-svg {
  display: block;
  color: #64748b;
  opacity: 0.92;
}

.edit-matting-stars-svg .edit-matting-star {
  transform-box: fill-box;
  transform-origin: center;
}

.edit-matting-stars-svg .edit-matting-star--a {
  animation: edit-matting-star-breathe-a 1.35s ease-in-out infinite;
}

.edit-matting-stars-svg .edit-matting-star--b {
  animation: edit-matting-star-breathe-b 1.35s ease-in-out infinite;
}

@keyframes edit-matting-star-breathe-a {
  0%,
  100% {
    transform: scale(0.88);
    opacity: 0.82;
  }

  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

@keyframes edit-matting-star-breathe-b {
  0%,
  100% {
    transform: scale(1.12);
    opacity: 1;
  }

  50% {
    transform: scale(0.88);
    opacity: 0.82;
  }
}

.edit-matting-label {
  margin: 0;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

/* 为拼接卡片 box-shadow / 圆角外侧留出空间，避免被 overflow:auto 裁切 */
.canvas-shell:not(.is-empty) {
  padding: 28px 28px 36px 28px;
}

.canvas-shell.is-empty {
  box-shadow: none;
}

.canvas-shell.is-empty .stitch-card {
  background: transparent !important;
  box-shadow: none;
}

.stitch-card {
  box-sizing: border-box;
  width: fit-content;
  min-width: 280px;
  min-height: 200px;
  background: #ffffff;
}

.stitch-card.is-active {
  box-shadow: var(--shadow-canvas);
}

/* 子图直角时仍会铺满内容区；裁进全图圆角内，避免四角「溢出」 */
.stitch-card.is-active:not(.pip-card) {
  overflow: hidden;
}

/* 画中画：底图不垫白底；阴影贴在真实合成区，不要打在外层 stitch-card（会随 flex 被拉高成一块大白底） */
.pip-app-body .stitch-card.pip-card,
.pip-app-body .stitch-card.pip-card.is-active {
  background: transparent;
  min-width: 0;
  min-height: 0;
  box-shadow: none;
}

/* 图片编辑：预览衬棋盘格，透明底（抠图等）可辨认；不透明像素仍盖住底纹 */
.edit-app-body .stitch-card.pip-card.is-active {
  background-color: transparent !important;
  background-image:
    linear-gradient(45deg, #e8eaed 25%, transparent 25%),
    linear-gradient(-45deg, #e8eaed 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8eaed 75%),
    linear-gradient(-45deg, transparent 75%, #e8eaed 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

/* 图片编辑：布局最小占位 10×10，小图不再被全局 280×200 壳撑开（拼接/画中画仍用原规则） */
.edit-app-body .stitch-card.pip-card {
  min-width: 10px;
  min-height: 10px;
}

.edit-app-body .zoom-wrapper {
  min-width: 0;
}

.edit-app-body .canvas-inner.pip-canvas-inner {
  min-width: 10px;
  min-height: 10px;
}

.stitch-card.is-active.is-bg-transparent {
  background-color: transparent !important;
  background-image:
    linear-gradient(45deg, #e8eaed 25%, transparent 25%),
    linear-gradient(-45deg, #e8eaed 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8eaed 75%),
    linear-gradient(-45deg, transparent 75%, #e8eaed 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.zoom-wrapper {
  position: relative;
  width: fit-content;
  max-width: 100%;
  min-width: min(280px, 100%);
  min-height: 0;
}

.zoom-surface {
  --pip-zoom: 1;
  transform-origin: 0 0;
  will-change: transform;
}

.zoom-surface .canvas-inner {
  width: fit-content;
  height: fit-content;
}

.canvas-inner {
  position: relative;
  min-width: 280px;
  min-height: 200px;
}

.placeholder {
  margin: 0;
  padding: 80px 40px;
  text-align: center;
  font-size: 14px;
  line-height: normal;
  color: var(--text-muted);
}

.stitch-host {
  display: flex;
}

.stitch-host[data-mode="vertical"] {
  flex-direction: column;
}

.stitch-host[data-mode="horizontal"] {
  flex-direction: row;
  flex-wrap: nowrap;
}

.stitch-host[data-mode="grid"] {
  flex-direction: row;
  flex-wrap: wrap;
}

.stitch-host img {
  display: block;
  max-width: 100%;
  height: auto;
}

.stitch-host .cell {
  position: relative;
  display: block;
  box-sizing: border-box;
  overflow: hidden;
  flex-shrink: 0;
}

.stitch-host .cell-crop {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  cursor: grab;
}

.stitch-host .cell-crop:active {
  cursor: grabbing;
}

.radius-split-block,
.gap-pad-split-block {
  margin-bottom: var(--sidebar-block-gap);
}

.radius-split-block .field:last-child,
.gap-pad-split-block .field:last-child {
  margin-bottom: 0;
}

.stitch-host .cell-crop::after {
  content: "裁剪";
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  font-size: 10px;
  color: #fff;
  background: rgba(37, 99, 235, 0.85);
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.stitch-host .cell-crop:hover::after {
  opacity: 1;
}

.stitch-host .cell.cell-drag-target {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.cell-crop {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.cell-crop img {
  display: block;
  max-width: none !important;
  height: auto;
  width: auto;
}

.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.crop-modal[hidden] {
  display: none !important;
}

.crop-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.crop-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px 22px 18px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.crop-modal-title {
  margin: 0 0 6px;
  font-size: 16px;
}

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

/* —— Tinify：左右分栏，加载层仅在弹窗内（不盖住主画布）—— */
.crop-modal.tinify-modal .crop-modal-dialog.tinify-modal-dialog {
  position: relative;
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: hidden;
  padding: 16px 18px 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tinify-modal-head .crop-modal-title {
  margin: 0 0 6px;
}
.tinify-modal-head .crop-hint {
  margin: 0 0 8px;
  font-size: 12px;
}
.tinify-modal-head .tinify-modal-quota-line {
  margin: 0 0 12px;
}

.tinify-modal-head {
  flex-shrink: 0;
}

.tinify-modal-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(200px, 1fr) auto;
  column-gap: 16px;
  row-gap: 12px;
  flex: 1 1 auto;
  min-height: min(380px, 52vh);
  margin-bottom: 0;
  align-items: stretch;
}

.tinify-modal-top--src {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  min-width: 0;
}

.tinify-modal-top--out {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  min-width: 0;
}

.tinify-modal-src-frame {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
}

.tinify-modal-out-frame {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
}

.tinify-modal-col-primary {
  grid-column: 1;
  grid-row: 3;
  justify-self: center;
}

.tinify-modal-col-secondary {
  grid-column: 2;
  grid-row: 3;
  justify-self: center;
}

@media (max-width: 720px) {
  .tinify-modal-split {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto auto;
    min-height: 0;
  }

  .tinify-modal-top--src {
    grid-column: 1;
    grid-row: 1;
  }

  .tinify-modal-src-frame {
    grid-column: 1;
    grid-row: 2;
  }

  .tinify-modal-col-primary {
    grid-column: 1;
    grid-row: 3;
  }

  .tinify-modal-top--out {
    grid-column: 1;
    grid-row: 4;
  }

  .tinify-modal-out-frame {
    grid-column: 1;
    grid-row: 5;
  }

  .tinify-modal-col-secondary {
    grid-column: 1;
    grid-row: 6;
  }
}

.tinify-modal-top {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tinify-modal-top .field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
}

.tinify-modal-src-pick-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}

.tinify-modal-src-pick-area .tinify-modal-upload[hidden] + .tinify-modal-clear-file {
  margin-top: 0;
}

.tinify-modal-top--src .tinify-modal-upload {
  margin-bottom: 0;
}
.tinify-modal-dialog .tinify-modal-clear-file {
  margin-top: 0;
  width: 100%;
  box-sizing: border-box;
}
.tinify-modal-dialog #tinifyModalDropHost.dragover .tinify-modal-pick-label {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tinify-modal-dialog .tinify-modal-canvas-opt {
  margin-bottom: 8px;
}
.tinify-modal-dialog .tinify-modal-use-canvas-note {
  margin-top: 4px;
  margin-bottom: 0;
}

.tinify-modal-top--src #tinifyModalHint {
  margin: 2px 0 0;
  min-height: 2.75em;
}

.tinify-modal-preview-frame.tinify-modal-src-frame,
.tinify-modal-preview-frame.tinify-modal-out-frame {
  position: relative;
  min-height: 200px;
  max-height: min(46vh, 380px);
  overflow: auto;
  margin: 0;
  padding: 10px;
  background: #f3f4f6;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tinify-modal-panel-placeholder {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.tinify-modal-panel-placeholder[hidden] {
  display: none !important;
}

.tinify-modal-preview-frame .tinify-modal-preview-img {
  display: block;
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: min(42vh, 340px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.tinify-modal-preview-frame .tinify-modal-preview-img:not([src]),
.tinify-modal-preview-frame .tinify-modal-preview-img[src=""] {
  visibility: hidden;
  position: absolute;
  width: 0;
  height: 0;
}

.tinify-modal-compress-stats {
  margin: 0 0 4px;
  font-size: 12px;
  min-height: 2.75em;
  color: var(--text);
}

.tinify-modal-col-primary,
.tinify-modal-col-secondary {
  width: auto;
  max-width: 100%;
  margin-top: 0;
  margin-bottom: 0;
  padding: 7px 14px;
  box-sizing: border-box;
  font-size: 12px;
  white-space: nowrap;
}

.tinify-modal-busy-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.78);
  border-radius: inherit;
  backdrop-filter: blur(4px);
}
.tinify-modal-busy-layer[hidden] {
  display: none !important;
}
.tinify-modal-busy-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.tinify-modal-busy-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tinify-busy-spin 0.82s linear infinite;
}
@keyframes tinify-busy-spin {
  to {
    transform: rotate(360deg);
  }
}

.crop-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 16px;
  max-height: min(70vh, 640px);
  overflow: auto;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 12px;
}

.crop-img-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  vertical-align: top;
}

.crop-modal-img {
  display: block;
  max-width: min(860px, 85vw);
  max-height: min(65vh, 600px);
  width: auto;
  height: auto;
  user-select: none;
}

.crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #fff;
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  cursor: move;
  touch-action: none;
}

.crop-handle {
  position: absolute;
  display: block;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 2px;
}

.crop-handle-br {
  right: -6px;
  bottom: -6px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

.crop-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.btn-secondary {
  padding: 8px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #f9fafb;
}

.btn-primary {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.btn-primary:hover {
  opacity: 0.92;
}

/* —— 多页布局：首页 / 占位页可滚动 —— */
html:has(body.imgprocess-scroll-page),
html:has(body.imgprocess-scroll-page) body {
  height: auto;
  min-height: 100%;
  max-height: none;
}

body.imgprocess-scroll-page {
  overflow-x: hidden;
  overflow-y: auto;
}

/* —— 工具胶囊导航（与 mode-toggle 同系配色） —— */
.tool-nav-capsule {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  flex-shrink: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.tool-nav-capsule::-webkit-scrollbar {
  height: 4px;
}

.tool-nav-capsule::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
}

.tool-nav-capsule--header {
  max-width: 100%;
}

.tool-nav-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tool-nav-pill:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.75);
}

.tool-nav-pill.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.tool-nav-pill.is-active:hover {
  color: #fff;
  opacity: 0.95;
}


/* —— 占位子页 —— */
.imgprocess-placeholder {
  margin: 0;
  padding: 0 18px 40px;
  background: var(--bg-page);
}

.placeholder-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 16px;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 0 12px;
}

.placeholder-back {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.placeholder-back:hover {
  color: var(--accent);
}

.placeholder-main {
  max-width: 520px;
  margin: 48px auto 0;
  padding: 32px 28px;
  text-align: center;
  border-radius: var(--radius-panel);
  border: 1px solid var(--border);
  background: var(--bg-sidebar);
  box-shadow: var(--shadow-canvas);
}

.placeholder-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.placeholder-desc {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.placeholder-cta {
  display: inline-block;
  text-decoration: none;
  color: inherit;
}

@media (max-width: 520px) {
  .tool-nav-capsule--header .tool-nav-pill {
    padding: 6px 10px;
    font-size: 11px;
  }
}

/* —— 画中画 pip —— */
.upload-zone--compact {
  min-height: 72px;
  padding: 10px 12px;
}

.upload-zone--compact .upload-text {
  font-size: 12px;
}

.pip-select {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.pip-text-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.pip-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
  min-height: 52px;
  font-family: inherit;
}

.pip-inline-val {
  display: inline-block;
  min-width: 2ch;
  margin-left: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

/* 水印模式：角位网格与「边距」滑块之间的留白 */
.pip-wm-only .pip-wm-margin-row {
  margin-top: 12px;
}

.pip-inline-muted {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.pip-color-row .color-row {
  flex-wrap: wrap;
}

.pip-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pip-preset-btn {
  min-width: 44px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pip-preset-btn:hover {
  border-color: #cbd5e1;
}

.pip-preset-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.pip-preset-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pip-preset-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pip-preset-subtitle {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: none;
}

.pip-asset-source-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pip-asset-tab {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pip-asset-tab:hover {
  border-color: #cbd5e1;
  color: var(--text);
}

.pip-asset-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.pip-asset-svg-block {
  margin-top: 10px;
}

.pip-asset-svg-hint {
  margin-bottom: 8px;
}

.pip-asset-svg-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.pip-asset-svg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-height: 40px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: #0f172a;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.pip-asset-svg-btn:hover {
  border-color: var(--accent);
  background: #fff;
}

.pip-asset-svg-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.pip-asset-svg-btn .iconfont {
  font-size: 24px;
}

.pip-asset-svg-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.btn-pip-svg-page {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.btn-pip-svg-page:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-pip-svg-page:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pip-asset-svg-page-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 5rem;
  text-align: center;
}

.pip-asset-style-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pip-asset-style-swatch {
  flex: 1 1 36px;
  min-width: 36px;
  max-width: 48px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pip-asset-style-swatch:hover {
  border-color: var(--accent);
}

.pip-asset-style-swatch__face {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  box-sizing: border-box;
}

.pip-asset-style-swatch__face--hollow {
  background: repeating-linear-gradient(
    -45deg,
    #f1f5f9,
    #f1f5f9 4px,
    #e2e8f0 4px,
    #e2e8f0 8px
  );
  border: 3px solid #ef4444;
}

.pip-layer-strip-host.is-collapsed .pip-layer-strip-hint {
  display: none;
}

.pip-qr-style-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pip-qr-style-btn {
  flex: 1 1 40px;
  min-width: 40px;
  max-width: 52px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #fff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pip-qr-style-btn:hover {
  border-color: var(--accent);
}

.pip-qr-style-btn.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.pip-qr-style-face {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  box-sizing: border-box;
}

.pip-qr-style-face--wb {
  background-color: #fff;
  border: 2px solid #0f172a;
}

.pip-qr-style-face--bw {
  background-color: #0f172a;
  border: 2px solid #e2e8f0;
}

.pip-qr-style-face--tb {
  border: 2px dashed #64748b;
  background: repeating-linear-gradient(-45deg, #e2e8f0, #e2e8f0 3px, #f8fafc 3px, #f8fafc 6px);
}

.pip-qr-style-face--tw {
  border: 2px dashed #94a3b8;
  background: linear-gradient(160deg, #334155, #1e293b);
}

.pip-qr-apply-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent, #2563eb);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.pip-qr-apply-btn:hover {
  opacity: 0.92;
}

.pip-qr-apply-btn:active {
  transform: scale(0.98);
}

.bg-preset.pip-color-preset--transparent {
  background: repeating-linear-gradient(-45deg, #e2e8f0, #e2e8f0 4px, #f8fafc 4px, #f8fafc 8px);
  border: 1px dashed #94a3b8;
}

.pip-grad-fill-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.pip-grad-fill-open-btn {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.pip-grad-fill-open-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pip-grad-fill-status {
  margin: 0;
}

.pip-grad-dialog .pip-grad-dialog-panel {
  max-width: min(420px, 94vw);
  max-height: min(88vh, 640px);
  overflow: auto;
}

.pip-fill-img-dialog .pip-fill-img-dialog-panel {
  max-width: min(440px, 94vw);
}

.pip-fill-img-toolbar {
  margin: 8px 0 12px;
}

.pip-fill-img-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}

.pip-fill-img-zoom-label {
  flex: 0 0 auto;
  font-size: 13px;
  color: rgba(15, 23, 42, 0.75);
}

.pip-fill-img-zoom {
  flex: 1 1 auto;
  min-width: 0;
}

.pip-fill-img-crop-outer {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 14px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #0f172a;
}

.pip-fill-img-crop-canvas {
  display: block;
  width: 100%;
  height: 280px;
  cursor: grab;
  touch-action: none;
}

.pip-fill-img-crop-canvas:active {
  cursor: grabbing;
}

.pip-fill-img-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pip-grad-dir-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin: 12px 0 10px;
}

.pip-grad-dir-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.pip-grad-stops-head {
  display: grid;
  grid-template-columns: 72px 1fr 100px 40px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.pip-grad-stops-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.pip-grad-stop-row {
  display: grid;
  grid-template-columns: 72px 1fr 100px 40px;
  gap: 8px;
  align-items: center;
}

.pip-grad-stop-row input[type="number"] {
  width: 100%;
  max-width: 68px;
  box-sizing: border-box;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.pip-grad-stop-row input[type="color"] {
  width: 100%;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.pip-grad-stop-row input[type="range"] {
  width: 100%;
}

.pip-grad-stop-del {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.pip-grad-add-stop-btn {
  margin-bottom: 14px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: #f8fafc;
  cursor: pointer;
}

.pip-grad-dialog-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* 有底图后整块「1 底图」侧栏隐藏（避免 hidden 被 flex 样式盖住） */
.pip-base-panel[hidden] {
  display: none !important;
}

/* 画中画底图：上传 + 空白画布两列 */
.pip-base-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.pip-base-col--upload {
  flex: 2;
  min-width: 0;
}

.pip-base-col--upload .upload-zone {
  min-height: 100%;
  box-sizing: border-box;
}

.pip-base-col--blank {
  flex: 1;
  min-width: 0;
  display: flex;
}

/* 与上传区同款虚线框，无「+」号 */
.upload-zone.upload-zone--blank-only {
  width: 100%;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: center;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

.upload-zone.upload-zone--blank-only .upload-text {
  margin: 0;
}

.upload-zone.upload-zone--blank-only:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pip-blank-dialog-panel {
  max-width: min(420px, 96vw);
}

.pip-blank-size-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pip-blank-preset-btn {
  margin: 0;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--text);
}

.pip-blank-preset-btn:hover {
  border-color: #94a3b8;
}

.pip-blank-preset-btn.is-active {
  border-color: #2563eb;
  background: #eff6ff;
}

.pip-blank-custom-size .pip-blank-custom-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* edit.html · 输出宽高同一行 */
.edit-output-dims-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
}

.edit-output-dim {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.edit-output-dim .field-label {
  margin: 0;
  flex-shrink: 0;
}

.edit-output-dim .pip-blank-custom-inputs {
  flex-wrap: nowrap;
}

.edit-output-dims-row .pip-blank-num {
  width: 76px;
  margin-left: 0;
}

.edit-dim-sep {
  color: #94a3b8;
  font-size: 15px;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
  padding: 0 2px;
}

.edit-add-extra-size-btn {
  display: inline-block;
  width: auto;
  box-sizing: border-box;
  margin-top: 6px;
  padding: 3px 10px;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
}

.edit-extra-sizes-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.edit-extra-size-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f1f5f9;
  font-size: 13px;
  color: #334155;
}

/* 第一行：宽 × 高 同一排 */
.edit-extra-size-line1 {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}

.edit-extra-size-line1 .edit-output-dim .pip-blank-num {
  width: 72px;
}

/* 第二行：移除在右侧 */
.edit-extra-size-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
}

.edit-extra-size-remove {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.edit-extra-size-remove:hover {
  color: #b91c1c;
  background: rgba(248, 113, 113, 0.15);
}

.edit-stroke-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.edit-stroke-swatch {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border, #e2e8f0);
  box-sizing: border-box;
  padding: 0;
  cursor: pointer;
  background: var(--swatch, #fff);
}

.edit-stroke-swatch:hover {
  border-color: #94a3b8;
}

.edit-stroke-swatch:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.edit-frame-toggle-row {
  margin-top: 10px;
}

.edit-frame-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.edit-frame-preset {
  font-size: 12px;
  padding: 6px 10px;
}

.edit-format-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.edit-format-hint {
  margin-top: 6px;
  margin-bottom: 0;
}

.edit-upload-feedback {
  margin: 0 0 10px;
}

.edit-replace-top-panel {
  margin-bottom: var(--sidebar-section-gap);
  padding-bottom: 2px;
}

.edit-replace-top-panel:not(.pip-bg-replace-panel--dual) .edit-replace-image-btn,
.edit-replace-top-panel:not(.pip-bg-replace-panel--dual) .pip-bg-replace-secondary {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  cursor: pointer;
}

.edit-filename-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.edit-filename-input {
  flex: 1 1 120px;
  min-width: 0;
}

.edit-filename-ext {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  font-variant-numeric: tabular-nums;
}

.edit-third-party-hint {
  margin-top: 22px;
  margin-bottom: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border, #e2e8f0);
}

.edit-sidebar-tips-bottom {
  margin-top: calc(var(--sidebar-section-gap) + 8px);
}

.edit-compress-actions {
  margin-top: 10px;
}

.edit-compress-actions > .edit-replace-image-btn {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  cursor: pointer;
}

.edit-tinify-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--text, #0f172a);
}

.edit-tinify-link:visited {
  color: var(--text, #0f172a);
}

.edit-tinify-link:hover {
  color: var(--text, #0f172a);
}

.edit-aside-work .panel {
  margin-bottom: calc(var(--sidebar-section-gap) + 6px);
}

.edit-panel-export .edit-export-lock-row {
  margin-top: 4px;
  margin-bottom: 14px;
}

.edit-panel-export .edit-export-dims {
  margin-top: 2px;
  margin-bottom: 6px;
}

.edit-panel-export .field.edit-export-format-block {
  margin-top: 18px;
}

.edit-panel-export .field.slider-field#editQualityRow {
  margin-top: 16px;
}

.edit-panel-export .edit-compress-actions {
  margin-top: 8px;
}

.edit-corner-row.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.pip-blank-num-label {
  font-size: 13px;
  color: var(--text-muted, #64748b);
}

.pip-blank-num {
  width: 88px;
  margin-left: 4px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.pip-blank-size-x {
  font-size: 14px;
  color: #94a3b8;
}

.pip-blank-size-unit {
  font-size: 12px;
  color: #94a3b8;
}

.pip-blank-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

/* 画中画 · 导出弹窗（可复用到其它页的同类结构） */
.pip-export-dialog-panel {
  max-width: min(560px, 96vw);
}

.pip-export-preview-wrap {
  margin: 0 0 12px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: #e5e7eb;
  background-image:
    linear-gradient(45deg, #f3f4f6 25%, transparent 25%),
    linear-gradient(-45deg, #f3f4f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f3f4f6 75%),
    linear-gradient(-45deg, transparent 75%, #f3f4f6 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  text-align: center;
}

.pip-export-preview {
  display: inline-block;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 168px;
  vertical-align: middle;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.pip-export-dims-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.pip-export-dim-label {
  font-size: 13px;
  color: var(--text-muted, #64748b);
}

.pip-export-aspect-row {
  margin: 0;
  flex: 1 1 auto;
  min-width: 120px;
}

.pip-export-meta-block {
  margin: 14px 0 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(249, 250, 251, 0.95);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.65;
}

.pip-export-meta-line {
  margin: 2px 0;
}

.pip-export-meta-line--before .pip-export-meta-k {
  color: var(--text-muted, #64748b);
}

.pip-export-meta-line--before .pip-export-meta-v--muted {
  color: #9ca3af;
  font-weight: 400;
}

.pip-export-meta-line--after .pip-export-meta-k {
  color: var(--text, #111827);
  font-weight: 600;
}

.pip-export-meta-line--after .pip-export-meta-v {
  color: var(--text);
  font-weight: 500;
}

.pip-export-meta-k {
  margin-right: 6px;
}

.pip-export-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.pip-export-fmt-label {
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pip-export-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.pip-export-btn-continue {
  min-width: auto;
  padding-left: 14px;
  padding-right: 14px;
  max-width: 120px;
}

.pip-canvas-inner {
  display: block;
  line-height: 0;
}

.app:has(.pip-sidebar) .canvas-inner {
  min-width: 0;
  min-height: 0;
}

/* 画中画：勿让 .canvas-inner 的 min-width:0 把合成画布在 flex 里压成 0 宽条（预览会「坏掉」）。
   纯 min-content 在 CJK 占位下会缩成一字宽；与大画布取 max，并保证至少一屏可读宽度 */
.app:has(.pip-sidebar) .canvas-inner.pip-canvas-inner {
  min-width: max(min-content, min(280px, 100%));
  min-height: min-content;
  overflow: visible;
}

.pip-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.pip-canvas-stack {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}

/* 与导出圆角一致：裁剪画布像素，避免透明角下露出矩形白边 */
.pip-canvas-sheet {
  display: block;
  line-height: 0;
  width: fit-content;
  max-width: 100%;
  border-radius: var(--pip-out-corner, 0px);
  overflow: hidden;
}

.pip-canvas-stack .pip-canvas {
  display: block;
  /* 触摸端：避免浏览器把轻点当成滚动起点而不把事件交给画布；横向滚动仍可在外层 canvas-shell 空白处进行 */
  touch-action: none;
}

.pip-field-hint {
  margin-top: 4px;
  margin-bottom: 0;
}

.pip-anchor-group.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.pip-anchor-grid-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pip-anchor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(249, 250, 251, 0.65);
  box-sizing: border-box;
  max-width: 220px;
}

.pip-anchor-spacer {
  min-height: 34px;
  pointer-events: none;
}

.pip-anchor-btn {
  margin: 0;
  padding: 6px 4px;
  min-height: 34px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  color: #4b5563;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.pip-anchor-btn:hover {
  border-color: #cbd5e1;
  background: #f9fafb;
}

.pip-anchor-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.pip-layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pip-layer-item {
  margin: 0;
}

.pip-layer-tile {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.pip-layer-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.pip-layer-body:hover {
  background: #f9fafb;
}

.pip-layer-body.is-panel-open {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.pip-layer-name {
  flex-shrink: 0;
}

.pip-layer-status {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42%;
}

.pip-layer-body.is-panel-open .pip-layer-status {
  color: inherit;
  opacity: 0.85;
}

.pip-layer-del {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.pip-layer-del:hover {
  background: #fef2f2;
}

.pip-layer-del[hidden] {
  display: none;
}

.pip-type-hint {
  margin-bottom: var(--sidebar-block-gap);
}

.pip-app-body .canvas-shell:not(.is-empty) {
  padding: 22px;
}

.pip-app-body .zoom-wrapper {
  min-width: 0;
  margin-left: auto;
  margin-right: auto;
}

.pip-type-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pip-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pip-type-row:last-child {
  margin-bottom: 0;
}

.pip-type-row-main {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pip-type-row-main:hover {
  border-color: #cbd5e1;
}

.pip-type-row-main.is-panel-open {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.pip-type-row-trash {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pip-type-row-trash:hover {
  border-color: #fecaca;
  background: #fef2f2;
}

.pip-trash-svg {
  width: 18px;
  height: 18px;
  color: #4b5563;
}

.pip-params-slot {
  margin-top: 4px;
  padding-top: 12px;
}

.pip-params-slot .pip-type-block {
  display: none;
}

.pip-params-slot .pip-type-block.is-params-visible {
  display: block;
}

.pip-zoom-bbox {
  display: flex;
  flex-direction: column;
  width: fit-content;
  max-width: 100%;
}

/* 画中画：不要用 max-width:100% 把高分辨率画布在布局里压窄，否则适应窗口会按「条子」尺寸算缩放，预览变得极小 */
.pip-app-body .pip-zoom-bbox,
.edit-app-body .pip-zoom-bbox {
  max-width: none;
  /* 与 .pip-ruler-body：统一为 min(预览内容宽,高)*1%，由 pip.js / edit.js updatePreviewZoom 写入 --pip-ruler-gap */
  gap: var(--pip-ruler-gap, 8px);
}

.pip-app-body .pip-canvas-stack {
  max-width: none;
  overflow: visible;
  border-radius: var(--pip-out-corner, 0px);
  background: transparent;
}

.pip-app-body .pip-canvas-stack:not([hidden]) {
  box-shadow: var(--shadow-canvas);
}

.pip-app-body .pip-canvas,
.edit-app-body .pip-canvas {
  max-width: none;
  cursor: default;
}

.pip-wm-preview {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 4px;
}

.pip-wm-thumb {
  display: block;
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f8fafc;
}

.pip-wm-open-btn {
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.pip-wm-open-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.pip-dialog {
  padding: 0;
  border: none;
  border-radius: 14px;
  max-width: min(420px, 92vw);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
}

.pip-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.pip-dialog-panel {
  padding: 20px 20px 16px;
}

.pip-dialog-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.pip-dialog-hint {
  margin: 0 0 14px;
}

.pip-dialog-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.pip-dialog-actions.pip-image-wm-dialog-actions {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pip-dialog-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.pip-dialog-close-btn:hover {
  background: #f3f4f6;
}

.pip-ruler-top {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding-left: 40px;
  padding-bottom: 4px;
}

.pip-app-body .pip-ruler-top,
.edit-app-body .pip-ruler-top {
  padding-bottom: 0;
}

.pip-ruler-body {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
}

.pip-app-body .pip-ruler-body,
.edit-app-body .pip-ruler-body {
  gap: var(--pip-ruler-gap, 8px);
}

.pip-ruler-left {
  width: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.pip-dim-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  transform: scale(calc(1 / var(--pip-zoom, 1)));
  transform-origin: center center;
}

.pip-dim-label--vert {
  writing-mode: vertical-rl;
  transform: rotate(180deg) scale(calc(1 / var(--pip-zoom, 1)));
  transform-origin: center center;
  white-space: nowrap;
}

.pip-card-slot {
  flex: 1;
  /* 勿用 min-width:0，否则 flex 会把槽压窄，画布 max-width:100% 跟缩成条，缩放显示异常 */
  min-width: auto;
  min-height: 0;
}

/* 画中画页：系统中文栈。外链 @fontsource 在部分环境下 MIME 为 text/plain 会被浏览器拒绝加载。 */
.pip-app-body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

/* 与 .preview-bottom-bar 同 right inset；fixed 不随画布 transform 缩放 */
.pip-app-body .pip-layer-strip-host {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  top: calc(84px + env(safe-area-inset-top, 0px));
  bottom: auto;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 10px;
  max-width: min(200px, 32vw);
  max-height: min(calc(100vh - 120px), 480px);
  padding: 5px 5px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.pip-app-body .pip-layer-strip-host[hidden] {
  display: none !important;
}

.pip-layer-strip-head {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 0 0 0px;
}

.pip-layer-strip-hist {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.pip-layer-strip-hist-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  color: #6b7280;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.pip-layer-strip-hist-btn:hover:not(:disabled) {
  background: rgba(15, 23, 42, 0.1);
  color: #374151;
}

.pip-layer-strip-hist-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.pip-layer-strip-hist-icon {
  display: block;
  width: 20px;
  height: 20px;
}

.pip-layer-strip-title {
  flex: 1;
  min-width: 0;
}

.pip-layer-strip-group-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  color: #64748b;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.pip-layer-strip-group-btn:hover {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
}

.pip-layer-strip-group-btn .pip-group-svg {
  display: block;
}

.pip-layer-strip-group-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.pip-layer-strip-group-btn .pip-ungroup-svg {
  display: block;
}

.pip-layer-strip-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  color: #6b7280;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, transform 0.18s ease;
}

.pip-layer-strip-toggle:hover {
  background: rgba(15, 23, 42, 0.1);
  color: #374151;
}

.pip-layer-strip-toggle-icon {
  display: block;
  transition: transform 0.2s ease;
}

.pip-layer-strip-host.is-collapsed .pip-layer-strip-toggle-icon {
  transform: rotate(-90deg);
}

.pip-layer-strip-host.is-collapsed .pip-layer-strip-body {
  display: none;
}

.pip-layer-strip-hint {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.25;
  padding: 0 2px;
  opacity: 0.9;
}

.pip-layer-strip-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.pip-layer-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}

.pip-sub-fields.is-muted {
  opacity: 0.45;
  pointer-events: none;
}

.pip-strip-chip {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 7px 8px 7px 6px;
  border-radius: 9px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.92);
  cursor: grab;
  user-select: none;
  transition: border-color 0.12s, background 0.12s;
}

.pip-strip-chip.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.pip-strip-chip:active {
  cursor: grabbing;
}

.pip-strip-chip.is-dragging {
  opacity: 0.75;
}

.pip-strip-chip-grip {
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
  color: #9ca3af;
  letter-spacing: -1px;
  padding: 0 2px;
}

.pip-strip-chip-label {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pip-strip-chip.is-selected .pip-strip-chip-label {
  color: var(--accent);
}

.pip-strip-chip-actions {
  flex-shrink: 0;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 1px;
}

.pip-strip-chip-del {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.pip-strip-chip-del:hover {
  background: #fef2f2;
  color: #b91c1c;
}

.pip-strip-chip-del .pip-trash-svg {
  width: 16px;
  height: 16px;
}

.pip-strip-chip-dup {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.pip-strip-chip-dup:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.pip-strip-chip-dup .pip-dup-svg {
  width: 16px;
  height: 16px;
}

.pip-strip-chip.is-grouped .pip-strip-chip-label {
  color: var(--pip-group-accent, #2563eb);
  font-weight: 600;
}

.pip-strip-chip.is-grouped {
  box-shadow: inset 3px 0 0 0 var(--pip-group-accent, #2563eb);
}

.pip-strip-chip.is-grouped.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 0 var(--pip-group-accent, #2563eb);
}

.pip-asset-fill-extra-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pip-grad-fill-clear-btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
  color: #475569;
}

.pip-grad-fill-clear-btn:hover {
  background: #f1f5f9;
}

.pip-type-add-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.pip-type-add-btn {
  margin: 0;
  box-sizing: border-box;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.pip-type-add-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.pip-type-add-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.pip-type-add-btn.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22);
}

.pip-type-add-btn.is-selected:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.28);
}

.pip-layer-panel + .pip-layer-panel {
  margin-top: 4px;
}

.pip-type-hint.pip-type-hint--below-gap {
  margin-bottom: calc(var(--sidebar-block-gap) + 10px);
}

.pip-freepos-chk {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pip-param-mod {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.pip-param-mod:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.pip-param-mod-hd {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.pip-pos-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
}

.pip-pos-field .field-label {
  display: block;
  margin-top: 10px;
  margin-bottom: 6px;
  width: 100%;
  text-align: left;
}

.pip-pos-toggle.mode-toggle {
  width: 100%;
  max-width: 100%;
}

.pip-pos-toggle .pip-pos-mode-btn {
  min-width: 0;
  font-size: 12px;
  padding: 8px 4px;
  line-height: 1.25;
}

.pip-sub-fields[hidden] {
  display: none !important;
}

.pip-app-body .pip-color-row input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.pip-app-body .pip-color-row .color-row {
  width: 100%;
}

/* 与右侧固定图层条留白总量不变，左右对称，避免适应窗口后画布视觉偏左 */
.pip-app-body .canvas-shell.pip-has-base-canvas {
  padding-top: 22px;
  padding-bottom: 22px;
  padding-left: calc(22px + (min(200px, 32vw) + 6px) / 2);
  padding-right: calc(22px + (min(200px, 32vw) + 6px) / 2);
}

.pip-app-body .pip-layer-strip-host {
  right: calc(28px + env(safe-area-inset-right, 0px));
  background: rgba(255, 255, 255, 0.96);
}

.pip-anchor-field-plain {
  margin-bottom: 0;
}

.pip-anchor-group:not(.is-disabled) .pip-anchor-grid {
  max-width: min(100%, 300px);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding: 4px 6px;
  gap: 3px;
}

.pip-anchor-group:not(.is-disabled) .pip-anchor-btn {
  min-height: 24px;
  padding: 3px 2px;
  font-size: 10px;
}

.pip-anchor-group:not(.is-disabled) .pip-anchor-spacer {
  min-height: 24px;
}

.pip-color-row .bg-presets {
  margin-bottom: 8px;
}

.pip-mat-shadow-block.is-shadow-locked {
  opacity: 0.5;
  pointer-events: none;
}

.pip-mat-shadow-block.is-shadow-locked .pip-sub-fields {
  pointer-events: none;
}

.pip-text-select {
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.pip-selection-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
  border-radius: inherit;
}

.pip-selection-layer.is-multi .pip-sel-handle {
  display: none;
}

.pip-selection-box {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  box-sizing: border-box;
}

.pip-sel-frame {
  position: absolute;
  inset: 0;
  border: 1.5px solid rgba(59, 130, 246, 0.45);
  border-radius: 9px;
  box-sizing: border-box;
  pointer-events: none;
}

.pip-sel-handle {
  position: absolute;
  width: 11px;
  height: 11px;
  margin: 0;
  padding: 0;
  border: 1.5px solid rgba(37, 99, 235, 0.9);
  border-radius: 2px;
  background: #fff;
  box-sizing: border-box;
  pointer-events: auto;
  cursor: nwse-resize;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.pip-sel-handle--nw {
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}

.pip-sel-handle--ne {
  top: 0;
  left: 100%;
  transform: translate(-50%, -50%);
  cursor: nesw-resize;
}

.pip-sel-handle--sw {
  top: 100%;
  left: 0;
  transform: translate(-50%, -50%);
  cursor: nesw-resize;
}

.pip-sel-handle--se {
  top: 100%;
  left: 100%;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}

/* 画中画：色值复制、水印模式等共用浮动气泡 */
.imgprocess-floating-toast {
  padding: 10px 16px;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow:
    0 4px 14px rgba(15, 23, 42, 0.08),
    0 1px 3px rgba(15, 23, 42, 0.06);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.pip-wm-mode-bubble {
  position: fixed;
  z-index: 80;
  max-width: 240px;
  transform: translateY(6px);
}

.pip-wm-mode-bubble.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* —— 图标制作 icon —— */
.icon-hint {
  margin-top: 0;
}

.icon-secondary-block {
  margin-top: var(--sidebar-block-gap);
}

.panel-title--sub {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.icon-mode-toggle {
  gap: 6px;
}

.icon-mode-toggle .mode-btn {
  flex: 1 1 calc(50% - 3px);
  min-width: 72px;
}

.mode-toggle--compact {
  flex-wrap: nowrap;
}

.mode-toggle--compact .mode-btn {
  flex: 1;
  padding: 7px 4px;
  font-size: 11px;
}

.icon-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: var(--sidebar-block-gap);
}

.icon-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.icon-chip input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.icon-preset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-mini-btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 10px;
  font-size: 11px;
}

.icon-logo-text-block {
  margin-top: var(--sidebar-block-gap);
  padding-top: var(--sidebar-block-gap);
  border-top: 1px dashed var(--border);
}

/* 跨页导航 / 颜色历史（nav-handoff.js） */
#imgprocessColorRailHost.imgprocess-color-rail {
  position: absolute;
  left: 16px;
  bottom: 68px;
  z-index: 31;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  max-height: min(calc(100vh - 200px), 420px);
  width: 36px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  overflow-y: auto;
  overflow-x: hidden;
}

#imgprocessColorRailHost[hidden] {
  display: none !important;
}

.imgprocess-color-rail-swatch {
  flex-shrink: 0;
}

.imgprocess-copy-toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  z-index: 10000;
  transform: translateX(-50%) translateY(6px);
}

.imgprocess-copy-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.imgprocess-nav-cross-dialog .imgprocess-nav-cross-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* —— icon / stitch 等：竖屏触摸窄屏由 js/tool-rot.js 旋转根容器（与首页 home-rot 同思路）；body 加 .pich-tool-page —— */
.pich-tool-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* flex-basis 0% + max-height 100%：主区高度被父级锁死；勿写 height:auto 以免部分内核算不出侧栏滚动高度 */
.pich-tool-view > .app {
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  max-height: 100%;
  overflow: hidden;
  align-items: stretch;
}

html:has(body.pich-mobile-rot) {
  overflow: hidden;
  height: 100%;
}

body.pich-tool-page.pich-mobile-rot {
  display: block;
  overflow: hidden;
  min-height: 0;
  height: auto;
  max-height: none;
  min-height: 100vh;
  min-height: 100dvh;
  --sidebar-pad-x: 12px;
  --sidebar-pad-y: 14px;
  --sidebar-section-gap: 16px;
  --sidebar-block-gap: 11px;
}

body.pich-tool-page.pich-mobile-rot .pich-tool-view .sidebar {
  min-width: 0;
  /* 宽度由 js/tool-rot.js 写 --pich-rot-sidebar-w（≈ 视口高/4）；未写入前用 25dvh 近似 */
  width: var(--pich-rot-sidebar-w, 25dvh);
  flex: 0 0 var(--pich-rot-sidebar-w, 25dvh);
  flex-shrink: 0;
  align-self: stretch;
  min-height: 0;
  position: relative;
  z-index: 6;
}

body.pich-tool-page.pich-mobile-rot .pich-tool-view .sidebar > .pich-sidebar-scroll {
  overflow-y: scroll;
  /* 由 tool-rot 捕获 touch 滚动手感；勿与浏览器纵向手势抢 pan-y，否则发涩 */
  touch-action: none;
  overscroll-behavior-y: contain;
}

body.pich-tool-page.pich-mobile-rot .pich-tool-view {
  position: fixed;
  top: 0;
  left: 0;
  transform-origin: top left;
  max-width: none;
  max-height: none;
}

/* 画布区与顶栏贴边，点阵铺满主列 */
body.pich-tool-page.pich-mobile-rot .preview-wrap {
  padding: 0;
}

body.pich-tool-page.pich-mobile-rot .canvas-shell:not(.is-empty) {
  padding: 12px 8px 14px 8px;
}

/* 假横屏：与问候 .placeholder 同字色/字号/居中，仅加粗（由 tool-rot.js 插在 #placeholder 后） */
body.pich-tool-page.pich-mobile-rot .pich-rot-canvas-hint {
  margin: 0;
  padding: 0;
  text-align: center;
  font-size: 14px;
  line-height: normal;
  color: var(--text-muted);
  font-weight: 700;
}

body.pich-tool-page.pich-mobile-rot .preview-toolbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 8px;
  padding: 2px 4px 6px;
}

body.pich-tool-page.pich-mobile-rot .preview-toolbar-left {
  flex-wrap: nowrap;
  gap: 4px 6px;
  min-width: 0;
}

body.pich-tool-page.pich-mobile-rot .preview-zoom-slider-host {
  max-width: 160px;
  flex: 1 1 44px;
}

body.pich-tool-page.pich-mobile-rot .preview-toolbar-label {
  display: none;
}

body.pich-tool-page.pich-mobile-rot .upload-zone {
  min-height: 88px;
  padding: 10px;
}

body.pich-tool-page.pich-mobile-rot .upload-zone--compact {
  min-height: 0;
}

body.pich-tool-page.pich-mobile-rot .preview-toolbar .preview-zoom-slider-host #zoomSlider {
  width: 100%;
  min-width: 0;
}

body.pich-tool-page.pich-mobile-rot .btn-zoom-fit,
body.pich-tool-page.pich-mobile-rot .btn-zoom-reset {
  padding: 3px 6px;
  font-size: 11px;
}

body.pich-tool-page.pich-mobile-rot .tool-nav-capsule {
  gap: 0;
  padding: 2px;
}

body.pich-tool-page.pich-mobile-rot .tool-nav-pill {
  padding: 4px 7px;
  font-size: 11px;
}
