/* ============================================================
   祝福工坊 · 设计令牌与样式系统 v2
   层级：原始值层 → 语义层 → 组件层（组件只引用语义层）
   说明：仅改视觉，不改 HTML 结构与交互逻辑；旧变量保留别名以兼容模板。
   ============================================================ */

:root {
  /* ---------- 原始值：品牌色阶 ---------- */
  --coral-50:  #fff1ef;
  --coral-100: #ffe2de;
  --coral-200: #ffc9c1;
  --coral-400: #ff7f72;
  --coral-500: #f4615a;
  --coral-600: #d63f3f; /* 白底 4.51:1，正文可用 */
  --coral-700: #b93232;
  --peach-500: #ff8a5c;
  --amber-100: #fff2d9;
  --amber-500: #ffb545;
  --amber-700: #a56a00;
  --mint-500:  #2f9e7a;
  --mint-700:  #1f7459;
  --night-900: #141a3a;

  /* ---------- 原始值：中性色阶 ---------- */
  --neutral-0:   #ffffff;
  --neutral-25:  #fffdfb;
  --neutral-50:  #fffaf5;
  --neutral-100: #fff6ec;
  --neutral-200: #f7efe8;
  --neutral-300: #f1e3d7;
  --neutral-400: #e3cfbe;
  --neutral-500: #6f635c; /* 白底 6.07:1 */
  --neutral-600: #4d423b; /* 白底 9.4:1 */
  --neutral-700: #241c18; /* 白底 15.8:1 */

  /* ---------- 语义层：颜色 ---------- */
  --color-bg:              var(--neutral-50);
  --color-surface:         var(--neutral-0);
  --color-surface-soft:    var(--neutral-25);
  --color-surface-muted:   var(--neutral-200);
  --color-text:            var(--neutral-700);
  --color-text-secondary:  var(--neutral-600);
  --color-text-muted:      var(--neutral-500);
  --color-primary:         var(--coral-600);
  --color-primary-hover:   var(--coral-700);
  --color-primary-active:  #9e2727;
  --color-primary-ink:     var(--coral-700); /* 浅色底上的主色文字：5.35:1 */
  --color-primary-soft:    var(--coral-50);
  --color-primary-glow:    var(--coral-500);
  --color-border:          var(--neutral-300);
  --color-border-strong:   var(--neutral-400);
  --color-focus:           var(--coral-600);
  --color-success:         var(--mint-700);
  --color-warning:         #8a5600; /* 浅黄底 5.56:1 */
  --color-error:           #c0392b;

  /* ---------- 语义层：主题化装饰 ---------- */
  --hero-bg:       linear-gradient(180deg, #fff3e5 0%, var(--color-bg) 100%);
  --hero-glow-a:   rgba(255, 181, 69, 0.30);
  --hero-glow-b:   rgba(244, 97, 90, 0.20);
  --tpl-shade:     linear-gradient(180deg, transparent 38%, rgba(0, 0, 0, 0.46));
  --stage-bg:      #1a1a22;

  /* ---------- 兼容别名（旧模板引用） ---------- */
  --ink: var(--color-text);
  --ink-soft: var(--color-text-secondary);
  --muted: var(--color-text-muted);
  --paper: var(--color-bg);
  --card: var(--color-surface);
  --line: var(--color-border);
  --brand: var(--color-primary);
  --brand-dark: var(--coral-700);
  --sun: var(--amber-500);
  --mint: var(--mint-500);
  --night: var(--night-900);
  --radius: 18px;

  /* ---------- 字体 ---------- */
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;

  /* ---------- 间距（4px 基准） ---------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ---------- 圆角 / 阴影 / 动效 ---------- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(36, 28, 24, 0.06);
  --shadow-md: 0 10px 24px -16px rgba(89, 52, 30, 0.38);
  --shadow-lg: 0 24px 56px -30px rgba(89, 52, 30, 0.52);
  --shadow-brand: 0 12px 28px -14px rgba(214, 63, 63, 0.62);
  --shadow-focus: 0 0 0 3px rgba(214, 63, 63, 0.28);
  --dur-fast: 150ms;
  --dur-normal: 240ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ============================================================
   基础
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.28; margin: 0; letter-spacing: -0.02em; font-weight: 700; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.25em; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }

::selection { background: var(--coral-100); color: var(--coral-700); }

/* 键盘焦点：全站统一 2px 描边 + 2px 偏移 */
:where(a, button, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 var(--space-6); }
.muted { color: var(--color-text-muted); }
.hint { font-size: var(--text-sm); }

/* ============================================================
   顶栏
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(1.5) blur(10px);
  background: rgba(255, 250, 245, 0.88); /* 不支持 color-mix 的浏览器回退 */
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  border-bottom: 1px solid var(--color-border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--peach-500), var(--coral-500));
  color: #fff;
  font-size: 17px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 16px -6px rgba(244, 97, 90, 0.85);
}

.nav { display: flex; align-items: center; gap: var(--space-6); font-size: 15px; }
.nav a { position: relative; color: var(--color-text-secondary); transition: color var(--dur-fast) var(--ease); }
.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%; bottom: -4px;
  height: 2px;
  border-radius: 2px;
  background: var(--color-primary);
  transition: right var(--dur-normal) var(--ease);
}
.nav a:hover { color: var(--color-primary); }
.nav a:hover::after { right: 0; }

/* ============================================================
   Hero
   ============================================================ */

.hero {
  position: relative;
  overflow: hidden;
  padding: var(--space-16) 0 var(--space-12);
  background: var(--hero-bg);
  border-bottom: 1px solid var(--color-border);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.hero::before {
  width: 480px; height: 480px;
  right: -140px; top: -260px;
  background: radial-gradient(circle, var(--hero-glow-b), transparent 68%);
}
.hero::after {
  width: 380px; height: 380px;
  left: -150px; bottom: -260px;
  background: radial-gradient(circle, var(--hero-glow-a), transparent 70%);
}
.hero > .wrap { position: relative; z-index: 1; }

.eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--color-primary-ink);
  background: var(--color-surface);
  border: 1px solid var(--coral-100);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-4);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.hero h1 {
  font-size: clamp(32px, 5.2vw, 56px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.22;
  margin-bottom: var(--space-5);
  max-width: 760px;
}

.hero .lead {
  max-width: 640px;
  font-size: clamp(16px, 2vw, 19px);
  color: var(--color-text-secondary);
  line-height: 1.8;
}

.actions { display: flex; flex-wrap: wrap; gap: var(--space-4); margin: var(--space-8) 0 var(--space-4); }

/* ============================================================
   按钮
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 48px;
  padding: 0 var(--space-6);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--color-text);
  color: var(--color-surface);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
  user-select: none;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.btn-red {
  background: var(--color-primary);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), var(--shadow-brand);
}
.btn-red:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-red:active:not(:disabled) { background: var(--color-primary-active); }

.btn-ghost {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover:not(:disabled) { background: var(--color-surface-muted); border-color: var(--color-border-strong); }

.btn-sm { height: 40px; padding: 0 var(--space-5); font-size: var(--text-sm); }
.btn-block { width: 100%; }
.btn--icon { width: 44px; height: 44px; padding: 0; }

/* ============================================================
   区块与卡片
   ============================================================ */

.section { padding: var(--space-12) 0; }

.section-title {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 750;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.section-title::before {
  content: "";
  width: 4px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--peach-500), var(--color-primary));
}
.section-sub { color: var(--color-text-muted); margin: 0 0 var(--space-8) calc(4px + var(--space-3)); font-size: var(--text-base); }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--space-5); }

.feature {
  position: relative;
  padding: var(--space-6) var(--space-5);
  overflow: hidden;
  transition: transform var(--dur-normal) var(--ease), box-shadow var(--dur-normal) var(--ease), border-color var(--dur-normal) var(--ease);
}
.feature::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--peach-500), var(--color-primary));
  opacity: 0.85;
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--coral-200); }

.feature .num { font-size: 13px; font-weight: 700; color: var(--color-primary); letter-spacing: 0.12em; margin-bottom: var(--space-2); }
.feature h3 { font-size: 19px; margin-bottom: var(--space-2); }
.feature p { color: var(--color-text-muted); font-size: var(--text-sm); line-height: 1.75; }

.steps { display: grid; gap: var(--space-4); counter-reset: step; }
.step {
  position: relative;
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  padding: var(--space-5) var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.step::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--coral-50);
  border: 1px solid var(--coral-100);
  color: var(--color-primary);
  font-weight: 700;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.step strong { display: block; font-size: var(--text-base); margin-bottom: var(--space-1); }
.step .muted { font-size: var(--text-sm); }

/* ============================================================
   模板画廊
   ============================================================ */

.templates { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--space-5); }

.tpl {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 9 / 14;
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-5);
  color: #fff;
  isolation: isolate;
  box-shadow: var(--shadow-md);
  transition: transform var(--dur-normal) var(--ease), box-shadow var(--dur-normal) var(--ease);
}
.tpl:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.tpl::before {
  content: "";
  position: absolute;
  width: 78%; aspect-ratio: 1;
  top: -22%; right: -28%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.38), transparent 70%);
  z-index: -1;
}
.tpl::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tpl-shade);
  z-index: -1;
}

.tpl-heart { background: linear-gradient(160deg, #ffe0b8, #ff9f7a 58%, #f4615a); }
.tpl-night { background: linear-gradient(160deg, #39417a, #1e264f 58%, #0b1030); }
.tpl-mint  { background: linear-gradient(160deg, #d8f3e6, #8ed3b9 55%, #2f9e7a); }

.tpl-name { font-size: var(--text-xl); font-weight: 700; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.3); }
.tpl-sub { font-size: 13px; opacity: 0.92; margin-bottom: var(--space-1); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.25); }

/* ============================================================
   定价 / 常见问题 / 页脚
   ============================================================ */

.price-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-8);
  background: linear-gradient(135deg, var(--color-surface), var(--neutral-100));
  position: relative;
  overflow: hidden;
}
.price-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--amber-500), var(--color-primary));
}
.price-card h3 { font-size: var(--text-2xl); margin-bottom: var(--space-3); }
.price-card ul { color: var(--color-text-secondary); font-size: var(--text-sm); display: grid; gap: var(--space-2); }
.price-card li::marker { color: var(--color-primary); }

.faq { display: grid; border-top: 1px solid var(--color-border); }
.faq-item { padding: var(--space-5) 0 var(--space-5) var(--space-6); border-bottom: 1px solid var(--color-border); position: relative; }
.faq-item::before {
  content: "Q";
  position: absolute;
  left: 0; top: calc(var(--space-5) + 2px);
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--coral-50);
  color: var(--color-primary-ink);
  font-size: 12px;
  font-weight: 700;
}
.faq-item h3 { font-size: 17px; margin-bottom: var(--space-2); }
.faq-item p { color: var(--color-text-muted); font-size: var(--text-sm); max-width: 760px; line-height: 1.8; }

.footer { margin-top: var(--space-10); padding: var(--space-8) 0 var(--space-12); border-top: 1px solid var(--color-border); color: var(--color-text-muted); font-size: var(--text-sm); }
.footer p + p { margin-top: var(--space-2); }
.footer a { transition: color var(--dur-fast) var(--ease); }
.footer a:hover { color: var(--color-primary); }

/* ============================================================
   编辑器
   ============================================================ */

.editor { padding: var(--space-8) var(--space-6) var(--space-16); }

.editor-head { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-end; justify-content: space-between; margin-bottom: var(--space-6); }
.editor-head h1 { font-size: 26px; margin-bottom: var(--space-1); }
.head-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--space-6); align-items: start; }
.forms { display: grid; gap: var(--space-4); }

.block { padding: var(--space-5); }
.block h2 {
  font-size: var(--text-base);
  margin-bottom: var(--space-4);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.block h2::before { content: ""; width: 3px; height: 16px; border-radius: 3px; background: var(--color-primary); }

.field { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--color-text-secondary); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

.input, .textarea, select.input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface-soft);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-muted); }
.input:hover, .textarea:hover { border-color: var(--coral-200); }
.input:focus, .textarea:focus { background: var(--color-surface); border-color: var(--color-primary); box-shadow: var(--shadow-focus); }
.input:focus-visible, .textarea:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.input:disabled, .textarea:disabled { background: var(--color-surface-muted); color: var(--color-text-muted); cursor: not-allowed; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--color-error); }

.textarea { min-height: 96px; resize: vertical; line-height: 1.65; }

.style-dots { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.style-dot {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.style-dot:hover { border-color: var(--coral-200); background: var(--color-primary-soft); color: var(--color-text); }
.style-dot span { width: 16px; height: 16px; border-radius: 50%; background: var(--peach-500); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.style-dot[data-style="night"] span { background: #2a3164; }
.style-dot[data-style="mint"] span { background: #4fb894; }
.style-dot[data-style="funny"] span { background: var(--amber-500); }
.style-dot[data-style="formal"] span { background: #5b6b8c; }
.style-dot.on {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  box-shadow: var(--shadow-focus);
  color: var(--color-primary);
  font-weight: 600;
}

/* 模板预览卡片：直接看到配色和当前文案的效果 */
.template-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.template-card {
  position: relative;
  min-width: 0;
  display: grid;
  gap: var(--space-2);
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  text-align: left;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.template-card:hover { transform: translateY(-2px); border-color: var(--coral-200); box-shadow: var(--shadow-md); }
.template-card.on { border-color: var(--color-primary); box-shadow: var(--shadow-focus); }
.template-thumb {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 9 / 11;
  padding: var(--space-4) var(--space-3);
  border-radius: calc(var(--radius-lg) - 6px);
  overflow: hidden;
  isolation: isolate;
}
.template-thumb::before {
  content: "";
  position: absolute;
  right: -24%; bottom: -28%;
  width: 86%; aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3), transparent 70%);
  z-index: -1;
}
.template-thumb-kicker { font-size: 7px; font-weight: 600; letter-spacing: 0.18em; opacity: 0.78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-thumb-name { font-size: 15px; font-weight: 700; line-height: 1.35; word-break: break-word; }
.template-thumb-wish {
  font-size: 10px;
  line-height: 1.55;
  opacity: 0.84;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.template-meta { display: grid; gap: 1px; padding: 0 var(--space-1) var(--space-1); }
.template-meta strong { font-size: 13px; }
.template-meta span {
  font-size: 11px;
  line-height: 1.45;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.template-check {
  position: absolute;
  top: 12px; right: 12px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(36, 28, 24, 0.28);
}

.photos { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.photo-thumb { position: relative; width: 84px; height: 84px; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--color-border); background: var(--color-surface-muted); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb button {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(20, 16, 14, 0.72);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.photo-thumb button:hover { background: var(--color-error); }

.photo-add {
  width: 84px; height: 84px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--color-border-strong);
  background: var(--color-surface-soft);
  color: var(--color-text-muted);
  font-size: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: var(--space-1);
  text-align: center;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.photo-add:hover { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-primary); }
.photo-add b { font-size: 20px; color: var(--peach-500); font-weight: 400; line-height: 1; }

/* 预览列 */
.preview { position: sticky; top: 84px; display: grid; gap: var(--space-4); }
.stage-card { padding: var(--space-4); }
.stage { width: 100%; aspect-ratio: 9 / 16; border-radius: var(--radius-md); overflow: hidden; background: var(--stage-bg); position: relative; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.stage[data-ratio="16:9"] { aspect-ratio: 16 / 9; }
.stage canvas { width: 100%; height: 100%; display: block; }
.stage-badge {
  position: absolute;
  left: var(--space-2); top: var(--space-2);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(0, 0, 0, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  backdrop-filter: blur(4px);
}

.progress { height: 4px; border-radius: var(--radius-pill); background: var(--color-surface-muted); overflow: hidden; margin: var(--space-3) 0 var(--space-1); }
.progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--amber-500), var(--color-primary)); transition: width 120ms linear; }
.stage-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.stage-actions .btn { flex: 1; padding-inline: var(--space-3); }
.tip { font-size: 12px; color: var(--color-text-muted); line-height: 1.65; }

.notice {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--amber-100);
  border: 1px solid #f0dcb8;
  border-left: 3px solid var(--amber-500);
  color: var(--color-warning);
  font-size: 13px;
  line-height: 1.75;
}

.saved {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  background: linear-gradient(135deg, var(--color-surface), var(--color-primary-soft));
}
.saved code {
  display: inline-block;
  margin-top: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-secondary);
  word-break: break-all;
}
.saved-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.error, .ai-error {
  color: var(--color-error);
  background: #fdecea;
  border: 1px solid #f6cdc7;
  border-left: 3px solid var(--color-error);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.7;
  margin-bottom: var(--space-4);
}
.ai-error { font-size: 12px; padding: var(--space-2) var(--space-3); margin-bottom: 0; }

.paid-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-success);
  background: #eaf7f0;
  border: 1px solid #cfeedf;
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
}

.filelist { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.filelist a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: var(--text-sm);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.filelist a:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }

/* 模式切换 / AI 面板 */
.mode-tabs { display: flex; gap: var(--space-1); padding: var(--space-1); background: var(--color-surface-muted); border-radius: var(--radius-pill); margin-bottom: var(--space-4); }
.mode-tabs button {
  flex: 1;
  min-height: 44px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 13px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.mode-tabs button:hover { color: var(--color-text); }
.mode-tabs button.on { background: var(--color-surface); color: var(--color-text); font-weight: 600; box-shadow: var(--shadow-sm); }

/* 画幅切换 */
.ratio-switch { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.ratio-label { font-size: 12px; color: var(--color-text-muted); margin-right: 2px; }
.ratio-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  font-size: 12px;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.ratio-btn:hover { border-color: var(--coral-200); background: var(--color-primary-soft); color: var(--color-text); }
.ratio-btn.on { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-primary); box-shadow: var(--shadow-focus); font-weight: 600; }
.ratio-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ratio-shape { border: 1.5px solid currentColor; border-radius: 3px; opacity: 0.75; }
.ratio-shape.tall { width: 10px; height: 16px; }
.ratio-shape.wide { width: 16px; height: 10px; }

.ai-panel { display: grid; gap: var(--space-3); }
.ai-hero { border-radius: var(--radius-md); padding: var(--space-4); background: linear-gradient(135deg, var(--coral-50), #ffe3e8); border: 1px solid var(--coral-100); }
.ai-hero h3 { font-size: 15px; margin-bottom: var(--space-2); }
.ai-hero p { font-size: 13px; color: var(--color-text-secondary); line-height: 1.75; }
.ai-state { display: flex; justify-content: space-between; font-size: 12px; color: var(--color-text-muted); }
.ai-video { width: 100%; border-radius: var(--radius-md); background: #000; display: block; }

/* ============================================================
   分享页
   ============================================================ */

.share-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-8) var(--space-5);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 181, 69, 0.28), transparent 46%),
    radial-gradient(circle at 84% 88%, rgba(244, 97, 90, 0.22), transparent 48%),
    var(--color-bg);
}

.share-card {
  width: min(560px, 100%);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8) var(--space-8);
  text-align: center;
  color: #fff;
  box-shadow: 0 30px 70px -30px rgba(120, 60, 20, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  position: relative;
  overflow: hidden;
}
.share-card::before {
  content: "";
  position: absolute;
  width: 70%; aspect-ratio: 1;
  right: -25%; top: -30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3), transparent 70%);
  pointer-events: none;
}
/* 起点/终点均按白字 ≥4.5:1 校准（顶部小字 kicker、底部水印都落在渐变深浅两端） */
.share-card.theme-heart { background: linear-gradient(160deg, #c05038, #d64a68 55%, #cf4068); }
.share-card.theme-night { background: linear-gradient(160deg, #38407a, #1a2045 60%, #0d1230); }
.share-card.theme-mint  { background: linear-gradient(160deg, #24785e, #2a6d57 60%, #285f4e); }

.share-kicker { font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.9; margin-bottom: var(--space-5); position: relative; }
.share-card h1 { font-size: clamp(30px, 7vw, 44px); font-weight: 800; margin-bottom: var(--space-4); position: relative; }
.share-sep { width: 46px; height: 2px; background: rgba(255, 255, 255, 0.7); margin: var(--space-5) auto; border-radius: 2px; }
.share-wish { font-size: clamp(16px, 3.6vw, 19px); line-height: 1.95; white-space: pre-wrap; opacity: 0.98; position: relative; }
.share-from { margin-top: var(--space-6); font-size: var(--text-sm); opacity: 0.9; position: relative; }

.share-pay {
  margin-top: var(--space-6);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: left;
  font-size: 13px;
  line-height: 1.75;
  position: relative;
}
.share-pay strong { font-size: 15px; }
.share-pay .btn { margin-top: var(--space-3); width: 100%; background: #fff; color: #b83a52; }

.share-foot { margin-top: var(--space-5); text-align: center; font-size: 13px; color: var(--color-text-muted); position: relative; }
.share-foot a { color: var(--color-primary); }
.share-watermark { margin-top: var(--space-4); font-size: 12px; color: rgba(255, 255, 255, 0.78); letter-spacing: 0.08em; position: relative; }

/* ============================================================
   指南文章
   ============================================================ */

.article { padding: var(--space-12) 0 var(--space-5); }
.article h1 { font-size: clamp(26px, 4vw, 38px); margin-bottom: var(--space-4); }
.article h2 { font-size: 22px; margin: var(--space-8) 0 var(--space-3); }
.article h3 { font-size: 17px; margin: var(--space-6) 0 var(--space-2); }
.article p, .article li { color: var(--color-text-secondary); font-size: var(--text-base); }
.article p + p { margin-top: var(--space-3); }
.article ul, .article ol { display: grid; gap: var(--space-2); margin: var(--space-3) 0; }
.article .lede { font-size: var(--text-lg); color: var(--color-text-muted); max-width: 760px; }
.article blockquote { margin: var(--space-5) 0; padding: var(--space-4) var(--space-5); background: var(--amber-100); border-left: 3px solid var(--amber-500); border-radius: 0 var(--radius-md) var(--radius-md) 0; color: var(--color-text-secondary); }
.article .maxw { max-width: 780px; }

/* ============================================================
   场景入口
   ============================================================ */

.scene-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); counter-reset: scene; }
.scene-link {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  transition: transform var(--dur-normal) var(--ease), box-shadow var(--dur-normal) var(--ease), border-color var(--dur-normal) var(--ease);
}
.scene-link::before {
  counter-increment: scene;
  content: counter(scene, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
  opacity: 0.75;
  margin-bottom: var(--space-2);
}
.scene-link:hover { transform: translateY(-3px); border-color: var(--coral-200); box-shadow: var(--shadow-lg); }
.scene-link strong { font-size: var(--text-lg); font-weight: 600; }
.scene-link span { font-size: 13px; color: var(--color-text-muted); line-height: 1.65; }

/* ============================================================
   响应式（移动优先增强）
   ============================================================ */

@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; }
  .stage { max-width: 320px; margin: 0 auto; }
  .stage[data-ratio="16:9"] { max-width: 100%; }
  .hero { padding: var(--space-12) 0 var(--space-10); }
  .nav { gap: var(--space-4); font-size: 14px; }
  .price-card { padding: var(--space-6); }
  .scene-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 460px) {
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-meta span { display: none; }
}

@media (max-width: 560px) {
  :root { --space-12: 40px; }
  .wrap { padding: 0 var(--space-5); }
  .hero h1 { font-size: 32px; }
  .hero { padding: var(--space-10) 0 var(--space-8); }
  .actions .btn { flex: 1; }
  .row2 { grid-template-columns: 1fr; }
  .editor { padding: var(--space-5) var(--space-4) var(--space-12); }
  .editor-head h1 { font-size: 22px; }
  .saved { padding: var(--space-4); }
  .share-card { padding: var(--space-8) var(--space-5) var(--space-6); }
  .mode-tabs button { font-size: 12px; }
  .scene-links { grid-template-columns: 1fr; }
  .section-title::before { height: 24px; }
  .section-sub { margin-left: 0; }
}

/* 触摸目标：移动端保证 ≥ 44px */
@media (hover: none) {
  .btn-sm { height: 44px; }
  .photo-thumb button { width: 32px; height: 32px; }
}

/* ============================================================
   暗色主题（只覆盖语义层，原始值与组件不变）
   默认不启用；页面在 <html data-theme="dark"> 时生效
   ============================================================ */

[data-theme="dark"] {
  --color-bg: #16131a;
  --color-surface: #201c24;
  --color-surface-soft: #19161d;
  --color-surface-muted: #2b2630;
  --color-text: #f7f1ec;
  --color-text-secondary: #d8cec7;
  --color-text-muted: #b6a9a1;
  --color-primary: #ff9187;
  --color-primary-hover: #ffab9f;
  --color-primary-active: #ffc4b9;
  --color-primary-ink: #ffab9f;
  --color-primary-soft: #372128;
  --color-border: #3d3540;
  --color-border-strong: #5b505c;
  --color-focus: #ff9187;
  --color-success: #6fd6a8;
  --color-warning: #ffc766;
  --color-error: #ff9b8f;

  --hero-bg: linear-gradient(180deg, #241a22 0%, var(--color-bg) 100%);
  --hero-glow-a: rgba(255, 181, 69, 0.13);
  --hero-glow-b: rgba(255, 107, 114, 0.14);
  --stage-bg: #0d0d12;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 24px -16px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 56px -30px rgba(0, 0, 0, 0.8);
  --shadow-focus: 0 0 0 3px rgba(255, 145, 135, 0.3);

  --coral-50: #372128;
  --coral-100: #4a2a30;
  --coral-200: #63363b;
  --amber-100: #3b3022;
  --neutral-100: #26202a;
}

[data-theme="dark"] ::selection { background: #63363b; color: #fff; }
[data-theme="dark"] .topbar {
  backdrop-filter: saturate(1.2) blur(10px);
  background: rgba(22, 19, 26, 0.9);
  background: color-mix(in srgb, var(--color-bg) 90%, transparent);
}
[data-theme="dark"] .eyebrow { border-color: var(--color-border); }
[data-theme="dark"] .notice,
[data-theme="dark"] .article blockquote { border-color: var(--color-border); }
[data-theme="dark"] .notice { background: #3b3022; }
[data-theme="dark"] .error,
[data-theme="dark"] .ai-error { background: #3a2022; border-color: #63363b; }
[data-theme="dark"] .paid-tag { background: #1e3329; border-color: #2f5644; }
[data-theme="dark"] .share-foot { color: #d8cec7; }

/* ============================================================
   降低动效
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
