/* ============================================================
   家长端 · 择校路线手册
   只服务 index.html / result.html；管理端继续使用 app.css
   ============================================================ */

:root {
  color-scheme: light;

  --canvas: #e6ece5;
  --sheet: #fcfdf8;
  --sheet-2: #f2f6ee;
  --sheet-3: #f8faf5;

  --ink: #17251e;
  --ink-2: #405147;
  --ink-3: #66776c;

  --rule: #cfd9ce;
  --rule-soft: #e3eae0;

  --pine: #1d4b3a;
  --pine-deep: #123229;
  --pine-wash: #edf3ec;

  --red: #b5432f;
  --red-deep: #8f3020;
  --red-soft: #f6e4de;

  --cream: #f3f6ee;

  --radius-page: 2px;
  --radius: 6px;

  --font-serif: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", Georgia, serif;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --shadow-paper: 0 1px 0 rgba(23, 37, 30, 0.04), 0 24px 60px -30px rgba(18, 50, 41, 0.35);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--pine); color: var(--cream); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

html {
  scrollbar-color: var(--rule) transparent;
  scrollbar-width: thin;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--rule);
  border: 2px solid var(--sheet);
  border-radius: 6px;
}
::-webkit-scrollbar-track { background: transparent; }

input, textarea, select { caret-color: var(--pine); }

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.35;
  font-weight: 600;
}

p { margin: 0 0 0.7em; }
a { color: var(--pine); text-underline-offset: 3px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------- 手册骨架 ---------------------------- */

.handbook {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.cover {
  position: relative;
  background: var(--pine);
  color: var(--cream);
  padding: 30px 22px 26px;
  border-top: 3px solid var(--red);
}

.cover > * { position: relative; z-index: 1; }

.cover__title {
  font-family: var(--font-serif);
  font-size: clamp(30px, 8.2vw, 42px);
  line-height: 1.18;
  letter-spacing: 0.01em;
  color: var(--cream);
}

.cover__title .cover__subject { display: block; }

.cover__brand {
  margin: 14px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.12em;
  color: rgba(243, 246, 238, 0.74);
}

.cover__lede {
  margin: 16px 0 0;
  max-width: 26em;
  font-size: 14px;
  line-height: 1.8;
  color: rgba(243, 246, 238, 0.78);
}

.cover__meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid rgba(243, 246, 238, 0.16);
}

.cover__meta div { min-width: 0; }
.cover__meta dt {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: rgba(243, 246, 238, 0.66);
}
.cover__meta dd {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(243, 246, 238, 0.94);
}

.cover__foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid rgba(243, 246, 238, 0.16);
  font-size: 11.5px;
  line-height: 1.75;
  color: rgba(243, 246, 238, 0.7);
}
.cover__foot p { margin: 0 0 4px; }

/* ---------------------------- 路线 ---------------------------- */

.route {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(243, 246, 238, 0.16);
}

.route__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.route__label {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: rgba(243, 246, 238, 0.66);
}

.route__percent {
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: rgba(243, 246, 238, 0.82);
}

.route__list {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}

.route__list::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: rgba(243, 246, 238, 0.18);
}

.route__item {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 11px;
  padding: 7px 0;
  color: rgba(243, 246, 238, 0.72);
}

.route__node {
  position: relative;
  z-index: 1;
  width: 21px;
  height: 21px;
  border: 1px solid rgba(243, 246, 238, 0.34);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1;
  background: var(--pine);
  color: rgba(243, 246, 238, 0.66);
}

.route__text b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  color: inherit;
}

.route__item.is-done { color: rgba(243, 246, 238, 0.82); }
.route__item.is-done .route__node {
  background: var(--cream);
  border-color: var(--cream);
  color: var(--pine);
}
.route__item.is-done .route__node::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid var(--pine);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(42deg) translate(-1px, -1px);
}
.route__item.is-current { color: var(--cream); }
.route__item.is-current .route__node {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.route__note {
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: rgba(243, 246, 238, 0.66);
}

/* ---------------------------- 纸页 ---------------------------- */

.pages {
  position: relative;
  min-height: 100vh;
  padding: 0 20px calc(104px + var(--safe-bottom));
  background: var(--sheet);
}

/* 手机端：封面之后吸顶的分步路线 */
.progress {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -20px;
  padding: 11px 20px 10px;
  background: var(--sheet);
  border-bottom: 1px solid var(--rule-soft);
}

.progress-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
}

.progress-top strong {
  color: var(--pine);
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.steps { display: flex; gap: 4px; }
.steps .seg {
  flex: 1;
  height: 3px;
  background: var(--rule-soft);
  overflow: hidden;
}
.steps .seg i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--pine);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.steps .seg.done i { width: 100%; }
.steps .seg.active i { width: 45%; background: var(--red); }

/* ---------------------------- 步骤页 ---------------------------- */

.step {
  padding: 28px 0 10px;
}

.step-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.step-index {
  padding-top: 5px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--red);
  letter-spacing: 0.04em;
}

.step-title {
  font-family: var(--font-serif);
  font-size: 27px;
  line-height: 1.3;
  color: var(--ink);
}

/* ---------------------------- 字段 ---------------------------- */

.field {
  padding: 21px 0;
  border-top: 1px solid var(--rule-soft);
}
.field:first-of-type { border-top: 0; padding-top: 18px; }

.field > .label {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 3px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink);
}

.req {
  flex: none;
  margin-top: 1px;
  color: var(--red);
  font-size: 14px;
  line-height: 1.6;
}

.optional {
  flex: none;
  margin-top: 4px;
  padding: 0 5px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink-3);
}

.field.invalid > .label { color: var(--red-deep); }
.field.invalid .err { display: flex; }

.control { position: relative; }

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
  font-size: 16px;
  line-height: 1.5;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  appearance: none;
}

textarea { min-height: 96px; resize: vertical; line-height: 1.7; }

input::placeholder, textarea::placeholder {
  color: var(--ink-3);
  opacity: 1;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px var(--pine-wash);
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--red);
  background: #fffaf8;
  box-shadow: 0 0 0 3px var(--red-soft);
}

select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2366776c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* 整行选项 */
.options { display: grid; gap: 0; }

.opt {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 0 -8px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--rule-soft);
  background: transparent;
  cursor: pointer;
  transition: background 0.14s;
  -webkit-tap-highlight-color: transparent;
}
.opt:last-child { border-bottom: 0; }
.opt:hover { background: var(--sheet-2); }

.opt .dot {
  flex: none;
  position: relative;
  width: 19px;
  height: 19px;
  margin-top: 3px;
  border: 1.5px solid #a7b5aa;
  border-radius: 50%;
  background: #fff;
  transition: border-color 0.14s, background 0.14s;
}
.opt.multi .dot { border-radius: 4px; }

.opt .dot::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  transform: scale(0);
  transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1);
}

.opt .txt { flex: 1; min-width: 0; }
.opt .txt b {
  display: block;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--ink);
}
.opt input { position: absolute; opacity: 0; pointer-events: none; }

.opt:focus-within {
  outline: 2px solid var(--red);
  outline-offset: -2px;
}

.opt.checked { background: var(--pine-wash); }
.opt.checked .dot { border-color: var(--pine); background: var(--pine); }
.opt.checked .dot::after { transform: scale(1); }
.opt.checked .txt b { color: var(--pine-deep); }

.opt.multi.checked .dot::after {
  width: 8px;
  height: 4px;
  border: 0;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  border-radius: 0;
  background: transparent;
  transform: rotate(-45deg) translate(1px, -1px);
}

.rank-no {
  display: none;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--pine);
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 22px;
  text-align: center;
}
.opt.checked .rank-no { display: inline-block; }

/* Q9 领域矩阵 */
.matrix-wrap {
  margin: 6px 0 2px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-page);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.matrix {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}
.matrix th,
.matrix td {
  padding: 9px 7px;
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  white-space: nowrap;
}
.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sheet-2);
  color: var(--ink-2);
  font-weight: 600;
}
.matrix tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 128px;
  background: var(--sheet);
  color: var(--ink);
  font-weight: 500;
  text-align: left;
}
.matrix td { width: 54px; }
.matrix tbody tr:last-child th,
.matrix tbody tr:last-child td { border-bottom: 0; }
.matrix input {
  width: 17px;
  height: 17px;
  accent-color: var(--pine);
  cursor: pointer;
}

/* 紧凑刻度题 */
.options.chips {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
}

.chip {
  position: relative;
  display: block;
  padding: 12px 2px;
  border-right: 1px solid var(--rule-soft);
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
  -webkit-tap-highlight-color: transparent;
}
.chip:last-child { border-right: 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:focus-within { box-shadow: inset 0 0 0 2px var(--pine); }
.chip.checked {
  background: var(--pine);
  color: #fff;
  font-weight: 600;
}

/* 勾选同意 */
.consent {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet-2);
  cursor: pointer;
}
.consent .box {
  flex: none;
  position: relative;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border: 1.5px solid #a7b5aa;
  border-radius: 3px;
  background: #fff;
}
.consent.checked .box { background: var(--pine); border-color: var(--pine); }
.consent.checked .box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.consent span.t { font-size: 14px; font-weight: 500; line-height: 1.7; }

/* 错误 */
.err {
  display: none;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  color: var(--red);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.6;
}
.err::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  background: var(--red);
}

/* ---------------------------- 按钮与底栏 ---------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--pine);
  color: var(--cream);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.4;
  transition: background 0.16s, border-color 0.16s, transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--pine-deep); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn.ghost {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-2);
  font-weight: 500;
}
.btn.ghost:hover { background: var(--sheet-2); border-color: #b9c7bb; color: var(--ink); }

.btn.grow { flex: 1; }
.btn.sm { min-height: 38px; padding: 0 13px; font-size: 13px; border-radius: 4px; }

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--pine);
  font-size: 12.5px;
  line-height: 1.6;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--pine-deep); }

.navbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 11px 20px calc(11px + var(--safe-bottom));
  background: var(--sheet);
  border-top: 1px solid var(--rule);
}

.navbar-inner {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.result-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 10px 20px calc(10px + var(--safe-bottom));
  background: var(--sheet);
  border-top: 1px solid var(--rule);
}
.result-actions .inner {
  display: flex;
  gap: 8px;
  width: 100%;
}
.result-actions .btn {
  flex: 1 1 auto;
  min-height: 46px;
  padding: 0 10px;
  font-size: 13.5px;
  white-space: nowrap;
}
.result-actions .btn.sm { min-height: 46px; font-size: 13.5px; }

/* ---------------------------- 提示条 / Toast ---------------------------- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid #e5cfc6;
  border-radius: var(--radius);
  background: #fcf4f0;
  color: #6f3325;
  font-size: 12.5px;
  line-height: 1.7;
}
.banner b { color: var(--red-deep); font-weight: 600; }
.banner > div:first-child { flex: 1; min-width: 0; }
.banner .btn { flex: none; }
.banner .x {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.banner.calm {
  border-color: #cddccd;
  background: var(--pine-wash);
  color: var(--pine-deep);
}
.banner--fallback {
  border-color: #e0d3b5;
  background: #faf5e9;
  color: #66501f;
}
.banner--fallback b { color: #4f3d13; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + var(--safe-bottom));
  z-index: 60;
  max-width: min(92vw, 420px);
  padding: 10px 16px;
  border-radius: 4px;
  background: var(--pine-deep);
  color: var(--cream);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  box-shadow: 0 12px 32px rgba(18, 50, 41, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------- 页脚 ---------------------------- */

.footnote {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--rule-soft);
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--ink-3);
}
.footnote b { color: var(--ink-2); font-weight: 600; }
.footnote .link-btn { margin-top: 6px; }

/* ============================================================
   报告页
   ============================================================ */

.cover--report {
  display: flex;
  flex-direction: column;
}

.cover--report .cover__title {
  font-size: clamp(30px, 7.4vw, 40px);
}

.cover__grade {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: rgba(243, 246, 238, 0.72);
}

.paper-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 12px;
  margin-top: 16px;
  font-size: 11.5px;
  line-height: 1.6;
  color: rgba(243, 246, 238, 0.72);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border: 1px solid rgba(243, 246, 238, 0.26);
  border-radius: 2px;
  background: rgba(243, 246, 238, 0.1);
  color: var(--cream);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
}
.badge.rule {
  border-color: rgba(181, 67, 47, 0.55);
  background: rgba(181, 67, 47, 0.2);
  color: #f2d7cf;
}
.badge.manual {
  border-color: rgba(190, 160, 92, 0.5);
  background: rgba(190, 160, 92, 0.16);
  color: #efe3c2;
}
.badge.reviewed {
  border-color: rgba(243, 246, 238, 0.5);
  background: var(--cream);
  color: var(--pine-deep);
}

.gen-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(243, 246, 238, 0.16);
  font-size: 12.5px;
  line-height: 1.6;
  color: rgba(243, 246, 238, 0.86);
}
.gen-status .spinner {
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(243, 246, 238, 0.25);
  border-top-color: var(--cream);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.toc {
  margin-top: 22px;
  padding-top: 15px;
  border-top: 1px solid rgba(243, 246, 238, 0.16);
}

.toc__label {
  margin: 0 0 7px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: rgba(243, 246, 238, 0.66);
}

.toc ol { margin: 0; padding: 0; list-style: none; }

.toc a {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(243, 246, 238, 0.08);
  color: rgba(243, 246, 238, 0.66);
  font-size: 12.5px;
  line-height: 1.5;
  text-decoration: none;
}
.toc a:hover { color: var(--cream); }
.toc a.active { color: var(--cream); font-weight: 600; }
.toc a .num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: rgba(243, 246, 238, 0.66);
}
.toc a.active .num { color: #e7a292; }

.cover--report .cover__note {
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px solid rgba(243, 246, 238, 0.16);
  font-size: 11px;
  line-height: 1.7;
  color: rgba(243, 246, 238, 0.66);
}

/* 章节目录浮条（手机） */
.chapter-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 -20px;
  padding: 0 20px;
  height: 50px;
  background: var(--sheet);
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
}
.chapter-bar__num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--red);
}
.chapter-bar__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}
.chapter-bar__toc {
  flex: none;
  margin-left: auto;
  color: var(--pine);
  font-size: 11.5px;
  text-underline-offset: 3px;
}

/* ---------------------------- 章节 ---------------------------- */

.article { padding: 0; }

.chapter {
  padding: 28px 0 10px;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 62px;
}
.chapter:first-child { border-top: 0; padding-top: 30px; }

.chapter__head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}

.chapter__num {
  padding-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--red);
  letter-spacing: 0.04em;
}

.chapter__title {
  font-family: var(--font-serif);
  font-size: 26px;
  line-height: 1.3;
  color: var(--ink);
}

.chapter__hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-3);
}

.chapter__body {
  max-width: 42em;
  font-size: 16px;
  line-height: 1.9;
  color: var(--ink);
}

.chapter__empty {
  color: var(--ink-3);
  font-size: 13.5px;
  line-height: 1.8;
}

.chapter__body h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 28px 0 8px;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.5;
  color: var(--pine-deep);
}
.chapter__body h3::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  background: var(--pine);
  transform: translateY(-1px);
}

.chapter__body h4 {
  margin: 18px 0 5px;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
}

.chapter__body p { margin: 0 0 12px; }

.chapter__body strong { color: var(--pine-deep); font-weight: 650; }

.chapter__body a {
  color: var(--pine);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chapter__body ul,
.chapter__body ol {
  margin: 8px 0 15px;
  padding: 0;
  list-style: none;
}

.chapter__body ul li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 7px;
}
.chapter__body ul li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.78em;
  width: 5px;
  height: 5px;
  background: var(--pine);
  opacity: 0.8;
}

.chapter__body ol { counter-reset: item; }
.chapter__body ol li {
  position: relative;
  padding-left: 26px;
  margin-bottom: 9px;
  counter-increment: item;
}
.chapter__body ol li::before {
  content: counter(item);
  position: absolute;
  left: 0;
  top: 0.35em;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  color: var(--red);
}

.chapter__body blockquote {
  position: relative;
  margin: 18px 0;
  padding: 13px 15px;
  border: 1px solid #e6c9c0;
  border-radius: var(--radius-page);
  background: var(--red-soft);
  color: #6f2d20;
  font-size: 14.5px;
  line-height: 1.8;
}
.chapter__body blockquote::before {
  content: "注";
  display: inline-block;
  margin-right: 7px;
  padding: 0 4px;
  border-radius: 2px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  line-height: 1.6;
  vertical-align: 1px;
}
.chapter__body blockquote br { display: block; content: ""; margin-top: 4px; }

.chapter__body code {
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--sheet-2);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ---------------------------- 表格 ---------------------------- */

.tbl-wrap {
  margin: 14px 0 18px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-page);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.chapter__body table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.7;
}

.chapter__body thead th {
  padding: 10px 12px;
  background: var(--pine);
  color: var(--cream);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.chapter__body tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--rule-soft);
  vertical-align: top;
  color: var(--ink-2);
}
.chapter__body tbody tr:nth-child(even) td { background: var(--sheet-3); }
.chapter__body tbody td:first-child {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .tbl-wrap { overflow: visible; border: 0; background: transparent; }
  .chapter__body table { display: block; min-width: 0; background: transparent; }
  .chapter__body thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .chapter__body tbody { display: block; }
  .chapter__body tbody tr {
    display: block;
    margin: 0;
    padding: 12px 0;
    border-top: 1px solid var(--rule);
    background: transparent;
  }
  .chapter__body tbody tr:first-child { border-top: 0; }
  .chapter__body tbody tr:nth-child(even) td { background: transparent; }
  .chapter__body tbody td {
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .chapter__body tbody td:first-child {
    margin-bottom: 5px;
    font-size: 13.5px;
    white-space: normal;
  }
  .chapter__body tbody td:not(:first-child) {
    display: flex;
    gap: 9px;
    padding: 2px 0;
    font-size: 13px;
  }
  .chapter__body tbody td:not(:first-child)::before {
    content: attr(data-label);
    flex: none;
    width: 96px;
    color: var(--ink-3);
    font-size: 11px;
    line-height: 1.8;
  }

  .matrix-wrap { border: 0; background: transparent; overflow: visible; }
  .matrix { min-width: 0; display: block; }
  .matrix thead { display: none; }
  .matrix tbody { display: block; }
  .matrix tr {
    display: block;
    margin: 0 0 10px;
    padding: 10px 0 6px;
    border-bottom: 1px solid var(--rule);
  }
  .matrix tbody th {
    position: static;
    display: block;
    min-width: 0;
    padding: 0 0 6px;
    background: transparent;
    font-weight: 600;
  }
  .matrix td {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: auto;
    padding: 4px 8px 4px 0;
    border: 0;
    white-space: normal;
  }
  .matrix td::before {
    content: attr(data-label);
    color: var(--ink-2);
    font-size: 11.5px;
  }
  .matrix tr:last-child { border-bottom: 0; }
}

/* ---------------------------- 勾选清单 ---------------------------- */

.check-note {
  margin: 4px 0 10px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-3);
}

.check-list { margin: 6px 0 16px; padding: 0; list-style: none; }

.chapter__body .check-list li,
.chapter__body .check-item {
  position: relative;
  padding: 0;
  margin: 0;
  border-bottom: 1px dashed var(--rule-soft);
}
.chapter__body .check-list li::before,
.chapter__body .check-item::before { content: none; }

.check-item label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--ink-2);
  cursor: pointer;
}
.check-item label:hover { background: var(--sheet-2); }

.check-item input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.check-box {
  flex: none;
  position: relative;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border: 1.5px solid #a7b5aa;
  border-radius: 2px;
  background: #fff;
}

.check-item input:checked + label .check-box {
  border-color: var(--pine);
  background: var(--pine);
}
.check-item input:checked + label .check-box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.check-item input:focus-visible + label .check-box {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.check-item input:checked + label .check-text { color: var(--ink-3); }

.check-text { flex: 1; min-width: 0; }
.check-text strong { color: var(--pine-deep); }

/* ---------------------------- 报告尾页 ---------------------------- */

.article-end {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--ink-3);
}
.article-end .disclaimer { margin: 0; }
.article-end .regen { margin-top: 10px; }
.article-end .link-btn { color: var(--ink-3); }
.article-end .link-btn:hover { color: var(--pine); }

/* ---------------------------- 生成态 / 错误态 ---------------------------- */

.chapter__body.is-typing::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 15px;
  margin-left: 3px;
  background: var(--red);
  vertical-align: -2px;
  animation: blink 1s steps(2) infinite;
}

.skeleton { padding: 22px 0; }
.skeleton .bar {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 10px;
  margin-bottom: 12px;
  background: var(--rule-soft);
}
.skeleton .bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(252, 253, 248, 0.7), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
}
.skeleton .bar.title { width: 46%; height: 20px; margin-bottom: 20px; }
.skeleton .bar:nth-child(2) { width: 92%; }
.skeleton .bar:nth-child(3) { width: 78%; }

.error-page {
  max-width: 34em;
  padding: 48px 0 26px;
}
.error-page .err-rule {
  width: 44px;
  height: 3px;
  background: var(--red);
  margin-bottom: 18px;
}
.error-page .err-message {
  font-size: 15.5px;
  line-height: 1.9;
  color: var(--ink-2);
}
.error-page .err-actions { margin-top: 20px; }
.error-page .err-help {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-3);
}

/* ============================================================
   桌面 / 平板
   ============================================================ */

@media (max-width: 1023px) {
  body.step-active .cover { display: none; }
  .route { display: none; }
  .cover__foot p:last-child { display: none; }
  .toc ol {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 18px;
  }
  .toc a { padding: 6px 0; }
}

@media (min-width: 768px) {
  .cover { padding: 38px 34px 32px; }
  .pages { padding: 0 34px calc(110px + var(--safe-bottom)); }
  .progress { margin: 0 -34px; padding-left: 34px; padding-right: 34px; }
  .navbar { padding-left: 34px; padding-right: 34px; }
  .chapter-bar { margin: 0 -34px; padding: 0 34px; }
  .step-title { font-size: 29px; }
  .chapter__title { font-size: 28px; }
  .chapter__body { font-size: 16.5px; }
  .cover__title { font-size: 46px; }
}

@media (min-width: 1024px) {
  .handbook {
    grid-template-columns: 340px minmax(0, 1fr);
    padding: 24px;
  }

  .cover {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 48px);
    padding: 36px 30px 28px;
  }

  .cover__title { font-size: 38px; }
  .cover__lede { font-size: 13.5px; }
  .cover__meta { grid-template-columns: 1fr; gap: 8px; }
  .cover__meta div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .cover__meta dt { flex: none; }
  .cover__meta dd { margin: 0; text-align: right; }

  .pages {
    min-height: calc(100vh - 48px);
    padding: 0 48px 72px;
    border: 1px solid var(--rule);
    border-left: 0;
    border-radius: 0 var(--radius-page) var(--radius-page) 0;
    box-shadow: var(--shadow-paper);
  }

  .progress { display: none; }

  .step { padding-top: 40px; }
  .step-head { grid-template-columns: 44px minmax(0, 1fr); gap: 14px; }
  .step-title { font-size: 32px; }
  .field { padding: 24px 0; }

  .navbar {
    position: sticky;
    bottom: 0;
    left: auto;
    right: auto;
    margin: 0 -48px;
    padding: 14px 48px;
    background: var(--sheet);
  }
  .navbar-inner { max-width: none; }
  .navbar .btn { min-height: 46px; }

  .chapter-bar { display: none; }

  .chapter { padding-top: 34px; scroll-margin-top: 20px; }
  .chapter:first-child { padding-top: 40px; }
  .chapter__head { grid-template-columns: 44px minmax(0, 1fr); gap: 14px; }
  .chapter__num { padding-top: 7px; }
  .chapter__title { font-size: 30px; }

  .cover--report .cover__title { font-size: 40px; }
  .cover--report .toc { margin-top: 24px; }
  .cover--report .cover__note { margin-top: auto; }

  .cover .result-actions {
    position: static;
    margin: 18px 0 0;
    padding: 16px 0 0;
    border-top: 1px solid rgba(243, 246, 238, 0.16);
    background: transparent;
  }
  .cover .result-actions .inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .cover .result-actions .btn {
    min-height: 40px;
    padding: 0 8px;
    font-size: 12.5px;
    border-radius: 4px;
  }
  .cover .result-actions .btn:last-child {
    grid-column: 1 / -1;
    order: -1;
    border-color: var(--cream);
    background: var(--cream);
    color: var(--pine);
  }
  .cover .result-actions .btn:last-child:hover { background: #fff; }
  .cover .result-actions .btn.ghost {
    border-color: rgba(243, 246, 238, 0.35);
    background: transparent;
    color: var(--cream);
  }
  .cover .result-actions .btn.ghost:hover { background: rgba(243, 246, 238, 0.1); }
}

/* 矮屏桌面：封面收紧，保证目录与按钮不被挤出 */
@media (min-width: 1024px) and (max-height: 760px) {
  .cover { padding: 26px 28px 22px; }
  .cover__title { font-size: 36px; }
  .cover__lede { display: none; }
  .cover__meta { margin-top: 14px; padding-top: 10px; gap: 4px; }
  .route { margin-top: 14px; padding-top: 12px; }
  .route__item { padding: 5px 0; }
  .cover--report .toc { margin-top: 14px; padding-top: 12px; }
  .toc a { padding: 5px 0; }
  .cover--report .cover__note { display: none; }
}

/* ============================================================
   打印：另一张封面 + 连续章节
   ============================================================ */

.print-cover { display: none; }

@media print {
  html, body { background: #fff; }
  body { color: #000; font-size: 10.5pt; }

  .cover,
  .chapter-bar,
  .result-actions,
  .gen-status,
  .progress,
  .navbar,
  .toast,
  .banner,
  .footnote,
  .article-end,
  .skeleton { display: none !important; }

  .handbook {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .pages {
    min-height: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .print-cover {
    display: block;
    padding: 0 0 10mm;
    break-after: page;
    page-break-after: always;
  }
  .print-cover__brand {
    padding-bottom: 4mm;
    border-bottom: 1.5pt solid var(--pine);
    font-size: 9pt;
    letter-spacing: 0.12em;
    color: #333;
  }
  .print-cover h1 {
    margin: 18mm 0 4mm;
    font-family: var(--font-serif);
    font-size: 26pt;
    line-height: 1.2;
    font-weight: 600;
  }
  .print-cover .print-meta {
    font-size: 9.5pt;
    color: #333;
    line-height: 1.7;
  }
  .print-cover .print-toc {
    margin-top: 16mm;
    padding-top: 4mm;
    border-top: 0.6pt solid #999;
    columns: 2;
    column-gap: 12mm;
  }
  .print-cover .print-toc div {
    padding: 2mm 0;
    font-size: 10pt;
    break-inside: avoid;
  }
  .print-cover .print-toc b {
    display: inline-block;
    width: 8mm;
    font-family: var(--font-mono);
    font-size: 9pt;
    font-weight: 600;
    color: var(--red);
  }
  .print-cover .print-note {
    margin-top: 18mm;
    font-size: 9pt;
    line-height: 1.7;
    color: #444;
  }

  .article { padding: 0; }

  .chapter {
    padding: 0 0 6mm;
    border-top: 0.6pt solid #bbb;
    break-inside: auto;
  }
  .chapter:first-child { padding-top: 0; border-top: 0; }
  .chapter__head {
    margin-bottom: 4mm;
    padding-bottom: 3mm;
    border-bottom: 0.6pt solid #999;
    break-after: avoid;
    page-break-after: avoid;
  }
  .chapter__num { color: var(--red); }
  .chapter__title { font-size: 17pt; }
  .chapter__hint { font-size: 9pt; color: #555; }
  .chapter__body {
    max-width: 44em;
    font-size: 10.5pt;
    line-height: 1.75;
    color: #000;
  }
  .chapter__body h3 {
    margin: 5mm 0 1.5mm;
    font-size: 12pt;
    color: #000;
    break-after: avoid;
    page-break-after: avoid;
  }
  .chapter__body h3::before { background: #000; }
  .chapter__body h4 { break-after: avoid; page-break-after: avoid; }
  .chapter__body p { orphans: 2; widows: 2; }
  .chapter__body li { break-inside: avoid; page-break-inside: avoid; }
  .chapter__body strong { color: #000; }

  .chapter__body blockquote {
    background: #f4f4f4;
    border: 0.5pt solid #999;
    color: #000;
    break-inside: avoid;
  }
  .chapter__body blockquote::before {
    background: #000;
    color: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .tbl-wrap { overflow: visible; border: 0.5pt solid #999; margin: 4mm 0; }
  .matrix-wrap { overflow: visible; border: 0.5pt solid #999; margin: 3mm 0; }
  .matrix { min-width: 0; }
  .matrix th, .matrix td { padding: 1.2mm 1mm; font-size: 8pt; }
  .matrix tbody th { position: static; background: #fff; }
  .matrix thead th { position: static; background: #eee !important; }
  .chapter__body table { min-width: 0; font-size: 9pt; background: #fff; }
  .chapter__body thead th {
    background: #eee !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .chapter__body tbody td { color: #000; }
  .chapter__body thead {
    display: table-header-group;
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }
  .chapter__body tr { break-inside: avoid; }

  .check-item label { padding: 1.5mm 0; font-size: 9.5pt; color: #000; }
  .check-box { border-color: #333; }
  .check-item input:checked + label .check-box {
    background: #fff;
    border-color: #333;
  }
  .check-item input:checked + label .check-box::after { border-color: #000; }
  .check-item input:checked + label .check-text { color: #000; }

  a { color: inherit; text-decoration: none; }

  @page { size: A4; margin: 18mm 16mm; }
}

/* ---------------------------- 动效偏好 ---------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes shimmer { to { transform: translateX(100%); } }
