/* 换材预览 · 试用版 swap3 — 看图找料子模式 */
.sp-modebar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 0 0 14px; padding: 8px 10px; border-radius: 12px;
  background: linear-gradient(180deg, #f4f8fc, #eef3f8);
  border: 1px solid #d7e2ec;
}
.sp-modebar .sp-mode {
  border: 1px solid #c5d4e2; background: #fff; color: #2a3a4a;
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.sp-modebar .sp-mode.on {
  background: #1f6feb; color: #fff; border-color: #1f6feb;
  box-shadow: 0 1px 0 #1558c0;
}
.sp-modebar .sp-tag {
  margin-left: auto; font-size: 12px; color: #6a7a8a;
}
#spWorkspace.hidden, #vmMatchHost.hidden { display: none !important; }

.sp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.9fr);
  gap: 14px; align-items: start;
}
@media (max-width: 1080px) {
  .sp-layout { grid-template-columns: 1fr; }
}

.sp-stage-card { padding: 12px; }
.sp-stage-head {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px;
}
.sp-stage-head h3 { margin: 0; font-size: 15px; flex: 1; }
.sp-canvas-wrap {
  position: relative; background: #0f1720; border-radius: 10px;
  min-height: 320px; overflow: hidden; display: grid; place-items: center;
}
.sp-canvas-wrap canvas {
  max-width: 100%; max-height: 62vh; display: block; cursor: crosshair;
}
.sp-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #9aa8b6; text-align: center; padding: 24px; pointer-events: none;
}
.sp-empty.hidden { display: none; }
.sp-empty b { display: block; color: #d7e2ec; margin-bottom: 6px; }

.sp-side { display: flex; flex-direction: column; gap: 12px; }
.sp-zone { padding: 12px; }
.sp-zone h4 {
  margin: 0 0 8px; font-size: 13px; color: #334455;
  display: flex; align-items: center; gap: 6px;
}
.sp-zone h4 .sp-n {
  width: 18px; height: 18px; border-radius: 50%;
  background: #1f6feb; color: #fff; font-size: 11px;
  display: inline-grid; place-items: center;
}
.sp-hint { margin: 0; font-size: 12px; color: #6a7a8a; line-height: 1.45; }

.sp-sel-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px;
}
.sp-sel-meta span {
  background: #f5f8fb; border: 1px solid #e1e8ef; border-radius: 8px;
  padding: 6px 8px; font-size: 12px; color: #445566;
}

.sp-recent-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.sp-recent-head h4 { margin: 0; flex: 1; }
.sp-recent {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px; min-height: 84px;
}
.sp-recent-item {
  border: 1px solid #d7e2ec; border-radius: 10px; overflow: hidden;
  background: #fff; cursor: pointer; padding: 0; text-align: left;
}
.sp-recent-item.on { outline: 2px solid #1f6feb; border-color: #1f6feb; }
.sp-recent-item img {
  width: 100%; height: 56px; object-fit: cover; display: block; background: #eef2f6;
}
.sp-recent-item figcaption {
  font-size: 11px; padding: 4px 5px; color: #334455;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-recent-empty {
  grid-column: 1 / -1; font-size: 12px; color: #8a949e; padding: 18px 4px;
}

.sp-params {
  display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px;
}
.sp-params label {
  display: grid; grid-template-columns: 72px 1fr 42px; gap: 8px;
  align-items: center; font-size: 12px; color: #445566;
}
.sp-params input[type=range] { width: 100%; }
.sp-current {
  margin-top: 8px; padding: 8px 10px; border-radius: 8px;
  background: #f0f6ff; border: 1px solid #cfe0f7; font-size: 12.5px; color: #1f3b5c;
}

.sp-compare {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.sp-compare figure {
  margin: 0; border: 1px solid #e1e8ef; border-radius: 10px; overflow: hidden; background: #fff;
}
.sp-compare img, .sp-compare canvas {
  width: 100%; height: 140px; object-fit: contain; display: block; background: #0f1720;
}
.sp-compare figcaption {
  font-size: 11.5px; padding: 5px 8px; color: #556677; background: #f7fafc;
}
.sp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* 选石弹层内容（塞进既有 Modal） */
.sp-picker { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 0; min-height: 420px; }
.sp-picker-left {
  border-right: 1px solid #e1e8ef; display: flex; flex-direction: column; min-height: 0;
}
.sp-picker-search {
  padding: 8px; border-bottom: 1px solid #eef2f6;
}
.sp-picker-search input {
  width: 100%; box-sizing: border-box; border: 1px solid #c5d4e2;
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.sp-picker-list {
  overflow: auto; flex: 1; max-height: 420px; padding: 6px;
}
.sp-picker-item {
  width: 100%; text-align: left; border: 0; background: transparent;
  border-radius: 8px; padding: 8px 10px; cursor: pointer; display: block;
}
.sp-picker-item:hover { background: #f3f7fb; }
.sp-picker-item.on { background: #e8f1ff; }
.sp-picker-item b { display: block; font-size: 13px; color: #223344; }
.sp-picker-item small { color: #7a8a9a; font-size: 11.5px; }
.sp-picker-right { padding: 10px 12px; display: flex; flex-direction: column; min-height: 0; }
.sp-picker-right-h {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px;
}
.sp-picker-right-h b { font-size: 14px; }
.sp-picker-right-h span { font-size: 12px; color: #6a7a8a; }
.sp-picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px; overflow: auto; max-height: 380px; padding: 2px;
}
.sp-panel-card {
  border: 1px solid #d7e2ec; border-radius: 10px; overflow: hidden;
  background: #fff; cursor: pointer; padding: 0; text-align: left;
}
.sp-panel-card.on { outline: 2px solid #1f6feb; border-color: #1f6feb; }
.sp-panel-card img {
  width: 100%; height: 84px; object-fit: cover; display: block; background: #eef2f6;
}
.sp-panel-card figcaption {
  font-size: 11.5px; padding: 6px 7px; color: #334455; line-height: 1.35;
}
.sp-picker-foot-meta {
  font-size: 13px; color: #223344; margin-right: auto;
}
.sp-picker-empty {
  color: #8a949e; font-size: 13px; padding: 40px 12px; text-align: center;
}
#modal.sp-modal-wide { width: min(920px, 94vw); max-width: 94vw; }

.sp-compare-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 10px;
  align-items: stretch;
}
@media (max-width: 720px) {
  .sp-compare-row { grid-template-columns: 1fr; }
}
.sp-swatch {
  margin: 0;
  border: 1px solid #d7e2ec;
  border-radius: 10px;
  overflow: hidden;
  background: #0f1720;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.sp-swatch img {
  flex: 1;
  width: 100%;
  min-height: 160px;
  object-fit: cover;
  display: block;
  background: repeating-linear-gradient(45deg,#1a2330,#1a2330 8px,#152028 8px,#152028 16px);
}
.sp-swatch.has img { background: #111; }
.sp-swatch figcaption {
  font-size: 11.5px;
  line-height: 1.35;
  padding: 7px 8px;
  color: #d7e2ec;
  background: #1b2836;
}


/* swap3：下方全宽「原图 | 换后」结果区 */
.sp-result-card {
  margin-top: 14px;
  padding: 14px 14px 16px;
  scroll-margin-top: 72px;
}
.sp-result-card.has-result {
  border-color: #9ec0ea;
  box-shadow: 0 0 0 1px rgba(31,111,235,0.12);
}
.sp-result-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
}
.sp-result-head h3 { margin: 0; font-size: 15px; }
.sp-result-empty {
  margin: 0; padding: 28px 12px; text-align: center;
  font-size: 13px; color: #8a949e;
  background: #f7fafc; border: 1px dashed #d7e2ec; border-radius: 10px;
}
.sp-result-empty.hidden { display: none; }
.sp-result-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 900px) {
  .sp-result-row { grid-template-columns: 1fr; }
}
.sp-result-fig {
  margin: 0;
  border: 1px solid #d7e2ec;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.sp-result-canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #0f1720;
  cursor: zoom-in;
  max-height: 42vh;
  object-fit: contain;
}
.sp-result-fig figcaption {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  color: #334455;
  background: #f7fafc;
  border-top: 1px solid #eef2f6;
}
.sp-result-export {
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid #eef2f6;
  display: flex;
  gap: 8px;
}
.sp-swatch {
  margin: 10px 0 0;
  border: 1px solid #d7e2ec;
  border-radius: 10px;
  overflow: hidden;
  background: #0f1720;
  display: flex;
  flex-direction: column;
  min-height: 140px;
}
.sp-lightbox {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(8,12,18,0.86);
  display: none; place-items: center;
  padding: 24px;
}
.sp-lightbox.on { display: grid; }
.sp-lightbox img {
  max-width: min(96vw, 1400px);
  max-height: 86vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.45);
  background: #111;
}
.sp-lightbox-close {
  position: fixed; top: 16px; right: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: #fff; color: #223; font-size: 22px;
  cursor: pointer; line-height: 1;
}
.sp-lightbox-cap {
  position: fixed; bottom: 18px; left: 0; right: 0;
  text-align: center; color: #e8eef5; font-size: 14px; margin: 0;
}
