/* 编辑器工作台。名片本体的样式在 card.css，这里只管外围工具界面 */

:root {
  --navy: #0a2140;
  --navy-2: #17325a;
  --gold: #b67a32;
  --page: #eef1f7;
  --panel: #ffffff;
  --line: #e2e8f1;
  --ink: #16243a;
  --muted: #6b7a90;
  --ok: #2f8f5b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ---------------------------------------------------------- 顶栏 */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 62px; padding: 0 22px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.brand h1 { font-size: 15.5px; margin: 0; font-weight: 800; letter-spacing: .2px; white-space: nowrap; }
.brand .sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; }
.brand .divider { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.brand .gold-rule { width: 22px; height: 2px; background: var(--gold); border-radius: 2px; }

.actions { display: flex; align-items: center; gap: 9px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 10px 14px; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
.btn:hover { border-color: #c9d4e3; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { background: #f5f7fb; }
.btn.sm { padding: 7px 11px; font-size: 12px; border-radius: 9px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .spin { width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: 268px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 44px rgba(16, 36, 66, .16); padding: 6px; display: none; z-index: 40;
}
.menu.open .menu-pop { display: block; }
.menu-pop button {
  width: 100%; text-align: left; border: 0; background: none; border-radius: 9px;
  padding: 10px 11px; font-size: 13px; font-weight: 600;
}
.menu-pop button:hover { background: #f2f5fa; }
.menu-pop button span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }

/* ---------------------------------------------------------- 布局 */

.layout {
  display: grid; grid-template-columns: minmax(480px, 1fr) 470px;
  gap: 24px; padding: 22px; max-width: 1520px; margin: 0 auto; align-items: start;
}

.editor-col { display: grid; gap: 14px; }
.stage { position: sticky; top: 84px; display: grid; gap: 12px; justify-items: center; }

/* ---------------------------------------------------------- 表单 */

.fs {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 4px 16px rgba(18, 40, 74, .04);
}
.fs-head { display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px 12px; }
.fs-step {
  font-size: 11px; font-weight: 800; color: var(--gold);
  border: 1px solid #ecd9c0; background: #fdf7ef;
  border-radius: 7px; padding: 3px 7px; letter-spacing: .5px; flex: 0 0 auto;
}
.fs-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.fs-head p { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.fs-body { padding: 4px 18px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }

.ff { display: grid; gap: 7px; grid-column: 1 / -1; align-content: start; }
.ff.half { grid-column: auto; min-width: 0; }
.fl { font-size: 12px; font-weight: 700; color: #3d4d64; display: flex; align-items: center; gap: 7px; }
.fl.sm { font-size: 11px; color: var(--muted); font-weight: 600; }
.fl .req { font-style: normal; font-size: 10px; color: var(--gold); background: #fdf3e7; padding: 1px 5px; border-radius: 5px; }
.fl .cnt { font-style: normal; font-size: 11px; color: var(--muted); font-weight: 500; }
.fh { margin: 0; font-size: 11.5px; color: #8794a7; line-height: 1.6; }

.fi {
  width: 100%; border: 1px solid var(--line); background: #fbfcfe;
  border-radius: 10px; padding: 10px 12px; font-size: 13px; outline: none; transition: .15s;
}
.fi:focus { border-color: var(--navy); background: #fff; box-shadow: 0 0 0 3px rgba(10, 33, 64, .07); }
textarea.fi { resize: vertical; line-height: 1.7; }
.fi-wrap { position: relative; }
.fi-suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); }

.fc { display: flex; gap: 9px; align-items: center; }
.fc input[type="color"] {
  width: 42px; height: 38px; padding: 2px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff;
}

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.sw {
  width: 44px; height: 25px; border-radius: 999px; border: 0; background: #d3dae5;
  padding: 3px; transition: .18s; flex: 0 0 44px;
}
.sw i { display: block; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.sw.on { background: var(--navy); }
.sw.on i { transform: translateX(19px); }

/* 图片上传 */
.up-single { display: flex; gap: 14px; align-items: flex-start; }
.up-preview {
  width: 96px; height: 118px; flex: 0 0 96px; border-radius: 12px;
  border: 1px dashed #c6d0de; background: #f7f9fc;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background-image: linear-gradient(45deg, #eef1f5 25%, transparent 25%),
    linear-gradient(-45deg, #eef1f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef1f5 75%),
    linear-gradient(-45deg, transparent 75%, #eef1f5 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}
.up-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.up-preview span { font-size: 11px; color: #97a3b5; }
.up-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.up-actions .fh { width: 100%; }

.up-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.up-cell { position: relative; }
.up-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; }
.up-del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  border: 0; background: #16243a; color: #fff; font-size: 13px; line-height: 1;
}
.up-add {
  aspect-ratio: 1; border: 1px dashed #c6d0de; background: #f8fafc; border-radius: 10px;
  color: #8fa0b6; font-size: 17px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
}
.up-add span { font-size: 10px; }

/* 重复条目 */
.li-wrap { display: grid; gap: 9px; }
.li { border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; overflow: hidden; }
.li-head { display: flex; align-items: center; gap: 9px; padding: 9px 11px; background: #f4f7fb; border-bottom: 1px solid var(--line); }
.li-no {
  width: 19px; height: 19px; border-radius: 6px; background: var(--navy); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 19px;
}
.li-title { flex: 1; font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-tools { display: flex; gap: 4px; }
.li-tools button {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  font-size: 11px; padding: 3px 7px; color: #55647c;
}
.li-tools button[disabled] { opacity: .35; cursor: default; }
.li-tools button[data-del]:hover { color: #c0392b; border-color: #edc7c1; }
.li-body { padding: 11px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.ff-sub { display: grid; gap: 5px; min-width: 0; }
.ff-sub.full { grid-column: 1 / -1; }
.li-empty { font-size: 12px; color: #93a0b3; padding: 12px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.btn.add { width: 100%; justify-content: center; }

/* ---------------------------------------------------------- 预览 */

.preview-tabs {
  display: flex; gap: 4px; background: #fff; border: 1px solid var(--line);
  border-radius: 11px; padding: 4px;
}
.preview-tabs button {
  border: 0; background: none; border-radius: 8px; padding: 7px 13px;
  font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.preview-tabs button.on { background: var(--navy); color: #fff; }

.phone-shell {
  width: 430px; padding: 11px; border-radius: 42px; background: #10151d;
  box-shadow: 0 30px 60px rgba(14, 30, 55, .28), inset 0 0 0 2px #2a323d;
}
.phone {
  height: 760px; border-radius: 32px; overflow-y: auto; overflow-x: hidden; overflow-anchor: none;
  background: #f5f7fb; position: relative; scrollbar-width: none;
}
.phone::-webkit-scrollbar { display: none; }

.stage-foot { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hint-line { font-size: 11.5px; color: var(--muted); text-align: center; max-width: 420px; line-height: 1.7; }

/* ---------------------------------------------------------- 弹层 */

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(14px);
  background: #10203a; color: #fff; padding: 12px 18px; border-radius: 11px;
  font-size: 13px; font-weight: 600; box-shadow: 0 16px 36px rgba(10, 25, 50, .3);
  opacity: 0; pointer-events: none; transition: .22s; z-index: 90; max-width: 78vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-mask {
  position: fixed; inset: 0; background: rgba(12, 22, 40, .5); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 80; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: min(520px, 100%); max-height: 86vh; overflow: auto;
  box-shadow: 0 30px 70px rgba(10, 25, 50, .3);
}
.modal header { padding: 18px 20px 6px; }
.modal header h3 { margin: 0; font-size: 16px; }
.modal header p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.modal .body { padding: 14px 20px 18px; display: grid; gap: 12px; }
.modal footer { padding: 0 20px 18px; display: flex; gap: 9px; justify-content: flex-end; }

.link-row { display: flex; gap: 8px; }
.link-row .btn { white-space: nowrap; }
.link-row .fi { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.qr { display: flex; gap: 14px; align-items: center; }
.qr img { width: 128px; height: 128px; border: 1px solid var(--line); border-radius: 10px; }

.order-list { display: grid; gap: 9px; }
.order-item { border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; font-size: 12.5px; }
.order-item .top { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.order-item .sub { color: var(--muted); font-size: 11.5px; margin-top: 5px; line-height: 1.7; }
.tag { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.tag.paid { background: #eaf6ef; color: var(--ok); }
.tag.created { background: #fdf3e7; color: var(--gold); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .stage { position: static; order: -1; }
  .phone-shell { width: min(430px, 92vw); }
  .li-body { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 780px) {
  .fs-body { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { height: auto; padding: 12px; flex-wrap: wrap; }
  .layout { padding: 12px; }
  .li-body { grid-template-columns: 1fr; }
  .up-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* 微信转发预览 */
.wx-preview {
  display: flex; gap: 11px; align-items: stretch;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #f7f9fc;
}
.wx-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; flex: 0 0 96px; background: #fff; }
.wx-text { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 0; }
.wx-text b { font-size: 13.5px; }
.wx-text span { font-size: 12px; color: var(--muted); line-height: 1.6; }
