/* 拼豆图纸 · 清爽极简白 */
:root {
  --bg: #fafbfc;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: .01em; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.link { color: var(--accent-dark); text-decoration: none; }
.link:hover { text-decoration: underline; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 62px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 17px;
}
.logo {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  gap: 3px;
  flex: none;
}
.logo i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, .12);
}
.logo i:nth-child(2) { background: #2f9e44; }
.logo i:nth-child(3) { background: #1c7ed6; }
.logo i:nth-child(4) { background: #f2b705; }
.logo i:nth-child(5) { background: #9c36b5; }
.logo i:nth-child(6) { background: #e03131; }
.brand-name { letter-spacing: .03em; }

.nav { display: flex; gap: 4px; }
.nav a {
  padding: 6px 13px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  color: var(--muted);
  transition: .15s;
}
.nav a:hover { background: #f3f4f6; color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

.userbox {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.who { color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #cbd5e1; background: #f9fafb; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .25);
}
.btn.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.danger:hover:not(:disabled) { background: #fef2f2; border-color: #fca5a5; }
.btn.tiny { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* 页面容器 */
.page { max-width: 1280px; margin: 0 auto; padding: 26px 24px 60px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h1 { font-size: 24px; font-weight: 600; }
.page-head p { margin: 4px 0 0; font-size: 13px; }
.back {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 4px;
}
.back:hover { color: var(--accent-dark); }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h2 { font-size: 16px; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* 提示条 */
.flash {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.flash.ok { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.flash.err { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* 草稿提示条 */
.draft-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid #bfdbfe;
  color: #1e40af;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
}
.draft-bar[hidden] { display: none; }
.draft-bar span { flex: 1; min-width: 0; }

/* 表单 */
.form .field:first-child { margin-top: 0; }
.field { margin-top: 16px; }
.form-sec {
  font-size: 14px;
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}
.form-sec + .field, .form-sec + .row { margin-top: 14px; }
.form > .form-sec:first-of-type { border-top: 0; margin-top: 18px; padding-top: 0; }
.field label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.field label em {
  font-style: normal;
  color: var(--accent);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: .15s;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); }
input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 14px 0;
  cursor: pointer;
}
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.form .btn.block { margin-top: 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-form { display: inline-flex; margin: 0; gap: 4px; align-items: center; }
.inline-row-form { display: inline; }
.search { display: flex; gap: 8px; }
.search input { width: 220px; }

/* 标签 / 徽章 */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
  white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge.green { background: #ecfdf5; color: #047857; }

/* 生成器 */
.gen-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.gen-grid > .stack:first-child { position: sticky; top: 80px; }
.drop {
  border: 1.5px dashed #d1d5db;
  border-radius: 10px;
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  background: #fafbfc;
  transition: .15s;
}
.drop:hover, .drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; font-size: 14px; margin-bottom: 2px; }
.drop span { color: var(--muted); font-size: 12px; }
.picked { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.picked img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--line);
  display: none;
}
.picked .name {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.actions .btn:first-child { grid-column: span 2; }
.actions > form { margin: 0; }
.actions > form .btn { width: 100%; }

.preview-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.stats div {
  display: flex;
  align-items: baseline;
  gap: 5px;
  background: #f3f4f6;
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 12px;
}
.stats b { font-size: 13px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); }
.canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  max-height: 72vh;
  overflow: auto;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.canvas-wrap canvas { max-width: 100%; height: auto; display: block; }
.canvas-wrap.zoomed { justify-content: flex-start; align-items: flex-start; }
.canvas-wrap.zoomed canvas { max-width: none; }
.preview-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.preview-tools .check { margin: 0; flex: 1; }
.preview-tools .btn { flex: none; }
.empty {
  padding: 54px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.note { font-size: 12px; color: var(--muted); margin-top: 10px; }

.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 14px;
  max-height: 340px;
  overflow: auto;
}
.swatch {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.swatch i {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, .12);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .22);
}
.swatch .meta { flex: 1; min-width: 0; }
.swatch b { display: block; font-size: 12px; line-height: 1.3; }
.swatch small { display: block; color: var(--muted); font-size: 11px; line-height: 1.3; }
.swatch em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 分板 */
.boards-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.board-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.board-card canvas { display: block; width: 100%; height: auto; border-radius: 8px; }
.board-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* 作品库 */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(226px, 1fr));
  gap: 18px;
}
.work-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: .18s;
}
.work-card:hover { transform: translateY(-2px); border-color: #cbd5e1; box-shadow: 0 6px 20px -12px rgba(16, 24, 40, .25); }
.work-card .thumb {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.work-card .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.work-body { padding: 12px 14px 14px; }
.work-title {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.work-meta {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.work-sub {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 11px;
  color: var(--muted);
}

.empty-state { text-align: center; padding: 54px 20px; }
.empty-state h2 { font-size: 20px; margin-bottom: 6px; }
.empty-state p { margin: 0 0 18px; }
.empty-dots {
  display: inline-grid;
  grid-template-columns: repeat(3, 12px);
  gap: 5px;
  margin-bottom: 16px;
}
.empty-dots i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
  opacity: .75;
}
.empty-dots i:nth-child(2) { background: #2f9e44; }
.empty-dots i:nth-child(3) { background: #1c7ed6; }
.empty-dots i:nth-child(4) { background: #f2b705; }
.empty-dots i:nth-child(5) { background: #9c36b5; }
.empty-dots i:nth-child(6) { background: #e03131; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

/* 作品详情 */
.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) 370px;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}
.pattern-wrap {
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 76vh;
  overflow: auto;
}
.pattern-wrap img { display: block; width: 100%; height: auto; }
.info-list { list-style: none; margin: 0; padding: 0; }
.info-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.info-list li:last-child { border-bottom: none; }
.info-list span { color: var(--muted); flex: none; }
.info-list b { font-weight: 600; text-align: right; }

.share-box { margin-top: 16px; }
.share-box label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 12px; }

.dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, .14);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .2);
  vertical-align: middle;
}

/* 表格 */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table input[type="text"] { padding: 5px 8px; font-size: 12px; min-width: 64px; }
.actions-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.table .actions-cell { display: table-cell; }
.table .actions-cell > * { margin-right: 4px; }

/* 后台 */
.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 18px;
  background: #f3f4f6;
  border-radius: 999px;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  padding: 7px 18px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  transition: .15s;
}
.tab:hover { color: var(--ink); }
.tab.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card b {
  display: block;
  font-size: 27px;
  line-height: 1.2;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}
.stat-card span { font-size: 12px; color: var(--muted); }

.admin-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
  align-items: start;
}

.mini-list { display: flex; flex-direction: column; }
.mini-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  text-decoration: none;
}
.mini-item:last-child { border-bottom: none; }
.mini-item img, .mini-empty {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 9px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f9fafb;
}
.mini-text { display: flex; flex-direction: column; min-width: 0; }
.mini-text b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-text small { font-size: 11px; color: var(--muted); }

.plain-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.plain-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}
.plain-list li:last-child { border-bottom: none; }
.plain-list small { color: var(--muted); font-size: 11px; }

.palette-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.palette-admin-card { padding: 16px; }
.palette-admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.palette-admin-head small { display: block; font-size: 11px; margin-top: 2px; }
.swatches-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.swatches-row i {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, .12);
}

/* 登录注册 */
.auth-wrap { max-width: 420px; margin: 40px auto; }
.auth-wrap.wide { max-width: 560px; }
.auth-wrap .card { padding: 28px; }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head .logo { display: inline-grid; margin-bottom: 12px; }
.auth-title { font-size: 24px; margin-bottom: 4px; }
.auth-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.steps { padding-left: 20px; font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.steps li { margin: 7px 0; }
.steps b { color: var(--ink); }
code {
  background: #f3f4f6;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 99;
  transform: translateX(-50%) translateY(18px);
  background: #111827;
  color: #fff;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .22s;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 页脚 */
.foot { border-top: 1px solid var(--line); margin-top: 24px; }
.foot-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 18px 20px;
  font-size: 12px;
  color: var(--muted);
}

/* 响应式 */
@media (max-width: 1080px) {
  .gen-grid, .work-grid, .admin-cols { grid-template-columns: 1fr; }
  .gen-grid > .stack:first-child { position: static; }
  .work-grid { margin-bottom: 18px; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 14px; }
  .page { padding: 16px 14px 42px; }
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 8px 0; }
  .nav { order: 3; width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .userbox { margin-left: auto; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head h1 { font-size: 22px; }
  .search { width: 100%; }
  .search input { flex: 1; width: auto; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .actions { grid-template-columns: 1fr; }
  .actions .btn:first-child { grid-column: span 1; }
  .stats { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .foot-inner { flex-direction: column; align-items: flex-start; }
  .palette { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .boards-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
