/* style.css — R100 主样式 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang SC", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  font-size: var(--font-size-base, 24px);
  color: var(--color-text);
  background: var(--color-surface);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: calc(var(--contact-footer-h, 72px) + env(safe-area-inset-bottom));
}
body.mode-elder { --font-size-base: 32px; --font-size-lg: 40px; --btn-height: 64px; --touch-target: 72px; }

:root {
  --font-size-base: 24px;
  --font-size-lg: 32px;
  --font-size-xl: 48px;
  --touch-target: 60px;
  --btn-height: 56px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --spacing: 16px;
  --contact-footer-h: 72px;
  --color-primary: #FF7B42;
  --color-surface: #FFF3E0;
  --color-text: #3E2723;
  --color-accent: #FFB74D;
  --color-text-secondary: #795548;
  --color-success: #2E7D32;
  --color-error: #C62828;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

[data-scheme="warm-orange"] { --color-primary:#FF7B42; --color-surface:#FFF3E0; --color-text:#3E2723; --color-accent:#FFB74D; }
[data-scheme="china-red"] { --color-primary:#D4333B; --color-surface:#FFF0F0; --color-text:#4E0000; --color-accent:#FFD700; }
[data-scheme="lavender"] { --color-primary:#7C4DFF; --color-surface:#F3E5F5; --color-text:#311B92; --color-accent:#E1BEE7; }
[data-scheme="health-green"] { --color-primary:#2E7D32; --color-surface:#E8F5E9; --color-text:#1B5E20; --color-accent:#81C784; }
[data-scheme="golden"] { --color-primary:#F9A825; --color-surface:#FFF8E1; --color-text:#4E342E; --color-accent:#FFD54F; }
[data-scheme="rose-gold"] { --color-primary:#E91E63; --color-surface:#FCE4EC; --color-text:#880E4F; --color-accent:#F48FB1; }

#app-root { min-height: 100dvh; }
.view { display: none; min-height: 100dvh; padding: var(--spacing); padding-bottom: 100px; }
.view.active { display: block; animation: view-fade-in 0.4s ease; }

.view-header { display: flex; align-items: center; gap: 12px; margin-bottom: var(--spacing); flex-wrap: wrap; }
.view-header h2 { font-size: var(--font-size-lg); flex: 1; }
.back-btn { min-height: var(--btn-height); padding: 8px 16px; border: none; background: none; font-size: 20px; font-weight: 700; cursor: pointer; color: var(--color-primary); }

.btn {
  min-height: var(--btn-height); padding: 12px 20px; border-radius: var(--radius-lg);
  font-size: var(--font-size-base); font-weight: 700; border: 2px solid var(--color-primary);
  cursor: pointer; background: var(--color-surface); color: var(--color-text);
}
.btn:active { transform: scale(0.96); }
.btn--primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn--secondary { border-color: var(--color-accent); color: var(--color-primary); }
.btn--cta { min-height: 60px; font-size: var(--font-size-lg); width: 100%; max-width: 360px; animation: btn-pulse 2s infinite; }
.btn--text { background: none; border: none; color: var(--color-primary); min-height: var(--touch-target); }
.btn--chip { font-size: 18px; padding: 10px 14px; min-height: 44px; }
.btn--option { width: 100%; margin-bottom: 10px; text-align: left; }
.btn--option.selected, .template-card.selected, .dialect-btn.selected, .blessing-option.selected { background: rgba(255,123,66,0.15); border-color: var(--color-primary); box-shadow: var(--shadow); }
.btn-block { width: 100%; margin-top: 10px; }
.btn-fab { position: fixed; right: 16px; bottom: calc(var(--contact-footer-h) + 80px); z-index: 100; border-radius: 999px; padding: 16px 24px; box-shadow: var(--shadow); }
.btn--elder { min-height: 72px; font-size: var(--font-size-lg); width: 100%; margin-bottom: 12px; }

.hero-section { text-align: center; padding: 48px 16px 32px; min-height: 80dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: linear-gradient(160deg, var(--color-surface), #fff); }
.hero-heart { font-size: 80px; line-height: 1; }
.hero-title { font-size: clamp(28px, 6vw, 40px); font-weight: 800; color: var(--color-text); max-width: 320px; }
.hero-sub { font-size: var(--font-size-base); color: var(--color-text-secondary); }
.hero-features { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.feature-chip { padding: 10px 16px; border-radius: 999px; background: #fff; border: 2px solid var(--color-primary); font-weight: 700; font-size: 18px; }

.countdown-bar { display: flex; justify-content: space-between; align-items: center; padding: 16px; background: #fff; border-radius: var(--radius-lg); margin-bottom: var(--spacing); border-left: 6px solid var(--color-primary); box-shadow: var(--shadow); }
.countdown-num { font-size: var(--font-size-lg); font-weight: 800; color: var(--color-primary); }

.family-list { display: flex; flex-direction: column; gap: 12px; }
.member-card { display: flex; gap: 14px; align-items: center; padding: 16px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); flex-wrap: wrap; }
.member-avatar { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 36px; background: var(--color-surface); flex-shrink: 0; }
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-info { flex: 1; min-width: 140px; }
.member-info h3 { font-size: var(--font-size-lg); }
.member-days { display: inline-block; margin-top: 6px; padding: 4px 10px; background: var(--color-surface); border-radius: 999px; font-weight: 700; color: var(--color-primary); font-size: 18px; }
.member-actions { display: flex; flex-direction: column; gap: 6px; width: 100%; }
@media (min-width: 480px) { .member-actions { width: auto; } }

.card { background: #fff; border-radius: var(--radius-lg); padding: var(--spacing); margin-bottom: var(--spacing); box-shadow: var(--shadow); }
.card label { display: block; margin-bottom: 12px; font-weight: 700; }
.card input, .card select, .card textarea { display: block; width: 100%; margin-top: 6px; min-height: var(--btn-height); padding: 12px; font-size: 20px; border: 2px solid var(--color-primary); border-radius: 12px; }

.template-scroll { display: flex; gap: 12px; overflow-x: auto; padding: 8px 0 16px; scroll-snap-type: x mandatory; }
.template-card { flex: 0 0 160px; min-height: 160px; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 3px solid #eee; border-radius: var(--radius-lg); background: #fff; cursor: pointer; }
.template-emoji { font-size: 48px; }
.template-name { font-size: 18px; font-weight: 700; }
.template-cat { margin: 12px 0 8px; font-size: 20px; }

.blessing-option { display: block; width: 100%; text-align: left; padding: 16px; margin-bottom: 10px; border: 2px solid #eee; border-radius: var(--radius-lg); background: #fff; font-size: 20px; cursor: pointer; }
.blessing-edit { width: 100%; margin-top: 12px; padding: 16px; font-size: 20px; border: 2px solid var(--color-primary); border-radius: var(--radius-lg); min-height: 120px; }

.dialect-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.dialect-btn { min-height: var(--touch-target); padding: 14px; border: 2px solid #eee; border-radius: var(--radius-lg); background: #fff; cursor: pointer; font-size: 20px; }

.bottom-bar-confirm { position: fixed; left: 0; right: 0; bottom: var(--contact-footer-h); background: #fff; border-top: 3px solid var(--color-primary); padding: 12px var(--spacing); z-index: 90; box-shadow: 0 -4px 20px rgba(0,0,0,0.08); }
.bottom-bar-confirm .btn { margin-top: 8px; }

.card-preview-inner, .card-preview-lg .card-preview-inner { background: linear-gradient(135deg, var(--preview-surface, var(--color-surface)), #fff); border-radius: var(--radius-lg); padding: 20px; text-align: center; border: 3px solid var(--preview-primary, var(--color-primary)); }
.card-preview-deco { font-size: 48px; }
.card-preview-photo { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; margin: 12px auto; display: block; }
.card-preview-photo--placeholder { display: flex; align-items: center; justify-content: center; background: #eee; font-size: 36px; }
.card-preview-blessing { font-size: 20px; margin: 12px 0; line-height: 1.6; }
.card-preview-lg { max-width: 400px; margin: 0 auto 20px; }

.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { display: flex; gap: 12px; align-items: flex-start; padding: 16px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); flex-wrap: wrap; }
.timeline-emoji { font-size: 36px; }
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-item { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 48px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); }

.collab-meta { margin-bottom: 12px; color: var(--color-text-secondary); }
.collab-members { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.collab-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.collab-sigs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.collab-sig { padding: 14px; border-left: 6px solid; background: #fff; border-radius: 8px; }

.elder-card { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--elder-surface, var(--color-surface)); }
.elder-envelope { font-size: 64px; margin-bottom: 16px; }
.elder-card-body { width: 100%; max-width: 480px; text-align: center; }
.elder-deco { font-size: 72px; }
.elder-photo { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; margin: 20px auto; display: block; border: 4px solid var(--elder-primary, var(--color-primary)); }
.elder-photo--ph { display: flex; align-items: center; justify-content: center; font-size: 56px; background: #fff; margin: 20px auto; }
.elder-greeting { font-size: var(--font-size-xl); font-weight: 800; line-height: 1.5; margin: 20px 0; color: var(--color-text); }
.voice-bar { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 64px; background: #fff; border-radius: var(--radius-lg); margin: 20px 0; padding: 12px; font-size: 22px; }
.elder-actions { opacity: 0; transition: opacity 0.5s; }
.elder-actions.visible { opacity: 1; }
.elder-gallery { margin-top: 32px; width: 100%; }
.elder-gallery-scroll { display: flex; gap: 12px; overflow-x: auto; padding: 8px 0; }
.elder-gallery-item { flex: 0 0 140px; padding: 16px; background: #fff; border-radius: var(--radius-lg); text-align: center; font-size: 36px; }

.family-tree-svg { width: 100%; max-width: 360px; margin: 0 auto; display: block; transition: transform 0.3s; }
.tree-node { cursor: pointer; }
.tree-node.active circle { stroke-width: 5; }
.tree-controls { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

#panel-overlay { position: fixed; inset: 0; z-index: 1000; display: none; pointer-events: none; }
#panel-overlay.is-open { display: flex; align-items: flex-end; justify-content: center; pointer-events: auto; }
.panel-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.panel-sheet { position: relative; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; background: #fff; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: 24px; z-index: 1; }
.panel-sheet h2 { margin-bottom: 16px; }
.toggle-row { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 8px; cursor: pointer; }
.toggle-row input { width: 24px; height: 24px; }

#toast-container { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 2000; width: min(92vw, 400px); pointer-events: none; }
.toast { background: rgba(26,26,26,0.92); color: #fff; padding: 14px 20px; border-radius: 12px; margin-bottom: 8px; text-align: center; font-size: 20px; }
.toast--success { background: var(--color-success); }
.toast--warn { background: var(--color-error); }
.toast.hiding { opacity: 0; transition: opacity 0.4s; }

.empty-hint { text-align: center; padding: 32px; color: var(--color-text-secondary); }
.section-label { font-size: 22px; font-weight: 700; margin: 16px 0 8px; }
.step-indicator { text-align: center; font-weight: 700; color: var(--color-primary); margin-bottom: 12px; }
.loading-ai { text-align: center; padding: 40px; font-size: 22px; color: var(--color-text-secondary); }
.create-meta { text-align: center; font-size: 22px; margin-bottom: 12px; font-weight: 700; }
.confirm-note { text-align: center; margin: 16px 0; color: var(--color-text-secondary); }

.contact-footer { position: fixed; bottom: 0; left: 0; right: 0; z-index: 120; background: #fff; border-top: 1px solid rgba(0,0,0,0.08); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.contact-footer__btns { display: flex; justify-content: center; gap: 8px; max-width: 320px; margin: 0 auto; }
.contact-footer__cta, .contact-footer__btn { flex: 1; max-width: 88px; text-align: center; padding: 8px 4px; font-size: 12px; border-radius: 8px; font-weight: 700; }
.contact-footer__cta { background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.contact-footer__btn { background: #f0f0f0; border: none; cursor: pointer; text-decoration: none; color: inherit; display: flex; align-items: center; justify-content: center; }
.contact-footer__brand { text-align: center; font-size: 10px; color: var(--color-text-secondary); margin-top: 6px; }
body.has-contact-footer .view { padding-bottom: calc(var(--contact-footer-h) + 100px); }

:focus-visible { outline: 3px dashed var(--color-primary); outline-offset: 3px; }

/* ===== P1 样式 ===== */
.hero-quick-nav { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.fest-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.fest-banner span { font-size: 40px; }
.fest-template-card { position: relative; }
.fav-btn { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: none; background: rgba(255,255,255,0.9); border-radius: 50%; font-size: 18px; cursor: pointer; z-index: 2; }
.fav-btn.is-fav { color: #F9A825; }
.fest-picker-extra { margin-bottom: 16px; }
.fest-preview { text-align: center; }

.dash-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card { background: #fff; border-radius: var(--radius-lg); padding: 16px; text-align: center; box-shadow: var(--shadow); }
.stat-num { display: block; font-size: 36px; font-weight: 800; color: var(--color-primary); }
.dash-health { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.health-ring {
  width: 88px; height: 88px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--color-primary) calc(var(--health-pct) * 1%), #eee 0);
  flex-shrink: 0;
}
.health-score { width: 68px; height: 68px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; }
.health-tips { margin-top: 8px; padding-left: 18px; font-size: 18px; color: var(--color-text-secondary); }
.cal-item { padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,0.06); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.tree-viewport { overflow: hidden; touch-action: none; margin-bottom: 8px; }
.tree-quick-panel { background: #fff; border-radius: var(--radius-lg); padding: 16px; margin-top: 12px; box-shadow: var(--shadow); }
.tree-quick-panel span { display: block; margin: 6px 0 12px; color: var(--color-text-secondary); font-size: 18px; }

.print-preview-wrap {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.5);
  overflow-y: auto; padding: 16px; display: none;
}
.print-preview-wrap.is-open { display: block; }
.print-preview-toolbar {
  position: sticky; top: 0; display: flex; gap: 8px; justify-content: center;
  padding: 12px; background: #fff; border-radius: 12px; margin-bottom: 12px; z-index: 1; flex-wrap: wrap;
}
#annual-export-wrap {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.5);
  overflow-y: auto; padding: 16px; display: none;
}
#annual-export-wrap.is-open { display: block; }
.no-screen { display: none; }
body.printing-annual .no-screen { display: block; }

/* ===== 分享页 ===== */
body.share-page { background: linear-gradient(180deg, var(--color-surface) 0%, #fff 40%); }
.share-hero { text-align: center; padding: 32px 16px 16px; }
.share-eyebrow { font-size: 14px; font-weight: 700; color: var(--color-primary); letter-spacing: 0.05em; margin-bottom: 8px; }
.share-hero h1 { font-size: clamp(26px, 5vw, 36px); font-weight: 800; margin-bottom: 8px; }
.share-subtitle { font-size: 20px; color: var(--color-text-secondary); }
.share-preview { padding: 0 16px 16px; max-width: 480px; margin: 0 auto; }
.share-card-preview {
  background: linear-gradient(160deg, var(--share-surface, var(--color-surface)), #fff);
  border: 4px solid var(--share-primary, var(--color-primary));
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.share-card-badge { font-size: 56px; margin-bottom: 12px; }
.share-card-avatar { width: 88px; height: 88px; margin: 0 auto 12px; font-size: 48px; display: flex; align-items: center; justify-content: center; }
.share-card-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid var(--share-primary, var(--color-primary)); }
.share-card-to { font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.share-card-blessing { font-size: 22px; line-height: 1.7; margin: 16px 0; text-align: left; border-left: 4px solid var(--share-primary, var(--color-primary)); padding-left: 16px; }
.share-card-from { font-size: 18px; color: var(--color-text-secondary); }
.share-card-sigs { font-size: 16px; margin-top: 10px; color: var(--color-primary); }
.share-empty { text-align: center; padding: 32px 20px; }
.share-empty-icon { font-size: 64px; margin-bottom: 12px; }
.share-actions { padding: 8px 16px 100px; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.share-actions .btn--chip { width: 100%; }
.share-poster-wrap { padding: 16px; max-width: 360px; margin: 0 auto 16px; }
.share-poster-img { width: 100%; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
