/* ===== 名片工坊 · Business Card Studio ===== */
:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --ink: #2b2a30;
  --ink-2: #5c5b60;
  --ink-3: #8d8c90;
  --line: #e8e6e1;
  --line-2: #f0eee9;
  --brand: #5a6b5b;
  --brand-soft: #e8ece6;
  --danger: #b5615a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(30, 28, 24, .04), 0 8px 28px rgba(30, 28, 24, .06);
  --shadow-lg: 0 24px 60px rgba(40, 44, 38, .18), 0 4px 14px rgba(40, 44, 38, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input { font-family: inherit; }
button { cursor: pointer; }

/* ---------- 顶部栏 ---------- */
.topbar {
  height: 66px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; letter-spacing: .5px; }
.brand-text span { font-size: 10.5px; color: var(--ink-3); letter-spacing: .3px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all .16s ease;
  white-space: nowrap;
}
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); background: var(--surface-2); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(90,107,91,.28); }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* ---------- 主体布局 ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(420px, 560px) 1fr;
  gap: 28px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 26px 60px;
  align-items: start;
}

/* ---------- 编辑面板 ---------- */
.editor { display: flex; flex-direction: column; gap: 16px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.step {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
  margin-top: 1px;
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .2px; }
.panel-head h2 em { font-style: normal; font-weight: 500; color: var(--ink-3); font-size: 12px; margin-left: 5px; }
.panel-head p { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }
.req { color: var(--danger); }

/* 名片类型 */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-card {
  position: relative;
  text-align: left;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 15px 15px 13px;
  display: flex; flex-direction: column; gap: 2px;
  transition: all .16s ease;
}
.type-card:hover { border-color: #cfd3c9; }
.type-card.active { border-color: var(--brand); background: #f4f7f2; box-shadow: inset 0 0 0 1px var(--brand); }
.type-card.active::after {
  content: "✓"; position: absolute; top: 11px; right: 12px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 11px;
  display: grid; place-items: center;
}
.type-ico { font-size: 22px; margin-bottom: 4px; }
.type-name { font-weight: 700; font-size: 14px; }
.type-desc { color: var(--ink-3); font-size: 11.5px; }
.type-tag { color: var(--brand); font-size: 10.5px; margin-top: 7px; font-weight: 600; }

/* 版式 */
.layout-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.layout-card {
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 10px 8px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: all .16s ease;
}
.layout-card:hover { border-color: #cfd3c9; }
.layout-card.active { border-color: var(--brand); background: #f4f7f2; box-shadow: inset 0 0 0 1px var(--brand); }
.layout-name { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.layout-card.active .layout-name { color: var(--brand); }
.layout-thumb {
  width: 100%; aspect-ratio: 5 / 3;
  border-radius: 6px; background: #fff;
  border: 1px solid #e4e2dc;
  position: relative; overflow: hidden; display: block;
}
.layout-thumb i, .layout-thumb b, .layout-thumb u { position: absolute; display: block; }
/* 经典 */
.thumb-classic i { left: 0; top: 0; bottom: 0; width: 8%; background: var(--brand); }
.thumb-classic b { left: 14%; top: 28%; width: 42%; height: 8%; background: #9a9c96; border-radius: 2px; box-shadow: 0 9px 0 #c9cbc5, 0 17px 0 #d8dad4; }
.thumb-classic u { right: 10%; top: 22%; width: 26%; height: 56%; border-radius: 50%; background: #dfe3dc; }
/* 品牌 */
.thumb-brand i { left: 0; top: 0; bottom: 0; width: 40%; background: var(--brand); }
.thumb-brand b { left: 8%; top: 42%; width: 24%; height: 14%; border-radius: 3px; background: rgba(255,255,255,.8); }
.thumb-brand u { right: 8%; top: 30%; width: 44%; height: 7%; background: #9a9c96; border-radius: 2px; box-shadow: 0 8px 0 #c9cbc5, 0 15px 0 #d8dad4; }
/* 极简 */
.thumb-minimal i { left: 12%; top: 18%; width: 40%; height: 9%; background: #a7a9a3; border-radius: 2px; box-shadow: 0 10px 0 #d0d2cc; }
.thumb-minimal b { left: 12%; bottom: 20%; width: 24%; height: 5%; background: var(--brand); border-radius: 2px; }
.thumb-minimal u { right: 14%; bottom: 20%; width: 18%; height: 5%; background: #d6d8d2; border-radius: 2px; }
/* 商务 */
.thumb-signature i { left: 0; right: 0; top: 0; height: 22%; background: var(--brand); }
.thumb-signature b { left: 12%; top: 40%; width: 38%; height: 8%; background: #9a9c96; border-radius: 2px; box-shadow: 0 9px 0 #c9cbc5; }
.thumb-signature u { right: 12%; top: 36%; width: 26%; height: 44%; border-radius: 50%; background: #dfe3dc; }

/* 配色 */
.swatches { display: flex; flex-wrap: wrap; gap: 11px; margin-bottom: 17px; }
.swatch {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1.5px var(--line);
  position: relative; transition: transform .14s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { box-shadow: 0 0 0 2px var(--brand); }
.swatch.active::after { content: "✓"; position: absolute; inset: 0; color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.custom-color { border-top: 1px dashed var(--line); padding-top: 15px; }
.custom-color > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 9px; }
.custom-color-control { display: flex; align-items: center; gap: 11px; }
.custom-color-control input[type="color"] {
  width: 38px; height: 38px; border: none; border-radius: 10px; padding: 0;
  background: none; cursor: pointer;
}
.custom-color-control input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.custom-color-control input[type="color"]::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 10px; }
#custom-color-value { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.custom-color-control .hint { font-size: 11.5px; color: var(--ink-3); margin-left: auto; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input {
  width: 100%; height: 40px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px; color: var(--ink);
  transition: all .15s ease;
}
.field input::placeholder { color: #b6b4af; }
.field input:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(90,107,91,.12);
}

/* 上传 */
.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.upload-item { display: flex; flex-direction: column; gap: 8px; }
.upload-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.upload-box { position: relative; padding: 0; border: none; background: none; }
.upload-preview {
  width: 100%; aspect-ratio: 1 / 1;
  border: 1.5px dashed #d3d1ca;
  border-radius: 11px;
  background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--ink-3); font-size: 24px; font-weight: 300;
  overflow: hidden; transition: all .15s ease;
}
.upload-preview small { font-size: 11px; font-weight: 500; }
.upload-box:hover .upload-preview { border-color: var(--brand); color: var(--brand); background: #f4f7f2; }
.upload-preview.has-image { border-style: solid; border-color: var(--line); padding: 8px; }
.upload-preview img { width: 100%; height: 100%; object-fit: contain; border-radius: 5px; }
.upload-remove {
  display: none; position: absolute; top: -7px; right: -7px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; border: 2px solid var(--surface);
  font-size: 14px; line-height: 1; place-items: center; z-index: 2;
}
.upload-box.has-image .upload-remove { display: grid; }
.upload-note { margin: 14px 0 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }

/* ---------- 预览区 ---------- */
.stage {
  position: sticky; top: 94px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.stage-bar {
  height: 58px; padding: 0 22px;
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between;
}
.stage-title { font-weight: 700; font-size: 14px; }
.stage-title span { color: var(--ink-3); font-weight: 500; font-size: 11.5px; margin-left: 5px; }
.lang-switch { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; display: flex; gap: 2px; }
.lang-btn {
  border: none; background: none; border-radius: 6px;
  padding: 6px 15px; font-size: 12px; font-weight: 600; color: var(--ink-3);
  transition: all .15s ease;
}
.lang-btn.active { background: var(--brand); color: #fff; box-shadow: 0 1px 5px rgba(90,107,91,.3); }
.stage-body {
  flex: 1;
  padding: 40px 34px 26px;
  background:
    radial-gradient(circle at 50% 40%, #fbfaf8 0%, #f1efea 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 420px;
}
.card-shadow {
  width: 100%; max-width: 660px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  line-height: 0;
  transform: perspective(1600px) rotateX(3deg);
  transition: transform .3s ease;
}
.card-shadow:hover { transform: perspective(1600px) rotateX(0deg) translateY(-3px); }
#card-canvas { width: 100%; height: auto; display: block; }
.stage-hint {
  margin: 26px 0 0; font-size: 11.5px; color: var(--ink-3);
  display: flex; align-items: center; gap: 6px;
}
.stage-foot {
  padding: 18px 22px 20px; border-top: 1px solid var(--line-2); text-align: center;
}
.btn-wide { width: 100%; justify-content: center; height: 44px; font-size: 14px; }
.stage-foot p { margin: 11px 0 0; font-size: 11px; color: var(--ink-3); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; }
  .stage { position: static; order: -1; }
  .stage-body { min-height: auto; padding: 30px 22px 22px; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 14px; height: 60px; }
  .brand-text span { display: none; }
  .btn { padding: 8px 12px; font-size: 12px; }
  .app { padding: 16px 12px 40px; gap: 18px; }
  .panel { padding: 17px 16px 19px; }
  .form-grid { grid-template-columns: 1fr; }
  .type-grid { gap: 9px; }
  .upload-grid { gap: 9px; }
  .stage-bar { padding: 0 14px; }
  .stage-body { padding: 24px 14px 18px; }
}
