/* ===== 拼豆喵 · 手绘拙趣 × 紫帽魔法喵 IP ===== */
:root {
  --bg: #fffdf7;            /* IP 规范底色 */
  --card: #ffffff;
  --ink: #3a322b;           /* IP 线稿墨色 */
  --ink-soft: #9b9285;
  --line: #efe9dc;
  --yellow: #ffe58a;        /* IP 规范辅色 */
  --primary: #c7b5f5;       /* IP 规范主色紫 */
  --accent: #a88be0;        /* 深一档紫：hover / 描边 / 文字强调 */
  --blue: #b9cbf2;          /* 蓝紫点缀（加载豆/点缀） */
  --red: #e8897b;
  --green: #9cc27f;
  --pink: #f5a8c0;
  --shadow: 4px 4px 0 rgba(58, 50, 43, 0.12);
  --hand-radius: 16px 8px 18px 10px / 10px 18px 8px 16px;
  --font-hand: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  background-image: radial-gradient(circle, rgba(122, 108, 180, 0.10) 1.5px, transparent 1.6px);
  background-size: 26px 26px;
  overflow-x: hidden;
}

/* ===== 手绘小涂鸦 ===== */
.doodle { position: fixed; pointer-events: none; opacity: .55; z-index: 0; }
.doodle-star { top: 90px; right: 5vw; transform: rotate(-14deg); }
.doodle-squiggle { bottom: 40px; left: 4vw; transform: rotate(6deg); }
.doodle-smiley { top: 46vh; right: 3vw; transform: rotate(10deg); }
.doodle-fish { bottom: 120px; right: 6vw; transform: rotate(-8deg); }
.layout { position: relative; z-index: 1; }

/* ===== 顶栏（融入背景，仅留一条柔和分隔线） ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: var(--bg);
  border-bottom: 2px dashed var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 14px; }
.cat-logo {
  width: 52px; height: 52px;
  flex: none;
  filter: drop-shadow(2px 2px 0 rgba(58,53,45,.15));
  animation: cat-bob 3.2s ease-in-out infinite;
}
@keyframes cat-bob { 0%,100% { transform: rotate(0deg) translateY(0); } 50% { transform: rotate(-4deg) translateY(-3px); } }
.brand-text h1 {
  font-family: var(--font-hand);
  font-size: 30px;
  letter-spacing: 3px;
  line-height: 1.1;
  text-shadow: 2px 2px 0 rgba(199, 181, 245, .5);
}
.brand-text p { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
/* 猫窝档案：去框去底，纯文字按钮 */
#btnHistory {
  background: none;
  border: none;
  box-shadow: none;
  padding: 4px 2px;
  font-family: var(--font-hand);
  font-size: 17px;
  letter-spacing: 1px;
  color: var(--ink);
  cursor: pointer;
}
#btnHistory:hover { background: none; border: none; transform: none; opacity: .75; }
#btnHistory:active { transform: none; background: none; border: none; }
.topbar-badge {
  font-size: 12px;
  color: var(--ink-soft);
  border: 2px dashed var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  white-space: nowrap;
}

/* ===== 布局（控制项已拆进各页签，单列流式，全端一致） ===== */
.layout {
  display: block;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== 上传区（与背景同色，浏览器内居中） ===== */
.dropzone {
  background: var(--bg);
  border: 2.5px dashed transparent;
  border-radius: var(--hand-radius);
  padding: 10px;
  min-height: calc(80vh - 120px);
  display: flex;
  transition: border-color .2s, background .2s;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: #f5f1fb;
}
.dropzone-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}
.dropzone-inner h2 { font-family: var(--font-hand); font-size: 26px; letter-spacing: 2px; }
.dropzone-inner p { color: var(--ink-soft); font-size: 14px; }
.drop-hint { font-size: 14px !important; opacity: 1; }
/* 提示文字中的紫色强调 */
.hl-accent { color: var(--accent); }
/* 让喵挑一张：主按钮（手绘风） */
.pick-btn {
  font-family: var(--font-hand);
  font-size: 20px;
  letter-spacing: 2px;
  color: #3a352d;
  background: #cbbcf2;
  border: 2.5px solid #3a352d;
  border-radius: 12px 8px 12px 8px / 8px 12px 8px 12px;
  padding: 10px 28px;
  margin-top: 24px; /* 提示行距 12px × 3 = 36px */
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(58, 53, 45, .18);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.pick-btn:hover { background: #d8ccf6; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 rgba(58, 53, 45, .22); }
.pick-btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 rgba(58, 53, 45, .18); }
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-style: wavy;
}
.drop-cat {
  width: 84px; height: auto;
  position: relative;
  animation: cat-bob 2.4s ease-in-out infinite;
}
.drop-cat img { width: 100%; display: block; }
.drop-cat i { display: none; }

/* ===== 工作区 ===== */
.workspace { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.tabs {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 0 22px;
  margin-bottom: -26px;              /* 页签下端伸到文件夹后面（workspace flex gap 14px + 下探 12px） */
}
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;                       /* 未选中：不描线框 */
  background: #f3ecdc;                /* 默认：米灰收起标签 */
  font-family: var(--font-hand);
  font-size: 16px;
  letter-spacing: 1px;
  color: #7c7263;
  padding: 10px 30px 20px;
  cursor: pointer;
  border-radius: 12px 6px 12px 6px / 6px 12px 6px 12px;
  position: relative;
  z-index: 1;                         /* 垫在文件夹后面，上沿线穿过 */
  transition: background .15s, color .15s;
}
.tab:hover { background: #faf3e3; color: var(--ink); }
.tab.active {
  background: var(--primary);         /* 选中：紫色标签浮在文件夹前 */
  color: var(--ink);
  border: 2.5px solid #3a352d;
  border-bottom: none;
  border-radius: 12px 6px 0 0 / 6px 12px 0 0;
  padding: 10px 30px 12.5px;          /* 上10+边框2.5=下12.5，文字垂直居中 */
  margin-bottom: 12px;                /* 颜色止于线框上缘，齐平不溢出 */
  z-index: 3;
}
.tab.active::after {                  /* 页签正下方一段线框变紫，与文件身衔接 */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2.5px;
  height: 2.5px;
  background: var(--primary);
}
.tab-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  border: 2px solid #3a352d;
  border-radius: 50%;
  background: #fffdf6;
  font-family: var(--font-hand);
  font-size: 12px;
  color: var(--ink);
}

.panel { display: none; }
.panel.active {
  display: block;
  position: relative;
  z-index: 2;                         /* 文件夹身压住未选中页签 */
  background: #fffdf6;
  border: 2.5px solid #3a352d;
  border-radius: 14px;
  box-shadow: 5px 6px 0 rgba(58, 50, 43, 0.12);
  padding: 18px 22px 22px;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.compare figure {
  background: var(--card);
  border: 3px solid var(--ink);
  border-top-width: 2px;
  border-radius: var(--hand-radius);
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 0;
}
.compare figcaption {
  font-family: var(--font-hand);
  font-size: 15px;
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.fig-sub { font-family: var(--font-body); font-size: 13px; font-weight: 400; color: var(--ink-soft); }
.img-box {
  width: 100%;
  overflow: hidden;
  max-height: 62vh;
  border: 2px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  background: #f1ece0;
  cursor: grab;
}
.img-box canvas { display: block; max-width: 100%; height: auto; margin: 0 auto; image-rendering: pixelated; }
.panning { cursor: grabbing !important; }
.bead-bg {
  background-color: #f2ede1;
  background-image: radial-gradient(circle, rgba(139, 119, 80, 0.14) 2px, transparent 2.4px);
  background-size: 22px 22px;
}
.panel-tip { text-align: center; font-size: 12px; color: var(--ink-soft); margin-top: 8px; }

.chart-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  background: #faf6ec;
  border-radius: var(--hand-radius);
  padding: 10px 14px;
}
.btn-mini {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 2px solid #3a352d;
  background: #fffdf6;
  border-radius: 10px 5px 10px 5px / 5px 10px 5px 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: var(--font-hand);
  letter-spacing: 1px;
  color: var(--ink);
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s;
}
.btn-mini:hover { background: #fff; transform: translateY(-1px); box-shadow: 2px 2px 0 rgba(58, 50, 43, .18); }
.btn-mini:active { transform: translateY(1px); box-shadow: none; }
.btn-mini.active {
  background: var(--yellow);
  border-color: var(--ink);
}
.brush-swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  flex: none;
}
.brush-swatch.empty {
  background-image: linear-gradient(45deg, transparent 42%, #b9b2a4 42%, #b9b2a4 58%, transparent 58%) !important;
}
.edit-tip { font-size: 12px; color: var(--ink-soft); }

.chart-scroll {
  background-color: #f2ede1;
  border-radius: var(--hand-radius);
  padding: 16px;
  overflow: hidden;
  max-height: 72vh;
  cursor: grab;
  /* 图纸默认居画框中心，完整展示图案 */
  display: flex;
  align-items: center;
  justify-content: center;
}
/* 画布先缩到框内，超出的部分交给拖动/滚轮/加减号平移缩放 */
.chart-scroll canvas { display: block; margin: 0 auto; image-rendering: pixelated; max-width: 100%; height: auto; }
.chart-scroll.editing { cursor: default; }
.chart-scroll.editing canvas { cursor: crosshair; }

.legend {
  margin-top: 14px;
  background: #faf6ec;
  border-radius: var(--hand-radius);
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 2px solid var(--line);
  border-radius: 12px 5px 12px 5px / 5px 12px 5px 12px;
  padding: 5px 10px 5px 6px;
  font-size: 12px;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
  background: #fffdf6;
}
.legend-item:hover { transform: translateY(-2px) rotate(-1deg); border-color: var(--accent); }
.legend-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  flex: none;
}
.legend-meta b { font-size: 12px; }
.legend-meta span { color: var(--ink-soft); margin-left: 4px; }

/* 相近色号 */
.sim-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.sim-item i {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 1.5px solid rgba(0,0,0,0.25);
}

/* ===== 清单 ===== */
.list-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.summary-chip {
  background: var(--card);
  border: 2.5px dashed var(--line);
  border-radius: 12px 5px 12px 5px / 5px 12px 5px 12px;
  padding: 10px 16px;
  font-size: 13px;
}
.summary-chip b { font-family: var(--font-hand); font-size: 20px; margin-right: 4px; letter-spacing: 1px; }
.table-wrap {
  background: #fffdf6;
  border: 2.5px dashed #d8cdaf;
  border-radius: 14px;
  padding: 10px;
  overflow: auto;
  max-height: 62vh;
}
.mat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mat-table th, .mat-table td { padding: 8px 10px; text-align: left; white-space: nowrap; }
.mat-table thead th {
  font-family: var(--font-hand);
  letter-spacing: 1px;
  font-weight: 400;
  border-bottom: 2px dashed var(--line);
  position: sticky;
  top: -10px;
  background: #faf6ec;
}
.mat-table tbody tr { border-bottom: 1px dashed #efe8d6; }
.mat-table tbody tr:hover { background: #fdf6e3; }
.swatch-dot {
  display: inline-block;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  vertical-align: middle;
}

/* ===== 控制面板 ===== */
.controls { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 86px; }
.ctrl-card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-top-width: 2px;
  border-bottom-width: 4px;
  border-radius: var(--hand-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ctrl-card summary {
  font-family: var(--font-hand);
  font-size: 16px;
  letter-spacing: 1px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctrl-card summary::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--yellow);
  flex: none;
}
.ctrl-card:nth-child(2) summary::before { background: var(--blue); }
.ctrl-card:nth-child(3) summary::before { background: var(--green); }
.ctrl-card:nth-child(4) summary::before { background: var(--pink); }
.ctrl-body { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px; }

.size-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.size-presets button {
  border: 2.5px solid var(--line);
  background: #fffdf6;
  border-radius: 10px 5px 10px 5px / 5px 10px 5px 10px;
  padding: 8px 2px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  color: var(--ink-soft);
}
.size-presets button:hover { transform: translateY(-2px); border-color: var(--accent); }
.size-presets button.active {
  background: var(--yellow);
  border-color: var(--ink);
  color: var(--ink);
  font-weight: 700;
}
.row-inputs { display: flex; align-items: center; gap: 8px; }
.row-inputs label { font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 5px; flex: 1; }
.row-inputs input {
  width: 100%;
  border: 2.5px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 14px;
  background: #fffdf6;
  color: var(--ink);
}
.lock-btn {
  border: 2.5px solid var(--line);
  background: #fffdf6;
  border-radius: 8px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 14px;
  flex: none;
  filter: grayscale(1);
  opacity: .6;
}
.lock-btn.locked { filter: none; opacity: 1; border-color: var(--ink); background: var(--yellow); }

.slider-row { font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.slider-row b { color: var(--accent); }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 99px;
  border: 2px solid var(--ink);
  background: linear-gradient(90deg, var(--yellow), var(--pink), var(--blue));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(58,53,45,.25);
  cursor: pointer;
}
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.ctrl-note { font-size: 12px; color: var(--ink-soft); }

.btn-col { gap: 8px; }
.btn {
  border: 2.5px solid var(--ink);
  background: #fffdf6;
  border-radius: 12px 5px 12px 5px / 5px 12px 5px 12px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: var(--font-hand);
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(58,53,45,.16);
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px) rotate(-.5deg); box-shadow: 4px 4px 0 rgba(58,53,45,.16); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 rgba(0,0,0,0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: var(--primary);
}

.palette-info { padding: 14px 16px; }
.palette-info-head { font-family: var(--font-hand); letter-spacing: 1px; margin-bottom: 8px; }
.palette-strip {
  display: flex;
  height: 26px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 2px solid var(--ink);
}
.palette-strip i { flex: 1; display: block; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(58, 53, 45, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-top-width: 2px;
  border-bottom-width: 4px;
  border-radius: var(--hand-radius);
  box-shadow: 6px 6px 0 rgba(58,53,45,.2);
  padding: 20px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-card h3 { font-family: var(--font-hand); letter-spacing: 1px; font-size: 18px; }
.swap-from { font-family: var(--font-body); font-size: 13px; color: var(--ink-soft); }
.swap-search {
  border: 2.5px solid var(--line);
  border-radius: 10px 5px 10px 5px / 5px 10px 5px 10px;
  padding: 9px 12px;
  font-size: 13px;
  background: #fffdf6;
  color: var(--ink);
  outline: none;
}
.swap-search:focus { border-color: var(--accent); }
.swap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 6px;
  overflow: auto;
  padding: 4px;
}
.swap-cell {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 5px 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  background: #fffdf6;
  transition: transform .12s, border-color .12s;
}
.swap-cell:hover { transform: translateY(-2px); border-color: var(--accent); }
.swap-cell i {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--ink);
}
.swap-cell .empty-cell {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fafafa;
  border: 2px dashed #b9b2a4;
  position: relative;
}
.swap-cell .empty-cell::after {
  content: "";
  position: absolute;
  left: 20%; right: 20%; top: 46%;
  border-top: 2px solid #b9b2a4;
  transform: rotate(-45deg);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ===== 剪裁弹窗 ===== */
.crop-card { max-width: 640px; }
.crop-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  background: #f1ece0;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.crop-stage canvas {
  touch-action: none;
  cursor: move;
  border-radius: 4px;
}

/* ===== 猫窝档案（历史） ===== */
.history-card { max-width: 640px; }
.history-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px;
  min-height: 60px;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2.5px solid var(--line);
  border-radius: 12px 5px 12px 5px / 5px 12px 5px 12px;
  background: #fffdf6;
  padding: 8px 12px;
  transition: border-color .15s, transform .15s;
}
.history-item:hover { border-color: var(--accent); transform: translateX(2px); }
.history-thumb {
  width: 72px; height: 72px;
  flex: none;
  border: 2px solid var(--ink);
  border-radius: 8px;
  object-fit: contain;
  background: #f2ede1;
  image-rendering: pixelated;
}
.history-meta { flex: 1; min-width: 0; }
.history-meta b { font-size: 14px; display: block; }
.history-meta span { font-size: 12px; color: var(--ink-soft); display: block; margin-top: 2px; }
.history-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  padding: 30px 10px;
}

/* ===== 加载 ===== */
.loading {
  position: fixed; inset: 0;
  background: rgba(255, 253, 247, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 200;
}
.loading p { font-family: var(--font-hand); letter-spacing: 2px; color: var(--ink-soft); }
.loading-beads { display: flex; gap: 6px; }
.loading-beads span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--ink);
  animation: fill-bead 1s ease-in-out infinite;
}
.loading-beads span:nth-child(1) { background: var(--yellow); animation-delay: 0s; }
.loading-beads span:nth-child(2) { background: var(--pink); animation-delay: .12s; }
.loading-beads span:nth-child(3) { background: var(--blue); animation-delay: .24s; }
.loading-beads span:nth-child(4) { background: var(--green); animation-delay: .36s; }
.loading-beads span:nth-child(5) { background: var(--red); animation-delay: .48s; }
@keyframes fill-bead { 0%,100% { transform: scale(.7); opacity: .5; } 50% { transform: scale(1.15); opacity: 1; } }

/* ===== 喵之言（toast） ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fffdf6;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 12px 5px 12px 5px / 5px 12px 5px 12px;
  box-shadow: 4px 4px 0 rgba(58,53,45,.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 300;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 上传引导提示 ===== */
.drop-tips {
  margin-top: 6px; /* 与按钮间距一致：gap 12px + 6px = 18px */
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 460px;
}
.drop-tip {
  font-size: 9px;
  line-height: 1.5;
  padding: 4px 8px;
  border: none;
  border-radius: 10px 5px 10px 5px / 5px 10px 5px 10px;
  background: #fffdf6;
  color: var(--ink-soft);
  text-align: left;
}
/* 喵爱吃：浅黄虚线框 */
.drop-tip.good { border-color: #eed795; }
.drop-tip.bad { border-color: var(--red); }

/* ===== 去背景弹窗 ===== */
.bg-card { max-width: 640px; }
.bg-stage {
  display: flex; align-items: center; justify-content: center;
  background: #f2ede1;
  border: 2.5px solid var(--line);
  border-radius: 12px 5px 12px 5px / 5px 12px 5px 12px;
  padding: 10px;
  overflow: auto;
}
.bg-stage canvas {
  border: 2px solid var(--ink);
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
}
.bg-tools {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.bg-zoom {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  border: 2px dashed var(--line);
  border-radius: 10px 5px 10px 5px / 5px 10px 5px 10px;
}
/* 去背景工具第 2 行：拖动 + 缩放框 + 容差 + 模式，固定从行首开始 */
.bg-row2 {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.bg-zoom b { font-size: 12px; min-width: 40px; text-align: center; color: var(--accent); }
.color-tip {
  background: #fffdf6;
  border: 2px dashed var(--green); /* 与首页「喵爱吃」同款绿色虚线框 */
  border-radius: 10px 5px 10px 5px / 5px 10px 5px 10px;
  padding: 7px 10px;
}
.bg-tol { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.bg-tol input[type="range"] { width: 90px; accent-color: var(--accent); }
.bg-tol span { color: var(--accent); font-weight: 700; min-width: 20px; }
.bg-mode { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.bg-mode input { accent-color: var(--accent); }

/* ===== 风格选择弹窗 ===== */
.style-card { max-width: 720px; }
.style-detect {
  background: #fff6d8;
  border: 2px dashed var(--yellow);
  border-radius: 10px 5px 10px 5px / 5px 10px 5px 10px;
  padding: 8px 12px;
  font-size: 13px;
}
.style-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.style-item {
  position: relative;
  border: 2.5px solid var(--line);
  border-radius: 12px 5px 12px 5px / 5px 12px 5px 12px;
  background: #fffdf6;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform .12s, border-color .12s;
}
.style-item:hover { transform: translateY(-2px); border-color: var(--accent); }
.style-item.active { border-color: var(--accent); box-shadow: 3px 3px 0 rgba(168,139,224,.35); }
.style-thumb-wrap {
  width: 100%;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
}
.style-thumb-wrap canvas {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  image-rendering: pixelated;
}
.style-item b { font-size: 13px; }
.style-badge {
  position: absolute;
  top: -8px; right: -6px;
  background: var(--accent);
  color: #fffdf6;
  font-size: 10px;
  padding: 2px 7px;
  border: 2px solid var(--ink);
  border-radius: 10px 4px 10px 4px / 4px 10px 4px 10px;
  transform: rotate(4deg);
}
.style-work {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
  align-items: start;
}
.style-preview-box {
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid var(--line);
  border-radius: 12px 5px 12px 5px / 5px 12px 5px 12px;
  padding: 10px;
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
}
.style-preview-box canvas {
  max-width: 100%; max-height: 300px;
  width: auto; height: auto;
  border: 2px solid var(--ink);
  border-radius: 6px;
  image-rendering: pixelated;
}
.style-params {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px;
}
.style-params .slider-row label { font-size: 13px; }
.style-params select {
  border: 2.5px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  background: #fffdf6;
  color: var(--ink);
  outline: none;
  font-family: var(--font-body);
}
.style-params select:focus { border-color: var(--accent); }


/* ===== 移动端 ===== */
@media (max-width: 900px) {
  .layout { padding: 12px; }
  .brand-text h1 { font-size: 22px; }
  .brand-text p { display: none; }
  .topbar-badge { display: none; }
  .tab { font-size: 14px; }
  .img-box { max-height: 45vh; }
  .chart-scroll { max-height: 55vh; padding: 8px; }
  .dropzone { min-height: 45vh; }
  .doodle { display: none; }
  .cat-logo { width: 44px; height: 44px; }
}

/* ===== 预览页顶部工具栏内联控件 / 图纸页 CTA ===== */
.tb-group {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.tb-group .tb-label {
  font-family: var(--font-hand);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tb-group input[type="number"] {
  width: 58px;
  padding: 5px 6px;
  border: 2.5px solid var(--ink);
  border-radius: 8px 4px 8px 4px / 4px 8px 4px 8px;
  background: #fffdf6;
  font-family: var(--font-hand);
  font-size: 14px;
  text-align: center;
}
.tb-group input[type="range"] { width: 110px; accent-color: var(--accent); }
.tb-group > b { color: var(--accent); font-size: 14px; min-width: 22px; text-align: center; }
.tb-group .ctrl-note { white-space: nowrap; }
.panel-cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.preview-figure { margin: 0; }
.preview-figure .img-box { max-height: 58vh; }
/* 「喵排的豆豆」标题：手写体粗字，无外框 */
.preview-figure figcaption {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-family: var(--font-hand);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--ink);
  margin-bottom: 10px;
}
.preview-figure .size-note { color: var(--ink-soft); font-weight: 400; }

/* 导出页：清单副标题 + 一行导出按钮（副标题一律无外框，纯手写体粗字） */
.list-title,
.card-title {
  margin: 4px 0 8px;
  font-family: var(--font-hand);
  font-size: 16px;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: var(--ink);
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
}
.card-title { margin: 0; }
.export-btn-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  background: #faf6ec;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
/* 图纸名字输入框（✍️ 图标 + 仅底线） */
.rename-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-hand);
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
}
.rename-ico { font-size: 17px; line-height: 1; }
.rename-field input {
  width: 210px;
  border: none;
  border-bottom: 2.5px solid #3a352d;
  border-radius: 0;
  background: transparent;
  padding: 6px 4px;
  font-family: var(--font-hand);
  font-size: 15px;
  color: var(--ink);
  outline: none;
}
.rename-field input:focus { border-bottom-color: var(--accent); }

/* 编辑图纸页：图纸长相行 / 色号板标题行 */
.chart-look-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 10px;
}
.look-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.look-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}
.legend-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 14px 0 8px;
}
.legend-hint { font-size: 13px; font-weight: 400; color: var(--ink-soft); }

@media (max-width: 768px) {
  .compare { grid-template-columns: 1fr; }
  .mat-table th, .mat-table td { white-space: normal; padding: 6px 8px; }
  .table-wrap { overflow-x: auto; }
  .size-presets { grid-template-columns: repeat(2, 1fr); }
  .modal-card, .crop-card, .history-card, .bg-card, .style-card { max-width: 94vw; padding: 14px; }
  .chart-toolbar { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .style-grid { grid-template-columns: repeat(2, 1fr); }
  .style-work { grid-template-columns: 1fr; }
  .style-params { flex-direction: row; flex-wrap: wrap; gap: 10px 16px; }
  .bg-tools { flex-wrap: wrap; }
  .drop-tips { max-width: 100%; }
  .tabs { position: sticky; top: 0; z-index: 12; background: var(--bg); margin-bottom: 0; padding: 0 2px; gap: 8px; }
  .tab { padding: 8px 14px 10px; font-size: 14px; }
  .tab.active { margin-bottom: 0; padding: 8px 14px 10px; }
  .panel.active { padding: 14px 12px 16px; }
  .tb-group { width: 100%; }
  .tb-group input[type="range"] { width: 96px; }
  .panel-cta-row .btn { min-width: 100%; }
  .export-btn-row { flex-direction: column; }
  .export-btn-row .btn { width: 100%; }
  .panel-tip { font-size: 12px; }
}

/* 主行动按钮（下一步引导） */
.btn-cta {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 800;
  animation: cta-breath 2.4s ease-in-out infinite;
}
@keyframes cta-breath {
  0%, 100% { box-shadow: 0 0 0 0 rgba(156,194,127,.55); }
  50% { box-shadow: 0 0 0 7px rgba(156,194,127,0); }
}

@media (max-width: 480px) {
  .dropzone-inner { padding: 18px 14px; }
  .dropzone-inner h2 { font-size: 20px; }
  .tab { font-size: 13px; padding: 8px 8px 10px; gap: 5px; }
  .tab.active { padding: 8px 8px 10px; }
  .tab-num { width: 20px; height: 20px; font-size: 10px; }
  .ctrl-body { padding: 4px 12px 12px; gap: 10px; }
  .summary-chip { padding: 8px 10px; }
  .modal-card { padding: 12px; gap: 8px; }
  .modal-actions .btn { flex: 1; }
  .drop-tip { font-size: 11.5px; }
}

/* ===== 图片处理弹窗（剪裁+去背景+调色 三合一） ===== */
.proc-card { max-width: min(760px, 94vw); }
.proc-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.proc-tab {
  flex: 1;
  font-family: var(--font-hand);
  font-size: 16px;
  letter-spacing: 1px;
  padding: 9px 6px;
  cursor: pointer;
  background: #fff;
  color: var(--ink-soft);
  border: 2px solid var(--line);
  border-radius: 12px 5px 14px 6px / 6px 14px 5px 12px;
  transition: color .15s, background .15s, border-color .15s;
}
.proc-tab:hover { color: var(--ink); border-color: var(--accent); }
.proc-tab.active {
  background: var(--primary);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 rgba(45, 37, 40, .15);
}
.proc-stage {
  background: #faf7f0;
  border: 3px dashed #d8cdaf;
  border-radius: 14px 6px 16px 8px / 8px 16px 6px 14px;
  padding: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}
.proc-stage canvas { display: block; max-width: 100%; }
/* 处理弹窗：窗口矮时卡片内部滚动，stage 保持自然高度，画布不得戳出虚线框 */
#processModal .modal-card { overflow-y: auto; }
#processModal .proc-stage { flex-shrink: 0; }
/* 处理弹窗紧凑化：整体收紧 + 底部按钮 sticky 永远可见 */
#processModal .modal-card { gap: 8px; padding: 14px 16px 16px; max-height: 94vh; }
#processModal .proc-tabs { margin-bottom: 2px; }
#processModal .proc-stage { padding: 8px; }
#processModal .proc-tools { margin-top: 6px; gap: 6px; row-gap: 6px; }
#processModal .proc-tools .btn-mini { padding: 6px 9px; font-size: 12px; }
#processModal .ctrl-note { margin: 2px 0 0; }
/* 提示文字（procInfo）紧贴 sticky 按钮栏，留出滚动余量避免被按钮栏遮住下半截 */
#processModal #procInfo { margin: 2px 0 56px; }
#processModal .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 4px -16px -16px;
  padding: 10px 16px 14px;
  background: var(--card);
}
#processModal .modal-actions .btn { padding: 9px 12px; }
.proc-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.proc-tip { font-size: 13px; color: var(--ink-soft); }
.proc-tip.soft { opacity: .75; font-size: 12px; }
.proc-slider { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.proc-slider input[type="range"] { width: 110px; }
.proc-slider b { min-width: 34px; text-align: right; color: var(--ink); font-size: 13px; }

/* ===== 上传框：文案居左 + 场景图右侧居中 ===== */
#dropzone { position: relative; overflow: hidden; }
.drop-scene {
  position: absolute;
  right: 0;
  bottom: 0;
  height: 92%;
  width: auto;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  animation: sceneCrossfade 14s ease-in-out infinite;
}
.drop-scene-b {
  animation-delay: -7s;
  height: 88%;
  right: -75px;
}
#dropzone .dropzone-inner > :not(.drop-scene) { position: relative; z-index: 1; }
@keyframes sceneCrossfade {
  0%, 42% { opacity: 1; }
  50%, 92% { opacity: 0; }
  100% { opacity: 1; }
}
#dropzone .dropzone-inner {
  position: relative;
  z-index: 1;
  align-items: flex-start;
  text-align: left;
  padding: 44px 24px 44px 60px;
}
#dropzone .dropzone-inner h2,
#dropzone .dropzone-inner > p {
  max-width: 44%;
}
#dropzone .dropzone-inner h2 {
  max-width: 62%;
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.4;
  letter-spacing: 2px;
  margin: 0 0 4px;
}
#dropzone .drop-tips { text-align: left; max-width: 110%; width: max-content; }
#brandHome { cursor: pointer; }

/* 预览 / 图纸画布可拖动提示 */
#cvEffect, #cvChart { cursor: grab; }
#effectBox.panning canvas, #chartBox.panning canvas { cursor: grabbing; }

@media (max-width: 760px) {
  #dropzone { display: block; min-height: 0; }
  #dropzone .dropzone-inner {
    max-width: 100%;
    width: 100%;
    align-items: center;
    text-align: center;
    padding: 28px 14px 50vw;
  }
  #dropzone .dropzone-inner h2 { font-size: 24px; }
  #dropzone .dropzone-inner h2,
  #dropzone .dropzone-inner > p { max-width: 100%; }
  #dropzone .drop-tips { text-align: left; max-width: 100%; width: auto; }
  .drop-scene { left: 50%; right: auto; bottom: 4px; transform: translateX(-50%); width: 86%; height: auto; }
  .drop-scene-b { width: 86%; }
  .proc-stage { min-height: 150px; padding: 8px; }
}

/* ===== 图框缩放按钮（＋/－） ===== */
#effectBox, #chartBox { position: relative; }
.zoom-ctrl {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}
.zoom-btn {
  width: 30px;
  height: 30px;
  border: 2px solid #2b2b2b;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
  color: #2b2b2b;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(43, 43, 43, 0.25);
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0;
}
.zoom-btn:hover { background: #ffe9a8; }
.zoom-btn:active { transform: translateY(1px); box-shadow: 1px 1px 0 rgba(43, 43, 43, 0.25); }
/* 镜像 / 抓手按钮：图标 + 文字竖排居中，比加减号稍高 */
.zoom-btn.mirror-btn,
.zoom-btn.grab-btn {
  width: auto;
  height: auto;
  min-width: 34px;
  padding: 4px 6px 3px;
  flex-direction: column;
  gap: 1px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 1px;
  line-height: 1.1;
}
.zoom-btn.mirror-btn.active,
.zoom-btn.grab-btn.active { background: #ffe9a8; }
/* 加减号按钮的文字符号（与镜像按钮同大小：大符号 + 小文字） */
.zoom-btn .zoom-glyph { font-size: 15px; font-weight: 700; line-height: 1; }

/* ===== 预览页「对比」模式：左原图右图纸（移动端同样左右排布，各占一半） ===== */
#compareImg { display: none; }
.img-box.compare-mode { align-items: center; gap: 10px; }
.img-box.compare-mode #compareImg {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  max-width: 50%;
  margin: 0;
  height: auto;
  max-height: 100%;
  image-rendering: auto;
  border-radius: 6px;
}
.img-box.compare-mode #cvEffect {
  flex: 1 1 0;
  min-width: 0;
  max-width: 50%;
  margin: 0;
}
/* 对比模式：左「原图」右「预览图」标注 + 中间虚线分隔 */
.compare-tag {
  display: none;
  position: absolute;
  top: 8px;
  z-index: 6;
  font-family: var(--font-hand);
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--ink);
  background: rgba(255, 253, 246, 0.92);
  border: 2px solid var(--ink);
  border-radius: 8px 4px 8px 4px / 4px 8px 4px 8px;
  padding: 2px 9px;
  pointer-events: none;
}
.compare-tag.tag-l { left: 8px; }
.compare-tag.tag-r { right: 8px; }
.img-box.compare-mode .compare-tag { display: block; }
.img-box.compare-mode::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  bottom: 6px;
  border-left: 2px dashed #b9ae90;
  z-index: 4;
  pointer-events: none;
}
