/* ============================================================
   Printora 定制设计器
   依赖 style.css 的品牌变量（--navy / --orange / --lav / --r …）
   ============================================================ */

.dsg {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--lav);
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶栏 ---------------- */
.dsg-top {
  flex: none;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px 0 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.dsg-back {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-2);
  background: var(--lav);
  transition: background .18s var(--ease), color .18s var(--ease);
}
.dsg-back:hover { background: var(--navy); color: #fff; }

.dsg-prod { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.dsg-prod img {
  width: 44px; height: 44px; border-radius: var(--bs-border-radius-sm);
  background: var(--lav); object-fit: contain; padding: 4px;
}
.dsg-prod__meta { display: flex; flex-direction: column; line-height: 1.25; }
.dsg-prod__meta b { font-size: 14px; color: var(--ink); font-weight: 700; }
.dsg-prod__meta span { font-size: 12px; color: var(--muted); }

.dsg-opts { display: flex; align-items: center; gap: 18px; flex: 1; min-width: 0; overflow: hidden; }
.dsg-opt { display: flex; align-items: center; gap: 7px; }
.dsg-opt__label { font-size: 12px; color: var(--muted); white-space: nowrap; }
/* 顶栏色板 / 规格选项：留出均匀间距，避免选项黏连 */
.dsg-sw-list { display: flex; align-items: center; gap: 10px; }
.dsg-pill-list { display: flex; align-items: center; gap: 8px; }
.dsg-sw {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line-2);
  cursor: pointer; transition: box-shadow .16s var(--ease), transform .16s var(--ease);
}
.dsg-sw:hover { transform: scale(1.1); }
.dsg-sw.is-active { box-shadow: 0 0 0 2px var(--orange); }
.dsg-pill {
  padding: 3px 11px; font-size: 12px; border-radius: var(--bs-border-radius-sm);
  border: 1px solid var(--line-2); color: var(--ink-2); background: #fff;
  cursor: pointer; transition: all .16s var(--ease);
}
.dsg-pill.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

.dsg-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.dsg-save { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-right: 4px; }
.dsg-save i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: block; }
.dsg-save.is-saving i { background: var(--warn); animation: dsgPulse 1s infinite; }
@keyframes dsgPulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.dsg-save em { font-style: normal; }

.dsg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--bs-border-radius-sm);
  background: #fff; color: var(--ink-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .16s var(--ease);
}
.dsg-btn:hover { border-color: var(--navy); color: var(--navy); }
.dsg-btn:disabled { opacity: .4; cursor: not-allowed; }
.dsg-btn .ic { width: 17px; height: 17px; }
.dsg-btn--primary {
  background: linear-gradient(180deg, #F79634, var(--orange));
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 22px -12px rgba(246, 137, 31, .9);
}
.dsg-btn--primary:hover { color: #fff; filter: brightness(1.04); }
.dsg-btn--block { width: 100%; justify-content: center; margin-bottom: 8px; }

/* ---------------- 主体三栏 ---------------- */
.dsg-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 76px 292px minmax(360px, 1fr) 372px;
}

/* 工具轨 */
.dsg-rail {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 10px 0;
  display: flex; flex-direction: column; gap: 2px;
}
.dsg-rail__btn {
  width: 100%; padding: 11px 4px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 0; background: none; color: var(--muted);
  font-size: 11px; cursor: pointer; position: relative;
  transition: color .16s var(--ease), background .16s var(--ease);
}
.dsg-rail__btn .ic { width: 21px; height: 21px; }
.dsg-rail__btn:hover { color: var(--navy); background: var(--lav); }
.dsg-rail__btn.is-active { color: var(--orange); }
.dsg-rail__btn.is-active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 var(--bs-border-radius-sm) var(--bs-border-radius-sm) 0; background: var(--orange);
}

/* 左侧面板 */
.dsg-panel { background: #fff; border-right: 1px solid var(--line); overflow-y: auto; }
.dsg-pane { display: none; padding: 18px 16px 28px; }
.dsg-pane.is-active { display: block; }
.dsg-pane__title { font-size: 14px; font-weight: 700; color: var(--ink); margin: 0 0 8px; }
.dsg-sub { font-size: 12px; font-weight: 700; color: var(--ink); margin: 20px 0 8px; letter-spacing: .02em; }
.dsg-pane__hint { font-size: 12px; line-height: 1.65; color: var(--muted); margin: 0 0 14px; }
.dsg-pane__hint--foot { margin: 14px 0 0; }

.dsg-drop {
  width: 100%; padding: 26px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1.5px dashed var(--line-2); border-radius: var(--bs-border-radius-sm);
  background: var(--lav); color: var(--ink-2);
  cursor: pointer; transition: all .18s var(--ease);
}
.dsg-drop:hover, .dsg-drop.is-over { border-color: var(--orange); background: var(--orange-100); }
.dsg-drop .ic { width: 26px; height: 26px; color: var(--orange); }
.dsg-drop b { font-size: 13px; }
.dsg-drop span { font-size: 11px; color: var(--muted); }

.dsg-recent { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.dsg-recent img {
  width: 56px; height: 56px; border-radius: var(--bs-border-radius-sm); object-fit: cover;
  border: 1px solid var(--line); cursor: pointer;
}

.dsg-primary-btn {
  width: 100%; height: 42px; border: 0; border-radius: var(--bs-border-radius-sm);
  background: var(--navy); color: #fff; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; transition: background .16s var(--ease);
}
.dsg-primary-btn:hover { background: var(--navy-600); }

.dsg-presets { display: grid; gap: 8px; margin-top: 14px; }
.dsg-preset {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--bs-border-radius-sm);
  background: #fff; cursor: pointer; text-align: left;
  transition: all .16s var(--ease);
}
.dsg-preset:hover { border-color: var(--orange); background: var(--orange-100); }
.dsg-preset b { display: block; font-size: 18px; line-height: 1.2; color: var(--ink); }
.dsg-preset span { font-size: 11px; color: var(--muted); }

.dsg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.dsg-chip {
  padding: 4px 11px; font-size: 12px; border-radius: var(--bs-border-radius-sm);
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2); cursor: pointer;
  transition: all .16s var(--ease);
}
.dsg-chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

.dsg-clipart { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dsg-clipart button {
  aspect-ratio: 1; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--bs-border-radius-sm); background: var(--lav);
  cursor: pointer; padding: 10px; transition: all .16s var(--ease);
}
.dsg-clipart button:hover { border-color: var(--orange); background: var(--orange-100); transform: translateY(-2px); }
.dsg-clipart img { width: 100%; height: 100%; object-fit: contain; filter: none; }

/* 图层列表 */
.dsg-layers { display: flex; flex-direction: column; gap: 2px; }
.dsg-layer {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px; border-radius: var(--bs-border-radius-sm); cursor: pointer;
  border: 1px solid transparent; transition: background .14s var(--ease);
}
.dsg-layer:hover { background: var(--lav); }
.dsg-layer.is-active { background: var(--orange-100); border-color: rgba(246, 137, 31, .4); }
.dsg-layer__thumb {
  width: 30px; height: 30px; border-radius: var(--bs-border-radius-sm); background: var(--lav-2);
  display: grid; place-items: center; flex: none; overflow: hidden;
  font-size: 13px; color: var(--ink-2); font-weight: 700;
}
.dsg-layer__thumb img { width: 100%; height: 100%; object-fit: contain; }
.dsg-layer__name { flex: 1; min-width: 0; font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dsg-layer__ico { width: 22px; height: 22px; border: 0; background: none; color: var(--muted-2); cursor: pointer; border-radius: var(--bs-border-radius-sm); display: grid; place-items: center; }
.dsg-layer__ico:hover { color: var(--navy); background: #fff; }
.dsg-layer__ico .ic { width: 15px; height: 15px; }

/* 舞台 */
.dsg-stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.dsg-tabs {
  flex: none; display: flex; gap: 6px; align-items: center;
  padding: 12px 18px 0; overflow-x: auto;
}
.dsg-tab {
  position: relative;
  padding: 7px 15px; border-radius: var(--bs-border-radius-sm);
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
  font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: all .16s var(--ease);
}
.dsg-tab:hover { border-color: var(--navy); }
.dsg-tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.dsg-tab__dot {
  position: absolute; top: 4px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--orange);
}
.dsg-tab.is-active .dsg-tab__dot { background: #ffd8ac; }

.dsg-stage__body {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  background-color: #EFF1F9;
  background-image: radial-gradient(rgba(32, 38, 111, .10) 1px, transparent 1px);
  background-size: 18px 18px;
}
.dsg-canvas-wrap { position: relative; box-shadow: 0 24px 60px -30px rgba(16, 19, 65, .55); border-radius: var(--bs-border-radius-sm); }
.dsg-canvas-wrap canvas { display: block; border-radius: var(--bs-border-radius-sm); cursor: default; }
.dtx-text-edit { position: absolute; z-index: 5; }

.dsg-empty {
  position: absolute; left: 0; right: 0; bottom: 28px;
  width: max-content; max-width: calc(100% - 48px); margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 18px; border-radius: var(--bs-border-radius-sm);
  background: rgba(16, 19, 65, .62); color: #fff;
  text-align: center; pointer-events: none;
  opacity: 0; transition: opacity .2s var(--ease);
}
.dsg-empty.is-on { opacity: 1; }
.dsg-empty b { font-size: 13px; color: #fff; }
.dsg-empty span { font-size: 12px; color: rgba(255, 255, 255, .78); }

.dsg-issues {
  flex: none; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 0 18px; min-height: 0; transition: all .2s var(--ease);
}
.dsg-issues:not(:empty) { padding: 10px 18px; }
.dsg-issue {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--bs-border-radius-sm); font-size: 12px;
  background: #FFF4E6; color: #9A5B00; border: 1px solid #FFE0B8;
}
.dsg-issue.is-error { background: #FDECEC; color: #A32D2D; border-color: #F7C1C1; }
.dsg-issue .ic { width: 14px; height: 14px; }

/* 右侧栏 */
.dsg-side {
  background: #fff; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.dsg-3d { flex: 1 1 46%; min-height: 220px; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
.dsg-3d__head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--ink);
}
.dsg-3d__head span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.dsg-3d__tools { display: inline-flex; align-items: center; gap: 6px; }
.dsg-side-close { display: none; font-size: 13px; line-height: 1; padding: 3px 8px; }
.dsg-3d__head .ic { width: 16px; height: 16px; color: var(--orange); }
.dsg-mini {
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
  font-size: 11px; padding: 3px 9px; border-radius: var(--bs-border-radius-sm); cursor: pointer;
}
.dsg-mini.is-on { background: var(--navy); border-color: var(--navy); color: #fff; }
.dsg-3d__view {
  flex: 1; min-height: 0; position: relative;
  background: radial-gradient(120% 90% at 50% 8%, #ffffff 0%, #EDEFF8 62%, #E1E5F4 100%);
  overflow: hidden; touch-action: none;
}
.dsg-3d__views { flex: none; display: flex; gap: 5px; padding: 8px 12px; justify-content: center; }
.dsg-3d__views button {
  flex: 1; padding: 6px 0; font-size: 11px; border-radius: var(--bs-border-radius-sm);
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2); cursor: pointer;
}
.dsg-3d__views button:hover { border-color: var(--navy); color: var(--navy); }
.d3d-fallback { position: absolute; inset: 0; display: grid; place-items: center; gap: 8px; padding: 16px; text-align: center; }
.d3d-fallback img { max-width: 70%; max-height: 72%; }
.d3d-fallback span { font-size: 11px; color: var(--muted); }

/* 2D 平面印面模式：无 3D 卡，属性面板占满右栏（.dsg-3d 已由 JS 隐藏） */
.dsg-side.is-flat .dsg-props { flex: 1 1 100%; }

/* 属性面板 */
.dsg-props { flex: 1 1 54%; overflow-y: auto; padding: 14px 16px 24px; }
.dsg-props__empty { font-size: 12px; color: var(--muted); line-height: 1.7; padding: 6px 0; }
.dsg-props__title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dsg-props__title b { font-size: 13px; color: var(--ink); }
.dsg-field { margin-bottom: 12px; }
.dsg-field > label { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.dsg-field > label em { font-style: normal; color: var(--ink-2); font-weight: 600; }
.dsg-field input[type="range"] { width: 100%; accent-color: var(--orange); }
.dsg-field select, .dsg-field input[type="text"], .dsg-field input[type="number"] {
  width: 100%; height: 34px; padding: 0 10px; font-size: 13px;
  border: 1px solid var(--line-2); border-radius: var(--bs-border-radius-sm); background: #fff; color: var(--ink);
}
.dsg-swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.dsg-swatches button {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line-2); cursor: pointer;
}
.dsg-swatches button.is-active { box-shadow: 0 0 0 2px var(--orange); }
/* 文字颜色：自定义取色器（彩虹色轮圆环 + 内芯当前色） */
.dsg-color-input {
  width: 24px; height: 24px; padding: 0; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line-2); cursor: pointer;
  background: conic-gradient(#F0705A, #F5C147, #2FB98B, #4A9FE8, #8B6FD4, #F0705A);
  transition: box-shadow .16s var(--ease), transform .16s var(--ease);
}
.dsg-color-input:hover { transform: scale(1.1); box-shadow: 0 0 0 2px var(--orange); }
.dsg-color-input::-webkit-color-swatch-wrapper { padding: 3px; }
.dsg-color-input::-webkit-color-swatch { border: none; border-radius: 50%; }
.dsg-color-input::-moz-color-swatch { border: none; border-radius: 50%; }
/* 文字面板：新文字颜色 */
.dsg-text-color-field { margin-top: 12px; }
.dsg-swatch-auto {
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--orange);
  background: conic-gradient(#fff 0 25%, #101341 0 50%, #fff 0 75%, #101341 0);
}
.dsg-seg { display: flex; gap: 4px; }
.dsg-seg button {
  flex: 1; height: 32px; font-size: 12px; border-radius: var(--bs-border-radius-sm);
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2); cursor: pointer;
}
.dsg-seg button.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.dsg-row { display: flex; gap: 6px; }
.dsg-row .dsg-btn { flex: 1; justify-content: center; height: 34px; font-size: 12px; }

.dsg-info-list { display: grid; gap: 8px; }
.dsg-info-row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; padding: 8px 10px; border-radius: var(--bs-border-radius-sm); background: var(--lav);
}
.dsg-info-row b { color: var(--ink); font-weight: 600; }
.dsg-info-row span { color: var(--muted); text-align: right; }
.dsg-note {
  margin-top: 12px; padding: 10px 12px; border-radius: var(--bs-border-radius-sm);
  background: var(--orange-100); color: #8A4B00; font-size: 12px; line-height: 1.6;
  border: 1px solid #FFE0B8;
}

/* Toast */
.dsg-toast-wrap { position: fixed; right: 20px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
.dsg-toast {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: var(--bs-border-radius-sm); background: var(--navy-900); color: #fff;
  font-size: 13px; box-shadow: 0 18px 40px -20px rgba(16, 19, 65, .8);
  animation: dsgToastIn .24s var(--ease);
}
.dsg-toast .ic { width: 16px; height: 16px; color: #7EE3A9; }
.dsg-toast.is-warn .ic { color: #FFC46B; }
@keyframes dsgToastIn { from { opacity: 0; transform: translateY(8px); } }

/* 3D 悬浮按钮（窄屏） */
.dsg-3d-toggle {
  display: none; position: fixed; right: 16px; bottom: 16px; z-index: 40;
  align-items: center; gap: 6px; padding: 10px 15px; border-radius: var(--bs-border-radius-sm);
  border: 0; background: var(--navy); color: #fff; font-size: 13px; font-weight: 600;
  box-shadow: 0 14px 30px -14px rgba(16, 19, 65, .9); cursor: pointer;
}
.dsg-3d-toggle .ic { width: 17px; height: 17px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1360px) {
  .dsg-main { grid-template-columns: 72px 264px minmax(320px, 1fr) 330px; }
}
@media (max-width: 1180px) {
  .dsg-main { grid-template-columns: 68px 250px minmax(300px, 1fr); }
  .dsg-side {
    position: fixed; right: 0; top: 0; bottom: 0; width: 340px; max-width: 88vw;
    z-index: 45; transform: translateX(102%); transition: transform .26s var(--ease);
    box-shadow: -20px 0 50px -30px rgba(16, 19, 65, .6);
  }
  .dsg-side.is-open { transform: none; }
  .dsg-3d-toggle { display: inline-flex; }
  .dsg-opts { display: none; }
  .dsg-side-close { display: inline-block; }
}
@media (max-width: 860px) {
  .dsg-main { grid-template-columns: 62px minmax(0, 1fr); }
  .dsg-panel {
    position: fixed; left: 62px; top: 0; bottom: 0; width: 268px; z-index: 44;
    transform: translateX(-130%); transition: transform .26s var(--ease);
  }
  .dsg-panel.is-open { transform: none; }
  .dsg-prod__meta span { display: none; }
  .dsg-save { display: none; }
}
/* 窄屏顶栏：允许换行，保证加购按钮始终可见 */
@media (max-width: 620px) {
  .dsg-top { flex-wrap: wrap; height: auto; min-height: 58px; padding: 8px 10px; row-gap: 8px; }
  .dsg-prod { min-width: 0; flex: 1; }
  .dsg-prod__meta b { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dsg-actions { margin-left: auto; }
  .dsg-btn { padding: 0 10px; }
  #dsgReset { display: none; }
}
