/* ============================================================
 * 邀请函工坊 · 样式表（类型 × 风格）
 * ============================================================ */
:root {
  --bg: #f3f4f6; --panel: #ffffff; --ink: #1f2430; --muted: #6b7280;
  --line: #e5e7eb; --brand: #4f46e5; --radius: 14px; --shadow: 0 10px 30px rgba(17,24,39,.08);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ---------- 顶部栏 ---------- */
.app-header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; background: rgba(255,255,255,.9); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #8b5cf6); color: #fff; display: grid; place-items: center; font-size: 16px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .5px; }
.top-nav { display: flex; gap: 6px; }
.top-link { border: none; background: transparent; color: var(--muted); font-size: 14px; padding: 6px 12px; border-radius: 999px; }
.top-link.active { background: var(--brand); color: #fff; }

.screen { display: none; }
.screen.active { display: block; }

/* ---------- 画廊 ---------- */
.gallery-hero { padding: 26px 20px 8px; text-align: center; }
.gallery-hero h1 { margin: 0 0 8px; font-size: 22px; }
.gallery-hero p { margin: 0 auto; max-width: 540px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.gallery-foot { text-align: center; padding: 8px 0 40px; }

.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; padding: 18px 20px 30px; max-width: 960px; margin: 0 auto; }
.tpl-card { background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); transition: transform .15s ease, box-shadow .15s ease; }
.tpl-card:active { transform: translateY(2px); }
.tpl-thumb { position: relative; height: 240px; overflow: hidden; background: #eee; border-bottom: 1px solid var(--line); }
.tpl-meta { padding: 12px 14px; }
.tpl-meta .name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.tpl-meta .desc { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.5; }
.tpl-meta .tag { display: inline-block; margin-top: 8px; font-size: 11px; color: var(--brand); background: #eef2ff; padding: 2px 8px; border-radius: 999px; }

/* 类型选择卡：不显示模板，仅类型信息 */
.type-card { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 118px; padding: 22px 14px; cursor: pointer; }
.type-card .type-emoji { font-size: 38px; line-height: 1; margin-bottom: 10px; }
.type-card .tpl-meta { text-align: center; padding: 0; }
.type-card .tpl-meta .name { justify-content: center; font-size: 16px; }

/* ---------- 等比缩放包裹层 ---------- */
.scaler { position: relative; }
.scaler > .card { position: absolute; top: 0; left: 0; transform-origin: top left; }

/* ---------- 编辑器布局 ---------- */
.editor-layout { display: grid; grid-template-columns: 1fr 360px; gap: 0; min-height: calc(100vh - 55px); }
.preview-pane { display: flex; flex-direction: column; align-items: center; padding: 26px 16px 20px;
  background: radial-gradient(circle at 20% 10%, #e9ebff, transparent 40%), radial-gradient(circle at 80% 90%, #ffe9f3, transparent 40%), var(--bg); }
.preview-stage { flex: 1; display: flex; align-items: flex-start; justify-content: center; width: 100%; overflow: auto; padding: 6px; }
.action-bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }

/* ---------- 卡片基础（导出目标 + 语义块） ---------- */
.card { position: relative; width: 360px; min-height: 600px; padding: 50px 34px 44px; box-sizing: border-box; background: #fff; color: #222; font-family: var(--serif); display: flex; flex-direction: column; align-items: center; text-align: center; overflow: hidden; border-radius: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.card .blk { margin: 0; }
.card .blk-eyebrow { font-family: inherit; letter-spacing: 3px; font-size: 11px; text-transform: uppercase; opacity: .7; margin-bottom: 12px; }
.card .blk-heading { font-size: 28px; font-weight: 700; margin: 0 0 16px; letter-spacing: 2px; line-height: 1.25; }
.card .blk-sub { font-size: 13px; opacity: .8; letter-spacing: 1px; margin: 0 0 14px; }
.card .blk-duo { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 4px 0 10px; }
.card .blk-duo span { font-size: 20px; font-weight: 600; letter-spacing: 1px; }
.card .blk-duo i { font-style: normal; opacity: .55; font-size: 20px; }
.card .blk-person { margin: 6px 0; }
.card .blk-person .p-label { display: block; font-family: inherit; font-size: 11px; letter-spacing: 2px; opacity: .6; margin-bottom: 3px; }
.card .blk-person .p-val { font-size: 20px; font-weight: 600; letter-spacing: .5px; }
.card .blk-person.role-muted .p-val { font-size: 15px; font-weight: 500; opacity: .85; }
.card .blk-badge { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; font-weight: 800; font-size: 24px; margin: 8px 0; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.card .blk-badge small { font-size: 11px; font-weight: 600; }
.card .blk-theme { display: inline-block; font-family: inherit; font-size: 13px; padding: 5px 14px; border-radius: 999px; margin-bottom: 12px; }
.card .blk-text { font-size: 14px; line-height: 1.8; max-width: 240px; margin: 12px 0; opacity: .9; }
.card .blk-text.role-lead { font-size: 16px; font-weight: 600; opacity: 1; }
.card .blk-text.role-muted { font-size: 13px; opacity: .8; }
.card .blk-photo { width: 150px; height: 150px; border-radius: 50%; overflow: hidden; margin: 6px 0 16px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.card .blk-photo img { width: 100%; height: 100%; object-fit: cover; }
.card .blk-divider { margin: 16px 0; font-size: 18px; opacity: .7; }
.card .blk-meta { width: 100%; margin-top: auto; padding-top: 14px; }
.card .blk-meta p { margin: 9px 0; font-size: 14px; line-height: 1.5; }
.card .blk-meta b { display: inline-block; min-width: 40px; margin-right: 8px; font-family: inherit; font-weight: 600; opacity: .8; }

/* 配图：敬邀语下方、与祝福语等宽(240px)、形状裁切 + 四周羽化模糊 */
.card .blk-feature { margin: 16px 0 10px; display: flex; justify-content: center; width: 100%; }
.card .blk-feature .feat { width: 240px; height: 240px; overflow: hidden; }
.card .blk-feature .feat img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 左对齐排版时，配图也靠左，与祝福语对齐 */
.ly-left .blk-feature, .ly-split .blk-feature, .ly-timeline .blk-feature { justify-content: flex-start; }

/* ============================================================
 * 排版格式（结构维度，由 .card 上的 ly-* 类切换）
 * ============================================================ */
.ly-left { text-align: left; align-items: stretch; justify-content: flex-start; }
.ly-left .blk { text-align: left; }
.ly-left .blk-duo { justify-content: flex-start; }
.ly-left .blk-photo { margin-left: 0; margin-right: auto; }
.ly-left .blk-theme { align-self: flex-start; }

.ly-banner .blk-heading { position: relative; padding-bottom: 16px; margin-bottom: 20px; }
.ly-banner .blk-heading::after { content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 64px; height: 3px; background: currentColor; opacity: .45; border-radius: 3px; }
.ly-banner .blk-eyebrow { margin-bottom: 14px; }

.ly-timeline .blk-meta { position: relative; padding-left: 20px; text-align: left; }
.ly-timeline .blk-meta::before { content: ""; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 2px; background: currentColor; opacity: .28; }
.ly-timeline .blk-meta p { position: relative; text-align: left; }
.ly-timeline .blk-meta p::before { content: ""; position: absolute; left: -17px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: .6; }

.ly-focus { padding-top: 74px; padding-bottom: 66px; justify-content: center; }
.ly-focus .blk-heading { font-size: 34px; letter-spacing: 4px; }
.ly-focus .blk-text { max-width: 240px; }
.ly-focus .blk-divider { margin: 26px 0; }
.ly-focus .blk-photo { margin-top: 14px; }

.ly-split { text-align: left; align-items: stretch; }
.ly-split .blk-eyebrow, .ly-split .blk-heading { text-align: left; }
.ly-split .blk-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 12px; }
.ly-split .blk-meta p { display: flex; flex-direction: column; gap: 2px; margin: 0; text-align: left; }
.ly-split .blk-meta b { margin: 0; }
.ly-split .blk-photo { margin-left: 0; margin-right: auto; }

/* ============================================================
 * 字体（字体维度，由 .card 上的 ft-* 类切换，!important 确保覆盖风格默认）
 * ============================================================ */
.ft-serif { font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif !important; }
.ft-sans { font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif !important; }
.ft-kai { font-family: "Kaiti SC", "STKaiti", "KaiTi", "SimKai", serif !important; }
.ft-round { font-family: "Yuanti SC", "YuanTi", "Hiragino Sans GB", "Microsoft YaHei", sans-serif !important; }
.ft-hand { font-family: "Xingkai SC", "STXingkai", "Hanzipen SC", "Brush Script MT", cursive !important; }

/* 装饰通用 */
.deco { position: absolute; width: 88px; height: 88px; opacity: .55; pointer-events: none; color: currentColor; }
.deco-tl { top: 14px; left: 14px; }
.deco-br { bottom: 14px; right: 14px; transform: rotate(180deg); }

/* ============================================================
 * 风格皮肤
 * ============================================================ */
/* 1 优雅花卉 */
.st-floral { background: linear-gradient(160deg, #fdf6f0, #f6e7db); color: #5b4636; }
.st-floral .deco { color: #b98a6e; }
.st-floral .blk-meta b { color: #b98a6e; }

/* 2 缤纷派对 */
.st-confetti { background: linear-gradient(160deg, #ffd9ec, #c9b6ff); color: #4a235a; }
.st-confetti .deco { color: #ff7eb3; opacity: .85; }
.st-confetti .deco-balloon-l { top: 18px; left: 14px; width: 70px; height: 100px; }
.st-confetti .deco-balloon-r { bottom: 30px; right: 14px; width: 56px; height: 84px; }
.st-confetti .confetti { position: absolute; inset: 0; opacity: .55; pointer-events: none;
  background-image: radial-gradient(circle, #ff5d8f 2px, transparent 3px), radial-gradient(circle, #ffd23f 2px, transparent 3px), radial-gradient(circle, #4cc9f0 2px, transparent 3px), radial-gradient(circle, #80ed99 2px, transparent 3px);
  background-size: 70px 70px, 90px 90px, 110px 110px, 80px 80px; background-position: 10px 30px, 50px 80px, 20px 140px, 60px 200px; }
.st-confetti .blk-badge { background: #fff; color: #ff5d8f; }
.st-confetti .blk-theme { background: rgba(255,255,255,.6); color: #4a235a; }
.st-confetti .blk-meta p { display: inline-block; background: rgba(255,255,255,.6); border-radius: 999px; padding: 6px 14px; margin: 5px; font-size: 13px; }

/* 3 商务几何 */
.st-geometry { background: #ffffff; color: #1f3a5f; font-family: var(--sans); }
.st-geometry .deco { color: #1f3a5f; opacity: .12; top: -10px; right: -10px; width: 140px; height: 140px; }
.st-geometry .blk-heading { font-size: 24px; font-weight: 800; }
.st-geometry .blk-meta { border-top: 1px solid #e3e9f2; padding-top: 14px; }
.st-geometry .blk-meta b { color: #1f3a5f; min-width: 44px; }

/* 4 清新粉彩 */
.st-pastel { background: linear-gradient(160deg, #fff1f7, #e6f6ff); color: #6b4a5b; }
.st-pastel .deco { color: #f4a8c0; }
.st-pastel .deco-star-l { top: 22px; left: 22px; width: 34px; height: 34px; opacity: .8; }
.st-pastel .deco-star-r { bottom: 40px; right: 26px; width: 26px; height: 26px; opacity: .7; }
.st-pastel .blk-meta b { color: #d98aa8; }

/* 5 红金喜庆 */
.st-festive { background: linear-gradient(165deg, #8a0f1c, #c8102e); color: #ffe9b0; }
.st-festive .deco { color: #ffd76a; opacity: .9; }
.st-festive .deco-lantern-l { top: 12px; left: 16px; width: 50px; height: 70px; }
.st-festive .deco-lantern-r { top: 12px; right: 16px; width: 50px; height: 70px; }
.st-festive .blk-eyebrow { color: #ffd76a; opacity: .9; }
.st-festive .blk-heading { font-size: 38px; font-weight: 800; letter-spacing: 6px;
  background: linear-gradient(180deg, #fff2c4, #f5c542); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 2px 10px rgba(0,0,0,.2); }
.st-festive .blk-person .p-val { color: #fff; }
.st-festive .blk-text.role-lead { color: #fff; }
.st-festive .blk-meta b { color: #ffd76a; }

/* 6 炫彩渐变 */
.st-gradient { background: linear-gradient(135deg, #7b2ff7, #f107a3); color: #fff; }
.st-gradient .deco { color: #ffd6f5; opacity: .9; }
.st-gradient .deco-spark { top: 16px; right: 18px; width: 30px; height: 30px; }
.st-gradient .blk-theme { background: rgba(255,255,255,.22); color: #fff; }
.st-gradient .blk-meta p { background: rgba(255,255,255,.16); border-radius: 10px; padding: 8px 12px; margin: 6px 0; }

/* 7 极简留白 */
.st-minimal { background: #ffffff; color: #1a1a1a; border: 1px solid #ececec; box-shadow: 0 12px 40px rgba(0,0,0,.08); }
.st-minimal .deco { color: #cfcfcf; opacity: .9; top: 50%; left: 50%; width: 150px; height: 150px; transform: translate(-50%, -50%); }
.st-minimal .blk-eyebrow { color: #999; }
.st-minimal .blk-heading { font-weight: 600; }
.st-minimal .blk-divider { letter-spacing: 6px; }
.st-minimal .blk-meta b { color: #111; }

/* 8 复古质感 */
.st-retro { background: linear-gradient(160deg, #f3e9d2, #e7d3b1); color: #5b4632; }
.st-retro .deco { color: #9c6b3f; opacity: .8; top: 16px; left: 50%; width: 56px; height: 56px; transform: translateX(-50%); }
.st-retro .blk-badge { background: #9c6b3f; color: #f3e9d2; }
.st-retro .blk-meta b { color: #9c6b3f; }

/* 9 科技蓝紫 */
.st-tech { background: linear-gradient(160deg, #0f172a, #1e293b); color: #e2e8f0; font-family: var(--sans); }
.st-tech .deco { color: #38bdf8; opacity: .5; top: 0; left: 0; width: 100%; height: 100%; }
.st-tech .blk-eyebrow { color: #38bdf8; opacity: .9; }
.st-tech .blk-heading { font-weight: 800; text-shadow: 0 0 18px rgba(56,189,248,.35); }
.st-tech .blk-sub { color: #93c5fd; }
.st-tech .blk-person .p-val { color: #fff; }
.st-tech .blk-text { color: #cbd5e1; }
.st-tech .blk-meta b { color: #38bdf8; min-width: 44px; }
.st-tech .blk-badge { background: #38bdf8; color: #0f172a; }

/* 10 森系自然 */
.st-botanical { background: linear-gradient(160deg, #eef6ec, #dcefe0); color: #2f4a37; }
.st-botanical .deco { color: #4a7c59; }
.st-botanical .deco-leaf-l { top: 16px; left: 16px; width: 60px; height: 60px; }
.st-botanical .deco-leaf-r { bottom: 16px; right: 16px; width: 60px; height: 60px; transform: rotate(180deg); }
.st-botanical .blk-badge { background: #4a7c59; color: #eef6ec; }
.st-botanical .blk-meta b { color: #4a7c59; }

/* ============================================================
 * 编辑面板
 * ============================================================ */
.editor-pane { background: var(--panel); border-left: 1px solid var(--line); padding: 18px 16px 40px; overflow-y: auto; max-height: calc(100vh - 55px); }
.editor-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.editor-head .eh-row { display: flex; align-items: center; justify-content: space-between; }
.editor-head #currentTplName { font-weight: 700; font-size: 15px; }
.editor-head .eh-sub { font-size: 12px; color: var(--muted); }
.editor-head .eh-links { display: flex; gap: 12px; }
.editor-fields { display: flex; flex-direction: column; gap: 12px; }
.editor-section { margin-top: 22px; border-top: 1px dashed var(--line); padding-top: 16px; }
.editor-section h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.section-tip { font-size: 12px; color: var(--muted); line-height: 1.6; margin: -4px 0 12px; }
.inline-links { display: flex; gap: 14px; margin-top: 4px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; color: var(--muted); }
.field input[type="text"], .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 14px; font-family: inherit; color: var(--ink); background: #fff; resize: vertical; }
.field input[type="text"]:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.field textarea { min-height: 64px; line-height: 1.5; }
.field input[type="file"] { font-size: 13px; color: var(--muted); }
.select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 14px; font-family: inherit; color: var(--ink); background: #fff; }
.select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.link-btn { background: none; border: none; color: var(--brand); font-size: 13px; padding: 4px 0; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 11px; font-size: 14px; font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,.04); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; color: var(--muted); }

/* ---------- Toast / Modal ---------- */
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px); background: rgba(17,24,39,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 22px; max-width: 420px; width: 100%; }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal-tip { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0 0 14px; }
.share-url { width: 100%; height: 76px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12px; font-family: monospace; resize: none; color: var(--ink); word-break: break-all; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-pane { border-left: none; border-top: 1px solid var(--line); max-height: none; }
  .preview-pane { padding-top: 18px; }
}
