/* 封面工坊 —— 苹果简约浅色大厂风（沿用舰队 tokens：大留白 / 黑白灰骨架 / 克制蓝 #2563eb）
   系统字体栈，不链任何外部字体；圆角 8/12/16 三档；发丝线边框；单层极淡阴影。
   全站零广告：不接任何广告 SDK，不留广告位。 */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-muted: #f2f2f0;
  --text: #111111;
  --text-2: #555555;
  --text-3: #6e6e6e;
  --border: rgba(17, 17, 17, 0.10);
  --accent: #2563eb;
  --accent-soft: #eaf1fe;
  --accent-text: #1d4ed8;
  --good: #127a37;
  --good-soft: #e8f5ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;
  --shadow: 0 1px 2px rgba(17, 17, 17, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --num: -apple-system, BlinkMacSystemFont, "SF Mono", ui-monospace, "PingFang SC", sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.6; overflow-x: hidden; }
a { color: var(--accent-text); text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); font-size: 16px; }
img, canvas { max-width: 100%; }

/* ---------- 顶栏 ---------- */
/* M4②：顶栏必须不透明——半透明底滚动时会透出下层文案鬼影；再加 isolation 做层级隔离。 */
.topbar { position: sticky; top: 0; z-index: 30; background: #f7f7f5; isolation: isolate; border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1024px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.brand-tag { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.user-chip { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.lang-btn, .login-link { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 7px 14px; font-size: 14px; line-height: 1.2; white-space: nowrap; }
.lang-btn:hover, .login-link:hover { background: var(--surface-muted); }
.zero-ads-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--good-soft); color: var(--good); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.zero-ads-badge svg { width: 14px; height: 14px; }

/* ---------- 布局 ---------- */
.page { max-width: 1024px; margin: 0 auto; padding: 32px 20px 120px; }
.view { display: none; }
.view.active { display: block; animation: fadeUp 220ms var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view.active { animation: none; } * { transition: none !important; } }
.section { margin-top: 40px; }
.section-head { margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.section-head p { margin: 6px 0 0; color: var(--text-2); font-size: 15px; }
.kicker { font-size: 13px; color: var(--text-3); margin: 0 0 8px; }
.hero-title { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.lead { color: var(--text-2); font-size: 16px; margin: 12px 0 0; max-width: 720px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow); }
.card-pad { padding: 24px; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
.demo-note { margin-top: 16px; padding: 10px 14px; border-radius: var(--radius-m); background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.demo-tag { display: inline-block; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 500; border-radius: 999px; padding: 2px 9px; margin-left: 8px; vertical-align: middle; }
.form-msg { margin-top: 12px; font-size: 14px; color: var(--text-2); min-height: 20px; }
.form-msg.ok { color: var(--good); }
.form-msg.err { color: var(--bad); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 6px; }
.field input, .field textarea, .field select { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); }
.field textarea { padding: 12px 14px; resize: vertical; }
.field input[type="color"] { padding: 4px; height: 48px; cursor: pointer; border: 1px solid rgba(17, 17, 17, 0.45); border-radius: var(--radius-s); background: #ffffff; }
/* M4③：颜色值可读——input 旁并排显示十六进制值，配可见边框，白底上也不空白。 */
.color-field { display: flex; gap: 10px; align-items: center; }
.color-field input[type="color"] { flex: none; width: 76px; }
.color-value { font-family: var(--num); font-size: 14px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: 0.02em; }
.field input[type="range"] { padding: 0; accent-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.btn-primary { min-height: 48px; padding: 0 22px; border: none; border-radius: 999px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 500; white-space: nowrap; transition: background 150ms var(--ease); }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #9aa7bd; cursor: not-allowed; }
.btn-ghost { min-height: 48px; padding: 0 22px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 15px; font-weight: 500; white-space: nowrap; }
.btn-ghost:hover { background: var(--surface-muted); }
.btn-ghost:disabled { color: var(--text-3); cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 16px; font-size: 14px; }
.chip:hover { background: var(--surface-muted); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.notice { border-radius: var(--radius-m); padding: 14px 16px; font-size: 14px; margin-top: 16px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--accent-soft); color: var(--accent-text); }
.notice.muted-box { background: var(--surface-muted); color: var(--text-2); }
.quota-line { font-size: 14px; color: var(--text-2); margin-top: 12px; }

/* ---------- 生成页 ---------- */
.video-meta { margin-top: 16px; display: none; }
.video-meta.show { display: block; }
.video-meta .row-line { display: flex; gap: 8px; font-size: 15px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.video-meta .row-line:last-child { border-bottom: none; }
.video-meta .k { flex: none; width: 76px; color: var(--text-3); font-size: 14px; }
.video-meta .v { min-width: 0; overflow-wrap: anywhere; }
.video-meta img { display: block; width: 100%; max-width: 320px; border-radius: var(--radius-m); margin-top: 8px; }
.ai-gen-box { margin-top: 16px; padding: 18px 20px; border: 1px dashed var(--border); border-radius: var(--radius-m); background: var(--surface-muted); }
.ai-gen-box .btn-primary:disabled { background: #9aa7bd; }
.ai-gen-note { font-size: 14px; color: var(--text-2); margin: 10px 0 0; }
.tpl-pick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.tpl-card { overflow: hidden; cursor: pointer; text-align: left; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow); }
.tpl-card:hover { border-color: var(--accent); }
.tpl-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tpl-card canvas { display: block; width: 100%; height: auto; }
.tpl-card .tpl-body { padding: 12px 14px 14px; }
/* M4①：模板名/公式允许换行、任意处断词，标题完整可读，绝不在右缘截断。 */
.tpl-card h3 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; word-break: break-word; }
.tpl-card p { margin: 4px 0 0; font-size: 13px; color: var(--text-2); line-height: 1.5; overflow-wrap: anywhere; word-break: break-word; }

/* ---------- 编辑器 ---------- */
.editor-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; align-items: start; margin-top: 16px; }
.canvas-wrap { position: sticky; top: 76px; }
.canvas-frame { border-radius: var(--radius-l); overflow: hidden; border: 1px solid var(--border); background: #111; }
.canvas-frame canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: grab; }
.canvas-frame canvas:active { cursor: grabbing; }
.editor-panel .field-row { grid-template-columns: 1fr 1fr; }
.sticker-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sticker-row { display: flex; align-items: center; gap: 8px; font-size: 14px; background: var(--surface-muted); border-radius: var(--radius-s); padding: 8px 12px; }
.sticker-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sticker-row button { border: none; background: none; color: var(--bad); font-size: 13px; padding: 4px 6px; }
.hidden-canvas { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- 评分 ---------- */
.score-panel { padding: 28px; display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.score-num { font-family: var(--num); font-size: 72px; font-weight: 600; line-height: 1; letter-spacing: -0.03em; }
.score-unit { font-size: 20px; color: var(--text-3); font-weight: 400; }
.grade-chip { display: inline-block; margin-top: 10px; border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 500; background: var(--accent-soft); color: var(--accent-text); }
.grade-chip[data-grade="优秀"], .grade-chip[data-grade="Excellent"] { background: var(--good-soft); color: var(--good); }
.grade-chip[data-grade="建议重做"], .grade-chip[data-grade="Recommend rework"] { background: var(--bad-soft); color: var(--bad); }
.score-side { flex: 1; min-width: 220px; }
.verdict { margin: 0; font-size: 17px; font-weight: 600; }
.issue-summary { margin: 6px 0 0; color: var(--text-2); font-size: 15px; }
.metric-list { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.metric-row { border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.metric-row:last-child { border-bottom: none; padding-bottom: 0; }
.metric-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.metric-label { font-weight: 600; font-size: 15px; }
.metric-value { flex: 1; font-size: 13px; color: var(--text-2); min-width: 140px; }
.metric-score { font-family: var(--num); font-size: 20px; font-weight: 600; }
.metric-score.st-good { color: var(--good); }
.metric-score.st-warn { color: var(--warn); }
.metric-score.st-bad { color: var(--bad); }
.metric-bar { height: 8px; border-radius: 999px; background: var(--surface-muted); overflow: hidden; margin-top: 8px; }
.metric-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.metric-fill.st-good { background: var(--good); }
.metric-fill.st-warn { background: var(--warn); }
.metric-fill.st-bad { background: var(--bad); }
.metric-advice { margin: 8px 0 0; font-size: 14px; color: var(--text-2); }
.metric-fix { margin-top: 10px; }
.diag-canvas-wrap { border-radius: var(--radius-m); overflow: hidden; border: 1px solid var(--border); }
.diag-canvas-wrap canvas { display: block; width: 100%; height: auto; }
.issue-list { margin: 16px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.issue-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.issue-badge { flex: none; width: 22px; height: 22px; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.issue-tag { flex: none; font-weight: 600; }
.no-issue { color: var(--good); font-size: 14px; }
.advice-lang-note { font-size: 13px; color: var(--text-3); margin-top: 12px; }

/* ---------- 我的 ---------- */
.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.price-card { padding: 24px; display: flex; flex-direction: column; }
.price-card.featured { border-color: var(--accent); }
.price-card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.price-amount { font-family: var(--num); font-size: 32px; font-weight: 600; letter-spacing: -0.02em; margin: 10px 0 4px; }
.price-card ul { margin: 14px 0 0; padding: 0; list-style: none; flex: 1; }
.price-card li { font-size: 14px; color: var(--text-2); padding: 5px 0 5px 20px; position: relative; }
.price-card li::before { content: ""; position: absolute; left: 0; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: 0.55; }
.price-note { margin-top: 14px; font-size: 13px; color: var(--text-3); }
.redeem-row { display: flex; gap: 12px; }
.redeem-row input { flex: 1; min-height: 48px; padding: 0 14px; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); }
.order-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; flex-wrap: wrap; }
.order-row:last-child { border-bottom: none; }
.order-row .o-no { font-family: var(--num); font-weight: 600; }
.order-row .o-status { margin-left: auto; color: var(--text-2); }
.face-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.face-card { overflow: hidden; }
.face-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.face-card .face-body { padding: 12px 14px; }
.face-card .face-body p { margin: 0 0 8px; font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.me-list .row { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.me-list .row:last-child { border-bottom: none; }
.me-list .row .t { font-weight: 500; }
.me-list .row .s { margin-left: auto; color: var(--text-3); font-size: 14px; }
.me-list a.row { color: var(--text); display: flex; }
.me-list a.row:hover { background: var(--surface-muted); }

/* ---------- 登录 / 关于 ---------- */
.narrow { max-width: 560px; margin: 0 auto; }
.auth-card { padding: 32px 28px; }
.auth-card h1 { margin: 0; font-size: 24px; font-weight: 600; }
.auth-card .sub { color: var(--text-2); margin: 8px 0 24px; font-size: 15px; }
.code-row { display: flex; gap: 12px; }
.code-row input { flex: 1; min-width: 0; }
.about-body p { color: var(--text-2); font-size: 16px; }
.about-body .lead { color: var(--text); font-size: 19px; line-height: 1.5; }

/* ---------- 底栏导航 ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255, 255, 255, 0.94); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0); }
.tabbar-inner { max-width: 1024px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 10px; background: none; border: none; color: var(--text-3); font-size: 11px; min-height: 56px; }
.tab svg { width: 22px; height: 22px; stroke: currentColor; }
.tab.active { color: var(--accent-text); }
.tab:hover { color: var(--text); }
.footer { text-align: center; color: var(--text-3); font-size: 13px; padding: 8px 0 24px; }
.toast { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(8px); background: var(--text); color: #fff; border-radius: 999px; padding: 10px 18px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 180ms var(--ease), transform 180ms var(--ease); z-index: 40; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 断点 ---------- */
@media (max-width: 834px) {
  .editor-grid { grid-template-columns: 1fr; }
  .canvas-wrap { position: static; }
  .tpl-pick-grid { grid-template-columns: 1fr 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .face-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .page { padding: 24px 16px 112px; }
  .topbar-inner { padding: 10px 16px; }
  .brand-tag { display: none; }
  .hero-title { font-size: 26px; }
}
@media (max-width: 390px) {
  body { font-size: 15px; }
  .page { padding: 20px 14px 108px; }
  .hero-title { font-size: 24px; }
  .tpl-pick-grid { grid-template-columns: 1fr; }
  .face-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .editor-panel .field-row { grid-template-columns: 1fr; }
  .redeem-row { flex-direction: column; }
  .redeem-row .btn-primary { width: 100%; }
  .score-panel { padding: 20px; }
  .score-num { font-size: 56px; }
  .zero-ads-badge { display: none; }
  .user-chip { display: none; }
  .btn-row .btn-primary, .btn-row .btn-ghost { flex: 1 1 100%; }
}
@media (max-width: 320px) {
  .brand-name { font-size: 16px; }
  .score-num { font-size: 48px; }
}
