:root {
  --paper: #f5f2e9;
  --paper-deep: #ebe6d9;
  --sheet: #fffef9;
  --ink: #292723;
  --muted: #6f695f;
  --line: #d7c9ae;
  --vermilion: #b9362a;
  --pine: #315d54;
  --gold: #a98246;
  --focus: #2e6f9e;
  --danger: #9d281e;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "PingFang SC", "Microsoft YaHei", sans-serif; line-height: 1.75; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 40%, transparent); outline-offset: 3px; }

.topbar { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(10px); }
.topbar-inner { max-width: 980px; min-height: 68px; margin: auto; padding: 9px 18px; display: flex; align-items: center; gap: 13px; }
.back { color: var(--muted); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--vermilion); }
.seal { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: var(--vermilion); border-radius: 4px; font-family: "Songti SC", serif; font-weight: 700; }
.brand { font-weight: 700; letter-spacing: 0; }
.brand small { display: block; color: var(--muted); font-size: 9px; letter-spacing: 0; font-weight: 500; }
.trust { margin-left: auto; text-align: right; color: var(--muted); font-size: 11px; line-height: 1.55; }
.trust b { color: var(--pine); }

.shell { width: min(920px, calc(100% - 28px)); margin: 0 auto; padding-bottom: 38px; }
.steps { padding: 25px 0 12px; display: flex; align-items: center; justify-content: center; }
.step { border: 0; padding: 5px; display: flex; align-items: center; gap: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.step:disabled { cursor: not-allowed; opacity: .62; }
.step span { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; font-family: "Songti SC", serif; font-size: 12px; }
.step b { font-size: 12px; font-weight: 500; white-space: nowrap; }
.step.active { color: var(--ink); }
.step.active span { color: #fff; background: var(--vermilion); border-color: var(--vermilion); }
.step.active b { font-weight: 700; }
.step.done span { color: #fff; background: var(--pine); border-color: var(--pine); }
.step-line { width: 38px; height: 1px; background: var(--line); }

.page { display: none; animation: reveal .25s ease-out; }
.page.show { display: block; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } }
.title-block { max-width: 650px; margin: 28px auto 24px; text-align: center; }
.title-block.compact { margin-top: 20px; }
.title-block h1 { margin: 4px 0 8px; font-family: "Songti SC", "STSong", serif; font-size: 34px; letter-spacing: 0; }
.title-block p { margin: 0; color: var(--muted); font-size: 13px; }
.title-block .eyebrow { color: var(--vermilion); font-size: 11px; letter-spacing: 0; }

.paper-card { padding: 22px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--sheet); box-shadow: 0 2px 12px rgba(53, 44, 32, .045); }
.input-card { max-width: 680px; margin-inline: auto; }
.section-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.section-heading > span { width: 34px; height: 34px; display: grid; place-items: center; color: var(--vermilion); border: 1px solid var(--vermilion); border-radius: 50%; font-family: "Songti SC", serif; }
.section-heading h2 { margin: 0; font: 700 18px "Songti SC", serif; letter-spacing: 0; }
.field { display: block; margin-bottom: 19px; border: 0; padding: 0; }
.field > span, .field legend { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 700; }
.field em { color: var(--muted); font-size: 11px; font-style: normal; font-weight: 400; }
.field small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
input[type="text"], select { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 5px; background: #fff; }
#fullName { font-family: "Songti SC", serif; font-size: 20px; letter-spacing: 0; }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { min-height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; }
.segmented input:checked + span { color: #fff; border-color: var(--pine); background: var(--pine); }
.segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--focus) 40%, transparent); outline-offset: 3px; }
.check-row { display: flex; gap: 9px; align-items: flex-start; margin: 14px 0; font-size: 13px; }
.check-row input { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 3px; accent-color: var(--pine); }
.boundary-note { margin: 16px 0; padding: 12px 14px; color: #514b43; background: #f4efe4; border-left: 3px solid var(--gold); font-size: 12px; }
.boundary-note b { color: var(--ink); }
.history-link { color: var(--vermilion); font-weight: 700; }
.primary, .secondary { min-height: 44px; padding: 10px 18px; border-radius: 5px; cursor: pointer; font-weight: 700; letter-spacing: 0; }
.primary { color: #fff; border: 1px solid var(--vermilion); background: var(--vermilion); }
.secondary { color: var(--ink); border: 1px solid var(--ink); background: transparent; }
.primary:disabled, .secondary:disabled { cursor: not-allowed; opacity: .5; }
.wide { width: 100%; }
.form-error { display: none; margin: 12px 0 0; padding: 10px 12px; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); background: #fff6f3; font-size: 13px; }
.form-error.visible { display: block; }

.name-proof { min-height: 92px; padding: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--paper-deep); border: 1px solid var(--line); }
.proof-char { min-width: 54px; padding: 5px 8px; text-align: center; font: 30px "Songti SC", serif; border-bottom: 2px solid var(--vermilion); }
.proof-char small { display: block; color: var(--muted); font: 10px "PingFang SC", sans-serif; letter-spacing: 0; }
.confirmation-list { display: grid; gap: 12px; margin-top: 18px; }
.confirm-row { padding: 14px; border: 1px solid var(--line); border-radius: 5px; }
.confirm-row h3 { margin: 0 0 4px; font: 700 16px "Songti SC", serif; }
.confirm-row p { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.confirm-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.status-panel { margin-top: 16px; padding: 12px 14px; color: var(--pine); border-left: 3px solid var(--pine); background: #eef4f0; font-size: 12px; }

.fact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fact-card { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 6px; background: var(--sheet); }
.fact-card.wide { grid-column: 1 / -1; width: auto; }
.fact-card h2, .report-section h2 { margin: 0 0 12px; padding-left: 10px; border-left: 4px solid var(--vermilion); font: 700 17px "Songti SC", serif; letter-spacing: 0; }
.character-table, .grid-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.character-table-scroll { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; }
.character-table { min-width: 860px; }
.character-table th, .character-table td, .grid-table th, .grid-table td { padding: 9px 7px; border-bottom: 1px solid #e8dfd0; text-align: left; vertical-align: top; }
.character-table th, .grid-table th { color: var(--muted); font-weight: 500; }
.formula { color: var(--muted); font-size: 11px; }
.meaning-gloss { min-width: 12rem; line-height: 1.65; }
.numerology-rating { font-weight: 700; white-space: nowrap; }
.rating-吉 { color: #7b4f20; }
.rating-半吉 { color: #8b6f2f; }
.rating-凶 { color: #9e3529; }
.numerology-score { display: grid; gap: 7px; margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fffaf0; }
.numerology-score strong { font-size: 17px; }
.numerology-score small { color: var(--muted); line-height: 1.6; }
.semantic-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 10px; }
.semantic-item, .school-comparison { padding: 13px; border: 1px solid var(--line); border-radius: 6px; background: #fffdf8; }
.semantic-item h3, .school-comparison h3 { margin: 0 0 7px; font: 700 16px "Songti SC", serif; }
.semantic-item p, .school-comparison p { margin: 7px 0; font-size: 12px; line-height: 1.7; }
.term-button { padding: 2px 5px; color: var(--pine); border: 0; border-bottom: 1px dashed var(--pine); background: transparent; cursor: help; }
.tag-row { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { padding: 4px 9px; color: var(--pine); border: 1px solid color-mix(in srgb, var(--pine) 35%, transparent); border-radius: 999px; background: #f1f6f3; font-size: 12px; }
.plain-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.method-note { margin: 9px 0 0; padding: 8px 10px; color: #51483f; border-left: 3px solid var(--gold); background: #f6f1e7; font-size: 12px; }
.report-lead { padding: 21px; margin-bottom: 14px; color: #fff; background: var(--pine); border-radius: 6px; }
.report-lead h2 { margin: 0 0 8px; font: 700 20px "Songti SC", serif; letter-spacing: 0; }
.report-lead p { margin: 0; font-size: 14px; }
.name-dimension-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.name-dimension { padding: 12px 13px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 5px; background: rgba(255, 255, 255, .08); }
.name-dimension h3 { margin: 0 0 5px; color: #fff; font: 700 16px "Songti SC", serif; }
.name-dimension p { color: rgba(255, 255, 255, .92); font-size: 12px; line-height: 1.75; }
.report-section { padding: 20px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--sheet); }
.report-section p { margin: 0 0 10px; font-size: 14px; }
.report-section ul { margin: 0; padding-left: 20px; font-size: 13px; }
.source-list { color: var(--muted); font-size: 11px; }
.workflow-actions { margin: 24px 0; display: flex; gap: 10px; }
.workflow-actions button { flex: 1; }

.term-dialog { width: min(520px, calc(100% - 28px)); padding: 0; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; background: var(--sheet); }
.term-dialog::backdrop { background: rgba(34, 31, 27, .48); }
.dialog-head { min-height: 58px; padding: 12px 16px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font: 700 18px "Songti SC", serif; }
.dialog-head button { width: 34px; height: 34px; margin-left: auto; border: 0; border-radius: 50%; background: var(--paper-deep); cursor: pointer; font-size: 22px; }
#termBody { padding: 18px; font-size: 13px; }

@media (max-width: 650px) {
  .topbar-inner { min-height: 60px; padding: 8px 10px; }
  .trust { display: none; }
  .brand { font-size: 14px; }
  .back { font-size: 11px; }
  .shell { width: min(100% - 20px, 920px); }
  .steps { padding-top: 16px; overflow-x: auto; justify-content: flex-start; }
  .step { gap: 4px; padding-inline: 2px; }
  .step span { width: 25px; height: 25px; }
  .step b { font-size: 10px; }
  .step-line { width: 10px; flex: 0 0 auto; }
  .title-block { margin: 20px 8px; }
  .title-block h1 { font-size: 25px; letter-spacing: 0; }
  .paper-card { padding: 15px; }
  .fact-grid { grid-template-columns: 1fr; }
  .name-dimension-grid { grid-template-columns: 1fr; }
  .fact-card.wide { grid-column: auto; }
  .confirm-controls { grid-template-columns: 1fr; }
  .workflow-actions { flex-direction: column; }
}
