:root {
  --primary: #1A56DB;
  --gold: #D4AF37;
  --primary-dark: #1E429F;
  --accent: #1E429F;
  --warn: #F59E0B;
  --bg: #F3F4F6;
  --card: #FFFFFF;
  --text: #111827;
  --text-dim: #6B7280;
  --border: #E5E7EB;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(17, 24, 39, 0.08);
  --bottom-nav-h: 56px;
  --contact-footer-h: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
body { background: linear-gradient(180deg, var(--scene-bg) 0%, var(--bg) 220px); }

.page-root { padding: 16px 16px calc(var(--bottom-nav-h) + var(--contact-footer-h) + 24px); max-width: 960px; margin: 0 auto; }

.hero { text-align: center; padding: 28px 12px 20px; }
.hero.compact { padding: 16px 12px; }
.hero-eyebrow { font-size: 13px; color: var(--primary); margin-bottom: 8px; font-weight: 600; }
.hero h1 { font-size: 22px; font-weight: 700; color: var(--primary); line-height: 1.35; margin-bottom: 8px; }
.subtitle { font-size: 14px; color: var(--text-dim); }
.stat-row { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.stat-pill { background: var(--card); border-radius: var(--radius); padding: 12px 16px; min-width: 88px; box-shadow: var(--shadow); border-top: 3px solid var(--primary); }
.stat-pill strong { display: block; font-size: 20px; color: var(--primary); }
.stat-pill small { font-size: 11px; color: var(--text-dim); }
.stat-pill.accent { border-top-color: var(--accent); }
.stat-pill.accent strong { color: var(--accent); }
.stat-pill.gold { border-top-color: var(--gold); }
.stat-pill.gold strong { color: var(--gold); }

.card-panel { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card-panel h2, .card-panel h3 { font-size: 15px; margin-bottom: 12px; }
.hint, .p-desc { font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }

.scene-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.scene-chips.compact { margin: 0 0 12px; }
.scene-chip {
  border: 1px solid var(--border); background: var(--bg); border-radius: 20px;
  padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--text); transition: all 0.2s;
}
.scene-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.scene-hint { margin-top: 10px; font-size: 12px; color: var(--gold); font-weight: 500; }

.search-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 16px; margin-top: 8px; background: var(--bg);
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12); }
.result-count { margin: 10px 0; }

.tpl-grid { display: grid; gap: 10px; }
.tpl-card {
  border: 1px solid var(--border); background: var(--card); border-radius: var(--radius);
  padding: 14px; text-align: left; cursor: pointer; box-shadow: var(--shadow); width: 100%;
}
.tpl-card:active { border-color: var(--primary); transform: scale(0.99); }
.tpl-scene { font-size: 11px; color: var(--text-dim); display: block; margin-bottom: 4px; }
.tpl-card strong { display: block; font-size: 15px; color: var(--primary); margin-bottom: 4px; }
.tpl-card small { font-size: 12px; color: var(--text-dim); display: block; line-height: 1.4; }
.tpl-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tpl-tags em { font-style: normal; font-size: 10px; background: rgba(26, 86, 219, 0.08); color: var(--primary); padding: 2px 8px; border-radius: 10px; }

.guide-steps { list-style: none; counter-reset: step; }
.guide-steps li { display: flex; flex-direction: column; padding: 12px 0; border-bottom: 1px solid var(--border); counter-increment: step; }
.guide-steps li:last-child { border-bottom: none; }
.guide-steps li strong { font-size: 14px; color: var(--primary); }
.guide-steps li strong::before { content: counter(step) '. '; color: var(--gold); }
.guide-steps li span { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.sub-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-top: 4px; }
.sub-header h2 { font-size: 17px; flex: 1; }
.sub-back { border: none; background: var(--card); border-radius: 8px; padding: 8px 12px; font-size: 14px; cursor: pointer; box-shadow: var(--shadow); }

.form-root { display: grid; gap: 14px; margin: 16px 0; }
.form-field { display: block; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-label .req { color: var(--warn); font-style: normal; }
.form-field input, .form-field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; font-family: inherit;
}
.form-field input:focus, .form-field textarea:focus { outline: none; border-color: var(--primary); }

.contract-preview {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 20px 16px;
  font-size: 14px; line-height: 1.85; color: #1f2937; text-align: left; white-space: normal;
}
.preview-panel { padding: 0; overflow: hidden; }
.preview-actions { display: grid; gap: 10px; margin-bottom: 14px; }

.btn-primary, .btn-outline {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; border: none; text-decoration: none;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.btn-outline { background: var(--card); color: var(--primary); border: 1px solid var(--primary); }
.btn-full { width: 100%; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; text-decoration: underline; }

.mine-stats { list-style: none; }
.mine-stats li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.mine-stats strong { color: var(--primary); }

.disclaimer-inline { font-size: 11px; color: var(--text-dim); text-align: center; padding: 8px 16px 16px; line-height: 1.5; }
.empty-tip { text-align: center; padding: 32px 16px; color: var(--text-dim); font-size: 14px; }

.bottom-nav {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--contact-footer-h) + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto; display: flex; height: var(--bottom-nav-h);
  background: var(--card); border-top: 1px solid var(--border); z-index: 50;
}
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px; font-size: 10px; color: var(--text-dim); background: none; border: none; cursor: pointer; }
.nav-item.active { color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 20px; margin-bottom: 2px; }

.toast {
  position: fixed; left: 50%;
  bottom: calc(var(--bottom-nav-h) + var(--contact-footer-h) + 16px);
  transform: translateX(-50%);
  background: rgba(17,24,39,0.92); color: #fff; padding: 10px 20px; border-radius: 20px;
  font-size: 14px; z-index: 200; white-space: nowrap;
}
.toast.hidden { display: none; }

.contact-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto;
}
.contact-footer__btns { display: flex; gap: 8px; }
.contact-footer__cta { flex: 1; text-align: center; background: var(--primary); color: #fff !important; padding: 10px; border-radius: 999px; font-size: 13px; font-weight: 600; text-decoration: none; }
.contact-footer__btn { flex: 1; text-align: center; background: var(--bg); padding: 10px; border-radius: 999px; font-size: 13px; border: 0; cursor: pointer; text-decoration: none; color: inherit; }
.contact-footer__brand { margin: 6px 0 0; text-align: center; font-size: 10px; color: var(--text-dim); }

.share-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px calc(24px + var(--contact-footer-h)); }
.share-card { background: var(--card); border-radius: 16px; padding: 28px 24px 32px; text-align: center; max-width: 400px; width: 100%; box-shadow: var(--shadow); }
.share-eyebrow { color: var(--primary); font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.share-card h1 { font-size: 24px; margin-bottom: 8px; color: var(--primary); }
.share-desc { color: var(--text-dim); margin-bottom: 16px; font-size: 14px; line-height: 1.6; }
.share-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 16px 0 8px; }
.share-stats div { background: var(--bg); padding: 12px 8px; border-radius: 10px; }
.share-stats strong { display: block; font-size: 20px; color: var(--primary); margin-bottom: 4px; }
.share-stats span { font-size: 11px; color: var(--text-dim); }
#shareQr { display: block; margin: 12px auto 4px; border-radius: 8px; max-width: 200px; }
.share-qr-hint { font-size: 12px; color: var(--text-dim); margin-bottom: 16px; }
.share-card .btn-full { display: block; width: 100%; margin-top: 10px; text-align: center; text-decoration: none; }
.share-card button.btn-outline { font-family: inherit; }
.share-entry { display: block; text-align: center; text-decoration: none; margin-top: 12px; }

/* P1 · 收藏 / 草稿 / 弹窗 */
.tpl-card-wrap { position: relative; }
.fav-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 32px; height: 32px; border: none; border-radius: 50%;
  background: rgba(255,255,255,0.95); box-shadow: var(--shadow);
  font-size: 16px; color: var(--text-dim); cursor: pointer; line-height: 32px;
}
.fav-btn.on, .icon-btn.on { color: var(--gold); }
.icon-btn {
  border: none; background: var(--card); border-radius: 8px;
  width: 36px; height: 36px; font-size: 18px; cursor: pointer; box-shadow: var(--shadow); flex-shrink: 0;
}
.sub-header h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.draft-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.draft-banner p { margin: 0; font-size: 14px; }
.badge { font-size: 11px; background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 10px; margin-left: 6px; font-weight: 600; }

.draft-list, .history-list { list-style: none; }
.draft-item { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.draft-item__main {
  flex: 1; text-align: left; border: none; background: none; padding: 12px 0; cursor: pointer;
}
.draft-item__main strong { display: block; font-size: 14px; color: var(--primary); }
.draft-item__main small { font-size: 11px; color: var(--text-dim); }
.draft-item__del {
  border: none; background: none; color: var(--warn); font-size: 12px; cursor: pointer; padding: 8px;
}
.history-list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.history-list small { color: var(--text-dim); }

.modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.modal__mask { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal__sheet {
  position: relative; width: 100%; max-width: 480px; max-height: 85vh; overflow: auto;
  background: var(--card); border-radius: 16px 16px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  z-index: 1;
}
.modal__sheet h2 { font-size: 17px; margin-bottom: 12px; }
.modal__text { font-size: 13px; line-height: 1.7; color: var(--text-dim); white-space: pre-wrap; margin-bottom: 16px; max-height: 50vh; overflow: auto; }
.modal__link { display: block; text-align: center; margin-top: 12px; width: 100%; }
.modal__close { position: absolute; top: 12px; right: 16px; border: none; background: none; font-size: 28px; cursor: pointer; color: var(--text-dim); line-height: 1; }
.modal__sheet--share { text-align: center; }
#sharePoster { max-width: 100%; height: auto; border-radius: 12px; margin: 12px 0; box-shadow: var(--shadow); }
.disclaimer-inline .link-btn { font-size: 11px; margin-left: 4px; }

@media (min-width: 640px) {
  .tpl-grid { grid-template-columns: 1fr 1fr; }
}
