:root {
  --bg: #f2f4fa;
  --card: #ffffff;
  --ink: #1c2333;
  --muted: #7a8499;
  --line: #e6eaf2;
  --brand: #4f6ef7;
  --brand2: #7a5cff;
  --accent: #ff7a45;
  --green: #16a34a;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(31, 45, 90, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(79,110,247,0.10), transparent 60%),
    radial-gradient(900px 480px at 90% 0%, rgba(255,122,69,0.08), transparent 55%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* ---------- 顶部 ---------- */
.top {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 24px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  border-radius: 13px;
  box-shadow: 0 6px 16px rgba(79,110,247,0.35);
}
.brand-name { font-size: 18px; font-weight: 700; }
.brand-slogan { font-size: 12px; color: var(--muted); margin-top: 2px; }

.chip {
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #56627a;
  background: #eef1f8;
  transition: all 0.15s;
}
.chip:hover { background: #e3e8f4; }
.chip.active {
  background: linear-gradient(135deg, #12b76a, #0ea05b);
  color: #fff;
  box-shadow: 0 4px 12px rgba(18,183,106,0.35);
}

/* ---------- 主体 ---------- */
main {
  max-width: 1080px;
  margin: 12px auto 0;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 18px;
  align-items: start;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* 步骤条 */
.steps {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0 0 18px;
  padding: 0;
}
.steps li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.steps b {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: #eef1f8; color: #67718a;
  border-radius: 50%;
  font-size: 12px;
}
.steps li:not(:last-child)::after { content: "→"; margin-left: 6px; opacity: 0.45; }

/* 上传区 */
.dropzone {
  border: 2px dashed #c9d2e6;
  border-radius: 16px;
  padding: 56px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfe;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--brand);
  background: #f2f5ff;
  transform: translateY(-2px);
}
.dz-icon { font-size: 46px; margin-bottom: 10px; }
.dz-title { font-size: 16px; font-weight: 600; margin: 6px 0; }
.dz-sub { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin: 0; }

/* 处理中 */
.working { text-align: center; padding: 50px 20px; }
.spinner {
  width: 42px; height: 42px;
  margin: 0 auto 16px;
  border: 4px solid #e3e8f4;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.working p { color: var(--muted); font-size: 14px; }
.bar {
  width: min(420px, 100%);
  height: 8px;
  background: #e8edf7;
  border-radius: 999px;
  margin: 18px auto 8px;
  overflow: hidden;
}
.bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand2));
  border-radius: 999px;
  transition: width 0.2s;
}
.pct { font-size: 12px; color: var(--muted); margin: 0; }

/* 预览 */
.editor { display: none; }
.editor[hidden] { display: none; }
.editor:not([hidden]) { display: block; }
.preview-wrap {
  display: grid;
  place-items: center;
  min-height: 360px;
  background:
    repeating-conic-gradient(#eef1f7 0 25%, #f8fafd 0 50%) 0 0/24px 24px;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 14px;
}
#preview { max-width: 100%; max-height: 430px; border-radius: 6px; box-shadow: 0 8px 24px rgba(20,30,60,0.18); }
.editor-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 10px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }

/* 控制区 */
.controls[hidden] { display: none; }
.ctrl { margin-bottom: 16px; }
.ctrl > label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600; color: #3c465e;
  margin-bottom: 8px;
}
.ctrl output { color: var(--brand); font-weight: 700; font-size: 13px; }
.ctrl select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fafbfe;
  color: var(--ink);
}
.ctrl input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
  cursor: pointer;
}
.sub { font-size: 12px; color: var(--muted); margin: 6px 2px 0; line-height: 1.6; }

.swatches { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sw {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid #dfe5f0;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s;
}
.sw:hover { transform: scale(1.08); }
.sw.on { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }
.sw.custom {
  width: auto; height: 34px;
  display: flex; align-items: center; gap: 6px;
  border-radius: 999px;
  padding: 0 12px 0 6px;
  background: #f4f6fb;
  font-size: 12px;
  color: var(--muted);
}
.sw.custom input[type="color"] { width: 22px; height: 22px; border: none; background: none; padding: 0; cursor: pointer; }

/* 按钮 */
.btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(79,110,247,0.35);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.accent {
  background: linear-gradient(135deg, #ff8a50, var(--accent));
  color: #fff;
  box-shadow: 0 6px 16px rgba(255,122,69,0.35);
}
.btn.accent:hover { filter: brightness(1.05); }
.btn.ghost { background: #f1f4fa; color: #4a556f; box-shadow: none; }
.btn.ghost:hover { background: #e8edf7; }
.btn.sm { width: auto; padding: 8px 14px; font-size: 13px; }
.cam-btn { display: none; }
@media (max-width: 860px) {
  .cam-btn { display: block; width: 78%; margin: 16px auto 0; }
}
.exports { margin-top: 8px; display: grid; gap: 10px; }
.sheet-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.sheet-row select {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfe;
  padding: 0 10px;
  font-size: 14px;
}

/* 底部 */
footer { max-width: 1080px; margin: 18px auto 34px; padding: 0 20px; text-align: center; }
footer p { font-size: 12.5px; color: var(--muted); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(20, 26, 45, 0.5);
  display: grid; place-items: center;
  z-index: 50;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-mask[hidden] { display: none; }
.modal {
  position: relative;
  width: min(430px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 26px 24px 22px;
  box-shadow: 0 24px 60px rgba(15, 25, 55, 0.3);
  animation: pop 0.18s ease-out;
}
@keyframes pop { from { transform: translateY(14px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal-sub { margin: 0 0 16px; color: var(--accent); font-weight: 700; font-size: 14px; }
.modal input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 12px;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.5px;
}
.modal input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,110,247,0.15); }
.modal-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.modal-msg { font-size: 13px; margin: 12px 2px 0; min-height: 18px; color: var(--muted); }
.modal-msg.ok { color: var(--green); }
.modal-msg.err { color: #dc2626; }
.modal-contact { font-size: 12.5px; color: var(--muted); margin: 8px 2px 0; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  border: none; background: #f1f4fa;
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  color: #66718a;
  font-size: 13px;
}
.modal-close:hover { background: #e6ebf5; }

/* Toast */
.toast {
  position: fixed;
  left: 50%; bottom: 34px;
  transform: translateX(-50%);
  background: #232b3f;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
  box-shadow: 0 10px 30px rgba(10, 16, 34, 0.35);
  animation: rise 0.2s ease-out;
}
@keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* 移动端 */
@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  .preview-wrap { min-height: 260px; }
  .dropzone { padding: 40px 16px; }
}