/* ==========================================================================
   预测豆 Comadou · 数据故事：中国 31 省人口增减与迁移 2010–2030
   --------------------------------------------------------------------------
   来源：独立页面 cn-pyramid.html，全部样式原本写在 <style> 内。
   处理：所有选择器统一 scope 到 #cnpy 容器，避免污染全站（body/html/:root
         已分别映射为 #cnpy / 丢弃 / #cnpy 变量块）。
   注意：本文件只在文章 slug = cn-pyramid 的详情页加载，其它页面零影响。
   版本：2026-11-05
   ========================================================================== */


#cnpy {
  --bg:#f7f4ee;
  --surface:#fffdf8;
  --ink:#191610;
  --ink-2:#3d382e;
  --muted:#7a7264;
  --line:#e3dbcd;
  --line-2:#d3c8b6;
  --accent:#b4432e;
  --accent-soft:#e8b9a8;
  --teal:#2f6b66;
  --shadow:0 1px 2px rgba(60,45,25,.05), 0 8px 28px rgba(60,45,25,.05);
}
#cnpy * {box-sizing:border-box}
#cnpy {
  margin:0;
  background:
    radial-gradient(1200px 600px at 8% -5%, #fffdf6 0%, rgba(255,253,246,0) 60%),
    var(--bg);
  color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  font-size:16px;line-height:1.75;
  -webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;
}
#cnpy .wrap {max-width:1180px;margin:0 auto;padding:0 28px}
#cnpy h1, #cnpy h2, #cnpy h3, #cnpy .serif {font-family:"Songti SC","Noto Serif CJK SC","Source Han Serif SC",Garamond,"Times New Roman",serif}

#cnpy header.masthead {padding:28px 0 14px;border-bottom:1px solid var(--line)}
#cnpy .kicker {display:flex;align-items:center;gap:12px;font-size:12px;letter-spacing:.22em;color:var(--accent);font-weight:600}
#cnpy .kicker::before {content:"";width:34px;height:1px;background:var(--accent);display:block}
#cnpy h1 {font-size:clamp(27px,3.4vw,42px);line-height:1.14;font-weight:700;letter-spacing:-.01em;margin:14px 0 12px;max-width:17em}
#cnpy h1 em {font-style:normal;color:var(--accent)}
#cnpy .lead {font-size:15px;line-height:1.62;max-width:54em;color:var(--ink-2);margin:0 0 16px}
#cnpy .lead b {font-weight:600;color:var(--ink);border-bottom:2px solid var(--accent-soft)}
#cnpy .byline {display:flex;flex-wrap:wrap;gap:6px 20px;font-size:12.5px;color:var(--muted)}
#cnpy .byline span {white-space:nowrap}
#cnpy .byline span::before {content:"";display:inline-block;width:3px;height:3px;background:var(--line-2);border-radius:50%;margin-right:10px;vertical-align:middle}

#cnpy .strip {display:flex;flex-wrap:wrap;gap:8px 30px;align-items:baseline;padding:12px 0 4px;border-bottom:1px solid var(--line)}
#cnpy .strip .item {font-size:12.5px;color:var(--muted)}
#cnpy .strip .item b {font-family:"Songti SC",Georgia,serif;font-size:19px;color:var(--ink);margin-right:4px;font-weight:700}
#cnpy .strip .note {margin-left:auto;font-size:11.5px;color:var(--muted)}

#cnpy main {padding:26px 0 10px}
#cnpy .duo {display:grid;grid-template-columns:minmax(0,1.62fr) minmax(0,1fr);gap:18px;align-items:stretch;margin-bottom:14px}
#cnpy .duo>.block {margin-bottom:0;min-width:0;display:flex;flex-direction:column}
#cnpy .duo>.block>.mapfoot {margin-top:auto}
#cnpy .duo .mapwrap {padding:4px 10px 2px;flex:1;display:flex;align-items:center}
#cnpy .duo .mapwrap #map {margin:0 auto}
#cnpy .block {background:var(--surface);border:1px solid var(--line);border-radius:4px;box-shadow:var(--shadow);margin-bottom:20px}
#cnpy .block-head {display:flex;align-items:flex-end;justify-content:space-between;gap:14px;flex-wrap:wrap;padding:14px 22px 10px;border-bottom:1px solid var(--line)}
#cnpy .eyebrow {font-size:11px;letter-spacing:.14em;color:var(--muted);margin-bottom:3px}
#cnpy .block-head h2 {font-size:clamp(21px,2.4vw,27px);margin:0;line-height:1.25;letter-spacing:-.01em}
#cnpy .block-head p {margin:4px 0 0;font-size:12.5px;color:var(--muted)}

#cnpy /* ---------- map ---------- */
.mapwrap {position:relative;padding:6px 18px 4px}
#cnpy #map {display:block;width:100%;max-width:860px;height:auto;margin:0 auto;overflow:visible}
#cnpy #map .pv {stroke:#fffdf8;stroke-width:.8;transition:fill .35s ease,stroke .15s}
#cnpy #map .pv:hover {stroke:var(--ink);stroke-width:1.2}
#cnpy #map .pv.sel {stroke:var(--ink);stroke-width:1.8;paint-order:stroke}
#cnpy #map .nd {fill:#e9e4d9;stroke:#fffdf8;stroke-width:.8}
#cnpy #map .lbl {font-size:10.5px;fill:#4b4437;text-anchor:middle;pointer-events:none;paint-order:stroke;stroke:#fffdf8;stroke-width:2.6;stroke-linejoin:round}
#cnpy #map .lbl.sel {fill:var(--ink);font-weight:700;font-size:12px}
#cnpy #map .ar {pointer-events:none}
#cnpy #map .insetbox {fill:rgba(255,253,248,.92);stroke:var(--line-2);stroke-width:.8}
#cnpy #map .insetline {fill:none;stroke:#b9b0a0;stroke-width:.7}

#cnpy .mapside {width:186px;flex:none;font-size:11px;color:var(--muted)}
#cnpy .mshead {display:flex;justify-content:space-between;align-items:baseline;gap:8px}
#cnpy .mshead #rampcap {color:var(--muted);font-size:10.5px}
#cnpy .segmini {display:inline-flex;margin-top:7px;border:1px solid var(--line-2);border-radius:3px;overflow:hidden;background:#fff}
#cnpy .segmini button {font:inherit;font-size:10.5px;padding:2px 9px;border:none;background:transparent;color:var(--muted);cursor:pointer;transition:.15s}
#cnpy .segmini button+button {border-left:1px solid var(--line-2)}
#cnpy .segmini button[aria-pressed="true"] {background:var(--ink);color:#fff}
#cnpy .ramp {height:8px;border-radius:1px;margin:6px 0 3px;border:1px solid rgba(0,0,0,.06);background:linear-gradient(to right,#e4dbcb 0%,#dbc6af 25%,#cf9f7e 50%,#ba6e4e 75%,#a63a24 100%)}
#cnpy .rampax {display:flex;justify-content:space-between;font-size:10px;font-variant-numeric:tabular-nums}
#cnpy .mapside .cap {margin-top:2px}

#cnpy .mapfoot {display:flex;flex-wrap:wrap;gap:6px 20px;align-items:center;justify-content:space-between;padding:8px 22px 11px;border-top:1px solid var(--line);font-size:11.5px;color:var(--muted)}
#cnpy .flowbox {display:flex;align-items:center;gap:12px;flex-wrap:wrap}
#cnpy .netbadge {display:none;align-items:center;gap:7px;font-size:11.5px;font-variant-numeric:tabular-nums;
  border:1px solid var(--line-2);border-radius:999px;padding:3px 12px 3px 10px;background:#fff;color:var(--ink-2)}
#cnpy .netbadge.on {display:inline-flex}
#cnpy .netbadge i {width:6px;height:6px;border-radius:50%;flex:none}
#cnpy .netbadge.in i {background:#2f6b66}
#cnpy .netbadge.out i {background:#b4432e}
#cnpy .netbadge b {font-weight:600}
#cnpy .netbadge .dl {color:var(--muted);font-size:10.5px;border-left:1px solid var(--line-2);padding-left:8px;margin-left:2px}
#cnpy .flowhint {color:var(--muted)}
#cnpy .flowrank {font-size:11.5px;color:var(--muted);text-align:right;flex:1;min-width:0}
#cnpy .flowrank b {color:var(--ink-2);font-weight:600;margin-right:6px}
#cnpy .flowrank .warn {display:inline-block;margin-left:4px;padding:1px 6px;border-radius:2px;background:rgba(180,67,46,.09);color:var(--accent);font-size:10.5px;white-space:nowrap}

#cnpy /* ---------- timeline ---------- */
.yearbar {display:flex;align-items:center;gap:16px;padding:10px 22px 12px;flex-wrap:wrap}
#cnpy .playbtn {display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:50%;border:1px solid var(--line-2);background:#fff;color:var(--ink-2);cursor:pointer;flex:none;transition:.15s}
#cnpy .playbtn:hover {background:var(--ink);color:#fff;border-color:var(--ink)}
#cnpy .playbtn svg {width:12px;height:12px;fill:currentColor}
#cnpy .years {position:relative;display:flex;align-items:flex-start;gap:4px;flex:1;min-width:420px}
#cnpy .years::before {content:"";position:absolute;left:2px;right:2px;top:22px;height:1px;background:var(--line-2)}
#cnpy .year {position:relative;z-index:1;display:flex;flex-direction:column;align-items:center;gap:5px;flex:1;padding:44px 0 3px;background:transparent;border:none;font:inherit;font-size:12.5px;color:var(--muted);cursor:pointer;font-variant-numeric:tabular-nums}
#cnpy .year .mb {position:absolute;left:50%;transform:translateX(-50%);width:min(22px,62%);border-radius:1.5px 1.5px 0 0;
  background:var(--teal);opacity:.52;transition:opacity .15s,height .18s,top .18s;pointer-events:none}
#cnpy .year .mb.out {background:var(--accent);border-radius:0 0 1.5px 1.5px}
#cnpy .year .mb.est {background:transparent;box-shadow:inset 0 0 0 1.2px var(--teal)}
#cnpy .year .mb.est.out {box-shadow:inset 0 0 0 1.2px var(--accent)}
#cnpy .year .mb.est:hover {opacity:.15}
#cnpy .year:hover .mb {opacity:.8}
#cnpy .year[aria-pressed="true"] .mb {opacity:.95;width:min(26px,70%)}
#cnpy .year[aria-pressed="true"] {background:transparent}
#cnpy .year .mk {width:11px;height:11px;border-radius:50%;background:var(--surface);border:1.5px solid var(--line-2);transition:.18s}
#cnpy .year.obs .mk {background:var(--ink);border-color:var(--ink)}
#cnpy .year.pred .mk {border-style:dashed;border-color:var(--accent)}
#cnpy .year.back .mk {border-style:dotted;border-color:var(--muted)}
#cnpy .year:hover .mk {transform:scale(1.18)}
#cnpy .year[aria-pressed="true"] {color:var(--ink);font-weight:700}
#cnpy .year[aria-pressed="true"] .mk {background:var(--accent);border-color:var(--accent);box-shadow:0 0 0 4px rgba(180,67,46,.14)}
#cnpy .year[aria-pressed="true"].obs .mk {background:var(--ink);border-color:var(--ink);box-shadow:0 0 0 4px rgba(25,22,16,.12)}
#cnpy .year[aria-pressed="true"].back .mk {background:var(--muted);border-color:var(--muted);box-shadow:0 0 0 4px rgba(122,114,100,.12)}
#cnpy .yeartag {font-size:11.5px;color:var(--teal);white-space:nowrap;font-variant-numeric:tabular-nums;letter-spacing:.01em}
#cnpy .yeartag.neg {color:var(--accent)}
#cnpy .yeartag.hide {opacity:0}

#cnpy /* ---------- stage ---------- */
.stage {padding:16px 22px 10px;position:relative;transition:border-color .2s;container-type:inline-size}
#cnpy .stage-head {display:flex;align-items:flex-end;justify-content:space-between;gap:12px;padding-bottom:8px;border-bottom:1px solid var(--line)}
#cnpy .name-row {display:flex;align-items:center;flex-wrap:wrap;gap:8px 10px}
#cnpy .stage-head h2 {font-size:clamp(21px,2.3vw,27px);margin:0;line-height:1.18;letter-spacing:-.01em}
#cnpy .tier {display:inline-block;padding:2px 8px;border-radius:2px;font-size:11.5px;font-weight:600;letter-spacing:.04em;white-space:nowrap}
#cnpy .tier.t0 {color:#2f6b66;background:rgba(47,107,102,.11)}
#cnpy .tier.t1 {color:#8a6220;background:rgba(192,138,62,.14)}
#cnpy .tier.t2 {color:#b4432e;background:rgba(180,67,46,.12)}
#cnpy .stage-head .total {font-size:13px;color:var(--muted);white-space:nowrap;padding-bottom:4px}
#cnpy .stage-head .total b {font-family:"Songti SC",Georgia,serif;font-size:21px;color:var(--ink);margin-right:2px}
#cnpy .stats {display:grid;grid-template-columns:repeat(4,1fr);border-bottom:1px solid var(--line)}
#cnpy .stat {padding:9px 12px 8px;border-left:1px solid var(--line)}
#cnpy .stat:first-child {border-left:none;padding-left:2px}
#cnpy .stat .k {font-size:10.5px;color:var(--muted);letter-spacing:.08em}
#cnpy .stat .v {font-family:"Songti SC",Georgia,serif;font-size:22px;font-weight:700;line-height:1.18;letter-spacing:-.01em}
#cnpy .stat .v small {font-size:11.5px;margin-left:2px;font-weight:600}
#cnpy .stat .s {font-size:10.5px;color:var(--muted);line-height:1.45;min-height:1.45em}
#cnpy .stat .s .up {color:var(--accent)}
#cnpy .stat .s .down {color:var(--teal)}
#cnpy .stat .s .nw {white-space:nowrap}

#cnpy .toolbar {display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:space-between;margin:9px 0 0}
#cnpy .toggle {display:inline-flex;border:1px solid var(--line-2);border-radius:3px;overflow:hidden;background:#fff}
#cnpy .toggle button {font:inherit;font-size:11.5px;padding:4px 11px;border:none;background:transparent;color:var(--muted);cursor:pointer;transition:.15s}
#cnpy .toggle button+button {border-left:1px solid var(--line-2)}
#cnpy .toggle button[aria-pressed="true"] {background:var(--ink);color:#fff}
#cnpy .hint {font-size:11px;color:var(--muted)}

@container (max-width: 360px){
  #cnpy .stats {grid-template-columns:repeat(2,1fr)}
  #cnpy .stat {padding:10px 10px 9px}
  #cnpy .stat:nth-child(3) {border-left:none;padding-left:2px}
  #cnpy .stat:nth-child(n+3) {border-top:1px solid var(--line)}
  #cnpy .stat .v {font-size:22px}
  #cnpy .stage-head h2 {font-size:24px}
}

#cnpy #pyramid {min-height:280px}
#cnpy #pyramid svg {display:block;width:100%;height:auto;overflow:visible;animation:fade .28s ease-out}
@keyframes fade{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){#cnpy #pyramid svg {animation:none}}
#cnpy .grid {stroke:var(--line);stroke-width:1}
#cnpy .ax {fill:var(--muted);font-size:10.5px;font-variant-numeric:tabular-nums}
#cnpy .ann {fill:var(--muted);font-size:11px}
#cnpy .ann-strong {fill:var(--ink-2);font-size:12px;font-weight:600}
#cnpy .bar {shape-rendering:crispEdges}
#cnpy .caption {font-size:12px;color:var(--muted);margin:10px 0 2px;line-height:1.65;padding-top:10px;border-top:1px solid var(--line)}
#cnpy .caption b {color:var(--ink-2);font-weight:600}

#cnpy /* ---------- appendix ---------- */
.appendix {margin:38px 0 28px;padding:34px 0 6px;border-top:2px solid var(--ink)}
#cnpy .ap-inner {max-width:1000px;margin:0 auto}
#cnpy .ap-head {max-width:48em;margin-bottom:12px}
#cnpy .ap-head h2 {font-size:clamp(26px,3vw,35px);line-height:1.2;margin:10px 0 12px;letter-spacing:-.01em}
#cnpy .ap-head .dek {font-size:15.5px;line-height:1.8;color:var(--ink-2);margin:0}
#cnpy .part {display:grid;grid-template-columns:88px minmax(0,1fr);gap:28px;padding:26px 0 14px;border-top:1px solid var(--line);margin-top:26px}
#cnpy .part:first-of-type {border-top:none;margin-top:8px}
#cnpy .part-no {font-family:"Songti SC",Georgia,serif;font-size:42px;line-height:.92;color:#cdbca8;letter-spacing:-.02em}
#cnpy .part-main {max-width:47em;min-width:0}
#cnpy .part-main h3 {font-size:clamp(21px,2.2vw,25px);margin:0 0 12px;line-height:1.3;letter-spacing:-.01em}
#cnpy .part-main p {margin:0 0 1.05em;font-size:14.5px;line-height:1.95;color:var(--ink-2);text-wrap:pretty}
#cnpy .part-main p.lead {font-size:15.5px;line-height:1.85;color:var(--ink)}
#cnpy .part-main b {color:var(--ink);font-weight:600}
#cnpy .nw {white-space:nowrap}
#cnpy .sub {font-size:11px;letter-spacing:.16em;color:var(--accent);font-weight:600;margin:24px 0 8px}
#cnpy .sub:first-of-type {margin-top:18px}
#cnpy .cit {font-size:10px;color:var(--accent);text-decoration:none;vertical-align:super;line-height:0;margin-left:1px}
#cnpy .cit:hover {text-decoration:underline}
#cnpy .formula {margin:16px 0 20px;padding:15px 20px 13px;background:#fffdf8;border:1px solid var(--line);border-left:2px solid var(--accent-soft);
  font-family:Georgia,"Songti SC",serif;font-size:16px;line-height:1.85;color:var(--ink)}
#cnpy .formula span {display:block}
#cnpy .formula .cap {font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC",sans-serif;font-size:11px;color:var(--muted);margin-top:6px;line-height:1.6}
#cnpy .srctable {width:100%;border-collapse:collapse;margin:8px 0 18px;font-size:12.5px;line-height:1.65;table-layout:fixed}
#cnpy .srctable th {text-align:left;font-weight:600;color:var(--muted);font-size:10.5px;letter-spacing:.1em;padding:0 12px 7px 0;border-bottom:1px solid var(--ink)}
#cnpy .srctable td {padding:9px 12px 9px 0;border-bottom:1px solid var(--line);vertical-align:top;color:var(--ink-2)}
#cnpy .srctable td:first-child {color:var(--ink);font-weight:600;width:34%}
#cnpy .srctable td:nth-child(2) {width:37%}
#cnpy .srctable td:last-child {padding-right:0;color:var(--muted);font-size:11.5px;width:29%}
#cnpy .stats4 {display:grid;grid-template-columns:repeat(4,1fr);border-top:1px solid var(--ink);border-bottom:1px solid var(--line);margin:18px 0 6px}
#cnpy .stats4 div {padding:14px 16px 13px;border-left:1px solid var(--line)}
#cnpy .stats4 div:first-child {border-left:none;padding-left:0}
#cnpy .stats4 b {display:block;font-family:"Songti SC",Georgia,serif;font-size:38px;line-height:1;letter-spacing:-.02em}
#cnpy .stats4 span {display:block;font-size:11.5px;color:var(--muted);line-height:1.5;margin-top:7px}
#cnpy .statsnote {font-size:11px;color:var(--muted);margin:0 0 20px}
#cnpy .refs {margin:14px 0 0;padding:0;list-style:none;columns:2;column-gap:40px;font-size:12px;line-height:1.72;color:var(--muted)}
#cnpy .refs li {break-inside:avoid;margin:0 0 9px;padding-left:24px;text-indent:-24px}
#cnpy .refs li b {color:var(--ink-2);font-weight:600}
#cnpy .refs a {color:var(--accent);text-decoration:none}
#cnpy .refs a:hover {text-decoration:underline}
#cnpy footer {padding:0 0 46px;font-size:11.5px;color:var(--muted)}

#cnpy #tip {position:fixed;z-index:50;pointer-events:none;opacity:0;transition:opacity .1s;background:#fffdf8;border:1px solid var(--line-2);border-radius:3px;padding:8px 11px;font-size:11.5px;line-height:1.55;color:var(--ink-2);box-shadow:0 4px 18px rgba(60,45,25,.12);max-width:250px}
#cnpy #tip.on {opacity:1}
#cnpy #tip b {font-size:12px;color:var(--ink)}
#cnpy #tip .k {color:var(--muted)}
#cnpy #tip .in {color:var(--teal)}
#cnpy #tip .out {color:var(--accent)}

@media (max-width:1100px){
  #cnpy .duo {grid-template-columns:1fr}
}
@media (max-width:900px){
  #cnpy .years {overflow-x:auto;scrollbar-width:none}
  #cnpy .years::-webkit-scrollbar {display:none}
  #cnpy .years::before {display:none}
  #cnpy .year {min-width:42px}
  #cnpy .wrap {padding:0 18px}
  #cnpy header.masthead {padding:40px 0 22px}
  #cnpy .strip .note {display:none}
  #cnpy .mapwrap {padding:4px 10px}
  #cnpy .years {min-width:0;gap:0}
  #cnpy .year {font-size:11px}
  #cnpy .stage-head {flex-wrap:wrap;gap:6px}
  #cnpy .block-head {padding:16px 18px 10px}
  #cnpy .mapfoot {padding:10px 18px 14px}
  #cnpy .part {grid-template-columns:1fr;gap:2px;padding:22px 0 10px;margin-top:22px}
  #cnpy .part-no {font-size:27px;margin-bottom:3px}
  #cnpy .part-main {max-width:none}
  #cnpy .stats4 {grid-template-columns:repeat(2,1fr)}
  #cnpy .stats4 div:nth-child(3) {border-left:none;padding-left:0}
  #cnpy .stats4 div:nth-child(n+3) {border-top:1px solid var(--line)}
  #cnpy .refs {columns:1}
}
@media (max-width:820px){
  #cnpy .srctable {font-size:13px}
  #cnpy .srctable thead {display:none}
  #cnpy .srctable tbody, #cnpy .srctable tr, #cnpy .srctable td {display:block;width:auto}
  #cnpy .srctable tr {padding:9px 0;border-bottom:1px solid var(--line)}
  #cnpy .srctable td {border:none;padding:0 0 2px}
  #cnpy .srctable td:first-child {width:auto;margin-bottom:1px}
  #cnpy .srctable td:nth-child(2) {width:auto;color:var(--ink-2)}
  #cnpy .srctable td:last-child {display:block;width:auto;font-size:11.5px;color:var(--muted);line-height:1.55}
  #cnpy .srctable td:last-child::before {content:"注："}
}
@media (max-width:700px){
  #cnpy #map .lbl {display:none}
}
@media (max-width:560px){
  #cnpy .mapside {width:100%;margin-top:8px}
  #cnpy .stage-head .total {width:100%;padding-bottom:0}
  #cnpy .hint {display:none}
  #cnpy .yeartag {display:none}
}

/* ===== 站内适配层（必须放在最后，覆盖上面的原始规则） ===================== */
/* 站内 comadou-dark.css 有一条无前缀的全局规则 `h1..h6{color:var(--t1)}`，
   深色主题下 --t1 是浅色，会把米白纸面上的标题冲成几乎不可见的浅字。
   这里用更高特异性把标题色钉回本页自己的墨色变量。 */
#cnpy h1, #cnpy h2, #cnpy h3, #cnpy h4, #cnpy h5, #cnpy h6 { color: var(--ink); }
/* 紧跟在站内文章标题之后，压缩一下顶部留白 */
#cnpy header.masthead { padding-top: 6px; }
/* 深色主题下这片内容仍按纸面呈现，用细边框与微阴影交代边界 */
html[data-theme="dark"] #cnpy {
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .38);
}
/* 文章尾部的说明行原本带 46px 下边距，和站内标签区之间收一点 */
#cnpy footer { padding-bottom: 18px; }
