:root {
  color-scheme: light;
  --graphite: #18181b;
  --graphite-mid: #24252b;
  --red: #c81e1e;
  --red-dark: #a31919;
  --amber: #d97706;
  --amber-ink: #8a4209;
  --surface: #f6f7f9;
  --white: #fff;
  --text: #22252c;
  --muted: #4e5867;
  --line: #d8dde5;
  --display: "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Avenir Next", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --page-gutter: clamp(1rem, 4vw, 3.1rem);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-block-start: 18px; }
body { margin: 0; background: var(--surface); color: var(--text); font: 500 1rem/1.55 var(--body); }
a { color: var(--red-dark); text-underline-offset: 0.2em; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.48; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.13; color: var(--graphite); }
h1, h2 { font-family: var(--display); font-weight: 700; letter-spacing: -0.013em; }
svg { display: block; }
main { min-height: 60vh; }

.site-width { width: min(calc(100% - 2 * var(--page-gutter)), 1250px); margin-inline: auto; }
.sr-only, .skip-link:not(:focus) {
  position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link:focus {
  position: fixed; z-index: 20; top: .75rem; left: .75rem; background: var(--white);
  color: var(--graphite); padding: .6rem 1rem;
}

.site-header { color: var(--white); background: var(--graphite); border-bottom: 1px solid #393940; }
.masthead { display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 14px 28px; }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; font: 700 1.4rem/1 var(--display); }
.brand svg { flex: 0 0 auto; }
.brand strong { color: #ff726c; }
.masthead nav, .site-footer nav { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem clamp(.75rem, 2.5vw, 2.1rem); }
.masthead nav a, .site-footer nav a { color: #f3f3f6; padding-block: .42rem; text-decoration: none; font-size: .92rem; font-weight: 650; }
.masthead nav a:hover, .site-footer nav a:hover { text-decoration: underline; }
.site-footer { background: var(--graphite); color: var(--white); margin-top: clamp(2.5rem, 6vw, 5rem); }
.footer-inner { display: flex; align-items: start; justify-content: space-between; gap: 1.25rem 2rem; padding-block: 2rem; }
.footer-inner p { margin-top: .6rem; font-size: .9rem; color: #cbd0d9; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 42px; padding: .53rem .88rem; border: 1px solid transparent; border-radius: 4px;
  font-weight: 700; font-size: .86rem; line-height: 1.2; text-decoration: none;
  transition: background-color .16s, color .16s, border-color .16s;
}
.button-primary { background: var(--red); color: var(--white); border-color: var(--red); }
.button-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.button-secondary { color: var(--graphite); background: var(--white); border-color: #bfc6d0; }
.button-secondary:hover:not(:disabled) { border-color: var(--graphite); background: #edf0f4; }

.context-label {
  font: 700 .78rem/1.4 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--red-dark);
}
.home-hero { background: var(--graphite); color: var(--white); border-bottom: 4px solid var(--red); }
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center;
  gap: clamp(1.25rem, 4.5vw, 4.6rem); padding-block: clamp(2.3rem, 5.4vw, 4.8rem);
}
.hero-copy { border-left: 3px solid var(--red); padding-left: clamp(1rem, 3vw, 2.25rem); }
.hero-copy .context-label { color: #f5a949; }
.hero-copy h1 {
  font-size: clamp(2.7rem, 5.4vw, 5.2rem); line-height: .98; color: #fafafb;
  letter-spacing: -.026em; margin-top: .55rem;
}
.hero-copy h1 span { display: block; }
.hero-copy > p:not(.context-label):not(.hero-local) { color: #e3e5ec; max-width: 42ch; line-height: 1.55; margin-top: 1.22rem; }
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .85rem 1.15rem; margin-top: 1.55rem; }
.hero-actions .button { min-height: 46px; padding-inline: .95rem; }
.hero-link { color: #f8f8fa; font-size: .87rem; font-weight: 700; }
.hero-local { color: #cbd0d9; font-size: .85rem; margin-top: 1.22rem; }
.status-dot {
  display: inline-block; width: .52rem; height: .52rem; border-radius: 50%;
  background: #f5a949; vertical-align: .08em; margin-right: .25rem;
}
.hero-figure { border: 1px solid #4a4c56; background: var(--graphite-mid); border-radius: 5px; overflow: hidden; }
.hero-figure .technical-diagram { width: 100%; height: auto; }
.hero-figure figcaption { border-top: 1px solid #484a55; }
.hero-figure figcaption a {
  color: #f0f1f5; text-decoration: none; display: flex; gap: .5rem;
  justify-content: space-between; align-items: center; padding: .6rem .8rem; font-size: .9rem;
}
.hero-figure figcaption a:hover { background: #30313a; color: #fff; }
.hero-figure figcaption a svg { flex: 0 0 auto; color: #ffa651; }

.home-body { padding-top: clamp(2.5rem, 5.5vw, 4.3rem); }
.section-heading { margin-bottom: 1rem; }
.section-heading h2 { font-size: clamp(1.95rem, 4vw, 2.85rem); }
.section-heading p { color: var(--muted); margin-top: .35rem; }
.tools-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; }
.tool-card {
  position: relative; display: block; min-height: 166px; padding: 1rem 1rem 1.25rem;
  border: 1px solid var(--line); border-top: 2px solid #aeb6c1; border-radius: 5px;
  color: var(--graphite); background: var(--white); text-decoration: none;
  transition: border-color .16s, background-color .16s;
}
.tool-card:hover { border-color: var(--red); background: #fffafa; }
.tool-card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .66rem; }
.tool-card-top svg, .card-arrow { color: var(--red-dark); }
.tool-card-top span { font: 650 .7rem/1.2 var(--mono); color: var(--muted); text-transform: uppercase; }
.tool-card h3 { font-family: var(--display); font-size: 1.29rem; letter-spacing: -.012em; }
.tool-card p { font-size: .9rem; color: var(--muted); margin-top: .37rem; padding-right: 1.05rem; }
.card-arrow { position: absolute; right: .72rem; bottom: .65rem; }
.examples-section { margin-top: clamp(2.8rem, 6vw, 5rem); }

.page-shell { padding-top: clamp(1.05rem, 2.7vw, 2.15rem); }
.page-intro { margin-bottom: clamp(1.25rem, 3vw, 2.25rem); }
.breadcrumbs { font-size: .8rem; color: var(--muted); margin-bottom: clamp(1.25rem, 2.9vw, 2.25rem); }
.breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .58rem; list-style: none; margin: 0; padding: 0; }
.breadcrumbs li { min-width: 0; overflow-wrap: anywhere; }
.breadcrumbs li + li::before { content: "/"; color: #687486; margin-right: .58rem; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs [aria-current] { color: var(--graphite); font-weight: 700; }
.page-intro h1 { font-size: clamp(2.25rem, 5.2vw, 4.35rem); line-height: 1.02; max-width: 26ch; margin-top: .4rem; overflow-wrap: anywhere; }
.page-intro .lead { color: var(--muted); margin-top: .72rem; max-width: 74ch; font-size: clamp(1rem, 1.65vw, 1.13rem); }

.workbench { display: grid; grid-template-columns: minmax(0, .84fr) minmax(0, 1.16fr); gap: 1rem; align-items: start; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 5px; min-width: 0; }
.setup-panel { container-type: inline-size; }
.panel-heading {
  display: flex; gap: .6rem; justify-content: space-between; align-items: center;
  background: var(--graphite); color: var(--white); padding: .68rem clamp(.75rem, 2.2vw, 1.25rem);
  border-radius: 4px 4px 0 0; min-height: 54px;
}
.panel-heading h2 { color: var(--white); font-size: 1.45rem; }
.result-heading { border-left: 3px solid var(--red); }
.local-indicator { color: #f2cca0; font: 600 .72rem/1.2 var(--mono); text-align: end; }
.unit-toggle { display: inline-flex; border: 1px solid #777d88; border-radius: 4px; background: #313239; padding: 2px; gap: 2px; }
.unit-toggle button {
  min-width: 44px; min-height: 32px; padding: .2rem .48rem; border: 0; border-radius: 2px;
  color: #f5f5f8; background: transparent; font: 650 .79rem/1.2 var(--mono);
}
.unit-toggle [aria-pressed="true"] { color: var(--graphite); background: #fff; font-weight: 850; }
.unit-toggle button:hover:not([aria-pressed="true"]) { background: #464852; }

form[data-setup] { padding: .95rem clamp(.75rem, 2.2vw, 1.25rem) 1.1rem; }
fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
fieldset + fieldset { margin-top: 1.15rem; }
legend {
  display: block; width: 100%; color: var(--amber-ink); font-weight: 700; font-size: .84rem;
  margin-bottom: .6rem; padding: 0 0 .36rem; border-bottom: 1px solid var(--line);
}
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .68rem .65rem; align-items: start; }
.field { display: grid; min-width: 0; }
.field label { min-height: 2.35em; display: flex; align-items: end; line-height: 1.16; margin-bottom: .32rem; font-size: .84rem; font-weight: 700; overflow-wrap: anywhere; }
.input-shell {
  display: flex; width: 100%; min-width: 0; background: var(--surface);
  border: 1px solid #bfc6d1; border-radius: 4px; align-items: stretch;
}
.input-shell:focus-within { border-color: var(--graphite); box-shadow: 0 0 0 2px #f3bd80; }
.input-shell:has([aria-invalid="true"]) { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.input-shell input, .input-shell select, .input-shell textarea, .share-controls input {
  width: 100%; min-width: 0; min-height: 41px; background: transparent; border: 0;
  padding: .45rem .55rem; line-height: 1.2; outline: 0; font: 650 1rem/1.2 var(--mono);
}
.input-shell input::-webkit-inner-spin-button { appearance: none; }
.input-shell input[type="number"] { appearance: textfield; }
.input-shell textarea { resize: vertical; }
.input-shell select { font: 650 .91rem/1.2 var(--body); }
.input-unit {
  display: flex; color: var(--muted); padding: 0 .42rem 0 .12rem; align-items: center;
  white-space: nowrap; font: 550 .69rem/1.1 var(--mono);
}
.field-help, .field-error { font-size: .76rem; line-height: 1.37; margin-top: .28rem; color: var(--muted); overflow-wrap: anywhere; }
.field-help:empty { display: none; }
.field-error { color: var(--red-dark); font-weight: 750; }
[data-tool="gear"] .field:has(#field-ratios) { grid-column: 1 / -1; }
.setup-actions { display: flex; gap: .9rem; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-top: 1.05rem; }
.jump-results { display: none; align-items: center; gap: .25rem; font-size: .85rem; font-weight: 750; }
.jump-results svg { transform: rotate(90deg); }

[data-valid-results] { padding: .8rem clamp(.65rem, 2vw, 1.15rem) .92rem; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .52rem; }
.result-tile {
  padding: .53rem clamp(.45rem, 1.4vw, .82rem) .58rem; background: var(--surface);
  border: 1px solid #e0e4eb; border-left: 2px solid #878e9b; border-radius: 3px; overflow-wrap: anywhere;
}
.result-tile:first-child { border-left-color: var(--red); }
.result-tile.alert { border-left-color: var(--red); background: #fff0ee; }
.result-tile dt { color: var(--muted); font-size: .79rem; font-weight: 700; line-height: 1.13; margin-bottom: .28rem; }
.result-tile dd { font: 750 clamp(1rem, 2vw, 1.55rem)/1.2 var(--mono); color: var(--graphite); }
.result-tile.alert dd { color: var(--red-dark); }
.result-tile .result-note { font: 550 .73rem/1.26 var(--body); color: var(--muted); margin-top: .26rem; }
.diagram-box { margin-top: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.diagram-box figcaption {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .25rem .5rem;
  border-bottom: 1px solid var(--line); background: #fff; padding: .45rem .64rem;
  font-size: .83rem; font-weight: 750; color: var(--graphite);
}
.technical-diagram { inline-size: 100%; block-size: auto; }
.gear-picker { color: var(--muted); font-weight: 650; white-space: nowrap; }
.gear-picker select { padding: .18rem; border: 1px solid #bfc6d0; border-radius: 3px; background: #fff; }
.result-tables { display: grid; gap: .65rem; margin-top: .75rem; }
.result-table { width: 100%; min-width: 0; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .79rem; color: var(--text); }
caption { text-align: left; font-weight: 800; color: var(--graphite); margin: 0 0 .3rem; font-size: .86rem; }
th, td {
  vertical-align: top; border-bottom: 1px solid var(--line); padding: .36rem .36rem;
  text-align: end; line-height: 1.27; overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
}
thead { background: #edf0f4; }
th:first-child { text-align: start; width: 40%; }
[data-tool="gear"] th:first-child { width: 15%; }
[data-tool="ev"] th:first-child { width: 23%; }
[data-tool="tire"] .result-table + .result-table th:first-child { width: 32%; }
tbody th { font-weight: 650; }
.result-message {
  margin-top: .65rem; font-size: .84rem; line-height: 1.45; color: var(--muted);
  border-left: 2px solid #929aa8; padding: .45rem .6rem; background: var(--surface);
}
.result-message.alert { border-left-color: var(--red); color: #861e1e; background: #fff0ee; font-weight: 700; }
.result-message.caution { border-left-color: var(--amber); color: #723a10; background: #fff4e4; }
[data-result-error] { margin-inline: .8rem; margin-bottom: .8rem; }
.print-only { display: none; }

.export-panel { border-top: 1px solid var(--line); padding: .8rem clamp(.65rem, 2vw, 1.15rem); }
.export-main h3 { font-size: .95rem; margin-bottom: .48rem; }
.export-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.export-actions .button { font-size: .8rem; padding-inline: .66rem; min-height: 39px; }
.share-panel { margin-top: .7rem; }
.share-panel label { font-size: .85rem; font-weight: 750; }
.share-controls { display: flex; align-items: stretch; gap: .4rem; margin-top: .22rem; }
.share-controls input {
  border: 1px solid #bfc6d0; border-radius: 4px; background: var(--surface); font-size: .8rem;
}
.share-controls input:focus-visible { outline: 2px solid var(--amber); }
.share-controls button { flex: 0 0 auto; }
.action-status { color: var(--muted); font-size: .82rem; margin-top: .33rem; }
.action-status:empty { margin: 0; }

.content-panel {
  margin-top: 1rem; padding: clamp(1rem, 2.5vw, 1.7rem); background: var(--white);
  border: 1px solid var(--line); border-radius: 5px;
}
.content-panel h2 { font-size: clamp(1.62rem, 3vw, 2.17rem); margin-bottom: .82rem; }
.content-panel h3 { font-size: 1rem; margin-bottom: .3rem; }
.content-panel p { color: var(--muted); }
.formula-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 252px), 1fr)); gap: .7rem; }
.formula-grid article { padding: .75rem; background: var(--surface); border-top: 2px solid #aeb6c1; }
.formula-grid article p + p { margin-top: .4rem; }
.content-panel .formula {
  color: var(--graphite); font: 600 .87rem/1.5 var(--mono); overflow-wrap: anywhere;
}
.limits { margin-top: .85rem; padding-left: .75rem; border-left: 2px solid var(--amber); }
.source-links { margin: .7rem 0 0; padding-left: 1.22rem; font-size: .87rem; }
.source-links li + li { margin-top: .22rem; }
.worked-steps { margin: 0; padding-left: 1.25rem; }
.worked-steps li { padding: .54rem .55rem .54rem .25rem; }
.worked-steps li + li { border-top: 1px solid var(--line); }
.worked-steps li::marker { color: var(--red-dark); font-family: var(--mono); font-weight: 700; }
.worked-panel .takeaway { margin-top: .65rem; padding: .58rem .7rem; background: var(--surface); border-left: 2px solid var(--amber); }
.takeaway + p { margin-top: .5rem; }
.faq-list details + details { border-top: 1px solid var(--line); }
.faq-list summary {
  color: var(--graphite); font-weight: 750; cursor: pointer; padding: .57rem 0; overflow-wrap: anywhere;
}
.faq-list summary::marker { color: var(--red-dark); }
.faq-list details p { padding: 0 0 .65rem .95rem; max-width: 72ch; }
.guide-links {
  display: grid; gap: 0 1rem; grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0; margin: 0; list-style: none;
}
.guide-links li { min-width: 0; border-top: 1px solid var(--line); }
.guide-links a {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: .64rem .38rem;
  text-decoration: none; color: var(--graphite); font-size: .92rem; font-weight: 700; overflow-wrap: anywhere;
}
.guide-links a svg { flex: 0 0 auto; color: var(--red-dark); }
.guide-links a:hover { background: #fdeeed; color: var(--red-dark); }
.info-shell .prose { max-width: 78ch; }
.prose h2 { margin: 1rem 0 .45rem; }
.prose h2:first-child { margin-top: 0; }
.missing-panel { margin-top: clamp(2rem, 9vw, 7rem); max-width: 41rem; border-left: 3px solid var(--red); padding-left: 1rem; }
.missing-panel h1 { font-size: clamp(2.5rem, 7vw, 4.6rem); margin-top: .45rem; }
.missing-panel p { margin: .6rem 0 .9rem; color: var(--muted); }

@container (max-width: 350px) {
  .input-unit { white-space: normal; max-width: 40%; overflow-wrap: anywhere; }
}

@media (max-width: 960px) {
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .jump-results { display: inline-flex; }
  .result-tile dd { font-size: clamp(1.02rem, 2.7vw, 1.45rem); }
}
@media (max-width: 720px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 1.55rem; }
  .hero-copy h1 { font-size: clamp(2.6rem, 8.8vw, 4.3rem); }
  .hero-figure { width: min(100%, 35rem); }
}
@media (max-width: 560px) {
  .masthead { flex-direction: column; align-items: start; min-height: 0; padding-block: .65rem .42rem; gap: .25rem; }
  .masthead nav a, .site-footer nav a { font-size: .85rem; }
  .footer-inner { flex-direction: column; }
  .tools-grid { gap: .5rem; }
  .tool-card { min-height: 156px; padding: .72rem .64rem 1.4rem; }
  .tool-card h3 { font-size: 1.12rem; }
  .tool-card p { font-size: .8rem; padding: 0; }
  .tool-card-top { margin-bottom: .5rem; }
  .tool-card-top span { font-size: .59rem; }
  .tool-card-top svg { width: 27px; height: 27px; }
  .guide-links { grid-template-columns: minmax(0, 1fr); }
  th, td { padding-inline: .22rem; font-size: .75rem; }
}
@media (max-width: 360px) {
  .hero-copy h1 { font-size: 2.4rem; }
  .export-actions .button { padding-inline: .48rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; }
}

@page { margin: 12mm; }
@media print {
  html, body { background: #fff; color: #111; font-size: 9pt; }
  body { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  main { min-height: 0; }
  .site-header, .site-footer, .skip-link, .breadcrumbs, .page-intro .context-label,
  .page-intro .lead, .setup-panel, .result-heading, .export-panel, .gear-picker,
  .page-tool .content-panel, .page-guide .content-panel { display: none !important; }
  .site-width { width: 100%; max-width: none; }
  .page-shell { padding: 0; }
  .page-intro { margin: 0 0 2mm; }
  .page-intro h1 { font-size: 20pt; max-width: none; }
  .page-tool .page-intro::before, .page-guide .page-intro::before {
    content: "AUTOTORQUELAB  /  SETUP SPEC SHEET"; display: block;
    font: 700 9pt/1.2 var(--mono); color: var(--red-dark); margin-bottom: 2mm;
  }
  .workbench { display: block; }
  .panel { border: 0; }
  [data-valid-results] { padding: 0; }
  .print-only { display: block; }
  .print-inputs { margin-bottom: 2mm; }
  .print-inputs h2 { font-size: 11pt; margin-bottom: 1mm; }
  .print-inputs dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1mm 3mm; }
  .print-inputs dl div { padding: .4mm 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
  .print-inputs dt { color: var(--muted); font-size: 7.7pt; }
  .print-inputs dd { font: 650 8pt/1.16 var(--mono); }
  .result-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.5mm; break-inside: avoid; }
  .result-tile { padding: 1.2mm; }
  .result-tile dt { font-size: 7.8pt; margin-bottom: .6mm; }
  .result-tile dd { font-size: 10pt; }
  .result-tile .result-note { font-size: 7pt; }
  .diagram-box { margin: 2mm 0; break-inside: avoid; }
  .diagram-box figcaption { padding: 1mm 2mm; }
  .diagram-box .technical-diagram { width: 110mm; max-width: 100%; margin-inline: auto; }
  .result-tables { margin-top: 1mm; gap: 1.2mm; }
  table { font-size: 7.7pt; }
  caption { font-size: 8.6pt; margin-bottom: .4mm; }
  th, td { padding: .6mm 1mm; }
  tr { break-inside: avoid; }
  .result-message { margin-top: 1mm; padding: 1mm 1.5mm; font-size: 7.4pt; }
  .print-assumptions { margin-top: 2mm; font-size: 7.4pt; color: var(--muted); }
}
