/* ============================================================
   PLANO · 产品陈列台规划 — 全局样式
   美学方向：暖色展厅 / 编辑台感 / 木纹 + 陶土 + 深青
   ============================================================ */

:root {
  --bg:        #f4eee2;   /* 页面暖纸色 */
  --bg-deep:   #ece3d2;
  --panel:     #fbf8f1;
  --panel-2:   #f3ecdd;
  --ink:       #2b2a26;
  --ink-2:     #55503f;   /* 第二层级文字 */
  --muted:     #8a8271;   /* 弱化文字 */
  --line:      #e4dac6;
  --line-soft: #ece3d1;
  --accent:    #c96f4a;   /* 陶土橙 */
  --accent-soft: #f6e4d8;
  --teal:      #3f5a54;   /* 深青 */
  --danger:    #b0452f;
  --shadow-1:  0 1px 2px rgba(60,45,20,.06), 0 4px 14px rgba(60,45,20,.07);
  --shadow-pop: 0 4px 10px rgba(60,45,20,.1), 0 22px 52px rgba(60,45,20,.22);

  --font-display: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Menlo", "Cascadia Mono", monospace;

  --topbar-h: 60px;
  --editbar-h: 46px;
  --status-h: 34px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

/* 移动端视口高度：iOS Safari 的地址栏收/放会改变 visual viewport，
   100% 会导致舞台高度跳变（进而触发 resize → zoom.apply() 重排）。
   dvh 跟随动态视口，@supports 保证老 Safari 回落到 100%。 */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

img { -webkit-user-drag: none; user-select: none; }
#stage { user-select: none; -webkit-user-select: none; }
/* iOS 点击深色元素默认会闪一块半透明灰底，去掉 */
a, button, .tab-pill, .combo, input, label { -webkit-tap-highlight-color: transparent; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 细滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d6cbb4; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #c3b595; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 顶部导航 ============ */
#topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: linear-gradient(180deg, #fbf8f1, #f6efe1);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
  box-shadow: 0 1px 0 rgba(60,45,20,.03);
}

.brand { display: flex; align-items: center; gap: 11px; user-select: none; }

.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--ink);
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 7px; flex: 0 0 auto;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,.25), 0 2px 5px rgba(43,42,38,.3);
}
.brand-mark i { border-radius: 2.5px; background: #f4efe6; }
.brand-mark i:nth-child(1) { background: var(--accent); }
.brand-mark i:nth-child(4) { background: var(--teal); }

.brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 19px;
  letter-spacing: 3.5px; color: var(--ink);
}
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: 1.6px; }

/* Tab 导航 */
#tab-nav {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  overflow-x: auto; scrollbar-width: none; padding: 3px 0;
}
#tab-nav::-webkit-scrollbar { display: none; }

.tab-pill {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  background: transparent;
  border: 1px solid transparent;
  transition: all .18s ease;
  white-space: nowrap;
}
.tab-pill .tab-count {
  font-family: var(--font-mono); font-size: 10px;
  background: rgba(0,0,0,.07); border-radius: 999px; padding: 1px 6px;
  color: var(--muted);
}
.tab-pill:hover { background: rgba(255,255,255,.6); color: var(--ink); }
.tab-pill.on {
  background: var(--ink); color: #f7f1e4;
  box-shadow: 0 2px 8px rgba(43,42,38,.28);
}
.tab-pill.on .tab-count { background: rgba(255,255,255,.16); color: #e8dfc9; }
.tab-pill .tab-del {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  font-size: 12px; line-height: 15px; text-align: center; color: inherit; opacity: .7;
}
.tab-pill .tab-del:hover { opacity: 1; background: rgba(0,0,0,.12); }
.tab-pill.on .tab-del:hover { background: rgba(255,255,255,.2); }
body.mode-edit .tab-pill .tab-del { display: inline-block; }

/* 右侧操作区 */
.header-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

.zoom-ctl {
  display: flex; align-items: center;
  background: rgba(255,255,255,.65);
  border: 1px solid var(--line);
  border-radius: 12px; padding: 3px;
  box-shadow: var(--shadow-1);
}
.z-btn, .z-scale {
  height: 30px; min-width: 30px; padding: 0 8px;
  border-radius: 9px; font-size: 15px; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.z-btn:hover { background: rgba(43,42,38,.08); color: var(--ink); }
.z-scale {
  font-family: var(--font-mono); font-size: 11.5px; min-width: 52px;
  color: var(--muted); cursor: pointer;
}
.z-scale:hover { color: var(--ink); }
.z-btn.z-fit { font-size: 13px; }
#zoom-ctl .z-btn:disabled { opacity: .35; pointer-events: none; }

.mode-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 12px;
  background: var(--accent); color: #fff;
  font-size: 13.5px; font-weight: 600;
  box-shadow: 0 2px 10px rgba(201,111,74,.35);
  transition: transform .15s ease, box-shadow .2s ease;
}
.mode-toggle:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(201,111,74,.45); }
.mode-toggle:active { transform: translateY(0); }
.mode-icon { font-size: 15px; }
body.mode-edit .mode-toggle {
  background: var(--teal);
  box-shadow: 0 2px 10px rgba(63,90,84,.35);
}

/* ============ 编辑工具条 ============ */
#editbar {
  height: var(--editbar-h);
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: var(--teal);
  color: #eef2e9;
  box-shadow: 0 2px 10px rgba(40,55,50,.25);
  z-index: 25;
}
.editbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.editbar-title { font-weight: 700; letter-spacing: 2px; font-size: 13px; flex: 0 0 auto; }
.editbar-hint { font-size: 12px; color: rgba(238,242,233,.62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.btn {
  padding: 7px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  transition: all .15s ease;
}
.btn.ghost { background: rgba(255,255,255,.12); color: #f2f0e6; }
.btn.ghost:hover { background: rgba(255,255,255,.22); }
.btn.ghost.danger:hover { background: rgba(255,150,120,.28); }
.btn.primary {
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.btn.primary.wide { width: 100%; justify-content: center; padding: 10px 14px; margin-bottom: 14px; }
.btn.primary:hover { background: #d87a52; transform: translateY(-1px); }
.btn.mini { padding: 5px 11px; font-size: 12px; border-radius: 8px; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); font-weight: 500; }
.btn.mini:hover { background: #efe6d3; color: var(--ink); }
.btn.danger-wide { width: 100%; background: var(--accent-soft); color: var(--danger); font-weight: 600; }
.btn.danger-wide:hover { background: #f0d6c8; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.dot.dirty { background: #ffd9a8; box-shadow: 0 0 0 3px rgba(255,217,168,.25); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ============ 主体布局 ============ */
#layout { flex: 1; display: flex; min-height: 0; }

.side-panel {
  flex: 0 0 auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 14px;
  z-index: 20;
}
#tab-panel { width: 252px; }
#edit-panel { width: 338px; border-right: none; border-left: 1px solid var(--line); }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; letter-spacing: 1.8px; color: var(--muted);
  margin-bottom: 10px;
}
.panel-head.sub { margin: 12px 0 8px; font-size: 11.5px; }
.icon-btn {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--panel-2); color: var(--ink-2); font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  transition: all .15s ease;
}
.icon-btn:hover { background: var(--ink); color: #f7f1e4; border-color: var(--ink); }

.tab-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.tab-list li {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 10px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
  transition: all .15s ease;
}
.tab-list li:hover { background: var(--panel-2); }
.tab-list li.on { background: var(--ink); color: #f7f1e4; border-color: var(--ink); box-shadow: 0 2px 8px rgba(43,42,38,.25); }
.tab-list .tl-name { flex: 1; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-list .tl-combos { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.tab-list li.on .tl-combos { color: #c9c2ae; }
/* 行内操作按钮（上移 / 下移 / 删除）统一规格：
   18×18 盒保证三者热区一致，opacity .45 为常态弱化、hover 提亮 */
.tab-list .tl-move-up,
.tab-list .tl-move-down,
.tab-list .tl-del {
  flex: 0 0 auto;
  width: 18px; height: 18px; border-radius: 6px; font-size: 13px;
  color: inherit; opacity: .45;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity .15s ease, background .15s ease;
}
.tab-list .tl-move-up:hover,
.tab-list .tl-move-down:hover,
.tab-list .tl-del:hover { opacity: 1; background: rgba(0,0,0,.1); }
.tab-list li.on .tl-move-up:hover,
.tab-list li.on .tl-move-down:hover,
.tab-list li.on .tl-del:hover { background: rgba(255,255,255,.18); }

.panel-sec { padding: 12px 0; border-top: 1px dashed var(--line-soft); }
.panel-sec:first-of-type { border-top: none; padding-top: 0; }

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field input[type="text"], .field input[type="number"] {
  width: 100%; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff;
  font-size: 13px; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201,111,74,.14); outline: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-row .field { margin-bottom: 8px; }

.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; margin-bottom: 8px; }
.seg button {
  flex: 1; padding: 6px 0; border-radius: 7px; font-size: 12px; color: var(--muted); transition: all .15s ease;
}
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1); }

.ep-empty {
  text-align: center; color: var(--muted); font-size: 12.5px; line-height: 2;
  padding: 24px 14px; border: 1.5px dashed var(--line); border-radius: 14px;
}
.ep-empty p { margin-bottom: 14px; }

/* ---- 产品编辑卡片 ---- */
.prod-card {
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; padding: 10px; margin-bottom: 10px;
  box-shadow: var(--shadow-1);
}
.prod-top { display: flex; gap: 10px; margin-bottom: 8px; }
.prod-thumb {
  width: 62px; height: 62px; flex: 0 0 auto; border-radius: 10px;
  background: var(--panel-2); border: 1px dashed var(--line);
  overflow: hidden; cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s ease;
}
.prod-thumb:hover { border-color: var(--accent); }
.prod-thumb img { width: 100%; height: 100%; object-fit: cover; }
/* 不再支持本地上传（会写成 base64 撑爆 JSON），缩略图仅作预览 */
.prod-thumb.empty::after { content: "＋"; font-size: 20px; color: #b3a88f; }
.prod-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.prod-fields input {
  width: 100%; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line-soft);
  background: var(--panel); font-size: 12.5px; color: var(--ink);
}
.prod-fields input:focus { outline: none; border-color: var(--accent); }
.prod-meta { display: flex; justify-content: space-between; align-items: center; }
.prod-idx { font-family: var(--font-mono); font-size: 10px; color: #b3a88f; letter-spacing: 1px; }
.prod-del { color: var(--danger); font-size: 12px; opacity: .7; padding: 2px 6px; border-radius: 6px; }
.prod-del:hover { opacity: 1; background: var(--accent-soft); }

/* ---- 「桌面展示」开关（产品级别） ---- */
.switch {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  margin-left: auto; user-select: none;
}
.switch input { display: none; }
.switch .slider {
  width: 30px; height: 18px; border-radius: 999px; flex: 0 0 auto;
  background: #d6cbb4; position: relative;
  transition: background .2s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.15);
}
.switch .slider::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.28);
  transition: transform .2s cubic-bezier(.2,.8,.25,1);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(12px); }
.switch .switch-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* 隐藏产品的编辑卡片：缩略图灰化提示 */
.prod-card.off .prod-thumb img { filter: grayscale(.9); opacity: .4; }
.prod-card.off .prod-fields input { color: #b3a88f; }
.prod-card.off .switch-label { color: #c4b89e; }

/* ---- 产品图片链接行 ---- */
.prod-url { display: flex; gap: 6px; margin: 0 0 6px; }
.prod-url .pf-image {
  flex: 1; min-width: 0; width: 100%; padding: 6px 8px; border-radius: 7px;
  border: 1px solid var(--line-soft); background: var(--panel);
  font-size: 11.5px; color: var(--ink-2); font-family: var(--font-mono);
}
.prod-url .pf-image:focus { outline: none; border-color: var(--accent); }
.prod-url .prod-url-apply {
  flex: 0 0 auto; padding: 0 11px; border-radius: 7px;
  background: var(--teal); color: #fff; font-size: 11.5px;
  transition: background .15s ease;
}
.prod-url .prod-url-apply:hover { background: #2f4742; }

/* ---- 组合整体图：链接行 / 状态提示 / 按钮组 ---- */
.url-row { display: flex; gap: 6px; }
.url-row input {
  flex: 1; min-width: 0; width: 100%; padding: 6px 8px; border-radius: 7px;
  border: 1px solid var(--line-soft); background: var(--panel);
  font-size: 11.5px; color: var(--ink-2); font-family: var(--font-mono);
}
.url-row input:focus { outline: none; border-color: var(--accent); }
.url-hint { margin-top: 6px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.url-hint.ok { color: var(--teal); }
.url-hint.warn { color: var(--danger); }
.btn-row { display: flex; gap: 6px; margin-top: 8px; }
.btn-row .btn { flex: 0 0 auto; }

/* 组合面板内的独立开关：抵消 .switch 的 margin-left:auto */
.switch.row-switch { margin-left: 0; margin-bottom: 10px; }

/* 「纯白占位」开启时，整体图设置区置灰不可点 */
.field.is-disabled { opacity: .42; pointer-events: none; }

/* ---- 图片加载失败降级 ---- */
.prod-thumb img.img-dead, .combo-thumb img.img-dead,
.combo-fullimg img.img-dead { display: none; }
.img-fail-box { position: relative; }
.img-fail-box::after {
  content: "图片失效"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; letter-spacing: 1px; color: var(--danger);
  background: rgba(176,69,47,.07);
  border: 1px dashed rgba(176,69,47,.34); border-radius: inherit;
}

/* ============ 中央舞台 ============ */
#stage-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

#viewport {
  flex: 1; position: relative; overflow: hidden;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(circle at 1px 1px, rgba(138,130,113,.16) 1px, transparent 0) 0 0 / 26px 26px,
    linear-gradient(180deg, var(--bg), var(--bg-deep));
}
#viewport.dragging, #viewport.dragging .combo { cursor: grabbing; }

/* ---- 陈列桌 ---- */
#stage {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 0;
  will-change: transform;
  border-radius: 16px;
  background: #c9a576;
  box-shadow:
    inset 0 2px 14px rgba(0,0,0,.14),
    0 10px 28px rgba(80,60,30,.22),
    0 2px 6px rgba(80,60,30,.16);
  outline: 6px solid rgba(120,90,50,.14);
  overflow: visible;
}
#stage.bg-wood {
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.028) 0 2px, transparent 2px 30px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0 1px, transparent 1px 7px),
    linear-gradient(115deg, #d6b786 0%, #c9a576 55%, #bd915f 100%);
}
#stage.bg-none { background: #ece3d1; outline-color: rgba(120,90,50,.10); }
#stage.bg-image { background-size: cover; background-position: center; }

/* 桌面标牌（左下角名称牌） */
.stage-plaque {
  position: absolute; left: 14px; bottom: 12px;
  background: rgba(43,42,38,.78); color: #f2ead8;
  font-size: 12px; letter-spacing: 2px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px;
  pointer-events: none; white-space: nowrap;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  z-index: 2;
}

/* 桌面真实尺寸标注（右上角，10px = 1cm） */
.stage-size {
  position: absolute; right: 14px; top: 12px;
  font-family: var(--font-mono); font-size: 11px;
  color: rgba(43,42,38,.55);
  background: rgba(255,255,255,.35);
  border: 1px solid rgba(43,42,38,.14);
  padding: 4px 10px; border-radius: 999px;
  pointer-events: none; white-space: nowrap;
  backdrop-filter: blur(3px);
  letter-spacing: .5px;
  z-index: 2;
}

/* 台面中缝：沿长边或垂直分割桌面（Apple Store 双台面拼接缝） */
#stage .split-line {
  position: absolute; z-index: 1; pointer-events: none;
}
#stage .split-line.long {
  border-top: 2px solid rgba(43,42,38,.42);
  box-shadow: 0 1px 0 rgba(255,255,255,.3), 0 -1px 0 rgba(0,0,0,.06);
}
#stage .split-line.across {
  border-left: 2px solid rgba(43,42,38,.42);
  box-shadow: 1px 0 0 rgba(255,255,255,.3), -1px 0 0 rgba(0,0,0,.06);
}
/* 中缝两端的小圆点装饰（拼接台面螺孔感） */
#stage .split-line.long::before,
#stage .split-line.long::after {
  content: ""; position: absolute; top: -3px;
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(43,42,38,.5);
  box-shadow: 0 0 0 2px rgba(255,255,255,.28);
}
#stage .split-line.long::before { left: 12px; }
#stage .split-line.long::after { right: 12px; }

/* ---- 组合 ---- */
.combo {
  position: absolute;
  border-radius: 12px;
  padding: 7px;
  /* 纵向流式：图片区自适应占满，标签区由内容决定（统一预留 2 行） */
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255,253,247,.72);
  border: 1.5px solid rgba(43,42,38,.14);
  box-shadow: 0 1px 3px rgba(60,45,20,.08);
  transition: box-shadow .2s ease, border-color .2s ease, background .2s ease;
  cursor: pointer;
}
.combo:hover {
  background: rgba(255,253,247,.92);
  box-shadow: 0 4px 14px rgba(60,45,20,.16);
  border-color: rgba(43,42,38,.3);
}
/* 拖拽 / 缩放进行中：冻结卡片过渡与阴影重绘，避免与 transform 抢帧。
   注意 .combo 上原有的 backdrop-filter 会让每张卡片在缩放时逐帧重算模糊，
   已移除，改用更实的半透明底色来保持观感。 */
body.interacting .combo {
  transition: none;
  box-shadow: 0 1px 3px rgba(60,45,20,.08);
}
body.interacting .combo:hover {
  background: rgba(255,253,247,.72);
  box-shadow: 0 1px 3px rgba(60,45,20,.08);
  border-color: rgba(43,42,38,.14);
}

.combo-body {
  display: flex; gap: 6px;
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}
.combo-thumb {
  flex: 1 1 0; min-width: 0; border-radius: 8px; overflow: hidden;
  background: #fff; position: relative;
  box-shadow: 0 1px 2px rgba(60,45,20,.1);
}
.combo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.combo-thumb.empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #b3a88f; letter-spacing: 1px;
}
.combo-thumb .thumb-more {
  position: absolute; right: 4px; bottom: 4px;
  background: rgba(43,42,38,.72); color: #fff;
  font-size: 9.5px; padding: 2px 6px; border-radius: 999px;
  font-family: var(--font-mono);
}
/* 组合整体图模式：桌面只显示一张完整组合照片 */
.combo-fullimg {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 8px; overflow: hidden;
  background: #fff;
  pointer-events: none;
}
/* 组合整体图是放大查看的主体，单独提升为合成层，缩放时直接由 GPU 采样，
   无需每帧重新栅格化整张舞台。缩略图不提升，避免层数过多。 */
.combo-fullimg img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  backface-visibility: hidden;
  transform: translateZ(0);
}
/* ---- 表带托盘模式（combo.layout = 'bandTray'） --------------------------
   直接渲染 products 的 Apple png-alpha 直链：每条占一个等分槽位，
   槽位等高 → 所有图片盒子同尺寸 → 内容自然底对齐（Apple 表带图取景一致）。
   图片按「容器宽度优先、高度兜底」等比缩放，5 条 / 10 条共用同一托盘尺寸。 */
.combo-tray {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: space-evenly;
  gap: 2px;
  padding: 2px 3px 0;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, .55);
  pointer-events: none;
}
.tray-slot {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding-bottom: 1px;
}
/* 图区占满剩余高度，图片在其中「高度优先、宽度兜底」等比缩放并底对齐 */
.tray-band {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}
/* 图片盒 = 整个槽位（槽宽 × 图区高），用 object-fit: contain 等比装入并底对齐。
   这样无论细长条（裁后比例 ~0.22）还是带扣特写（~0.76）都不会被拉伸变形
   （此前 height:100% + max-width 的组合会让宽图被拉伸、看起来又高又大）。 */
.tray-band img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}
.tray-band img.img-dead { display: none; }
.tray-size {
  flex: 0 0 auto;
  max-width: 100%;
  font-size: 10px;
  line-height: 12px;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combo-tray.dense .tray-size { font-size: 8.5px; line-height: 10px; }
.tray-empty {
  margin: auto;
  font-size: 10px;
  color: #b3a88f;
  letter-spacing: 1px;
}
/* 纯占位模式：纯白区域，无边框无标签 */
.combo.plain {
  background: #fff; border-color: transparent; box-shadow: none;
}
.combo.plain:hover { background: #fff; border-color: transparent; box-shadow: none; }
body.mode-edit .combo.plain { border-color: rgba(43,42,38,.25); border-style: dashed; }
/* 批量粘贴表带：多行输入框 */
#ep-bulk textarea {
  width: 100%;
  min-height: 58px;
  resize: vertical;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
#ep-bulk textarea:focus { border-color: var(--accent); }
#ep-bulk .btn-row { margin-top: 6px; }

/* 名称标签：最多 2 行自动换行；min-height 统一预留 2 行，保证各卡片图片区高度一致。
   超出 2 行仍按省略号截断，避免超长名把卡片撑爆。 */
.combo-label {
  flex: 0 0 auto;
  min-height: 30px;
  font-size: 11px; line-height: 15px; font-weight: 600; color: var(--ink-2);
  white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  pointer-events: none;
}

/* 编辑态组合 */
body.mode-edit .combo {
  cursor: move;
  border-style: dashed;
  background: rgba(255,253,247,.6);
}
body.mode-edit .combo:hover { border-color: rgba(201,111,74,.7); }
body.mode-edit .combo.selected {
  border-style: solid;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(201,111,74,.35), 0 6px 18px rgba(60,45,20,.18);
  background: rgba(255,253,247,.94);
}
body.mode-edit .combo .resize-handle {
  position: absolute; right: -7px; bottom: -7px;
  width: 15px; height: 15px; border-radius: 4px;
  background: var(--accent); border: 2px solid #fff;
  cursor: nwse-resize; display: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  z-index: 3;
}
body.mode-edit .combo.selected .resize-handle { display: block; }

/* ============ 状态栏 ============ */
#statusbar {
  height: var(--status-h); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  font-size: 11.5px; color: var(--muted);
  background: rgba(244,238,226,.9);
  border-top: 1px solid var(--line);
}
#statusbar .sb-right { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); }
#sb-scale { color: var(--ink-2); font-weight: 600; }

/* 数据来源徽标：让用户一眼看出当前显示的是共享数据还是本机编辑结果。
   换浏览器看到不同布局时，这里能直接解释原因，而不是让人以为页面坏了。 */
.sb-source {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-body); font-size: 10.5px; font-weight: 600;
  letter-spacing: .3px; white-space: nowrap;
  border: 1px solid transparent;
}
/* 线上共享数据 = 正常态（主数据源） */
.sb-source.src-remote { background: rgba(63,90,84,.1); color: var(--teal); border-color: rgba(63,90,84,.22); }
/* 本地备份文件 = 降级态（远程读不到，正在用兜底副本） */
.sb-source.src-file { background: rgba(176,138,47,.13); color: #8a6a1f; border-color: rgba(176,138,47,.3); }
/* 本机编辑未导出 = 需要提醒，线上看不到这份 */
.sb-source.src-local { background: rgba(201,111,74,.13); color: var(--accent); border-color: rgba(201,111,74,.3); }
/* 回退内置示例 = 异常态 */
.sb-source.src-builtin { background: rgba(176,69,47,.12); color: var(--danger); border-color: rgba(176,69,47,.3); }

/* ============ Toast ============ */
#toast {
  position: fixed; left: 50%; bottom: 54px; transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: #f5efdf;
  padding: 10px 20px; border-radius: 999px;
  font-size: 13px; box-shadow: var(--shadow-pop);
  z-index: 100; opacity: 0; pointer-events: none;
  transition: all .25s cubic-bezier(.2,.8,.25,1);
  max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 上传遮罩 ============ */
#uploading-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(43,42,38,.35); backdrop-filter: blur(3px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: #fff; font-size: 14px; font-weight: 600;
}
.spin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   响应式
   断点说明：860px 是「能否编辑」的分界，而非「是否手机」的分界。
   实测 820px（iPad 竖屏）在原布局下完全正常，因此保留 860 不上调。
   860 以下进入「只读模式」：隐藏管理模式入口与两侧编辑面板。
   ============================================================ */

/* 端别提示文案切换：默认（宽屏）显示 only-wide，窄屏由媒体查询反转 */
.only-narrow { display: none; }

@media (max-width: 1080px) {
  #tab-panel { width: 220px; }
  #edit-panel { width: 300px; }
  .brand-sub { display: none; }
  .editbar-hint { display: none; }
}

@media (max-width: 860px) {
  /* ---- 只读模式：移除编辑入口 ----
     侧栏在窄屏是 absolute 覆盖式且没有遮罩/关闭按钮（实测 220+300=520
     > 390 会把舞台遮死且两侧都点不到）。与其做一个半残的抽屉式编辑器，
     不如窄屏直接不给入口。 */
  .mode-toggle { display: none; }

  /* ---- 顶栏重排为两行 ----
     顶栏原本是 品牌 | Tab导航 | 缩放+模式 的单行 flex。在窄屏实测：
     375px 下「管理模式」右边缘超出视口约 58px（按钮被切、点不到），
     Tab 导航被压到不足 10px 宽（两张 Tab 都塞不下）。
     改为：第 1 行 品牌 + 缩放控件；第 2 行 Tab 胶囊独占整行横向滚动。 */
  #topbar {
    height: auto;                 /* 解除 --topbar-h:60px 的单行高度 */
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    row-gap: 0;
    padding: 7px 12px 0;
  }
  .brand {
    /* 品牌名是「这是哪个工具」的识别锚点，缩放控件让位 */
    flex: 1 1 auto;
    min-width: 0;
  }
  .brand-text { min-width: 0; }
  .brand-name { font-size: 17px; letter-spacing: 2.5px; }
  .header-actions { flex: 0 0 auto; }

  /* 缩放控件：这是窄屏上唯一的「显式缩放」入口（捏合对手指要求高），
     按钮放大到接近 44pt 触摸热区 */
  .zoom-ctl { padding: 2px; border-radius: 11px; }
  .z-btn, .z-scale { height: 38px; min-width: 38px; font-size: 17px; }
  .z-scale { min-width: 48px; font-size: 11px; }

  /* Tab 胶囊独占第二行：order 让它在 .header-actions 之后换行 */
  #tab-nav {
    order: 10;
    flex: 1 0 100%;
    margin-top: 6px;
    padding-bottom: 6px;
    gap: 6px;
  }
  .tab-pill { padding: 7px 13px; font-size: 13px; }

  /* ---- 触屏 hover 隔离 ----
     iOS Safari 的 :hover 会在点击后「粘住」直到点到别处，导致组合卡片 /
     Tab / 缩放按钮点完保持高亮态。这里把窄屏下的 hover 结果显式打回各自的
     常态值（与基础规则一致），而不是给 :hover 加 @media 包裹 ——
     后者要改动每条 hover 声明的物理位置，容易漏。 */
  .combo:hover { background: rgba(255,253,247,.72); box-shadow: 0 1px 3px rgba(60,45,20,.08); border-color: rgba(43,42,38,.14); }
  .combo.plain:hover { background: #fff; border-color: transparent; box-shadow: none; }
  .tab-pill:hover { background: transparent; color: var(--ink-2); }
  .tab-pill.on:hover { background: var(--ink); color: #f7f1e4; }
  .z-btn:hover { background: none; color: var(--ink-2); }
  .z-scale:hover { color: var(--muted); }

  /* ---- 状态栏窄屏精简 ---- */
  .only-wide { display: none; }
  .only-narrow { display: block; }
  #statusbar { padding: 0 12px; }
  #statusbar .sb-left {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* 窄屏优先显示缩放百分比；数据来源改为「有/无色点」隐晦提示，
     完整说明留在 title 里（长按/悬停可看） */
  #sb-source {
    font-size: 0; padding: 0; width: 8px; height: 8px;
    border-radius: 50%; border-width: 2px;
  }
  #sb-source::after { content: ""; font-size: 10px; }

  /* ---- 窄屏首屏引导 ---- */
  #mob-hint {
    position: fixed;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    z-index: 90;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 20px 26px;
    border-radius: 18px;
    background: rgba(43,42,38,.82);
    color: #f5efdf;
    font-size: 14px; font-weight: 600; letter-spacing: .5px;
    box-shadow: var(--shadow-pop);
    pointer-events: none;         /* 引导层不挡手势 */
    animation: mh-in .28s cubic-bezier(.2,.8,.25,1);
  }
  #mob-hint .mh-ico { font-size: 30px; line-height: 1; }
  #mob-hint .mh-txt { white-space: nowrap; }
  #mob-hint.out { animation: mh-out .25s ease forwards; }
}

/* 极窄屏（iPhone SE 一代 / 部分安卓机 ≤360px）：
   品牌名 + 缩放控件放不下同一行，会把顶栏挤成三行（实测 320px → 133px）。
   这里让品牌文字让位，保证第 1 行仍是「品牌标 + 缩放控件」。 */
@media (max-width: 360px) {
  .brand-name { font-size: 0; }              /* 保留 brand-mark 图标作为识别锚点 */
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .zoom-ctl { padding: 1px; }
  .z-btn, .z-scale { height: 34px; min-width: 34px; }
  .z-scale { min-width: 44px; }
  #mob-hint { padding: 16px 18px; font-size: 13px; }
  #mob-hint .mh-txt { font-size: 12.5px; }
}
@keyframes mh-in  { from { opacity: 0; transform: translate(-50%,-50%) scale(.92); } }
@keyframes mh-out { to   { opacity: 0; transform: translate(-50%,-50%) scale(.96); } }
