:root {
  color-scheme: dark;
  --bg: #101112;
  --surface: #181a1b;
  --surface-2: #222528;
  --surface-3: #2d3336;
  --text: #f5f1e9;
  --muted: #a9aaa6;
  --line: #3b4144;
  --accent: #3f8cff;
  --accent-2: #f2b544;
  --danger: #df5b4f;
  --steel: #9ca7ad;
  --glass: #7db9c6;
  --shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --layout-gap: 14px;
  --flow-label-width: 112px;
  --flow-visual-shift: calc((var(--flow-label-width) + 10px) / -2);
  --screen-fit-height: clamp(720px, calc(100vh - 122px), 800px);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #fbfdff;
  --surface-2: #f3f7fb;
  --surface-3: #e7eef6;
  --text: #111827;
  --muted: #5f6f82;
  --line: #cbd7e4;
  --accent: #2563eb;
  --accent-2: #9a6500;
  --danger: #b23d35;
  --steel: #64748b;
  --glass: #3c7c96;
  --shadow: 0 18px 42px rgba(30, 41, 59, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 280px),
    radial-gradient(circle at 82% 0%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 300px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  min-width: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1540px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 6px 0 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 0 8px;
}

.brand-copy {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 2.75vw, 3.25rem);
  line-height: 0.95;
  white-space: nowrap;
}

h2 {
  margin: 0;
  font-size: 1rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.subtitle {
  max-width: 780px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  box-shadow: var(--shadow);
}

.pill-btn,
.pill-icon {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
}

.pill-btn {
  padding: 7px 10px;
}

.pill-icon {
  padding: 7px 9px;
}

.pill-btn:hover,
.pill-icon:hover,
.pill-btn.active,
.pill-icon.active {
  border-color: color-mix(in srgb, var(--line) 68%, var(--text) 18%);
  background: var(--surface-2);
  color: var(--text);
}

.tool-button,
.segment {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.tool-button {
  padding: 0 12px;
  white-space: nowrap;
}

.tool-button:hover,
.segment:hover {
  border-color: var(--accent);
}

.simulator-layout {
  display: grid;
  grid-template-columns: 300px minmax(560px, 1fr) 350px;
  gap: var(--layout-gap);
  align-items: stretch;
  min-height: 0;
}

.results-column {
  display: grid;
  gap: var(--layout-gap);
  min-width: 0;
}

.results-column {
  grid-template-columns: 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  height: var(--screen-fit-height);
}

.panel {
  min-width: 0;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  box-shadow: var(--shadow);
}

.cockpit-panel,
.mechanical-flow-panel,
.gearbox-panel,
.car-panel,
.output-panel {
  padding: 12px;
}

.cockpit-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 4px;
  height: var(--screen-fit-height);
  overflow: hidden;
}

.mechanical-flow-panel,
.flow-subblock,
.car-panel,
.output-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.mechanical-flow-panel {
  gap: 8px;
  height: var(--screen-fit-height);
  --accent: #18b79d;
  --glass: #7db9c6;
}

[data-theme="light"] .mechanical-flow-panel {
  --accent: #087f72;
  --glass: #2e7587;
}

.cockpit-panel > .panel-title-row,
.mechanical-flow-panel > .panel-title-row {
  margin-bottom: 0;
}

.car-panel,
.output-panel {
  align-self: stretch;
  height: 100%;
  width: 100%;
  justify-self: stretch;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  min-width: 0;
}

.panel-title-row > div {
  min-width: 0;
}

.status-pill,
.unit-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 100%;
}

.microcopy {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.transmission-note {
  margin-bottom: 14px;
}

.cockpit-section {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.section-label {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.cockpit-readouts .gauge-row,
.cockpit-readouts .pedal-row {
  margin-bottom: 0;
}

.technical-settings {
  --settings-control-height: 42px;
  grid-template-rows: auto auto;
  align-content: stretch;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
}

.technical-settings .control-group {
  margin-bottom: 0;
}

.technical-settings .control-grid,
.technical-settings .curve-controls {
  gap: 6px 10px;
}

.technical-layout {
  display: grid;
  align-content: space-between;
  row-gap: 12px;
  column-gap: 10px;
}

.settings-row {
  display: grid;
  column-gap: 10px;
  min-width: 0;
}

.technical-settings select,
.technical-settings input[type="number"],
.technical-settings .segment {
  min-height: var(--settings-control-height);
  height: var(--settings-control-height);
}

.settings-row-main {
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 0.75fr);
}

.settings-row-triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wheel-group,
.motion-group {
  grid-column: span 2;
}

.wheel-group {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.direction-group {
  min-width: 0;
}

.embedded-shift {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: stretch;
  gap: 10px;
  padding: 14px 0 12px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.embedded-shift-header {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 4px;
  min-width: 0;
}

.gauge-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.gauge-card {
  position: relative;
  min-width: 0;
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-3) 72%, transparent), var(--surface-2)),
    var(--surface-2);
  overflow: hidden;
}

.gauge-card-title {
  position: absolute;
  top: 7px;
  left: 8px;
  right: 8px;
  z-index: 1;
  color: var(--text);
  overflow: hidden;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gauge-card svg {
  display: block;
  width: 100%;
  height: 116px;
  margin-top: 10px;
}

.gauge-value {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  display: grid;
  justify-items: center;
  gap: 2px;
}

.gauge-value strong {
  font-size: clamp(1.08rem, 1.25vw, 1.42rem);
  line-height: 1;
}

.gauge-value strong[contenteditable="true"] {
  outline: none;
  border-radius: 4px;
  caret-color: var(--accent-2);
}

.gauge-value strong[contenteditable="true"]:focus {
  text-shadow: 0 0 10px color-mix(in srgb, var(--accent-2) 58%, transparent);
}

.gauge-value span {
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 800;
}

.gauge-track,
.gauge-danger,
.gauge-fill {
  fill: none;
  stroke-linecap: round;
  stroke-width: 13;
}

.gauge-track {
  stroke: color-mix(in srgb, var(--line) 82%, transparent);
}

.gauge-danger {
  stroke: color-mix(in srgb, var(--danger) 72%, transparent);
}

.gauge-fill {
  stroke: var(--accent);
}

.gauge-tick {
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.gauge-title {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
}

.gauge-needle {
  transform-box: view-box;
  transform-origin: 130px 96px;
  transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.needle-shape {
  fill: var(--accent-2);
  stroke: color-mix(in srgb, var(--accent-2) 62%, black 38%);
  stroke-width: 1;
}

.needle-hub {
  fill: var(--surface);
  stroke: var(--accent-2);
  stroke-width: 3;
}

.pedal-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.pedal-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 900;
  letter-spacing: 0;
}

.pedal-button.brake {
  background: linear-gradient(180deg, color-mix(in srgb, var(--danger) 22%, var(--surface-2)), var(--surface-2));
}

.pedal-button.throttle {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 34%, var(--surface-2)), var(--surface-2));
}

.pedal-button:active {
  transform: translateY(2px);
}

.control-group {
  display: grid;
  gap: 5px;
  margin-bottom: 7px;
}

.control-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.label-row,
.range-row,
.speed-entry {
  display: flex;
  align-items: center;
  gap: 10px;
}

.label-row {
  justify-content: space-between;
}

.range-row input[type="range"] {
  flex: 1;
  min-width: 0;
}

.range-row input[type="number"] {
  width: 96px;
}

.speed-entry input[type="number"] {
  width: 100%;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
}

.segment {
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--muted);
}

.segment.active {
  border-color: color-mix(in srgb, var(--accent) 84%, white 16%);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--text);
}

select,
input[type="number"] {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 10px;
}

select {
  text-overflow: ellipsis;
}

input[type="range"] {
  accent-color: var(--accent);
}

.curve-controls {
  display: grid;
  transition: opacity 180ms ease;
}

.curve-controls.is-muted {
  opacity: 0.55;
}

.embedded-shift .microcopy {
  display: block;
  align-self: center;
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: 0.72rem;
  line-height: 1.25;
}

.shift-gate {
  display: grid;
  justify-items: center;
  align-items: center;
  width: 100%;
  min-height: 134px;
}

.shift-plate {
  position: relative;
  width: min(100%, 146px);
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.18), transparent 48%),
    color-mix(in srgb, var(--surface-3) 92%, white 8%);
  aspect-ratio: 1.04;
}

.shift-lines {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: visible;
}

.shift-rail-svg {
  stroke: color-mix(in srgb, var(--text) 78%, var(--line));
  stroke-width: 4;
  stroke-linecap: square;
}

.neutral-node {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  min-width: 23px;
  min-height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 900;
}

.shift-button {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 950;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
}

.shift-button.active {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent) 34%, var(--surface));
  color: var(--text);
}

.flow-subblock svg,
.view-card svg {
  display: block;
  width: 100%;
}

.flow-stack {
  position: relative;
  display: grid;
  grid-template-rows: minmax(165px, 1fr) 12px minmax(305px, 1.85fr) 12px minmax(230px, 1.25fr);
  gap: 6px;
  min-height: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 72%, transparent), var(--surface)),
    var(--surface-2);
}

.mechanical-route-svg {
  position: absolute;
  inset: 10px 12px;
  z-index: 0;
  width: calc(100% - 24px);
  height: calc(100% - 20px);
  transform: translateX(var(--flow-visual-shift));
  pointer-events: none;
}

.mechanical-route-path {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 3;
  stroke-dasharray: 9 9;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: shaftSlide 1s linear infinite;
}

.flow-subblock {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--flow-label-width) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.flow-subblock .panel-title-row {
  align-self: center;
  margin-bottom: 0;
  padding-left: 2px;
}

.flow-subblock svg {
  min-height: 0;
  height: 100%;
  transform: translateX(var(--flow-visual-shift));
}

.mechanical-flow-panel .schematic-floor {
  fill: transparent;
  stroke: transparent;
}

#engineFlowSvg {
  height: 100%;
}

#gearboxSvg {
  height: 100%;
}

#gearboxSvg .gear-text {
  font-size: 12.5px;
}

#differentialSvg {
  height: 100%;
}

.flow-connector {
  width: 4px;
  height: 100%;
  justify-self: center;
  transform: translateX(calc(var(--flow-label-width) / 2));
  border-radius: 999px;
  background: transparent;
}

#topCarSvg {
  height: 100%;
  max-height: 330px;
}

.car-view-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  width: min(100%, 315px);
  height: 100%;
  margin-inline: auto;
  align-items: stretch;
}

.view-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 86%, var(--accent) 10%), var(--surface));
}

.car-top-card {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 0;
  padding: 6px;
}

.card-label {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
  height: 100%;
}

.metric-card {
  appearance: none;
  display: grid;
  gap: 3px;
  min-height: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.metric-card.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 15%, var(--surface-2)), var(--surface-2));
}

.metric-card:hover,
.metric-card.active {
  border-color: var(--accent-2);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 58%, transparent);
}

.metric-card.active {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 24%, var(--surface-2)), var(--surface-2));
}

.metric-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.metric-card strong {
  align-self: end;
  font-size: clamp(1.35rem, 1.65vw, 1.85rem);
  line-height: 1;
}

.metric-card small {
  color: var(--accent-2);
}

.schematic-floor {
  fill: color-mix(in srgb, var(--surface-2) 78%, transparent);
  stroke: var(--line);
}

.component-hit {
  cursor: pointer;
  outline: none;
}

.component-hit .component-box,
.component-hit .diff-blue-case,
.component-hit .differential-gear,
.component-hit .schematic-tire,
.component-hit .schematic-tire-rect {
  transition:
    stroke 160ms ease,
    fill 160ms ease,
    filter 160ms ease;
}

.component-hit:hover .component-box,
.component-hit:hover .diff-blue-case,
.component-hit:hover .differential-gear,
.component-hit:hover .schematic-tire,
.component-hit:hover .schematic-tire-rect,
.component-hit.active .component-box,
.component-hit.active .diff-blue-case,
.component-hit.active .differential-gear,
.component-hit.active .schematic-tire,
.component-hit.active .schematic-tire-rect,
.component-hit.active .shaft.base,
.component-hit.active .shaft.motion {
  stroke: var(--accent-2);
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent-2) 54%, transparent));
}

.component-hit.active .component-box {
  fill: color-mix(in srgb, var(--accent) 24%, var(--surface-3));
}

.component-box {
  fill: color-mix(in srgb, var(--surface-3) 88%, white 6%);
  stroke: var(--line);
  stroke-width: 2.5;
}

.gearbox-box {
  fill: color-mix(in srgb, var(--surface-3) 88%, var(--steel) 12%);
}

.diff-box {
  fill: color-mix(in srgb, var(--accent-2) 18%, var(--surface-3));
}

.diff-main-shaft {
  stroke: #050505;
  stroke-width: 14;
  stroke-linecap: butt;
}

.diff-cross-shaft {
  stroke: #3b78ad;
  stroke-width: 14;
  stroke-linecap: square;
}

.diff-blue-case,
.differential-gear {
  fill: #5b9bd5;
  stroke: #386f9d;
  stroke-width: 2;
  stroke-linejoin: round;
}

.diff-post {
  fill: #5a96c8;
}

.diff-window {
  fill: var(--surface);
  stroke: #386f9d;
  stroke-width: 2;
}

.diff-case-line {
  stroke: #386f9d;
  stroke-width: 2;
}

.differential-gear-motion-line {
  stroke: #f5f2e8;
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0.78;
}

.door-lines,
.mirror-line {
  fill: none;
  stroke: color-mix(in srgb, var(--text) 42%, transparent);
  stroke-width: 2;
  stroke-linecap: round;
}

.engine-cylinder {
  fill: color-mix(in srgb, var(--surface) 78%, var(--steel) 12%);
  stroke: color-mix(in srgb, var(--line) 78%, var(--text) 18%);
  stroke-width: 2;
}

.engine-piston {
  fill: color-mix(in srgb, var(--accent) 42%, var(--surface));
  stroke: color-mix(in srgb, var(--text) 78%, var(--line));
  stroke-width: 1.5;
}

.engine-crank-case {
  fill: color-mix(in srgb, var(--surface) 82%, black 10%);
  stroke: var(--accent-2);
  stroke-width: 3;
  stroke-dasharray: 7 6;
}

.engine-crank-arm,
.engine-rod {
  stroke: color-mix(in srgb, var(--accent-2) 82%, black 8%);
  stroke-width: 4;
  stroke-linecap: round;
}

.engine-rod {
  stroke-width: 3.5;
}

.engine-pin {
  fill: var(--surface);
  stroke: var(--accent-2);
  stroke-width: 2;
}

.engine-pin.center {
  fill: var(--accent-2);
  stroke: var(--surface);
}

.clutch-pack {
  fill: color-mix(in srgb, var(--accent-2) 30%, var(--surface-3));
  stroke: var(--line);
  stroke-width: 2;
}

.diff-ring {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 5;
  stroke-dasharray: 10 8;
  animation: shaftSlide 1s linear infinite;
}

.schematic-tire {
  fill: #111;
  stroke: color-mix(in srgb, var(--line) 70%, white 12%);
  stroke-width: 4;
}

.schematic-tire-rect {
  fill: #0a0a09;
  stroke: color-mix(in srgb, var(--line) 70%, white 12%);
  stroke-width: 3;
}

.wheel-long-line {
  stroke: #f5f2e8;
  stroke-width: 3;
  stroke-linecap: round;
}

.drive-axle {
  fill: none;
  stroke: color-mix(in srgb, var(--accent-2) 84%, #ff7a1a);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.axle-joint {
  fill: color-mix(in srgb, var(--accent-2) 90%, #ff7a1a);
}

.component-value {
  fill: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-anchor: middle;
}

.shaft.base {
  stroke: var(--steel);
  stroke-width: 8;
  stroke-linecap: round;
}

.shaft.motion,
.power-arrow {
  stroke: var(--accent-2);
  stroke-width: 3;
  stroke-dasharray: 9 9;
  stroke-linecap: round;
  animation: shaftSlide 1s linear infinite;
}

.gear-center-line {
  stroke: var(--steel);
  stroke-width: 2;
  stroke-dasharray: 9 9;
  stroke-linecap: round;
}

.gear-center-line.active {
  stroke: var(--accent-2);
  animation: shaftSlide 1s linear infinite;
}

.arrow-head {
  fill: var(--accent-2);
}

.mesh-line {
  stroke: var(--line);
  stroke-width: 3;
  stroke-dasharray: 8 8;
  opacity: 0.48;
}

.mesh-line.active {
  stroke: var(--accent-2);
  opacity: 1;
  animation: shaftSlide 0.9s linear infinite;
}

.rect-gear .gear-rect {
  fill: color-mix(in srgb, var(--surface-3) 92%, white 8%);
  stroke: var(--line);
  stroke-width: 2;
}

.rect-gear.active .gear-rect {
  fill: color-mix(in srgb, var(--accent) 58%, var(--surface-3));
  stroke: var(--accent);
}

.rect-gear.reverse .gear-rect {
  fill: color-mix(in srgb, var(--danger) 48%, var(--surface-3));
  stroke: var(--danger);
}

.gear-motion-line {
  stroke: color-mix(in srgb, var(--text) 64%, var(--surface) 24%);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.5;
}

.rect-gear.active .gear-motion-line,
.rect-gear.reverse .gear-motion-line {
  stroke: color-mix(in srgb, white 86%, var(--surface));
  opacity: 0.72;
}

.direct-clutch {
  fill: color-mix(in srgb, var(--surface-3) 88%, white 7%);
  stroke: var(--line);
  stroke-width: 2;
}

.direct-clutch.active {
  fill: color-mix(in srgb, var(--accent-2) 54%, var(--surface-3));
  stroke: var(--accent-2);
}

.gear-text,
.svg-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
}

.gear-text {
  font-size: 11.5px;
}

.gear-text.side-label {
  text-anchor: start;
}

.clutch-label {
  fill: var(--text);
  font-size: 17px;
}

.svg-label.center {
  text-anchor: middle;
}

.garage-floor {
  fill: color-mix(in srgb, var(--surface-2) 82%, transparent);
  stroke: var(--line);
}

.road-guide {
  stroke: color-mix(in srgb, var(--accent) 38%, var(--line));
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 42 24;
  fill: none;
}

.radius-line,
.ackermann-line {
  stroke: var(--accent-2);
  stroke-width: 2;
  stroke-dasharray: 7 7;
}

.ackermann-line {
  opacity: 0.5;
}

.curve-center {
  fill: var(--accent-2);
  stroke: var(--surface);
  stroke-width: 2;
}

.top-body {
  fill: color-mix(in srgb, var(--accent) 70%, #ffffff 7%);
  stroke: color-mix(in srgb, var(--accent) 70%, black 30%);
  stroke-width: 2;
}

.top-glass {
  fill: color-mix(in srgb, var(--glass) 52%, var(--surface));
  stroke: color-mix(in srgb, var(--glass) 70%, black 30%);
  stroke-width: 2;
}

.top-hood {
  fill: color-mix(in srgb, var(--accent) 45%, var(--surface));
  opacity: 0.74;
}

.centerline {
  stroke: color-mix(in srgb, var(--text) 45%, transparent);
  stroke-width: 2;
  stroke-dasharray: 8 8;
}

.car-line-art {
  pointer-events: none;
}

[data-theme="dark"] .car-line-art {
  filter: invert(1) contrast(1.12) brightness(1.08);
  opacity: 0.92;
}

.wheel-rubber {
  fill: #111;
  stroke: #111;
  stroke-width: 1;
}

.wheel-mark {
  stroke: #f5f2e8;
  stroke-width: 3;
  stroke-linecap: round;
}

.track-dimension-line {
  stroke: var(--text);
  stroke-width: 5;
  stroke-linecap: round;
}

.track-dimension-label {
  fill: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
  font-weight: 500;
  text-anchor: middle;
}

.headlight {
  stroke: #ffe7a3;
  stroke-width: 6;
  stroke-linecap: round;
}

.taillight {
  stroke: var(--danger);
  stroke-width: 6;
  stroke-linecap: round;
}

.door-handle {
  fill: color-mix(in srgb, var(--text) 88%, black 12%);
}

@keyframes shaftSlide {
  to {
    stroke-dashoffset: -36;
  }
}

@media (max-width: 1180px) {
  .topbar {
    display: grid;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .simulator-layout,
  .car-view-grid {
    grid-template-columns: 1fr;
  }

  .results-column {
    grid-template-rows: auto;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(560px, calc(100vw - 18px));
    padding-top: 12px;
  }

  .gauge-row,
  .control-grid,
  .pedal-row,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .settings-row-main,
  .settings-row-triple {
    grid-template-columns: 1fr;
  }

  .wheel-group,
  .motion-group {
    grid-column: auto;
  }

  .segmented {
    grid-auto-flow: row;
  }

  .range-row {
    align-items: stretch;
    flex-direction: column;
  }

  .range-row input[type="number"] {
    width: 100%;
  }

  #topCarSvg,
  .car-top-card {
    min-height: 360px;
    height: 360px;
  }

  h1 {
    font-size: 2.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
