/* C59：共享「可拖动分割线」裁剪面板
   来源 = 画布 .cviewer 那套切割（canvas.js:12028 起），抽成独立组件给
   共享大图查看器 / 买家秀 / 主图换场景 / 画布 共用一份实现。
   观感跟画布一致：深色灯箱 + 青色分割线 + 金色选中态（C61 定的那套线样式）。 */

.sp-overlay {
  position: fixed;
  inset: 0;
  z-index: 10040; /* 要盖过共享查看器 .image-viewer(9999) */
  display: flex;
  flex-direction: column;
  background: rgba(6, 6, 10, 0.94);
  /* 面板内部固定「深底 + 浅字」，不跟随页面主题（跟画布查看器一个道理） */
  --sp-fill: rgba(255, 255, 255, 0.08);
  --sp-fill-hover: rgba(255, 255, 255, 0.18);
  --sp-line: rgba(255, 255, 255, 0.18);
  --sp-text: #e8e8ea;
  --sp-text-dim: #c9c9d2;
}

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

.sp-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--sp-text-dim);
  font-size: 12px;
}

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

.sp-tip {
  color: var(--sp-text-dim);
}

.sp-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--sp-line);
  border-radius: 8px;
  background: var(--sp-fill);
  color: var(--sp-text-dim);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.sp-close:hover {
  background: rgba(240, 80, 80, 0.85);
  border-color: #f05050;
  color: #fff;
}

.sp-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px 4px;
}

/* 图片与线层同框：线层 inset:0 正好压在图片上（不是压在整个舞台） */
/* C69：这里原来只有 display:flex + max-*，没写 align-items → flex 默认 stretch，
   加上 max-height:100% 拿到舞台高度后，<img> 被交叉轴拉满：2480×3312 显示成 1568×827。
   ★ 必须让 .sp-figure 与图片盒子严格同尺寸（线层是 inset:0 叠在 figure 上的），
     所以是「给确定高度 + 不 stretch + 宽高交给比例算」，**不是**只加 object-fit（那会让线切歪）。 */
.sp-figure {
  position: relative;
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

.sp-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.sp-crop {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

.sp-line {
  position: absolute;
  background: #22d3ee;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9), 0 0 6px rgba(34, 211, 238, 0.8);
  cursor: move;
  touch-action: none;
  z-index: 3; /* C67：线永远压在勾选层上面 */
}

.sp-line-x {
  top: 0;
  bottom: 0;
  width: 3px;
  margin-left: -1.5px;
}

.sp-line-y {
  left: 0;
  right: 0;
  height: 3px;
  margin-top: -1.5px;
}

.sp-line.is-selected {
  background: #fbbf24;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.95), 0 0 10px rgba(251, 191, 36, 0.9);
  z-index: 4; /* C67：选中 / 拖动中的线置顶（交点处不被另一条抢） */
}

.sp-line-x.is-selected {
  width: 4px;
  margin-left: -2px;
}

.sp-line-y.is-selected {
  height: 4px;
  margin-top: -2px;
}

.sp-cell {
  position: absolute;
  background: rgba(34, 211, 238, 0.22);
  border: 1px solid rgba(34, 211, 238, 0.9);
  pointer-events: none;
}

.sp-cell[hidden] {
  display: none !important;
}

/* ---------- C67：格子勾选层（pickable） ---------- */
.sp-picks {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.sp-picks[hidden] {
  display: none !important;
}
.sp-pick {
  position: absolute;
  border: 1px dashed rgba(255, 255, 255, 0.55);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.sp-pick.is-picked {
  background: rgba(34, 211, 238, 0.16);
}
.sp-pick:not(.is-picked) {
  background: rgba(0, 0, 0, 0.42);
}
.sp-pick-no {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 1px 7px;
}
.sp-pick-count {
  font-size: 12px;
  color: var(--brand-line, #A9EFA4);
  white-space: nowrap;
}

.sp-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px 16px;
}

.sp-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--sp-text-dim);
}

.sp-field input {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid var(--sp-line);
  border-radius: 6px;
  background: var(--sp-fill);
  color: var(--sp-text);
  font-family: inherit;
  font-size: 12px;
}

.sp-btn {
  padding: 6px 14px;
  border: 1px solid var(--sp-line);
  border-radius: 8px;
  background: var(--sp-fill);
  color: var(--sp-text-dim);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.sp-btn:hover:not(:disabled) {
  background: var(--sp-fill-hover);
}

.sp-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.sp-btn-primary {
  margin-left: auto;
  background: var(--brand, #71DC68);
  border-color: var(--brand-strong, #5BC85A);
  color: var(--brand-ink, #14331B);
  font-weight: 600;
}

.sp-btn-primary:hover:not(:disabled) {
  background: var(--brand-strong, #5BC85A);
}

.sp-msg {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: #fbbf24; /* 规则提示要显眼（如"缺少可合并的相邻区块"） */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .sp-bar {
    gap: 8px;
  }

  .sp-btn-primary {
    margin-left: 0;
  }
}

/* ==========================================================================
 * C60：画布 `.cviewer` 的切割线 / 格子高亮 —— 复用同一份样式（单一出处）
 *
 * 这几条原来在 canvas.css 里（C61 定的那套配色）。C60 把画布页也引上本文件后，
 * 线样式只此一份：改这里同时影响共享面板（.sp-*）与画布（.cviewer-*）。
 * 画布的**交互**没动（仍是 canvas.js 自己那套拖线/加线/删线/确认切割）。
 * ========================================================================== */
.cviewer-line {
  position: absolute;
  background: #22d3ee;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9), 0 0 6px rgba(34, 211, 238, 0.8);
  cursor: move;
}

.cviewer-line-x {
  top: 0;
  bottom: 0;
  width: 3px;
  margin-left: -1.5px;
}

.cviewer-line-y {
  left: 0;
  right: 0;
  height: 3px;
  margin-top: -1.5px;
}

.cviewer-line.is-selected {
  background: #fbbf24;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.95), 0 0 10px rgba(251, 191, 36, 0.9);
}

.cviewer-line-x.is-selected {
  width: 4px;
  margin-left: -2px;
}

.cviewer-line-y.is-selected {
  height: 4px;
  margin-top: -2px;
}

.cviewer-cell {
  position: absolute;
  background: rgba(34, 211, 238, 0.22);
  border: 1px solid rgba(34, 211, 238, 0.9);
  pointer-events: none;
}
