:root {
  --cream: #fff6e8;
  --paper: #fffbf4;
  --ink: #0f3b3a;
  --mute: #5b706d;
  --sun: #ff8a3d;
  --sun-deep: #e8661c;
  --lime: #8fcf2f;
  --blue: #3d8fe0;
  --line: rgba(15, 59, 58, 0.12);
  --panel-w: min(430px, 36vw);
  --gutter: clamp(16px, 4vw, 56px);
  --radius: 22px;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  color-scheme: light;
}
:lang(zh) { --font: 'Plus Jakarta Sans', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.035em; line-height: 0.98; }
:lang(zh) :is(h1, h2, h3) { letter-spacing: 0; line-height: 1.15; word-break: keep-all; overflow-wrap: anywhere; }
p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; border-radius: 8px; }

.skip-link { position: fixed; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--cream); padding: 10px 16px; border-radius: 999px; }
.skip-link:focus { top: 12px; }

/* Header */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px var(--gutter);
}
.wordmark { font-weight: 800; font-size: 26px; letter-spacing: -0.05em; text-decoration: none; }
.wordmark span { color: var(--sun); }
.site-header nav { display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: rgba(255, 251, 244, 0.72); backdrop-filter: blur(10px); box-shadow: 0 0 0 1px var(--line); }
.site-header nav a { padding: 7px 14px; border-radius: 999px; text-decoration: none; font-size: 14px; font-weight: 600; color: var(--mute); }
.site-header nav a:hover, .site-header nav a.is-here { background: var(--ink); color: var(--cream); }
.header-end { display: flex; align-items: center; gap: 10px; }
.lang { height: 40px; min-width: 52px; padding: 0 12px; border: 0; border-radius: 999px; background: rgba(255, 251, 244, 0.8); box-shadow: 0 0 0 1px var(--line); font-weight: 700; font-size: 14px; cursor: pointer; }
.lang:hover { background: var(--paper); }

.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 999px; border: 0;
  background: var(--paper); box-shadow: 0 0 0 1.5px var(--ink) inset;
  font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.pill:hover { transform: translateY(-1px); }
.pill-solid { background: var(--sun); box-shadow: none; color: #1e1206; }
.pill-solid:hover { background: #ff9a55; }
.text-link { font-weight: 700; text-decoration: none; border-bottom: 2px solid var(--sun); padding-bottom: 2px; }

/* Stage: the diorama sits behind everything. */
.stage { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
#scene { width: 100%; height: 100%; display: block; }
.stage-fallback { display: none; }
.no-webgl #scene { display: none; }
.no-webgl .stage-fallback { display: block; position: absolute; inset: 0; background: linear-gradient(#9cc6ea, #f3e6cf 70%, #b7cd94 70%, #b7cd94 76%, #8a6a4f 76%); }
.no-webgl .fb-sun { position: absolute; right: 18%; top: 18%; width: 120px; height: 120px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 80px #ffb37a; }
.pin {
  position: absolute; left: 0; top: 0; z-index: 2; transform: translate(-50%, -100%);
  padding: 7px 12px 7px 10px; border-radius: 999px; background: var(--ink); color: var(--cream);
  font-size: 13px; font-weight: 700; white-space: nowrap; opacity: 0; transition: opacity 0.4s;
  display: flex; align-items: center; gap: 6px; pointer-events: none;
}
.pin::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.35); }
.pin::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; background: var(--ink); transform: translateX(-50%) rotate(45deg); border-radius: 2px; z-index: -1; }
.pin.is-on { opacity: 1; }
.no-webgl .pin { display: none; }

main { position: relative; z-index: 1; }
section { position: relative; min-height: 100vh; min-height: 100svh; padding: 110px var(--gutter) 60px; }

.kicker { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sun-deep); margin-bottom: 14px; }
:lang(zh) .kicker { letter-spacing: 0.04em; }
.lede { font-size: 18px; color: var(--mute); max-width: 34ch; margin-top: 20px; }
:lang(zh) .lede { max-width: 26em; }
.note { font-size: 13px; color: var(--mute); }

/* Hero */
.hero { display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.hero-copy { max-width: 640px; pointer-events: auto; }
.hero h1 { font-size: clamp(54px, 8.4vw, 132px); }
:lang(zh) .hero h1 { font-size: clamp(48px, 7vw, 108px); }
.hero-actions { margin-top: 28px; }
.hero-note { align-self: flex-end; font-size: 13px; font-weight: 600; color: var(--mute); background: rgba(255, 251, 244, 0.75); padding: 6px 12px; border-radius: 999px; pointer-events: auto; }

/* Panels */
.panel {
  width: var(--panel-w); padding: 28px; border-radius: var(--radius);
  background: rgba(255, 251, 244, 0.9); backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 0 0 1px var(--line), 0 24px 60px -30px rgba(15, 59, 58, 0.35);
}
.panel h2 { font-size: clamp(36px, 3.6vw, 54px); margin-bottom: 22px; }

/* 01 · Home */
.home { display: flex; align-items: center; }
.homes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.home-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 12px; border-radius: 16px; border: 0; background: var(--cream); box-shadow: 0 0 0 1px var(--line) inset; cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s;
}
.home-opt svg { width: 44px; height: 30px; margin-bottom: 6px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.home-opt b { font-size: 15px; }
.home-opt small { font-size: 12px; line-height: 1.3; color: var(--mute); }
.home-opt[aria-checked='true'] { background: var(--ink); color: var(--cream); box-shadow: none; }
.home-opt[aria-checked='true'] small { color: rgba(255, 246, 232, 0.7); }
.home-opt[aria-checked='true'] svg { stroke: var(--sun); fill: rgba(255, 138, 61, 0.25); }

.bill { display: flex; justify-content: space-between; align-items: baseline; margin-top: 24px; font-weight: 600; font-size: 15px; }
.bill output { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
#bill { width: 100%; margin: 10px 0 4px; height: 36px; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; }
#bill::-webkit-slider-runnable-track { height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--sun) var(--fill, 20%), rgba(15, 59, 58, 0.12) var(--fill, 20%)); }
#bill::-moz-range-track { height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--sun) var(--fill, 20%), rgba(15, 59, 58, 0.12) var(--fill, 20%)); }
#bill::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -10px; border-radius: 50%; background: var(--ink); border: 5px solid var(--paper); box-shadow: 0 2px 10px rgba(15, 59, 58, 0.35); }
#bill::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--ink); border: 5px solid var(--paper); box-shadow: 0 2px 10px rgba(15, 59, 58, 0.35); }
.bill-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--mute); }

.result { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 22px 0 14px; border-radius: 16px; overflow: hidden; background: var(--line); }
.result div { background: var(--paper); padding: 12px 14px; }
.result dt { font-size: 12px; color: var(--mute); font-weight: 600; }
.result dd { margin: 2px 0 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.result div:nth-child(3) dd { color: var(--sun-deep); }
.capped { font-size: 13px; color: var(--sun-deep); font-weight: 600; margin-bottom: 14px; }

/* 02 · Day */
.day, .year { padding: 0; }
.day-pin, .year-pin { position: relative; height: 100vh; height: 100svh; padding: 110px var(--gutter) 40px; display: flex; align-items: center; }
.caption { min-height: 4.8em; font-size: 17px; font-weight: 500; }
.caption b { color: var(--sun-deep); }
.chart { margin: 18px 0 0; }
.chart svg { width: 100%; height: 110px; display: block; overflow: visible; }
.ch-sun { fill: rgba(255, 138, 61, 0.22); }
.ch-sun-line { fill: none; stroke: var(--sun); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.ch-use { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.ch-cursor { stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--mute); margin-top: 4px; }
.chart figcaption { display: flex; gap: 16px; margin-top: 10px; font-size: 13px; font-weight: 600; }
.key::before { content: ''; display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.key-sun::before { background: var(--sun); }
.key-use::before { background: repeating-linear-gradient(90deg, var(--ink) 0 5px, transparent 5px 8px); }

.hud {
  position: absolute; right: var(--gutter); bottom: 32px;
  display: flex; gap: 1px; border-radius: 18px; overflow: hidden;
  background: var(--line); box-shadow: 0 0 0 1px var(--line), 0 20px 50px -30px rgba(15, 59, 58, 0.5);
}
.hud > div { background: rgba(255, 251, 244, 0.92); backdrop-filter: blur(12px); padding: 12px 18px; min-width: 112px; }
.hud small { display: block; font-size: 12px; font-weight: 600; color: var(--mute); }
.hud b { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud .hud-clock { display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--cream); font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-clock i { width: 22px; height: 22px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 16px var(--sun); transition: background 0.4s, box-shadow 0.4s; }
.hud-clock i.is-rain { background: #a9b6c2; box-shadow: none; border-radius: 50% 50% 40% 40%; }
.hud-clock i.is-night { background: #f5e7c8; box-shadow: none; }
.hud-chart { display: none; }
.hud-grid.is-out b { color: #4f8c11; }
.hud-grid.is-in b { color: var(--blue); }

/* 03 · Year */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; align-items: end; height: 96px; }
.bars span { position: relative; border-radius: 6px 6px 3px 3px; background: var(--sun); transform-origin: bottom; }
.bars span::after { content: attr(data-m); position: absolute; left: 0; right: 0; bottom: -18px; text-align: center; font-size: 10px; color: var(--mute); font-weight: 600; }
.bars span.is-monsoon { background: #ffbe8f; }
.year .note { margin-top: 26px; }
.ledger { margin-top: 18px; border-top: 1px solid var(--line); }
.ledger-year { padding: 16px 0 14px; border-bottom: 1px solid var(--line); }
.ledger-year small { display: block; font-size: 13px; font-weight: 700; color: var(--sun-deep); }
.ledger-year b { display: block; font-size: clamp(38px, 3.6vw, 52px); font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ledger-year b.is-neg { color: var(--mute); }
.ledger-year span { font-size: 13px; color: var(--mute); }
.ledger-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.ledger-row b { font-variant-numeric: tabular-nums; }
.tree-note { margin-top: 14px; font-size: 13px; color: var(--mute); }

/* 04 · Report */
.report { display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: center; }
.share { display: flex; flex-wrap: wrap; gap: 10px; }
.visit { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.visit h3 { font-size: 20px; letter-spacing: -0.02em; margin-bottom: 4px; }
.visit label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--mute); }
.visit input { height: 44px; padding: 0 14px; border-radius: 12px; border: 0; background: var(--cream); box-shadow: 0 0 0 1px var(--line) inset; color: var(--ink); font-size: 16px; }
.visit input:focus { outline: none; box-shadow: 0 0 0 2px var(--sun) inset; }
.visit input[aria-invalid='true'] { box-shadow: 0 0 0 2px #d9534f inset; }
.visit button { margin-top: 6px; justify-self: start; }
.card-wrap { margin: 0; justify-self: end; width: min(420px, 100%); }
.card-wrap img { display: block; width: 100%; aspect-ratio: 4 / 5; border-radius: 20px; background: var(--paper); box-shadow: 0 30px 80px -30px rgba(15, 59, 58, 0.55), 0 0 0 1px var(--line); transform: rotate(2deg); }
.card-wrap figcaption { margin-top: 18px; max-width: 36ch; background: rgba(255, 251, 244, 0.8); padding: 8px 12px; border-radius: 12px; }

.site-footer { position: relative; z-index: 1; padding: 28px var(--gutter) 40px; background: var(--ink); color: rgba(255, 246, 232, 0.75); font-size: 13px; display: grid; gap: 8px; }
.site-footer a { color: var(--cream); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40; transform: translate(-50%, 20px);
  max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 16px;
  background: var(--ink); color: var(--cream); font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Loading screen */
.loader {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 6px;
  background: radial-gradient(120% 80% at 50% 38%, #fffaf1 0%, var(--cream) 60%, #f6e7cf 100%);
  transition: opacity 0.7s ease, transform 0.9s cubic-bezier(0.7, 0, 0.2, 1), visibility 0s linear 0.9s;
}
.loader.is-done { opacity: 0; transform: translateY(-6%); visibility: hidden; pointer-events: none; }
.loader-art { width: min(300px, 72vw); height: auto; overflow: visible; }
.ld-sun { transform: translateY(calc((1 - var(--p)) * 92px)); transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.ld-disc { fill: var(--sun); }
.ld-glow { fill: rgba(255, 138, 61, 0.18); animation: ld-pulse 1.8s ease-in-out infinite; transform-origin: 138px 40px; }
.ld-rays { stroke: var(--sun); stroke-width: 4; stroke-linecap: round; opacity: calc(0.25 + var(--p) * 0.75); transform-origin: 138px 40px; animation: ld-spin 9s linear infinite; }
.ld-roofs { fill: var(--cream); stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; stroke-dasharray: 420; stroke-dashoffset: 420; animation: ld-draw 1.4s 0.15s cubic-bezier(0.6, 0, 0.2, 1) forwards; }
.ld-ground { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.ld-panels rect { fill: var(--ink); opacity: 0.12; transition: opacity 0.3s, fill 0.3s; }
.ld-panels rect.is-on { opacity: 1; fill: #1e3a5f; }
.loader-word { margin-top: 10px; font-weight: 800; font-size: 30px; letter-spacing: -0.05em; }
.loader-word span { color: var(--sun); }
.loader-text { font-size: 14px; font-weight: 600; color: var(--mute); }
.loader-text b { color: var(--ink); font-variant-numeric: tabular-nums; display: inline-block; min-width: 3.2ch; text-align: right; }
.l-zh { display: none; }
:lang(zh) .l-zh { display: inline; }
:lang(zh) .l-en { display: none; }
@keyframes ld-draw { to { stroke-dashoffset: 0; } }
@keyframes ld-spin { to { transform: rotate(360deg); } }
@keyframes ld-pulse { 50% { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) {
  .ld-rays, .ld-glow { animation: none; }
  .ld-roofs { animation: none; stroke-dashoffset: 0; }
  .loader { transition: opacity 0.3s, visibility 0s linear 0.3s; }
  .loader.is-done { transform: none; }
}

/* Tablet and phone: the street sits up top, panels slide up from the bottom. */
@media (max-width: 860px) {
  :root { --panel-w: 100%; }
  .site-header { padding: 12px 16px; }
  .site-header nav { display: none; }
  .header-end .pill { min-height: 40px; padding: 0 14px; font-size: 13px; }
  section { padding: 90px 16px 24px; }
  .hero { justify-content: flex-start; }
  .hero h1 { font-size: clamp(46px, 14vw, 72px); }
  :lang(zh) .hero h1 { font-size: clamp(42px, 12vw, 64px); }
  .lede { font-size: 16px; }
  .hero-note { position: absolute; bottom: 20px; right: 16px; }
  .home { align-items: flex-end; padding-top: 46vh; }
  .panel { padding: 20px; }
  .panel h2 { font-size: 34px; margin-bottom: 16px; }
  .home-opt { padding: 10px; }
  .home-opt small { display: none; }
  .day-pin, .year-pin { align-items: flex-end; padding: 0 16px 16px; }
  .day-panel { padding: 18px 18px 14px; }
  .day-panel h2 { display: none; }
  .day-panel .kicker { margin-bottom: 6px; }
  .caption { min-height: 4.6em; font-size: 15px; }
  .chart svg { height: 70px; }
  .hud { left: 16px; right: 16px; top: 72px; bottom: auto; display: grid; grid-template-columns: repeat(4, 1fr); }
  .hud > div { min-width: 0; padding: 8px 10px; }
  .hud .hud-clock { grid-column: 1 / -1; font-size: 22px; padding: 8px 12px; }
  .day-panel .chart { display: none; }
  .hud-chart { display: block; flex: 1; min-width: 0; margin: 0 0 0 8px; }
  .hud-chart svg { display: block; width: 100%; height: 42px; overflow: visible; }
  .hud-chart .ch-sun { fill: rgba(255, 138, 61, 0.3); }
  .hud-chart .ch-use, .hud-chart .ch-cursor { stroke: var(--cream); }
  .hud-chart figcaption { display: flex; justify-content: flex-end; gap: 10px; margin-top: 3px; font-size: 10px; font-weight: 600; color: rgba(255, 246, 232, 0.75); }
  .hud-chart .key::before { width: 10px; height: 3px; margin-right: 4px; }
  .hud-chart .key-use::before { background: repeating-linear-gradient(90deg, var(--cream) 0 4px, transparent 4px 6px); }
  .hud-clock i { width: 16px; height: 16px; }
  .hud small { font-size: 10.5px; line-height: 1.25; }
  .hud b { font-size: 16px; }
  .year-pin .panel h2 { display: none; }
  .bars { height: 64px; }
  .ledger-year { padding: 10px 0; }
  .ledger-year b { font-size: 34px; }
  .ledger-row { padding: 7px 0; font-size: 14px; }
  .tree-note { display: none; }
  .report { grid-template-columns: 1fr; padding-top: 90px; }
  .card-wrap { justify-self: center; order: -1; width: min(320px, 82vw); }
}
@media (max-width: 860px) and (max-height: 700px) {
  .chart { display: none; }
}

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