/* 拼豆图纸生成器 - 样式 */
:root {
  --accent: #ff6b9d;
  --accent-2: #fb923c;
  --grad: linear-gradient(135deg, #ff6b9d, #fb923c);
  --soft-pink: #fff5f8;
  --pink-line: #ffd6df;
  --text: #1f2430;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --line: #eceef1;
  --bg: #fbfbfc;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(31, 36, 48, 0.05);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- 顶部 ---------- */
.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar .logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 800;
  box-shadow: 0 2px 8px rgba(255, 107, 157, 0.35);
}
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: 0.5px; }
.topbar .sub { color: var(--muted-2); font-size: 12px; margin-left: 2px; }
.topbar .spacer { flex: 1; }
.auth-area { display: flex; align-items: center; gap: 8px; }
.auth-btn { min-width: 84px; }
.service-btn { color: var(--accent); border-color: var(--pink-line); }
.service-btn:hover { background: var(--soft-pink); }
.user-menu { display: flex; align-items: center; gap: 10px; }

/* 手机端汉堡按钮与标题 */
.menu-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text);
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
.mobile-title {
  display: none;
  flex: 1;
  text-align: center;
  font-size: 16px; font-weight: 700;
  color: var(--text);
}

/* 手机端抽屉菜单 */
.mobile-drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  z-index: 99; display: none;
}
.mobile-drawer-overlay.show { display: block; }
.mobile-drawer {
  position: fixed; top: 0; left: 0;
  width: 280px; max-width: 78vw;
  height: 100vh; height: 100dvh;
  background: #fff;
  z-index: 100;
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s ease;
  box-shadow: 4px 0 16px rgba(0,0,0,0.12);
}
.mobile-drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-brand { display: flex; align-items: center; gap: 12px; }
.drawer-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: url('test.png') center/cover no-repeat;
  flex: none;
}
.drawer-title-wrap, .drawer-brand-text { display: flex; flex-direction: column; gap: 2px; }
.drawer-title { font-size: 16px; font-weight: 700; color: var(--text); }
.drawer-site { font-size: 12px; color: var(--muted-2); }
.drawer-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid #d1d5db; border-radius: 10px;
  background: #fff; color: #4b5563;
  font-size: 15px; cursor: pointer;
}
.drawer-menu { display: flex; flex-direction: column; padding: 8px; }
.drawer-item {
  display: flex; align-items: center;
  width: 100%; padding: 12px 14px;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--text); font-size: 15px;
  text-align: left; text-decoration: none;
  cursor: pointer;
}
.drawer-item:hover { background: var(--soft-pink); color: var(--accent); }
.drawer-user {
  display: flex; flex-direction: column;
}

/* ---------- 主体布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr 360px;
  gap: 16px;
  padding: 16px;
  max-width: none;
  margin: 0;
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  align-items: stretch;
}
.col-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.col-left.is-history .gen-panel { display: none; }
.col-center { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-replace { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card h2 { font-size: 17px; font-weight: 700; }
.card .card-desc { color: var(--muted-2); font-size: 13px; margin-top: 4px; }

/* 左侧上传/空白画板入口已集中到画布中央，原入口仅保留 DOM 供 JS 复用 */
.intro-card { display: none; }

/* ---------- 画布空状态：中央入口卡片 ---------- */
.canvas-stage.empty {
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  color: var(--text);
  gap: 0;
}
.canvas-stage.empty .empty-bg {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(880px, 94%);
  height: auto; max-height: 94%;
  object-fit: contain;
  image-rendering: pixelated;
  z-index: 0;
  pointer-events: none;
}
.canvas-stage:not(.empty) .empty-bg { display: none; }
.canvas-stage.empty .empty-actions {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 20px;
  width: 100%; max-width: 440px; padding: 20px;
}
.empty-card {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  padding: 24px 22px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(31, 36, 48, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.empty-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(31, 36, 48, 0.18);
  border-color: var(--accent);
}
.empty-card-title { font-size: 18px; font-weight: 700; color: var(--text); }
.empty-card-desc { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.45; }

/* ---------- 上传区 ---------- */
.upload-zone {
  margin-top: 12px;
  border: 2px dashed var(--pink-line);
  border-radius: var(--radius);
  background: var(--soft-pink);
  padding: 26px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: #ffeff5;
}
.upload-zone .up-icon {
  width: 46px; height: 46px; margin: 0 auto 8px;
  border-radius: 50%; background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; font-weight: 300;
}
.upload-zone .up-main { font-weight: 600; color: var(--text); }
.upload-zone .up-main em { color: var(--accent); font-style: normal; }
.upload-zone .up-tip { color: var(--muted-2); font-size: 12px; margin-top: 4px; }
.upload-thumb {
  margin-top: 12px; display: flex; align-items: center; gap: 10px;
  background: var(--soft-pink); border: 1px solid var(--pink-line);
  border-radius: 10px; padding: 8px;
}
.upload-thumb img {
  width: 52px; height: 52px; object-fit: cover; border-radius: 8px;
  image-rendering: pixelated; background: #fff;
}
.upload-thumb .t-meta { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); }
.upload-thumb .t-name { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-btn {
  border: none; background: none; color: var(--accent);
  font-size: 14px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.link-btn:hover { background: var(--soft-pink); }

/* ---------- 参数设置 ---------- */
.param-group { margin-top: 14px; }
.param-group > label {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px;
}
.param-group > label .val { color: var(--accent); font-weight: 700; }
.form-select {
  width: 100%; height: 38px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px; font-size: 13px; color: var(--text);
  background: #fff; outline: none; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.form-select:focus { border-color: var(--accent); }

input[type="range"].param-slider {
  width: 100%; height: 6px; appearance: none; -webkit-appearance: none;
  background: linear-gradient(to right, var(--accent) var(--fill, 100%), #f0f0f2 var(--fill, 100%));
  border-radius: 999px; outline: none; cursor: pointer;
}
input[type="range"].param-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(255, 107, 157, 0.4); cursor: pointer;
}
input[type="range"].param-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); cursor: pointer;
}

/* ---------- 开关 ---------- */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
}
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch-row span { font-size: 13px; }
.switch-label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.help-mark {
  flex: none; width: 18px; height: 18px; line-height: 18px; text-align: center;
  border-radius: 50%; background: var(--soft-pink); color: var(--accent);
  font-size: 11px; font-weight: 700; cursor: help; user-select: none;
  transition: background 0.15s, color 0.15s;
}
.help-mark:hover { background: var(--accent); color: #fff; }
.help-tooltip {
  position: fixed; z-index: 200; max-width: 260px;
  background: rgba(26, 26, 46, 0.96); color: #fff;
  font-size: 12px; line-height: 1.55; padding: 9px 12px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22); pointer-events: none;
  opacity: 0; transform: translateY(4px); transition: opacity 0.15s, transform 0.15s;
}
.help-tooltip.show { opacity: 1; transform: translateY(0); }
.switch {
  position: relative; width: 40px; height: 22px; cursor: pointer;
  background: #e5e7eb; border-radius: 999px; transition: background 0.15s;
  flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: left 0.15s;
}
.switch.on { background: var(--accent); }
.switch.on::after { left: 21px; }

/* ---------- 预览区 ---------- */
.preview-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tabs {
  display: inline-flex; background: #f3f4f6; border-radius: 10px; padding: 3px;
}
.tabs button {
  border: none; background: none; padding: 6px 16px; font-size: 13px;
  border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600;
}
.tabs button.active { background: #fff; color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
/* 节点 tab-upload-btn-style-match-2026-08-24：样式对齐「保存历史」(.btn.primary) */
.tab-upload-btn {
  margin-left: 20px; padding: 0 16px; height: 36px; font-size: 13px; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer; color: #fff;
  background: var(--grad); box-shadow: 0 2px 8px rgba(255, 107, 157, 0.35);
  transition: background 0.15s, transform 0.1s;
}
.tab-upload-btn:hover:not(:disabled) { background: var(--grad); filter: brightness(0.92); color: #fff; }
.tab-upload-btn:active { transform: translateY(1px); }
.preview-meta { color: var(--muted-2); font-size: 15px; margin-left: auto; font-weight: 800}

.canvas-stage {
  margin: 12px 12px 12px 20px;
  position: relative;
  flex: none;
  height: 72vh;
  min-height: 560px;
  max-height: 920px;
  border-radius: var(--radius);
  background:
    repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 0 0 / 24px 24px;
  border: 1px solid var(--line);
  overflow: hidden;
}
.canvas-stage.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted-2); gap: 12px;
}
.canvas-stage.empty .empty-img {
  max-width: 440px; max-height: 440px; width: auto; height: auto;
  border-radius: 16px; object-fit: contain;
}
.canvas-stage.empty .empty-title {
  font-size: 16px; font-weight: 700; color: var(--text);
}
.canvas-stage.empty .empty-tip {
  font-size: 22px; font-weight: 700; color: var(--muted);
}
/* 图纸预览卡片按内容高度排列；画布为固定高度，颜色统计在下方，超出时整列可滚动 */
#previewCard { flex: none; display: flex; flex-direction: column; }
.canvas-pan-layer {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  cursor: grab;
}
.canvas-pan-layer.dragging { cursor: grabbing; }
.cell-highlight {
  position: absolute;
  border: 2px solid #ff3b30;
  box-shadow: 0 0 0 4px rgba(255, 59, 48, .28), inset 0 0 0 1px rgba(255, 255, 255, .4);
  border-radius: 3px;
  pointer-events: none;
  z-index: 10;
  transition: opacity .25s ease;
}
.cell-highlight.fade-out { opacity: 0; }
.canvas-inner {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
  box-shadow: 0 4px 24px rgba(31, 36, 48, 0.12);
}
.canvas-inner canvas { display: block; image-rendering: pixelated; }
.canvas-inner img { display: block; max-width: none; }

.stage-toolbar {
  position: absolute; right: 12px; bottom: 12px; z-index: 5;
  display: flex; gap: 6px; align-items: center;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(4px);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px;
  box-shadow: var(--shadow);
}
.stage-toolbar button {
  width: 30px; height: 30px; border: none; background: none;
  border-radius: 50%; cursor: pointer; font-size: 15px; color: var(--text);
}
.stage-toolbar button:hover { background: var(--soft-pink); color: var(--accent); }
.stage-toolbar .zoom-val { font-size: 12px; color: var(--muted); min-width: 42px; text-align: center; }
.stage-toolbar .tb-exit {
  width: auto; height: 28px; padding: 0 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap;
}
.stage-toolbar .tb-exit:hover { background: var(--soft-pink); }

/* 画笔状态浮层：画布左上角，选中颜色/擦除时显示 */
.brush-badge {
  position: absolute; left: 14px; top: 14px; z-index: 6;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.94); backdrop-filter: blur(4px);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
  box-shadow: var(--shadow);
}
.brush-badge .bb-swatch {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(0,0,0,0.1); flex: none;
}
.brush-badge .bb-info { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brush-badge .bb-tag { font-size: 11px; font-weight: 700; color: var(--accent); }
.brush-badge .bb-color {
  font-size: 12px; color: var(--text); max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brush-badge .bb-exit {
  height: 30px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--accent);
  font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.brush-badge .bb-exit:hover { background: var(--soft-pink); }

.preview-actions {
  display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 16px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  cursor: pointer; font-weight: 600; text-decoration: none;
  box-sizing: border-box; transition: all 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--soft-pink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- 手动空白画板 ---------- */
.blank-row { display: flex; align-items: flex-end; gap: 10px; margin-top: 8px; }
.blank-row label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.blank-row input { width: 64px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; font-size: 13px; }
.blank-tip { margin-top: 8px; color: var(--accent); line-height: 1.5; }
.btn.primary {
  background: var(--grad); border: none; color: #fff;
  box-shadow: 0 2px 8px rgba(255, 107, 157, 0.35); margin-left: auto;
}
/* 预览区主按钮需要相邻，取消自动左顶；保存草稿推到最右，与下载图纸紧邻 */
.preview-actions .btn.primary { margin-left: 0; }
#saveDraftBtn { margin-left: auto; }
.btn.primary:hover:not(:disabled) { background: var(--grad); filter: brightness(0.92); color: #fff; }
.btn.danger { background: #fff; border-color: #fecaca; color: #dc2626; }
.btn.danger:hover:not(:disabled) { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }

/* ---------- 颜色统计 ---------- */
.stats-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  max-height: 340px; overflow-y: auto; padding-right: 4px;
}
.stat-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; transition: border-color 0.15s, transform 0.1s;
  background: #fff;
}
.stat-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat-item.active { border-color: #ff3b30; box-shadow: 0 0 0 2px rgba(255,59,48,0.25); }
.stat-item .sw {
  width: 100%; height: 34px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.stat-item .s-name {
  font-size: 11px; color: var(--muted); max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-item .s-count { font-size: 11px; color: var(--accent); font-weight: 700; }
.stats-empty { margin-top: 12px; color: var(--muted-2); font-size: 15px; }

/* ---------- 弹窗通用 ---------- */
.popup-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(31, 36, 48, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.popup {
  background: #fff; border-radius: 16px; box-shadow: 0 12px 48px rgba(0,0,0,0.2);
  max-width: 100%; max-height: 92vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.dialog-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.dialog-header h3 { font-size: 15px; }
.popup-close {
  border: none; background: #f3f4f6; width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; color: var(--muted); font-size: 13px;
}
.popup-close:hover { background: var(--soft-pink); color: var(--accent); }

/* ---------- 裁剪弹窗 ---------- */
.crop-dialog { width: 640px; }
.crop-canvas-wrap {
  padding: 16px; display: flex; align-items: center; justify-content: center;
  background: #2b2b33; overflow: auto;
}
.crop-canvas-wrap canvas { cursor: move; max-width: 100%; }
.crop-actions { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.crop-btn { flex: 1; height: 38px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.crop-btn-ok { border: none; background: var(--grad); color: #fff; }
.crop-btn-skip { border: 1px solid var(--line); background: #fff; color: var(--text); }
.crop-btn-skip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 创建空白画布弹窗 ---------- */
.blank-dialog { width: 420px; }
.blank-dialog-body { padding: 20px; }
.blank-dialog-desc { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.blank-dims { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.blank-dim { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.blank-dim span { font-size: 13px; color: var(--text); }
.blank-dim input {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; box-sizing: border-box;
}
.blank-dim input:focus { border-color: var(--accent); outline: none; }
.blank-dim-x { color: var(--muted); font-size: 14px; padding-bottom: 10px; }
.blank-size-tip { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.blank-quick-sizes { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.blank-quick-btn {
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
}
.blank-quick-btn:hover { border-color: var(--accent); color: var(--accent); }
.blank-quick-btn.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.blank-actions { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.blank-actions .btn { flex: 1; height: 40px; border-radius: 10px; font-size: 14px; font-weight: 600; }

/* ---------- 换色弹窗 ---------- */
.replace-popup { width: 420px; }
.replace-current {
  display: flex; align-items: center; gap: 10px; padding: 12px 2px 0;
  font-size: 12px; color: var(--muted);
}
.replace-current .sw { width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(0,0,0,0.1); }
.replace-coord {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 18px 0; font-size: 12px; color: var(--muted);
}
.replace-coord .coord-label { font-weight: 600; color: var(--ink); }
.replace-coord .coord-inputs { display: inline-flex; align-items: center; gap: 4px; }
.replace-coord .coord-inputs input {
  width: 54px; height: 30px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 8px; font-size: 13px; text-align: center; outline: none;
}
.replace-coord .coord-inputs input:focus { border-color: var(--accent); }
.replace-coord .coord-go {
  height: 30px; padding: 0 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 600;
}
.replace-coord .coord-go:hover { filter: brightness(1.05); }
.replace-coord .coord-tip { flex-basis: 100%; font-size: 11px; color: var(--muted-2); }
.replace-search { padding: 10px 18px 0; }
.replace-search input {
  width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 9px;
  padding: 0 12px; font-size: 13px; outline: none;
}
.replace-search input:focus { border-color: var(--accent); }
.replace-grid {
  padding: 12px 18px 16px; overflow-y: auto; max-height: 520px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px;
}
.replace-cell:hover { border-color: var(--accent); transform: translateY(-1px); }
.replace-cell.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255, 107, 157, 0.25); }
.replace-cell .c {
  height: 30px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}
.replace-erase {
  display: block;
  width: calc(100% - 36px);
  margin: 16px auto 0;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.replace-erase.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.replace-empty { color: var(--muted-2); font-size: 13px; }

/* 颜色编辑面板字号加大一号 */
.col-replace { font-size: 14px; }
.col-replace .card h2 { font-size: 16px; padding-left: -8px; }
#previewCard h2 { padding-left: 18px; }
.replace-current { font-size: 13px; }
.replace-coord { font-size: 13px; }
.replace-coord .coord-tip { font-size: 12px; }
.brush-row { font-size: 16px; }
.brush-row .brush-unit { font-size: 12px; }
.brush-hint { font-size: 12px; }
.replace-search input { height: 36px; font-size: 14px; }
.replace-cell .c { font-size: 11px; }
.replace-cell .m { font-size: 11px; }
.replace-erase { height: 36px; font-size: 13px; }

/* ---------- 笔刷控件 ---------- */
.brush-controls {
  padding: 16px 2px 0;
}
.brush-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 16px; font-weight: 600; margin-bottom: 6px;
}
.brush-row .brush-val { color: var(--accent); font-weight: 700; min-width: 16px; text-align: right; }
.brush-row .brush-unit { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 2px; }
.brush-hint { font-size: 13px; color: var(--muted-2); margin-top: 4px; line-height: 1.45; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; top: 72px; transform: translateX(-50%);
  z-index: 200; background: rgba(31,36,48,0.92); color: #fff;
  padding: 10px 20px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 参数行(滑块+数字) ---------- */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row .param-slider { flex: 1; }
.param-num {
  width: 62px; height: 30px; flex: none;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0 6px; font-size: 13px; text-align: center; outline: none;
  color: var(--text); background: #fff;
}
.param-num:focus { border-color: var(--accent); }
.param-num::-webkit-outer-spin-button, .param-num::-webkit-inner-spin-button { -webkit-appearance: none; }
.param-num { -moz-appearance: textfield; appearance: textfield; }
.param-hint { margin-top: 6px; font-size: 13px; color: var(--muted-2); }

/* ---------- 分段按钮组 ---------- */
.btn-grid { display: flex; gap: 6px; margin-top: 10px; }
.btn-grid.wrap { flex-wrap: wrap; }
.btn-grid.four .seg-btn { flex: 1; }
.seg-btn {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 12px; font-weight: 600; padding: 7px 10px; border-radius: 8px;
  cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
.seg-btn:hover { border-color: var(--accent); color: var(--accent); }
.seg-btn.active {
  background: var(--grad); border-color: transparent; color: #fff;
  box-shadow: 0 1px 5px rgba(255, 107, 157, 0.35);
}
.btn-grid.wrap .seg-btn { padding: 5px 9px; font-size: 13px; }

.palette-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px;
}
.palette-head > label { font-size: 16px; font-weight: 600; }
#excludedHint { color: var(--muted-2); margin-left: 4px; }

/* ---------- 颜色数量上限行 ---------- */
.count-row { display: flex; align-items: center; gap: 12px; }
.count-row .param-slider { flex: 1; }
.count-switch-label {
  font-size: 13px; color: var(--text); white-space: nowrap; flex: none;
}

/* ---------- 小按钮 ---------- */
.btn.sm { height: 34px; padding: 0 10px; font-size: 14px; border-radius: 8px; }

/* ---------- 色板管理弹窗 ---------- */
.palette-dialog { width: 720px; }
.palette-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px 0; font-size: 13px; color: var(--muted);
}
.palette-toolbar .spacer { flex: 1; }
.palette-search { padding: 10px 18px 0; }
.palette-search input {
  width: 100%; height: 34px; padding: 0 12px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--text);
  background: #fff;
}
.palette-search input:focus { border-color: var(--accent); outline: none; }
.palette-tip {
  padding: 10px 18px 2px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.palette-grid {
  padding: 12px 18px 18px; overflow-y: auto; max-height: 480px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px;
}
.palette-cell {
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  cursor: pointer; background: #fff; transition: transform 0.1s, border-color 0.12s;
  position: relative;
}
.replace-cell {
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  cursor: pointer; background: #fff; transition: border-color 0.12s, transform 0.1s;
}
.palette-cell:hover { transform: translateY(-1px); border-color: var(--accent); }
.palette-cell .c {
  height: 28px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}
.palette-cell.excluded { opacity: 0.35; }
.palette-cell.excluded .c { position: relative; }
.palette-cell.excluded .c::after {
  content: ""; position: absolute; left: 8%; right: 8%; top: 50%;
  border-top: 2px solid rgba(220, 38, 38, 0.85); transform: rotate(-12deg);
}
.palette-cell.excluded::before {
  content: "✕"; position: absolute; right: 3px; top: 2px; z-index: 1;
  font-size: 9px; color: rgba(220, 38, 38, 0.9); font-weight: 700;
}
@media (min-width: 561px) {
  .palette-cell .m, .replace-cell .m { display: none; }
}

/* ---------- 处理状态行 ---------- */
.process-status {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted-2);
  background: var(--soft-pink);
  border: 1px solid var(--pink-line);
  border-radius: 8px;
  padding: 6px 10px;
}

/* ---------- 色板管理器品牌行 ---------- */
.palette-brands {
  display: flex; gap: 6px;
  padding: 12px 18px 0;
}
.palette-brands .seg-btn { flex: 1; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d8dbe0; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--pink-line); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 登录/注册弹窗 ---------- */
.auth-dialog { width: 420px; }
.auth-body { padding: 22px 26px 26px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label { font-size: 13px; font-weight: 600; color: var(--text); }
.auth-field input {
  height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; outline: none; transition: border-color 0.15s;
}
.auth-field input:focus { border-color: var(--accent); }
.auth-input-wrap { position: relative; display: flex; align-items: center; }
.auth-input-wrap input { width: 100%; padding-right: 38px; }
.eye-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; cursor: pointer; font-size: 15px;
  color: var(--muted); padding: 4px; line-height: 1;
}
.eye-btn:hover { color: var(--text); }
.auth-error { min-height: 18px; font-size: 12px; color: #dc2626; text-align: center; }
.auth-submit {
  width: 100%; height: 44px; border-radius: 10px; font-size: 15px; font-weight: 600;
  background: #1f2430; color: #fff; border: none; cursor: pointer; margin-top: 4px;
}
.auth-submit:hover:not(:disabled) { background: #2b3140; }
.auth-switch {
  margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted);
}
.auth-switch .link-btn { margin-left: 4px; font-size: 13px; }

/* ---------- 个人中心 ---------- */
.account-dialog { width: 420px; }
.account-body { padding: 20px 26px 24px; display: flex; flex-direction: column; gap: 14px; }
.account-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.account-label { color: var(--muted); min-width: 64px; }
.account-member { flex-wrap: wrap; }
.member-active { color: #16a34a; font-weight: 600; }
.member-inactive { color: #dc2626; font-weight: 600; }
.account-sep { height: 1px; background: var(--line); margin: 2px 0; }
.account-activate label, .account-pwd label { font-size: 13px; font-weight: 600; color: var(--text); }
.activate-input { display: flex; gap: 8px; margin-top: 6px; }
.activate-input input { flex: 1; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; letter-spacing: 1px; }
.account-pwd { display: flex; flex-direction: column; gap: 8px; }
.account-pwd input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.account-error { min-height: 16px; font-size: 12px; color: #dc2626; }
.account-logout { align-self: flex-start; margin-top: 4px; }

/* ---------- 管理后台 ---------- */
.admin-dialog { width: 640px; max-width: 94vw; }
.admin-body { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 16px; }
.admin-stats { display: flex; flex-wrap: wrap; gap: 10px; }
/* === NODE: admin-backend-optimize-2026-08-20 === 顶部三分组卡（天卡/周卡/年卡） */
.admin-type-card { flex: 1 1 220px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.admin-type-card .atc-title { font-size: 15px; font-weight: 700; color: var(--accent); margin-bottom: 10px; }
.admin-type-card .atc-metrics { display: flex; gap: 16px; }
.admin-type-card .atc-metrics .m { font-size: 13px; color: var(--muted); }
.admin-type-card .atc-metrics .m b { display: block; font-size: 20px; color: #111; line-height: 1.25; }
.admin-type-card .atc-metrics .m.used b { color: #dc2626; }
.admin-type-card .atc-metrics .m.unused b { color: #16a34a; }
.admin-type-card .atc-metrics .m.invalid b { color: #dc2626; }
.stat-item { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.stat-item b { display: block; font-size: 20px; color: var(--accent); }
.stat-item span { font-size: 12px; color: var(--muted); }
.admin-gen label, .admin-list-head label { font-size: 13px; font-weight: 600; }
.admin-gen-row { display: flex; gap: 8px; margin-top: 6px; }
.admin-gen-row select, .admin-list-head select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.admin-search { flex: 1; min-width: 120px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.admin-search:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(230, 0, 126, 0.12); }
@media (max-width: 640px) {
  .admin-list-head { flex-wrap: wrap; }
  .admin-search { flex: 1 1 100%; order: 3; }
}
.admin-gen-row input[type=number] { width: 90px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.admin-gen-result { margin-top: 8px; }
.admin-gen-actions { display: flex; gap: 14px; margin-bottom: 6px; }
.admin-gen-result textarea { width: 100%; box-sizing: border-box; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.admin-list-head { display: flex; align-items: center; gap: 10px; }
.admin-list-table { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.admin-table th { background: var(--bg-soft); position: sticky; top: 0; }
.admin-table .mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; }
.admin-table .used { color: #dc2626; }
.admin-table .unused { color: #16a34a; }
.admin-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }
.admin-table .disabled-tag { color: #b45309; font-weight: 600; }
.admin-table .valid-tag { color: #16a34a; font-weight: 600; }
.admin-table .invalid-tag { color: #dc2626; font-weight: 600; }
.admin-table .revoke-btn { padding: 4px 12px; font-size: 12px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; }
.admin-table .revoke-btn:hover { border-color: var(--accent); color: var(--accent); }
/* === NODE: admin-backend-optimize-2026-08-20 === 列表行操作按钮：复制 / 失效(恢复) / 删除 */
.admin-table .row-actions { white-space: nowrap; }
.admin-table .row-actions .btn { padding: 3px 9px; font-size: 12px; margin-right: 4px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; }
.admin-table .row-actions .copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.admin-table .row-actions .invalid-btn:hover { border-color: #b45309; color: #b45309; }
.admin-table .row-actions .del-btn { color: #dc2626; }
.admin-table .row-actions .del-btn:hover { background: #dc2626; color: #fff; border-color: #dc2626; }
.admin-table .row-actions .admin-badge { display: inline-block; padding: 3px 10px; font-size: 12px; border-radius: 8px; background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; font-weight: 600; }
.admin-key-hint { margin-top: 10px; font-size: 12px; color: var(--muted); background: #fff7fa; border: 1px solid var(--pink-line); border-radius: 8px; padding: 8px 10px; }
.admin-key-hint b { color: var(--accent); letter-spacing: 1px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* 激活卡密弹窗 */
.auth-tip { font-size: 13px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }

/* ---------- 客服弹窗 ---------- */
.service-dialog { width: 380px; }
.service-body {
  padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 14px;
  align-items: center; text-align: center;
}
.service-body p { font-size: 13px; color: var(--text); line-height: 1.6; text-align: left; }
.service-body img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.service-body .btn { min-width: 96px; }

/* ---------- 底部展示说明 ---------- */
.showcase-section {
  max-width: 1560px; margin: 0 auto; padding: 28px 16px 40px;
  display: flex; flex-direction: column; gap: 22px;
}
.section-title {
  text-align: center; font-size: 22px; font-weight: 700; color: #a14d4d;
  margin-bottom: 4px;
}
.showcase-gallery {
  display: flex; align-items: center; justify-content: center; gap: 24px; flex-wrap: wrap;
}
.showcase-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; max-width: 420px;
}
.showcase-card img { max-width: 100%; height: auto; border-radius: 10px; }
.showcase-tag { font-size: 12px; color: var(--muted); }
.showcase-arrow { font-size: 28px; color: var(--muted-2); }
.features-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
.feature-item {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; gap: 14px; align-items: flex-start;
}
.feature-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
}
.feature-text { display: flex; flex-direction: column; gap: 4px; }
.feature-text b { font-size: 14px; }
.feature-text span { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---------- 历史记录页面 ---------- */
.history-page {
  position: fixed; inset: 0; z-index: 45; background: var(--bg);
  display: flex; flex-direction: column;
}
.history-header {
  min-height: 64px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-end;
  padding: 12px 24px; gap: 16px;
}
.history-actions { display: flex; align-items: center; gap: 12px; }
.history-bulk {
  display: flex; align-items: center; gap: 12px;
}
.history-bulk-count {
  font-size: 14px; font-weight: 600; color: var(--text); margin-right: 4px;
}
.history-count {
  background: #f0f0f0; color: var(--text); font-size: 12px; padding: 5px 12px;
  border-radius: 20px;
}
.history-body {
  flex: 1; overflow: auto; max-width: 1560px; width: 100%; margin: 0 auto;
  padding: 24px; display: flex; flex-direction: column; gap: 18px;
}
.history-hero { display: flex; flex-direction: column; gap: 6px; }
.history-hero h2 { font-size: 26px; font-weight: 700; color: var(--text); }
.history-hero p { font-size: 14px; color: var(--muted); }
.history-search { width: 100%; }
.history-search input {
  width: 100%; max-width: 720px; padding: 12px 16px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 15px; outline: none;
}
.history-search input:focus { border-color: var(--accent); }
.history-section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; flex: 1; }
.history-section-title {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.history-section-icon { font-size: 18px; }
.history-section-text { font-size: 16px; font-weight: 700; color: var(--text); }
.history-section-count {
  margin-left: auto; background: var(--accent); color: #fff; font-size: 12px;
  min-width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.history-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
}
.history-card {
  background: #fff; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden; display: flex; flex-direction: column; position: relative; cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  border: 2px solid transparent;
}
.history-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
.history-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,107,157,0.15); }
.history-card.bulk .hc-select { display: flex; }
.history-card .hc-select {
  position: absolute; top: 10px; left: 10px; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(255,255,255,0.92); border: 2px solid var(--line);
  display: none; align-items: center; justify-content: center; z-index: 2;
  font-size: 13px; font-weight: 700; color: #fff;
}
.history-card.selected .hc-select { background: var(--accent); border-color: var(--accent); }
.history-card .hc-menu {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px;
  border-radius: 50%; border: none; background: rgba(255,255,255,0.92); color: #555;
  cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px;
  line-height: 1; z-index: 3;
}
.history-card .hc-menu:hover { background: #fff; color: var(--accent); }
.history-card .hc-menu-popover {
  position: absolute; top: 44px; right: 10px; min-width: 130px;
  background: #fff; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  border: 1px solid var(--line); padding: 6px; z-index: 10;
  display: none; flex-direction: column; gap: 2px;
}
.history-card .hc-menu-popover.show { display: flex; }
.history-card .hc-menu-item {
  padding: 8px 10px; font-size: 13px; color: var(--text); border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.history-card .hc-menu-item:hover { background: var(--soft-pink); color: var(--accent); }
.history-card .hc-menu-item.hc-delete { color: #dc2626; }
.history-card .hc-menu-item.hc-delete:hover { background: #fee2e2; color: #b91c1c; }
.history-card .hc-img {
  aspect-ratio: 1 / 1; background: #f3f4f6;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.history-card .hc-img img { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.history-card .hc-noimg { color: var(--muted-2); font-size: 13px; }
.history-card .hc-info { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.history-card .hc-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-card .hc-meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.history-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted-2); gap: 8px;
}
.history-empty img { max-width: 120px; border-radius: 12px; }

/* ---------- 重命名弹窗 ---------- */
.rename-dialog { width: 420px; max-width: calc(100vw - 32px); }
.rename-body { padding: 20px 24px; }
.rename-body input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; outline: none;
}
.rename-body input:focus { border-color: var(--accent); }
.rename-error { color: #dc2626; font-size: 12px; margin-top: 8px; min-height: 18px; }
.rename-footer {
  padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 10px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .col-left, .col-center { display: contents; }
  /* 画布置最顶部；参数设置/色号系统紧随其下；替换列与统计卡在更后 */
  #previewCard { order: 0; }
  .col-left > .card { order: 1; }
  .col-replace { order: 2; height: auto; overflow-y: visible; }
  #statsCard { order: 3; }
  .canvas-stage { height: 60vh; min-height: 420px; flex: none; margin: 10px; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .features-grid { grid-template-columns: 1fr; }
  .showcase-gallery { flex-direction: column; }
  .showcase-arrow { transform: rotate(90deg); }
  .history-header { min-height: auto; padding: 12px 16px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .history-actions { width: 100%; justify-content: space-between; }
  .history-bulk { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .history-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 历史记录网格响应式：桌面 4 列 → 平板 3 列 → 小平板 2 列 → 手机 1 列 */
@media (max-width: 1200px) {
  .history-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .history-grid { grid-template-columns: 1fr; }
  .history-search input { max-width: 100%; }
}

/* 顶部导航栏响应式：平板隐藏副标题/缩小，手机只保留 logo+按钮区并允许折行 */
@media (max-width: 960px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .sub { display: none; }
  .topbar h1 { font-size: 15px; }
  .topbar .logo { width: 30px; height: 30px; font-size: 16px; }
}
@media (max-width: 560px) {
  .topbar { position: relative; padding: 0 10px; gap: 6px; height: auto; min-height: 52px; flex-wrap: nowrap; }
  .topbar .logo, .topbar h1, .topbar .sub { display: none; }
  .menu-toggle { display: flex; position: relative; z-index: 2; }
  .spacer { display: none; }
  .mobile-title {
    display: flex; align-items: center; justify-content: center;
    position: absolute; inset: 0; pointer-events: none;
  }
  .auth-area { display: none; }
}

/* ---------- 手机端弹窗/面板优化 ---------- */
@media (max-width: 560px) {
  /* 弹窗在手机上居中显示：自动高度、不铺满全屏，关闭按钮始终可见，四周留出边距 */
  .popup-mask { padding: 16px; align-items: center; }
  .popup-mask .popup {
    width: 100%; max-width: 100%; height: auto; max-height: 88vh;
    border-radius: 16px; padding-bottom: env(safe-area-inset-bottom);
  }
  .popup-mask .popup .dialog-header {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
  .palette-dialog, .auth-dialog, .account-dialog,
  .service-dialog, .crop-dialog {
    width: 100% !important; max-width: 100% !important;
  }

  /* 手机端图纸预览画布加宽：收窄外边距，让画布尽量贴近屏幕边缘 */
  .canvas-stage { margin: 1px; height: 42vh; min-height: 360px; }
  .canvas-stage.empty .empty-img { max-width: 80vw; max-height: 60vh; }

  /* 色板管理：工具栏自动折行，按钮不换行 */
  .palette-toolbar {
    flex-wrap: wrap;
    gap: 8px 6px;
    padding: 12px 14px 0;
  }
  .palette-toolbar .spacer { display: none; }
  .palette-toolbar > span { flex: 1 1 100%; font-size: 12px; }
  .palette-toolbar .btn.sm {
    flex: 1 1 auto; min-width: 70px; white-space: nowrap;
    height: 30px; padding: 0 10px; font-size: 12px;
  }

  /* 搜索、提示文字稍小 */
  .palette-search, .replace-search { padding: 8px 14px 0; }
  .palette-tip { padding: 8px 14px 2px; font-size: 12px; }

  /* 色板网格：少列大格，确保色块/色号/名称可见 */
  .palette-grid {
    padding: 10px 14px 14px;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 10px;
  }
  .palette-cell { border-radius: 10px; }
  .palette-cell .c { height: 50px; font-size: 14px; }
  .palette-cell .m {
    display: block; font-size: 11px; color: var(--muted); text-align: center;
    padding: 0 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* 替换颜色网格同样放大 */
  .replace-grid {
    padding: 10px 14px 14px;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px;
  }
  .replace-cell { border-radius: 10px; }
  .replace-cell .c { height: 48px; font-size: 14px; }
  .replace-cell .m {
    display: block; font-size: 11px; color: var(--muted); text-align: center;
    padding: 0 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* 登录按钮与退出按钮一致：去掉最小宽度，避免过宽 */
  .auth-area .btn.sm.auth-btn { min-width: auto; }

  /* 顶部登录/客服按钮：边框改细、更轻量 */
  .auth-area .btn.sm {
    border: none;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    color: var(--text);
  }
  .auth-area .btn.sm:hover:not(:disabled) {
    background: var(--soft-pink);
    color: var(--accent);
  }

}

/* ---------- 管理后台全页面 ---------- */
.admin-page {
  position: fixed; inset: 0; z-index: 45; background: var(--bg);
  display: none; flex-direction: column;
}
.admin-page-header {
  height: 64px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
}
.admin-page-header h2 { font-size: 18px; font-weight: 700; }
.admin-page-body {
  flex: 1; overflow: auto; max-width: 1560px; width: 100%; margin: 0 auto;
  padding: 20px 24px 30px; display: flex; flex-direction: column; gap: 18px;
}
.admin-page-section {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}

@media (max-width: 960px) {
  .admin-page-header { height: auto; padding: 12px 16px; }
  .admin-page-body { padding: 14px 16px 20px; }
}
@media (max-width: 640px) {
  .admin-page-header h2 { font-size: 16px; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-list-table { max-height: 420px; }
}
