/* 拼豆工坊 PC 版 — 暖色手作主题 */
:root {
  --bg: #f3ecdd;
  --panel: #fffdf5;
  --panel-2: #fbf6ea;
  --line: #e7dcc8;
  --ink: #3f2d1c;
  --ink-2: #7a6650;
  --muted: #9a8069;
  --primary: #744821;
  --primary-deep: #5b3818;
  --accent: #e8a23c;
  --teal: #55bca9;
  --danger: #c94f43;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(93, 64, 30, 0.07), 0 12px 32px rgba(93, 64, 30, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 400px at 70% -10%, rgba(232, 162, 60, 0.10), transparent 60%),
    radial-gradient(900px 380px at 10% 110%, rgba(85, 188, 169, 0.08), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 { margin: 0; font-weight: 800; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 253, 245, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 12px 28px;
  display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-beads { display: inline-flex; gap: 3px; }
.brand-beads i {
  width: 14px; height: 14px; border-radius: 50%;
  box-shadow: inset 0 -3px 4px rgba(0,0,0,.18), inset 0 3px 4px rgba(255,255,255,.45);
}
.brand-beads i:nth-child(1) { background: #e8a23c; }
.brand-beads i:nth-child(2) { background: #c94f43; }
.brand-beads i:nth-child(3) { background: #55bca9; }
.brand-name { font-size: 20px; font-weight: 900; letter-spacing: 1px; }
.brand-tag {
  font-size: 11px; font-weight: 700; color: var(--primary);
  border: 1px solid var(--primary); border-radius: 20px; padding: 1px 8px;
}
#main-nav { display: flex; gap: 6px; flex: 1; }
#main-nav button {
  border: 0; background: transparent; cursor: pointer;
  font-size: 15px; font-weight: 600; color: var(--ink-2);
  padding: 8px 16px; border-radius: 10px; transition: all .15s;
}
#main-nav button:hover { background: rgba(116, 72, 33, 0.08); color: var(--ink); }
#main-nav button.active { background: var(--primary); color: #fff; }
.user-chip {
  border: 1.5px solid var(--primary); background: transparent; color: var(--primary);
  font-size: 14px; font-weight: 700; padding: 7px 18px; border-radius: 22px; cursor: pointer;
  transition: all .15s;
}
.user-chip:hover { background: var(--primary); color: #fff; }
.user-chip.logged-in { background: var(--primary); color: #fff; }

/* ===== 主体布局 ===== */
main#view { flex: 1; max-width: 1440px; width: 100%; margin: 0 auto; padding: 20px 28px 30px; }
.workspace {
  display: grid;
  grid-template-columns: 308px minmax(0, 1fr) 264px;
  gap: 16px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-section { padding: 16px 18px; border-bottom: 1px dashed var(--line); }
.panel-section:last-child { border-bottom: 0; }
.panel-section h4 { font-size: 13.5px; color: var(--primary); letter-spacing: .5px; margin-bottom: 10px; }
.panel-section.grow { flex: 1; min-height: 200px; }
.right-panel { display: flex; flex-direction: column; }
.params-panel { max-height: calc(100vh - 110px); overflow-y: auto; }
.params-panel::-webkit-scrollbar { width: 8px; }
.params-panel::-webkit-scrollbar-thumb { background: #d8ccb8; border-radius: 8px; }

/* ===== 表单元素 ===== */
.field-row {
  display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13.5px;
}
.field-row > span:first-child { width: 76px; flex-shrink: 0; color: var(--ink-2); }
.field-row select, .field-row input[type="range"] { flex: 1; }
.field-row em { font-style: normal; width: 42px; text-align: right; color: var(--primary); font-weight: 700; }
.field-row.slim { margin: 0; }
.field-row.slim > span:first-child { width: auto; }
select, input[type="text"], .text-chip {
  border: 1.5px solid var(--line); border-radius: 9px; background: #fff;
  padding: 7px 10px; font-size: 13.5px; color: var(--ink); outline: none;
}
select:focus, input:focus { border-color: var(--accent); }
input[type="range"] { accent-color: var(--primary); }
.check-row { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; margin: 4px 10px 4px 0; }
.check-row input { accent-color: var(--primary); width: 15px; height: 15px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 6px 0 10px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 13px; font-weight: 600; padding: 6px 13px; border-radius: 20px; cursor: pointer;
  transition: all .12s;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.small { padding: 4px 11px; font-size: 12px; }
.text-chip { width: 110px; }

.btn {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  font-size: 14px; font-weight: 700; padding: 9px 18px; border-radius: 11px; cursor: pointer;
  transition: all .15s;
}
.btn:hover:not(:disabled) { border-color: var(--primary); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(160deg, #8a5a2c, var(--primary) 55%, var(--primary-deep));
  border: 0; color: #fff;
  box-shadow: 0 4px 14px rgba(116, 72, 33, 0.35);
}
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(116, 72, 33, 0.42); }
.btn.big { width: 100%; padding: 13px; font-size: 16px; margin: 14px 0 16px; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 12px; font-size: 12.5px; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }
.btn-col .btn { width: 100%; }

/* ===== 上传框 ===== */
.upload-box {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 2px dashed #d3c3a4; border-radius: 12px; background: var(--panel-2);
  padding: 18px 12px; margin-bottom: 10px; cursor: pointer; text-align: center;
  font-size: 14px; font-weight: 600; transition: all .15s;
  max-width: 100%;
}
.upload-box:hover { border-color: var(--accent); background: #fdf8ec; }
.upload-icon { font-size: 26px; }
.upload-box.has-image { padding: 10px 10px 8px; gap: 4px; }
.upload-box.has-image .upload-icon { display: none; }
.upload-box #upload-title { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-thumb {
  width: 100%; height: 150px; object-fit: contain;
  border-radius: 8px; background:
    repeating-conic-gradient(#f1ead9 0 25%, #fff 0 50%) 0 0 / 16px 16px;
}

/* ===== 画布区 ===== */
.canvas-panel { display: flex; flex-direction: column; min-height: 620px; }
.canvas-toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.toolbar-group { display: flex; gap: 6px; }
.canvas-stage {
  position: relative; flex: 1; overflow: auto;
  display: flex; align-items: flex-start; justify-content: flex-start;
  padding: 16px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.canvas-stage::-webkit-scrollbar { width: 0; height: 0; display: none; }
.canvas-stage > * { margin: auto; }
.canvas-stage.pannable { cursor: grab; }
.canvas-stage.pannable:active { cursor: grabbing; }
.pan-hint {
  position: absolute; right: 14px; bottom: 12px; z-index: 5;
  background: rgba(63, 45, 28, 0.85); color: #fff;
  font-size: 12px; padding: 5px 13px; border-radius: 16px; pointer-events: none;
}
.empty-hint { text-align: center; margin: auto; padding: 60px 20px; }
.empty-hint h3 { margin: 14px 0 4px; }
.empty-beads { display: inline-flex; gap: 6px; }
.empty-beads span {
  width: 16px; height: 16px; border-radius: 50%;
  box-shadow: inset 0 -4px 5px rgba(0,0,0,.2), inset 0 4px 5px rgba(255,255,255,.5);
}
.empty-beads span:nth-child(5n+1) { background: #e8a23c; }
.empty-beads span:nth-child(5n+2) { background: #c94f43; }
.empty-beads span:nth-child(5n+3) { background: #55bca9; }
.empty-beads span:nth-child(5n+4) { background: #7c9fd4; }
.empty-beads span:nth-child(5n) { background: #b495d6; }
.empty-beads.big span { width: 22px; height: 22px; }
.crop-view { text-align: center; }
.crop-view canvas { border-radius: 10px; cursor: grab; max-width: 100%; touch-action: none; }
.crop-view canvas:active { cursor: grabbing; }
.crop-hint { margin-top: 8px; }
.preview-wrap { position: relative; }
.preview-wrap #preview-canvas { display: block; border-radius: 8px; box-shadow: 0 2px 14px rgba(93,64,30,.12); }
.preview-wrap #overlay-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
.preview-3d { padding: 30px 0 10px; text-align: center; }
.scene3d { perspective: 1100px; display: flex; justify-content: center; padding: 30px 0; }
.board3d {
  display: grid; gap: 2px;
  transform-style: preserve-3d;
  transform: rotateX(55deg) rotateZ(45deg);
  transition: transform .05s linear;
  cursor: grab;
  scale: var(--bead-scale, 1);
}
.board3d:active { cursor: grabbing; }
.bead3d {
  width: var(--bead-size, 14px); height: var(--bead-size, 14px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, rgba(255,255,255,.85), rgba(255,255,255,0) 38%),
    var(--c, #ddd);
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.28), inset 0 2px 3px rgba(255,255,255,.4);
}

/* ===== 右栏 ===== */
.pattern-info .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pattern-info .info-grid > div { text-align: center; background: var(--panel-2); border-radius: 10px; padding: 10px 4px; }
.pattern-info em { display: block; font-style: normal; font-size: 20px; font-weight: 900; color: var(--primary); }
.pattern-info span { font-size: 11.5px; color: var(--muted); }
.usage-list { max-height: 380px; overflow-y: auto; }
.usage-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.usage-row:last-child { border-bottom: 0; }
.swatch-dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 -2px 3px rgba(0,0,0,.2); }
.usage-code { font-weight: 800; color: var(--primary); width: 34px; }
.usage-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.usage-count { font-weight: 700; }

/* ===== 调色盘 ===== */
.palette-tabs { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.palette-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; max-height: 220px; overflow-y: auto; padding: 2px; }
.swatch {
  aspect-ratio: 1; border-radius: 9px; border: 2px solid rgba(0,0,0,.08); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; transition: transform .1s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.excluded { opacity: .28; text-decoration: line-through; }

/* ===== 账户页 ===== */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.account-grid .wide { grid-column: 1 / -1; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.account-card { display: flex; align-items: center; gap: 16px; }
.avatar {
  width: 62px; height: 62px; border-radius: 50%; background: var(--panel-2);
  border: 2px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--primary); overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-main { flex: 1; }
.nickname-input { font-size: 16px; font-weight: 700; width: 200px; margin-bottom: 4px; }
.member-card { background: linear-gradient(150deg, #7c5427, #5b3818); color: #fdf3dd; border: 0; }
.member-card.vip { background: linear-gradient(150deg, #b07a2c, #7c4a12); }
.member-head { display: flex; align-items: center; justify-content: space-between; }
.member-name { font-size: 24px; font-weight: 900; letter-spacing: 1px; }
.member-badge { font-size: 12px; border: 1px solid rgba(253,243,221,.6); border-radius: 20px; padding: 3px 12px; }
.member-desc { margin: 10px 0 6px; opacity: .85; font-size: 13.5px; }
.member-date { font-size: 12.5px; opacity: .65; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.feature { background: var(--panel-2); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.feature.off { opacity: .5; }
.feature-name { font-size: 12.5px; color: var(--ink-2); }
.feature-value { font-size: 16px; font-weight: 800; color: var(--primary); }
.redeem-row { display: flex; gap: 10px; margin-top: 10px; }
.redeem-row input { flex: 1; max-width: 340px; }

/* ===== 空状态 / 登录弹窗 ===== */
.empty-state { text-align: center; padding: 90px 20px; }
.empty-state h2 { margin: 16px 0 6px; }
.loading-page { text-align: center; padding: 90px; color: var(--muted); }

.modal-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(53, 36, 18, 0.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  position: relative; background: var(--panel); border-radius: 18px;
  padding: 30px 36px 26px; width: 380px; max-width: 92vw; text-align: center;
  box-shadow: 0 24px 60px rgba(53, 36, 18, 0.35);
}
.modal h3 { font-size: 20px; margin-bottom: 16px; }
.modal-close {
  position: absolute; top: 10px; right: 14px; border: 0; background: transparent;
  font-size: 26px; color: var(--muted); cursor: pointer; line-height: 1;
}
.qr-wrap img { width: 190px; height: 190px; border-radius: 10px; border: 1px solid var(--line); }
.pairing-block { margin: 14px 0 6px; }
.pairing-label { font-size: 13px; color: var(--ink-2); margin: 0 0 8px; }
.pairing-code {
  font-size: 34px; font-weight: 900; letter-spacing: 4px; color: var(--primary);
  background: var(--panel-2); border: 1.5px dashed #d3c3a4; border-radius: 12px;
  padding: 10px; font-variant-numeric: tabular-nums;
}
.login-status { min-height: 20px; font-size: 13px; color: var(--ink-2); margin: 10px 0; }

/* ===== 操作记录抽屉 ===== */
.drawer-mask {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(53, 36, 18, 0.35);
  display: flex; justify-content: flex-end;
}
.drawer {
  width: 400px; max-width: 94vw; height: 100%;
  background: var(--panel); box-shadow: -12px 0 40px rgba(53,36,18,.25);
  display: flex; flex-direction: column;
  animation: drawer-in .2s ease;
}
@keyframes drawer-in { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.drawer-head h3 { margin: 0; font-size: 17px; flex-shrink: 0; }
.drawer-head .modal-close { position: static; margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px; }
.history-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: #fff; }
.history-thumbs { display: flex; gap: 10px; align-items: flex-start; }
.history-thumbs figure { margin: 0; width: 86px; flex-shrink: 0; }
.history-thumbs img {
  width: 86px; height: 86px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); display: block; cursor: pointer;
  background: repeating-conic-gradient(#f1ead9 0 25%, #fff 0 50%) 0 0 / 12px 12px;
}
.history-thumbs figcaption { text-align: center; font-size: 11px; color: var(--muted); margin-top: 3px; }
.history-meta { flex: 1; font-size: 12.5px; line-height: 1.7; color: var(--ink-2); }
.history-meta b { color: var(--primary); }
.scope-badge {
  display: inline-block; font-size: 11px; border-radius: 12px; padding: 1px 9px; font-weight: 700;
}
.scope-badge.guest { background: #eeeae4; color: var(--muted); }
.scope-badge.server { background: #e3f2ee; color: #2e8c6a; }
.history-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ===== Toast / Footer ===== */
.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%) translateY(20px);
  background: #3f2d1c; color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 22px; border-radius: 24px; opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 120; box-shadow: 0 10px 26px rgba(0,0,0,.28);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #a83e33; }

.footer {
  text-align: center; padding: 18px; color: var(--muted); font-size: 12.5px;
  border-top: 1px solid var(--line); background: rgba(255,253,245,.6);
}
.footer .divider { margin: 0 8px; opacity: .5; }

/* ===== 响应式 ===== */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 280px minmax(0, 1fr); }
  .right-panel { grid-column: 2; }
}
@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .right-panel { grid-column: 1; }
  .account-grid { grid-template-columns: 1fr; }
  main#view { padding: 14px; }
  .topbar-inner { padding: 10px 14px; gap: 12px; }
  .brand-name { display: none; }
}

/* 会员权益锁定态：超出档位的尺寸/色数选项 */
.chip.locked {
  opacity: 0.35;
  text-decoration: line-through;
  cursor: not-allowed;
  pointer-events: none;
}

/* Neutral workspace keeps color assessment independent of warm page decoration. */
:root { --bg: #f3f5f8; --panel: #fff; --panel-2: #f7f9fc; --line: #dfe5ed; --ink: #273449; --ink-2: #56667b; --muted: #758399; --shadow: 0 3px 16px rgba(30,44,65,.05); }
body { background: var(--bg); }
.canvas-panel { background: #fff; }
.canvas-stage { background: #f8fafc; }
.advanced-panel summary { cursor: pointer; font-weight: 700; color: var(--ink-2); padding: 4px 0 12px; }
.advanced-panel:not([open]) { padding-bottom: 4px; }
.board3d { display: block !important; grid-template-columns: none !important; background: transparent !important; padding: 0 !important; box-shadow: none; }
.board3d canvas { display: block; filter: drop-shadow(0 8px 3px rgba(25,35,50,.2)); }
.style-candidates { display: grid; gap: 10px; }
.style-candidate { display: grid; grid-template-columns: 82px 1fr; grid-template-rows: 1fr 1fr; text-align: left; gap: 2px 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; cursor: pointer; }
.style-candidate canvas { width: 82px; height: 82px; grid-row: 1 / 3; border-radius: 6px; }
.style-candidate b { align-self: end; font-size: 14px; }
.style-candidate span { align-self: start; font-size: 12px; color: var(--muted); }
.style-candidate:hover { border-color: #55bca9; background: #f6fcfa; }
#compare-source { touch-action: none; user-select: none; }
@media (max-width: 1000px) { .style-candidates { grid-template-columns: repeat(3, 1fr); } .style-candidate { display: flex; flex-direction: column; align-items: center; } }

.export-code-option { display: flex; align-items: center; gap: 8px; color: #485b70; font-size: 13px; }
.export-hint { font-size: 12px; line-height: 1.6; margin: 6px 0; }

.export-preview-dialog { width: min(1100px, 92vw); max-height: 92vh; overflow: auto; border: 1px solid #dfe5ed; border-radius: 12px; padding: 16px; background: white; }
.export-preview-dialog::backdrop { background: rgba(25,35,50,.55); }
.export-preview-dialog form { position: sticky; top: 0; text-align: right; }
.export-preview-dialog img { display: block; width: 100%; height: auto; margin-top: 12px; }

.history-toolbar{padding:12px;border-bottom:1px solid #ddd}.history-toolbar p{line-height:1.6}.history-actions{flex-wrap:wrap}.history-pager{display:flex;justify-content:space-between;align-items:center;padding:16px}.history-preview-dialog{width:min(900px,94vw);max-height:90vh;overflow:auto;border:0;border-radius:16px;padding:0}.history-preview-dialog::backdrop{background:#0009}.history-preview-body{padding:16px}.history-preview-body canvas,.history-preview-body img{display:block;max-width:100%;height:auto;margin:auto}
