:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --line: #e6eaf2;
  --text: #1c2434;
  --muted: #7b869c;
  --primary: #2f6bff;
  --primary-dark: #1f52d6;
  --radius: 14px;
  --shadow: 0 2px 6px rgba(24, 39, 75, .04), 0 12px 32px rgba(24, 39, 75, .06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1360px; margin: 0 auto; padding: 22px 24px 40px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 13px; flex: none;
  background: linear-gradient(135deg, #3b78ff, #1e4fd0);
  color: #fff; font-weight: 800; font-size: 17px; letter-spacing: .5px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(47, 107, 255, .28);
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.privacy {
  display: flex; align-items: center; gap: 10px;
  background: #eaf7ee; border: 1px solid #cdecda; color: #146c3a;
  padding: 8px 14px; border-radius: 999px; font-size: 12.5px;
}
.privacy b { display: block; font-size: 12.5px; }
.privacy small { display: block; opacity: .75; font-size: 11px; line-height: 1.3; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #22b35a; box-shadow: 0 0 0 4px rgba(34, 179, 90, .15); }

/* ---------- 布局 ---------- */
.layout {
  display: grid; grid-template-columns: minmax(340px, 1fr) minmax(360px, 1.05fr);
  gap: 20px; align-items: start;
}
.col-controls { display: flex; flex-direction: column; gap: 16px; }
.col-preview { position: sticky; top: 20px; }

.card, .preview-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2, .preview-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.step {
  width: 24px; height: 24px; border-radius: 8px; flex: none;
  background: #eaf0ff; color: var(--primary); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.note { margin: -4px 0 14px; font-size: 12.5px; color: var(--muted); }
.note b { color: #4a556b; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- 上传 ---------- */
.drop {
  border: 1.5px dashed #b9c6e4; border-radius: 12px; background: #fafbff;
  padding: 22px 14px; text-align: center; cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}
.drop:hover, .drop.over { border-color: var(--primary); background: #f0f5ff; }
.drop:focus-visible { outline: 3px solid rgba(47, 107, 255, .3); outline-offset: 2px; }
.drop-plus { font-size: 30px; line-height: 1; color: var(--primary); font-weight: 300; }
.drop-title { margin-top: 6px; font-size: 13.5px; }
.drop-sub { margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.toolrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; min-width: 0; }
.field > label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: #4b566b; margin-bottom: 6px; font-weight: 600; }
.field output { font-weight: 600; color: var(--primary); font-size: 12px; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field-inline { display: flex; align-items: center; padding-top: 18px; }

input[type="text"], select {
  width: 100%; height: 36px; padding: 0 10px; font-size: 13px; color: var(--text);
  background: #fff; border: 1px solid #dce2ee; border-radius: 8px; outline: none;
  font-family: inherit;
}
input[type="text"]:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
input[type="color"] { width: 100%; height: 34px; padding: 2px; border: 1px solid #dce2ee; border-radius: 8px; background: #fff; cursor: pointer; }
input[type="range"] { width: 100%; height: 20px; margin: 0; accent-color: var(--primary); cursor: pointer; }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: #4b566b; cursor: pointer; user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; margin: 0; }

.segmented { display: flex; background: #f1f4fa; border-radius: 9px; padding: 3px; gap: 2px; }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented span {
  display: block; text-align: center; padding: 6px 2px; border-radius: 7px;
  font-size: 12px; color: #6b768c; cursor: pointer; white-space: nowrap; transition: .15s;
}
.segmented input:checked + span { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(20,35,70,.12); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ---------- 按钮 ---------- */
.btn {
  font: inherit; font-size: 13px; font-weight: 600; border-radius: 9px;
  padding: 9px 16px; border: 1px solid transparent; cursor: pointer; transition: .16s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(47,107,255,.25); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef3ff; color: var(--primary); border-color: #dbe6ff; }
.btn-secondary:hover { background: #e2ebff; }
.btn-ghost { background: #fff; color: #5c677d; border-color: #dce2ee; }
.btn-ghost:hover { background: #f7f9fd; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-mini { padding: 4px 9px; font-size: 11.5px; font-weight: 600; background: #f2f5fb; color: #55617a; border: 1px solid #e3e8f2; border-radius: 7px; }
.btn-mini:hover { background: #e8efff; color: var(--primary); border-color: #cddbff; }

/* ---------- 裁剪槽 ---------- */
.slot { border: 1px solid var(--line); border-radius: 11px; padding: 10px; margin-bottom: 12px; background: #fcfdff; }
.slot:last-of-type { margin-bottom: 0; }
.slot-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.slot-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.tag { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 6px; }
.tag-top { background: #eaf0ff; color: #2a55c8; }
.tag-bottom { background: #fff1e6; color: #b5631a; }
.crop-wrap {
  position: relative; width: 100%; height: 190px;
  background: #f2f5fa; border-radius: 8px; overflow: hidden;
  border: 1px solid #e8ecf4;
}
.crop-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.crop-canvas.dragging { cursor: grabbing; }
.slot-hint { margin-top: 7px; font-size: 11.5px; color: var(--muted); min-height: 17px; }

/* ---------- 预览 ---------- */
.preview-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.badge-live { font-size: 11px; font-weight: 700; color: #14804a; background: #e7f7ee; border-radius: 999px; padding: 3px 10px; }
.paper-wrap {
  background: #e9edf5; border-radius: 10px; padding: 18px;
  display: flex; justify-content: center; max-height: 66vh; overflow: auto;
}
#pagePreview {
  display: block; width: 100%; max-width: 460px; height: auto;
  background: #fff; box-shadow: 0 4px 20px rgba(28, 42, 80, .16); border-radius: 2px;
}
.actions { display: flex; gap: 9px; margin-top: 16px; flex-wrap: wrap; }
.actions .btn-primary { flex: 1; min-width: 160px; }
.tip { margin: 12px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.7; }

.footer { margin-top: 26px; text-align: center; font-size: 11.5px; color: #98a2b5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 16px);
  background: #1e293f; color: #fff; font-size: 13px; padding: 10px 20px;
  border-radius: 10px; box-shadow: 0 10px 30px rgba(15,25,50,.28);
  opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s; z-index: 99;
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .col-preview { position: static; }
  .paper-wrap { max-height: none; }
}
@media (max-width: 560px) {
  .app { padding: 14px 12px 30px; }
  .card, .preview-card { padding: 14px; }
  .grid2 { grid-template-columns: 1fr; }
  .field-inline { padding-top: 2px; }
  .crop-wrap { height: 160px; }
  .privacy { display: none; }
}
