:root {
  --ink: #23262b;
  --muted: #5f636b;
  --gold: #cca240;
  --gold-dark: #7a5c12;
  --gold-tint: #faf5e6;
  --rule: #e7dfcb;
  --field: #bdb49f;
  --amber: #8a4b00;
  --red: #a32a1f;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: #fff; color: var(--ink); font: 16px/1.65 var(--sans); }
h1, h2, h3, p, ol, ul, dl, dd, fieldset { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
ol { list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold-dark); outline-offset: 2px; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.page { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px; }
.loading { padding: 48px 0; color: var(--muted); }

/* 顶部 */
.wechat-banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; background: var(--gold-tint); border-bottom: 1px solid var(--rule); font-size: 14px; }
.wechat-banner p { flex: 1; }
.wechat-banner button { flex: none; }
.top { position: sticky; top: 0; z-index: 5; background: #fff; }
.brand { display: flex; align-items: center; gap: 10px; max-width: 640px; margin: 0 auto; padding: 8px 16px; }
.brand img { display: block; width: 48px; height: 48px; }
.org { font-family: var(--serif); font-size: 17px; font-weight: 700; line-height: 1.3; }
.org-en { font-family: var(--sans); font-size: 13px; font-weight: 400; color: var(--muted); }
.form-name { font-size: 13px; color: var(--muted); line-height: 1.3; }
.progress { height: 3px; background: var(--rule); }
#progress-fill { height: 100%; width: 0; background: var(--gold); transition: width .25s ease; }
.stepper { display: flex; gap: 2px; max-width: 640px; margin: 0 auto; padding: 0 8px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--rule); }
.stepper::-webkit-scrollbar { display: none; }
.step { min-height: 44px; padding: 0 8px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-size: 14px; white-space: nowrap; cursor: pointer; }
.step.current { border-bottom-color: var(--gold); color: var(--ink); font-weight: 600; }

/* 章节标题：像徽章一样的进度圈 */
.chapter-head { display: flex; align-items: center; gap: 14px; padding: 28px 0 22px; }
.seal { flex: none; width: 64px; height: 64px; }
.seal circle { fill: none; }
.seal-outer { stroke: var(--gold); stroke-width: 1; }
.seal-arc { stroke: var(--gold); stroke-width: 3; transform: rotate(-90deg); transform-origin: 32px 32px; }
.seal-number { font: 700 22px var(--serif); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
h1 { font: 700 27px/1.25 var(--serif); }
.intro { margin-top: 4px; color: var(--muted); font-size: 15px; }
h3 { margin: 10px 0 2px; font: 700 19px/1.4 var(--serif); }

/* 表单 */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
.fields > * { grid-column: 1 / -1; min-width: 0; }
.fields > .half { grid-column: span 1; }
label, legend { display: block; font-size: 15px; font-weight: 600; }
.field > label, .field > legend { margin-bottom: 5px; }
.help { color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.field > .help { margin-bottom: 6px; }
.check { margin-top: 4px; color: var(--amber); font-size: 13.5px; }
.note { color: var(--muted); font-size: 13.5px; }
input:not([type=radio]):not([type=checkbox]), select, textarea {
  display: block; width: 100%; min-height: 46px; padding: 9px 11px;
  border: 1px solid var(--field); border-radius: 3px; background: #fff; color: var(--ink);
  font: inherit; font-size: 16px; appearance: none; -webkit-appearance: none;
}
select { padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 15px center, right 10px center; background-size: 5px 5px; background-repeat: no-repeat; }
select:disabled { background-color: #f5f3ee; color: var(--muted); }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--gold-dark); }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: block; font-weight: 400; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--field); border-radius: 3px; }
.choice input:checked + span { border-color: var(--gold); background: var(--gold-tint); box-shadow: inset 0 0 0 1px var(--gold); font-weight: 600; }
.choice input:focus-visible + span { outline: 2px solid var(--gold-dark); outline-offset: 2px; }

/* 可添加多条 */
.group > h3 { margin-bottom: 8px; }
.entry { margin-bottom: 18px; padding-left: 12px; border-left: 2px solid var(--gold); }
.entry-head { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.entry-title { font-weight: 600; overflow-wrap: anywhere; }
.compact .entry { margin-bottom: 10px; border-left: 1px solid var(--rule); }
.compact .entry-title { color: var(--muted); font-size: 14px; font-weight: 400; }
.group-label { margin-bottom: 2px; font-size: 15px; font-weight: 600; }
.section { padding-top: 4px; }
.section > h3 { margin-bottom: 12px; }
.list-row + .list-row { margin-top: 8px; }
.list-input { display: flex; gap: 6px; align-items: center; }
.list-input input { flex: 1; min-width: 0; }

/* 按钮 */
.button { min-height: 46px; padding: 0 20px; border: 1px solid var(--field); border-radius: 3px; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.button.primary { border-color: var(--gold); background: var(--gold); }
.button.danger { border-color: var(--red); background: var(--red); color: #fff; }
.button.large { width: 100%; min-height: 52px; font-size: 17px; }
.button:disabled { opacity: .55; cursor: default; }
.text-button { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--gold-dark); font: inherit; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.text-button.danger { color: var(--red); }
.text-button:disabled { color: var(--muted); text-decoration: none; }
.add-button { min-height: 44px; padding: 0 14px; border: 1px dashed var(--gold); border-radius: 3px; background: none; color: var(--gold-dark); font: inherit; font-size: 15px; cursor: pointer; }
.field .add-button { margin-top: 8px; }

/* 文书追问 */
.coach { margin-top: 2px; }
.coach-button { font-weight: 600; }
.coach-result { margin-top: 6px; }
.coach-result > div { padding: 10px 12px; background: var(--gold-tint); }
.coach-title { font-weight: 600; font-size: 14px; }
.coach-result ul { margin: 4px 0 0; padding-left: 20px; font-size: 15px; }

.nav { display: flex; justify-content: space-between; gap: 12px; padding: 28px 0 8px; }
.foot { padding-top: 8px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.save-status { color: var(--muted); font-size: 13px; }
.save-status.warn { color: var(--amber); font-weight: 600; }
.foot-actions { display: flex; justify-content: space-between; }

/* 生成页 */
.finish { display: grid; gap: 16px; }
.status { color: var(--muted); font-size: 15px; min-height: 1.6em; }
.notice { padding: 14px; background: var(--gold-tint); }
.notice h3 { margin-top: 0; }
.notice .datacode { margin-top: 10px; }
.notice.error { margin-top: 28px; }
.datacode { display: grid; gap: 8px; justify-items: start; }
.datacode textarea { font-size: 13px; word-break: break-all; }
.result { padding: 16px; border-top: 3px solid var(--gold); background: var(--gold-tint); }
.result:focus { outline: none; }
.result-box, .entry { scroll-margin-top: 130px; }
.result h2 { font: 700 22px/1.3 var(--serif); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.contact { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 10px 0; }
.contact dt { color: var(--muted); }
.contact dd { font-weight: 600; overflow-wrap: anywhere; }
.fallback summary { min-height: 44px; display: flex; align-items: center; color: var(--gold-dark); cursor: pointer; }
.fallback p { margin-bottom: 8px; color: var(--muted); font-size: 14px; }

/* 弹窗 */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(35, 38, 43, .5); }
.modal { width: 100%; max-width: 420px; max-height: 90vh; overflow: auto; padding: 20px; background: #fff; border-top: 3px solid var(--gold); }
.modal h2 { margin-bottom: 8px; font: 700 20px/1.3 var(--serif); }
.modal textarea { margin-top: 10px; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
@media (max-width: 380px) {
  h1 { font-size: 24px; }
  .seal { width: 54px; height: 54px; }
}
