/* ── Design tokens ─────────────────────────────────────── */
:root {
  --bg: #0e1420;
  --bg-soft: #141c2c;
  --panel: #1a2436;
  --panel-2: #202c42;
  --ink: #f2f5fa;
  --ink-dim: #a8b4c8;
  --ink-faint: #6c7a92;
  --gold: #f5c451;
  --gold-deep: #d9a227;
  --teal: #43d3c9;
  --rose: #f27896;
  --line: rgba(242, 245, 250, 0.12);
  --radius: 18px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --font-serif: "Noto Serif TC", serif;
  --font-sans: "Noto Sans TC", -apple-system, "PingFang TC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Hero ─────────────────────────────────────────────── */
.hero {
  min-height: 96vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 72px 24px 40px;
  background:
    radial-gradient(1100px 520px at 82% -10%, rgba(245, 196, 81, 0.16), transparent 62%),
    radial-gradient(820px 460px at 8% 110%, rgba(67, 211, 201, 0.10), transparent 60%),
    var(--bg);
  position: relative;
}

.hero-inner { max-width: 1060px; margin: 0 auto; width: 100%; }

.kicker {
  color: var(--gold);
  font-size: 0.86rem;
  letter-spacing: 0.22em;
  font-weight: 700;
  margin-bottom: 22px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5.6vw, 4.2rem);
  line-height: 1.22;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.accent { color: var(--gold); }

.lede {
  margin-top: 26px;
  max-width: 620px;
  color: var(--ink-dim);
  font-size: 1.08rem;
}

.hero-stat {
  margin-top: 46px;
  background: linear-gradient(150deg, rgba(245, 196, 81, 0.10), rgba(26, 36, 54, 0.9));
  border: 1px solid rgba(245, 196, 81, 0.35);
  border-radius: 24px;
  padding: 34px 38px;
  max-width: 760px;
  box-shadow: var(--shadow);
}

.hero-person {
  color: var(--ink-dim);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.hero-number {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 6px 0 10px;
}

.counter {
  font-family: var(--font-serif);
  font-size: clamp(3.4rem, 9vw, 6.4rem);
  font-weight: 900;
  color: var(--gold);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.hero-unit { font-size: 1.6rem; font-weight: 700; color: var(--ink); }

.hero-caption { color: var(--ink-dim); font-size: 1.02rem; }
.hero-caption strong { color: var(--ink); }

.hero-punch {
  margin-top: 16px;
  background: rgba(245, 196, 81, 0.13);
  border: 1px solid rgba(245, 196, 81, 0.45);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--ink);
  font-size: 1.06rem;
  line-height: 1.85;
  max-width: 720px;
}

.hero-punch strong { color: var(--gold); }

.scroll-hint {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--ink-faint);
  font-size: 0.85rem;
  letter-spacing: 0.14em;
}

/* ── Sections ─────────────────────────────────────────── */
.section {
  max-width: 1060px;
  margin: 0 auto;
  padding: 88px 24px;
}

.section h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.65rem, 3.4vw, 2.3rem);
  font-weight: 900;
  line-height: 1.35;
}

.section-intro {
  margin-top: 14px;
  color: var(--ink-dim);
  max-width: 720px;
}

/* ── Calculator ───────────────────────────────────────── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.22s ease;
}

.chip:hover { border-color: var(--gold); color: var(--ink); transform: translateY(-2px); }

.chip.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #241a05;
  font-weight: 700;
}

.chips-small .chip { padding: 8px 14px; font-size: 0.88rem; }

.mode-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.mode-label { color: var(--ink-dim); font-weight: 700; }

.mode-note {
  margin-top: 16px;
  color: var(--ink-faint);
  font-size: 0.88rem;
  line-height: 1.7;
  border-left: 3px solid rgba(245, 196, 81, 0.45);
  padding-left: 12px;
  max-width: 780px;
}

.custom-input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  padding: 10px 16px;
  font-size: 1rem;
  width: 220px;
  font-family: var(--font-sans);
}

.custom-input:focus { outline: 2px solid var(--gold); }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-top: 34px;
}

.result-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px;
}

.result-main {
  background: linear-gradient(155deg, rgba(245, 196, 81, 0.14), var(--panel));
  border-color: rgba(245, 196, 81, 0.4);
}

.result-card h3 {
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-weight: 700;
}

.result-big {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
}

.result-big .counter { font-size: clamp(2.1rem, 5vw, 3.1rem); }
.result-unit { font-size: 1.25rem; font-weight: 700; }

.result-mid {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 900;
  color: var(--teal);
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.result-unit-small { font-size: 1rem; color: var(--ink-dim); font-family: var(--font-sans); }

.result-sub { margin-top: 10px; color: var(--ink-faint); font-size: 0.88rem; line-height: 1.6; }

/* ── Bar chart ────────────────────────────────────────── */
.scale-toggle { margin-top: 26px; display: flex; gap: 10px; flex-wrap: wrap; }

.bar-chart { margin-top: 30px; display: flex; flex-direction: column; gap: 14px; }

.bar-row {
  display: grid;
  grid-template-columns: 190px 1fr 170px;
  align-items: center;
  gap: 16px;
}

.bar-label { font-size: 0.95rem; color: var(--ink-dim); }
.bar-label strong { color: var(--ink); display: block; font-size: 1.02rem; }

.bar-track {
  background: var(--panel);
  border-radius: 8px;
  height: 30px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  width: 0;
  transition: width 1s cubic-bezier(0.22, 0.8, 0.28, 1);
  min-width: 4px;
}

.bar-row:nth-child(n+2) .bar-fill {
  background: linear-gradient(90deg, #2c7a75, var(--teal));
}

.bar-value {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bar-value span { color: var(--ink-faint); font-family: var(--font-sans); font-size: 0.82rem; display: block; }

/* ── Perspective ──────────────────────────────────────── */
.perspective-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 22px;
  margin-top: 34px;
}

.perspective-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 28px;
}

.perspective-card h3 { font-size: 1.12rem; line-height: 1.55; }

.timeline { margin-top: 24px; display: flex; flex-direction: column; gap: 22px; }

.timeline-label { font-size: 0.88rem; color: var(--ink-dim); display: block; margin-bottom: 8px; }

.timeline-track {
  background: var(--panel-2);
  border-radius: 8px;
  height: 26px;
  overflow: hidden;
}

.timeline-fill { height: 100%; border-radius: 8px; transition: width 1.1s ease; }
.fill-today { width: 4.2%; background: var(--rose); }
.fill-wealth { width: 100%; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }

.timeline-value {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--gold);
}

.perspective-note { margin-top: 20px; color: var(--ink-faint); font-size: 0.92rem; }

.compare-list { list-style: none; margin-top: 22px; display: flex; flex-direction: column; gap: 16px; }

.compare-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 12px;
}

.compare-label { color: var(--ink-dim); font-size: 0.92rem; }

.compare-value {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--teal);
  white-space: nowrap;
  font-size: 1.12rem;
}

/* ── Method ───────────────────────────────────────────── */
.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 30px;
  margin-top: 30px;
}

.method h3 { margin-bottom: 12px; font-size: 1.05rem; color: var(--gold); }

.method p { color: var(--ink-dim); margin-bottom: 14px; font-size: 0.98rem; }

.formula {
  background: var(--panel);
  border: 1px solid rgba(245, 196, 81, 0.3);
  border-radius: 12px;
  padding: 16px 18px;
  color: var(--ink) !important;
  font-family: var(--font-serif);
  font-size: 1.05rem !important;
}

.sources { margin-top: 26px; font-size: 0.9rem; color: var(--ink-faint); }

/* ── Footer ───────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--line);
  padding: 40px 24px 56px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.88rem;
}

.footer-meta { margin-top: 8px; letter-spacing: 0.08em; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 720px) {
  .hero { padding: 116px 18px 40px; }
  .hero-stat { padding: 24px 20px; }
  .section { padding: 64px 18px; }
  .bar-row { grid-template-columns: 1fr; gap: 6px; }
  .bar-value { text-align: left; }
  .compare-list li { flex-direction: column; gap: 2px; }
  .toolbar { justify-content: flex-start; padding: 12px 18px 0; }
}

/* ── Toolbar ──────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 8px;
  z-index: 50;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 12px 24px 0;
}

.tool-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.tool-btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.tool-btn:disabled { opacity: 0.6; cursor: wait; }

.tool-btn-accent {
  background: var(--gold);
  border-color: var(--gold);
  color: #241a05;
  font-weight: 700;
}

.data-status {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

/* ── Light theme ──────────────────────────────────────── */
:root[data-theme="light"] {
  --bg: #f5f1e8;
  --bg-soft: #ece6d8;
  --panel: #ffffff;
  --panel-2: #f1ebdd;
  --ink: #222b3d;
  --ink-dim: #4b5872;
  --ink-faint: #7b859b;
  --gold: #a1741a;
  --gold-deep: #c2931f;
  --teal: #0d7f76;
  --rose: #c04a6c;
  --line: rgba(34, 43, 61, 0.14);
  --shadow: 0 18px 48px rgba(120, 100, 55, 0.16);
}

:root[data-theme="light"] .hero {
  background:
    radial-gradient(1100px 520px at 82% -10%, rgba(194, 147, 31, 0.14), transparent 62%),
    radial-gradient(820px 460px at 8% 110%, rgba(13, 127, 118, 0.08), transparent 60%),
    var(--bg);
}

:root[data-theme="light"] .hero-stat {
  background: linear-gradient(150deg, rgba(194, 147, 31, 0.10), rgba(255, 255, 255, 0.9));
  border-color: rgba(161, 116, 26, 0.35);
}

:root[data-theme="light"] .result-main {
  background: linear-gradient(155deg, rgba(194, 147, 31, 0.10), var(--panel));
  border-color: rgba(161, 116, 26, 0.35);
}

:root[data-theme="light"] .chip.active,
:root[data-theme="light"] .tool-btn-accent { color: #ffffff; }

:root[data-theme="light"] .formula { border-color: rgba(161, 116, 26, 0.35); }

:root[data-theme="light"] .hero-punch {
  background: rgba(194, 147, 31, 0.12);
  border-color: rgba(161, 116, 26, 0.4);
}

:root[data-theme="light"] .bar-row:nth-child(n+2) .bar-fill {
  background: linear-gradient(90deg, var(--teal), #2aa79c);
}

/* ── 統一站頭（logo · menu · 深淺色切換） ───────────── */
.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: rgba(14, 20, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-logo { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.site-logo:hover { text-decoration: none; }

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: #241a05;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 1.05rem;
}

.logo-text { font-family: var(--font-serif); font-weight: 900; letter-spacing: 0.05em; }

.site-menu { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; }
.site-menu a {
  color: var(--ink-dim);
  font-size: 0.92rem;
  font-weight: 700;
  border-bottom: 2px solid transparent;
}
.site-menu a:hover, .site-menu a.current {
  color: var(--ink);
  text-decoration: none;
  border-bottom-color: var(--gold);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.theme-toggle:hover { border-color: var(--gold); transform: translateY(-1px); }

:root[data-theme="light"] .site-head { background: rgba(245, 241, 232, 0.92); }
:root[data-theme="light"] .logo-mark { color: #ffffff; }

/* ── 行動版主選單（漢堡選單，與題目頁一致） ───────── */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex: none;
  transition: border-color 0.2s ease;
}

.menu-toggle:hover { border-color: var(--gold); }

@media (max-width: 860px) {
  .site-head { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .menu-toggle { display: inline-flex; margin-left: auto; order: 2; }
  .theme-toggle { order: 3; padding: 8px 12px; }
  .site-menu {
    display: none;
    order: 4;
    width: 100%;
    margin: 2px 0 4px;
    flex-direction: column;
    gap: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
  }
  .site-head.nav-open .site-menu { display: flex; }
  .site-menu a {
    padding: 13px 18px;
    font-size: 1rem;
    border-bottom: 1px solid var(--line);
    border-left: 3px solid transparent;
  }
  .site-menu a:last-child { border-bottom: none; }
  .site-menu a:hover,
  .site-menu a.current {
    border-bottom-color: var(--line);
    border-left-color: var(--gold);
    background: rgba(245, 196, 81, 0.1);
    text-decoration: none;
  }
}
