@import url('../vendor/fonts/fonts.css');
@import url('../vendor/fonts/cjk-r1.css'); /* 中文字体：按字分片，设计里用到哪片才下载哪片 */

:root {
  --s1: 8px; --s2: 12px; --s3: 16px; --s4: 24px; --s5: 32px;
  --f-xs: 10px; --f-sm: 12px; --f-md: 14px; --f-base: 16px; --f-lg: 20px; --f-xl: 24px;
  --lh-sm: 20px; --lh-md: 24px; --lh-base: 28px;

  --c-text: #1e2124;
  --c-text-mid: #494a4b;
  --c-text-lite: #767676;
  --c-line: #dfdbd3;
  --c-bg: #f4f1ec;
  --c-panel: #fbfaf7;
  --c-accent: #0e7a5f;     /* 唯一强调色：当前态、可生产 */
  --c-accent-soft: #e3f0eb;
  --c-warn: #a86a12;       /* 提醒 */
  --c-warn-soft: #f6ecd9;
  --c-danger: #d93a32;     /* 只给不能生产的问题 */
  --c-danger-soft: #f9e4e2;

  --r: 4px; --r-pill: 9999px;
  --ease-out: cubic-bezier(.215,.61,.355,1);
  --ease-in: cubic-bezier(.55,.055,.675,.19);
  --ease-mv: cubic-bezier(.645,.045,.355,1);
  --t-fast: 100ms; --t-mid: 250ms;
  --shadow: 0 1px 8px rgba(30,33,36,.10);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--c-bg); color: var(--c-text); font: var(--f-md)/var(--lh-md) var(--font); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* —— 按钮三档：实心主按钮 / 描边次按钮 / 文字链 —— */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--c-line); background: var(--c-panel); white-space: nowrap;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out); }
.btn:hover { border-color: var(--c-text-lite); background: #fff; }
.btn:active { transform: translate3d(0,1px,0); }
a.btn { text-decoration: none; color: var(--c-text); }
a.link { color: var(--c-text-mid); }
a.link:hover { color: var(--c-text); }
.btn.primary { background: var(--c-text); border-color: var(--c-text); color: #fff; font-weight: 500; }
.btn.primary:hover { background: #33373b; }
.btn.primary:disabled { background: #b9b6b0; border-color: #b9b6b0; cursor: not-allowed; }
.btn.small { height: 28px; padding: 0 10px; font-size: var(--f-sm); }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--c-text-mid); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--c-line); }
.link:hover { color: var(--c-text); text-decoration-color: currentColor; }

/* —— 顶栏 —— */
.top { height: 56px; display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s3); border-bottom: 1px solid var(--c-line); background: var(--c-panel); }
.brand { font-weight: 600; font-size: var(--f-base); display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 20px; height: 20px; border-radius: var(--r); background: #c7a27a; position: relative; }
.brand-mark::after { content: ''; position: absolute; left: 0; right: 0; top: 7px; height: 6px; background: #fff; }
.title-input { border: 1px solid transparent; background: transparent; border-radius: var(--r); padding: 4px 8px; width: 220px; color: var(--c-text-mid); }
.title-input:hover { border-color: var(--c-line); }
.title-input:focus { outline: none; border-color: var(--c-text-lite); background: #fff; color: var(--c-text); }
.spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--c-line); border-radius: var(--r-pill); padding: 2px; background: var(--c-bg); }
.seg button { border: 0; background: none; height: 28px; padding: 0 12px; border-radius: var(--r-pill); color: var(--c-text-mid); transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out); }
.seg button:hover { color: var(--c-text); background: rgba(255,255,255,.7); }
.seg button.on { background: var(--c-text); color: #fff; font-weight: 500; }
.seg-label { color: var(--c-text-lite); font-size: var(--f-sm); margin-right: 4px; }
.lang-seg button { height: 24px; padding: 0 8px; font-size: var(--f-sm); } /* 语言开关：中 / EN */
.check-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--c-line); background: var(--c-panel); font-weight: 500; }
.check-chip:hover { border-color: var(--c-text-lite); }
.check-chip.ok { color: var(--c-accent); border-color: var(--c-accent); background: var(--c-accent-soft); }
.check-chip.bad { color: var(--c-danger); border-color: var(--c-danger); background: var(--c-danger-soft); }
.check-chip.warn { color: var(--c-warn); border-color: #e2c48f; background: var(--c-warn-soft); }
.check-chip.busy { color: var(--c-text-mid); }

/* —— 三栏 —— */
.app { --left-w: 340px; --right-w: 400px; --viewer-h: 360px; display: grid; grid-template-columns: var(--left-w) minmax(0,1fr) var(--right-w); height: calc(100vh - 56px); }
.app.left-collapsed { --left-w: 0px; }
.app.left-collapsed .left, .app.left-collapsed .left-split { display: none; }
/* 三栏各占各的列：收起对话栏时只空出第一列，画布和右栏不跟着错位 */
.app > .left { grid-column: 1; } .app > .center { grid-column: 2; } .app > .right { grid-column: 3; }
.col-split.left-split { left: -3px; right: auto; }
.left-open { position: absolute; left: 0; top: 50%; z-index: 7; transform: translate3d(0,-50%,0); writing-mode: vertical-rl; letter-spacing: .2em; padding: 14px 6px; border: 1px solid var(--c-line); border-left: 0; border-radius: 0 var(--r) var(--r) 0; background: var(--c-panel); color: var(--c-text-mid); box-shadow: var(--shadow); transition: color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out); }
.left-open:hover { color: var(--c-text); background: #fff; }
.col-split { position: absolute; right: -3px; top: 0; bottom: 0; width: 6px; z-index: 9; cursor: col-resize; }
.col-split::after { content: ''; position: absolute; left: 2px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background var(--t-fast) var(--ease-out); }
.col-split:hover::after, .col-split.drag::after { background: var(--c-accent); }
.viewer-split { position: absolute; left: 0; right: 0; bottom: -4px; height: 8px; z-index: 6; cursor: row-resize; }
.viewer-split::after { content: ''; position: absolute; left: 50%; bottom: 3px; width: 40px; height: 3px; margin-left: -20px; border-radius: var(--r-pill); background: var(--c-line); transition: background var(--t-fast) var(--ease-out); }
.viewer-split:hover::after, .viewer-split.drag::after { background: var(--c-accent); }
body.resizing, body.resizing * { user-select: none !important; }
.col { min-height: 0; display: flex; flex-direction: column; }
.left { border-right: 1px solid var(--c-line); background: var(--c-panel); }
.right { border-left: 1px solid var(--c-line); background: var(--c-panel); overflow-y: auto; }
.center { position: relative; overflow: hidden; }

.panel { flex: none; border-bottom: 1px solid var(--c-line); padding: var(--s3); }
.panel-hd { display: flex; align-items: baseline; gap: 8px; margin-bottom: var(--s2); }
.panel-hd h3 { margin: 0; font-size: var(--f-md); font-weight: 600; }
.panel-hd .sub { color: var(--c-text-lite); font-size: var(--f-sm); }
.panel-hd .act { margin-left: auto; }

/* —— 对话 —— */
.chat-hd { padding: var(--s3); border-bottom: 1px solid var(--c-line); }
.chat-title { display: flex; align-items: center; gap: 8px; margin: -4px 0 6px; }
.chat-hd h2 { flex: 1; min-width: 0; margin: 0; font-size: var(--f-base); font-weight: 600; }
.scope { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--f-sm); color: var(--c-text-mid); }
.scope-chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); background: var(--c-accent-soft); color: var(--c-accent); font-weight: 500; }
.scope-chip button { border: 0; background: none; color: inherit; padding: 0; line-height: 1; font-size: var(--f-md); }
.chat-log { flex: 1; overflow-y: auto; padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.msg { max-width: 92%; padding: 8px 12px; border-radius: var(--r); line-height: 22px; white-space: pre-wrap; animation: rise var(--t-mid) var(--ease-out); }
.msg.user { align-self: flex-end; background: var(--c-text); color: #fff; }
.msg.ai { align-self: flex-start; background: #fff; border: 1px solid var(--c-line); }
.msg.sys { align-self: center; color: var(--c-text-lite); font-size: var(--f-sm); background: none; padding: 0; }
/* 每段对话一个容器；折起来的旧消息、要点卡、「对话 ▾」 */
.thread { display: flex; flex-direction: column; gap: var(--s2); }
.fold { align-self: stretch; border: 1px dashed var(--c-line); border-radius: var(--r); padding: 6px 10px; color: var(--c-text-lite); font-size: var(--f-sm); }
.fold > summary { cursor: pointer; list-style: none; text-align: center; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:hover { color: var(--c-text); }
.fold[open] { display: flex; flex-direction: column; gap: var(--s2); padding-bottom: 10px; }
.fold[open] > .msg { opacity: .6; }
.memo { align-self: stretch; border: 1px solid var(--c-accent); background: var(--c-accent-soft); border-radius: var(--r); padding: 8px 12px; }
.memo-hd { display: flex; align-items: center; gap: 12px; font-size: var(--f-sm); color: var(--c-accent); font-weight: 500; }
.memo-hd .spacer { flex: 1; }
.memo-hd .link { font-size: var(--f-sm); font-weight: 400; }
.memo-tx { margin-top: 4px; white-space: pre-wrap; line-height: 22px; }
.memo-edit { width: 100%; border: 1px solid var(--c-line); border-radius: var(--r); padding: 8px 10px; line-height: 22px; resize: vertical; background: #fff; }
.msg .meta { display: block; margin-top: 6px; font-size: var(--f-sm); color: var(--c-text-lite); }
.msg .undo { margin-left: 8px; }
/* 等助手：对话里的等待卡 + 画布上方的状态条（只报已等几秒和张数，不做假进度条） */
.msg.wait { min-width: 220px; }
.wait-hd { display: flex; align-items: center; gap: 8px; }
.wait-sec { margin-left: auto; color: var(--c-text-lite); font-size: var(--f-sm); font-variant-numeric: tabular-nums; }
.wait-ft { display: flex; align-items: center; gap: 8px; margin-top: 2px; padding-left: 16px; color: var(--c-text-lite); font-size: var(--f-sm); }
.wait-ft .link { margin-left: auto; }
.wait-dot { flex: none; width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--c-accent); animation: breathe 1.4s var(--ease-mv) infinite; }
@keyframes breathe { 0%, 100% { opacity: .35; transform: scale(.75); } 50% { opacity: 1; transform: none; } }
.ai-pill { position: absolute; left: 50%; top: 64px; z-index: 6; display: flex; align-items: center; gap: 8px; max-width: calc(100% - 32px); padding: 6px 14px; transform: translate3d(-50%, 0, 0); background: var(--c-panel); border: 1px solid var(--c-line); border-radius: var(--r-pill); box-shadow: var(--shadow); font-size: var(--f-sm); white-space: nowrap; animation: fade var(--t-mid) var(--ease-out); }
.ai-pill .t { flex: none; font-weight: 500; font-variant-numeric: tabular-nums; }
.ai-pill .s { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--c-text-lite); }
.ai-pill .link { flex: none; }
.ai-pill.done { color: var(--c-accent); border-color: var(--c-accent); background: var(--c-accent-soft); }
@media (prefers-reduced-motion: reduce) { .wait-dot { animation: none; opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translate3d(0,6px,0); } to { opacity: 1; transform: none; } }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 var(--s3) var(--s2); }
.suggest button { border: 1px solid var(--c-line); background: #fff; border-radius: var(--r-pill); padding: 4px 12px; font-size: var(--f-sm); color: var(--c-text-mid); transition: border-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out); }
.suggest button:hover { border-color: var(--c-text-lite); color: var(--c-text); }
.chat-input { border-top: 1px solid var(--c-line); padding: var(--s2) var(--s3) var(--s3); }
.chat-input textarea { width: 100%; resize: none; height: 72px; border: 1px solid var(--c-line); border-radius: var(--r); padding: 8px 10px; background: #fff; line-height: 22px; }
.chat-input textarea:focus { outline: none; border-color: var(--c-text-lite); }
.chat-input .row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.chat-input .hint { color: var(--c-text-lite); font-size: var(--f-sm); }

/* —— 中间画布 —— */
.toolbar { position: absolute; left: 50%; top: var(--s3); transform: translateX(-50%); z-index: 5; display: flex; gap: 4px; padding: 4px; background: var(--c-panel); border: 1px solid var(--c-line); border-radius: var(--r-pill); box-shadow: var(--shadow); }
.toolbar .btn { border-color: transparent; background: none; }
.toolbar .btn:hover { background: var(--c-bg); }
.toolbar .sep { width: 1px; background: var(--c-line); margin: 4px 2px; }
.facebar { position: absolute; left: var(--s3); bottom: var(--s3); z-index: 5; display: flex; gap: 8px; align-items: center; }
.zoombar { position: absolute; right: var(--s3); bottom: var(--s3); z-index: 5; display: flex; gap: 6px; align-items: center; color: var(--c-text-mid); font-size: var(--f-sm); }
.canvas-wrap { position: absolute; inset: 0; }
.legend { position: absolute; right: var(--s3); top: var(--s3); z-index: 5; pointer-events: none; font-size: var(--f-sm); color: var(--c-text-mid); background: var(--c-panel); border: 1px solid var(--c-line); border-radius: var(--r); padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.dropzone { position: absolute; inset: 0; z-index: 20; display: none; pointer-events: none; background: rgba(14,122,95,.05); border: 2px dashed var(--c-accent); }
.dropzone.on { display: block; }
.droplabel { position: fixed; z-index: 70; pointer-events: none; transform: translate3d(14px, 14px, 0); background: var(--c-accent); color: #fff; font-weight: 500; font-size: var(--f-md); padding: 6px 14px; border-radius: var(--r-pill); box-shadow: var(--shadow); white-space: nowrap; }
body.dragging-file .viewer { box-shadow: inset 0 0 0 2px var(--c-accent); }
.ctxmenu { position: fixed; z-index: 70; min-width: 180px; background: var(--c-panel); border: 1px solid var(--c-line); border-radius: var(--r); box-shadow: 0 6px 24px rgba(30,33,36,.16); padding: 4px; animation: fade var(--t-mid) var(--ease-out); }
.ctxmenu button { display: flex; width: 100%; justify-content: space-between; gap: 16px; border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: var(--r); color: var(--c-text); }
.ctxmenu button:hover { background: var(--c-bg); }
.ctxmenu button .k { color: var(--c-text-lite); font-size: var(--f-sm); }
.ctxmenu { max-height: calc(100vh - 16px); overflow-y: auto; } /* 长菜单（字体列表）在矮屏上能滚 */
.font-pick { max-width: 100%; font-size: var(--f-md); }
.font-note { margin-top: 4px; line-height: 1.6; }
.ctxmenu button.danger { color: var(--c-danger); }
.ctxmenu button.danger:hover { background: var(--c-danger-soft); }
.ctxmenu hr { border: 0; border-top: 1px solid var(--c-line); margin: 4px 0; }
.tour { position: fixed; inset: 0; z-index: 80; }
.tour-hole { position: fixed; border-radius: var(--r); box-shadow: 0 0 0 9999px rgba(30,33,36,.55); transition: all var(--t-mid) var(--ease-mv); pointer-events: none; }
.tour-card { position: fixed; width: 320px; background: var(--c-panel); border-radius: var(--r); box-shadow: 0 8px 40px rgba(30,33,36,.3); padding: 16px; transition: all var(--t-mid) var(--ease-mv); }
.tour-card h3 { margin: 0 0 6px; font-size: var(--f-base); font-weight: 600; }
.tour-card p { margin: 0; color: var(--c-text-mid); line-height: 22px; }
.tour-card .row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.tour-card .dots { color: var(--c-text-lite); font-size: var(--f-sm); }

/* —— 3D —— */
.viewer { flex: none; position: relative; height: var(--viewer-h); border-bottom: 1px solid var(--c-line); background: #efece6; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.viewer-ctl { position: absolute; left: var(--s2); right: var(--s2); bottom: var(--s2); display: flex; gap: 6px; align-items: center; }
.viewer-ctl .btn { background: rgba(251,250,247,.92); }
.viewer-tools { position: absolute; right: var(--s2); top: var(--s2); display: flex; gap: 6px; }
.viewer-tools .btn { background: rgba(251,250,247,.92); }
.viewer-badge { position: absolute; left: var(--s2); top: var(--s2); font-size: var(--f-sm); color: var(--c-text-mid); background: rgba(251,250,247,.92); border-radius: var(--r-pill); padding: 2px 10px; }
.viewer.dark-stage .viewer-badge { background: rgba(19,22,24,.6); color: rgba(255,255,255,.78); } /* 深色影棚（透明玻璃）上的提示 */
.viewer.full { position: fixed; inset: 56px 0 0 0; height: auto; z-index: 30; }

/* —— 属性 —— */
.field { display: grid; grid-template-columns: 72px minmax(0,1fr); align-items: center; gap: 8px; margin-bottom: 10px; }
.field > label { color: var(--c-text-mid); font-size: var(--f-sm); }
.field input[type=text], .field input[type=number], .field select, .field textarea { width: 100%; height: 30px; border: 1px solid var(--c-line); border-radius: var(--r); padding: 0 8px; background: #fff; }
.field textarea { height: 64px; padding: 6px 8px; resize: vertical; line-height: 20px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--c-text-lite); }
.field input[type=range] { width: 100%; accent-color: var(--c-text); }
.field .inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 22px; height: 22px; border-radius: var(--r-pill); border: 1px solid rgba(0,0,0,.15); cursor: pointer; position: relative; transition: transform var(--t-fast) var(--ease-out); }
.sw:hover { transform: scale(1.12); }
.sw.on { outline: 2px solid var(--c-text); outline-offset: 2px; }
.sw.disabled { opacity: .25; cursor: not-allowed; }
.sw-custom { overflow: hidden; background: conic-gradient(#e5484d, #f2b33d, #46a758, #0e7a5f, #3e63dd, #8e4ec6, #e5484d); }
.sw-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; cursor: pointer; }
.field .inline > select { flex: 1 1 80px; width: auto; min-width: 0; }
input[type=color] { width: 30px; height: 26px; padding: 0; border: 1px solid var(--c-line); border-radius: var(--r); background: none; cursor: pointer; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tools .btn { justify-content: flex-start; }
.empty { color: var(--c-text-lite); font-size: var(--f-sm); }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.thumb { border: 1px solid var(--c-line); border-radius: var(--r); background: #fff; padding: 0; overflow: hidden; aspect-ratio: 1; position: relative; transition: border-color var(--t-fast) var(--ease-out); }
.thumb:hover { border-color: var(--c-text-lite); }
.thumb.on { border: 2px solid var(--c-text); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span { position: absolute; left: 0; right: 0; bottom: 0; font-size: var(--f-xs); line-height: 16px; background: rgba(251,250,247,.92); text-align: center; }

/* —— 盒内物品 —— */
.items { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.item-card { border: 1px solid var(--c-line); border-radius: var(--r); background: #fff; padding: 0; overflow: hidden; text-align: left; position: relative; transition: border-color var(--t-fast) var(--ease-out); }
.item-card:hover { border-color: var(--c-text-lite); }
.item-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.item-card .nm { display: block; font-size: var(--f-xs); line-height: 14px; padding: 4px 4px 5px; }
.item-card .qty { position: absolute; right: 4px; top: 4px; min-width: 18px; height: 18px; border-radius: var(--r-pill); background: var(--c-text); color: #fff; font-size: var(--f-xs); line-height: 18px; text-align: center; padding: 0 4px; }
.item-card.on { border: 2px solid var(--c-text); }
.picked { margin-top: var(--s2); display: flex; flex-direction: column; gap: 6px; }
.picked-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--c-line); border-radius: var(--r); background: #fff; }
.picked-row .nm { font-weight: 500; }
.picked-row .dim { color: var(--c-text-lite); font-size: var(--f-sm); }
.picked-row .colors { grid-column: 1 / -1; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--c-line); border-radius: var(--r-pill); }
.stepper button { width: 26px; height: 24px; border: 0; background: none; }
.stepper button:hover { background: var(--c-bg); border-radius: var(--r-pill); }
.stepper span { min-width: 18px; text-align: center; font-size: var(--f-sm); }
.est { font-size: var(--f-xs); color: var(--c-warn); border: 1px solid #e2c48f; border-radius: var(--r-pill); padding: 0 6px; margin-left: 4px; }
.src-tag { font-size: var(--f-xs); color: var(--c-text-lite); border: 1px solid var(--c-line); border-radius: var(--r-pill); padding: 0 6px; margin-left: 4px; }
.item-card .dm { display: block; font-size: 10px; line-height: 12px; padding: 0 4px 5px; margin-top: -3px; color: var(--c-text-lite); font-variant-numeric: tabular-nums; }
/* 装得多满：盒内尺寸 / 放了几件 / 最高的离盒顶还剩多少 */
.fill-sum { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin-top: var(--s2); padding: 8px 10px; border: 1px solid var(--c-line); border-radius: var(--r); background: #fff; font-size: var(--f-sm); }
.fill-sum .k { color: var(--c-text-lite); }
.fill-sum .v { font-variant-numeric: tabular-nums; }
.fill-sum .v.bad { color: var(--c-danger); }
/* 帮我挑礼物 */
.gift-entry { display: flex; align-items: center; gap: 8px; margin-bottom: var(--s2); }
.gift-box { border: 1px solid var(--c-line); border-radius: var(--r); background: #fff; padding: 10px; margin-bottom: var(--s2); display: flex; flex-direction: column; gap: 8px; }
.gift-hd { display: flex; align-items: center; justify-content: space-between; }
.gift-ask { display: flex; gap: 6px; }
.gift-in { flex: 1; min-width: 0; height: 28px; border: 1px solid var(--c-line); border-radius: var(--r); padding: 0 8px; background: #fff; }
.gift-in:focus { outline: none; border-color: var(--c-text-lite); }
.gift-wait { display: flex; align-items: center; justify-content: space-between; font-size: var(--f-sm); color: var(--c-text-mid); }
.gift-src { font-size: var(--f-sm); color: var(--c-text-mid); line-height: 20px; }
.gift-card { border: 1px solid var(--c-line); border-radius: var(--r); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; transition: border-color var(--t-fast) var(--ease-out); }
.gift-card:hover { border-color: var(--c-text-lite); }
.gift-top { display: flex; align-items: baseline; gap: 8px; width: 100%; }
.gift-fit { margin-left: auto; font-size: var(--f-xs); white-space: nowrap; }
.gift-fit.ok { color: var(--c-accent); }
.gift-fit.bad { color: var(--c-warn); }
.gift-items { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: var(--f-sm); }
.gift-it { display: inline-flex; align-items: center; gap: 4px; }
.gift-it img { width: 24px; height: 24px; border-radius: var(--r); object-fit: cover; }
.gift-it .dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); display: inline-block; }
.gift-why { font-size: var(--f-sm); color: var(--c-text-mid); line-height: 20px; }

/* —— 校验 —— */
.issues { display: flex; flex-direction: column; gap: 6px; }
.issue { border: 1px solid var(--c-line); border-left-width: 3px; border-radius: var(--r); padding: 8px 10px; background: #fff; cursor: pointer; transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out); }
.issue:hover { background: var(--c-panel); }
.issue.error { border-left-color: var(--c-danger); }
.issue.warn { border-left-color: var(--c-warn); }
.issue.busy { border-left-color: var(--c-text-lite); }
.issue .t { font-weight: 500; }
.issue.error .t { color: var(--c-danger); }
.issue .w { color: var(--c-text-mid); font-size: var(--f-sm); line-height: 20px; margin-top: 2px; }
.issue .row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.tag { font-size: var(--f-xs); color: var(--c-text-lite); border: 1px solid var(--c-line); border-radius: var(--r-pill); padding: 0 6px; }
.allgood { display: flex; align-items: center; gap: 8px; color: var(--c-accent); font-weight: 500; }
details.fold summary { cursor: pointer; color: var(--c-text-mid); font-size: var(--f-sm); }
details.fold summary:hover { color: var(--c-text); }
details.fold .body { font-size: var(--f-sm); color: var(--c-text-mid); line-height: 20px; margin-top: 6px; }

/* —— 弹窗 —— */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(30,33,36,.35); display: flex; align-items: center; justify-content: center; animation: fade var(--t-mid) var(--ease-out); }
.modal { background: var(--c-panel); border-radius: var(--r); box-shadow: 0 8px 40px rgba(30,33,36,.25); width: min(1100px, 94vw); height: min(760px, 92vh); display: flex; flex-direction: column; overflow: hidden; }
.modal-hd { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--c-line); }
.modal-hd h3 { margin: 0; font-size: var(--f-base); font-weight: 600; }
.modal-bd { flex: 1; min-height: 0; position: relative; }
.modal-ft { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); border-top: 1px solid var(--c-line); }
.modal-ft:empty { display: none; } /* 没有按钮的弹窗（我的方案）不留一条空脚 */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--c-text); color: #fff; padding: 8px 16px; border-radius: var(--r-pill); display: flex; gap: 12px; align-items: center; animation: rise var(--t-mid) var(--ease-out); pointer-events: auto; max-width: min(640px, calc(100vw - 24px)); }
.toast .link { color: #fff; text-decoration-color: rgba(255,255,255,.5); }
/* 键盘操作看得见焦点（鼠标点不显示） */
:focus-visible { outline: 2px solid var(--c-accent, #0e7a5f); outline-offset: 2px; }
button:focus:not(:focus-visible), input:focus:not(:focus-visible) { outline: none; }
/* 顶栏保存状态 */
/* 顶栏「保存」：状态 + 点开改名/另存；手机上只剩图标 */
.save-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--c-line); border-radius: var(--r-pill); background: var(--c-panel); color: var(--c-text-mid); font-size: var(--f-sm); cursor: pointer; transition: border-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out); }
.save-btn:hover { border-color: var(--c-text-lite); color: var(--c-text); }
.save-btn .ic { font-size: var(--f-sm); line-height: 1; }
.save-btn[data-state="saved"] .ic { color: var(--c-accent); }
.save-btn[data-state="error"], .save-btn[data-state="conflict"] { color: var(--c-danger); border-color: var(--c-danger); background: var(--c-danger-soft); }
.save-btn.compact { width: 28px; padding: 0; justify-content: center; }
.save-btn.compact .lbl { display: none; }
.name-input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--c-line); border-radius: var(--r); background: #fff; font-size: var(--f-base); color: var(--c-text); }
.name-input:focus { outline: none; border-color: var(--c-text-lite); }
.save-dlg { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.save-lbl { display: flex; flex-direction: column; gap: 6px; font-size: var(--f-sm); color: var(--c-text-mid); }
.save-where { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: var(--r); background: var(--c-accent-soft); color: var(--c-text); font-size: var(--f-md); line-height: 1.7; }
.save-where .ic { color: var(--c-accent); }
.save-dlg .empty { margin: 0; line-height: 1.7; }
.proj-find { max-width: 320px; margin-bottom: 16px; }
/* 首屏占位：脚本跑起来后由 main.js 移除 */
.boot { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--c-bg); color: var(--c-text-mid); }
/* 工厂端：搜索栏、备注、信息表单；编辑器里下架的物品 */
.f-tools { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.f-search { height: 32px; border: 1px solid var(--c-line); border-radius: var(--r); padding: 0 10px; min-width: 260px; }
.f-note { font-size: var(--f-sm); color: var(--c-text-mid); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-log { font-size: var(--f-xs); }
.f-form { display: grid; gap: 12px; max-width: 560px; margin-top: 16px; }
.f-field { display: grid; gap: 4px; font-size: var(--f-sm); color: var(--c-text-mid); }
.f-field input, .f-field textarea { border: 1px solid var(--c-line); border-radius: var(--r); padding: 6px 10px; font: inherit; color: var(--c-text); }
.item-card.off { opacity: .45; cursor: not-allowed; }
/* 最近删除 */
.trash-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-top: 1px solid var(--c-line); }
.trash-row .nm { flex: 1; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* —— 附图 / 概念卡片 / 浮动工具条 —— */
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 2px; border: 1px solid var(--c-line); border-radius: var(--r-pill); background: #fff; font-size: var(--f-sm); color: var(--c-text-mid); }
.attach-chip img { width: 26px; height: 26px; border-radius: var(--r-pill); object-fit: cover; }
.attach-chip button { border: 0; background: none; color: var(--c-text-lite); padding: 0 6px; line-height: 1; }
.attach-chip button:hover { color: var(--c-text); }
.msg-atts { display: flex; gap: 6px; margin-top: 6px; }
.msg-atts img { width: 56px; height: 56px; object-fit: cover; border-radius: var(--r); border: 1px solid rgba(255,255,255,.4); }
.left.drop-on { box-shadow: inset 0 0 0 2px var(--c-accent); }
.suggest button.strong { border-color: var(--c-accent); color: var(--c-accent); font-weight: 500; }
.suggest button.strong:hover { background: var(--c-accent-soft); }
.msg.wide { max-width: 100%; align-self: stretch; }
.concepts { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.cc { border: 1px solid var(--c-line); border-radius: var(--r); background: var(--c-panel); padding: 8px 10px; display: grid; gap: 6px; transition: border-color var(--t-fast) var(--ease-out); }
.cc:hover { border-color: var(--c-text-lite); }
.cc.on { border: 2px solid var(--c-accent); padding: 7px 9px; }
.cc-hd { font-weight: 600; font-size: var(--f-sm); color: var(--c-text-mid); }
.cc-text { font-size: var(--f-base); line-height: 22px; white-space: pre-wrap; background: #fff; border-radius: var(--r); padding: 8px; }
.cc-img { height: 132px; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/12px 12px; border-radius: var(--r); overflow: hidden; }
.cc-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cc-why { font-size: var(--f-sm); color: var(--c-text-lite); line-height: 18px; white-space: normal; }
.cc .btn { justify-self: start; }
.selbar { position: absolute; z-index: 6; display: flex; gap: 4px; padding: 4px; background: var(--c-panel); border: 1px solid var(--c-line); border-radius: var(--r-pill); box-shadow: var(--shadow); transform: translate3d(-50%, 0, 0); animation: fade var(--t-mid) var(--ease-out); }
.selbar .btn { border-color: transparent; background: none; }
.selbar .btn:hover { background: var(--c-bg); }

/* —— 案例库 —— */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.gal-card { border: 1px solid var(--c-line); border-radius: var(--r); background: #fff; padding: 0; overflow: hidden; text-align: left; transition: border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out); }
.gal-card:hover { border-color: var(--c-text-lite); transform: translate3d(0,-2px,0); }
.gal-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #efece6; }
.gal-card .nm { display: block; padding: 8px 12px; font-weight: 500; }
/* 我的方案：缩略图 + 名字 + 尺寸/时间 + 复制/删除；正在改的描边强调 */
.gallery.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.gallery.small .nm { padding: 6px 10px; font-size: var(--f-sm); }
.proj-h { margin: 20px 0 10px; font-size: var(--f-sm); font-weight: 600; color: var(--c-text-mid); }
.proj-card { position: relative; cursor: pointer; display: flex; flex-direction: column; }
.proj-card.on { border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent); }
.proj-card .nm { padding-bottom: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-card .sub { padding: 0 12px; font-size: var(--f-xs); color: var(--c-text-lite); }
.proj-ph { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; background: #efece6; color: var(--c-text-lite); font-size: var(--f-xl); }
.proj-badge { position: absolute; left: 8px; top: 8px; padding: 0 8px; border-radius: var(--r-pill); background: var(--c-accent); color: #fff; font-size: var(--f-xs); line-height: 20px; }
.proj-acts { display: flex; gap: 12px; padding: 4px 12px 8px; font-size: var(--f-sm); }
.link.danger-link:hover { color: var(--c-danger); }

/* —— 属性面板分组、勾选、图层 —— */
.sec-hd { margin: 16px 0 10px; padding-top: 12px; border-top: 1px solid var(--c-line); font-size: var(--f-sm); font-weight: 600; color: var(--c-text-mid); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: var(--f-sm); color: var(--c-text-mid); cursor: pointer; }
.chk input { accent-color: var(--c-accent); }
.layers summary { display: flex; align-items: baseline; gap: 8px; cursor: pointer; list-style: none; }
.layers summary::-webkit-details-marker { display: none; }
.layers summary h3 { margin: 0; font-size: var(--f-md); font-weight: 600; }
.layers summary h3::before { content: '▸ '; color: var(--c-text-lite); }
.layers[open] summary h3::before { content: '▾ '; }
.layers summary .sub { color: var(--c-text-lite); font-size: var(--f-sm); }
.ly-face { display: flex; justify-content: space-between; margin: 12px 0 4px; font-size: var(--f-xs); color: var(--c-text-lite); text-transform: none; }
.ly-face .n { color: var(--c-text-lite); }
.ly-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 4px 6px; border-radius: var(--r); cursor: pointer; transition: background var(--t-fast) var(--ease-out); }
.ly-row:hover { background: var(--c-bg); }
.ly-row.on { background: var(--c-accent-soft); }
.ly-row.off .ly-name { color: var(--c-text-lite); text-decoration: line-through; }
.ly-tag { width: 22px; height: 22px; border-radius: var(--r); background: var(--c-bg); color: var(--c-text-mid); font-size: var(--f-xs); display: inline-flex; align-items: center; justify-content: center; }
.ly-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--f-sm); }
.ly-name .tag { margin-left: 6px; }
.ly-acts { display: inline-flex; gap: 2px; opacity: .55; transition: opacity var(--t-fast) var(--ease-out); }
.ly-row:hover .ly-acts, .ly-row.on .ly-acts { opacity: 1; }
.ly-acts button { border: 0; background: none; padding: 2px 6px; border-radius: var(--r); font-size: var(--f-xs); color: var(--c-text-mid); }
.ly-acts button:hover { background: #fff; color: var(--c-text); }
.ly-acts button.del:hover { color: var(--c-danger); }

/* —— AI 宣传图 —— */
.promo { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 0; height: 100%; }
.promo-side { padding: 16px; border-right: 1px solid var(--c-line); overflow: auto; }
.promo-main { display: flex; flex-direction: column; min-height: 0; padding: 16px; gap: 12px; }
.promo-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: #efece6; border-radius: var(--r); padding: 12px; }
.promo-stage img { max-width: 100%; max-height: calc(100% - 44px); object-fit: contain; border-radius: var(--r); box-shadow: var(--shadow); }
.promo-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.promo-thumbs { display: flex; gap: 8px; overflow-x: auto; }
.promo-thumbs .thumb { width: 96px; flex: none; aspect-ratio: 3 / 2; }
/* 「出 3 张应景的」：三格各自显示进度，画好的可点开 */
.promo-set { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; }
.promo-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; aspect-ratio: 3 / 2; border: 1px dashed var(--c-line); border-radius: var(--r); background: var(--c-panel); padding: 8px; text-align: center; overflow: hidden; }
.promo-cell img { width: 100%; min-height: 0; flex: 1; object-fit: cover; border-radius: var(--r); box-shadow: none; max-height: none; }
.promo-cell.pick { cursor: pointer; border-style: solid; transition: border-color var(--t-fast) var(--ease-out); }
.promo-cell.pick:hover { border-color: var(--c-accent); }
/* 贺卡 */
.card-dlg .promo-stage { overflow: hidden; }
.card-dlg .promo-stage canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; box-shadow: var(--shadow); border-radius: var(--r); }
.card-styles { flex-wrap: wrap; border-radius: var(--r); }
.card-styles button { display: inline-flex; align-items: center; gap: 6px; }
.card-styles i { width: 12px; height: 12px; border-radius: var(--r-pill); border: 2px solid; }
.card-field { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: start; gap: 8px; margin-bottom: 8px; }
.card-field span { color: var(--c-text-mid); line-height: 32px; }
html[lang="en"] .card-field { grid-template-columns: 76px minmax(0, 1fr); }
.card-field input, .card-field textarea { width: 100%; border: 1px solid var(--c-line); border-radius: var(--r); padding: 6px 10px; font: inherit; background: #fff; }
.card-field textarea { resize: vertical; line-height: 22px; }
.card-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.card-share { margin-top: 12px; }
.card-share input { width: 100%; border: 1px solid var(--c-line); border-radius: var(--r); padding: 6px 10px; font: inherit; color: var(--c-text-mid); background: var(--c-bg); }
@media (max-width: 900px) {
  .promo { display: flex; flex-direction: column; height: 100%; overflow: auto; }
  .promo > * { flex: none; }
  .promo-side { border-right: 0; border-bottom: 1px solid var(--c-line); overflow: visible; }
  .promo-main { min-height: 420px; }
  .promo-set { grid-template-columns: minmax(0, 1fr); }
  .card-dlg .promo-main { min-height: 0; order: -1; } /* 手机：预览在上，边看边改 */
  .card-dlg .promo-stage { flex: none; overflow: visible; }
  .card-dlg .promo-stage canvas { width: min(100%, 280px); height: auto; max-height: none; }
}

/* —— 素材库抽屉 —— */
.libdrawer { position: absolute; left: 0; top: 0; bottom: 0; width: 320px; z-index: 8; background: var(--c-panel); border-right: 1px solid var(--c-line); box-shadow: 4px 0 16px rgba(30,33,36,.08); display: flex; flex-direction: column; padding: 12px 14px; gap: 8px; animation: libIn var(--t-mid) var(--ease-out); }
@keyframes libIn { from { transform: translate3d(-16px,0,0); opacity: 0; } to { transform: none; opacity: 1; } }
.lib-hd { display: flex; align-items: baseline; gap: 8px; }
.lib-hd h3 { margin: 0; font-size: var(--f-base); font-weight: 600; }
.lib-hd .sub { color: var(--c-text-lite); font-size: var(--f-sm); }
.lib-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.lib-filters button { border: 1px solid var(--c-line); background: #fff; border-radius: var(--r-pill); padding: 2px 10px; font-size: var(--f-sm); color: var(--c-text-mid); transition: border-color var(--t-fast) var(--ease-out); }
.lib-filters button:hover { border-color: var(--c-text-lite); }
.lib-filters button.on { background: var(--c-text); border-color: var(--c-text); color: #fff; }
.lib-q { height: 30px; border: 1px solid var(--c-line); border-radius: var(--r); padding: 0 10px; background: #fff; }
.lib-q:focus { outline: none; border-color: var(--c-text-lite); }
.lib-tip { font-size: var(--f-xs); color: var(--c-text-lite); line-height: 16px; }
.lib-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.lib-card { position: relative; border: 1px solid var(--c-line); border-radius: var(--r); background: #fff; overflow: hidden; cursor: grab; transition: border-color var(--t-fast) var(--ease-out); }
.lib-card:hover { border-color: var(--c-text-lite); }
.lib-img { display: block; width: 100%; aspect-ratio: 1; padding: 6px; border: 0; background: repeating-conic-gradient(#f1efea 0 25%, #fff 0 50%) 0 0/12px 12px; cursor: pointer; }
.lib-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lib-kind { position: absolute; left: 6px; top: 6px; font-size: var(--f-xs); line-height: 16px; padding: 0 6px; border-radius: var(--r-pill); background: rgba(30,33,36,.7); color: #fff; }
.lib-acts { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-top: 1px solid var(--c-line); }
.lib-acts button, .lib-acts a { border: 0; background: none; padding: 2px 6px; border-radius: var(--r); font-size: var(--f-xs); color: var(--c-text-mid); text-decoration: none; cursor: pointer; }
.lib-acts button:hover, .lib-acts a:hover { background: var(--c-bg); color: var(--c-text); }
.lib-acts .del:hover { color: var(--c-danger); }

/* —— 数值输入、配色点、快捷键表、菜单提示、开关态 —— */
.num-in { height: 28px; border: 1px solid var(--c-line); border-radius: var(--r); padding: 0 6px; background: #fff; font-variant-numeric: tabular-nums; }
.num-in:focus { outline: none; border-color: var(--c-text-lite); }
.theme-dots { display: inline-flex; margin-right: 6px; }
.theme-dots i { width: 10px; height: 10px; border-radius: var(--r-pill); border: 1px solid rgba(0,0,0,.12); margin-right: -3px; }
table.kbd { width: 100%; border-collapse: collapse; }
table.kbd td { padding: 8px 4px; border-bottom: 1px solid var(--c-line); }
table.kbd td:last-child { text-align: right; }
kbd { font-family: inherit; font-size: var(--f-sm); background: var(--c-bg); border: 1px solid var(--c-line); border-radius: var(--r); padding: 2px 8px; }
.menu-tip { padding: 4px 10px 6px; font-size: var(--f-xs); color: var(--c-text-lite); }
.ctxmenu button.redo { color: var(--c-text-lite); }
.menu-now { display: flex; align-items: center; gap: 8px; padding: 2px 10px; font-size: var(--f-xs); color: var(--c-accent); }
.menu-now::after { content: ''; flex: 1; border-top: 1px solid var(--c-accent); }
.btn.on { background: var(--c-text); border-color: var(--c-text); color: #fff; }
/* 顶栏不折行：方案名可以缩，其他保持一行；放不下的收进「更多」 */
@media (max-width: 1360px) { #sizeDims, .top > a.link { display: none; } }
@media (max-width: 1400px) { #histBtn, #helpBtn, #projBtn { display: none; } } /* 账号积分按钮占了位置：历史、怎么用、我的方案收进「更多」 */
@media (max-width: 1300px) and (min-width: 901px) { body:not(.page) .top .brand { font-size: 0; gap: 0; } .acct .ac-user { display: none; } .top > .title-input { flex-basis: 160px; } } /* 只收编辑器的品牌名；工厂端 / 工坊页（body.page）顶栏不挤 */
.top > * { flex: none; white-space: nowrap; }
.top > .title-input { flex: 0 1 220px; min-width: 96px; }
.toolbar { white-space: nowrap; max-width: calc(100% - 32px); overflow-x: auto; scrollbar-width: none; }
.legend { top: 72px; }
/* 英文顶栏更长：窄桌面（≤1023px）只留品牌标志，不显示品牌名 */
@media (min-width: 901px) and (max-width: 1023px) { html[lang="en"] .top .brand { font-size: 0; gap: 0; } }
/* 窄的时候让位：3D 区的操作提示、画布底部的网格/看选中（右键菜单里也有） */
.viewer { container-type: inline-size; }
@container (max-width: 560px) { .viewer-badge { display: none; } }
.center { container-type: inline-size; }
@container (max-width: 640px) { #gridBtn, #zoomSel { display: none; } }

/* —— 手机 / 窄屏（≤900px）：底部切换「改盒面 / 看成品 / 和助手说」；属性是底部抽屉；改盒面时右上角 3D 小窗实时跟着变 —— */
.mtabs, .sheet-head, .pip-hit, .m-size, .m-show { display: none; }
@media (max-width: 900px) {
  :root { --top-h: 52px; --tab-h: calc(56px + env(safe-area-inset-bottom)); --peek-h: 52px; }
  body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
  input, textarea, select { font-size: 16px; } /* iOS 小于 16px 的输入框一聚焦就放大整页 */
  .m-hide { display: none !important; }
  .m-show { display: inline; }
  .btn { height: 36px; }
  .btn.small { height: 32px; padding: 0 12px; }
  .btn.icon { width: 36px; }
  .btn.small.icon { width: 32px; }

  /* 顶栏：标志 / 方案名 / 撤销重做 / 校验 / 提交 / ⋯，其余收进 ⋯ */
  .top { height: var(--top-h); gap: 6px; padding: 0 8px 0 12px; }
  .top .brand { display: none; } /* 方案名比标志要紧：手机上把位置让给方案名 */
  #projBtn, #sizeSeg, #sizeDims, #histBtn, #helpBtn, #redoBtn, .top > a.link, .top > .spacer { display: none; } /* 重做在 ⋯ 里 */
  .top > .title-input { flex: 1 1 auto; width: auto; min-width: 0; padding: 4px 6px; }
  .save-btn { width: 32px; height: 32px; padding: 0; justify-content: center; flex: none; }
  .save-btn .lbl { display: none; }
  .save-btn .ic { font-size: var(--f-base); }
  #moreBtn { width: 32px; height: 32px; font-size: var(--f-lg); text-decoration: none; color: var(--c-text); }
  .check-chip { padding: 0 10px; }
  #exportBtn { padding: 0 14px; }

  /* 三个页面叠在一起，只显示当前那个（不改尺寸，切回来画布和 3D 保持原样） */
  .app { display: block; position: relative; height: calc(100vh - var(--top-h) - var(--tab-h)); height: calc(100dvh - var(--top-h) - var(--tab-h)); }
  .app > .col { position: absolute; inset: 0; visibility: hidden; border: 0; }
  .app.left-collapsed .left { display: flex; }
  body[data-mtab="edit"] .app > .center, body[data-mtab="chat"] .app > .left, body[data-mtab="view"] .app > .right { visibility: visible; }
  .chat-collapse, .left-open, .col-split, .viewer-split, .legend, .zoombar, .dropzone, #viewBig, #viewFull, .viewer-badge { display: none !important; }
  .viewer-ctl { overflow-x: auto; scrollbar-width: none; } /* 3D 下面一排（预览开关 + 视角）放不下就横滑 */
  .viewer-ctl > * { flex: none; }

  /* 改盒面 */
  .app > .center { bottom: 52px; } /* 固定按「只露一条」留位：选中后多出的一排盖在画布上，画布不跟着变尺寸重排 */
  body.has-quick .facebar { bottom: 56px; }
  .toolbar { left: 8px; right: 8px; top: 8px; transform: none; max-width: none; }
  .ai-pill { left: 8px; top: 56px; transform: none; max-width: calc(100% - 128px); } /* 右上角让给 3D 小窗 */
  .ai-pill .s { display: none; }
  .toolbar .btn.small { padding: 0 9px; }
  .toolbar:not(.at-end) { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); } /* 右边淡出：提示还能往左滑 */
  .facebar { left: 8px; right: 8px; bottom: 8px; overflow-x: auto; scrollbar-width: none; }
  .facebar .seg { flex: none; background: var(--c-panel); }
  .selbar { max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none; }
  .libdrawer { width: 100%; border-right: 0; }

  /* 属性抽屉：平时只露一条（点开看全部），选中谁就显示谁 */
  body[data-mtab="edit"] .app > .right { visibility: visible; position: fixed; inset: auto 0 var(--tab-h) 0; height: var(--peek-h); overflow: hidden; z-index: 20; border-top: 1px solid var(--c-line); box-shadow: 0 -4px 16px rgba(30,33,36,.08); transition: height var(--t-mid) var(--ease-out); }
  body[data-mtab="edit"].sheet-open .app > .right { height: min(56dvh, 520px); overflow-y: auto; overscroll-behavior: contain; }
  body.sheet-open .sheet-quick { display: none; } /* 展开后下面就是全部选项，那排快捷按钮重复了 */
  body[data-mtab="edit"] .right > .panel:not(#inspector):not(#layersPanel) { display: none; }
  body.has-quick { --peek-h: 100px; }
  body[data-mtab="edit"] .sheet-head { display: block; }
  .sheet-head { position: sticky; top: 0; z-index: 3; flex: none; background: var(--c-panel); border-bottom: 1px solid var(--c-line); }
  .sheet-bar { position: relative; display: flex; align-items: center; gap: 8px; width: 100%; height: 52px; padding: 6px 16px 0; border: 0; background: none; text-align: left; font-weight: 600; }
  .sheet-quick { display: flex; gap: 6px; padding: 0 12px 10px; overflow-x: auto; scrollbar-width: none; }
  .sheet-quick:empty { display: none; }
  .sheet-quick .btn { flex: none; }
  .btn.danger-text { color: var(--c-danger); }
  .sheet-bar::before { content: ''; position: absolute; left: 50%; top: 6px; width: 32px; height: 3px; margin-left: -16px; border-radius: var(--r-pill); background: var(--c-line); }
  .sheet-bar .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sheet-bar .sub { flex: none; color: var(--c-text-lite); font-size: var(--f-sm); font-weight: 400; }
  .sheet-bar .chev { flex: none; margin-left: auto; color: var(--c-text-mid); font-size: var(--f-sm); font-weight: 500; }

  /* 3D 小窗：改盒面时在右上角跟着变，点一下看大图 */
  body[data-mtab="edit"] .viewer { position: fixed; right: 8px; top: calc(var(--top-h) + 58px); width: 96px; height: 96px; z-index: 15; border: 1px solid var(--c-line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
  body[data-mtab="edit"] .viewer > :not(canvas):not(.pip-hit) { display: none !important; }
  body[data-mtab="edit"] .pip-hit { display: block; position: absolute; inset: 0; z-index: 2; border: 0; background: none; }
  body[data-mtab="edit"].sheet-open .viewer { visibility: hidden; } /* 抽屉拉起来后画布只剩一截，小窗别再挡住选中的东西 */

  /* 看成品：大 3D + 尺寸 + 盒里放什么 + 能不能生产 */
  body[data-mtab="view"] .viewer { height: min(56dvh, 120vw); }
  body[data-mtab="view"] #inspector, body[data-mtab="view"] #layersPanel { display: none; }
  body[data-mtab="view"] .m-size { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .m-size .lbl { font-weight: 600; }
  .m-size .dims { color: var(--c-text-lite); font-size: var(--f-sm); }

  /* 底部切换 */
  .mtabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: var(--tab-h); padding-bottom: env(safe-area-inset-bottom); background: var(--c-panel); border-top: 1px solid var(--c-line); }
  .mtabs button { flex: 1; position: relative; border: 0; background: none; color: var(--c-text-lite); font-size: var(--f-md); transition: color var(--t-fast) var(--ease-out); }
  .mtabs button.on { color: var(--c-text); font-weight: 600; }
  .mtabs button.on::before { content: ''; position: absolute; left: 32%; right: 32%; top: -1px; height: 2px; background: var(--c-accent); }
  .mtabs button .dot { position: absolute; top: 14px; width: 6px; height: 6px; margin-left: 2px; border-radius: var(--r-pill); background: var(--c-accent); }

  /* 浮层避开底部切换、别超出屏幕 */
  .toasts { bottom: calc(var(--tab-h) + var(--peek-h) + 12px); }
  .modal { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px) !important; }
  .modal-hd h3 { white-space: nowrap; }
  .modal-hd .empty { display: none; }
  .gallery, .gallery.small { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tour-card { width: min(320px, calc(100vw - 16px)); }
  .ctxmenu { max-height: 70dvh; overflow-y: auto; }
  .ctxmenu button { padding: 10px 12px; }
}
#exportBtn { gap: 0; } /* 按钮文字拆成了几段（手机上藏一段），段间不要留空 */
body[data-mtab] img, body[data-mtab] a { -webkit-touch-callout: none; } /* 编辑器里长按图片/链接不弹系统菜单 */

/* —— 快速摆放：九宫格 + 大小档 —— */
.quick-row { display: flex; gap: 12px; align-items: flex-start; }
.nine { flex: none; display: grid; grid-template-columns: repeat(3, 24px); gap: 3px; padding: 3px; border: 1px solid var(--c-line); border-radius: var(--r); background: #fff; }
.nine button { width: 24px; height: 24px; border: 0; border-radius: var(--r); background: var(--c-bg); display: flex; align-items: center; justify-content: center; transition: background var(--t-fast) var(--ease-out); }
.nine button i { width: 6px; height: 6px; border-radius: var(--r-pill); background: var(--c-text-lite); transition: background var(--t-fast) var(--ease-out); }
.nine button:hover { background: var(--c-accent-soft); }
.nine button:hover i { background: var(--c-accent); }
.quick-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
@media (max-width: 900px) { .nine { grid-template-columns: repeat(3, 32px); } .nine button { width: 32px; height: 32px; } }

/* 顶栏账号按钮：账号名 + 积分 */
.acct { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--c-line); border-radius: var(--r-pill); background: var(--c-panel); font-size: var(--f-sm); max-width: 220px; }
.acct:hover { border-color: var(--c-text-lite); }
.acct .ac-user { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct .ac-credits { color: var(--c-accent); white-space: nowrap; }
@media (max-width: 900px) { .acct .ac-user { display: none; } }
/* 积分明细 */
.credits .w-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.credits .stat { border: 1px solid var(--c-line); border-radius: var(--r); background: var(--c-panel); padding: 8px 12px; }
.credits .stat b { display: block; font-size: var(--f-lg); line-height: 28px; }
.credits .stat span { color: var(--c-text-mid); font-size: var(--f-xs); }
.credits .how { margin: 0; padding-left: 18px; color: var(--c-text-mid); line-height: 22px; }
.credits .ledger td.plus { color: var(--c-ok, #2e7d32); text-align: right; }
.credits .ledger td.minus { color: var(--c-text-mid); text-align: right; }
.credits .ledger td.empty { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .credits .w-stats { grid-template-columns: repeat(2, 1fr); } }
