@font-face{font-family:Fraunces;font-style:normal;font-weight:100 900;font-display:swap;src:url("fonts/fraunces-normal-latin.woff2") format("woff2");unicode-range:U+0000-00FF,U+2013-2014,U+2018-2019,U+201C-201E,U+2026,U+20AC,U+2190-2193,U+2212,U+00B7}
@font-face{font-family:Fraunces;font-style:normal;font-weight:100 900;font-display:swap;src:url("fonts/fraunces-normal-latin-ext.woff2") format("woff2");unicode-range:U+0100-024F,U+0218-021B,U+1E00-1EFF}
@font-face{font-family:Plex;font-style:normal;font-weight:400;font-display:swap;src:url("fonts/plexmono-latin.woff2") format("woff2");unicode-range:U+0000-00FF,U+2013-2014,U+2018-2019,U+201C-201E,U+2212,U+00B7,U+00B3}
@font-face{font-family:Plex;font-style:normal;font-weight:400;font-display:swap;src:url("fonts/plexmono-latin-ext.woff2") format("woff2");unicode-range:U+0100-024F,U+0218-021B}

/* night in the Sadu valley (dark) and river stone by day (light) */
:root{
  --bg:#0b1416;--bg2:#101c1f;--ink:#e9eff0;--muted:#b4c4c7;--accent:#ffc46b;--water:#7fd8ea;--line:#2b3c40;--line-soft:#22333a;
  --sky0:#0a1517;--sky1:#14262a;--hill2:#13242a;--hill1:#182e33;--ground:#0e1a1d;--river:#2d5560;
  --facade:#d8b25c;--roof:#3b2e29;--cut:#0b1416;--wheel:#9fb7bc;--bld:#0f1b1e;--win-off:#203238;--win-on:#ffc46b;--pole:#53676c;
  --glow0:rgba(255,196,107,.28);--glow1:rgba(255,196,107,0);--smoke:#8d9ca0;--eq-bg:#132226;
  --to-top-bg:#0b1416;--to-top-fg:#e9eff0;
  color-scheme:dark;
}
html.light{
  --bg:#eef3f3;--bg2:#e2eaeb;--ink:#0d1b1e;--muted:#33484d;--accent:#8a4b00;--water:#0b6f86;--line:#b9c9cc;--line-soft:#cfdcde;
  --sky0:#dbe8ea;--sky1:#eef3f3;--hill2:#c3d4d6;--hill1:#adc3c6;--ground:#9fb5b8;--river:#5e98a6;
  --facade:#d9a93f;--roof:#5a463d;--cut:#f6f8f8;--wheel:#2f4a50;--bld:#5d7378;--win-off:#8ea4a8;--win-on:#ffcf5a;--pole:#53676c;
  --glow0:rgba(255,190,80,.22);--glow1:rgba(255,190,80,0);--smoke:#7c8a8d;--eq-bg:#e0eaeb;
  --to-top-bg:#eef3f3;--to-top-fg:#0d1b1e;
  color-scheme:light;
}
*{box-sizing:border-box}
[hidden]{display:none!important}
svg[hidden]{display:none}
html{-webkit-text-size-adjust:100%;scroll-padding-top:56px}
body{margin:0;background:var(--bg);color:var(--ink);font:400 1.1rem/1.62 Fraunces,Georgia,serif;font-optical-sizing:auto;font-variation-settings:"SOFT" 50,"WONK" 0}
a{color:var(--ink);text-decoration-color:var(--accent);text-underline-offset:.18em;text-decoration-thickness:1px}
a:hover{text-decoration-thickness:2px}
:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.skip{position:absolute;left:-999px;top:8px;background:var(--bg);color:var(--ink);padding:.4rem .8rem;z-index:99}
.skip:focus{left:8px}
.eq,output,.ticks,.lbls,.legend,.kicker,.facts dt,.hint,.like,.share-row .lbl,footer,.topbar{font-family:Plex,ui-monospace,monospace}
.num{white-space:nowrap;font-variant-numeric:lining-nums tabular-nums}

.topbar{position:sticky;top:0;z-index:20;height:44px;display:flex;align-items:center;gap:.7rem;padding:0 max(16px,env(safe-area-inset-right)) 0 max(16px,env(safe-area-inset-left));background:color-mix(in srgb,var(--bg) 88%,transparent);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);border-bottom:1px solid var(--line-soft);font-size:.82rem}
.topbar .home{display:flex;align-items:center;gap:.45rem;text-decoration:none}
.motif{width:20px;height:20px;color:var(--accent)}
.spacer{flex:1}
.chip{padding:.2rem .45rem;border:1px solid var(--line);border-radius:4px;text-decoration:none;font-size:.76rem;min-height:28px;display:inline-flex;align-items:center}
.icon-btn{width:36px;height:36px;display:inline-grid;place-items:center;background:none;border:1px solid var(--line);border-radius:50%;color:var(--ink);cursor:pointer}
.progress{position:absolute;left:0;right:0;bottom:-1px;height:2px;overflow:hidden}
.progress i{display:block;height:100%;background:var(--accent);transform:scaleX(0);transform-origin:left}

.wrap{max-width:44rem;margin:0 auto;padding:0 16px}
.hero{padding-top:clamp(1.6rem,5vw,3.6rem);padding-bottom:1.2rem}
.kicker{color:var(--accent);font-size:.8rem;letter-spacing:.06em;text-transform:uppercase;margin:0 0 .8rem}
h1{font-weight:640;font-size:clamp(2rem,5.4vw,3.6rem);line-height:1.04;letter-spacing:-.018em;margin:0 0 1rem;font-variation-settings:"SOFT" 100,"WONK" 1}
h1 em{font-style:normal;color:var(--water)}
.deck{font-size:clamp(1.08rem,2vw,1.26rem);color:var(--ink);margin:0;max-width:40rem}
h2{font-weight:600;font-size:clamp(1.5rem,3.2vw,2.05rem);line-height:1.15;margin:0 0 1rem;letter-spacing:-.01em}

/* the instrument */
.instrument{display:grid;gap:0;margin:1rem auto 2.5rem;max-width:90rem;padding:0 16px}
.stage{margin:0;border:1px solid var(--line-soft);border-radius:6px 6px 0 0;overflow:hidden}
#plant{display:block;width:100%;height:auto}
.panel{border:1px solid var(--line-soft);border-top:0;border-radius:0 0 6px 6px;padding:1rem 1rem 1.2rem;background:var(--bg2)}
@media (min-width:1100px){
  .instrument{grid-template-columns:minmax(0,1fr) 23rem;align-items:start}
  .stage{border-radius:6px 0 0 6px!important;border-right:0}
  .stage{border-radius:6px 0 0 6px}
  .panel{border-top:1px solid var(--line-soft);border-left:0;border-radius:0 6px 6px 0;display:flex;flex-direction:column}
}
.answer .big{margin:0;font-weight:700;font-size:clamp(2.2rem,5vw,3.1rem);line-height:1;color:var(--accent);font-variant-numeric:tabular-nums;font-variation-settings:"SOFT" 100,"WONK" 1}
.answer .big #homes-u{font-size:.55em;font-weight:500;color:var(--ink)}
.like{margin:.35rem 0 .6rem;font-size:.8rem;color:var(--muted)}
.why{margin:0 0 .5rem;font-size:.95rem;line-height:1.5;min-height:4.5em}
.now{margin:0 0 1rem;font-size:.85rem;line-height:1.45;color:var(--muted);border-top:1px solid var(--line-soft);padding-top:.5rem}
.plan img{background:#f4efe2;border-radius:2px}
.ctl label{display:flex;justify-content:space-between;gap:.6rem;align-items:baseline;font-weight:600;font-size:.98rem;margin:.6rem 0 .35rem}
output{font-weight:400;font-size:.9rem;color:var(--water);white-space:nowrap}
input[type=range]{width:100%;height:44px;margin:0;accent-color:var(--water);background:transparent}
.ticks{position:relative;height:2.3rem;font-size:.68rem;color:var(--muted);margin:-.3rem .55rem 0}
.ticks span{position:absolute;top:0;transform:translateX(-50%);text-align:center;line-height:1.25;white-space:nowrap;border-left:1px solid var(--muted);padding-left:0;}
.ticks span::before{content:"";position:absolute;left:50%;top:-6px;height:6px;border-left:1px solid var(--muted)}
.ticks span{border:0}
.ticks b{display:block;font-weight:400;color:var(--ink)}
.ticks span:first-child{transform:translateX(-100%);text-align:right;padding-right:4px}.ticks span:last-child{transform:translateX(-50%)}
.hint{font-size:.78rem;color:var(--muted);margin:.2rem 0 .6rem;line-height:1.45}
.steam,.reset{font:inherit;font-size:.92rem;min-height:44px;padding:.45rem .9rem;border-radius:999px;border:1px solid var(--line);background:transparent;color:var(--ink);cursor:pointer}
.steam{margin:.2rem 0 .6rem}
.steam[data-on="1"]{border-color:var(--accent);color:var(--accent)}
.reset{font-size:.85rem;padding:.35rem .8rem}
.kwh-row{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}
.kwh-row input{font:inherit;font-size:1.1rem;width:7.5rem;min-height:44px;padding:.35rem .6rem;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--ink)}
.kwh-row input[aria-invalid=true]{border-color:#e07a5f}
.kwh-row span{font-family:Plex,monospace;font-size:.85rem;color:var(--muted)}
.panel .share-row{margin-top:auto;padding-top:.8rem}

/* drawing tokens: the scene is always night, in both themes */
.stage{--sky0:#060d10;--sky1:#14262c;--hill3:#0f1d22;--hill2:#13252b;--hill1:#183036;--ground:#0d191c;--river:#24505b;--water:#7fd8ea;
  --facade:#d9b25c;--band:#f1e6c8;--roof:#2e2522;--cut:#081114;--wheel:#a9c2c7;--bld:#0c171a;--win-off:#1e3137;--win-on:#ffc46b;--pole:#56696e;
  --glow0:rgba(255,196,107,.30);--glow1:rgba(255,196,107,0);--smoke:#8d9ca0;--lab:#b9cacd;--ink-s:#eef3f3;--accent-s:#ffc46b;--line:#30454a;background:var(--sky1)}
.bld2{fill:#11211f;fill:#122226}
.stars circle{fill:#e8f0f2}.moon{fill:#e9e2c8;opacity:.85}.hill3{fill:var(--hill3)}
.band{stroke:var(--band);stroke-width:5;fill:none;opacity:.9}
.inscr{font:600 9px Fraunces,serif;letter-spacing:.12em;fill:#4a3a1a}
.arch{fill:var(--win-on);opacity:calc(.35 + .65 * var(--glow,.7))}
.gen{fill:#3a4c51;stroke:var(--wheel);stroke-width:1.2}.coil{stroke:#c98a4b;stroke-width:1.4}
.shaft{stroke:var(--wheel);stroke-width:2.5}.casing{fill:#22363b;stroke:var(--wheel);stroke-width:1.4}
.runner{fill:none;stroke:var(--water);stroke-width:2.4;stroke-dasharray:4 5}
.wh{fill:var(--win-on);opacity:0;transition:opacity .5s}.wh.on{opacity:.13}

.sky0{stop-color:var(--sky0)}.sky1{stop-color:var(--sky1)}
.glow0{stop-color:var(--glow0)}.glow1{stop-color:var(--glow1)}
.halo{opacity:calc(.2 + var(--glow,.7))}
.hill2{fill:var(--hill2)}.hill1{fill:var(--hill1)}.ground{fill:var(--ground)}
.river{fill:none;stroke:var(--river);stroke-width:7;stroke-linecap:round}
.flow{fill:none;stroke:var(--water);stroke-linecap:round;stroke-dasharray:10 14;transition:stroke-width .4s,opacity .4s}
.river-flow{stroke-dasharray:6 18}
.canal-bed{stroke:var(--line);stroke-width:11;stroke-linecap:round}
.pipe-wall{stroke:var(--line);stroke-width:12;stroke-linecap:round}
.weir,.basin{fill:var(--pole)}
.dim path{stroke:var(--lab);stroke-width:1;fill:none}
.dim text{fill:var(--accent-s);font:400 15px Plex,monospace}
.facade{fill:var(--facade)}.roof{fill:var(--roof)}.cut{fill:var(--cut);opacity:.92}
.wheel circle,.wheel path{fill:none;stroke:var(--wheel);stroke-width:2}
.boiler{fill:var(--pole)}
.steam-on .boiler{fill:#e07a5f}
.chimney{fill:var(--roof)}
#smoke circle{fill:var(--smoke);opacity:.55}
#smoke{transition:opacity .6s}
.pole{stroke:var(--pole);stroke-width:2;fill:none}
.wire{stroke:var(--pole);stroke-width:1;fill:none}
.bld{fill:var(--bld)}
.win{fill:var(--win-off);transition:fill .5s}
.win.on{fill:var(--win-on)}
.lbls text,.legend{fill:var(--lab);font:400 13px Plex,monospace}
.lbls .big{font:600 24px Fraunces,serif;fill:var(--ink-s)}
.lbls .riv{font-style:italic}
#spill-lbl{transition:opacity .4s;fill:var(--water)}
.legend{fill:var(--ink-s)}
@media (prefers-reduced-motion:reduce){.flow,.win,#smoke{transition:none}}

/* chapters */
.chap{padding:2.2rem 0}
.chap p{margin:0 0 1rem}
.chap.tint{background:var(--bg2)}
.eq{display:block;font-size:clamp(.9rem,2.6vw,1.12rem);background:var(--eq-bg);border-left:3px solid var(--water);padding:.7rem .9rem;overflow-x:auto;white-space:nowrap}
.facts{display:grid;grid-template-columns:auto 1fr;gap:.25rem 1.2rem;margin:1.4rem 0;padding:1rem 0;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
.facts dt{font-size:.78rem;color:var(--muted);align-self:center}
.facts dd{margin:0;font-weight:600}
.photo{margin:1.6rem 0 0}
.photo img{width:100%;height:auto;display:block;border-radius:4px}
.photo figcaption{font-size:.82rem;color:var(--muted);margin-top:.5rem;line-height:1.45}
.small{font-size:.9rem;line-height:1.5}
.small li{margin-bottom:.55rem}

.share-row{display:flex;align-items:center;gap:.45rem;flex-wrap:wrap}
.share-row .lbl{font-size:.78rem;color:var(--muted);margin-right:.2rem}
.share-row a,.share-row button{width:40px;height:40px;display:inline-grid;place-items:center;border:1px solid var(--line-soft);border-radius:50%;background:transparent;color:var(--ink);cursor:pointer;padding:0}
.share-row a:hover,.share-row button:hover,.share-row a:focus-visible,.share-row button:focus-visible{color:var(--accent);border-color:var(--accent)}
.share-row svg{width:18px;height:18px}
@media (pointer:coarse){.share-row a,.share-row button{width:44px;height:44px}}
.share-status{font-size:.82rem;color:var(--muted);min-height:1.2em;margin:.3rem 0 0}

.rail{position:fixed;right:10px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;gap:12px;z-index:15;opacity:0;transition:opacity .4s;pointer-events:none}
.rail-on .rail{opacity:1;pointer-events:auto}
.rail a{position:relative;display:block;width:10px;height:10px;border-radius:50%;border:1px solid var(--muted);text-decoration:none}
.rail a[aria-current]{background:var(--accent);border-color:var(--accent)}
.rail a span{position:absolute;right:18px;top:50%;transform:translateY(-50%);white-space:nowrap;font:400 .74rem Plex,monospace;background:var(--bg);color:var(--ink);padding:.15rem .4rem;border:1px solid var(--line-soft);border-radius:3px;opacity:0;pointer-events:none;transition:opacity .2s}
.rail a:hover span,.rail a:focus-visible span{opacity:1}
@media (max-width:1499px){.rail{display:none}}

footer{max-width:44rem;margin:0 auto;padding:2rem 16px 4rem;font-size:.78rem;color:var(--muted);display:flex;gap:.6rem;flex-wrap:wrap}
footer span{flex-basis:100%}
footer a{color:var(--muted)}
.redirect{padding:3rem 0}
@media print{.topbar,.rail,.share-row,.panel .ctl{display:none}}
