/* ===========================================================
   拼豆图纸生成器 · 样式表
   =========================================================== */
:root {
  --bg: #f6f5f9;
  --bg2: #fdf7fa;
  --panel: #ffffff;
  --line: #e9e6ef;
  --line-strong: #dcd7e6;
  --text: #221f2e;
  --text-2: #6a6580;
  --text-3: #9a94ac;
  --accent: #ff5d8f;
  --accent-d: #f03e77;
  --accent-soft: #fff0f5;
  --violet: #7c6cf5;
  --teal: #23b5ad;
  --danger: #e5484d;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(34, 31, 46, .04), 0 8px 24px -12px rgba(34, 31, 46, .12);
  --shadow-lg: 0 24px 60px -20px rgba(34, 31, 46, .22);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* 统一兜底：带 hidden 属性的一律不显示，避免被 display 类规则覆盖 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

/* 吸顶导航会挡住滚动目标，留出安全距离 */
html { scroll-padding-top: 84px; scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 12% -10%, #ffe9f1 0%, transparent 60%),
    radial-gradient(900px 460px at 92% 0%, #eae7ff 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1560px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: #fff; border: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 6px;
  box-shadow: var(--shadow);
}
.brand-mark i { border-radius: 3px; background: var(--c); display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; letter-spacing: .2px; }
.brand-text em { font-style: normal; font-size: 11.5px; color: var(--text-3); letter-spacing: .4px; }
.topnav { display: flex; gap: 4px; }
.topnav a {
  padding: 7px 14px; border-radius: 999px; text-decoration: none;
  color: var(--text-2); font-size: 13.5px; transition: .18s;
}
.topnav a:hover { background: var(--accent-soft); color: var(--accent-d); }

/* ---- 顶栏用户信息（登录态由 auth.js 注入） ---- */
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 6px 4px 4px; border-radius: 999px;
  background: #f7f5fd; border: 1px solid rgba(108, 92, 231, .12);
}
.uc-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #7c6cf5, #a98bfb);
  color: #fff; font-size: 13px; font-weight: 800; letter-spacing: .3px;
}
.uc-main { display: flex; flex-direction: column; line-height: 1.15; padding-right: 4px; }
.uc-main b { font-size: 12.5px; font-weight: 700; color: var(--text); max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-main i { font-style: normal; font-size: 11px; color: var(--text-3); }
.uc-btn {
  height: 28px; padding: 0 11px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-size: 12px; font-weight: 650;
  transition: .16s; font-family: inherit;
}
.uc-btn:hover { background: var(--accent-d); }
.uc-btn.ghost { background: transparent; color: var(--text-3); border: 1px solid var(--line-strong); }
.uc-btn.ghost:hover { background: #fff; color: var(--text-2); }
.uc-more { font-style: normal; }
.uc-acts { display: flex; align-items: center; gap: 9px; }
.uc-kebab {
  display: none; width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
  background: #efeafd; color: #6c5ce7; font-size: 15px; line-height: 1; font-family: inherit;
}
.user-chip.is-expired .uc-main i { color: #d94a3d; font-weight: 600; }
.user-chip.is-expired .uc-avatar { background: linear-gradient(145deg, #f0857a, #e2604f); }
.user-chip.need-bind { background: #fff8ea; border-color: #f2dca4; }
.uc-btn.bind { background: #f0a01e; }
.uc-btn.bind:hover { background: #d98c12; }

/* 未登录：顶栏登录/注册入口 */
.guest-box { display: flex; align-items: center; gap: 8px; }
.guest-box[hidden] { display: none; }
.guest-link {
  padding: 7px 14px; border-radius: 999px; text-decoration: none;
  font-size: 13px; font-weight: 600; color: var(--text-2); border: 1px solid var(--line-strong);
  transition: .16s; background: #fff;
}
.guest-link:hover { color: var(--accent-d); border-color: var(--accent); }
.guest-pri {
  padding: 7px 16px; border-radius: 999px; text-decoration: none;
  font-size: 13px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #7c6cf5, #a78dff);
  box-shadow: 0 6px 16px -8px rgba(108, 92, 231, .8); transition: .16s;
}
.guest-pri:hover { filter: brightness(1.06); }

.auth-toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 300;
  transform: translate(-50%, 14px); opacity: 0; pointer-events: none;
  background: #221f2e; color: #fff; font-size: 13px; padding: 10px 20px;
  border-radius: 999px; box-shadow: 0 12px 30px -12px rgba(34, 31, 46, .5);
  transition: .22s; max-width: min(560px, 90vw); text-align: center;
}
.auth-toast.show { opacity: 1; transform: translate(-50%, 0); }
.auth-toast[data-kind="err"] { background: #a8332a; }
.auth-toast[data-kind="warn"] { background: #8a5a12; }

@media (max-width: 900px) {
  /* 手机上收紧而不是隐藏：兑换/退出都是必须能点到的 */
  .uc-main b { display: none; }
  .uc-avatar { width: 26px; height: 26px; font-size: 12px; }
  .user-chip { gap: 6px; padding: 3px 4px 3px 3px; }
  .uc-main { padding-right: 0; }
  .uc-main i { font-size: 10.5px; white-space: nowrap; }
  .uc-btn { height: 26px; padding: 0 8px; font-size: 11.5px; }
  .uc-more { display: none; }
}
@media (max-width: 420px) {
  .brand-text em { display: none; }
  .uc-btn.ghost { padding: 0 6px; }
}
@media (max-width: 560px) {
  /* 手机上把「绑定 / 兑换 / 退出」收进 ⋯ 菜单，顶栏只留头像 + 剩余天数 */
  .uc-kebab { display: grid; place-items: center; }
  .user-chip { position: relative; gap: 6px; }
  .user-chip .uc-acts { display: none; }
  .user-chip.open .uc-acts {
    display: flex; flex-direction: column; gap: 6px;
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
    background: #fff; padding: 8px; border-radius: 14px;
    box-shadow: 0 18px 40px -14px rgba(34, 31, 46, .38), 0 0 0 1px var(--line);
  }
  .user-chip.open .uc-btn { display: inline-flex; align-items: center; justify-content: center; width: 118px; height: 32px; font-size: 12.5px; }
  .user-chip.open .uc-more { display: inline; }
  .topbar-inner { gap: 8px; }
  .brand-text strong { white-space: nowrap; }
  .brand-text em { display: none; }
  .topnav a { white-space: nowrap; }
}

/* ---------------- 主布局 ---------------- */
.layout {
  max-width: 1840px; margin: 0 auto; padding: 16px 18px 8px;
  display: grid;
  /* 中栏画布优先：两侧只在必要时变窄，屏幕越宽画布越大 */
  grid-template-columns: clamp(258px, 17vw, 300px) minmax(0, 1fr) clamp(266px, 18vw, 312px);
  gap: 14px; align-items: start;
}
.col-left, .col-right {
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 76px;
  max-height: calc(100vh - 92px); overflow-y: auto;
  padding-right: 4px; margin-right: -4px;
  scrollbar-width: thin; scrollbar-color: #ddd8e8 transparent;
}
.col-left::-webkit-scrollbar, .col-right::-webkit-scrollbar { width: 7px; }
.col-left::-webkit-scrollbar-thumb, .col-right::-webkit-scrollbar-thumb { background: #d5cfe2; border-radius: 99px; }
.col-left::-webkit-scrollbar-thumb:hover, .col-right::-webkit-scrollbar-thumb:hover { background: #c3bcd4; }
.col-left::-webkit-scrollbar-track, .col-right::-webkit-scrollbar-track { background: transparent; }
.col-center { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card-grow { display: flex; flex-direction: column; min-height: 0; }
/* 侧栏是定高滚动容器，卡片不允许被压缩，否则内容会溢出压到下一张卡片 */
.col-left > .card, .col-right > .card { flex: 0 0 auto; }
.card-title {
  margin: 0 0 12px; font-size: 13.5px; font-weight: 700; letter-spacing: .3px;
  display: flex; align-items: center; gap: 8px; color: var(--text);
}
.card-title .step {
  width: 19px; height: 19px; border-radius: 6px; flex: none;
  background: var(--accent-soft); color: var(--accent-d);
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.btn-mini {
  margin-left: auto; border: 1px solid var(--line-strong); background: #fff;
  color: var(--text-2); font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  cursor: pointer; font-family: inherit; transition: .15s;
}
.btn-mini:hover { border-color: var(--accent); color: var(--accent-d); }

/* ---------------- 上传区 ---------------- */
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fdfcff, #faf8fd);
  padding: 20px 12px;
  text-align: center; cursor: pointer;
  transition: .18s; outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.drag { border-color: var(--accent-d); background: var(--accent-soft); transform: scale(.995); }
.dz-icon { width: 26px; height: 26px; color: var(--accent); margin-bottom: 6px; }
.dz-empty p { margin: 0; font-size: 13px; font-weight: 600; }
.dz-empty small { color: var(--text-3); font-size: 11.5px; }
.dz-preview { display: flex; align-items: center; gap: 10px; text-align: left; }
.dz-preview[hidden] { display: none; }
.dz-preview img {
  width: 52px; height: 52px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--line); background: #fff; flex: none;
}
.dz-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.dz-meta span { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-meta small { color: var(--text-3); font-size: 11px; }
.dz-change {
  border: 1px solid var(--line-strong); background: #fff; border-radius: 8px;
  padding: 4px 10px; font-size: 11.5px; cursor: pointer; color: var(--text-2); font-family: inherit;
}
.dz-change:hover { border-color: var(--accent); color: var(--accent-d); }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.numfield {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 0 10px; height: 36px; background: #fff;
}
.numfield span { font-size: 11.5px; color: var(--text-3); flex: none; }
.numfield input {
  border: 0; outline: 0; width: 100%; font-family: var(--mono);
  font-size: 13.5px; font-weight: 600; color: var(--text); background: transparent;
  -moz-appearance: textfield;
}
.numfield input::-webkit-outer-spin-button,
.numfield input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.numfield:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

select {
  width: 100%; height: 36px; padding: 0 30px 0 11px; font-family: inherit; font-size: 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff 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='%239a94ac' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--text); appearance: none; cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); cursor: pointer; margin-top: 9px; }
.check.inline { margin-top: 0; padding-left: 4px; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #f2f0f6; padding: 3px; border-radius: var(--radius-sm); }
.seg {
  border: 0; background: transparent; padding: 7px 4px; border-radius: 8px;
  font-size: 12.5px; font-family: inherit; color: var(--text-2); cursor: pointer; transition: .16s; font-weight: 500;
}
.seg:hover { color: var(--text); }
.seg.active { background: #fff; color: var(--accent-d); font-weight: 700; box-shadow: 0 1px 3px rgba(34,31,46,.12); }

.slider-row { display: grid; grid-template-columns: 44px 1fr 34px; align-items: center; gap: 8px; margin-bottom: 6px; }
.slider-row span { font-size: 12px; color: var(--text-2); }
.slider-row output { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); text-align: right; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 5px; border-radius: 999px;
  background: #e8e4f0; outline: none; cursor: pointer; width: 100%;
  transition: background .12s;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); cursor: pointer;
  box-shadow: 0 1px 4px rgba(34,31,46,.2); transition: .15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
  border: 2px solid var(--accent); cursor: pointer;
}

.hint { margin: 7px 0 0; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.hint.center { text-align: center; }

/* ---------------- 色板 ---------------- */
.palette-tabs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.pal-tab {
  border: 1px solid var(--line-strong); background: #fff; color: var(--text-2);
  font-size: 11.5px; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  font-family: inherit; transition: .15s; font-weight: 500;
}
.pal-tab:hover { border-color: var(--accent); color: var(--accent-d); }
.pal-tab.active { background: var(--text); border-color: var(--text); color: #fff; font-weight: 600; }

.swatches {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px;
  max-height: 168px; overflow-y: auto; padding-right: 2px;
}
.sw {
  position: relative; aspect-ratio: 1; border-radius: 4px; cursor: pointer;
  border: 1px solid rgba(0,0,0,.09); padding: 0; transition: transform .12s;
  outline: none;
}
.sw:hover { transform: scale(1.18); z-index: 2; box-shadow: 0 3px 10px rgba(34,31,46,.22); }
.sw.active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); z-index: 3; }
.sw:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--violet); }
.swatches::-webkit-scrollbar { width: 5px; }
.swatches::-webkit-scrollbar-thumb { background: #ddd8e8; border-radius: 99px; }

.custom-mgr { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.custom-add { display: grid; grid-template-columns: 32px 1fr auto; gap: 6px; align-items: center; }
.custom-add input[type="color"] {
  width: 32px; height: 30px; padding: 2px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.custom-add input[type="text"] {
  height: 30px; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 0 9px; font-family: inherit; font-size: 12px; outline: 0; width: 100%; color: var(--text);
}
.custom-add input[type="text"]:focus { border-color: var(--accent); }

/* ---------------- 工具栏 ---------------- */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; box-shadow: var(--shadow);
}
.tools { display: flex; gap: 2px; }
.tool {
  width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent;
  color: var(--text-2); cursor: pointer; display: grid; place-items: center;
  transition: .15s; padding: 0;
}
.tool svg { width: 18px; height: 18px; }
.tool:hover:not(:disabled) { background: #f4f2f8; color: var(--text); }
.tool.active { background: var(--text); color: #fff; }
.tool:disabled { opacity: .32; cursor: not-allowed; }
.tool-sep { width: 1px; height: 20px; background: var(--line); }
.brush-size { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-2); }
.brush-size input[type="range"] { width: 62px; }
.brush-size output { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); width: 10px; }
.history { display: flex; gap: 2px; }
.current-color {
  margin-left: auto; display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px 3px 4px;
  background: #fbfafd; font-size: 11.5px; color: var(--text-2);
}
.current-color i {
  width: 20px; height: 20px; border-radius: 50%; display: block;
  border: 1px solid rgba(0,0,0,.12); background: #ccc;
}
.current-color span { font-family: var(--mono); font-weight: 600; }

/* ---------------- 画布 ---------------- */
.board-wrap {
  background: #f7f6fa; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); flex: 1 1 auto;
  height: clamp(420px, calc(100vh - 218px), 1000px);
  display: flex; padding: 12px; overflow: auto;
  background-position: 0 0, 8px 8px;
}
.board-inner { position: relative; line-height: 0; margin: auto; flex: none; }
#board {
  display: block; border-radius: 12px; touch-action: none; cursor: crosshair;
  box-shadow: 0 0 0 1px rgba(34,31,46,.06), 0 12px 28px -14px rgba(34,31,46,.3);
  background: #f2f2f2; image-rendering: pixelated;
}
.board-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; text-align: center;
  background: rgba(255,255,255,.9); border-radius: 4px; padding: 20px;
  line-height: 1.5;
}
.board-empty[hidden] { display: none; }
.board-empty svg { width: 34px; height: 34px; color: #cfc9dd; margin-bottom: 6px; }
.board-empty p { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
.board-empty small { font-size: 11.5px; color: var(--text-3); }

/* ---------------- 按钮 ---------------- */
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: .16s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--accent); color: var(--accent-d); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #f8457c 100%);
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px -6px rgba(255, 93, 143, .7);
}
.btn-primary:hover { background: linear-gradient(135deg, #ff6d9a 0%, var(--accent-d) 100%); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); font-weight: 500; }
.btn-ghost:hover { background: #f2f0f6; color: var(--text); border-color: transparent; }
.btn-danger:hover { background: #fff0f0; color: var(--danger); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------------- 预览 & 统计 ---------------- */
.preview-box {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  background: #fbfafd; border: 1px solid var(--line);
  display: grid; place-items: center; min-height: 150px; padding: 10px;
}
#preview { max-width: 100%; height: auto; display: none; image-rendering: pixelated; border-radius: 4px; }
.preview-empty { margin: 0; font-size: 11.5px; color: var(--text-3); text-align: center; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat {
  background: #fbfafd; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 4px; text-align: center;
}
.stat b { display: block; font-size: 16px; font-family: var(--mono); letter-spacing: -.5px; color: var(--text); }
.stat span { font-size: 10.5px; color: var(--text-3); }

/* ---------------- 色号清单 ---------------- */
.legend { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; max-height: 340px; padding-right: 2px; }
.legend-empty { margin: 0; font-size: 11.5px; color: var(--text-3); line-height: 1.6; }
.legend-row {
  display: grid; grid-template-columns: 20px 46px 1fr auto; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 7px; font-size: 12px; cursor: pointer; transition: .13s;
}
.legend-row:hover { background: #f7f5fb; }
.legend-row i {
  width: 20px; height: 20px; border-radius: 5px; display: block;
  border: 1px solid rgba(0,0,0,.12);
}
.legend-row .lg-code { font-family: var(--mono); font-weight: 700; font-size: 11.5px; }
.legend-row .lg-name { color: var(--text-2); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .lg-count { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.legend::-webkit-scrollbar { width: 5px; }
.legend::-webkit-scrollbar-thumb { background: #ddd8e8; border-radius: 99px; }

/* ---------------- 草稿 ---------------- */
.drafts { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.draft-row {
  display: flex; align-items: center; gap: 9px; padding: 6px; border-radius: 9px;
  border: 1px solid var(--line); background: #fdfcff; font-size: 12px;
}
.draft-row canvas { width: 38px; height: 38px; border-radius: 6px; border: 1px solid var(--line); flex: none; background: #fff; }
.draft-info { flex: 1; min-width: 0; }
.draft-info b { display: block; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-info small { color: var(--text-3); font-size: 10.5px; }
.draft-row button {
  border: 0; background: transparent; color: var(--text-3); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 4px; border-radius: 6px; flex: none;
}
.draft-row button:hover { background: #fff0f0; color: var(--danger); }
.draft-load { color: var(--text-2) !important; }
.draft-load:hover { background: #eef6ff !important; color: var(--violet) !important; }

/* ---------------- 说明区 ---------------- */
.doc { max-width: 860px; margin: 40px auto 0; padding: 0 24px; }
.doc h2 { font-size: 19px; margin: 0 0 16px; letter-spacing: -.2px; }
.doc h2:not(:first-child) { margin-top: 36px; }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); }
.steps li { margin-bottom: 10px; line-height: 1.75; }
.steps b { color: var(--text); }
.faq details {
  border-bottom: 1px solid var(--line); padding: 12px 0; color: var(--text-2);
}
.faq summary { cursor: pointer; font-weight: 600; color: var(--text); font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; color: var(--accent); font-weight: 700; width: 12px; }
.faq details[open] summary::before { content: "−"; }
.faq p { margin: 8px 0 0 20px; font-size: 13px; line-height: 1.75; }

.foot { text-align: center; padding: 40px 24px 48px; color: var(--text-3); font-size: 11.5px; }
.foot p { margin: 0; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: rgba(34, 31, 46, .94); color: #fff; padding: 9px 18px;
  border-radius: 999px; font-size: 13px; z-index: 999;
  opacity: 0; pointer-events: none; transition: .24s cubic-bezier(.2,.9,.3,1);
  box-shadow: var(--shadow-lg); max-width: 84vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 272px minmax(0, 1fr) 284px; gap: 12px; padding: 14px; }
  .swatches { grid-template-columns: repeat(9, 1fr); }
}
@media (max-width: 1080px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); }
  .col-left, .col-right { position: static; }
  .col-right { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); align-items: start; }
}
@media (max-width: 760px) {
  .topbar-inner { padding: 10px 14px; }
  /* 手机上只留「效果展示」入口，其余收进页面内 */
  .topnav { display: flex; }
  .topnav a { display: none; }
  .topnav a[href="/showcase.html"] { display: inline-block; padding: 6px 10px; font-size: 12.5px; }
  .topnav a.active { display: none; }
  .layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .col-center { order: -1; }
  .col-right { grid-template-columns: 1fr; }
  .board-wrap { min-height: 300px; height: clamp(300px, 48vh, 420px); }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .doc { padding: 0 16px; }
  .stats { margin-bottom: 4px; }
}

@media (max-width: 380px) {
  .topbar-inner { padding: 10px 10px; gap: 6px; }
  .brand-text strong { font-size: 12.5px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
}

/* ===========================================================
   参数面板 / 工具组 / 杂色面板 / 弹窗（v2 新增）
   =========================================================== */

/* ---- 字段标题行 ---- */
.field-head { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.field-head .field-label { margin: 0; }
.field-range { margin-left: auto; font-size: 10px; color: var(--text-3); font-family: var(--mono); letter-spacing: .2px; }
.field-val {
  font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--text);
  min-width: 30px; text-align: right; letter-spacing: -.3px;
}

/* ---- 输入行 ---- */
.row-mid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-top: 8px; align-items: center; }
.row-inline { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 8px; align-items: center; }
.row-mid .btn, .row-inline .btn { height: 36px; padding: 0 13px; }
.numfield input:disabled { color: var(--text-3); }

/* ---- 色号档位 ---- */
.tiers { display: flex; flex-wrap: wrap; gap: 5px; }
.tier {
  border: 1px solid var(--line-strong); background: #fff; color: var(--text-2);
  border-radius: 999px; padding: 3px 10px; font-size: 11.5px; cursor: pointer;
  font-family: var(--mono); font-weight: 600; transition: .15s;
}
.tier:hover { border-color: var(--accent); color: var(--accent-d); }
.tier.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.btn-block { width: 100%; justify-content: center; margin-top: 10px; }
.swatches { max-height: 132px; margin-bottom: 2px; }

/* ---- 第二排工具按钮 ---- */
.toolbar-tools { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 7px; }
.actbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--text-2); font-size: 11.5px; font-family: inherit; cursor: pointer;
  transition: .15s; line-height: 1.2; white-space: nowrap;
}
.actbtn svg { width: 17px; height: 17px; flex: none; }
.actbtn:hover { border-color: var(--accent); color: var(--accent-d); background: var(--accent-soft); }
.actbtn.active { background: var(--text); border-color: var(--text); color: #fff; }
.actbtn:active { transform: translateY(1px); }

/* ---- 缩放 ---- */
.zoom { display: flex; align-items: center; gap: 3px; }
.zoom .tool { width: 26px; height: 26px; }
.zoom .tool svg { width: 14px; height: 14px; }
.zoom span { font-family: var(--mono); font-size: 11px; color: var(--text-3); min-width: 36px; text-align: center; }
.zoom .zoom-hint {
  min-width: 0; margin-left: 4px; padding: 2px 7px; border-radius: 999px;
  background: #f3f0ff; color: #6c5ce7; font-family: inherit; font-size: 10.5px;
  letter-spacing: -.1px; white-space: nowrap;
}
.zoom .zoom-hint[hidden] { display: none; }
@media (max-width: 1320px) { .zoom .zoom-hint { display: none; } }

/* ---- 右栏切页 ---- */
.tabs-mini { display: inline-flex; background: #f2f0f6; padding: 2px; border-radius: 999px; gap: 2px; }
.tm-tab {
  border: 0; background: transparent; font-size: 11.5px; padding: 3px 11px; border-radius: 999px;
  cursor: pointer; font-family: inherit; color: var(--text-2); transition: .15s; font-weight: 500;
}
.tm-tab:hover { color: var(--text); }
.tm-tab.active { background: #fff; color: var(--text); font-weight: 700; box-shadow: 0 1px 3px rgba(34,31,46,.13); }
.tab-panel[hidden] { display: none; }

/* ---- 去除杂色 ---- */
.noise-head { padding: 0 2px 10px; border-bottom: 1px dashed var(--line); margin-bottom: 8px; }
.noise-title { margin: 0; font-size: 12.5px; font-weight: 700; color: var(--text); }
.noise-title b { font-family: var(--mono); font-size: 14px; color: var(--accent-d); }
.noise-sub { margin: 4px 0 0; font-size: 11px; color: var(--text-3); line-height: 1.5; }
.noise-sub b { font-family: var(--mono); color: var(--text-2); }
.noise-list { display: flex; flex-direction: column; gap: 2px; max-height: 268px; overflow-y: auto; padding-right: 2px; }
.noise-list::-webkit-scrollbar { width: 5px; }
.noise-list::-webkit-scrollbar-thumb { background: #ddd8e8; border-radius: 99px; }
.noise-row {
  display: grid; grid-template-columns: 22px 48px minmax(0, 1fr) auto 22px; align-items: center; gap: 7px;
  padding: 5px 6px; border-radius: 8px; cursor: pointer; transition: .13s;
}
.noise-row:hover { background: var(--accent-soft); }
.noise-row i { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,.13); display: block; }
.nr-code { font-family: var(--mono); font-weight: 700; font-size: 12px; color: var(--text); }
.nr-name { font-size: 11.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nr-count { font-family: var(--mono); font-size: 12px; color: var(--text-2); text-align: right; }
.nr-del {
  border: 0; background: transparent; color: #c9c3d6; cursor: pointer; border-radius: 6px;
  padding: 2px; display: grid; place-items: center; transition: .13s;
}
.nr-del svg { width: 14px; height: 14px; }
.nr-del:hover { color: var(--danger); background: #ffecec; }
#btnAutoNoise { margin-top: 10px; }

/* ---- 弹窗 ---- */
.modal {
  position: fixed; inset: 0; z-index: 300; padding: 20px;
  background: rgba(34, 31, 46, .42); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 430px;
  box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2,.9,.3,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-card h3 { margin: 0 0 6px; font-size: 16px; }
.modal-card textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px;
  font-family: inherit; font-size: 15px; resize: vertical; outline: 0; margin-top: 10px; color: var(--text);
}
.modal-card textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-row { display: flex; gap: 18px; margin-top: 10px; }
.modal-row .check { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---- 二维码弹窗 ---- */
.qr-card { max-width: 440px; }
.qr-card .hint { margin: 0 0 12px; font-size: 12px; line-height: 1.75; color: var(--text-3); }
.qr-card .fl { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.qr-card textarea.inp { margin-top: 6px; }
.qr-card .modal-row { align-items: center; gap: 10px; }
.qr-card select.inp {
  height: 34px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 0 8px;
  font: inherit; font-size: 12.5px; color: var(--text); background: #fff; outline: 0; flex: 1;
}
.qr-card select.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.qr-prev { display: flex; gap: 14px; align-items: center; margin-top: 12px; min-height: 84px; }
.qr-prev canvas {
  width: 84px; height: 84px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; image-rendering: pixelated; flex: none;
}
.qr-prev canvas[hidden] { display: none; }
.qr-info { font-size: 12px; color: var(--text-3); line-height: 1.65; min-width: 0; }
.qr-info b { color: var(--text-2); font-size: 13px; }
.qr-card .msg { min-height: 17px; font-size: 12.5px; color: #d33; margin: 8px 0 0; }
.qr-card .msg.ok { color: #1a9c52; }

/* ---- 上传区下方的三个备用入口 ---- */
.src-more { margin-top: 12px; }
.src-more-label { margin: 0 0 7px; font-size: 11.5px; color: var(--text-3); }
.src-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.srcbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 9px 3px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--text-2); font-size: 11.5px; font-family: inherit; cursor: pointer;
  transition: .15s; line-height: 1.2;
}
.srcbtn svg { width: 17px; height: 17px; flex: none; }
.srcbtn span { white-space: nowrap; }
.srcbtn:hover { border-color: var(--accent); color: var(--accent-d); background: var(--accent-soft); }
.srcbtn:active { transform: translateY(1px); }

/* ---- 绑定账号弹窗 ---- */
.bind-card { max-width: 420px; }
.bind-card .hint { margin: 0 0 16px; font-size: 12px; line-height: 1.75; color: var(--text-3); }
.bind-card .fl { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin: 0 0 6px; }
.bind-card .inp {
  width: 100%; height: 42px; border: 1px solid var(--line-strong); border-radius: 11px;
  padding: 0 13px; font: inherit; font-size: 14px; color: var(--text); background: #fff;
  outline: 0; transition: .16s; margin-bottom: 12px;
}
.bind-card .inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bind-card .msg { min-height: 17px; font-size: 12.5px; color: #d33; margin: 0 0 6px; }
.modal-actions a.btn { text-decoration: none; }

/* ---- 效果展示图弹窗 ---- */
.show-card { max-width: 840px; padding: 18px 18px 16px; }
.show-head { display: flex; align-items: flex-start; gap: 12px; }
.show-head h3 { margin: 0 0 3px; }
.show-head .hint { margin: 0; font-size: 11.5px; color: var(--text-3); }
.show-x {
  margin-left: auto; flex: none; width: 28px; height: 28px; border-radius: 8px;
  border: 0; background: #f3f1f8; color: var(--text-2); cursor: pointer; font-size: 13px;
  display: grid; place-items: center; font-family: inherit;
}
.show-x:hover { background: var(--accent-soft); color: var(--accent-d); }
.show-wrap {
  margin-top: 12px; border-radius: 12px; overflow: auto; max-height: 62vh;
  background: #f6f4fb; border: 1px solid var(--line);
}
.show-wrap img { display: block; width: 100%; height: auto; }
.show-card .modal-actions { margin-top: 12px; }

/* ---- 裁剪弹窗 ---- */
.crop-card { max-width: 780px; padding: 18px 18px 16px; }
.crop-head { display: flex; align-items: flex-start; gap: 12px; }
.crop-head-text { min-width: 0; }
.crop-head h3 { margin: 0 0 2px; }
.crop-head .hint { margin: 0; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.crop-reset {
  margin-left: auto; flex: none; border: 1px solid var(--line-strong); background: #fff;
  color: var(--text-2); font-size: 11.5px; padding: 4px 11px; border-radius: 999px;
  cursor: pointer; font-family: inherit; transition: .15s;
}
.crop-reset:hover { border-color: var(--accent); color: var(--accent-d); }

.crop-stage {
  position: relative; margin-top: 14px; border-radius: 12px; overflow: hidden;
  background: #16141f; height: clamp(220px, 44vh, 420px);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#cropCanvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

.crop-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.crop-ratios { display: flex; gap: 6px; flex-wrap: wrap; }
.cr-btn {
  border: 1px solid var(--line-strong); background: #fff; color: var(--text-2);
  font-family: var(--mono); font-size: 11.5px; padding: 4px 10px; border-radius: 999px;
  cursor: pointer; transition: .15s;
}
.cr-btn:hover { border-color: var(--accent); color: var(--accent-d); }
.cr-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-d); font-weight: 700; }
.crop-info {
  margin: 0 0 0 auto; font-family: var(--mono); font-size: 11.5px; color: var(--text-3);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .crop-stage { height: clamp(200px, 38vh, 320px); }
  .crop-info { margin-left: 0; width: 100%; }
  .crop-head .hint { display: none; }
}

@media (max-width: 1280px) {
  .toolbar-tools { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  .toolbar-tools { grid-template-columns: repeat(4, 1fr); }
  .actbtn { font-size: 11px; padding: 7px 2px; }
  .zoom { display: none; }
}
