:root {
  color-scheme: light;
  --canvas: #fcf9f8;
  --surface: #fff;
  --surface-muted: #f0edec;
  --graphite: #1b1c1b;
  --muted: #5f6366;
  --steel: #74777a;
  --border: #c4c7ca;
  --accent: #fe6b00;
  --accent-dark: #8a3600;
  --comparison: #176c69;
  --comparison-surface: #d4ecea;
  --error: #ba1a1a;
  --error-surface: #ffdad6;
  --focus: #fe6b00;
  --shell: 1200px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--graphite);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 0; background: var(--canvas); }
button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-dark); text-underline-offset: 3px; }
a:hover { color: var(--graphite); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 24px; line-height: 32px; margin-bottom: 12px; }
h2 { font-size: 20px; line-height: 28px; margin-bottom: 8px; }
h3 { font-size: 16px; line-height: 24px; margin-bottom: 8px; }
p { margin-bottom: 16px; }
.shell { width: min(calc(100% - 48px), var(--shell)); margin-inline: auto; }
.skip-link { position: fixed; left: 16px; top: 12px; z-index: 100; background: var(--graphite); color: #fff; padding: 10px 14px; opacity: 0; clip-path: inset(50%); transform: translateY(calc(-100% - 24px)); pointer-events: none; }
.skip-link:focus-visible { opacity: 1; clip-path: inset(0); transform: translateY(0); pointer-events: auto; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header { height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.wordmark { color: var(--graphite); font-weight: 750; text-decoration: none; }
.header-link { min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; font-weight: 650; text-decoration: none; border-bottom: 2px solid var(--accent); }
.intro { padding-block: 40px 32px; max-width: 780px; margin-left: max(24px, calc((100vw - var(--shell)) / 2)); }
.intro p { color: var(--muted); font-size: 17px; line-height: 26px; margin: 0; }

.calculator-band { border-block: 1px solid var(--border); background: var(--surface); }
.calculator-heading-row { padding-block: 24px 16px; }
.calculator-heading-row p { color: var(--muted); margin: 0; }
.controls-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding-block: 16px 24px; }
.control-group { min-width: 0; border: 0; padding: 0; margin: 0; }
.control-group legend, .control-group > label, .field > label, .group-label { display: block; font-size: 12px; line-height: 16px; font-weight: 700; margin-bottom: 8px; }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 44px; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.segmented button { min-height: 44px; border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--graphite); padding: 8px 12px; cursor: pointer; }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--graphite); color: #fff; }
.help { color: var(--muted); font-size: 14px; line-height: 20px; margin: 6px 0 0; }
.unit-label { color: var(--muted); font-weight: 500; }
input[type="number"] { width: 100%; height: 44px; border: 1px solid var(--steel); border-radius: 4px; background: var(--surface); color: var(--graphite); padding: 8px 12px; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; }
input[aria-invalid="true"] { border: 2px solid var(--error); }
.field-error { min-height: 20px; color: var(--error); font-size: 14px; line-height: 20px; margin: 4px 0 0; }

.workspace { display: grid; grid-template-columns: 440px minmax(0, 1fr); border-top: 1px solid var(--border); }
.input-rail { padding: 28px 32px 32px 0; border-right: 1px solid var(--border); }
.results-panel { min-width: 0; padding: 28px 0 40px 32px; }
.config-section + .config-section { border-top: 1px solid var(--border); padding-top: 28px; margin-top: 28px; }
.config-section[data-config="b"] { border-left: 4px solid var(--comparison); padding-left: 16px; }
.section-description { color: var(--muted); font-size: 14px; line-height: 20px; }
.section-heading-row { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.form-section { border-top: 1px solid var(--border); margin-top: 24px; padding-top: 20px; }
.form-section > h3 { margin-bottom: 4px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.field-grid.metric { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; }
.tire-disclosure { border-left: 3px solid var(--steel); padding-left: 12px; color: var(--muted); font-size: 14px; line-height: 20px; margin-top: 16px; }
.derived-value { background: var(--surface-muted); padding: 12px; margin-top: 12px; font-size: 14px; }
.gear-list { display: grid; gap: 10px; margin-top: 16px; }
.gear-row { display: grid; grid-template-columns: 58px minmax(0, 1fr) 44px; gap: 8px; align-items: start; }
.gear-row > label { min-height: 44px; display: flex; align-items: center; font-size: 14px; font-weight: 650; }
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--error); cursor: pointer; font-size: 22px; }
.icon-button:disabled { color: var(--steel); background: var(--surface-muted); cursor: not-allowed; }
.row-error { grid-column: 2 / -1; min-height: 0; }
.compare-control { border-block: 1px solid var(--border); margin-block: 28px; padding-block: 12px; }
.switch-row { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-row span { display: grid; gap: 2px; }
.switch-row small { color: var(--muted); font-size: 13px; line-height: 18px; }
.switch-row input { width: 44px; height: 24px; accent-color: var(--comparison); }

.button, .text-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; padding: 9px 14px; font-weight: 700; cursor: pointer; text-decoration: none; }
.button { border: 1px solid var(--graphite); }
.button-primary { background: var(--graphite); color: #fff; }
.button-primary:hover { background: var(--accent); color: var(--graphite); }
.button-secondary { background: var(--surface); color: var(--graphite); }
.button-danger { background: var(--error); border-color: var(--error); color: #fff; }
.button:disabled { background: var(--surface-muted); color: var(--steel); border-color: var(--border); cursor: not-allowed; }
.text-button { border: 0; background: transparent; color: var(--accent-dark); }
.command-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.command-status { min-height: 24px; margin: 8px 0 0; color: var(--comparison); font-size: 14px; }

.empty-results { min-height: 260px; display: grid; align-content: center; border-block: 1px solid var(--border); padding: 32px; background: var(--canvas); }
.empty-results p { color: var(--muted); margin-bottom: 0; }
.result-disclosure { background: #fff4eb; border-left: 4px solid var(--accent); padding: 16px; font-size: 14px; line-height: 21px; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); margin-block: 24px; }
.summary-item { background: var(--surface); padding: 12px; min-width: 0; }
.summary-item dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.summary-item dd { margin: 4px 0 0; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-weight: 650; overflow-wrap: anywhere; }
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 700; padding: 12px; background: var(--surface-muted); }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-size: 12px; background: var(--canvas); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.comparison-value { color: var(--comparison); font-weight: 700; }
.comparison-metrics { display: grid; gap: 3px; min-width: 150px; margin: 0; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.comparison-metrics div { display: flex; justify-content: space-between; gap: 10px; }
.comparison-metrics dt { color: var(--muted); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 11px; font-weight: 700; }
.comparison-metrics dd { margin: 0; font-weight: 650; }

.alert { display: flex; justify-content: space-between; align-items: start; gap: 20px; padding: 16px; margin-block: 12px 20px; border: 1px solid var(--error); background: var(--error-surface); }
.alert[hidden] { display: none; }
.alert p { margin: 4px 0 0; }
.alert ul { margin-bottom: 0; }
.alert-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.content-band { padding-block: 64px; border-bottom: 1px solid var(--border); }
.content-band:nth-of-type(even) { background: var(--surface); }
.prose-wide { max-width: 920px; }
.method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--border); margin-top: 32px; }
.method-grid article { padding: 24px 24px 24px 0; border-bottom: 1px solid var(--border); }
.method-grid article:nth-child(even) { padding-left: 24px; border-left: 1px solid var(--border); }
.method-grid article:last-child { grid-column: 1 / -1; border-left: 0; }
code { display: block; white-space: normal; overflow-wrap: anywhere; background: var(--surface-muted); border-left: 3px solid var(--steel); padding: 10px 12px; margin-top: 8px; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 13px; }
.faq details { border-top: 1px solid var(--border); }
.faq details:last-child { border-bottom: 1px solid var(--border); }
.faq summary { min-height: 52px; display: flex; align-items: center; cursor: pointer; padding: 12px 4px; }
.faq summary h3 { margin: 0; }
.faq details p { padding: 0 32px 20px 4px; margin: 0; }

.site-footer { background: var(--graphite); color: #e6e1df; padding-block: 40px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 40px; }
.footer-copy { max-width: 590px; }
.footer-copy p { color: #c9c5c3; font-size: 14px; margin: 5px 0 0; }
.legal-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px 24px; list-style: none; margin: 0; padding: 0; }
.legal-links a { min-height: 44px; display: inline-flex; align-items: center; color: #e6e1df; text-decoration: none; white-space: nowrap; }
.legal-links a:hover { color: var(--accent); text-decoration: underline; }

.legal-main { min-height: 60vh; padding-block: 40px 72px; }
.legal-shell { max-width: 760px; }
.back-link { min-height: 44px; display: inline-flex; align-items: center; margin-bottom: 28px; font-weight: 700; }
.legal-prose h1 { margin-bottom: 20px; }
.legal-prose h2 { margin: 36px 0 12px; padding-top: 20px; border-top: 1px solid var(--border); }
.legal-prose li { margin-bottom: 8px; }
.legal-prose code { display: inline; padding: 1px 4px; border: 0; }
.mail-link { margin-block: 8px 12px; }
.not-found { min-height: 60vh; display: grid; align-items: center; padding-block: 64px; }
.eyebrow { color: var(--accent-dark); font-weight: 750; }
dialog { width: min(calc(100% - 32px), 380px); border: 1px solid var(--border); border-radius: 4px; padding: 24px; }
dialog::backdrop { background: rgb(27 28 27 / 55%); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

@media (max-width: 820px) {
  .shell { width: min(calc(100% - 32px), var(--shell)); }
  .intro { width: min(calc(100% - 32px), 780px); margin-inline: auto; padding-block: 32px 24px; }
  .controls-grid { grid-template-columns: 1fr; gap: 20px; }
  .workspace { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .input-rail { padding: 24px 0 32px; border-right: 0; border-bottom: 1px solid var(--border); }
  .results-panel { padding: 28px 0 40px; }
  .footer-inner { flex-direction: column; align-items: center; text-align: center; }
  .legal-links { justify-content: center; gap: 4px 16px; }
}

@media (max-width: 520px) {
  .site-header { height: 64px; }
  .field-grid, .field-grid.metric, .summary-grid, .method-grid { grid-template-columns: minmax(0, 1fr); }
  .method-grid article, .method-grid article:nth-child(even), .method-grid article:last-child { grid-column: auto; padding: 20px 0; border-left: 0; }
  .command-row .button { flex: 1 1 140px; }
  .alert { flex-direction: column; }
  .alert-actions { width: 100%; }
  .alert-actions .button { width: 100%; }
  .results-panel { min-width: 0; }
  .table-wrap { border: 0; overflow: visible; }
  table, caption, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  tbody { display: grid; gap: 12px; }
  tbody tr { border: 1px solid var(--border); background: var(--surface); padding: 10px 12px; }
  tbody th, tbody td { display: flex; justify-content: space-between; gap: 16px; min-height: 34px; padding: 6px 0; border-bottom: 1px solid var(--surface-muted); white-space: normal; text-align: right; }
  tbody th::before, tbody td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; text-align: left; }
  tbody tr > :last-child { border-bottom: 0; }
  .comparison-metrics { width: min(100%, 185px); min-width: 0; }
  caption { width: 100%; border: 1px solid var(--border); border-bottom: 0; white-space: normal; overflow-wrap: normal; }
  .legal-main { padding-block: 24px 56px; }
}

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