:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --border: #dfe5ef;
  --border-strong: #cbd5e1;
  --text: #111c31;
  --muted: #64748b;
  --blue: #1769e0;
  --blue-dark: #0f55bd;
  --blue-soft: #eaf3ff;
  --green: #087a45;
  --green-soft: #eefaf4;
  --amber: #9a5b00;
  --amber-soft: #fff7e6;
  --red: #b42318;
  --red-soft: #fff1f0;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -20%, rgba(23, 105, 224, 0.1), transparent 34rem),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

svg {
  display: block;
  max-width: 100%;
}

.site-header {
  min-height: 64px;
  border-bottom: 1px solid rgba(203, 213, 225, 0.78);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  width: min(1480px, calc(100% - 40px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand,
.github-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
}

.brand-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
}

.brand-icon svg {
  width: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.github-button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.github-button:hover {
  border-color: #94a3b8;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.github-button svg {
  width: 20px;
  fill: currentColor;
}

.page-wrap {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 0;
}

.hero {
  text-align: center;
  margin: 0 auto 24px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.hero p {
  max-width: 780px;
  margin: 12px auto 0;
  color: #56647a;
  font-size: clamp(1rem, 1.6vw, 1.2rem);
}

.calculator-shell {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(560px, 1.15fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.input-panel,
.results-panel {
  min-width: 0;
  padding: 28px;
}

.input-panel {
  border-right: 1px solid var(--border);
}

.results-panel {
  background: linear-gradient(180deg, #fff, #fcfdff 70%);
}

.form-section + .form-section {
  margin-top: 28px;
  padding-top: 25px;
  border-top: 1px solid var(--border);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.35;
}

.section-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.section-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  color: var(--blue);
  display: grid;
  place-items: center;
}

.section-icon svg {
  width: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.success-icon {
  color: var(--green);
}

.full-field {
  margin-top: 20px;
}

.field-grid,
.angle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.measurement-grid {
  margin-top: 17px;
}

.angle-grid {
  margin-top: 18px;
  gap: 14px;
}

.field {
  min-width: 0;
}

.field label,
.dialog-unit-row label,
.measurement-groups label {
  display: block;
  margin-bottom: 7px;
  color: #172036;
  font-size: 0.88rem;
  font-weight: 680;
}

.field input,
.field select,
.dialog-unit-row select,
.measurement-groups input {
  width: 100%;
  min-height: 45px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.field > select,
.dialog-unit-row select {
  padding: 9px 12px;
}

.field input,
.measurement-groups input {
  padding: 10px 12px;
}

.field input:focus,
.field select:focus,
.dialog-unit-row select:focus,
.measurement-groups input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.13);
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--red);
  background: var(--red-soft);
}

.field small {
  display: block;
  margin-top: 7px;
  min-height: 1.3em;
  color: var(--muted);
  font-size: 0.78rem;
}

.field-error {
  display: block;
  min-height: 1.2em;
  margin-top: 4px;
  color: var(--red);
  font-size: 0.78rem;
}

.input-with-unit,
.input-with-suffix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.input-with-unit input,
.input-with-suffix input {
  border-radius: 9px 0 0 9px;
}

.input-with-unit select {
  width: 78px;
  padding: 8px 10px;
  border-left: 0;
  border-radius: 0 9px 9px 0;
  background: #f8fafc;
}

.input-with-unit select:disabled {
  color: #334155;
  opacity: 1;
  cursor: default;
}

.input-with-suffix span {
  min-width: 43px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 9px 9px 0;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.vehicle-helper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding: 13px 14px;
  border: 1px solid #bdd7ff;
  border-radius: 10px;
  background: var(--blue-soft);
}

.vehicle-helper strong,
.vehicle-helper span {
  display: block;
}

.vehicle-helper strong {
  color: #114ba1;
  font-size: 0.86rem;
}

.vehicle-helper span {
  color: #47617f;
  font-size: 0.78rem;
}

.text-button {
  flex: 0 0 auto;
  border: 0;
  padding: 0;
  color: var(--blue-dark);
  background: transparent;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.form-message {
  min-height: 1.5em;
  margin: 15px 0 0;
  color: var(--red);
  font-size: 0.86rem;
}

.form-message.is-success {
  color: var(--green);
}

.form-actions,
.result-actions,
.dialog-actions {
  display: flex;
  gap: 10px;
}

.form-actions {
  margin-top: 8px;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 46px;
  border-radius: 9px;
  font-weight: 760;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.primary-button {
  border: 1px solid var(--blue);
  background: linear-gradient(180deg, #287af0, #1769e0);
  color: #fff;
  box-shadow: 0 9px 22px rgba(23, 105, 224, 0.22);
}

.primary-button:hover {
  background: linear-gradient(180deg, #1f70e7, #0f5fcf);
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: #27364f;
  padding: 9px 15px;
}

.secondary-button:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

#calculate-button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 1rem;
}

#calculate-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.results-heading-row,
.vehicle-results-header,
.diagram-toolbar,
.formula-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.calculation-basis,
.local-processing {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #1757ad;
  font-size: 0.75rem;
  font-weight: 740;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.metric-card {
  min-width: 0;
  min-height: 110px;
  padding: 16px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  text-align: center;
  box-shadow: 0 6px 17px rgba(15, 23, 42, 0.035);
}

.metric-card span,
.metric-card small {
  display: block;
}

.metric-card span {
  min-height: 2.5em;
  color: #334155;
  font-size: 0.78rem;
}

.metric-card strong {
  display: block;
  margin: 5px 0 2px;
  color: #095bc9;
  font-size: clamp(1.08rem, 1.5vw, 1.42rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.metric-card small {
  color: #64748b;
  font-size: 0.73rem;
}

.formula-row {
  margin: 18px 0 12px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  color: #475569;
  font-size: 0.78rem;
}

.local-processing {
  background: #f1f5f9;
  color: #526077;
}

.diagram-card {
  margin: 0;
  padding: 14px 16px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  overflow: hidden;
}

.diagram-toolbar {
  margin-bottom: 3px;
  color: #334155;
  font-size: 0.8rem;
}

.diagram-toolbar figcaption {
  color: #172036;
  font-weight: 760;
}

#ramp-diagram {
  width: 100%;
  max-width: 100%;
  min-height: 250px;
}

.ground-line {
  stroke: #9ca8b9;
  stroke-width: 2;
  stroke-dasharray: 7 7;
}

.ramp-line,
.platform-line {
  stroke: #68758a;
  stroke-width: 10;
  stroke-linecap: square;
}

.dimension-line {
  stroke: #3d4b63;
  stroke-width: 1.5;
  marker-start: none;
  marker-end: none;
}

.angle-arc {
  fill: none;
  stroke: #475569;
  stroke-width: 1.5;
}

.car-body {
  fill: #f8fafc;
  stroke: #27364f;
  stroke-width: 2;
}

.car-window {
  fill: #a8c6e7;
  stroke: #27364f;
  stroke-width: 1.5;
}

.car-wheel {
  fill: #263247;
  stroke: #fff;
  stroke-width: 2;
}

.car-hub {
  fill: #cbd5e1;
}

.diagram-label {
  fill: #3d4b63;
  font-size: 14px;
}

.primary-label {
  fill: #095bc9;
  font-weight: 750;
}

.strong-label {
  fill: #1e293b;
  font-weight: 750;
}

.vehicle-results {
  margin-top: 20px;
  padding-top: 19px;
  border-top: 1px solid var(--border);
}

.vehicle-results-header h3 {
  margin: 0;
  font-size: 1.04rem;
}

.vehicle-results-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.clearance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.clearance-card {
  padding: 13px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  text-align: center;
}

.clearance-card span,
.clearance-card small {
  display: block;
}

.clearance-card span {
  color: #475569;
  font-size: 0.76rem;
}

.clearance-card strong {
  display: block;
  margin: 5px 0 2px;
  font-size: 0.96rem;
}

.clearance-card small {
  color: #64748b;
  font-size: 0.7rem;
}

.status-pass {
  color: var(--green);
  border-color: #b8e3ce;
  background: var(--green-soft);
}

.status-marginal,
.status-partial {
  color: var(--amber);
  border-color: #efcf91;
  background: var(--amber-soft);
}

.status-risk {
  color: var(--red);
  border-color: #f1b8b3;
  background: var(--red-soft);
}

.status-neutral {
  color: #526077;
  border-color: #d7dee8;
  background: #f8fafc;
}

.recommendation-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid #bdd7ff;
  border-radius: 10px;
  background: var(--blue-soft);
  color: #24466f;
}

.recommendation-card p {
  margin: 0;
  font-size: 0.82rem;
}

.recommendation-icon {
  flex: 0 0 21px;
  color: var(--blue-dark);
}

.recommendation-icon svg,
.tip-strip svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.result-actions {
  justify-content: flex-end;
  margin-top: 13px;
}

.result-actions .secondary-button {
  min-height: 39px;
  font-size: 0.78rem;
}

.tip-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 20px 0 0;
  padding: 12px 18px;
  border: 1px solid #c9dcfa;
  border-radius: 11px;
  background: #eef5ff;
  color: #1f4d8c;
  text-align: center;
}

.tip-strip p {
  margin: 0;
  font-size: 0.82rem;
}

.support-content {
  margin: 48px auto;
  padding: 32px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--border);
}

.support-content h2 {
  margin: 0;
  font-size: 1.5rem;
}

.support-content > div > p {
  max-width: 880px;
  color: #56647a;
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 23px;
}

.support-grid article {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.support-grid h3 {
  margin: 0 0 7px;
  font-size: 1rem;
}

.support-grid p {
  margin: 0;
  color: #5e6d82;
  font-size: 0.86rem;
}

.measurement-dialog {
  width: min(860px, calc(100% - 30px));
  max-height: min(820px, calc(100vh - 30px));
  padding: 0;
  border: 0;
  border-radius: 15px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.measurement-dialog::backdrop {
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(3px);
}

.measurement-dialog form {
  padding: 24px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-heading h2 {
  margin: 0;
}

.dialog-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  border: 1px solid var(--border);
  background: #fff;
  color: #475569;
  font-size: 1.4rem;
  line-height: 1;
}

.dialog-unit-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--blue-soft);
}

.dialog-unit-row label {
  margin: 0;
}

.measurement-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.measurement-groups fieldset {
  min-width: 0;
  margin: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.measurement-groups legend {
  padding: 0 6px;
  color: #164f9d;
  font-weight: 750;
}

.measurement-groups label:not(:first-of-type) {
  margin-top: 12px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 7px;
}

.dialog-actions .primary-button {
  padding: 9px 18px;
}

.site-footer {
  padding: 25px 20px 32px;
  border-top: 1px solid var(--border);
  color: #64748b;
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.82rem;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(23, 105, 224, 0.25);
  outline-offset: 2px;
}

@media (max-width: 1100px) {
  .calculator-shell {
    grid-template-columns: minmax(380px, 0.92fr) minmax(470px, 1.08fr);
  }

  .input-panel,
  .results-panel {
    padding: 22px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card {
    min-height: 96px;
  }
}

@media (max-width: 820px) {
  .site-header {
    position: static;
  }

  .header-inner,
  .page-wrap {
    width: min(100% - 24px, 720px);
  }

  .page-wrap {
    padding-top: 22px;
  }

  .hero {
    margin-bottom: 18px;
  }

  .hero h1 {
    font-size: clamp(2rem, 9vw, 2.75rem);
  }

  .hero p {
    font-size: 0.98rem;
  }

  .calculator-shell {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .input-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .results-panel {
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .results-heading-row,
  .formula-row {
    align-items: flex-start;
  }

  .support-grid,
  .measurement-groups {
    grid-template-columns: 1fr;
  }

  #ramp-diagram {
    min-height: 230px;
  }
}

@media (max-width: 560px) {
  .header-inner {
    min-height: 58px;
  }

  .brand span:last-child {
    display: none;
  }

  .github-button {
    min-height: 38px;
    padding: 7px 11px;
  }

  .input-panel,
  .results-panel {
    padding: 18px 15px;
  }

  .field-grid,
  .angle-grid,
  .metric-grid,
  .clearance-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .vehicle-helper,
  .results-heading-row,
  .vehicle-results-header,
  .formula-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .vehicle-helper {
    gap: 8px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .metric-card {
    min-height: 100px;
  }

  .clearance-card:last-child {
    grid-column: 1 / -1;
  }

  .result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tip-strip {
    align-items: flex-start;
    text-align: left;
  }

  .support-content {
    margin: 28px auto;
    padding: 22px 17px;
  }

  .dialog-unit-row {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
  }
}

@media (max-width: 390px) {
  .field-grid,
  .angle-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .clearance-grid {
    grid-template-columns: 1fr;
  }

  .clearance-card:last-child {
    grid-column: auto;
  }

  .result-actions,
  .dialog-actions {
    grid-template-columns: 1fr;
  }
}

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