/* 《投资人的一生》界面样式。视觉稿 design/project/*.dc.html（暖纸风，390 宽手机优先，720 宽两栏）。
   全局约束：375px 宽无横向滚动、字号 ≥ 14px、可点区 ≥ 40px。配色 token 照抄视觉稿。 */
:root {
  --paper: #F4EFE6;
  --card: #FBF8F2;
  --ink: #2B2622;
  --muted: #6B6258;
  --line: #d8cfc0;
  --track: #e6ddcf;
  --red: #C0392B;
  --red-dark: #8f2a1f;
  --orange: #E08D3C;
  --green: #4a7c59;
  --blue: #2B6CB0;
  --brown: #8a5a2b;
  --white: #FFFFFF;
  --serif: 'Noto Serif SC', Georgia, 'Songti SC', serif;
  --sans: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  overscroll-behavior-y: contain; /* 手机上往下拉不触发刷新（终审 R5；真刷新了也能从 sessionStorage 续局） */
}
a { color: var(--red); }
a:hover { color: var(--red-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 700; }

#app { min-height: 100vh; }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.muted { color: var(--muted); }
.nw { white-space: nowrap; }
.label { font-size: 14px; color: var(--muted); }
.kicker { font-size: 14px; color: var(--orange); font-weight: 700; letter-spacing: 0.12em; }
.rule { height: 1px; background: var(--line); }
.foot { text-align: center; font-size: 14px; color: var(--muted); line-height: 1.6; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 按钮 */
.btn-primary {
  display: flex; align-items: center; justify-content: center;
  min-height: 54px; width: 100%; padding: 0 16px;
  border: none; border-radius: 14px;
  background: var(--red); color: var(--white);
  font-size: 18px; font-weight: 700; letter-spacing: 0.06em;
}
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost {
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 22px;
  background: var(--card); color: var(--ink); font-size: 15px;
}
.link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0;
  border: none; background: none; color: var(--red); font-size: 14px; font-weight: 600; text-decoration: none;
}
.pill {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); color: var(--muted); font-size: 14px; white-space: nowrap;
}
.pill-ink { border-color: var(--ink); color: var(--ink); font-weight: 600; }

/* 分段按钮 */
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; min-height: 44px; padding: 0 10px;
  border: 1px solid var(--ink); border-radius: 10px;
  background: var(--card); color: var(--ink); font-size: 16px; font-weight: 600;
}
.seg-round .seg-btn { border-color: var(--line); border-radius: 22px; font-size: 15px; font-weight: 400; }
.seg-btn.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.seg-origin .seg-btn { flex: 1 1 auto; }
.seg-origin .seg-narrow { flex: 0 0 96px; }
.seg-pill { gap: 0; border: 1px solid var(--ink); border-radius: 20px; overflow: hidden; }
.seg-pill .seg-btn { min-height: 40px; border: none; border-radius: 0; font-size: 14px; font-weight: 400; padding: 0 12px; flex: 0 0 auto; }

/* 开局 */
.start-grid { display: flex; flex-direction: column; gap: 18px; }
.start-intro, .start-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.topline { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.title { font-family: var(--serif); font-size: 34px; line-height: 1.25; color: var(--red); }
.title-sm { font-size: 26px; }
.lede { font-size: 15px; line-height: 1.7; color: var(--muted); }
.form { gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; }
.big-year { font-family: var(--serif); font-size: 28px; font-weight: 700; }
.range { width: 100%; height: 44px; margin: 0; accent-color: var(--red); }
.ticks { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.hint { font-size: 14px; color: var(--muted); line-height: 1.6; }
.origin-manual { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.text, .select {
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--white); font-size: 16px;
}
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.check input { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; accent-color: var(--red); }

/* 顶栏与六维 */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.when { font-family: var(--serif); font-size: 20px; font-weight: 700; white-space: nowrap; }
.when small { color: var(--muted); font-size: 15px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.dims { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.dim { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.dim-name, .dim-val { font-size: 14px; }
.dim-name { color: var(--muted); }
.dim-bar { display: block; width: 100%; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.dim-bar i { display: block; height: 6px; border-radius: 3px; }

/* 年卡 */
.year-grid { display: flex; flex-direction: column; gap: 14px; }
.headline { font-size: 15px; line-height: 1.7; }
.macro { font-size: 14px; color: var(--muted); }
.choices { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.opt {
  display: flex; align-items: stretch;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.opt-main {
  flex: 1; min-width: 0; min-height: 56px; text-align: left; padding: 12px 14px;
  border: none; background: transparent; display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.opt-main:hover, .act:hover, .opt-side:hover, .tool:hover { background: #f1eadf; }
.opt-text { font-size: 16px; font-weight: 600; line-height: 1.5; }
.opt-prob { font-size: 14px; color: var(--muted); }
.opt-quote { color: var(--ink); } /* 买房卡的房价、首付、月供（终审 S2） */
.opt-side {
  flex: 0 0 56px; border: none; border-left: 1px solid var(--line); background: transparent;
  color: var(--red); font-size: 14px; font-weight: 600; line-height: 1.4;
}
.opt-stay { background: var(--paper); border-style: dashed; }
.opt-group { flex-direction: column; }
.opt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; flex-wrap: wrap; }
.opt-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 160px; }
.opt-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tool {
  min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 20px;
  background: transparent; color: var(--red); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.opt-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.act {
  min-height: 48px; padding: 6px 10px; border: none;
  background: var(--card); font-size: 15px; font-weight: 600; line-height: 1.4;
}
.act:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* 结果态 */
.result { gap: 12px; }
.picked { font-size: 14px; color: var(--muted); }
.line { font-size: 16px; line-height: 1.7; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { font-size: 14px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.ledger-line { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ledger-line div { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: var(--paper); border-radius: 10px; min-width: 0; }
.ledger-line dt { font-size: 14px; color: var(--muted); }
.ledger-line dd { margin: 0; font-size: 15px; font-weight: 600; }
.fx-note { font-size: 14px; } /* 搬家那年：上一年末的钱折成了多少（终审 S1） */
.event { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-left: 3px solid var(--orange); background: var(--paper); border-radius: 0 10px 10px 0; }
.event-family { border-left-color: var(--muted); }
.event-property { border-left-color: var(--brown); }
.death { font-family: var(--serif); font-size: 18px; font-weight: 700; color: var(--red); }

/* 停顿 */
.pause { gap: 14px; }
.birth { font-size: 15px; line-height: 1.8; color: var(--muted); }
.pause-kicker { font-family: var(--serif); font-size: 26px; }
.question { font-size: 18px; line-height: 1.7; }
.textarea { width: 100%; min-height: 110px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); font-size: 16px; line-height: 1.6; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; }
.row .btn-primary { flex: 1; min-height: 48px; font-size: 16px; }

/* 财富面板 */
.back { font-size: 15px; }
.wealth-head { display: flex; flex-direction: column; gap: 2px; }
.worth-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.worth { font-family: var(--serif); font-size: 34px; font-weight: 700; }
.books { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.book { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.book-total { font-size: 20px; font-weight: 700; }
.book-parts { font-size: 14px; color: var(--muted); line-height: 1.5; }
.wealth-grid { display: flex; flex-direction: column; gap: 14px; }
.chart-card { padding: 14px; gap: 8px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.chart-title { font-size: 15px; font-weight: 600; }
.chart { width: 100%; min-width: 0; }
.chart svg text { font-family: var(--sans); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.legend-inline { font-size: 14px; }
.swatch-line, .swatch-dash { display: inline-block; width: 16px; height: 0; margin-right: 4px; vertical-align: middle; }
.swatch-line { border-top: 3px solid var(--red); }
.swatch-dash { border-top: 2px dashed var(--muted); }
.houses { gap: 10px; }
.house { display: flex; flex-direction: column; gap: 6px; font-size: 14px; padding-top: 8px; border-top: 1px solid var(--line); }
.house:first-of-type { border-top: none; padding-top: 0; }
.house-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.house-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; color: var(--muted); }
.house-event { display: flex; gap: 8px; align-items: baseline; padding: 10px 12px; background: var(--paper); border-radius: 10px; font-size: 14px; }
.house-event b { color: var(--red); flex: 0 0 auto; }

/* 底部弹层 */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(43, 38, 34, 0.35); z-index: 10; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 560px; margin: 0 auto; max-height: 82vh; overflow-y: auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--card); border: 1px solid var(--orange); border-bottom: none; border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 -8px 24px rgba(43, 38, 34, 0.12);
}
.sheet-title { font-family: var(--serif); font-size: 20px; }
.tier { font-weight: 700; color: var(--orange); }
.src-link { display: inline-flex; align-items: center; min-height: 40px; font-weight: 600; }
.sheet-close { align-self: stretch; margin-top: 6px; }
.spark { width: 100%; }
.kv { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kv div { padding: 8px 10px; background: var(--paper); border-radius: 10px; }
.kv dt { font-size: 14px; color: var(--muted); }
.kv dd { margin: 0; font-size: 17px; font-weight: 700; }

/* 720 宽：两栏 */
@media (min-width: 700px) {
  .page { padding: 24px 16px 32px; }
  .start-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 24px; align-items: start; }
  .start-intro { position: sticky; top: 24px; }
  .year-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .year-grid > .world { position: sticky; top: 16px; }
  .books { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .wealth-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .pause { max-width: 560px; width: 100%; margin: 0 auto; }
}

/* 总结屏（视觉稿 Summary.dc.html；手机上雷达与曲线上下两张，≥ 560px 并排） */
.sum-head { display: flex; flex-direction: column; gap: 6px; }
.sum-title { font-family: var(--serif); font-size: 30px; line-height: 1.3; word-break: keep-all; }
.sum-charts { display: flex; flex-direction: column; gap: 14px; }
.card-title { font-size: 16px; font-weight: 600; }
.rank-card { border-color: var(--red); gap: 6px; }
.rank-text { font-family: var(--serif); font-size: 17px; line-height: 1.6; }
.busy { display: block; position: relative; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.busy i { position: absolute; top: 0; bottom: 0; left: -30%; width: 30%; border-radius: 2px; background: var(--orange); animation: busy 1.4s ease-in-out infinite; }
@keyframes busy { from { left: -30%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .busy i { animation: none; left: 0; width: 100%; opacity: 0.4; } }
.decisions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.5; }
.decisions li { display: flex; justify-content: space-between; gap: 10px; }
.decisions b { flex: 0 0 auto; white-space: nowrap; font-weight: 700; }
.decisions b.up { color: var(--green); }
.decisions b.down { color: var(--red); }
.decisions-all { font-size: 14px; }
.quote { margin: 0; display: flex; flex-direction: column; gap: 6px; padding: 12px 16px; border-left: 3px solid var(--orange); background: var(--card); border-radius: 0 12px 12px 0; }
.quote p { font-family: var(--serif); font-size: 16px; line-height: 1.6; }
.sum-note { font-size: 15px; line-height: 1.7; }
.sum-actions { display: flex; flex-direction: column; gap: 10px; }
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1 1 0; min-width: 0; }
.btn-line {
  min-height: 48px; padding: 0 12px;
  border: 1px solid var(--ink); border-radius: 12px; background: transparent; color: var(--ink); font-size: 15px; font-weight: 600;
}
.btn-line.on { background: var(--ink); color: var(--paper); }
.btn-line:disabled, .btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-feedback {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; width: 100%; padding: 8px 16px;
  border: 1px dashed var(--muted); border-radius: 12px; background: transparent; color: var(--ink); font-size: 18px; font-weight: 700;
}
.btn-feedback span { font-size: 14px; font-weight: 400; color: var(--muted); }
.sum-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 20px; }
.center { text-align: center; }
.hint .link { margin-left: 6px; vertical-align: middle; }
.copy-box { display: flex; flex-direction: column; gap: 6px; }
.share-url { min-height: 0; font-size: 14px; word-break: break-all; }
.share-link { word-break: break-all; color: var(--ink); }

/* 分享页（视觉稿 Share.dc.html：深色底） */
.shared { min-height: 100vh; background: var(--ink); color: var(--paper); }
.page-shared .sum-title { color: var(--paper); word-break: normal; }
.page-shared .lede { color: var(--line); }
.page-shared .card { color: var(--ink); }
.share-card { border: none; border-radius: 18px; gap: 12px; }
.share-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.share-top > div { display: flex; flex-direction: column; }
.share-rank { align-items: flex-end; text-align: right; }
.share-rank b { font-size: 16px; }
.share-worth { font-family: var(--serif); font-size: 28px; font-weight: 700; }
.share-dims { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; font-size: 14px; color: var(--muted); }
.share-dims div { display: flex; flex-direction: column; gap: 2px; }
.share-dims b { font-size: 16px; color: var(--ink); }
.btn-orange { min-height: 54px; width: 100%; border: none; border-radius: 14px; background: var(--orange); color: var(--ink); font-size: 17px; font-weight: 700; }
.btn-dark-line { min-height: 44px; width: 100%; border: 1px solid var(--muted); border-radius: 12px; background: transparent; color: var(--paper); font-size: 15px; }
.btn-feedback-dark { color: var(--paper); border-color: var(--line); }
.btn-feedback-dark span { color: var(--line); }
.foot-dark { color: var(--line); }
.page-shared .rank-card { border-color: var(--orange); }
/* 分享页：旧数据的提示（终审 R3）、排位「算一算」那一块（终审 R4） */
.stale-note { font-size: 14px; color: var(--ink); background: var(--orange); border-radius: 10px; padding: 8px 12px; }
.rank-go { display: flex; flex-direction: column; gap: 6px; }
.rank-go:empty { display: none; }
.btn-rank { width: 100%; min-height: 44px; }

/* 最近十局 */
.recs { display: flex; flex-direction: column; gap: 10px; }
.rec { gap: 6px; }
.rec-on { border-width: 2px; }
.rec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }

/* 提意见（底部弹层） */
.fb-form { display: flex; flex-direction: column; gap: 8px; }
.fb-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; }
.fb-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fb-hint { color: var(--red); font-size: 14px; }
.fb-fail { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--paper); border-radius: 12px; }
.btn-mail { min-height: 48px; font-size: 16px; text-decoration: none; }
.btn-mail:hover { color: var(--white); }
/* 蜜罐：人看不见、点不到（大小为 0，不占地方），自动填表的程序会填 */
.hp, .hp * { position: absolute; width: 0; height: 0; margin: 0; padding: 0; border: 0; overflow: hidden; opacity: 0; pointer-events: none; }
.sharecard-img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; }
a.btn-primary { text-decoration: none; }
a.btn-primary:hover { color: var(--white); }

@media (min-width: 560px) {
  .sum-charts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
}
@media (min-width: 700px) {
  .page-summary, .page-records { max-width: 720px; }
}
