/* ===== 拼豆喵 · 手绘拙趣 × 紫帽魔法喵 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(--card);
  border-bottom: 3px 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; }
.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: grid;
  /* minmax(0,1fr)：1fr 的 auto 最小尺寸会被图纸内容撑爆页面（侧栏被挤出视口） */
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  align-items: start;
}

/* ===== 上传区 ===== */
.dropzone {
  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);
  padding: 10px;
  min-height: 60vh;
  display: flex;
}
.dropzone.dragover .dropzone-inner {
  border-color: var(--accent);
  background: #f5f1fb;
}
.dropzone-inner {
  flex: 1;
  border: 3px dashed #d8cdaf;
  border-radius: 14px 6px 16px 8px / 8px 16px 6px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
  transition: border-color .2s, background .2s;
}
.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: 12px !important; opacity: .8; }
.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;
  background: var(--card);
  border: 3px solid var(--ink);
  border-top-width: 2px;
  border-radius: var(--hand-radius);
  box-shadow: var(--shadow);
  padding: 6px;
  gap: 4px;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-hand);
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--ink-soft);
  padding: 10px 8px;
  cursor: pointer;
  border-radius: 12px 5px 14px 6px / 6px 14px 5px 12px;
  position: relative;
  z-index: 1;
  transition: color .2s;
}
.tab.active { color: var(--ink); }
.tab-ink {
  position: absolute;
  top: 6px; bottom: 6px;
  width: calc((100% - 12px - 8px) / 3);
  left: 6px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 12px 5px 14px 6px / 6px 14px 5px 12px;
  transition: transform .25s cubic-bezier(.4, 1.4, .6, 1);
  z-index: 0;
}

.panel { display: none; }
.panel.active { display: block; }

.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: 12px; 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: var(--card);
  border: 3px solid var(--ink);
  border-top-width: 2px;
  border-radius: var(--hand-radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
}
.btn-mini {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 2.5px solid var(--ink);
  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;
  box-shadow: 2px 2px 0 rgba(58,53,45,.18);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.btn-mini:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 rgba(58,53,45,.18); }
.btn-mini:active { transform: translate(2px, 2px); box-shadow: 0 0 0 rgba(0,0,0,0); }
.btn-mini.active {
  background: var(--yellow);
}
.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: 3px solid var(--ink);
  border-top-width: 2px;
  border-radius: var(--hand-radius);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: hidden;
  max-height: 72vh;
  cursor: grab;
}
/* 画布先缩到框内，超出的部分交给拖动/滚轮/加减号平移缩放 */
.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: var(--card);
  border: 3px solid var(--ink);
  border-top-width: 2px;
  border-radius: var(--hand-radius);
  box-shadow: var(--shadow);
  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 solid var(--ink);
  border-radius: 12px 5px 12px 5px / 5px 12px 5px 12px;
  box-shadow: 2px 2px 0 rgba(58,53,45,.15);
  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: var(--card);
  border: 3px solid var(--ink);
  border-top-width: 2px;
  border-radius: var(--hand-radius);
  box-shadow: var(--shadow);
  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: var(--card);
}
.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: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 460px;
}
.drop-tip {
  font-size: 12.5px;
  line-height: 1.6;
  padding: 8px 12px;
  border-radius: 10px 5px 10px 5px / 5px 10px 5px 10px;
  border: 2px dashed var(--line);
  background: #fffdf6;
  color: var(--ink-soft);
  text-align: left;
}
.drop-tip.good { border-color: var(--green); }
.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;
}
.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 { grid-template-columns: 1fr; padding: 12px; gap: 14px; }
  .controls { position: static; order: 2; }
  .stage { order: 1; }
  .compare { grid-template-columns: 1fr; }
  .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; }
}

@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%; }
}

@media (max-width: 480px) {
  .dropzone-inner { padding: 18px 14px; }
  .dropzone-inner h2 { font-size: 20px; }
  .tab { font-size: 13px; padding: 8px 4px; }
  .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; }
#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: 1%;
  bottom: 4px;
  width: min(58%, 620px);
  pointer-events: none;
  user-select: none;
  z-index: 0;
  animation: sceneCrossfade 14s ease-in-out infinite;
}
.drop-scene-b {
  animation-delay: -7s;
  right: -14px;
  width: min(58%, 620px);
}
#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 48px;
}
#dropzone .dropzone-inner h2,
#dropzone .dropzone-inner > p {
  max-width: 55%;
}
#dropzone .dropzone-inner h2 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.4;
  letter-spacing: 2px;
  margin: 0 0 4px;
}
#dropzone .drop-tips { text-align: left; max-width: 130%; 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%; }
  .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;
}
.zoom-btn:hover { background: #ffe9a8; }
.zoom-btn:active { transform: translateY(1px); box-shadow: 1px 1px 0 rgba(43, 43, 43, 0.25); }
