:root {
  --bg: #0e1014;
  --panel: #181b22;
  --panel-2: #20242d;
  --line: #2c313b;
  --text: #e8eaf0;
  --muted: #9aa1ad;
  --accent: #6fa0cd;
  --accent-2: #8fd0a8;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #1b2230 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: 60px;
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 30px; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: .5px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-hint { color: var(--muted); font-size: 12px; background: var(--panel); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); }

/* 布局 */
.layout {
  display: grid; grid-template-columns: 380px 1fr; gap: 24px;
  padding: 28px 32px; max-width: 1240px; margin: 0 auto;
}
@media (max-width: 880px) { .layout { grid-template-columns: 1fr; } }
.col-title { font-size: 15px; margin: 0 0 14px; color: var(--text); font-weight: 600; }
.col-title .count {
  display: inline-block; min-width: 20px; text-align: center; font-size: 12px;
  background: var(--accent); color: #0e1014; border-radius: 999px; padding: 1px 7px; margin-left: 4px;
}

/* 上传 */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--panel);
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--accent); background: var(--panel-2); }
.drop-empty { text-align: center; color: var(--muted); padding: 20px; }
.drop-ico { font-size: 34px; margin-bottom: 10px; }
.drop-empty p { margin: 0 0 4px; color: var(--text); font-size: 15px; }
.drop-empty span { font-size: 12px; }
.product-preview { width: 100%; height: 100%; object-fit: contain; background: #0a0c10; }
.ghost-btn {
  margin-top: 12px; width: 100%; background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px; cursor: pointer; font-size: 13px;
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); }

/* 调色盘卡片 */
.palette-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* 占比条 */
.ratio-bar {
  display: flex; height: 92px; border-radius: 10px; overflow: hidden; background: var(--panel-2);
  border: 1px solid var(--line);
}
.ratio-bar .empty-hint { margin: auto; color: var(--muted); font-size: 13px; }
.seg-color { position: relative; height: 100%; min-width: 4px; cursor: pointer; transition: filter .1s; }
.seg-color:hover { filter: brightness(1.08); }
.seg-color .seg-label {
  position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: 10px;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); pointer-events: none; font-variant-numeric: tabular-nums;
}
.seg-color .seg-hex {
  position: absolute; left: 0; right: 0; top: 6px; text-align: center; font-size: 9px;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); pointer-events: none; opacity: .85;
}
.divider {
  width: 8px; height: 100%; margin: 0 -4px; cursor: col-resize; z-index: 3; position: relative;
}
.divider::after {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 2px; height: 40%; background: rgba(255,255,255,.7); border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
/* 选中色块的小工具条 */
.seg-tools {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  display: none; gap: 6px; z-index: 4;
}
.seg-color.selected .seg-tools { display: flex; }
.seg-color.selected { outline: 2px solid #fff; outline-offset: -2px; }
.seg-tools button {
  width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer; font-size: 13px;
  background: rgba(0,0,0,.55); color: #fff; display: flex; align-items: center; justify-content: center;
}
.seg-tools button:hover { background: rgba(0,0,0,.8); }
.ratio-hint { color: var(--muted); font-size: 11px; margin: 8px 2px 0; }

/* 操作 chips */
.palette-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 8px 12px;
  font-size: 13px; cursor: pointer; user-select: none;
}
.chip:hover { border-color: var(--accent); }
.add-chip { border-color: var(--accent); color: var(--accent); }

/* 预设 */
.presets { margin-top: 16px; }
.presets-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.preset-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 8px; }
.preset {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--panel-2);
}
.preset:hover { border-color: var(--accent); }
.preset .strip { display: flex; height: 30px; }
.preset .strip span { flex: 1; }
.preset .name { font-size: 11px; color: var(--muted); padding: 4px 8px; }

/* 选项 */
.options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin: 18px 0;
}
.opt-wide { grid-column: 1 / -1; }
.opt label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  background: transparent; border: none; color: var(--muted); padding: 8px 14px; cursor: pointer; font-size: 13px;
}
.seg button.active { background: var(--accent); color: #0e1014; font-weight: 600; }
.opt input[type=text] {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 13px;
}
.opt input[type=text]:focus { outline: none; border-color: var(--accent); }

/* 生成按钮 */
.gen-btn {
  width: 100%; padding: 14px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0c0f14;
  font-size: 15px; font-weight: 700; letter-spacing: .5px;
}
.gen-btn:disabled { opacity: .45; cursor: not-allowed; }
.gen-btn:not(:disabled):hover { filter: brightness(1.05); }
.status { text-align: center; color: var(--muted); font-size: 13px; min-height: 18px; margin: 12px 0 0; }
.status.err { color: #ff8d8d; }

/* 结果 */
.results { max-width: 1240px; margin: 10px auto 0; padding: 0 32px; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 18px; }
.result-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.result-card.is-original { outline: 1px dashed var(--line); }
.result-card img { width: 100%; display: block; aspect-ratio: 1; object-fit: contain; background: #0a0c10; }
.result-meta { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; }
.result-meta .swatch { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.result-meta .dot { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(255,255,255,.2); }
.result-meta a { color: var(--accent); font-size: 12px; text-decoration: none; }
.result-card.loading { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.result-card.fail { color: #ff8d8d; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-inner { display: flex; flex-direction: column; align-items: center; }

/* ============ 顶栏链接 / 返回 ============ */
.topbar-link {
  color: var(--accent); text-decoration: none; font-size: 13px; background: var(--panel);
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line);
}
.topbar-link:hover { border-color: var(--accent); }
.back {
  text-decoration: none; color: var(--muted); font-size: 22px; line-height: 1;
  border: 1px solid var(--line); border-radius: 10px; padding: 4px 11px; margin-right: 4px;
}
.back:hover { color: var(--text); border-color: var(--accent); }

/* ============ 灵感库 ============ */
.gallery-wrap { max-width: 1240px; margin: 0 auto; padding: 28px 32px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.empty { color: var(--muted); text-align: center; padding: 60px; }
.empty code { background: var(--panel); padding: 2px 8px; border-radius: 6px; }

.card {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: default;
}
.card-img { aspect-ratio: 3/4; background: #0a0c10; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-foot { padding: 12px 14px; }
.card-name { margin: 0 0 3px; font-size: 15px; }
.card-oneline { margin: 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 悬停浮层 */
.card-hover {
  position: absolute; inset: 0; background: linear-gradient(to top, rgba(10,12,16,.97) 60%, rgba(10,12,16,.82));
  backdrop-filter: blur(2px); padding: 18px; display: flex; flex-direction: column; justify-content: flex-end;
  opacity: 0; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; pointer-events: none;
}
.card:hover .card-hover { opacity: 1; transform: translateY(0); pointer-events: auto; }
.hover-oneline { margin: 0 0 14px; font-size: 14px; color: var(--text); line-height: 1.5; }
.hover-dims { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.hover-dims li { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.dim-tag {
  flex: none; font-size: 11px; color: #0e1014; background: var(--accent); border-radius: 6px;
  padding: 2px 7px; font-weight: 600;
}
li[data-dim="material"] .dim-tag { background: #d8b48f; }
li[data-dim="color"] .dim-tag { background: #6fa0cd; }
li[data-dim="element"] .dim-tag { background: #8fd0a8; }
.dim-text { color: var(--text); }
.dim-palette { display: inline-flex; gap: 3px; margin-left: auto; }
.pal-dot { width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(255,255,255,.25); }

.hover-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
.hbtn {
  text-align: center; text-decoration: none; font-size: 12.5px; padding: 9px 4px; border-radius: 9px;
  font-weight: 600; color: #0e1014; transition: filter .12s;
}
.hbtn:hover { filter: brightness(1.08); }
.hbtn.mat { background: #d8b48f; }
.hbtn.col { background: #6fa0cd; }
.hbtn.ele { background: #8fd0a8; }

/* ============ 材质/元素 标签选择器 ============ */
.chip-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.pick-chip {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.pick-chip:hover { border-color: var(--accent); }
.pick-chip.on { background: var(--accent); color: #0e1014; border-color: var(--accent); font-weight: 600; }
.custom-input {
  flex: 1; min-width: 140px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; color: var(--text); font-size: 13px;
}
.custom-input:focus { outline: none; border-color: var(--accent); }
.cur-hint { color: var(--muted); font-size: 12px; margin: 10px 2px 0; }
