/* 紫微研习 · 国潮色彩 */
:root {
  --paper: #f8f0dc;
  --card: #fffaf0;
  --ink: #1d1a16;
  --ink-soft: #5b544a;
  --red: #e0432b;
  --red-deep: #b92f1b;
  --teal: #0e7a66;
  --teal-deep: #095648;
  --teal-soft: #d5ebe2;
  --yellow: #f8bf24;
  --yellow-soft: #fde9a9;
  --blue: #24477f;
  --pink: #f6c4b3;
  --line: 2px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --radius: 16px;
  --display: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  --bar-h: 64px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--bar-h) + 64px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.7 var(--sans);
}
main { flex: 1; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* ── 图标（Tabler Icons，用 mask 着色） ── */
.icon { display: inline-block; width: 20px; height: 20px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.i-edit { --i: url('/assets/icons/edit.svg'); }
.i-download { --i: url('/assets/icons/download.svg'); }
.i-book { --i: url('/assets/icons/book.svg'); }
.i-chevron { --i: url('/assets/icons/chevron-down.svg'); }

/* ── 通用部件 ── */
.card { background: var(--card); border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: var(--line); border-radius: 999px;
  font-weight: 700; font-size: 15px; white-space: nowrap;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .6; cursor: wait; transform: none; }
.btn-red { background: var(--red); color: #fff; }
.btn-yellow { background: var(--yellow); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-plain { background: var(--card); }
.btn-big { width: 100%; min-height: 54px; font-size: 18px; letter-spacing: 4px; }
.link-button { display: block; margin: 14px auto 0; padding: 6px 10px; font-size: 13px; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 4px; }
.link-button:hover { color: var(--red-deep); }
.fineprint { font-size: 12px; line-height: 1.7; color: var(--ink-soft); }

.segment { display: flex; border: var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.segment > * { flex: 1; }
.segment label { position: relative; cursor: pointer; }
.segment input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segment span, .segment button { display: grid; place-items: center; height: 100%; min-height: 44px; padding: 0 18px; font-weight: 700; font-size: 15px; }
.segment > * + * { border-left: var(--line); }
.segment input:checked + span, .segment button[aria-pressed=true] { background: var(--ink); color: var(--yellow); }
.segment input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: -3px; }

/* ── 顶栏 ── */
.bar {
  position: sticky; top: 0; z-index: 20;
  height: var(--bar-h); padding: 0 28px;
  display: flex; align-items: center; gap: 20px;
  background: var(--paper); border-bottom: var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.seal {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--red); color: #fff; border: var(--line); border-radius: 10px;
  font: 700 22px/1 var(--display); transform: rotate(-4deg);
}
.brand-name { font: 700 22px/1 var(--display); letter-spacing: 3px; white-space: nowrap; }
.bar-birth { margin-left: auto; font-size: 14px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar-actions { display: flex; gap: 12px; }
.bar-birth[hidden] + .bar-actions { margin-left: auto; }

/* ── 首页 ── */
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 440px); gap: 56px; align-items: center;
  padding: 72px max(28px, calc((100vw - 1160px) / 2)) 96px;
  background: var(--teal); color: #fff;
}
.hero-art { position: absolute; left: 50%; top: 50%; width: 720px; height: 720px; transform: translate(-32%, -50%); pointer-events: none; }
.art-ring { fill: none; stroke: var(--yellow); stroke-width: 2; opacity: .55; }
.art-sun { fill: var(--red); stroke: var(--ink); stroke-width: 2; }
.art-ticks { stroke: var(--yellow); stroke-width: 3; stroke-linecap: round; opacity: .7; }
.art-stars { fill: var(--yellow); }
.art-cloud { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.hero-copy { position: relative; }
.hero-tag { display: inline-block; padding: 5px 14px; background: var(--yellow); color: var(--ink); border: var(--line); border-radius: 999px; font-weight: 700; font-size: 14px; letter-spacing: 2px; }
.hero h1 { margin: 22px 0 20px; font: 900 clamp(44px, 6.2vw, 84px)/1.18 var(--display); letter-spacing: 2px; }
.hero h1 em { font-style: normal; color: var(--yellow); }
.hero-sub { max-width: 30em; font-size: 18px; line-height: 1.8; color: #e6f3ee; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 34px; }
.hero-facts li { display: flex; flex-direction: column; padding: 10px 18px 12px; background: var(--teal-deep); border: 2px solid #ffffff40; border-radius: 14px; }
.hero-facts b { font: 900 28px/1.2 var(--display); color: var(--yellow); }
.hero-facts span { font-size: 13px; color: #d3e8e1; }

.form-card { position: relative; padding: 30px 30px 24px; color: var(--ink); box-shadow: 8px 8px 0 var(--ink); }
.form-card h2 { font: 900 30px/1.2 var(--display); letter-spacing: 2px; }
.form-lead { margin: 4px 0 22px; font-size: 14px; color: var(--ink-soft); }
.field { min-width: 0; margin: 0 0 18px; padding: 0; border: 0; }
.field label, .field legend { display: block; margin-bottom: 7px; padding: 0; font-weight: 700; font-size: 14px; }
.field small { font-weight: 400; font-size: 12px; color: var(--ink-soft); margin-left: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row.tight { gap: 10px; }
.field input[type=date], .field input[type=time], .field input[type=number], .field select {
  width: 100%; min-width: 0; height: 48px; padding: 0 12px;
  background: #fff; border: var(--line); border-radius: 12px; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.field select { padding-right: 34px; background: #fff url('/assets/icons/chevron-down.svg') right 10px center / 18px no-repeat; }
.field select:disabled { background-color: #efe7d4; color: var(--ink-soft); }
.field input:focus, .field select:focus { outline: 3px solid var(--yellow); outline-offset: 0; }
.segment label { margin: 0 !important; }
.field .segment { height: 48px; border-radius: 12px; }
.advanced { margin-bottom: 18px; font-size: 13px; color: var(--ink-soft); }
.advanced summary { cursor: pointer; padding: 4px 0; font-weight: 700; color: var(--teal-deep); }
.advanced .field { margin: 12px 0 10px; color: var(--ink); }
.error { margin-bottom: 16px; padding: 10px 14px; background: #fde3dc; border: 2px solid var(--red); border-radius: 12px; color: var(--red-deep); font-size: 14px; font-weight: 700; }

.wave {
  height: 28px; margin-top: -28px; position: relative;
  background:
    radial-gradient(circle at 50% 100%, var(--paper) 0 9px, var(--ink) 9px 11px, var(--paper) 11px 19px, var(--ink) 19px 21px, var(--paper) 21px 27px, var(--ink) 27px 29px, transparent 29px) 0 0 / 58px 29px repeat-x;
}

.steps { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 14px; max-width: 1160px; margin: 0 auto; padding: 22px 16px 30px; font-weight: 700; font-size: 15px; }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps li + li::before { content: "→"; margin-right: 6px; color: var(--ink-soft); font-weight: 400; }
.step-num { width: 30px; height: 30px; display: grid; place-items: center; border: var(--line); border-radius: 50%; font: 900 15px/1 var(--display); }
.step-teal { background: var(--teal); color: #fff; }
.step-yellow { background: var(--yellow); }
.step-red { background: var(--red); color: #fff; }

/* ── 结果页 ── */
.result { max-width: 1160px; margin: 0 auto; padding: 36px 28px 72px; }
.result-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px 40px; flex-wrap: wrap; }
.result-kicker { display: inline-block; padding: 3px 12px; background: var(--red); color: #fff; border: var(--line); border-radius: 999px; font-weight: 700; font-size: 13px; letter-spacing: 2px; }
.result-head h1 { margin-top: 10px; font: 900 clamp(38px, 5vw, 60px)/1.2 var(--display); letter-spacing: 3px; }
.facts { display: flex; flex-wrap: wrap; gap: 10px; }
.facts div { padding: 7px 14px 8px; background: var(--card); border: var(--line); border-radius: 12px; }
.facts dt { font-size: 12px; line-height: 1.4; color: var(--ink-soft); }
.facts dd { font-weight: 700; font-size: 16px; line-height: 1.4; }

.jump { position: sticky; top: var(--bar-h); z-index: 10; display: flex; gap: 10px; margin: 26px -28px 0; padding: 10px 28px; background: var(--paper); border-bottom: 2px dashed #1d1a1633; }
.jump-link { padding: 5px 16px; border: var(--line); border-radius: 999px; background: var(--card); font-weight: 700; font-size: 14px; text-decoration: none; white-space: nowrap; }
.jump-link:hover { background: var(--yellow); }

.block { margin-top: 44px; }
.block-title { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.block-num { width: 54px; height: 54px; flex: none; display: grid; place-items: center; background: var(--teal); color: #fff; border: var(--line); border-radius: 50%; font: 900 26px/1 var(--display); box-shadow: 3px 3px 0 var(--ink); }
.num-red { background: var(--red); }
.block-title h2 { font: 900 32px/1.25 var(--display); letter-spacing: 3px; }
.block-title p { font-size: 15px; color: var(--ink-soft); }

/* 命盘 */
.chart-wrap { display: grid; grid-template-columns: minmax(0, 700px) minmax(280px, 1fr); gap: 32px; align-items: start; }
.board {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 2px;
  aspect-ratio: 1; background: var(--ink); border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.board-empty { grid-column: 1 / -1; grid-row: 1 / -1; display: grid; place-items: center; padding: 24px; background: var(--card); text-align: center; font-weight: 700; color: var(--ink-soft); }
.board.is-empty { aspect-ratio: auto; min-height: 180px; }
.palace { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px 12px 10px; background: var(--card); text-align: left; overflow: hidden; transition: background .15s; }
.palace:hover { background: var(--yellow-soft); }
.palace[aria-pressed=true] { background: var(--yellow); }
.palace:focus-visible { outline-offset: -4px; }
.palace-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.palace-name { padding: 1px 8px 2px; background: var(--ink); color: var(--card); border-radius: 6px; font-weight: 700; font-size: 14px; line-height: 1.5; white-space: nowrap; }
.palace.is-ming .palace-name { background: var(--red); color: #fff; }
.palace-branch { font: 700 15px/1 var(--display); color: var(--ink-soft); }
.palace-stars { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.star { display: flex; align-items: center; gap: 5px; font: 900 23px/1.3 var(--display); white-space: nowrap; }
.star-none { font: 400 14px/1.6 var(--sans); color: var(--ink-soft); }
.hua { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 50%; font: 700 12px/1 var(--sans); color: #fff; background: var(--teal); }
.hua[data-hua=化权] { background: var(--red); }
.hua[data-hua=化科] { background: var(--blue); }
.hua[data-hua=化忌] { background: var(--ink); }
.palace-aux { margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.palace-foot { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: auto; padding-top: 4px; font-size: 11px; line-height: 1.4; color: var(--ink-soft); white-space: nowrap; }
.tag-shen { padding: 0 6px; background: var(--teal); color: #fff; border-radius: 999px; font-weight: 700; }
.board-center {
  grid-column: 2 / 4; grid-row: 2 / 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; text-align: center;
  color: #fff;
  background:
    radial-gradient(circle at 50% 100%, transparent 0 13px, #ffffff1f 13px 15px, transparent 15px 25px, #ffffff1f 25px 27px, transparent 27px) 0 0 / 56px 28px,
    radial-gradient(circle at 50% 100%, transparent 0 13px, #ffffff1f 13px 15px, transparent 15px 25px, #ffffff1f 25px 27px, transparent 27px) 28px 14px / 56px 28px,
    var(--teal);
}
.center-kicker { padding: 2px 12px; background: var(--yellow); color: var(--ink); border-radius: 999px; font-weight: 700; font-size: 12px; letter-spacing: 2px; }
.center-title { font: 900 clamp(22px, 3.4vw, 38px)/1.25 var(--display); letter-spacing: 3px; white-space: nowrap; }
.center-meta { font-size: 13px; line-height: 1.8; color: #e3f1ec; }
.center-meta b { color: var(--yellow); }

.board-col { min-width: 0; }
.palace { position: relative; }
.palace.in-sf { background: var(--teal-soft); }
.palace.in-sf:hover { background: #c3e2d6; }
.sf-tag:empty { display: none; }
.sf-tag { position: absolute; right: 6px; bottom: 6px; z-index: 1; width: 22px; height: 22px; display: grid; place-items: center; background: var(--teal); color: #fff; border: 1.5px solid var(--ink); border-radius: 50%; font: 700 12px/1 var(--sans); }
.palace.is-current { box-shadow: inset 0 0 0 4px var(--red); }
.age-current { padding: 0 6px; background: var(--red); color: #fff; border-radius: 999px; font-weight: 700; }
.age-current::before { content: "当前 "; }
.center-current { margin-top: 2px; padding: 4px 12px; background: var(--red); color: #fff; border: 2px solid var(--ink); border-radius: 999px; font-weight: 700; font-size: 13px; box-shadow: 2px 2px 0 var(--ink); white-space: nowrap; }
.center-current:hover { background: var(--red-deep); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 18px; font-size: 13px; color: var(--ink-soft); }
.legend li { display: flex; align-items: center; gap: 6px; }
.mark { padding: 0 7px; border-radius: 999px; font-weight: 700; font-size: 12px; line-height: 1.7; }
.mark-current { background: var(--red); color: #fff; }
.mark-sf { background: var(--teal); color: #fff; border: 1.5px solid var(--ink); }
.sf-row dt { line-height: 1.4 !important; padding-top: 4px; }
.sf-list { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.sf-item { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 10px; background: var(--teal-soft); border: 1.5px solid var(--ink); border-radius: 10px; text-align: left; font-size: 14px; }
.sf-item:hover { background: #c3e2d6; }
.sf-label { padding: 0 6px; background: var(--teal); color: #fff; border-radius: 5px; font-weight: 700; font-size: 12px; line-height: 1.6; }
.sf-stars { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-left: auto; font-family: var(--display); font-weight: 700; font-size: 15px; }
.sf-stars > span { display: inline-flex; align-items: center; gap: 3px; }
.sf-stars .hua { width: 16px; height: 16px; font-size: 10px; }
.sf-stars .muted { font-family: var(--sans); font-weight: 400; font-size: 13px; }
.flow-tag:empty { display: none; }
.flow-tag { position: absolute; left: 50%; bottom: 6px; z-index: 1; transform: translateX(-50%); padding: 0 7px; background: var(--blue); color: #fff; border: 1.5px solid var(--ink); border-radius: 999px; font: 700 11px/1.6 var(--sans); white-space: nowrap; }
.hua-flow { background: #fff !important; border: 2px solid var(--hc, var(--teal)); color: var(--hc, var(--teal)); }
.hua-flow[data-hua=化权] { --hc: var(--red); }
.hua-flow[data-hua=化科] { --hc: var(--blue); }
.hua-flow[data-hua=化忌] { --hc: var(--ink); }
.flow-aux { display: none; }
.palace-aux .hua { width: 15px; height: 15px; margin-left: 2px; font-size: 9px; vertical-align: -2px; }
.star-aux { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 13px; line-height: 1.4; color: var(--ink-soft); white-space: nowrap; }
.star-aux .hua { width: 17px; height: 17px; font-size: 10px; }
.flow-hua { margin: 0 0 18px; }
.flow-hua-title { margin-bottom: 8px; font-weight: 700; font-size: 14px; }
.flow-hua-title small { margin-left: 6px; font-weight: 400; font-size: 12px; color: var(--ink-soft); }
.flow-hua-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.flow-hua-item { width: 100%; display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: #fff; border: 1.5px solid var(--ink); border-radius: 10px; text-align: left; font-size: 14px; }
.flow-hua-item:hover:not(:disabled) { background: var(--yellow-soft); }
.flow-hua-item b { font-family: var(--display); font-size: 16px; }
.flow-hua-item .muted { margin-left: auto; font-size: 13px; white-space: nowrap; }
.chip-flow { background: #fff; }
.mark-flow { background: var(--blue); color: #fff; border: 1.5px solid var(--ink); }

/* 大限时间轴 */
.timeline-card { margin-top: 32px; padding: 24px 26px 26px; }
.timeline-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px 24px; flex-wrap: wrap; }
.timeline-head h3 { font: 900 24px/1.3 var(--display); letter-spacing: 2px; }
.timeline-head p { font-size: 14px; color: var(--ink-soft); }
.year-stepper { display: flex; align-items: center; gap: 6px; }
.year-stepper > button:not(.year-now) { width: 38px; height: 38px; border: var(--line); border-radius: 50%; background: var(--card); font-size: 22px; line-height: 1; box-shadow: 2px 2px 0 var(--ink); }
.year-stepper > button:disabled { opacity: .35; cursor: default; }
.year-stepper output { min-width: 8.5em; text-align: center; font: 900 18px/1 var(--display); letter-spacing: 1px; }
.year-now { margin-left: 4px; padding: 6px 12px; border: var(--line); border-radius: 999px; background: var(--yellow); font-weight: 700; font-size: 13px; box-shadow: 2px 2px 0 var(--ink); }
.year-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 18px; }
.pill { padding: 2px 12px; border: 1.5px solid var(--ink); border-radius: 999px; background: #fff; font-weight: 700; font-size: 14px; }
.pill-flow { background: var(--blue); color: #fff; }
.timeline { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0; border: var(--line); border-radius: 12px; overflow: hidden; }
.timeline li + li { border-left: 2px solid var(--ink); }
.seg { position: relative; width: 100%; height: 100%; min-height: 118px; display: flex; flex-direction: column; gap: 2px; padding: 10px 8px 26px; background: var(--card); text-align: left; transition: background .15s; }
.seg:hover { background: var(--yellow-soft); }
.seg[aria-pressed=true] { background: var(--yellow); }
.seg.is-current { box-shadow: inset 0 -6px 0 var(--red); }
.seg.is-current .seg-age { background: var(--red); color: #fff; }
.seg-age { align-self: flex-start; padding: 0 6px; border-radius: 6px; background: var(--ink); color: var(--card); font-weight: 700; font-size: 12px; line-height: 1.7; white-space: nowrap; }
.seg-name { margin-top: 4px; font: 900 17px/1.3 var(--display); white-space: nowrap; }
.seg-stars { font-size: 12px; line-height: 1.4; color: var(--ink-soft); }
.seg-years { position: absolute; left: 8px; bottom: 9px; font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.seg-marker:empty { display: none; }
.seg-marker { position: absolute; bottom: 0; height: 24px; width: 0; border-left: 2px dashed var(--blue); font-size: 0; color: transparent; }
.seg.has-year .seg-years { visibility: hidden; }
.seg-marker::before { content: ""; position: absolute; left: -6px; top: -5px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); border: 1.5px solid var(--ink); }

.palace-card { position: sticky; top: calc(var(--bar-h) + 72px); padding: 26px 26px 22px; }
.palace-kicker { font-weight: 700; font-size: 13px; color: var(--red-deep); letter-spacing: 1px; }
.palace-card h3 { margin: 2px 0 16px; font: 900 34px/1.25 var(--display); letter-spacing: 3px; }
.palace-list > div { display: grid; grid-template-columns: 3.2em 1fr; gap: 12px; padding: 12px 0; border-top: 2px dashed #1d1a1626; }
.palace-list dt { font-weight: 700; font-size: 14px; color: var(--ink-soft); line-height: 30px; }
.palace-list dd { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; min-height: 30px; font-size: 15px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 11px; border: var(--line); border-radius: 999px; font-weight: 700; font-size: 15px; background: #fff; }
.chip-main { background: var(--yellow); font-family: var(--display); font-size: 18px; }
.chip .hua { width: 18px; height: 18px; font-size: 11px; }
.palace-card .btn { width: 100%; margin: 10px 0 14px; }

/* 解读 */
.reading-wrap { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
.topics { position: sticky; top: calc(var(--bar-h) + 72px); display: flex; flex-direction: column; gap: 8px; }
.topic { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 14px; border: var(--line); border-radius: 12px; background: var(--card); font-weight: 700; font-size: 16px; text-align: left; white-space: nowrap; transition: transform .12s, box-shadow .12s; }
.topic::before { content: ""; width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--dot, var(--teal)); border: 1.5px solid var(--ink); }
.topic:nth-child(4n+2) { --dot: var(--red); }
.topic:nth-child(4n+3) { --dot: var(--yellow); }
.topic:nth-child(4n+4) { --dot: var(--blue); }
.topic:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.topic[aria-pressed=true] { background: var(--ink); color: var(--yellow); box-shadow: 3px 3px 0 var(--red); }

.article { padding: 34px 40px 32px; max-width: 800px; }
.article-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding-bottom: 20px; border-bottom: var(--line); }
.article-kicker { font-weight: 700; font-size: 14px; color: var(--red-deep); letter-spacing: 2px; }
.article-head h3 { margin-top: 4px; font: 900 30px/1.4 var(--display); letter-spacing: 1px; }
.mode { flex: none; }
.mode button { min-height: 38px; padding: 0 16px; font-size: 14px; }
.prose { font-size: 17px; line-height: 1.95; }
.prose p { margin-bottom: 1.1em; }
.prose h4 { margin: 1.8em 0 .7em; padding-left: 12px; border-left: 6px solid var(--red); font: 900 21px/1.4 var(--display); letter-spacing: 1px; }
.prose hr { margin: 1.8em 0; border: 0; border-top: 2px dashed #1d1a1633; }
.prose strong { font-weight: 700; }
.prose .bullet { padding-left: 1.1em; text-indent: -1.1em; font-size: 15px; line-height: 1.8; color: var(--ink-soft); margin-bottom: .6em; }
/* 结构化解读 */
.digest { display: flex; flex-direction: column; gap: 22px; margin-bottom: 26px; }
.portrait { font-size: 17px; line-height: 1.95; }
.portrait::first-letter { float: left; margin: 6px 10px 0 0; font: 900 58px/0.9 var(--display); color: var(--red); }
.borrow-note { padding: 10px 14px; background: var(--yellow-soft); border: 2px dashed var(--ink); border-radius: 12px; font-size: 14px; line-height: 1.75; }
.panel { position: relative; margin-top: 4px; padding: 32px 20px 16px; border: var(--line); border-radius: 14px; }
.panel h4 { position: absolute; top: -14px; left: 16px; padding: 1px 12px 2px; border: var(--line); border-radius: 999px; background: var(--card); font: 700 14px/1.5 var(--sans); letter-spacing: 2px; }
.panel p { font-size: 16px; line-height: 1.9; }
.panel p + p { margin-top: .8em; }
.panel-advice { background: var(--yellow); box-shadow: 4px 4px 0 var(--ink); }
.panel-advice h4 { background: var(--ink); color: var(--yellow); }
.panel-advice p { font-size: 17px; font-weight: 500; }
.panel-core { background: #fff; }
.panel-core h4 { background: var(--teal); color: #fff; }
.panel-core p { font-size: 15px; color: #37322b; }
.panel .more { margin: 8px 0 0; padding: 4px 0; color: var(--teal-deep); font-weight: 700; }
.panel-risk { background: #fde3dc; }
.panel-risk h4 { background: var(--red); color: #fff; }
.panel ul { display: flex; flex-direction: column; gap: 8px; }
.panel li { position: relative; padding-left: 18px; font-size: 15px; line-height: 1.75; }
.panel li::before { content: ""; position: absolute; left: 2px; top: .65em; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 1.5px solid var(--ink); }
.panel-terms { background: var(--card); border-style: dashed; }
.panel-terms dl { display: flex; flex-direction: column; gap: 10px; }
.panel-terms div { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: baseline; }
.panel-terms dt { padding: 0 9px; background: var(--blue); color: #fff; border-radius: 6px; font-weight: 700; font-size: 13px; line-height: 1.7; white-space: nowrap; }
.panel-terms dd { font-size: 14px; line-height: 1.7; color: var(--ink-soft); }
.prompts { margin: 4px 0 0; display: flex; flex-direction: column; gap: 4px; }
.prompts li { position: relative; padding-left: 1.3em; }
.prompts li::before { content: "？"; position: absolute; left: 0; font-weight: 900; color: var(--teal-deep); }
.note p + .prompts { margin-top: 10px; padding-top: 10px; border-top: 2px dashed #1d1a1633; }
.muted { color: var(--ink-soft); font-size: 14px; }
.chip-borrowed { background: var(--card); border-style: dashed; font-family: var(--display); font-size: 17px; }
.note { margin: 8px 0 26px; padding: 14px 18px; background: var(--teal-soft); border: var(--line); border-radius: 12px; font-size: 15px; line-height: 1.8; }
.note::before { content: "问问自己"; display: block; font-weight: 700; font-size: 13px; color: var(--teal-deep); letter-spacing: 2px; }
.note.is-warn { background: var(--pink); }
.note.is-warn::before { content: "请注意"; color: var(--red-deep); }
.full-text { margin-bottom: 26px; }
.fold-bar { display: flex; justify-content: flex-end; margin: -6px 0 8px; }
.fold-bar .link-button { margin: 0; color: var(--teal-deep); font-weight: 700; }
.fold { border-top: 2px dashed #1d1a1633; }
.fold:last-child { border-bottom: 2px dashed #1d1a1633; }
.fold summary { display: flex; align-items: center; gap: 10px; padding: 12px 2px; cursor: pointer; list-style: none; font: 900 18px/1.4 var(--display); letter-spacing: 1px; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: ""; width: 6px; height: 20px; flex: none; background: var(--red); border-radius: 2px; }
.fold summary::after { content: "+"; margin-left: auto; width: 26px; height: 26px; display: grid; place-items: center; border: 1.5px solid var(--ink); border-radius: 50%; font: 700 16px/1 var(--sans); }
.fold[open] summary::after { content: "−"; background: var(--ink); color: var(--yellow); }
.fold summary:hover { color: var(--red-deep); }
.fold-body { padding: 2px 2px 14px; }
.tagline-hint { display: inline-block; margin-top: 10px; padding: 3px 12px; background: var(--yellow-soft); border: 1.5px solid var(--ink); border-radius: 10px; font-size: 14px; line-height: 1.7; }
.tagline-hint b { color: var(--red-deep); }
.evidence { border: var(--line); border-radius: 12px; background: #fff; }
.evidence summary { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-weight: 700; font-size: 15px; cursor: pointer; list-style: none; }
.evidence summary::-webkit-details-marker { display: none; }
.evidence .i-chevron { margin-left: auto; transition: transform .15s; }
.evidence[open] .i-chevron { transform: rotate(180deg); }
#evidence-body { padding: 4px 16px 0; font-size: 14px; line-height: 1.8; }
#evidence-body p { margin-bottom: 10px; }
.evidence .fineprint { margin: 4px 16px 14px; padding-top: 12px; border-top: 2px dashed #1d1a1626; }

/* ── 页脚 ── */
footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 24px; padding: 18px 28px; background: var(--ink); color: #d9d1bf; font-size: 13px; }

/* ── 中等宽度 ── */
@media (max-width: 1040px) {
  .timeline { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .timeline li:nth-child(7) { border-left: 0; }
  .timeline li:nth-child(n+7) { border-top: 2px solid var(--ink); }
  .hero { grid-template-columns: 1fr; gap: 40px; padding-top: 48px; padding-bottom: 80px; }
  .hero-art { left: auto; right: -260px; top: 220px; transform: translateY(-50%); }
  .art-cloud { display: none; }
  .form-card { max-width: 520px; }
  .chart-wrap { grid-template-columns: 1fr; }
  .board { max-width: 700px; width: 100%; margin: 0 auto; }
  .palace-card { position: static; max-width: 700px; width: 100%; margin: 0 auto; }
  .reading-wrap { grid-template-columns: 1fr; gap: 20px; }
  .topics { position: static; flex-direction: row; overflow-x: auto; margin: 0 -28px; padding: 2px 28px 8px; scrollbar-width: none; }
  .topics::-webkit-scrollbar { display: none; }
  .topic { flex: none; border-radius: 999px; font-size: 15px; }
  .article { max-width: none; }
}

/* ── 手机 ── */
@media (max-width: 640px) {
  :root { --bar-h: 56px; --shadow: 4px 4px 0 var(--ink); }
  .bar { padding: 0 16px; gap: 10px; }
  .seal { width: 32px; height: 32px; font-size: 18px; }
  .brand-name { font-size: 19px; letter-spacing: 2px; }
  .bar-birth { display: none; }
  .bar-actions { margin-left: auto; gap: 8px; }
  .bar-actions .btn { min-height: 38px; padding: 0 12px; font-size: 13px; gap: 5px; box-shadow: 2px 2px 0 var(--ink); }
  .bar-actions .icon { width: 16px; height: 16px; }

  .hero { padding: 32px 16px 64px; gap: 28px; }
  .hero-art { width: 420px; height: 420px; right: -210px; top: -60px; transform: none; }
  .hero h1 { margin: 16px 0 14px; font-size: 44px; }
  .hero-sub { font-size: 16px; }
  .hero-facts { gap: 8px; margin-top: 22px; }
  .hero-facts li { padding: 8px 12px 9px; }
  .hero-facts b { font-size: 21px; }
  .hero-facts span { font-size: 12px; }
  .form-card { padding: 22px 18px 18px; box-shadow: 5px 5px 0 var(--ink); }
  .form-card h2 { font-size: 26px; }
  .steps { font-size: 13px; gap: 8px; padding: 16px 12px 22px; }
  .steps li + li::before { margin-right: 2px; }
  .step-num { width: 26px; height: 26px; font-size: 13px; }

  .result { padding: 24px 16px 52px; }
  .result-head h1 { font-size: 36px; letter-spacing: 2px; }
  .facts { gap: 8px; }
  .facts div { padding: 5px 11px 6px; }
  .facts dd { font-size: 15px; }
  .jump { margin: 20px -16px 0; padding: 8px 16px; gap: 8px; overflow-x: auto; }
  .jump-link { padding: 4px 12px; font-size: 13px; }
  .block { margin-top: 32px; }
  .block-title { gap: 12px; margin-bottom: 16px; }
  .block-num { width: 44px; height: 44px; font-size: 21px; }
  .block-title h2 { font-size: 25px; letter-spacing: 2px; }
  .block-title p { font-size: 14px; }

  .chart-wrap { gap: 20px; }
  .board { border-radius: 12px; }
  .palace { padding: 5px 5px 4px; }
  .palace-name { padding: 0 5px 1px; font-size: 11px; border-radius: 4px; }
  .palace-branch { font-size: 12px; }
  .palace-stars { margin-top: 3px; gap: 0; }
  .star { font-size: 15px; gap: 2px; line-height: 1.25; }
  .star-none { font-size: 11px; }
  .hua { width: 14px; height: 14px; font-size: 9px; }
  .palace-aux { display: none; }
  .palace-foot { font-size: 9px; padding-top: 0; line-height: 1.2; }
  .tag-shen { padding: 0 4px; }
  .palace.is-current { box-shadow: inset 0 0 0 3px var(--red); }
  .age-current { padding: 0 3px; }
  .age-current::before { content: ""; }
  .sf-tag { right: 3px; top: 3px; bottom: auto; width: 16px; height: 16px; font-size: 9px; }
  .palace.in-sf .palace-branch { visibility: hidden; }
  .center-current { font-size: 10px; padding: 2px 8px; }
  .legend { gap: 6px 12px; font-size: 12px; margin-top: 14px; }
  .flow-hua-list { grid-template-columns: 1fr 1fr; gap: 6px; }
  .flow-aux { display: block; }
  .flow-aux:empty { display: none; }
  .palace:has(.flow-aux:not(:empty)) .star { line-height: 1.12; }
  .palace:has(.flow-aux:not(:empty)) .palace-stars { margin-top: 2px; }
  .palace:has(.flow-aux:not(:empty)) .palace-foot { line-height: 1; }
  .flow-hua-item { padding: 6px 8px; font-size: 13px; }
  .star-aux { font-size: 10px; gap: 2px; margin-top: 0; line-height: 1.3; }
  .star-aux .hua { width: 13px; height: 13px; font-size: 8px; }
  .hua-flow { border-width: 1.5px; }
  .flow-tag { bottom: auto; top: 4px; left: auto; right: 3px; transform: none; padding: 0 4px; font-size: 9px; line-height: 1.5; }
  .palace.is-flow .palace-branch { visibility: hidden; }
  .palace.is-flow .sf-tag { top: auto; bottom: 3px; }
  .timeline-card { margin-top: 24px; padding: 18px 16px 18px; }
  .timeline-head h3 { font-size: 21px; }
  .year-stepper { width: 100%; }
  .year-stepper output { flex: 1; font-size: 16px; }
  .year-summary { margin: 12px 0 14px; gap: 6px; }
  .pill { font-size: 13px; padding: 1px 10px; }
  .timeline { display: flex; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .timeline li { flex: 0 0 96px; scroll-snap-align: start; }
  .timeline li:nth-child(n+7) { border-top: 0; }
  .timeline li:nth-child(7) { border-left: 2px solid var(--ink); }
  .board-center { gap: 8px; padding: 8px; }
  .center-kicker { font-size: 10px; padding: 1px 9px; }
  .center-meta { font-size: 11px; line-height: 1.7; }
  .palace-card { padding: 20px 18px 16px; }
  .palace-card h3 { font-size: 28px; }

  .topics { margin: 0 -16px; padding: 2px 16px 8px; }
  .article { padding: 22px 18px 20px; }
  .article-head { flex-direction: column; gap: 14px; margin-bottom: 18px; padding-bottom: 16px; }
  .article-head h3 { font-size: 24px; }
  .mode { align-self: stretch; }
  .prose { font-size: 16px; line-height: 1.9; }
  .prose h4 { font-size: 19px; }
  .portrait { font-size: 16px; line-height: 1.9; }
  .portrait::first-letter { font-size: 50px; }
  .panel { padding: 30px 15px 14px; }
  .panel-advice p { font-size: 16px; }
  footer { padding: 16px; font-size: 12px; }
}

@media (max-width: 350px) {
  .btn-text { display: none; }
  .bar-actions .btn { padding: 0 11px; }
  .star { font-size: 14px; }
  .field-row:not(.tight) { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ── 打印 / 存为 PDF ── */
.inline-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; font: inherit; }
.print-view { display: none; }

@page { size: A4; margin: 14mm 14mm 16mm; }
@media print {
  html, body { background: #fff; }
  body { display: block; min-height: 0; font-size: 11pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body > *:not(.print-view) { display: none !important; }
  .print-view { display: block; color: var(--ink); }
  .print-view .card, .print-view .board, .print-view .panel-advice { box-shadow: none; }

  .pv-head { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: var(--line); }
  .pv-brand { display: flex; align-items: center; gap: 8px; }
  .pv-brand .seal { width: 28px; height: 28px; font-size: 16px; }
  .pv-brand .brand-name { font-size: 15px; letter-spacing: 2px; }
  .pv-head h1 { font: 900 30px/1.2 var(--display); letter-spacing: 3px; }
  .pv-head .facts div { padding: 3px 9px 4px; border-radius: 8px; }
  .pv-head .facts dt { font-size: 9pt; }
  .pv-head .facts dd { font-size: 10.5pt; }

  .pv-chart { margin-top: 14px; break-after: page; }
  .pv-chart h2, .pv-topic h2 { font: 900 18px/1.35 var(--display); letter-spacing: 1px; margin-bottom: 10px; }
  .pv-chart .board { width: 100%; max-width: 170mm; margin: 0 auto; border-radius: 10px; }
  .pv-chart .palace { padding: 8px 8px 6px; }
  .pv-chart .palace-aux { display: -webkit-box; }
  .pv-chart .star { font-size: 19px; }
  .pv-chart .board-center { background: var(--teal); }
  .pv-now { margin-top: 12px; font-size: 10.5pt; line-height: 1.7; }
  .pv-chart .legend { margin-top: 8px; font-size: 9pt; }

  .pv-topic { padding-top: 14px; margin-top: 16px; border-top: var(--line); }
  .pv-topic:first-of-type { margin-top: 0; border-top: 0; padding-top: 0; }
  .pv-topic h2 { break-after: avoid; }
  .pv-topic .article-kicker { font-size: 10pt; }
  .pv-topic .tagline-hint { margin: 0 0 10px; font-size: 9.5pt; }
  .pv-topic .digest { gap: 16px; margin: 6px 0 12px; }
  .pv-topic .portrait, .pv-topic .panel p { font-size: 10.5pt; line-height: 1.75; }
  .pv-topic .portrait::first-letter { font-size: 40px; }
  .pv-topic .panel { margin-top: 6px; padding: 30px 14px 10px; break-inside: avoid; }
  .pv-topic .panel-core { break-inside: auto; }
  .pv-topic .panel h4 { font-size: 10pt; }
  .pv-topic .panel li, .pv-topic .panel-terms dd { font-size: 9.5pt; }
  .pv-topic .borrow-note { font-size: 9.5pt; }
  .pv-prompts { margin: 0; padding: 8px 12px; font-size: 9.5pt; break-inside: avoid; }
  .pv-foot { margin-top: 20px; padding-top: 10px; border-top: 2px dashed #1d1a1666; font-size: 8.5pt; line-height: 1.7; color: var(--ink-soft); break-inside: avoid; }
}
