/* ===========================================================
   豆豆图纸屋 · 全局样式
   儿童友好：圆润造型、明亮配色、大字号、柔和阴影
   =========================================================== */
:root {
  --purple: #6C5CE7;
  --purple-dark: #5646C4;
  --purple-light: #EFECFF;
  --pink: #FF7EB6;
  --pink-light: #FFE4F0;
  --yellow: #FFD166;
  --yellow-light: #FFF4D6;
  --green: #38C98A;
  --green-light: #DDF7EA;
  --blue: #4EA8F5;
  --blue-light: #E3F2FF;
  --ink: #2D2A4A;
  --ink-soft: #6B6789;
  --line: #E9E6F5;
  --bg: #F6F4FF;
  --card: #FFFFFF;
  --shadow: 0 8px 24px rgba(90, 70, 180, 0.09);
  --shadow-hover: 0 14px 34px rgba(90, 70, 180, 0.16);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  height: 72px; padding: 0 28px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  background: var(--purple-light);
  display: grid; place-items: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 19px; font-weight: 800; letter-spacing: .5px; color: var(--ink); }
.brand-text small { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }

.mode-switch {
  display: flex; gap: 4px; padding: 5px;
  background: var(--bg); border-radius: 999px;
}
.mode-btn {
  padding: 8px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 700; color: var(--ink-soft);
  transition: all .2s;
}
.mode-btn.active {
  background: var(--purple); color: #fff;
  box-shadow: 0 4px 12px rgba(108,92,231,.35);
}

/* ---------- 视图容器 ---------- */
.view { min-height: calc(100vh - 72px); }

/* ---------- 管理端布局 ---------- */
.admin-layout { display: flex; min-height: calc(100vh - 72px); }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: #fff; border-right: 1px solid var(--line);
  padding: 24px 16px;
}
.sidebar-title {
  font-size: 11px; font-weight: 800; color: var(--ink-soft);
  letter-spacing: 2px; padding: 0 12px; margin: 0 0 12px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 6px;
  border-radius: 14px; font-weight: 700; font-size: 15px;
  color: var(--ink-soft); transition: all .18s;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--purple); }
.nav-item.active { background: var(--purple-light); color: var(--purple); }
.admin-main { flex: 1; padding: 32px 38px 60px; min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.page-head h1 { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: .5px; }
.page-head p { margin: 6px 0 0; color: var(--ink-soft); font-size: 14px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border: none; border-radius: 999px;
  font-weight: 800; font-size: 14px; transition: all .18s;
  background: var(--bg); color: var(--ink);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--purple); color: #fff; box-shadow: 0 6px 16px rgba(108,92,231,.28); }
.btn-primary:hover { background: var(--purple-dark); }
.btn-pink { background: var(--pink); color: #fff; box-shadow: 0 6px 16px rgba(255,126,182,.3); }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(56,201,138,.28); }
.btn-ghost { background: transparent; border: 2px solid var(--line); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 800;
}
.tag-purple { background: var(--purple-light); color: var(--purple); }
.tag-green { background: var(--green-light); color: #24875C; }
.tag-gray { background: #F0F0F5; color: #888; }
.tag-yellow { background: var(--yellow-light); color: #B07D00; }
.tag-pink { background: var(--pink-light); color: #D6407E; }

/* 统计卡 */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card { display: flex; align-items: center; gap: 16px; padding: 22px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; flex-shrink: 0; }
.stat-icon svg { width: 26px; height: 26px; }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.pink { background: var(--pink-light); color: var(--pink); }
.stat-icon.green { background: var(--green-light); color: var(--green); }
.stat-icon.blue { background: var(--blue-light); color: var(--blue); }
.stat-num { font-size: 28px; font-weight: 900; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }

/* 图纸卡片网格（管理端） */
.pattern-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 20px; }
.pattern-card { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: all .2s; }
.pattern-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.pattern-thumb {
  aspect-ratio: 1; background: #FBFBFF; display: grid; place-items: center;
  overflow: hidden; position: relative; border-bottom: 1px solid var(--line);
}
.pattern-thumb canvas { max-width: 88%; max-height: 88%; object-fit: contain; image-rendering: pixelated; }
.pattern-card-body { padding: 16px; }
.pattern-card h3 { margin: 0 0 6px; font-size: 16px; font-weight: 800; }
.pattern-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--ink-soft); }
.pattern-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.btn-icon-only { padding: 7px 9px; }
/* 缩略图右上角的只读预览入口（点击卡片其余部分直接进编辑） */
.thumb-preview {
  position: absolute; right: 10px; top: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.92); color: var(--ink-soft);
  box-shadow: 0 3px 10px rgba(60,40,120,.16);
  opacity: .62; transition: all .18s; z-index: 2;
}
.pattern-card:hover .thumb-preview { opacity: 1; }
.thumb-preview:hover { color: var(--purple); background: #fff; transform: scale(1.06); }
@media (hover: none) { .thumb-preview { opacity: .85; } }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 70px 20px; color: var(--ink-soft); }
.empty-state svg { width: 72px; height: 72px; color: #CFC9EC; margin-bottom: 14px; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-size: 20px; }

/* ---------- 表单 ---------- */
.form-label { display: block; font-weight: 800; font-size: 14px; margin: 0 0 8px; }
.form-hint { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.input, .select {
  width: 100%; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 14px; background: #fff; color: var(--ink);
  outline: none; transition: border-color .2s;
}
.input:focus, .select:focus { border-color: var(--purple); }
.field { margin-bottom: 20px; }

/* 上传区 */
.upload-zone {
  border: 3px dashed #D8D2F5; border-radius: 22px;
  background: #FBFAFF; padding: 46px 20px; text-align: center;
  cursor: pointer; transition: all .2s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--purple); background: var(--purple-light); }
.upload-zone svg { width: 56px; height: 56px; color: var(--purple); margin-bottom: 12px; }
.upload-zone h3 { margin: 0 0 6px; font-size: 19px; }
.upload-zone p { margin: 0; color: var(--ink-soft); font-size: 13px; }

/* 规格选择 */
.spec-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.spec-option {
  border: 3px solid var(--line); border-radius: 18px; padding: 18px 14px;
  text-align: center; cursor: pointer; transition: all .2s; background: #fff;
}
.spec-option:hover { border-color: #C9BEF7; }
.spec-option.selected { border-color: var(--purple); background: var(--purple-light); }
.spec-option .spec-badge {
  width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px; font-weight: 900;
  background: var(--purple-light); color: var(--purple);
}
.spec-option.selected .spec-badge { background: var(--purple); color: #fff; }
.spec-option strong { display: block; font-size: 15px; font-weight: 800; }
.spec-option small { display: block; color: var(--ink-soft); font-size: 11px; margin-top: 3px; }

/* 生成向导步骤 */
.wizard-steps { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  border-radius: 999px; background: #fff; box-shadow: var(--shadow);
  font-size: 13px; font-weight: 700; color: var(--ink-soft);
}
.step b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-size: 12px; }
.step.active { color: var(--purple); }
.step.active b { background: var(--purple); color: #fff; }
.step.done b { background: var(--green); color: #fff; }

/* 生成结果区 */
.result-wrap { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.result-canvas-box {
  flex: 0 1 auto; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  max-width: 100%; overflow: auto;
}
.result-canvas-box { max-width: min(100%, 620px); }
.result-canvas-box canvas { display: block; image-rendering: pixelated; max-width: 100%; height: auto !important; }
.result-info { flex: 1; min-width: 260px; }

/* 颜色清单 */
.color-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.color-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.color-swatch { width: 30px; height: 30px; border-radius: 9px; border: 2px solid rgba(0,0,0,.08); flex-shrink: 0; }
.color-code { font-weight: 800; font-size: 13px; min-width: 40px; }
.color-name { flex: 1; font-size: 13px; color: var(--ink-soft); }
.color-count { font-size: 12px; font-weight: 700; color: var(--purple); background: var(--purple-light); padding: 3px 9px; border-radius: 999px; }

/* ---------- 管理端详情：编辑工具条 ---------- */
.toolbar-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tool-group { display: flex; align-items: center; gap: 10px; }
.tool-label { font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.seg-ctrl { display: inline-flex; padding: 4px; background: var(--bg); border-radius: 12px; gap: 3px; }
.seg-ctrl button {
  border: none; background: transparent; padding: 7px 16px; border-radius: 9px;
  font-weight: 700; font-size: 13px; color: var(--ink-soft); cursor: pointer; transition: all .18s;
}
.seg-ctrl button:hover { background: rgba(255,255,255,.7); }
.seg-ctrl button.active { background: var(--purple); color: #fff; box-shadow: 0 3px 10px rgba(108,92,231,.3); }
.editor-panel {
  margin-top: 16px; padding: 16px; border-radius: 16px;
  background: linear-gradient(135deg, #F6F3FF, #EEF6FF); border: 1px dashed #C9BEF7;
}
.editor-palette { display: flex; flex-wrap: wrap; gap: 7px; max-width: 560px; }
.palette-chip {
  width: 28px; height: 28px; border-radius: 9px; border: 2px solid rgba(0,0,0,.12);
  cursor: pointer; transition: transform .15s, box-shadow .15s; padding: 0;
}
.palette-chip:hover { transform: scale(1.15); }
.palette-chip.active { box-shadow: 0 0 0 3px var(--purple), 0 3px 8px rgba(0,0,0,.2); transform: scale(1.1); }
.palette-chip.disabled { opacity: .35; cursor: not-allowed; }
.replace-btn { margin-left: auto; padding: 3px 10px !important; font-size: 11px !important; }
canvas.editable { cursor: crosshair; }

/* ---------- 临摹模式 ---------- */
.mode-tabs { display: inline-flex; gap: 6px; padding: 5px; background: #fff; border: 2px solid var(--line); border-radius: 16px; margin-bottom: 22px; box-shadow: 0 4px 14px rgba(60,40,120,.06); }
.mode-tab {
  display: inline-flex; align-items: center; gap: 7px; border: none; background: transparent;
  padding: 10px 20px; border-radius: 11px; font-weight: 800; font-size: 14px;
  color: var(--ink-soft); cursor: pointer; transition: all .18s;
}
.mode-tab:hover { background: var(--bg); }
.mode-tab.active { background: var(--purple); color: #fff; box-shadow: 0 4px 12px rgba(108,92,231,.3); }
.trace-main { flex: 1; min-width: 320px; display: flex; flex-direction: column; gap: 20px; }
/* 临摹视口：裁剪溢出 + 放大后可滚动查看局部 */
.trace-viewport {
  position: relative; overflow: auto; max-height: 600px; width: 100%;
  border: 2px solid var(--line); border-radius: 14px; background: #F4F1FA;
  -webkit-overflow-scrolling: touch;
}
.trace-viewport.tbg-dark { background: #14161F; }
.trace-viewport.tbg-transparent {
  background-image: linear-gradient(45deg, #E9E5F5 25%, transparent 25%, transparent 75%, #E9E5F5 75%),
                    linear-gradient(45deg, #E9E5F5 25%, transparent 25%, transparent 75%, #E9E5F5 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px; background-color: #fff;
}
.trace-canvas-box {
  position: relative; display: inline-block; margin: 8px; padding: 0;
  border-radius: 6px; overflow: hidden; line-height: 0;
}
/* 画布用 dpr=2 绘制，属性宽是显示宽的 2 倍；显式锁定 CSS 宽度，避免被全局 max-width:100% 二次缩放 */
.trace-canvas-box canvas { display: block; image-rendering: pixelated; max-width: none; }
/* 调整模式下给手柄留出空间，避免被画布裁掉；视口不滚动以便看全图 */
.trace-canvas-box.adjusting { overflow: visible; padding: 18px; margin: 22px; background: transparent; }
.trace-canvas-box.adjusting canvas { border-radius: 4px; }
.trace-viewport.adjusting-view { overflow: hidden; max-height: none; display: flex; justify-content: center; align-items: center; }
/* 参考图叠加层：wrap 负责平移/缩放，imgbox 负责裁剪 */
/* 叠加层始终对齐 canvas：默认无内边距时贴边；调整模式 box 有 16px padding 时用 16px 偏移 */
.trace-overlay-wrap {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  transform-origin: top left; pointer-events: none; user-select: none;
}
.trace-canvas-box.adjusting .trace-overlay-wrap { left: 18px; top: 18px; width: calc(100% - 36px); height: calc(100% - 36px); }
.trace-overlay-imgbox { width: 100%; height: 100%; pointer-events: none; }
.trace-overlay-imgbox img { width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; -webkit-user-drag: none; }
.trace-overlay-wrap.adjusting { pointer-events: none; }
.trace-overlay-wrap.adjusting .trace-overlay-imgbox { pointer-events: auto; cursor: move; outline: 2px dashed rgba(108,92,231,.9); outline-offset: -2px; }
.trace-overlay-wrap.adjusting .trace-overlay-imgbox img { cursor: move; }
/* 四角缩放手柄（白）/ 裁剪手柄（黄） */
.ref-corner, .ref-clip {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.3); pointer-events: auto; z-index: 3;
}
.ref-corner { background: #fff; border: 3px solid var(--purple); cursor: nwse-resize; }
.ref-clip { width: 22px; height: 22px; background: #E6A817; border: 3px solid #fff; cursor: crosshair; z-index: 4; }
.ref-corner.tl { left: -13px; top: -13px; }
.ref-corner.tr { right: -13px; top: -13px; cursor: nesw-resize; }
.ref-corner.bl { left: -13px; bottom: -13px; cursor: nesw-resize; }
.ref-corner.br { right: -13px; bottom: -13px; }
/* 缩放控制栏 */
.trace-zoom-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.trace-zoom-bar .zoom-val { min-width: 52px; text-align: center; font-weight: 800; color: var(--purple); font-size: 14px; }
.trace-tip { font-size: 12px; color: var(--ink-soft); margin: 10px 0 0; line-height: 1.6; }
.trace-tip b { color: var(--purple); }
/* 笔刷大小分段控件 */
.brush-size-ctrl { display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px; background: var(--bg); border-radius: 10px; }
.brush-size-ctrl .size-btn {
  border: none; background: transparent; padding: 4px 9px; border-radius: 7px;
  font-size: 12px; font-weight: 800; color: var(--ink-soft); cursor: pointer; transition: all .15s;
}
.brush-size-ctrl .size-btn:hover { background: rgba(255,255,255,.8); }
.brush-size-ctrl .size-btn.active { background: var(--purple); color: #fff; box-shadow: 0 2px 6px rgba(108,92,231,.3); }
.trace-overlay-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink-soft); cursor: pointer; }
.trace-overlay-toggle input { width: 16px; height: 16px; accent-color: var(--purple); }
.trace-upload { min-height: 96px; }
.trace-upload svg { width: 40px; height: 40px; margin-bottom: 6px; }
.trace-upload h3 { font-size: 15px; }
.trace-ref-thumb { max-width: 120px; max-height: 72px; object-fit: contain; border-radius: 10px; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
@media (max-width: 720px) {
  .mode-tab { padding: 9px 14px; font-size: 13px; }
  .trace-main { min-width: 100%; }
}

/* ---------- 弹窗 ---------- */
.modal-root {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(35, 28, 70, .45); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 24px; width: min(560px, 100%);
  max-height: 88vh; overflow: auto; padding: 28px;
  box-shadow: 0 24px 60px rgba(30, 20, 70, .28);
}
.modal h2 { margin: 0 0 16px; font-size: 22px; font-weight: 900; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal-sub { margin: -6px 0 16px; font-size: 13px; line-height: 1.6; color: var(--ink-soft); }

/* 详情页只读提示 */
.detail-readonly-tip {
  display: flex; align-items: center; gap: 6px;
  margin: 12px 0 0; padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--ink-soft);
}
.detail-readonly-tip svg { flex-shrink: 0; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; top: 88px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 14px;
  font-weight: 700; font-size: 14px; box-shadow: var(--shadow-hover);
  animation: toastIn .25s ease;
}
.toast.success { background: var(--green); }
.toast.error { background: #E74C5B; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ===========================================================
   展示端（TV 大屏）
   =========================================================== */
.tv-mode body { background: #1B1638; color: #fff; }
.tv-mode .topbar {
  background: rgba(27, 22, 56, .92);
  border-bottom-color: rgba(255,255,255,.1);
}
.tv-mode .brand-text strong { color: #fff; }
.tv-mode .brand-text small { color: #BDB4E8; }
.tv-mode .mode-switch { background: rgba(255,255,255,.08); }
.tv-mode .mode-btn { color: #C7BEEA; }
.tv-mode .mode-btn.active { background: var(--purple); color: #fff; }
.display-layout {
  min-height: calc(100vh - 72px);
  padding: 30px 44px 60px;
  background: radial-gradient(1200px 600px at 15% -10%, #3A2B7A 0%, #1B1638 55%);
  color: #fff;
}
.display-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.display-head h1 { margin: 0; font-size: 40px; font-weight: 900; letter-spacing: 1px; }
.display-head p { margin: 6px 0 0; color: #BDB4E8; font-size: 17px; }
.tv-hint {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: #E8E2FF;
  font-size: 14px; font-weight: 700;
}
.tv-hint kbd {
  background: rgba(255,255,255,.18); border-radius: 6px;
  padding: 2px 8px; font-family: inherit; font-size: 12px;
}

.tv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 26px; }
.tv-card {
  background: rgba(255,255,255,.07); border: 3px solid transparent;
  border-radius: 26px; padding: 18px; cursor: pointer;
  transition: all .18s; outline: none;
}
.tv-card:hover { background: rgba(255,255,255,.12); }
.tv-card.focused {
  border-color: var(--yellow);
  background: rgba(255,209,102,.14);
  transform: scale(1.035);
  box-shadow: 0 0 0 6px rgba(255,209,102,.12), 0 18px 40px rgba(0,0,0,.3);
}
.tv-card-thumb {
  aspect-ratio: 1; border-radius: 18px; background: rgba(255,255,255,.06);
  display: grid; place-items: center; overflow: hidden; margin-bottom: 14px;
}
.tv-card-thumb canvas { max-width: 90%; max-height: 90%; image-rendering: pixelated; }
.tv-card h3 { margin: 0 0 8px; font-size: 22px; font-weight: 900; }
.tv-card .tag { font-size: 13px; }

/* 展示端详情 */
.detail-layout { display: flex; gap: 40px; align-items: flex-start; flex-wrap: wrap; }
.detail-canvas-box {
  background: rgba(255,255,255,.06); border-radius: 26px; padding: 24px;
  max-width: 100%; overflow: auto;
}
.detail-canvas-box canvas { display: block; image-rendering: pixelated; max-width: 100%; height: auto !important; }
.detail-side { flex: 1; min-width: 300px; }
.detail-side h2 { margin: 0 0 6px; font-size: 34px; font-weight: 900; }
.detail-side .meta-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 24px; }
.detail-side .meta-row .tag { font-size: 15px; padding: 6px 16px; }
.detail-side h3 { font-size: 20px; margin: 24px 0 10px; color: #E8E2FF; }
.tv-color-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  border-radius: 14px; background: rgba(255,255,255,.07); margin-bottom: 10px;
  font-size: 17px; border: 2px solid transparent; outline: none;
}
.tv-color-row.focused { border-color: var(--yellow); background: rgba(255,209,102,.14); }
.tv-color-row .color-swatch { width: 38px; height: 38px; }
.tv-color-row .color-code { font-size: 17px; min-width: 52px; }
.tv-color-row .color-name { flex: 1; color: #DCD6FA; }
.tv-color-row .color-count { font-size: 15px; background: rgba(255,255,255,.14); color: #fff; }

.tv-back {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 999px; background: rgba(255,255,255,.12);
  color: #fff; font-weight: 800; font-size: 15px; margin-bottom: 22px;
  border: 2px solid transparent; outline: none;
}
.tv-back.focused { border-color: var(--yellow); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .topbar { height: 64px; padding: 0 16px; }
  .brand-text small { display: none; }
  .sidebar { display: none; }
  .admin-main { padding: 22px 16px 50px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head h1 { font-size: 24px; }
  .spec-grid { grid-template-columns: 1fr; }
  .display-layout { padding: 20px 16px 50px; }
  .display-head h1 { font-size: 28px; }
  .tv-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
  .tv-card h3 { font-size: 17px; }
  .detail-layout { gap: 20px; }
  .detail-side h2 { font-size: 26px; }
}

@media (max-width: 560px) {
  .mode-btn { padding: 7px 14px; font-size: 13px; }
  .brand-text strong { font-size: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-num { font-size: 22px; }
  .pattern-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .pattern-card-body { padding: 12px; }
  /* 手机上提示条放到底部，别糊住页面标题 */
  .toast-root { top: auto; bottom: 18px; right: 12px; left: 12px; align-items: center; }
  .toast { animation: toastUp .24s ease; max-width: 100%; }
}

/* ============================================================
   临摹工作区（Photoshop 式画布交互）
   画布居中占满，工具走左侧竖栏，选项顶部吸附，参数右侧吸附面板
   ============================================================ */
.ps-app {
  --ps-top: 72px;
  --ps-pad-x: 38px;
  --ps-pad-top: 32px;
  --ps-pad-bottom: 60px;
  display: flex; flex-direction: column;
  height: calc(100vh - var(--ps-top));
  height: calc(100dvh - var(--ps-top));
  min-height: 580px;
  margin: calc(-1 * var(--ps-pad-top)) calc(-1 * var(--ps-pad-x)) calc(-1 * var(--ps-pad-bottom));
  background: #EDEAF7;
  overflow: hidden;
}

/* ---------- 顶部文档栏 ---------- */
.ps-topbar {
  display: flex; align-items: center; gap: 16px;
  height: 56px; flex-shrink: 0; padding: 0 14px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.ps-doc { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.ps-back {
  width: 32px; height: 32px; padding: 0; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  color: var(--ink-soft); cursor: pointer; transition: all .15s;
}
.ps-back:hover { color: var(--purple); border-color: var(--purple); background: var(--purple-light); }
.ps-name {
  width: 200px; max-width: 34vw; padding: 6px 9px;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  font-family: var(--font); font-size: 15px; font-weight: 800; color: var(--ink);
}
.ps-name::placeholder { color: #B9B4D0; font-weight: 600; }
.ps-name:hover { background: #F7F5FF; }
.ps-name:focus { outline: none; border-color: var(--purple); background: #fff; }
.ps-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; }
.ps-meta b { color: var(--purple); font-size: 13px; font-weight: 900; }
.ps-meta i { font-style: normal; padding-left: 10px; border-left: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1180px) { .ps-meta i { display: none; } }

.ps-specs { display: flex; gap: 6px; flex-shrink: 0; }
.ps-spec {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 4px 11px; border-radius: 9px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft);
  cursor: pointer; font-family: var(--font); transition: all .16s;
}
.ps-spec b { font-size: 12.5px; font-weight: 900; line-height: 1.2; }
.ps-spec span { font-size: 9.5px; opacity: .78; line-height: 1.1; }
.ps-spec:hover { border-color: #C9C0F5; color: var(--purple); }
.ps-spec.active { background: var(--purple); border-color: var(--purple); color: #fff; box-shadow: 0 4px 12px rgba(108,92,231,.32); }

.ps-topactions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* 顶栏按钮统一 34px 高（基础 .btn 的 18px 图标会把行高撑破）；
   用 padding 控高而不用固定 height，避免窄屏下内部元素单独溢出 */
.ps-topactions .btn-sm { padding: 8px 15px; font-size: 13px; line-height: 1.25; }
.ps-topactions .btn-sm svg { width: 15px; height: 15px; }

/* ---------- 选项栏（跟随工具） ---------- */
.ps-optionsbar {
  display: flex; align-items: center; gap: 13px;
  height: 44px; flex-shrink: 0; padding: 0 14px;
  background: #FAF9FF; border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden;
}
.ps-optionsbar::-webkit-scrollbar { height: 0; }
.ps-opt { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.ps-opt-label { font-size: 10.5px; font-weight: 800; color: var(--ink-soft); letter-spacing: .4px; }
.ps-sep { width: 1px; height: 18px; background: var(--line); flex-shrink: 0; }
.ps-zoom { margin-left: auto; }
.ps-zoom .zoom-val { font-size: 12px; min-width: 42px; }
.ps-icon-btn {
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); font-size: 15px; font-weight: 800; font-family: var(--font);
  cursor: pointer; transition: all .15s;
}
.ps-icon-btn:hover { border-color: var(--purple); color: var(--purple); background: #fff; }
.ps-fit-btn { width: auto; padding: 0 9px; font-size: 11.5px; }

/* ---------- 主体：工具栏 / 画布 / 面板 ---------- */
.ps-body { display: flex; flex: 1; min-height: 0; }

.ps-toolbar {
  width: 54px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0; background: #fff; border-right: 1px solid var(--line);
}
.ps-tool {
  width: 38px; height: 38px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 10px; background: transparent;
  color: var(--ink-soft); cursor: pointer; transition: all .15s;
}
.ps-tool:hover { background: var(--purple-light); color: var(--purple); }
.ps-tool.active { background: var(--purple); color: #fff; box-shadow: 0 4px 10px rgba(108,92,231,.32); }
.ps-tool-sep { width: 24px; height: 1px; background: var(--line); margin: 5px 0; }
.ps-mode-group { display: contents; }
.ps-mode-group[data-off] .ps-tool { opacity: .32; pointer-events: none; }

/* 画布工作区（深色，网格点阵） */
.ps-stage {
  position: relative; flex: 1; min-width: 0;
  display: flex; overflow: auto;
  background-color: #38334E;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.06) 1px, transparent 0);
  background-size: 22px 22px;
  -webkit-overflow-scrolling: touch;
}
.ps-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ps-stage-inner { margin: auto; padding: 40px 34px; display: flex; }
.ps-stage .trace-canvas-box { margin: 0; box-shadow: 0 14px 44px rgba(0,0,0,.45); }
.ps-stage .trace-canvas-box.adjusting { margin: 0; }
.ps-stage.tbg-transparent .trace-canvas-box {
  background-image: linear-gradient(45deg, #E9E5F5 25%, transparent 25%, transparent 75%, #E9E5F5 75%),
                    linear-gradient(45deg, #E9E5F5 25%, transparent 25%, transparent 75%, #E9E5F5 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px; background-color: #fff;
}
/* 底部状态栏：提示语放在画布外面，永不挡住要放豆的格子 */
.ps-statusbar {
  height: 28px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: #2C2740; color: rgba(255,255,255,.62);
  font-size: 11px; border-top: 1px solid rgba(255,255,255,.06);
  overflow: hidden;
}
.ps-statusbar::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(76,203,113,.16);
}
.ps-hint {
  flex: 0 1 auto; min-width: 0; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.ps-keys { margin-left: auto; flex-shrink: 0; opacity: .66; }

/* 右侧吸附面板 */
.ps-panel {
  width: 268px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: #fff; border-left: 1px solid var(--line);
  overflow-y: auto;
  transition: width .2s ease, opacity .16s;
}
.ps-app.panel-off .ps-panel { width: 0; opacity: 0; overflow: hidden; border-left: none; }
.ps-sec { padding: 13px 14px 15px; border-bottom: 1px solid var(--line); }
.ps-sec:last-child { border-bottom: none; }
.ps-sec-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 9px; font-size: 11.5px; font-weight: 800;
  color: var(--ink-soft); letter-spacing: .4px;
}
.ps-sec-head small { font-weight: 500; opacity: .72; font-size: 10px; }
.ps-cur { display: flex; align-items: center; gap: 5px; max-width: 62%; }
.ps-cur i { width: 13px; height: 13px; border-radius: 4px; border: 1px solid rgba(0,0,0,.14); flex-shrink: 0; }
.ps-cur em {
  font-style: normal; font-size: 10.5px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ps-palette { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.ps-palette .palette-chip {
  width: 100%; height: auto; aspect-ratio: 1 / 1;
  border-radius: 6px; border: 2px solid transparent; padding: 0;
}
.ps-palette .palette-chip.active { border-color: var(--ink); transform: scale(1.06); }

.ps-upload {
  position: relative; display: flex; align-items: center; gap: 9px;
  padding: 9px; border-radius: 11px;
  border: 1.5px dashed #D6D0F0; background: #FBFAFF;
  cursor: pointer; transition: all .15s;
}
.ps-upload:hover { border-color: var(--purple); background: var(--purple-light); }
.ps-upload-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.ps-upload-txt { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); }
.ps-upload-icon { color: var(--purple); display: inline-flex; }
/* 空状态把上传入口做成虚线大按钮，一眼看到第一步 */
.ps-upload-empty {
  flex-direction: column; gap: 7px; padding: 16px 12px;
  border-style: dashed; border-width: 1.5px; border-color: rgba(139,107,242,.42);
}
.ps-upload-empty .ps-upload-txt { font-size: 12.5px; color: var(--purple); }
.ps-upload-clear {
  position: absolute; right: 5px; top: 5px;
  width: 19px; height: 19px; padding: 0; border-radius: 50%;
  border: none; background: rgba(45,42,74,.72); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.ps-mini-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; cursor: pointer; color: var(--ink); }
.ps-mini-toggle input { accent-color: var(--purple); width: 12px; height: 12px; margin: 0; }
.ps-slider { margin-top: 9px; }
.ps-slider label { display: flex; justify-content: space-between; font-size: 10.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 3px; }
.ps-slider label b { color: var(--purple); }
.ps-range { width: 100%; accent-color: var(--purple); height: 16px; }

/* ---------- 自动生成：工作台第一步 ---------- */
.ps-gen .ps-upload { margin-bottom: 3px; }
.ps-gen .ps-upload-empty { justify-content: center; padding: 15px 10px; }
.ps-gen .ps-upload-empty .ps-upload-txt { font-size: 12px; font-weight: 800; color: var(--purple); }
.ps-gen-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 12px; padding: 9px 12px;
  font-size: 13px; border-radius: 10px;
}
.ps-gen-btn:disabled {
  background: #ECE8FA; color: #9E97BC; border-color: transparent; box-shadow: none; opacity: 1;
}
.ps-tip { margin: 9px 0 0; font-size: 10.5px; line-height: 1.6; color: var(--ink-soft); }

/* ---------- 原图对比窗口 ---------- */
.ps-compare {
  position: relative; width: 340px; flex-shrink: 0;
  display: none; flex-direction: column;
  background: #241F38; border-right: 1px solid rgba(255,255,255,.07);
}
.ps-app.compare-on .ps-compare { display: flex; }
.cmp-head {
  height: 38px; flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 12px; color: #E8E2FF; font-size: 11.5px; font-weight: 800;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.cmp-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.cmp-tools b { font-size: 10.5px; min-width: 34px; text-align: center; color: rgba(255,255,255,.7); font-weight: 700; }
.cmp-btn {
  width: 22px; height: 22px; padding: 0; border: none; border-radius: 6px;
  background: rgba(255,255,255,.1); color: #E8E2FF;
  font-size: 13px; font-weight: 800; font-family: var(--font); cursor: pointer;
}
.cmp-btn:hover { background: rgba(255,255,255,.2); }
.cmp-btn.cmp-fit { width: auto; padding: 0 7px; font-size: 10.5px; }
.cmp-close {
  width: 22px; height: 22px; padding: 0; border: none; border-radius: 6px;
  background: transparent; color: rgba(255,255,255,.6); cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.cmp-close:hover { background: rgba(255,255,255,.14); color: #fff; }
.cmp-stage {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  display: grid; place-items: center; cursor: grab; touch-action: none;
  background-color: #1E1A2E;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.05) 1px, transparent 0);
  background-size: 18px 18px;
}
.cmp-stage.dragging { cursor: grabbing; }
.cmp-stage img {
  max-width: 100%; max-height: 100%; display: block;
  transform-origin: center center; user-select: none;
  -webkit-user-drag: none; will-change: transform;
}
.cmp-tip {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  padding: 3px 10px; border-radius: 999px; background: rgba(0,0,0,.5);
  color: rgba(255,255,255,.68); font-size: 10px; white-space: nowrap; pointer-events: none;
}
.cmp-empty { text-align: center; color: rgba(255,255,255,.46); padding: 0 20px; }
.cmp-empty svg { opacity: .5; }
.cmp-empty p { margin: 8px 0 3px; font-size: 12px; font-weight: 800; color: rgba(255,255,255,.72); }
.cmp-empty small { font-size: 10.5px; line-height: 1.6; }

/* 选项栏里的对比开关 */
.ps-cmp-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-soft);
  font-family: var(--font); font-size: 11.5px; font-weight: 800; cursor: pointer;
}
.ps-cmp-btn:hover { border-color: var(--purple); color: var(--purple); }
.ps-cmp-btn.active { background: var(--purple); border-color: var(--purple); color: #fff; }

/* 面板里的对比入口 */
.ps-cmp-open {
  width: 100%; margin-top: 10px; padding: 7px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 9px; border: 1px dashed #D6D0F0; background: #FBFAFF;
  color: var(--purple); font-family: var(--font); font-size: 11.5px; font-weight: 800; cursor: pointer;
}
.ps-cmp-open:hover { border-color: var(--purple); background: var(--purple-light); }
.ps-ref-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; font-size: 10px; color: var(--ink-soft); }

/* 面板里的用料清单压缩成小行 */
.ps-panel .result-info { flex: none; min-width: 0; }
.ps-panel .color-list { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.ps-panel .color-row { gap: 7px; padding: 5px 7px; border-radius: 9px; }
.ps-panel .color-swatch { width: 18px; height: 18px; border-radius: 6px; border-width: 1px; }
.ps-panel .color-code { font-size: 10.5px; min-width: 24px; letter-spacing: .2px; }
.ps-panel .color-name { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-panel .color-count { font-size: 9.5px; padding: 2px 6px; white-space: nowrap; }
.ps-empty { padding: 16px 6px !important; }
.ps-empty svg { width: 26px !important; height: 26px !important; margin-bottom: 6px; }
.ps-empty p { font-size: 11.5px; margin: 6px 0 0; }

/* ---------- 用料清单：每行可点开换色 ---------- */
.ps-panel .color-list.editable .color-row {
  width: 100%; border: 1px solid transparent; background: transparent;
  font-family: var(--font); text-align: left; color: inherit; cursor: pointer;
}
.ps-panel .color-list.editable .color-row:hover { background: var(--purple-light); border-color: #E1DAFB; }
.color-edit { display: inline-flex; color: #B9B2DA; flex-shrink: 0; }
.ps-panel .color-list.editable .color-row:hover .color-edit { color: var(--purple); }

/* ---------- 换色弹窗（纯色块，不给名字） ---------- */
.cs-body { display: flex; gap: 18px; align-items: flex-start; }
.cs-col { min-width: 0; }
.cs-col:first-child { width: 180px; flex-shrink: 0; }
.cs-title { font-size: 10.5px; font-weight: 800; letter-spacing: .4px; color: var(--ink-soft); margin-bottom: 8px; }
.cs-olds { display: flex; flex-direction: column; gap: 5px; max-height: 300px; overflow-y: auto; padding-right: 2px; }
.cs-old {
  display: flex; align-items: center; gap: 7px; padding: 5px 7px;
  border-radius: 9px; border: 2px solid var(--line); background: #fff;
  cursor: pointer; font-family: var(--font); transition: all .14s;
}
.cs-old:hover { border-color: #CFC5F4; }
.cs-old.active { border-color: var(--purple); background: var(--purple-light); }
.cs-dot { width: 20px; height: 20px; border-radius: 6px; border: 1px solid rgba(0,0,0,.12); flex-shrink: 0; }
.cs-num { font-size: 10.5px; font-weight: 700; color: var(--ink-soft); }
.cs-arrow { display: inline-flex; margin-left: auto; color: #C3BCE0; transform: rotate(180deg); }
.cs-to { width: 18px; height: 18px; border-radius: 6px; border: 1px solid rgba(0,0,0,.12); flex-shrink: 0; }
.cs-to.empty { border-style: dashed; border-color: #CFC8EC; background: #fff; }
.cs-palette { display: grid; grid-template-columns: repeat(6, 28px); gap: 7px; }
.cs-chip {
  width: 28px; height: 28px; padding: 0; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent; cursor: pointer; transition: transform .12s;
}
.cs-chip:hover { transform: scale(1.14); border-color: rgba(0,0,0,.2); }
.cs-chip.picked {
  transform: scale(1.1); border-color: #fff;
  box-shadow: 0 0 0 2px var(--purple), 0 0 0 4px rgba(139,107,242,.28);
}
.cs-chip.picked svg { width: 12px; height: 12px; margin: auto; stroke-width: 3.4; }
.cs-chip.picked svg path { stroke: #fff; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.45)); }
.cs-count { margin-right: auto; font-size: 11px; font-weight: 700; color: var(--ink-soft); align-self: center; }

/* ---------- 自定义豆板尺寸 ---------- */
.cust-row { display: flex; gap: 14px; }
.cust-row label { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.cust-row .input { flex: 1; min-width: 0; }
.cust-row em { font-style: normal; font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.cust-hint { margin: 12px 0 0; font-size: 12px; font-weight: 800; color: var(--purple); }
.ps-spec-custom { border-style: dashed; }

/* 面板里的规格切换：只在窄屏出现（顶栏那组会藏起来） */
.ps-spec-row { display: none; padding: 12px 14px 0; }

.ps-link-btn {
  border: none; background: transparent; padding: 0;
  font-family: var(--font); font-size: 10.5px; font-weight: 800;
  color: var(--purple); cursor: pointer;
}
.ps-link-btn:hover { text-decoration: underline; }

/* 选项栏内的段控件与笔刷尺寸压缩 */
.ps-optionsbar .seg-ctrl { padding: 2px; gap: 1px; }
.ps-optionsbar .seg-ctrl button { padding: 3px 9px; font-size: 11px; }
.ps-optionsbar .brush-size-ctrl { gap: 4px; }
.ps-optionsbar .brush-size-ctrl .tool-label { display: none; }
.ps-optionsbar .size-btn { padding: 3px 7px; font-size: 11px; border-radius: 6px; }

@media (max-width: 900px) {
  .ps-app {
    --ps-top: 64px; --ps-pad-x: 16px; --ps-pad-top: 22px; --ps-pad-bottom: 50px;
  }
  /* 窄屏选项栏换行，避免横向溢出把笔刷挤没 */
  .ps-optionsbar {
    height: auto; min-height: 42px; flex-wrap: wrap; gap: 6px 10px;
    padding: 6px 12px; overflow: visible;
  }
  .ps-opt-label { display: none; }
  .ps-sep { display: none; }
  .ps-doc { gap: 8px; }
  .ps-name { width: 140px; font-size: 14px; }
  .ps-meta i { display: none; }
  .ps-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30;
    width: 260px; box-shadow: -12px 0 32px rgba(30,24,60,.18); }
  .ps-body { position: relative; }
  /* 窄屏收起 = 滑出屏幕（绝对定位下不能用 width:0） */
  .ps-app.panel-off .ps-panel { width: 260px; opacity: 1; overflow: visible; transform: translateX(100%); }
  .ps-stage-inner { padding: 24px 16px; }
  .ps-hint { font-size: 10.5px; }
  .ps-keys { display: none; }
  .ps-statusbar { padding: 0 10px; gap: 8px; }
  /* 窄屏：原图对比铺满画布区，盖在网格上，关掉再看豆子 */
  .ps-compare { position: absolute; inset: 0; width: auto; z-index: 25; }
}
@media (max-width: 560px) {
  .ps-specs { display: none; }
  .ps-spec-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
  .ps-spec-row .ps-specs { display: flex; flex: 1; gap: 5px; }
  .ps-spec-row .ps-spec { flex: 1; padding: 4px 2px; }
  .ps-name { width: 108px; font-size: 13px; }
  .ps-meta { font-size: 11px; gap: 0; }
  .ps-topactions .btn-ghost { display: none; }
  .ps-topactions .btn-sm { padding: 6px 11px; font-size: 12px; }
  .ps-panel { width: 232px; }
  .ps-app.panel-off .ps-panel { width: 232px; transform: translateX(100%); }
  .cs-body { flex-direction: column; gap: 12px; }
  .cs-col:first-child { width: 100%; }
  .cs-olds { flex-direction: row; flex-wrap: wrap; max-height: 120px; }
  .cs-old { flex: 0 0 auto; }
  .cs-palette { grid-template-columns: repeat(8, 1fr); }
  .cs-chip { width: 100%; height: auto; aspect-ratio: 1 / 1; }
  /* 卡片窄，按钮去掉图标保证一行放得下 */
  .pattern-actions .btn-sm { padding: 7px 10px; font-size: 12px; gap: 0; }
  .pattern-actions .btn-sm svg { display: none; }
  .pattern-actions .btn-icon-only { padding: 7px 9px; }
  .pattern-actions .btn-icon-only svg { display: inline; }
}

/* 临摹工作区内提示条挪到顶栏右下方，避免遮挡画布底部和状态栏 */
body:has(.ps-app) .toast-root {
  top: 112px; bottom: auto; left: auto; right: 292px;
  transform: none; align-items: flex-end;
}
@media (max-width: 900px) {
  /* 窄屏面板是浮层，提示条回到顶部居中（必须写在全量规则之后才生效） */
  body:has(.ps-app) .toast-root { top: 108px; right: 0; left: 0; width: auto; align-items: center; }
}
body:has(.ps-app) .toast-root .toast { max-width: min(320px, 62vw); text-align: center; }
body:has(.ps-app) .toast { animation: toastUp .24s ease; }
@keyframes toastUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
