/* WohnMathe editorial interface — warm paper, bold ink, hard-shadow data blocks */
:root {
  --paper: #fff4dc;
  --surface: #fffdf7;
  --surface-muted: #f5eddd;
  --ink: #171918;
  --ink-soft: #5e5a50;
  --line: #171918;
  --teal: #0d7e9c;
  --teal-dark: #075d73;
  --teal-pale: #c8e8ec;
  --yellow: #ffd84d;
  --pink: #f4b0c7;
  --sky: #a9daf2;
  --mint: #bfe5db;
  --danger: #9b302c;
  --success: #1f7259;
  --hard-shadow: 5px 6px 0 var(--ink);
  --hard-shadow-sm: 3px 4px 0 var(--ink);
  --radius: 17px;
  --radius-sm: 11px;
  --nav-h: 78px;
  --font-body: "Avenir Next", Avenir, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Arial Rounded MT Bold", "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --font-data: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
a { color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

:where(a, button, input, select, summary):focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 3px;
}
::selection { color: var(--ink); background: var(--yellow); }

.skip-link {
  position: fixed;
  top: -90px;
  left: 18px;
  z-index: 1000;
  padding: 11px 16px;
  border: 2px solid var(--line);
  border-radius: 10px;
  color: var(--surface);
  background: var(--teal);
  box-shadow: var(--hard-shadow-sm);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 16px; }
.noscript-note {
  width: min(1360px, calc(100% - 48px));
  margin: 18px auto 0;
  padding: 12px 15px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--yellow);
  font-weight: 700;
}

.zh { display: none !important; }
body.has-translation .zh { display: block !important; }
body.has-translation span.zh,
body.has-translation small.zh { display: block !important; }
.zh[dir="rtl"] { text-align: right; unicode-bidi: plaintext; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 300;
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px max(28px, calc((100vw - 1360px) / 2));
  border-bottom: 2px solid var(--line);
  background: rgba(255, 244, 220, .96);
}
.brand { display: inline-flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 49px;
  height: 49px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 14px 11px 15px 10px;
  background: var(--teal);
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-1deg);
}
.brand-mark::after { content: none; }
.brand-mark svg {
  width: 32px;
  fill: none;
  stroke: var(--surface);
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-mark .brand-math { stroke: var(--yellow); stroke-width: 2.45; }
.brand-copy { display: grid; line-height: 1.08; }
.brand-copy strong { font-family: var(--font-display); font-size: 22px; letter-spacing: -.025em; }
.brand-copy small { margin-top: 5px; color: var(--ink-soft); font-family: var(--font-data); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-guide-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 3px solid var(--teal);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.header-guide-link:hover { color: var(--teal-dark); border-bottom-color: var(--yellow); }
.language-control,
.icon-button {
  border: 2px solid var(--line);
  background: var(--surface);
  box-shadow: var(--hard-shadow-sm);
}
.language-control {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 5px 4px 14px;
  border-radius: 13px 16px 12px 15px;
}
.language-label { color: var(--ink-soft); font-size: 12px; font-weight: 700; line-height: 1.2; }
.language-label .zh { margin-top: 2px; font-weight: 500; }
.language-control select {
  min-width: 96px;
  min-height: 44px;
  padding: 0 30px 0 11px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-muted);
  font-weight: 700;
}
.icon-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px 11px 15px 12px;
}
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-button:hover,
.language-control:hover { transform: translate(-1px, -1px); box-shadow: 4px 5px 0 var(--ink); }

.app-shell { width: min(1360px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 64px; }
.intro {
  display: grid;
  grid-template-columns: minmax(0, 880px) minmax(290px, 330px);
  align-items: center;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 24px;
}
h1, h2, h3 { margin: 0; font-family: var(--font-display); overflow-wrap: break-word; text-wrap: balance; }
h1 { max-width: none; font-size: clamp(42px, 4vw, 58px); line-height: .98; letter-spacing: -.04em; text-wrap: pretty; }
h1::after {
  content: "";
  width: min(430px, 68%);
  height: 10px;
  display: block;
  margin-top: 12px;
  background:
    linear-gradient(var(--teal), var(--teal)) 0 0 / 76% 6px no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) 82% 0 / 18% 6px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 7px / 100% 2px no-repeat;
  transform: skewX(-18deg);
  transform-origin: left center;
}
.intro-content { min-width: 0; }
.intro-copy { max-width: 68ch; margin: 14px 0 0; color: var(--ink-soft); font-size: 16px; line-height: 1.55; text-wrap: pretty; }
.intro-copy.zh { margin-top: 6px; font-size: 14px; }
body.has-translation .intro-content {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr);
  align-items: start;
  gap: 0 24px;
}
body.has-translation .intro-content h1 { grid-column: 1 / -1; }
body.has-translation .intro-copy,
body.has-translation .intro-copy.zh { margin-top: 14px; }
body.has-translation .intro-copy.zh {
  padding-left: 20px;
  border-left: 2px solid var(--teal);
}
.source-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border: 2px solid var(--line);
  border-radius: 13px 17px 12px 15px;
  background: var(--yellow);
  box-shadow: var(--hard-shadow-sm);
  transform: rotate(.35deg);
}
.source-note svg { width: 20px; flex: 0 0 auto; fill: none; stroke: var(--ink); stroke-width: 2; }
.source-note span { display: grid; }
.source-note strong { font-family: var(--font-display); font-size: 14px; }
.source-note small { margin-top: 3px; color: var(--ink); font-size: 12px; }

.tool-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 15px 13px 17px 12px;
  background: var(--surface);
  box-shadow: var(--hard-shadow);
}
.tool-tab {
  min-width: 0;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  padding: 12px 18px;
  border: 0;
  border-right: 2px solid var(--line);
  background: transparent;
  text-align: left;
  transition: color 160ms var(--ease), background 160ms var(--ease);
}
.tool-tab:last-child { border-right: 0; }
.tool-tab:hover { background: var(--teal-pale); }
.tool-tab.active { color: #fff; background: var(--teal); }
.tab-icon { width: 25px; height: 25px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool-tab > span { min-width: 0; display: grid; }
.tool-tab strong { font-size: 15px; }
.tool-tab small { margin-top: 2px; overflow: hidden; color: var(--ink-soft); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.tool-tab.active small { color: #fff; }
.tab-zh-short { display: none !important; }

.ad-zone {
  position: relative;
  min-height: 280px;
  margin-top: 34px;
  padding: 28px 18px 18px;
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  background: rgba(255, 253, 247, .48);
}
.ad-zone[hidden] { display: none; }
.ad-label { position: absolute; top: 7px; left: 50%; color: var(--ink-soft); font-family: var(--font-data); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; transform: translateX(-50%); }
.ad-mount { min-height: 250px; display: grid; place-items: center; }

.calculator-view {
  display: grid;
  grid-template-columns: minmax(430px, .78fr) minmax(600px, 1.22fr);
  gap: 22px;
  align-items: start;
}
.calculator-view[hidden] { display: none; }
.input-panel,
.compare-header,
.scenario-input,
.comparison-results,
.compare-chart-card {
  border: 2px solid var(--line);
  background: var(--surface);
  box-shadow: var(--hard-shadow);
}
.input-panel { min-width: 0; overflow: visible; border-radius: 16px 13px 18px 12px; }
.result-panel {
  min-width: 0;
  padding: 15px;
  border: 2px solid var(--line);
  border-radius: 14px 18px 13px 16px;
  background: var(--teal);
  box-shadow: var(--hard-shadow);
}
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 17px;
  border-bottom: 2px solid var(--line);
}
.panel-heading h2, .compare-header h2 { font-size: 23px; line-height: 1.08; letter-spacing: -.025em; }
.panel-heading p, .compare-header p { margin: 6px 0 0; color: var(--ink-soft); font-size: 14px; }
.panel-heading p.zh, .compare-header p.zh { margin-top: 2px; }
.live-status { display: inline-flex; align-items: center; gap: 6px; color: var(--success); font-family: var(--font-data); font-size: 11px; font-weight: 700; }
.live-status i { width: 8px; height: 8px; border: 1px solid var(--ink); border-radius: 50%; background: #48bb85; }

.calc-form { padding: 0 22px 22px; }
fieldset { min-width: 0; margin: 0; padding: 20px 0; border: 0; border-bottom: 2px solid var(--line); }
fieldset:last-child { padding-bottom: 0; border-bottom: 0; }
legend { width: 100%; margin-bottom: 15px; padding: 0; font-family: var(--font-display); font-size: 16px; }
legend .zh { margin-top: 3px; color: var(--ink-soft); font-family: var(--font-body); font-size: 12px; font-weight: 500; }
.field-grid { display: grid; gap: 14px; }
.field-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; display: grid; align-content: start; gap: 7px; }
.field-label {
  min-height: 39px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  align-content: flex-end;
  gap: 0 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
body.has-translation .field-label { min-height: 44px; }
.field-label label { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.field-label small, .compact-field small { color: var(--ink-soft); font-size: 12px; font-weight: 500; }
body.has-translation .field-label small.zh,
body.has-translation .compact-field small.zh,
body.has-translation .metric small.zh { display: inline !important; }
.field-label.with-info { position: relative; padding-right: 36px; }
.mini-info {
  position: absolute;
  right: -10px;
  bottom: -10px;
  width: 44px;
  height: 44px;
  border: 0;
  color: transparent;
  background: transparent;
  font-size: 0;
}
.mini-info::before {
  content: "i";
  position: absolute;
  inset: 9px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--yellow);
  font-family: var(--font-data);
  font-size: 12px;
  font-weight: 800;
}
.input-wrap { position: relative; min-width: 0; display: block; }
.input-wrap input,
.input-wrap select {
  width: 100%;
  height: 48px;
  padding: 0 45px 0 13px;
  border: 2px solid var(--line);
  border-radius: 9px 12px 9px 11px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease), background 140ms var(--ease);
}
.input-wrap select { padding-right: 34px; appearance: none; }
.select-wrap::after { content: "⌄"; position: absolute; right: 13px; top: 50%; color: var(--ink); font-size: 18px; font-weight: 800; transform: translateY(-58%); pointer-events: none; }
.input-wrap input:hover,
.input-wrap select:hover { background: #fffbed; }
.input-wrap input:focus,
.input-wrap select:focus { background: #fffbed; box-shadow: 3px 3px 0 var(--ink); transform: translate(-1px, -1px); }
.input-wrap input.invalid { border-color: var(--danger); box-shadow: 3px 3px 0 var(--danger); }
.unit { position: absolute; right: 13px; top: 50%; color: var(--ink-soft); font-family: var(--font-data); font-size: 12px; transform: translateY(-50%); pointer-events: none; }
.equity-input-wrap input { padding-right: 102px; }
.equity-mode-switch {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  display: grid;
  grid-template-columns: repeat(2, 44px);
  overflow: hidden;
  border-left: 2px solid var(--line);
  border-radius: 0 8px 8px 0;
  background: var(--surface-muted);
}
.equity-mode-switch button {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-right: 1px solid #bcb5a7;
  color: var(--ink-soft);
  background: transparent;
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 800;
}
.equity-mode-switch button:last-child { border-right: 0; }
.equity-mode-switch button[aria-pressed="true"] { color: #fff; background: var(--teal); }
.equity-mode-switch button:hover:not([aria-pressed="true"]) { color: var(--ink); background: var(--yellow); }
.equity-mode-switch button:focus-visible { position: relative; z-index: 1; outline: 3px solid var(--yellow); outline-offset: -4px; }
.equity-equivalence {
  min-height: 18px;
  display: block;
  color: var(--teal-dark);
  font-family: var(--font-data);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.field-error { display: block; color: var(--danger); font-size: 12px; font-weight: 700; line-height: 1.35; }
.field-error[hidden] { display: none; }
.field-error-translation { display: block; margin-top: 2px; }

.explanation { margin-top: 14px; border: 2px solid var(--line); border-radius: 10px 13px 9px 12px; background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); }
.explanation summary { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 13px; font-size: 13px; font-weight: 700; cursor: pointer; list-style: none; }
.explanation summary::-webkit-details-marker { display: none; }
.explanation summary::after { content: "+"; font-size: 20px; }
.explanation[open] summary::after { content: "−"; }
.explanation summary .zh { margin-left: auto; color: var(--ink); font-weight: 500; }
.explanation div { padding: 0 13px 12px; color: var(--ink); font-size: 13px; }
.explanation p { margin: 0; }
.explanation p.zh { margin-top: 5px; }
.text-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 0 4px;
  border: 0;
  color: var(--teal-dark);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}
.text-button .zh { color: var(--ink-soft); font-weight: 500; }
.text-button svg { width: 17px; margin-inline-start: auto; fill: none; stroke: currentColor; stroke-width: 2; transition: transform 180ms var(--ease); }
.text-button[aria-expanded="true"] svg { transform: rotate(180deg); }
.advanced-fields { margin-top: 7px; padding: 14px; border: 2px dashed var(--line); border-radius: 11px; background: var(--surface-muted); }
.inline-info { margin-top: 13px; padding: 13px 14px; border: 2px solid var(--line); border-radius: 10px 13px 9px 12px; background: var(--teal-pale); }
.inline-info strong { font-family: var(--font-display); font-size: 14px; }
.inline-info p { margin: 4px 0 0; color: #28464d; font-size: 14px; }

.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 2px 4px 12px; color: #fff; }
.result-head > div { display: grid; font-family: var(--font-data); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.result-head small { margin-top: 2px; color: #fff; font-family: var(--font-body); font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.result-badge { padding: 5px 9px; border: 2px solid var(--line); border-radius: 999px; color: var(--ink); background: var(--yellow); font-size: 11px; font-weight: 800; }
.primary-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 2px solid rgba(23,25,24,.48);
}
.primary-result {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 19px 20px;
  color: #fff;
}
.primary-result-secondary { border-left: 2px solid rgba(23,25,24,.48); }
.primary-result > span { font-family: var(--font-data); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.primary-result > small { font-size: 13px; }
.primary-result strong { margin-top: 5px; font-family: var(--font-display); font-size: clamp(42px, 4vw, 62px); line-height: 1; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.primary-result em { margin-top: 8px; font-family: var(--font-data); font-size: 12px; font-style: normal; }
.primary-result em.zh { margin-top: 2px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.rate-metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric {
  min-width: 0;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 13px;
  border: 2px solid var(--line);
  border-radius: 10px 13px 9px 12px;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink);
}
.metric:nth-child(2) { background: var(--pink); }
.metric:nth-child(3) { background: var(--sky); }
.metric:nth-child(4) { background: var(--mint); }
.metric span { font-family: var(--font-data); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
.metric small { margin-top: 2px; color: var(--ink); font-size: 12px; }
.metric strong { margin-top: 7px; overflow: hidden; font-family: var(--font-display); font-size: 18px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }

.chart-card,
.budget-meter-card,
.guidance-card,
.scenario-list,
.cost-breakdown {
  margin-top: 14px;
  padding: 15px;
  border: 2px solid var(--line);
  border-radius: 11px 14px 10px 13px;
  color: var(--ink);
  background: var(--surface);
}
.chart-card { overflow: hidden; background: #fbfaf6; }
.chart-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.chart-heading > div:first-child { display: grid; }
.chart-heading strong { font-family: var(--font-data); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.chart-heading small { margin-top: 2px; color: var(--ink-soft); font-size: 11px; }
.chart-heading > span { color: var(--ink-soft); font-family: var(--font-data); font-size: 11px; }
.chart-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 -15px; border-top: 1px solid #c7c2b8; border-bottom: 1px solid #c7c2b8; background: #f3f0e8; }
.chart-stats > div { min-width: 0; display: grid; gap: 3px; padding: 10px 15px; border-right: 1px solid #c7c2b8; }
.chart-stats > div:last-child { border-right: 0; }
.chart-stats small { color: var(--ink-soft); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.chart-stats small.zh { letter-spacing: 0; text-transform: none; }
.chart-stats strong { overflow: hidden; font-family: var(--font-display); font-size: 15px; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.chart-stats em { margin-left: 4px; color: var(--teal-dark); font-family: var(--font-data); font-size: 10px; font-style: normal; }
.line-chart, .compare-chart { width: 100%; height: auto; overflow: visible; }
.line-chart { margin-top: 8px; }
.grid-lines line { vector-effect: non-scaling-stroke; }
.grid-lines .grid-horizontal { stroke: rgba(23,25,24,.17); stroke-width: 1; }
.grid-lines .grid-vertical { stroke: rgba(23,25,24,.09); stroke-width: 1; stroke-dasharray: 3 5; }
.line-chart .area { fill: rgba(13,126,156,.12); }
.line-chart .line { fill: none; stroke: var(--teal); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-points circle { fill: #fbfaf6; stroke: var(--teal); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-points circle.is-final { fill: var(--yellow); stroke: var(--ink); stroke-width: 2.5; }
.chart-labels text { fill: var(--ink-soft); font-family: var(--font-data); font-size: 10px; }
.chart-endpoint .endpoint-halo { fill: rgba(255,216,79,.28); stroke: none; }
.chart-endpoint text { fill: var(--ink); paint-order: stroke; stroke: #fbfaf6; stroke-width: 5px; stroke-linejoin: round; font-family: var(--font-data); font-size: 11px; font-weight: 800; }
.chart-axis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: -1px 4px 0 61px; color: var(--ink-soft); font-family: var(--font-data); font-size: 10px; }
.chart-axis span { text-align: center; }
.chart-axis span:first-child { text-align: left; }
.chart-axis span:last-child { text-align: right; }
.data-fallback { margin-top: 8px; }
.data-fallback summary { min-height: 44px; display: inline-flex; align-items: center; color: var(--teal-dark); font-size: 12px; font-weight: 800; cursor: pointer; }
.data-fallback table { width: 100%; margin-top: 7px; border-collapse: collapse; font-size: 12px; }
.data-fallback th, .data-fallback td { padding: 7px 4px; border-bottom: 1px solid #bdb4a5; text-align: right; }
.data-fallback th:first-child, .data-fallback td:first-child { text-align: left; }

.cost-breakdown { background: var(--surface); }
.breakdown-head { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 10px; border-bottom: 2px solid var(--line); font-size: 13px; font-weight: 800; }
.breakdown-row { display: flex; justify-content: space-between; gap: 16px; padding-top: 9px; color: var(--ink-soft); font-size: 12px; }
.breakdown-row strong { color: var(--ink); font-family: var(--font-data); }
.breakdown-row .zh { margin-top: 1px; font-size: 11px; }
.stacked-meter { height: 22px; display: flex; overflow: hidden; border: 2px solid var(--line); border-radius: 999px; background: var(--surface-muted); }
.meter-segment { height: 100%; min-width: 0; transition: flex-basis 220ms var(--ease); }
.meter-segment.costs { background: #5e5a50; }
.meter-segment.rate { background: var(--pink); }
.meter-segment.free { background: var(--mint); }
.meter-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.legend-item { min-width: 0; display: grid; grid-template-columns: 9px minmax(0, 1fr); align-items: start; column-gap: 7px; color: var(--ink-soft); font-size: 11px; }
.legend-item i { width: 8px; height: 8px; margin-top: 3px; border: 1px solid var(--line); border-radius: 2px; }
.legend-item i.costs { background: #5e5a50; }
.legend-item i.rate { background: var(--pink); }
.legend-item i.free { background: var(--mint); }
.legend-copy { min-width: 0; display: grid; gap: 2px; line-height: 1.25; }
.legend-copy > span { min-width: 0; overflow-wrap: anywhere; }
.legend-copy > span.zh { color: var(--ink-soft); }
.legend-copy strong { margin-top: 2px; color: var(--ink); font-family: var(--font-data); font-size: 12px; line-height: 1.2; white-space: nowrap; }
.guidance-card { display: flex; align-items: flex-start; gap: 11px; background: var(--yellow); }
.guidance-icon { width: 31px; height: 31px; flex: 0 0 auto; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--surface); font-weight: 800; }
.guidance-card strong { display: block; font-size: 13px; }
.guidance-card p { margin: 4px 0 0; color: var(--ink); font-size: 12px; }
.scenario-list { display: grid; gap: 7px; }
.scenario-row { min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 11px; border-bottom: 1px dashed #837d70; }
.scenario-row:last-child { border-bottom: 0; }
.scenario-row span { display: grid; color: var(--ink-soft); font-size: 12px; }
.scenario-row span small { font-size: 11px; }
.scenario-row strong { font-family: var(--font-data); font-size: 12px; }

.compare-view { display: block; }
.compare-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 21px 23px; border-radius: 15px 12px 17px 13px; }
.compare-header .compact-field { width: min(310px, 100%); }
.scenario-input-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.scenario-input { min-width: 0; padding: 17px; border-radius: 13px 16px 12px 14px; }
.scenario-input:nth-child(1) { background: var(--yellow); }
.scenario-input:nth-child(2) { background: var(--pink); }
.scenario-input:nth-child(3) { background: var(--sky); }
.scenario-input.featured { transform: translateY(-3px) rotate(.25deg); }
.scenario-title { min-height: 43px; display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.scenario-letter { width: 32px; height: 32px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--surface); font-family: var(--font-data); font-weight: 800; }
.scenario-title > div { min-width: 0; display: grid; }
.scenario-title strong { font-size: 14px; }
.scenario-title small { color: var(--ink); font-size: 11px; }
.recommended { margin-left: auto; padding: 4px 7px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 11px; font-weight: 800; }
.scenario-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.compact-field { min-width: 0; display: grid; gap: 6px; color: var(--ink); font-size: 12px; font-weight: 700; }
.scenario-input .compact-field small,
.scenario-input .unit { color: var(--ink); }
body.has-translation .compact-field > span:first-child { min-height: 34px; }
.compact-field .input-wrap input, .compact-field .input-wrap select { height: 44px; font-size: 15px; }
.comparison-results { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; margin-top: 18px; padding: 17px; border-radius: 14px 17px 13px 15px; }
.comparison-table-wrap { min-width: 0; overflow-x: auto; }
.comparison-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.comparison-table th, .comparison-table td { padding: 12px 10px; border-bottom: 2px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.comparison-table th { color: var(--ink-soft); font-family: var(--font-data); font-size: 11px; text-transform: uppercase; }
.comparison-table th:first-child, .comparison-table td:first-child { width: 34%; text-align: left; }
.comparison-table td:not(:first-child) { font-family: var(--font-data); font-weight: 700; }
.comparison-table td.best { background: var(--yellow); }
.comparison-table .zh { color: var(--ink-soft); font-family: var(--font-body); font-size: 11px; font-weight: 500; }
.compare-insight { padding: 15px; border: 2px solid var(--line); border-radius: 10px 13px 9px 12px; background: var(--teal-pale); box-shadow: 3px 3px 0 var(--ink); }
.compare-insight span { width: 36px; height: 36px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; color: #fff; background: var(--teal); font-family: var(--font-data); font-weight: 800; }
.compare-insight strong { display: block; margin-top: 12px; font-size: 13px; }
.compare-insight p { margin: 6px 0 0; color: var(--ink-soft); font-size: 12px; }
.compare-chart-card { margin-top: 18px; padding: 17px; border-radius: 13px 16px 12px 14px; background-color: var(--surface); background-image: radial-gradient(#d5cdbd 1px, transparent 1px); background-size: 14px 14px; }
.chart-legend { display: flex !important; flex-direction: row !important; align-items: center; gap: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-soft); font-family: var(--font-data); font-size: 11px; }
.chart-legend i { width: 19px; height: 0; border: 0; border-top: 4px solid; border-radius: 0; }
.chart-legend i.a { border-color: #5e5a50; }
.chart-legend i.b { border-color: var(--teal); border-top-style: dashed; }
.chart-legend i.c { border-color: #c56f10; border-top-style: dotted; }
.compare-line { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.compare-line.a { stroke: #5e5a50; stroke-width: 5; }
.compare-line.b { stroke: var(--teal); stroke-width: 4.25; stroke-dasharray: 18 10; }
.compare-line.c { stroke: #c56f10; stroke-width: 4; stroke-dasharray: 2 10; }

.content-bridge {
  margin-top: 42px;
  padding: clamp(24px, 4vw, 42px);
  border: 2px solid var(--line);
  border-radius: 18px 14px 20px 13px;
  background: var(--yellow);
  box-shadow: var(--hard-shadow);
}
.content-bridge-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
}
.content-kicker-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.content-kicker { display: block; font-family: var(--font-data); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.content-bridge h2 { max-width: 22ch; margin: 0; font-family: var(--font-display); font-size: clamp(25px, 3.4vw, 42px); line-height: 1.02; letter-spacing: -.04em; text-wrap: balance; }
.content-bridge p { max-width: 64ch; margin: 12px 0 0; color: #403b2f; font-size: 15px; }
.content-link { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 17px; border: 2px solid var(--line); border-radius: 11px; color: #fff; background: var(--ink); box-shadow: 3px 4px 0 var(--teal); font-size: 13px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.content-link:hover { color: #fff; background: var(--teal); }
.guide-title-stage { min-width: 0; }
.guide-title-viewport { min-height: 2.1em; overflow: hidden; perspective: 800px; }
.guide-title-link {
  display: block;
  width: fit-content;
  color: var(--ink);
  text-decoration: none;
  transform-origin: center top;
  will-change: transform, opacity;
}
.guide-title-link:hover { color: var(--teal-dark); }
.guide-title-link > span { display: block; }
.guide-title-link > small.zh {
  display: none;
  margin-top: 8px;
  color: var(--teal-dark);
  font-family: var(--font-body);
  font-size: clamp(14px, 1.45vw, 17px);
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: 0;
}
body.has-translation .guide-title-link > small.zh { display: block; }
body.has-translation .guide-title-viewport { min-height: 3em; }
.guide-title-link.is-leaving { animation: guide-page-out 280ms cubic-bezier(.55, .06, .68, .19) both; }
.guide-title-link.is-entering { animation: guide-page-in 420ms cubic-bezier(.16, 1, .3, 1) both; }
.guide-rotator-toggle {
  width: 30px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, .7);
  box-shadow: 1px 2px 0 var(--ink);
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 900;
}
.guide-rotator-toggle:hover { color: #fff; background: var(--teal); transform: translateY(-1px); }
.guide-rotator-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@keyframes guide-page-out {
  from { opacity: 1; transform: translateY(0) rotateX(0); }
  to { opacity: 0; transform: translateY(-72%) rotateX(48deg); }
}
@keyframes guide-page-in {
  from { opacity: 0; transform: translateY(72%) rotateX(-48deg); }
  to { opacity: 1; transform: translateY(0) rotateX(0); }
}

.app-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 30px; margin-top: 34px; padding: 25px 4px; border-top: 2px solid var(--line); color: var(--ink-soft); }
.app-footer strong { color: var(--ink); font-family: var(--font-display); font-size: 15px; }
.app-footer p { margin: 4px 0 0; font-size: 13px; }
.footer-links { display: flex; gap: 18px; }
.footer-links a { min-height: 44px; display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; text-decoration: underline; text-decoration-color: var(--teal); text-decoration-thickness: 2px; text-underline-offset: 4px; white-space: nowrap; }
.legal-note { grid-column: 1 / -1; max-width: 72ch; }
.legal-details { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.legal-details details { min-width: 0; border-top: 2px solid var(--line); }
.legal-details summary { min-height: 44px; display: flex; align-items: center; padding: 8px 0; color: var(--ink); font-size: 12px; font-weight: 800; cursor: pointer; }
.legal-details p { margin: 0; padding: 0 0 11px; font-size: 13px; }
.mobile-summary { display: none; }

@media (min-width: 1200px) {
  .intro-content h1 { white-space: nowrap; }
}

@media (max-width: 1120px) {
  .app-shell { width: min(100% - 32px, 1050px); }
  .intro { grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; }
  .calculator-view { grid-template-columns: minmax(380px, .86fr) minmax(480px, 1.14fr); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .comparison-results { grid-template-columns: minmax(0, 1fr) 250px; }
}

@media (max-width: 900px) {
  :root { --nav-h: 68px; }
  .app-header { padding-inline: 18px; }
  .brand-copy small { display: none; }
  .app-shell { width: min(100% - 24px, 820px); padding-top: 28px; }
  .intro { grid-template-columns: 1fr; gap: 22px; }
  .source-note { max-width: 520px; }
  .tool-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-tab:nth-child(2) { border-right: 0; }
  .tool-tab:nth-child(-n+2) { border-bottom: 2px solid var(--line); }
  .calculator-view { grid-template-columns: 1fr; }
  .scenario-input-grid { grid-template-columns: 1fr; }
  .scenario-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .comparison-results { grid-template-columns: 1fr; }
  .compare-insight { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; column-gap: 12px; }
  .compare-insight strong { margin-top: 0; }
  .compare-insight p { grid-column: 2; }
}

@media (max-width: 620px) {
  body { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .app-header { min-height: 68px; gap: 8px; padding: 9px 10px; }
  .header-actions { gap: 6px; }
  .brand { gap: 9px; }
  .brand-mark { width: 42px; height: 42px; box-shadow: 2px 3px 0 var(--ink); }
  .brand-mark svg { width: 28px; }
  .brand-copy strong { font-size: 19px; }
  .header-guide-link { min-height: 42px; padding-inline: 8px; font-size: 12px; }
  .language-label { display: none; }
  .language-control { min-height: 48px; padding: 2px; box-shadow: 2px 3px 0 var(--ink); }
  .language-control select { width: 76px; min-width: 0; min-height: 44px; padding-left: 8px; }
  .icon-button { width: 44px; height: 44px; box-shadow: 2px 3px 0 var(--ink); }
  .app-shell { width: min(100% - 18px, 600px); padding-top: 26px; }
  .intro { margin-bottom: 22px; }
  .intro-content,
  body.has-translation .intro-content { display: block; }
  h1 { font-size: clamp(38px, 11.5vw, 50px); line-height: .98; }
  h1::after { width: min(360px, 82%); height: 10px; margin-top: 10px; }
  .intro-copy { font-size: 15px; }
  body.has-translation .intro-copy.zh {
    margin-top: 9px;
    padding-top: 8px;
    padding-left: 0;
    border-top: 2px solid var(--teal);
    border-left: 0;
  }
  .source-note { padding: 13px 14px; }
  .tool-nav {
    position: sticky;
    top: 68px;
    z-index: 200;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    margin-inline: -9px;
    padding: 5px 9px 9px;
    border: 0;
    border-radius: 0;
    background: var(--paper);
    box-shadow: none;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  .tool-nav::-webkit-scrollbar { display: none; }
  .tool-tab,
  .tool-tab:nth-child(2),
  .tool-tab:nth-child(-n+2) {
    width: auto;
    min-width: max-content;
    min-height: 58px;
    flex: 0 0 auto;
    gap: 9px;
    padding: 9px 14px;
    border: 2px solid var(--line);
    border-radius: 11px 14px 10px 13px;
    background: var(--surface);
    box-shadow: 3px 4px 0 var(--ink);
    text-align: center;
    scroll-snap-align: start;
  }
  .tool-tab.active { color: #fff; background: var(--teal); }
  .tool-tab small { display: none !important; }
  body.has-translation .tool-tab small.zh { display: none !important; }
  body.has-translation .tool-tab .tab-zh-short { display: inline !important; margin-left: 4px; color: inherit; font-size: 12px; font-weight: 600; }
  .tool-tab > span { display: flex; align-items: baseline; white-space: nowrap; }
  .tool-tab strong { font-size: 13px; white-space: nowrap; }
  .tab-icon { width: 22px; height: 22px; }
  .content-bridge-head { grid-template-columns: 1fr; align-items: start; }
  .content-link { justify-self: start; white-space: normal; }
  .guide-title-viewport { min-height: 2.75em; }
  body.has-translation .guide-title-viewport { min-height: 4em; }
  .ad-zone { min-height: 300px; margin-top: 28px; padding-inline: 0; }
  .panel-heading { padding: 17px; }
  .panel-heading h2, .compare-header h2 { font-size: 21px; }
  .calc-form { padding-inline: 17px; }
  .field-grid.two-col, .field-grid.three-col { grid-template-columns: 1fr; }
  .field-label, body.has-translation .field-label { min-height: 0; }
  .input-wrap input, .input-wrap select { height: 54px; font-size: 17px; }
  .result-panel { padding: 12px; }
  .primary-result-grid { grid-template-columns: 1fr; }
  .primary-result-secondary { border-top: 2px solid rgba(23,25,24,.48); border-left: 0; }
  .primary-result { min-height: 150px; padding-inline: 14px; }
  .primary-result-grid .primary-result strong { font-size: clamp(30px, 8.2vw, 43px); white-space: nowrap; }
  .metric-grid { gap: 9px; }
  .rate-metric-grid { grid-template-columns: 1fr; }
  .metric { min-height: 98px; padding: 12px; }
  .metric strong { font-size: 16px; }
  .chart-card, .budget-meter-card, .guidance-card, .scenario-list, .cost-breakdown { padding: 13px; }
  .meter-legend { grid-template-columns: 1fr; gap: 10px; }
  .legend-item { grid-template-columns: 10px minmax(0, 1fr); }
  .chart-card svg { min-height: 170px; }
  .compare-header { display: grid; padding: 17px; }
  .compare-header .compact-field { width: 100%; }
  .scenario-input { padding: 15px; }
  .scenario-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.has-translation .compact-field > span:first-child { min-height: 24px; }
  .comparison-results, .compare-chart-card { padding: 13px; }
  .comparison-table { min-width: 590px; }
  .compare-chart { min-height: 210px; }
  .app-footer { grid-template-columns: 1fr; padding-bottom: 20px; }
  .footer-links { flex-wrap: wrap; }
  .legal-details { grid-template-columns: 1fr; }
  .mobile-summary {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 350;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 9px 9px 14px;
    border: 2px solid var(--line);
    border-radius: 14px 17px 13px 15px;
    color: var(--ink);
    background: var(--surface);
    box-shadow: 4px 5px 0 var(--ink);
  }
  .mobile-summary > span { min-width: 0; display: grid; }
  .mobile-summary small { font-size: 11px; font-weight: 700; }
  .mobile-summary strong { overflow: hidden; font-family: var(--font-display); font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-summary button { min-width: 48px; min-height: 48px; padding: 0 14px; border: 2px solid var(--line); border-radius: 10px 13px 9px 12px; color: #fff; background: var(--teal); box-shadow: 2px 3px 0 var(--ink); font-size: 12px; font-weight: 800; white-space: nowrap; }
  .mobile-summary button .zh { font-size: 11px; }
}

@media (max-width: 370px) {
  .brand-copy { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric { min-height: 78px; }
  .scenario-fields { grid-template-columns: 1fr; }
  .meter-legend { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tool-tab,
  .input-wrap input,
  .input-wrap select,
  .text-button svg,
  .meter-segment { transition: none; }
  .guide-title-link.is-leaving,
  .guide-title-link.is-entering { animation: none; }
}
