/* The calculator page: same colour tokens as the homepage, phone first. */
:root {
  color-scheme: light;
  --paper: #fcfcfe;
  --surface: #ffffff;
  --wash: #f1f2f8;
  --ink: #252630;
  --muted: #646674;
  --line: #e1e2eb;
  --accent: #5553b8;
  --accent-wash: #eeedf8;
  --on-ink: #ffffff;
  --good: #2f7a4f;
  --warn: #a2541b;
  --display: "Avenir Next", "SF Pro Display", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #17171d;
    --surface: #202027;
    --wash: #26262f;
    --ink: #f0f0f6;
    --muted: #afb0bf;
    --line: #3a3a47;
    --accent: #b0adff;
    --accent-wash: #2d2b41;
    --on-ink: #19191f;
    --good: #7fd3a1;
    --warn: #f0a46a;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); line-height: 1.6; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-underline-offset: 4px; }
h1, h2 { margin: 0; font-family: var(--display); }
p { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; top: 8px; left: 8px; transform: translateY(-180%); padding: 8px 14px; background: var(--surface); z-index: 5; }
.skip-link:focus { transform: none; }

.calc-header { max-width: 1080px; margin: 0 auto; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.calc-brand { color: var(--ink); text-decoration: none; font-family: var(--display); font-weight: 600; font-size: 17px; }
.calc-brand span { color: var(--muted); font-weight: 500; }
.calc-header-link { font-size: 14px; }

.calc-main { max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; outline: none; }
.calc-intro { padding: 12px 0 20px; }
.calc-intro h1 { font-size: 30px; line-height: 1.25; }
.calc-intro p { margin-top: 8px; color: var(--muted); font-size: 15px; }

.calc-layout { display: grid; gap: 20px; }
.calc-form { display: grid; gap: 16px; min-width: 0; }
fieldset { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
legend { padding: 0 6px; font-weight: 600; font-size: 15px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; font-size: 15px; min-width: 0; }
.field small, .hint { color: var(--muted); font-size: 13px; }
.input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.input input { flex: 1; min-width: 0; padding: 12px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 17px; outline: none; }
.input em { padding-right: 12px; color: var(--muted); font-style: normal; font-size: 14px; white-space: nowrap; }
.field[data-invalid] .input { border-color: var(--warn); }
.field-error { color: var(--warn); font-size: 13px; }

.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.presets button { padding: 10px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; }
.presets button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.presets button:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.more { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 0 16px; }
.more summary { padding: 14px 0; cursor: pointer; font-weight: 600; font-size: 15px; }
.more[open] { padding-bottom: 16px; }
.more .field + .field { margin-top: 14px; }

.calc-result { min-width: 0; }
.result-card { padding: 20px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 14px; }
.result-empty { padding: 20px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }
.result-label { color: var(--muted); font-size: 14px; }
.result-big { font-family: var(--display); font-size: 36px; line-height: 1.15; font-weight: 700; color: var(--accent); }
.result-sub { font-size: 15px; }
.result-facts { display: grid; gap: 8px; margin: 0; padding: 14px 0 0; border-top: 1px solid var(--line); }
.result-facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.result-facts dt { color: var(--muted); }
.result-facts dd { margin: 0; text-align: right; font-weight: 600; }
.result-tip { padding: 12px; border-radius: 10px; background: var(--wash); font-size: 14px; }
.result-warn { color: var(--warn); }
.chart { width: 100%; height: auto; display: block; }
.chart .area { fill: var(--accent-wash); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .axis { stroke: var(--line); }
.chart .marker { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--body); }
.chart-caption { color: var(--muted); font-size: 12px; }
.button { display: inline-flex; justify-content: center; align-items: center; padding: 12px 18px; border: 1px solid var(--ink); border-radius: 10px; background: var(--ink); color: var(--on-ink); font: inherit; font-size: 15px; cursor: pointer; }
.button:hover { background: var(--accent); border-color: var(--accent); }
.button-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.button-quiet:hover { color: var(--on-ink); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.result-actions small { color: var(--muted); font-size: 13px; }

.calc-history { margin-top: 28px; }
.calc-history h2, .calc-notes summary { font-size: 18px; }
.calc-history ol { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.calc-history li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 14px; }
.calc-history li span:first-child { color: var(--muted); }
.calc-history .delta-good { color: var(--good); }
.calc-history .delta-bad { color: var(--warn); }
.calc-history button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; }

.calc-notes { margin-top: 28px; display: grid; gap: 4px; }
.calc-notes details { border-top: 1px solid var(--line); padding: 12px 0; }
.calc-notes summary { cursor: pointer; font-family: var(--display); font-weight: 600; font-size: 16px; }
.calc-notes ul, .calc-notes p { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.calc-notes ul { padding-left: 20px; }
.calc-desktop { margin-top: 20px; padding: 16px; border-radius: 14px; background: var(--wash); font-size: 14px; }

@media (min-width: 880px) {
  .calc-header { padding: 22px 24px; }
  .calc-main { padding: 0 24px 64px; }
  .calc-intro { padding: 24px 0 28px; }
  .calc-intro h1 { font-size: 40px; }
  .calc-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 32px; align-items: start; }
  .calc-result { position: sticky; top: 20px; }
  .result-big { font-size: 44px; }
}
@media (prefers-reduced-motion: no-preference) { .button { transition: background .15s, border-color .15s; } }
.calc-history li span:first-child { white-space: nowrap; }

.row-block { margin-top: 18px; display: grid; gap: 8px; }
.row-block h3 { margin: 0; font-size: 15px; font-family: var(--display); }
.row-line { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); margin-bottom: 8px; }
.row-line .cell { flex: 1 1 88px; display: grid; gap: 2px; font-size: 12px; color: var(--muted); min-width: 0; }
.row-line input, .row-line select { width: 100%; min-width: 0; padding: 9px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; }
.row-line select { width: auto; }
.row-line button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 8px 4px; }
.row-line[data-invalid] { border-color: var(--warn); }
.row-line .field-error { flex-basis: 100%; }
.row-block .button { justify-self: start; padding: 8px 14px; font-size: 14px; }
.compare { width: 100%; border-collapse: collapse; font-size: 14px; }
.compare caption { text-align: left; color: var(--muted); font-size: 13px; padding-bottom: 6px; }
.compare th, .compare td { padding: 8px 6px; text-align: left; border-top: 1px solid var(--line); font-weight: 400; }
.compare thead th { color: var(--muted); font-size: 12px; border-top: 0; }
.compare tr.current th, .compare tr.current td { font-weight: 700; color: var(--accent); }
