/* =============================================================
   DAS LABS · PistonLab
   The PropulsionLab design language, one hue over.

   Same system as app/static/styles.css — graphite surfaces,
   hairline rules, Inter + JetBrains Mono, 10px panels / 6px
   controls, accent used sparingly — with the cold-flow blue
   swapped for PistonLab's combustion orange.
   ============================================================= */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  /* surfaces */
  --bg:          #08090b;
  --surface:     #0d0e11;
  --surface-2:   #131418;
  --surface-3:   #191b20;
  --surface-4:   #20232a;

  /* hairlines */
  --line:          rgba(255, 255, 255, 0.06);
  --line-strong:   rgba(255, 255, 255, 0.10);
  --line-emphasis: rgba(255, 255, 255, 0.18);

  /* ink */
  --text:        #f4f4f5;
  --text-2:      rgba(244, 244, 245, 0.62);
  --text-3:      rgba(244, 244, 245, 0.42);
  --text-4:      rgba(244, 244, 245, 0.26);

  /* accent (used sparingly) — PropulsionLab's blue, one hue over */
  --accent:        #e8923e;
  --accent-strong: #f2ab63;
  --accent-soft:   rgba(232, 146, 62, 0.10);
  --accent-line:   rgba(232, 146, 62, 0.32);

  /* chart palette — muted, premium */
  --c-pv:     #e8923e;   /* P–V loop / pressure — the accent line */
  --c-temp:   #d97757;   /* temperature */
  --c-power:  #e8923e;   /* power */
  --c-torque: #94a3b8;   /* torque — cool slate, for contrast */
  --c-grid:   rgba(255, 255, 255, 0.07);
  --c-axis:   rgba(244, 244, 245, 0.42);

  /* status */
  --ok:    #84cc8a;
  --warn:  #d4a155;
  --err:   #d97670;

  /* typography */
  --font-sans:    "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "Cascadia Mono", "Menlo", monospace;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;

  /* motion */
  --ease-soft: cubic-bezier(0.32, 0.72, 0.0, 1.0);
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  overflow-x: hidden;
}
a { color: inherit; }

/* page fade-in */
body { animation: pageIn 480ms var(--ease-out) both; }
@keyframes pageIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* =========================================================
   BOOT SCREEN  (~1s DAS LABS intro, then fades out)
   ========================================================= */

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  background: var(--bg);
  animation: bootScreenOut 1450ms var(--ease-out) forwards;
}
@keyframes bootScreenOut {
  0%   { opacity: 1; visibility: visible; }
  68%  { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}
.boot-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bootLogoIn 620ms var(--ease-soft) both;
}
@keyframes bootLogoIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
.boot-logo-img {
  display: block;
  width: min(560px, 72vw);
  height: auto;
}
.boot-fallback {
  align-items: center;
  gap: 22px;
  color: #c2c5cb;
}
.boot-word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0.34em;
  padding-left: 0.34em;
  color: #c2c5cb;
}
@media (max-width: 560px) {
  .boot-word { font-size: 21px; letter-spacing: 0.28em; padding-left: 0.28em; }
}

/* =========================================================
   TYPOGRAPHY PRIMITIVES
   ========================================================= */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
}
.eyebrow .num {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-2);
}
.eyebrow .rule {
  flex: 1;
  min-width: 40px;
  height: 1px;
  background: var(--line);
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--text);
  letter-spacing: -0.02em;
  font-weight: 500;
  line-height: 1.15;
}
p { margin: 0; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }

/* =========================================================
   MISSION BAR  (top navigation)
   ========================================================= */

.mission-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  background: rgba(8, 9, 11, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(140%) blur(20px);
  -webkit-backdrop-filter: saturate(140%) blur(20px);
}
.mission-bar-left,
.mission-bar-right {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

/* Hamburger — hidden on desktop, morphs into an X when open. */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  margin: 0 auto;
  border-radius: 2px;
  background: var(--text);
  transition: transform 240ms var(--ease-soft), opacity 180ms var(--ease-out);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text);
  text-decoration: none;
}
.brand .brand-mark {
  font-weight: 700;
  letter-spacing: 0.13em;
  font-size: 13.5px;
  text-transform: uppercase;
  color: var(--text);
}
.brand .brand-fallback {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-3);
  letter-spacing: 0.01em;
}
/* Wordmark artwork sits on black; screen blend drops the field out. */
.brand .brand-product-img {
  height: 15px;
  width: auto;
  display: block;
  mix-blend-mode: screen;
  filter: brightness(1.45) contrast(1.05);
}
.brand:hover .brand-mark { color: var(--accent-strong); }
.brand .brand-dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--text-4);
  display: inline-block;
  vertical-align: middle;
  margin: 0 5px;
}
.badge-dev {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}

.mission-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: color 200ms var(--ease-out);
}
.mission-link:hover { color: var(--text); }
button.unit-toggle {
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  letter-spacing: 0.01em;
  min-height: 0;
}
button.unit-toggle:hover { color: var(--text); border-color: var(--line-strong); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
.status-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
}
.status-pill.ok { color: var(--text); border-color: var(--line-strong); }
.status-pill.ok::before { background: var(--ok); }
.status-pill.busy::before { background: var(--accent); animation: pulse 1s infinite; }
.status-pill.err { color: var(--text); border-color: var(--line-strong); }
.status-pill.err::before { background: var(--err); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Enthusiast / Engineer — a hairline segmented control, not a pill. */
.mode-toggle {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.mode-opt {
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  padding: 4px 12px;
  min-height: 0;
  border-radius: 4px;
  transition: color 200ms var(--ease-out), background 200ms var(--ease-out);
}
.mode-opt:hover { color: var(--text-2); }
.mode-opt.is-active { background: var(--surface-4); color: var(--text); }

body.mode-enthusiast .engineer-only { display: none !important; }
body.mode-engineer .enthusiast-only { display: none !important; }

/* =========================================================
   APP SHELL
   ========================================================= */

.app-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 56px 32px 80px;
  display: grid;
  gap: 56px;
}

/* =========================================================
   HERO BAND
   ========================================================= */

.hero-band {
  position: relative;
  display: grid;
  gap: 48px;
  align-items: center;
  padding: 32px 0 24px;
}
.hero-copy { min-width: 0; }
.hero-band .eyebrow { margin-bottom: 28px; }

.hero-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.4rem, 5.6vw, 4.4rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
  margin: 0 0 24px;
  color: var(--text);
  text-wrap: balance;
}
.hero-title .accent {
  font-style: normal;
  color: var(--text-2);
}
.hero-sub {
  max-width: 62ch;
  margin-bottom: 36px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--text-2);
  font-weight: 400;
  text-wrap: pretty;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}
.hero-stat {
  padding: 18px 20px 18px 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.hero-stat:last-child { border-right: 0; padding-right: 0; }
.hero-stat-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  line-height: 1.3;
  min-height: 2.6em;
  margin-bottom: 10px;
}
.hero-stat-value {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.hero-stat-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.hero-stat-arrow {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 400;
  color: var(--text-4);
}

/* =========================================================
   SECTION HEADERS
   ========================================================= */

.section { display: grid; gap: 24px; }
.section-header { display: grid; gap: 6px; }
.section-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.4rem, 2vw, 1.9rem);
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}
.section-sub {
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.55;
  max-width: 64ch;
  margin: 0;
}

/* Concept strip — orients a new reader in one line. */
.concept-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--line-emphasis);
  border-radius: 6px;
  background: var(--surface);
}
.concept-eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.concept-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
}
.concept-body b { color: var(--text); font-weight: 500; }

/* =========================================================
   ENGINE TYPE RAIL  (petrol / diesel)
   ========================================================= */

.engine-type {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.etype {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-align: left;
  font-family: var(--font-sans);
  cursor: pointer;
  transition:
    background 240ms var(--ease-out),
    border-color 240ms var(--ease-out),
    transform 240ms var(--ease-out);
}
.etype:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.etype.is-active {
  background: var(--surface-2);
  border-color: var(--line-emphasis);
}
.etype.is-active::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform-origin: left;
  animation: rule 320ms var(--ease-out);
}
@keyframes rule { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.etype-icon { color: var(--text-3); }
.etype-icon svg { width: 26px; height: 26px; display: block; }
.etype.is-active .etype-icon { color: var(--text); }
.etype-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.1;
}
.etype-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* =========================================================
   PANEL
   ========================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 18px;
}
.card:last-child { margin-bottom: 0; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.card-head h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}
.card-head-left { display: flex; align-items: baseline; gap: 12px; }
.hint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}

/* =========================================================
   WORKSPACE
   ========================================================= */

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (min-width: 981px) { .controls { position: sticky; top: 88px; } }

/* =========================================================
   INPUTS
   ========================================================= */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin-bottom: 16px;
}
.field-row .field { margin-bottom: 0; }

.field label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 7px;
}
.field label small {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
}
.field label b {
  margin-left: auto;
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.field-foot {
  display: block;
  margin-top: 6px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
}

input, select, textarea, button {
  font: inherit;
  border-radius: 6px;
  min-height: 36px;
}
input, select, textarea {
  width: 100%;
  padding: 8px 11px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  transition:
    background 200ms var(--ease-out),
    border-color 200ms var(--ease-out);
}
select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 28px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
select option { background: var(--surface-2); color: var(--text); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--line-emphasis);
  background: var(--surface-3);
}
.select-wrap { position: relative; }
.select-wrap.small select { min-height: 32px; padding: 5px 26px 5px 10px; font-size: 12px; }

/* range sliders — the thumb is the one white control, like the primary button */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface-4);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: 0;
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--bg);
  transition: transform 140ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: 0;
  cursor: pointer;
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.1); }
input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 7px var(--accent-soft);
}

/* collapsible input section */
.accordion { padding-top: 0; padding-bottom: 0; }
.accordion summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  padding: 20px 4px 20px 24px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.005em;
  color: var(--text);
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary .chev { display: none; }
.accordion summary::before {
  content: "";
  position: absolute;
  top: 50%; left: 4px;
  width: 8px; height: 8px;
  border-right: 1px solid var(--text-3);
  border-bottom: 1px solid var(--text-3);
  transform: translateY(-65%) rotate(-45deg);
  transition: transform 240ms var(--ease-out);
}
.accordion[open] summary::before { transform: translateY(-25%) rotate(45deg); }
.accordion summary:hover::before { border-color: var(--text); }
.accordion-body { padding: 4px 0 22px; }

/* presets — hairline chips, not pills */
.presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.preset {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition:
    background 200ms var(--ease-out),
    border-color 200ms var(--ease-out),
    color 200ms var(--ease-out);
}
.preset:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-3); }
.preset.is-active {
  color: var(--text);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* =========================================================
   BUTTONS
   ========================================================= */

button {
  border: 1px solid transparent;
  padding: 9px 16px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  transition:
    background 180ms var(--ease-out),
    border-color 180ms var(--ease-out),
    color 180ms var(--ease-out);
}
button:disabled { opacity: 0.42; cursor: not-allowed; }

.primary-button {
  color: #08090b;
  background: #f4f4f5;
  border-color: #f4f4f5;
}
.primary-button:hover:not(:disabled) { background: #ffffff; border-color: #ffffff; }
.ghost-btn {
  color: var(--text-2);
  background: transparent;
  border-color: var(--line-strong);
}
.ghost-btn:hover:not(:disabled) { color: var(--text); border-color: var(--line-emphasis); }

/* small segmented chart switches (Loops ⟷ Crank angle) */
.chart-tabs, .dyno-controls { display: flex; gap: 8px; align-items: center; }
.numerics-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 14px 0 4px; }
.numerics-actions .hint { flex: 1; min-width: 140px; }
.chart-tab {
  padding: 5px 11px;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 200ms var(--ease-out),
    border-color 200ms var(--ease-out),
    color 200ms var(--ease-out);
}
.chart-tab:hover { color: var(--text-2); border-color: var(--line-strong); }
.chart-tab.is-active {
  color: var(--text);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* =========================================================
   METRIC GRID
   ========================================================= */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 24px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.metric {
  position: relative;
  padding: 18px 20px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.metric .k {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.metric .v {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.metric .u {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-3);
  margin-left: 5px;
}
/* the headline number is the one place the accent lands in this grid */
.metric.primary .v { color: var(--accent); }

/* =========================================================
   LIMIT BANNER  (knock / smoke / misfire)
   ========================================================= */

.limit-banner { display: grid; gap: 10px; margin-bottom: 24px; }
.limit-banner:empty { display: none; }
.limit {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--warn);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.limit.warning { border-left-color: var(--err); }
.limit b {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--warn);
}
.limit.warning b { color: var(--err); }

/* =========================================================
   RESULT ROWS  (indicated → brake ladder, analysis)
   ========================================================= */

.rows { display: grid; }
.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-2);
}
.row:first-child { border-top: 0; }
.row .rk { min-width: 0; }
.row .rv {
  color: var(--text);
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-weight: 500;
  white-space: nowrap;
}
/* Section break inside a long row list. The configuration card runs to twenty
   rows once an engine is fully specified; without these it reads as a wall. */
.row-group {
  padding: 18px 0 6px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
}
.row-group:first-child { padding-top: 0; border-top: 0; }
/* The row after a heading owns the divider above it, so drop its own. */
.row-group + .row { border-top: 0; }

.row.sub .rk { color: var(--text-3); padding-left: 16px; }
.row.sub .rv { color: var(--text-2); font-weight: 400; }
.row.total .rk { color: var(--text); font-weight: 500; }
.row.total .rv { color: var(--accent); }

/* =========================================================
   CHARTS
   ========================================================= */

canvas { display: block; width: 100%; }
/* Pin display heights so a width:100% canvas never drives its own height
   from the bitmap aspect ratio (which can balloon under full-page capture). */
#canvasA, #canvasB { height: 300px; }
#dynoCanvas { height: 300px; }
#engineCanvas { height: 340px; }

.plot-wrap {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}
.plot-note {
  margin: 14px 0 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.55;
  max-width: 72ch;
}

/* two loops side by side */
.diagram-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.diagram-cell { min-width: 0; }
.diagram-title {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

/* living engine panel */
.engine-controls { display: flex; align-items: center; gap: 10px; }
.stroke-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  min-width: 104px;
  text-align: center;
  transition: color 220ms var(--ease-out), border-color 220ms var(--ease-out);
}
.engine-play { min-width: 40px; padding: 6px 10px; font-size: 11px; min-height: 0; }
.ignition-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-3);
  transition: color 220ms var(--ease-out), border-color 220ms var(--ease-out);
}
/* Petrol and diesel stay legibly apart without reaching outside the warm
   palette: spark takes the accent, compression the hotter terracotta. */
.ignition-badge[data-ign="spark"] { color: var(--accent); border-color: var(--accent-line); }
.ignition-badge[data-ign="compression"] { color: var(--c-temp); border-color: rgba(217, 119, 87, 0.36); }

/* =========================================================
   ENERGY BALANCE
   ========================================================= */

.ebar {
  display: flex;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
}
.ebar-seg { height: 100%; min-width: 1px; transition: flex-grow 360ms var(--ease-soft); }
.ebar-seg.work    { background: #e8923e; }
.ebar-seg.wall    { background: #d97757; }
.ebar-seg.exhaust { background: #4b5468; }
.ebar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-top: 14px;
}
.ebar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}
.ebar-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.ebar-legend b {
  color: var(--text);
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-weight: 500;
}

/* =========================================================
   STATE TABLE
   ========================================================= */

.state-wrap {
  margin-top: 22px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.state-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.state-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.state-wrap::-webkit-scrollbar-track { background: transparent; }

.state-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}
.state-table th,
.state-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 400;
  white-space: nowrap;
}
.state-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-sans);
  border-bottom: 1px solid var(--line-strong);
}
.state-table th.s-name,
.state-table td.s-name { text-align: left; }
.state-table tbody tr { transition: background 160ms var(--ease-out); }
.state-table tbody tr:hover { background: var(--surface-2); }
.state-table tbody tr:last-child td { border-bottom: 0; }

/* =========================================================
   NOTES
   ========================================================= */

.note {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
  max-width: 68ch;
}
.note strong, .note b { color: var(--text); font-weight: 500; }

/* =========================================================
   FOOTER
   ========================================================= */

.mission-footer {
  margin-top: 64px;
  padding: 32px 32px 48px;
  border-top: 1px solid var(--line);
  background: transparent;
}
.mission-footer-grid {
  width: min(1320px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 32px;
  align-items: start;
}
.mission-footer .footer-block {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
}
.mission-footer .footer-block strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 10px;
}
.mission-footer .footer-block a { color: var(--text-2); text-decoration: none; }
.mission-footer .footer-block a:hover { color: var(--text); }

/* =========================================================
   ⓘ TOOLTIPS
   ========================================================= */

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  margin-left: 6px;
  vertical-align: middle;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
  cursor: help;
  position: relative;
  user-select: none;
  transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out);
}
.info:hover { border-color: var(--line-emphasis); color: var(--text); }
.info::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  white-space: normal;
  pointer-events: none;
  z-index: 60;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.5);
  /* display:none so hidden tooltips take no layout space (no phantom overflow) */
  display: none;
}
.info:hover::after { display: block; animation: tipIn 160ms var(--ease-soft) both; }
@keyframes tipIn {
  from { opacity: 0; transform: translateX(-50%) translateY(3px); }
  to   { opacity: 1; transform: translateX(-50%); }
}
/* right-aligned so metric tooltips never push past the right edge */
.metric .info::after { left: auto; right: 0; transform: none; }
.metric .info:hover::after { animation: tipInR 160ms var(--ease-soft) both; }
@keyframes tipInR {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================
   CONFIGURATION CARD  (layout + breathing analysis)
   ========================================================= */

.verdicts { display: grid; gap: 10px; margin-top: 20px; }
.verdicts p {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: baseline;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.verdicts p span {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* =========================================================
   BUILD CALL-TO-ACTION
   ========================================================= */

.build-cta {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 18px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  min-height: 0;
}
.build-cta span {
  font-size: 11.5px;
  font-weight: 400;
  color: rgba(8, 9, 11, 0.62);
  letter-spacing: 0;
}

/* =========================================================
   BUILDER OVERLAY  (branching wizard)
   ========================================================= */

.bd-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 5, 7, 0.72);
  backdrop-filter: saturate(120%) blur(6px);
  -webkit-backdrop-filter: saturate(120%) blur(6px);
  animation: bdFade 200ms var(--ease-out) both;
}
.bd-overlay[hidden] { display: none; }
@keyframes bdFade { from { opacity: 0; } to { opacity: 1; } }

.bd-panel {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: min(860px, 92vh);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  animation: bdRise 320ms var(--ease-out) both;
}
@keyframes bdRise {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

.bd-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.bd-head-text { display: grid; gap: 4px; min-width: 0; }
.bd-brand {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.bd-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}
.bd-close {
  flex: none;
  width: 32px; height: 32px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color 180ms var(--ease-out), border-color 180ms var(--ease-out);
}
.bd-close:hover { color: var(--text); border-color: var(--line-emphasis); }

/* progress rail */
.bd-progress {
  display: flex;
  gap: 4px;
  padding: 14px 24px 0;
  flex: none;
}
.bd-dot {
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: var(--surface-4);
  transition: background 280ms var(--ease-out);
}
.bd-dot.is-done { background: var(--accent-line); }
.bd-dot.is-active { background: var(--accent); }

.bd-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px 24px 26px;
  animation: bdStep 260ms var(--ease-out) both;
}
@keyframes bdStep {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.bd-body::-webkit-scrollbar { width: 8px; }
.bd-body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.bd-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 12px;
}
.bd-step-count {
  margin-left: auto;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--text-4);
}
.bd-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
  margin: 0 0 10px;
}
.bd-blurb {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
  margin: 0 0 22px;
  max-width: 62ch;
}
.bd-note {
  margin: 18px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent-line);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}
.bd-note b { color: var(--text); font-weight: 500; }
.bd-note.bd-error { border-left-color: var(--err); color: var(--text); }

/* choice cards */
.bd-choices { display: grid; gap: 10px; }
.bd-choices[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bd-choices[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bd-choices[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.bd-choice {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 14px 15px;
  min-height: 0;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 200ms var(--ease-out),
    border-color 200ms var(--ease-out),
    transform 200ms var(--ease-out);
}
.bd-choice:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.bd-choice.is-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.bd-choice-label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.2;
}
.bd-choice-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}
.bd-choice-desc {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2);
}
.bd-choice.is-active .bd-choice-sub { color: var(--accent); }

/* range rows */
.bd-range { display: grid; gap: 10px; margin-bottom: 18px; }
.bd-range:last-of-type { margin-bottom: 0; }
.bd-range-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}
.bd-range-head b {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* review */
.bd-spec {
  display: grid;
  border-top: 1px solid var(--line);
  margin-bottom: 20px;
}
.bd-spec-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-2);
}
.bd-spec-row b {
  color: var(--text);
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-weight: 500;
  text-align: right;
}

.bd-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  margin-bottom: 16px;
}
.bd-metric {
  padding: 14px 15px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.bd-metric span {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}
.bd-metric b {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 21px;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.bd-metric i {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
}

.bd-warn {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 12px 15px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--warn);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.bd-warn.warning { border-left-color: var(--err); }
.bd-warn b {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--warn);
}
.bd-warn.warning b { color: var(--err); }

.bd-verdicts { display: grid; gap: 10px; margin-top: 16px; }
.bd-verdicts p {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  align-items: baseline;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
}
.bd-verdicts p span {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}

.bd-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  flex: none;
}
.bd-foot button { min-width: 110px; }

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .app-shell { padding: 36px 20px 64px; gap: 44px; }
  .mission-bar { padding: 14px 20px; }
  .workspace { grid-template-columns: 1fr; }
  .diagram-pair { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mission-footer { padding: 28px 20px 40px; }
  .mission-footer-grid { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-stat { border-right: 0; }
}

/* ---------------------------------------------------------
   MISSION BAR COLLAPSE  ( <= 980 px )
   The status pill + mode toggle + links are wider than a
   tablet bar, so the nav becomes a hamburger dropdown at the
   same breakpoint the workspace stacks — never a middle band
   where the inline nav pushes the page sideways.
   --------------------------------------------------------- */
@media (max-width: 980px) {
  .mission-bar {
    position: relative;
    gap: 12px;
    flex-wrap: nowrap;
  }
  .mission-bar-left { flex: 1 1 auto; min-width: 0; gap: 12px; }
  .nav-toggle { display: flex; }

  .mission-bar-right {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0 20px;
    background: rgba(8, 9, 11, 0.97);
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(140%) blur(20px);
    -webkit-backdrop-filter: saturate(140%) blur(20px);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: max-height 300ms var(--ease-soft), opacity 200ms var(--ease-out);
  }
  .mission-bar-right.open {
    max-height: 80vh;
    overflow-y: auto;
    opacity: 1;
    pointer-events: auto;
    padding-top: 6px;
    padding-bottom: 10px;
  }
  .mission-bar-right .mission-link,
  .mission-bar-right .status-pill,
  .mission-bar-right button.unit-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 48px;
    padding: 0 4px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    font-size: 15px;
    white-space: nowrap;
  }
  .mission-bar-right button.unit-toggle { justify-content: flex-start; }
  .mission-bar-right .mode-toggle { width: 100%; margin: 10px 0; }
  .mission-bar-right .mode-opt { flex: 1; min-height: 40px; }
  .mission-bar-right > *:last-child { border-bottom: 0; }
}
@media (max-width: 640px) {
  .field-row, .engine-type, .presets, .metrics { grid-template-columns: 1fr; }
  .concept-strip { grid-template-columns: 1fr; gap: 8px; padding: 12px 14px; }
}

/* Builder on small screens: full-bleed sheet, single-column choices. */
@media (max-width: 760px) {
  .bd-overlay { padding: 0; place-items: stretch; }
  .bd-panel {
    width: 100%;
    max-height: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }
  .bd-head { padding: 16px 16px 12px; }
  .bd-progress { padding: 12px 16px 0; }
  .bd-body { padding: 18px 16px 24px; }
  .bd-foot { padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .bd-title { font-size: 20px; }
  .bd-choices[data-cols="2"],
  .bd-choices[data-cols="3"] { grid-template-columns: 1fr; }
  .bd-choices[data-cols="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bd-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bd-choice, .bd-foot button { min-height: 44px; }
  .verdicts p, .bd-verdicts p, .bd-warn { grid-template-columns: 1fr; gap: 4px; }
}

/* =========================================================
   MOBILE PASS  ( <= 760 px )
   ========================================================= */

@media (max-width: 760px) {
  html, body { -webkit-text-size-adjust: 100%; }

  .app-shell { padding: 28px 14px 56px; gap: 32px; }

  /* MISSION BAR — the collapse itself lives in the <=980px block; the phone
     only tightens the gutters and shrinks the wordmark. */
  .mission-bar { padding: 11px 14px; }
  .mission-bar-right { padding: 0 14px; }
  .brand .brand-product-img { height: 13px; }

  /* HERO */
  .hero-band { padding: 20px 0 12px; gap: 24px; }
  .hero-title {
    font-size: clamp(1.65rem, 7vw, 2.2rem);
    line-height: 1.1;
    margin-bottom: 18px;
    overflow-wrap: break-word;
    text-wrap: pretty;
  }
  .hero-title br { display: none; }
  .hero-sub { font-size: 14.5px; line-height: 1.5; margin-bottom: 22px; max-width: none; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }

  /* PANELS */
  .card { padding: 18px 14px; }
  .card-head { flex-wrap: wrap; gap: 8px 12px; align-items: flex-start; }
  .card-head h2 { font-size: 15px; }
  .section-title { font-size: 1.35rem; }

  /* FORMS — 16px+ stops iOS auto-zoom; >=40px is thumb-friendly. */
  input[type="number"], input[type="text"], select, textarea {
    font-size: 16px;
    min-height: 40px;
    padding: 8px 10px;
  }
  input[type="range"] { min-height: 0; }

  /* BUTTONS — 44px minimum touch target. */
  .primary-button, .ghost-btn { min-height: 44px; padding: 11px 18px; }
  .chart-tab, .mode-opt, .engine-play { min-height: 34px; }

  /* keep any wide child from forcing horizontal scroll */
  .workspace, .controls, .results, .card { min-width: 0; }
  .info::after { max-width: 220px; }

  .mission-footer { margin-top: 40px; padding: 24px 14px 36px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
