:root {
  --brand: #1f4e46;
  --bg: #f3f4f2;
  --card: #fff;
  --text: #1f2421;
  --muted: #6b716d;
  --border: #dde0dc;
  font-family: 'Noto Sans SC Variable', system-ui, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
[v-cloak] { display: none; }
button, input, textarea { font: inherit; color: inherit; }

.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; font-size: 18px; color: var(--brand); margin-right: auto; }
.switch { display: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; font-size: 14px; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:disabled { opacity: 0.6; cursor: wait; }
.btn.ghost { background: transparent; }
.btn.add { width: 100%; border-style: dashed; color: var(--brand); }

/* 两栏占满窗口剩余高度，各自滚动：左边往下填，右边预览一直在 */
.layout { display: grid; grid-template-columns: minmax(360px, 480px) 1fr; height: calc(100vh - 56px); height: calc(100dvh - 56px); }
.editor { overflow-y: auto; padding: 16px; border-right: 1px solid var(--border); }
.preview { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; align-items: center; }
.preview .paper { box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.card.foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }

label, .field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
input:not([type=checkbox]), textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-size: 14px; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 30%, transparent); border-color: var(--brand); }
input:disabled { background: #f5f5f5; }
textarea { resize: vertical; line-height: 1.6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.end { display: flex; align-items: center; gap: 8px; }
.check { flex-direction: row; align-items: center; gap: 4px; margin: 0; white-space: nowrap; color: var(--text); }

/* 顶部 3 步引导 */
.steps { display: flex; gap: 6px; margin-bottom: 6px; }
.steps div { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; border-radius: 8px; background: #fff; border: 1px solid var(--border); font-size: 13px; font-weight: 600; white-space: nowrap; }
.steps b, .no { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-style: normal; }
.steps-hint { margin: 0 2px 12px; line-height: 1.6; }
.card h3 { display: flex; align-items: center; gap: 8px; }
.card h3 .sub { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted); }

/* 模板横向一排，左右滑动 */
.tpl-list { display: flex; gap: 10px; margin: 0 -16px 12px; padding: 2px 16px 8px; overflow-x: auto; scroll-snap-type: x proximity; }
.tpl-btn { flex: none; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px 6px; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; font-size: 13px; }
.tpl-btn.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); color: var(--brand); }
/* 缩略图：整页 A4 按比例缩到 96px 宽 */
.thumb { width: 96px; height: 136px; overflow: hidden; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); pointer-events: none; }
.thumb .paper { zoom: 0.121; }

/* 预览里每隔一页高度画一条红色细线，提示大致分页位置 */
.paper.guides { position: relative; }
.paper.guides::after { content: ''; position: absolute; inset: 297mm 0 0; z-index: 5; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(220, 38, 38, 0.55) 0 0.4mm, transparent 0.4mm 297mm); }
.row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.row .label { width: 64px; font-size: 13px; color: var(--muted); }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.seg { height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; }
.seg.on { border-color: var(--brand); color: var(--brand); font-weight: 600; }

.sample-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.sample-btn { display: grid; grid-template-columns: 36px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 6px 8px; text-align: left; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; }
.sample-btn:hover { border-color: var(--brand); }
.sample-btn.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); background: color-mix(in srgb, var(--brand) 6%, #fff); }
.sample-btn img { grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: top; }
.sample-btn b { font-size: 13px; }
.sample-btn span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card > .hint { margin: 10px 0 0; }

/* 预览下方：左边分页说明，右边版权声明，宽度对齐纸张 */
.preview-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; max-width: 100%; margin-top: 10px; }
.preview-foot .legal { margin-left: auto; color: #a3a8a4; font-size: 11px; }

.left { font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.mask { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.4); }
.dialog { width: 100%; max-width: 380px; padding: 20px; border-radius: 12px; background: #fff; }
.dialog h3 { margin: 0 0 8px; font-size: 16px; }
.dialog .hint { margin: 0 0 12px; line-height: 1.6; }
.dialog input { letter-spacing: 0.08em; text-transform: uppercase; }
.err { margin: 8px 0 0; color: #b42318; font-size: 13px; }
.dialog-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* 照片：最多 3 张备选，点哪张用哪张 */
.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-pick, .photo-add { position: relative; flex: none; width: 64px; height: 82px; padding: 0; border-radius: 8px; cursor: pointer; }
.photo-pick { border: 2px solid transparent; background: none; box-shadow: 0 0 0 1px var(--border); }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; object-position: top; border-radius: 6px; display: block; }
.photo-pick.on { border-color: var(--brand); box-shadow: none; }
.photo-pick.on::after { content: '✓'; position: absolute; left: 4px; bottom: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; line-height: 18px; text-align: center; }
.photo-pick em { position: absolute; right: 3px; top: 3px; padding: 0 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 11px; font-style: normal; }
.photo-pick .del { position: absolute; right: -7px; top: -7px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--border); color: #b42318; font-size: 15px; line-height: 19px; text-align: center; }
.photo-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; margin: 0; border: 1px dashed var(--border); background: #fff; color: var(--muted); font-size: 12px; }
.photo-add b { font-size: 22px; line-height: 1; color: var(--brand); font-weight: 400; }
.photo-add.none b { font-size: 18px; color: var(--muted); }
.photo-add:hover { border-color: var(--brand); }
.card > .photos-hint { margin: 8px 0 16px; }

.photo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.photo-row img, .photo-empty { flex: none; width: 60px; height: 76px; object-fit: cover; object-position: top; border-radius: 6px; }
.photo-empty { display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border); color: var(--muted); font-size: 12px; }
.photo-ops { display: flex; flex-direction: column; gap: 6px; }
.photo-ops > span:first-child { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-row label.btn { flex-direction: row; margin: 0; color: var(--text); }
.dialog .buy { margin: 12px 0 0; }

.item-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.item-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.item-tools b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-tools span { display: flex; gap: 4px; flex: none; }
.mini { height: 26px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 12px; cursor: pointer; }
.mini:disabled { opacity: 0.4; cursor: default; }
.mini.danger { color: #b42318; }

@media (max-width: 899px) {
  .switch { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  .switch button { height: 32px; padding: 0 14px; border: 0; background: #fff; font-size: 14px; }
  .switch button.on { background: var(--brand); color: #fff; }
  .brand { font-size: 16px; }
  .layout { display: block; height: auto; }
  .editor { border: 0; }
  .show-edit .preview, .show-preview .editor { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
