:root {
  --bg: #06090e;
  --panel: #0b1017;
  --panel2: #0f151e;
  --line: rgba(140, 170, 205, 0.12);
  --line2: rgba(140, 170, 205, 0.22);
  --text: #dfe7f0;
  --dim: #8796a8;
  --amber: #ffb547;
  --cyan: #4fd1ff;
  --red: #ff5a4a;
  --green: #4be08a;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, sans-serif; font-size: 13px; }
button { font: inherit; color: inherit; }

.app { display: grid; grid-template-rows: 58px 1fr; grid-template-columns: minmax(0, 1fr); height: 100vh; }

/* header */
.top { display: flex; align-items: center; gap: 20px; padding: 0 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #0c121a, #080c12); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 250px; }
.logo { width: 28px; height: 28px; color: var(--amber); filter: drop-shadow(0 0 6px rgba(255, 181, 71, 0.5)); animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.brand-name { margin: 0; font-weight: 700; letter-spacing: 0.14em; font-size: 13px; }
.brand-sub { color: var(--dim); font-size: 11px; }
.types { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.types button { background: none; border: 0; padding: 7px 14px; border-radius: 7px; cursor: pointer; color: var(--dim); font-weight: 500; white-space: nowrap; }
.types button:hover { color: var(--text); }
.types button.on { background: linear-gradient(180deg, #1d2633, #151c26); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2), 0 0 16px rgba(255, 181, 71, 0.12); }
.types button.on::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); margin-right: 8px; vertical-align: middle; box-shadow: 0 0 8px var(--amber); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg button { background: none; border: 0; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--dim); }
.seg button.on { background: #1a2330; color: var(--text); }
.seg.small button { padding: 4px 9px; font-size: 12px; }
.ghost { background: none; border: 1px solid var(--line2); border-radius: 8px; padding: 6px 12px; cursor: pointer; color: var(--dim); }
.ghost:hover { color: var(--text); border-color: var(--dim); }
.status { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(75, 224, 138, 0.3); color: var(--green); background: rgba(75, 224, 138, 0.06); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; animation: pulse 1.4s ease-in-out infinite; }
.status.bad { color: var(--red); border-color: rgba(255, 90, 74, 0.35); background: rgba(255, 90, 74, 0.07); }
.status.warn { color: var(--amber); border-color: rgba(255, 181, 71, 0.35); background: rgba(255, 181, 71, 0.07); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* layout */
.main { display: grid; grid-template-columns: 318px minmax(0, 1fr) 356px; min-height: 0; }
.panel { background: var(--panel); overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: #243040 transparent; }
.controls { border-right: 1px solid var(--line); padding: 10px 12px 30px; }
.outputs { border-left: 1px solid var(--line); padding: 12px 14px 30px; }
.center { display: grid; grid-template-rows: minmax(0, 1fr) auto 270px; min-width: 0; min-height: 0; }
.viewport { position: relative; overflow: hidden; min-height: 0; }
.viewport canvas { display: block; width: 100%; height: 100%; }

/* control sections */
.sec { border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); margin-bottom: 10px; overflow: hidden; }
.sec-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; user-select: none; font-weight: 600; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: #b9c6d4; }
.sec-h .idx { font-family: var(--mono); color: var(--amber); font-size: 11px; }
.sec-h .chev { margin-left: auto; color: var(--dim); transition: transform 0.2s; }
.sec.closed .chev { transform: rotate(-90deg); }
.sec.closed .sec-b { display: none; }
.sec-b { padding: 2px 12px 12px; }
.field { padding: 8px 0 4px; }
.frow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.frow label { color: #c3cfdc; font-size: 12.5px; }
.val { display: flex; align-items: center; gap: 5px; }
.val input { width: 78px; background: #070b10; border: 1px solid var(--line2); border-radius: 6px; color: var(--text); font-family: var(--mono); font-size: 12px; padding: 4px 6px; text-align: right; }
.val input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.15); }
.val .unit { color: var(--dim); font-family: var(--mono); font-size: 11px; min-width: 34px; }
.hint { color: var(--dim); font-size: 11px; margin-top: 3px; font-family: var(--mono); }
input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; cursor: pointer; --p: 50%; }
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--amber) 0, var(--amber) var(--p), #1e2834 var(--p)); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--amber) 0, var(--amber) var(--p), #1e2834 var(--p)); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px; box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.35), 0 0 12px rgba(255, 181, 71, 0.6); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.35); }
select { width: 100%; background: #070b10; border: 1px solid var(--line2); border-radius: 7px; color: var(--text); padding: 7px 8px; font: inherit; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.switch { position: relative; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #1e2834; border-radius: 22px; transition: 0.2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #cfd8e3; transition: 0.2s; }
.switch input:checked + span { background: var(--amber); box-shadow: 0 0 12px rgba(255, 181, 71, 0.5); }
.switch input:checked + span::before { transform: translateX(18px); background: #fff; }

/* HUD */
.hud { position: absolute; z-index: 3; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-tl { top: 12px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: rgba(8, 12, 18, 0.72); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; }
.chip .k { color: var(--dim); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.chip .v { font-family: var(--mono); font-size: 14px; margin-top: 2px; }
.chip .v small { color: var(--dim); font-size: 10px; margin-left: 3px; }
.hud-tr { top: 12px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud-tr .seg { background: rgba(8, 12, 18, 0.72); backdrop-filter: blur(8px); }
.toggles { display: flex; gap: 10px; background: rgba(8, 12, 18, 0.72); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--dim); font-size: 12px; }
.toggles label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.toggles input { accent-color: var(--amber); }
.hud-bl { bottom: 12px; left: 12px; }
.legend { background: rgba(8, 12, 18, 0.72); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 240px; }
.legend-title { color: var(--dim); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 6px; }
.legend-bar { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #1a40ff 0%, #26b3ff 4.7%, #40ffcc 9.4%, #f2f24d 17.5%, #ff991f 31.6%, #ff4010 50.5%, #ff4073 71.7%, #ffccff 100%); }
.legend-ticks { position: relative; height: 14px; font-family: var(--mono); font-size: 10px; color: var(--dim); margin-top: 4px; }

.labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.st-label { position: absolute; left: 0; top: 0; pointer-events: auto; }
.st-label b { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; font-family: var(--mono); font-size: 11px; font-weight: 600; color: #0b1017; background: var(--cyan); box-shadow: 0 0 12px rgba(79, 209, 255, 0.6); cursor: default; }
.st-label.failed b { background: #5a6676; box-shadow: none; }
.st-label .tip { display: none; position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: rgba(8, 12, 18, 0.92); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; font-family: var(--mono); font-size: 11px; line-height: 1.55; }
.st-label .tip .n { font-family: Inter, sans-serif; font-weight: 600; color: var(--cyan); margin-bottom: 2px; }
.st-label:hover .tip, .st-label.hl .tip { display: block; }
.st-label.hl b { background: var(--amber); box-shadow: 0 0 14px rgba(255, 181, 71, 0.8); }

.fail { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 4; max-width: 560px; background: rgba(40, 10, 10, 0.86); border: 1px solid rgba(255, 90, 74, 0.5); color: #ffd6d0; border-radius: 10px; padding: 10px 14px; backdrop-filter: blur(8px); font-size: 12.5px; line-height: 1.45; }
.fail strong { color: var(--red); letter-spacing: 0.1em; font-family: var(--mono); font-size: 11px; display: block; margin-bottom: 3px; }

.legend-ticks span { position: absolute; transform: translateX(-50%); }
.legend-ticks span:first-child { transform: none; }
.legend-ticks span:last-child { transform: translateX(-100%); }

/* charts */
.charts { border-top: 1px solid var(--line); background: var(--panel); display: grid; grid-template-rows: 38px 1fr; min-height: 0; }
.chart-tabs { display: flex; gap: 2px; padding: 6px 10px 0; border-bottom: 1px solid var(--line); }
.chart-tabs button { background: none; border: 0; padding: 6px 12px; color: var(--dim); cursor: pointer; border-bottom: 2px solid transparent; }
.chart-tabs button.on { color: var(--text); border-color: var(--amber); }
#chart { width: 100%; height: 100%; display: block; min-height: 0; }

/* outputs */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.kpi { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; position: relative; overflow: hidden; }
.kpi.hero { grid-column: span 2; padding: 14px; background: radial-gradient(120% 140% at 0% 0%, rgba(255, 181, 71, 0.12), transparent 60%), var(--panel2); }
.kpi .k { color: var(--dim); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; }
.kpi .v { font-family: var(--mono); font-size: 19px; margin-top: 4px; font-weight: 600; }
.kpi.hero .v { font-size: 34px; color: #fff; text-shadow: 0 0 22px rgba(255, 181, 71, 0.45); }
.kpi .v small { color: var(--dim); font-size: 11px; font-weight: 400; margin-left: 4px; }
.kpi .bar { margin-top: 10px; height: 6px; border-radius: 3px; background: #1a2230; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), #ff6a3d); box-shadow: 0 0 10px var(--amber); transition: width 0.25s; }
.kpi .sub { color: var(--dim); font-size: 11px; margin-top: 6px; font-family: var(--mono); }
.blk { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.blk h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: #b9c6d4; font-weight: 600; display: flex; justify-content: space-between; }
.blk h3 span { color: var(--dim); font-weight: 400; letter-spacing: 0; text-transform: none; font-family: var(--mono); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; font-size: 12px; }
.kv .k { color: var(--dim); }
.kv .v { font-family: var(--mono); text-align: right; }
.effs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.eff { text-align: center; }
.eff svg { width: 74px; height: 74px; }
.eff .l { color: var(--dim); font-size: 10.5px; margin-top: -2px; }
table.st { width: 100%; border-collapse: collapse; font-size: 12px; }
table.st th { text-align: right; color: var(--dim); font-weight: 500; font-size: 10.5px; letter-spacing: 0.06em; padding: 4px 4px; border-bottom: 1px solid var(--line); }
table.st th:first-child, table.st td:first-child { text-align: left; }
table.st td { padding: 5px 4px; font-family: var(--mono); text-align: right; border-bottom: 1px solid rgba(140, 170, 205, 0.06); }
table.st td.nm { font-family: Inter, sans-serif; color: var(--dim); text-align: left; font-size: 11.5px; }
table.st tr:hover td { background: rgba(79, 209, 255, 0.05); }
table.st .sid { display: inline-grid; place-items: center; min-width: 20px; height: 18px; border-radius: 9px; background: rgba(79, 209, 255, 0.14); color: var(--cyan); font-size: 10.5px; font-weight: 600; margin-right: 6px; }
.warns { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.warns li { font-size: 12px; line-height: 1.45; color: #ffd9a0; background: rgba(255, 181, 71, 0.07); border: 1px solid rgba(255, 181, 71, 0.22); border-radius: 8px; padding: 7px 9px; }
.warns li.okmsg { color: #a9f0c6; background: rgba(75, 224, 138, 0.06); border-color: rgba(75, 224, 138, 0.2); }
.note { color: var(--dim); font-size: 11px; line-height: 1.5; margin-top: 10px; }

@media (max-width: 1180px) {
  html, body { height: auto; }
  .app { height: auto; grid-template-rows: auto 1fr; }
  .top { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 10px; }
  .types { order: 3; width: 100%; overflow-x: auto; }
  .main { grid-template-columns: 1fr; }
  .center { grid-template-rows: 62vh auto 280px; order: -1; }
  .controls, .outputs { border: 0; overflow: visible; }
  .legend { display: none; }
}

/* ---------- touch + small screens ---------- */
.mtabs { display: none; }
.types .short { display: none; }
/* six presets don't fit full names beside the brand and buttons until ~1700 px */
@media (max-width: 1700px) { .types .long { display: none; } .types .short { display: inline; } .types { min-width: 0; overflow-x: auto; } }
@media (min-width: 901px) and (max-width: 1400px) { .app { grid-template-rows: auto minmax(0, 1fr); } .top { flex-wrap: wrap; padding: 8px 12px; gap: 8px 16px; } .types { order: 3; width: 100%; } }
.st-label.pin .tip { display: block; }
.st-label.pin b { background: var(--amber); box-shadow: 0 0 14px rgba(255, 181, 71, 0.8); }

@media (pointer: coarse) {
  input[type='range'] { height: 32px; }
  input[type='range']::-webkit-slider-runnable-track { height: 6px; }
  input[type='range']::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -9px; }
  input[type='range']::-moz-range-track { height: 6px; }
  input[type='range']::-moz-range-thumb { width: 24px; height: 24px; }
  .val input, select { font-size: 16px; } /* stops iOS zoom-on-focus */
  .val input { width: 92px; padding: 6px 8px; }
  .sec-h { padding: 14px 12px; }
  .switch { width: 48px; height: 28px; }
  .switch span::before { width: 22px; height: 22px; }
  .switch input:checked + span::before { transform: translateX(20px); }
  .st-label::before { content: ''; position: absolute; inset: -8px; } /* bigger tap target */
  .st-label .tip { bottom: 36px; }
}

/* phone portrait (and small tablets): app shell with a pinned 3D view and a bottom tab bar */
@media (max-width: 900px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { -webkit-tap-highlight-color: transparent; }
  .app { height: 100vh; height: 100dvh; grid-template-rows: auto minmax(0, 1fr) auto; }

  .top { flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand { min-width: 0; gap: 8px; }
  .logo { width: 22px; height: 22px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 12px; letter-spacing: 0.1em; }
  .top-right { gap: 6px; }
  .status { padding: 5px 8px; font-size: 10px; letter-spacing: 0.08em; }
  .seg button, .ghost { padding: 6px 9px; font-size: 12px; }
  .types { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .types::-webkit-scrollbar { display: none; }
  .types button { flex: 1 0 auto; padding: 8px 12px; }
  .types .long { display: none; }
  .types .short { display: inline; }

  .main { grid-template-columns: 1fr; grid-template-rows: clamp(210px, 40dvh, 420px) minmax(0, 1fr); overflow: hidden; }
  .center { display: contents; }
  .viewport { grid-row: 1; border-bottom: 1px solid var(--line); }
  .controls, .outputs, .charts { grid-row: 2; display: none; border: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .main[data-tab='design'] .controls,
  .main[data-tab='results'] .outputs { display: block; }
  .main[data-tab='charts'] .charts { display: grid; border-top: 0; }
  .controls { padding: 10px 10px 24px; }
  .outputs { padding: 10px 10px 24px; }
  .charts { grid-template-rows: 44px minmax(0, 1fr); padding-bottom: 6px; }
  .chart-tabs { overflow-x: auto; scrollbar-width: none; padding: 6px 6px 0; }
  .chart-tabs::-webkit-scrollbar { display: none; }
  .chart-tabs button { white-space: nowrap; padding: 8px 12px; }

  /* HUD: keep the engine visible */
  .hud-tl { top: 8px; left: 8px; gap: 5px; max-width: 55%; }
  .chip { padding: 4px 7px; border-radius: 7px; }
  .chip .k { font-size: 9px; letter-spacing: 0.08em; }
  .chip .v { font-size: 12px; }
  .hud-tl .chip:nth-child(2), .hud-tl .chip:nth-child(4) { display: none; }
  .hud-tr { top: 8px; right: 8px; gap: 5px; }
  .seg.small button { padding: 5px 8px; font-size: 11px; }
  .toggles { gap: 8px; padding: 5px 8px; font-size: 11px; }
  .legend { display: none; }
  .fail { left: 8px; right: 8px; bottom: 8px; transform: none; max-width: none; font-size: 12px; padding: 8px 10px; }

  .mtabs { display: flex; border-top: 1px solid var(--line); background: rgba(8, 12, 18, 0.96); padding-bottom: env(safe-area-inset-bottom); }
  .mtabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; padding: 8px 0 7px; color: var(--dim); font-size: 11px; font-weight: 500; cursor: pointer; }
  .mtabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mtabs button.on { color: var(--amber); }
  .mtabs button.on svg { filter: drop-shadow(0 0 6px rgba(255, 181, 71, 0.6)); }

  .kpi.hero .v { font-size: 30px; }
  .st-wrap, .blk { overflow-x: auto; }
}

@media (max-width: 380px) {
  .brand-name { display: none; }
  .hud-tr .seg button[data-v='front'], .hud-tr .seg button[data-v='rear'] { padding: 5px 6px; }
}

/* phone landscape: 3D on the left, active panel on the right */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .top { flex-wrap: nowrap; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .types { order: 0; width: auto; flex: 1; min-width: 0; }
  .brand > div { display: none; }
  .main { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .viewport { grid-row: 1; grid-column: 1; border-bottom: 0; border-right: 1px solid var(--line); }
  .controls, .outputs, .charts { grid-row: 1; grid-column: 2; }
  .toggles { display: none; }
  .mtabs button { flex-direction: row; justify-content: center; gap: 6px; padding: 6px 0; }
  .mtabs svg { width: 18px; height: 18px; }
}
.st-label.below .tip { bottom: auto; top: 30px; }

/* ---------- V8 additions ---------- */
.preset-card { border: 1px solid rgba(255, 181, 71, 0.25); background: radial-gradient(120% 140% at 0% 0%, rgba(255, 181, 71, 0.1), transparent 60%), var(--panel2); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.pc-name { font-weight: 700; letter-spacing: 0.04em; }
.pc-note { color: var(--dim); font-size: 11.5px; margin-top: 3px; font-family: var(--mono); }
.pc-mod { color: var(--dim); font-size: 11px; margin-top: 6px; }
.pc-mod.on { color: var(--amber); }
.kpi.hero.half { grid-column: span 1; padding: 12px; }
.kpi.hero.half .v { font-size: 27px; }
.kpi.hero.pwr { background: radial-gradient(120% 140% at 0% 0%, rgba(79, 209, 255, 0.12), transparent 60%), var(--panel2); }
.kpi.hero.pwr .v { text-shadow: 0 0 22px rgba(79, 209, 255, 0.45); }
.kpi.hero.pwr .bar i { background: linear-gradient(90deg, #4fd1ff, #6f8bff); box-shadow: 0 0 10px #4fd1ff; }
.field.disabled { opacity: 0.45; }
.field.disabled input { pointer-events: none; }
em.bad { color: var(--red); font-style: normal; }
.chip.tach .v { color: var(--amber); }
.sound { display: flex; align-items: center; gap: 6px; }
.sound svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound .w { display: none; }
.sound.on { color: var(--amber); border-color: rgba(255, 181, 71, 0.5); box-shadow: 0 0 14px rgba(255, 181, 71, 0.18); }
.sound.on .w { display: inline; }
.sound.on .x { display: none; }
.legend-title span { color: var(--text); font-family: var(--mono); letter-spacing: 0.04em; margin-left: 4px; }
.fire-strip { display: flex; gap: 4px; }
.fire-strip span { flex: 1; text-align: center; font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 3px 0; border-radius: 5px; background: #141c27; color: var(--dim); border: 1px solid var(--line); transition: background 0.5s, color 0.5s, box-shadow 0.5s; }
.fire-strip span.r { border-bottom-color: rgba(79, 209, 255, 0.5); }
.fire-strip span.l { border-bottom-color: rgba(255, 181, 71, 0.5); }
.fire-strip span.lit { background: #ffb547; color: #0b1017; box-shadow: 0 0 12px rgba(255, 181, 71, 0.8); transition: none; }
.legend-bar.v8 { background: linear-gradient(90deg, #1f59ff 0%, #33ccff 3%, #4dffbf 9.4%, #ffd940 20.8%, #ff8019 35.8%, #ff4d1f 58.5%, #ff8c8c 81%, #ffe6ff 100%); }
.st-label.firing b { background: var(--amber); box-shadow: 0 0 16px rgba(255, 181, 71, 0.9); }
@media (max-width: 900px) {
  .sound span { display: none; }
  .sound { padding: 6px 8px; }
  .hud-tl .chip:nth-child(2), .hud-tl .chip:nth-child(4) { display: initial; }
  .hud-tl .chip:nth-child(3), .hud-tl .chip:nth-child(4) { display: none; }
  #speed { display: none; }
}
#units .short, #reset .short { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .top-right { flex-wrap: nowrap; min-width: 0; }
}
@media (max-width: 480px) {
  #units .long, #reset .long { display: none; }
  #units .short, #reset .short { display: inline; }
  #reset { padding: 6px 10px; }
}

/* ---------- shop mode: customer dyno runs ---------- */
.dynosec { border-color: rgba(255, 95, 210, 0.28); background: radial-gradient(120% 120% at 100% 0%, rgba(255, 95, 210, 0.07), transparent 55%), var(--panel2); }
.dynosec .sec-h .idx { color: #ff5fd2; }
.sec-h .tag { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; color: #ff5fd2; border: 1px solid rgba(255, 95, 210, 0.4); border-radius: 4px; padding: 1px 5px; }
.btn { background: linear-gradient(180deg, #ff6fd8, #e0429f); color: #170612; border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer; box-shadow: 0 0 16px rgba(255, 95, 210, 0.25); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.ghost.sm { padding: 2px 8px; font-size: 11px; }
.ghost.wide { width: 100%; margin: 8px 0 2px; font-size: 12px; text-align: left; }
.dzone { border: 1.5px dashed rgba(255, 95, 210, 0.35); border-radius: 10px; padding: 14px 12px; margin: 8px 0 6px; text-align: center; transition: border-color 0.15s, background 0.15s; }
.dzone.over { border-color: #ff5fd2; background: rgba(255, 95, 210, 0.08); }
.dz-t { font-weight: 600; font-size: 13px; }
.dz-s { color: var(--dim); font-size: 11px; margin: 4px 0 10px; line-height: 1.45; }
.dz-b { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.dzone.compact { padding: 8px 10px; display: flex; align-items: center; gap: 10px; text-align: left; }
.dzone.compact .dz-t { font-size: 12px; flex: 1; }
.dzone.compact .dz-s { display: none; }
.dzone.compact .dz-b .ghost { display: none; }
.dzone.compact .btn { padding: 6px 10px; font-size: 12px; }
.dmsg { font-size: 11.5px; line-height: 1.45; border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.dmsg.err { background: rgba(255, 90, 74, 0.1); border: 1px solid rgba(255, 90, 74, 0.3); color: #ffb3aa; }
.dmsg.ok { background: rgba(75, 224, 138, 0.08); border: 1px solid rgba(75, 224, 138, 0.25); color: #b8f3d0; }
.dmap { border: 1px solid var(--line2); border-radius: 10px; padding: 10px; margin: 8px 0; background: #080c12; }
.dm-h { font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; margin-bottom: 8px; }
.dm-h span { color: var(--dim); font-weight: 400; font-family: var(--mono); font-size: 11px; }
.dm-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 12px; }
.dm-row > span:first-child { color: #c3cfdc; width: 78px; flex: none; }
.dm-row select { flex: 1; min-width: 0; padding: 5px 6px; font-size: 12px; }
.dm-row select.u { flex: none; width: 62px; padding: 5px 4px; }
.dm-row input[type='text'] { flex: 1; min-width: 0; background: #070b10; border: 1px solid var(--line2); border-radius: 7px; color: var(--text); padding: 5px 8px; font: inherit; font-size: 12px; }
.dm-row .seg { flex: 1; min-width: 0; }
.dm-row .seg button { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-prev { font-family: var(--mono); font-size: 11px; color: #c3cfdc; margin: 8px 0; line-height: 1.5; }
.dm-prev .bad, .fitres.poor { color: #ffb3aa; }
.dm-b { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.dm-b select { flex: 1; min-width: 0; padding: 6px; font-size: 12px; }
.dm-b.tools { margin-top: 10px; }
.dm-b.tools .ghost { flex: 1; font-size: 11.5px; padding: 6px 8px; white-space: nowrap; }
.drun { display: flex; align-items: center; gap: 9px; padding: 7px 4px; border-top: 1px solid var(--line); }
.drun.off { opacity: 0.45; }
.drun .sw { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--c); background: var(--c); box-shadow: 0 0 8px var(--c); cursor: pointer; flex: none; padding: 0; }
.drun.off .sw { background: transparent; box-shadow: none; }
.dr-t { flex: 1; min-width: 0; }
.dr-n { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dr-s { font-family: var(--mono); font-size: 10.5px; color: var(--dim); margin-top: 2px; }
.drun .x { background: none; border: 0; color: var(--dim); font-size: 18px; cursor: pointer; padding: 0 4px; }
.drun .x:hover { color: var(--red); }
#dAct { margin-top: 4px; }
.loss { flex: 1; display: flex; align-items: center; gap: 8px; }
.loss b { font-family: var(--mono); font-size: 12px; font-weight: 600; min-width: 42px; text-align: right; }
.busy { position: relative; margin-top: 10px; height: 30px; border-radius: 8px; background: #080c12; border: 1px solid var(--line2); overflow: hidden; }
.busy i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, rgba(255, 95, 210, 0.15), rgba(255, 95, 210, 0.4)); transition: width 0.25s; }
.busy span { position: relative; display: block; text-align: center; line-height: 28px; font-family: var(--mono); font-size: 11.5px; }
.fitres { font-size: 11.5px; line-height: 1.5; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #080c12; border: 1px solid var(--line2); }
.fitres.good { border-color: rgba(75, 224, 138, 0.3); color: #c8f5da; }
.fitres.ok { border-color: rgba(255, 181, 71, 0.3); color: #ffe1b0; }
.cal { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.cal-h { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: #b9c6d4; font-weight: 600; display: flex; justify-content: space-between; }
.cal-h span { text-transform: none; letter-spacing: 0; color: var(--dim); font-weight: 400; font-family: var(--mono); }
.cmp { margin-top: 12px; border: 1px solid var(--line2); border-radius: 10px; padding: 9px 10px; background: #080c12; }
.cmp-h { display: flex; justify-content: space-between; align-items: center; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: #b9c6d4; font-weight: 600; }
.cmp-g { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.cmp-g > div { background: var(--panel); border-radius: 8px; padding: 7px 8px; }
.cmp-g b { display: block; font-family: var(--mono); font-size: 16px; }
.cmp-g span { color: var(--dim); font-size: 10.5px; }
.cmp-g .up b { color: var(--green); text-shadow: 0 0 10px rgba(75, 224, 138, 0.35); }
.cmp-g .down b { color: var(--red); }
.cmp-l { color: var(--dim); font-family: var(--mono); font-size: 10.5px; margin-top: 7px; }
@media (max-width: 900px) {
  .dm-row select, .dm-row input[type='text'] { font-size: 16px; }
  .dm-b.tools { flex-wrap: wrap; }
}

/* ---------- shop tuning ---------- */
.tunesec .sec-h .idx { color: var(--amber); }
.tunesec .sec-h .tag { color: var(--amber); border-color: rgba(255, 181, 71, 0.4); }
.tune-intro { margin: 2px 0 8px; }
.tune-foot { margin-top: 8px; }
.tune-none { font-size: 12px; line-height: 1.5; color: var(--dim); padding: 8px 10px; border: 1px dashed var(--line2); border-radius: 8px; }
.tmod { display: flex; gap: 10px; align-items: flex-start; padding: 9px 8px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 7px; cursor: pointer; background: #0a0f16; transition: border-color 0.15s, background 0.15s; }
.tmod:hover { border-color: var(--line2); }
.tmod.on { border-color: rgba(255, 181, 71, 0.55); background: linear-gradient(180deg, rgba(255, 181, 71, 0.07), rgba(255, 181, 71, 0.02)); }
.tmod input { margin-top: 2px; accent-color: var(--amber); flex: none; width: 16px; height: 16px; }
.tm-b { min-width: 0; font-size: 11.5px; line-height: 1.45; }
.tm-n { font-weight: 600; font-size: 12.5px; color: var(--text); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tm-c { font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); border: 1px solid var(--line2); border-radius: 4px; padding: 0 4px; font-weight: 500; }
.tm-s { color: var(--dim); margin: 2px 0 4px; }
.tm-g { display: flex; gap: 8px; }
.tm-k { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); width: 30px; flex: none; padding-top: 1px; }
.tm-real, .tm-sim { color: #dfe7ef; }
.tm-real .dim { color: var(--dim); }
.tm-fit { font-family: var(--mono); font-size: 10px; border-radius: 4px; padding: 0 5px; margin-left: 4px; white-space: nowrap; }
.tm-fit.good { color: #a9f0c6; background: rgba(75, 224, 138, 0.1); }
.tm-fit.ok { color: #ffe1b0; background: rgba(255, 181, 71, 0.1); }
.tm-fit.poor { color: #ffb3aa; background: rgba(255, 110, 90, 0.1); }
.tm-src { color: var(--dim); font-size: 10.5px; margin-top: 4px; }
.tm-src a { color: #8fc3ff; text-decoration: none; }
.tm-src a:hover { text-decoration: underline; }
.tune-sum { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px 10px; align-items: center; font-family: var(--mono); font-size: 11.5px; padding: 8px 10px; margin-bottom: 8px; border-radius: 8px; background: #080c12; border: 1px solid rgba(255, 181, 71, 0.3); }
.tune-sum .k { display: block; font-size: 9.5px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.tune-sum .gain { color: var(--amber); font-weight: 700; text-align: right; }

/* ---------- ECU import ---------- */
.imp-wrap { position: relative; }
.imp-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; width: 300px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55); }
.imp-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px; border-radius: 7px; cursor: pointer; font: inherit; font-weight: 600; }
.imp-menu button:hover { background: rgba(79, 209, 255, 0.08); }
.imp-menu small { display: block; font-weight: 400; color: var(--dim); font-size: 11px; margin-top: 2px; }
.imp-note { font-size: 10.5px; color: var(--dim); padding: 6px 10px 4px; border-top: 1px solid var(--line); margin-top: 4px; }
.ecu-chip { border: 1px solid rgba(79, 209, 255, 0.35); background: linear-gradient(180deg, rgba(79, 209, 255, 0.07), rgba(79, 209, 255, 0.02)); border-radius: 12px; padding: 9px 11px; margin-bottom: 10px; font-size: 12px; }
.ec-h { display: flex; align-items: center; gap: 7px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #b9e9ff; }
.ec-dot, .ews-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.ec-tag, .ews-flag { font-family: var(--mono); font-size: 9.5px; color: var(--dim); border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px; text-transform: uppercase; letter-spacing: 0.06em; }
.ec-f { margin: 5px 0 7px; font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.ec-f span { color: var(--dim); }
.ec-warn { color: #ffe1b0; background: rgba(255, 181, 71, 0.08); border: 1px solid rgba(255, 181, 71, 0.3); border-radius: 8px; padding: 6px 8px; margin-bottom: 7px; line-height: 1.45; }
.ec-warn button { margin-top: 4px; }
.ec-b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ec-rem { display: flex; align-items: center; gap: 5px; color: var(--dim); font-size: 11px; cursor: pointer; }
.ec-rem input { accent-color: var(--cyan); }
.ec-x { margin-left: auto; }
.ghost.sm { padding: 4px 9px; font-size: 11.5px; }

.ecu-ws { position: fixed; z-index: 50; top: 58px; right: 0; bottom: 0; width: min(1000px, calc(100vw - 330px)); background: rgba(9, 13, 19, 0.98); border-left: 1px solid var(--line2); box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5); display: grid; grid-template-rows: auto auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); backdrop-filter: blur(6px); }
.ews-h { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-width: 0; }
.ews-t { flex: 1; }
.ews-t { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ews-t b { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.ews-file { font-family: var(--mono); font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ews-x { margin-left: auto; }
.ews-tabs { display: flex; gap: 2px; padding: 6px 10px 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ews-tabs button { background: none; border: 0; color: var(--dim); padding: 8px 11px; cursor: pointer; font: inherit; font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.ews-tabs button.on { color: var(--text); border-bottom-color: var(--cyan); }
.ews-tabs .n { font-family: var(--mono); font-size: 9.5px; margin-left: 5px; color: var(--cyan); }
.ews-b { overflow: auto; padding: 12px 16px 30px; }
.ews-sec { margin-bottom: 18px; }
.ews-sec h4 { margin: 0 0 6px; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: #b9c6d4; }
.ews-note, .ews-desc { color: var(--dim); font-size: 12px; line-height: 1.55; margin: 0 0 8px; max-width: 760px; }
.ews-note a, .ews-desc a { color: #8fc3ff; }
.src { font-family: var(--mono); font-size: 10px; color: #6f8296; margin-left: 6px; }
.ews-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 8px; font-size: 12px; }
.ews-kv dt { color: var(--dim); }
.ews-kv dd { margin: 0; font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.ews-list { margin: 0; padding-left: 16px; font-size: 12px; line-height: 1.7; }
.ews-list span { color: var(--dim); font-family: var(--mono); font-size: 11px; }
.ews-notes { margin: 6px 0 0; padding-left: 16px; color: var(--dim); font-size: 11.5px; line-height: 1.5; }
.ews-q { width: 100%; max-width: 320px; background: #070b10; border: 1px solid var(--line2); color: var(--text); border-radius: 7px; padding: 6px 9px; font: inherit; margin-bottom: 8px; }
.ews-raw { font-family: var(--mono); font-size: 11px; }
.ews-raw .r { display: grid; grid-template-columns: minmax(140px, 220px) 1fr 80px; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.ews-raw .k { color: #b9e9ff; }
.ews-raw .v { word-break: break-all; }
.ews-raw .u, .ews-raw .more { color: var(--dim); }
.ews-diag { list-style: none; margin: 0; padding: 0; font-size: 12px; line-height: 1.5; }
.ews-diag li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ews-diag li > span { width: 16px; flex: none; text-align: center; font-weight: 700; }
.ews-diag .error > span { color: var(--red); }
.ews-diag .warn > span { color: var(--amber); }
.ews-diag .info > span { color: var(--dim); }
.ews-diag code { display: block; font-size: 10.5px; color: var(--dim); margin-top: 4px; line-height: 1.5; }
.ews-diag summary { cursor: pointer; color: #8fc3ff; font-size: 11px; }

.hm { position: relative; width: 100%; max-width: 900px; }
.hm canvas { display: block; cursor: crosshair; }
.hm-tip { display: none; position: absolute; pointer-events: none; background: #0d141d; border: 1px solid var(--line2); border-radius: 7px; padding: 6px 8px; font-family: var(--mono); font-size: 10.5px; line-height: 1.45; white-space: nowrap; z-index: 2; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5); }
.hm-tip span { color: var(--dim); }
.hm-read { font-family: var(--mono); font-size: 11px; margin-top: 4px; min-height: 15px; color: #ffe1b0; }
.hm-read span { color: var(--dim); }

.toast { position: fixed; z-index: 80; left: 0; right: 0; margin: 0 auto; bottom: 22px; width: fit-content; max-width: min(560px, 92vw); display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: #111821; border: 1px solid var(--line2); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6); font-size: 12.5px; line-height: 1.5; }
.toast.error { border-color: rgba(255, 90, 74, 0.55); }
.toast.warn { border-color: rgba(255, 181, 71, 0.55); }
.toast.ok { border-color: rgba(75, 224, 138, 0.5); }
.toast button { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 14px; }

@media (max-width: 900px) {
  .ecu-ws { top: 0; width: 100vw; border-left: 0; }
  .imp-menu { position: fixed; left: 10px; right: 10px; top: 60px; width: auto; }
  .ews-raw .r { grid-template-columns: 120px 1fr; }
  .ews-raw .u { display: none; }
  .ews-file, .ews-flag { display: none; }
  .ews-b { padding: 10px 10px 30px; }
  .toast { bottom: 76px; }
}

/* ---------- ECU tune driving the engine (phase 2) ---------- */
.ec-dot.live, .ews-flag.live { background: var(--green, #4be08a); box-shadow: 0 0 8px var(--green, #4be08a); }
.ews-flag.live { background: rgba(75, 224, 138, 0.12); box-shadow: none; color: #9ff0c2; border-color: rgba(75, 224, 138, 0.4); }
.ec-mode { display: flex; align-items: center; gap: 4px; margin: 0 0 8px; font-size: 11px; color: var(--dim); }
.ec-mode span { margin-right: 4px; }
.ec-mode button { background: #0b1118; border: 1px solid var(--line2); color: var(--dim); padding: 4px 9px; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 600; }
.ec-mode button.on { color: var(--text); border-color: var(--cyan); background: rgba(79, 209, 255, 0.12); }
.ec-skip { font-size: 11px; color: var(--dim); line-height: 1.45; margin-bottom: 7px; }
.linkish { background: none; border: 0; padding: 0; color: #8fc3ff; cursor: pointer; font: inherit; font-size: 11.5px; margin-bottom: 7px; }
.ec-form { border-top: 1px solid var(--line); padding-top: 8px; margin-bottom: 8px; display: grid; gap: 6px; }
.ec-form p { margin: 0; color: var(--dim); font-size: 11px; line-height: 1.45; }
.ec-form label { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.ec-form label > :first-child { flex: none; }
.ec-form input, .ec-form select { margin-left: auto; width: 96px; background: #070b10; border: 1px solid var(--line2); color: var(--text); border-radius: 6px; padding: 4px 6px; font: inherit; font-family: var(--mono); font-size: 11.5px; }
.ec-form select { width: 140px; font-family: inherit; }
.ec-fb { display: flex; align-items: center; justify-content: space-between; font-family: var(--mono); font-size: 11.5px; color: #b9e9ff; }
.prov { font-style: normal; font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; padding: 0 4px; border-radius: 3px; border: 1px solid var(--line2); color: var(--dim); vertical-align: 1px; cursor: help; white-space: nowrap; }
.prov.p-commanded { color: #b9e9ff; border-color: rgba(79, 209, 255, 0.45); }
.prov.p-calculated { color: #ffe1b0; border-color: rgba(255, 181, 71, 0.45); }
.prov.p-simulated { color: #c9d3de; }
.prov.p-measured { color: #9ff0c2; border-color: rgba(75, 224, 138, 0.45); }
.ecu-blk .dim { color: var(--dim); font-size: 11px; }
.ecu-asm { margin: 8px 0 0; color: var(--dim); font-size: 11px; line-height: 1.45; }
.field.by-tune { opacity: 0.45; pointer-events: none; }

/* ---------- replay: recording card + timeline (phase 3) ---------- */
.rec-card { border: 1px solid rgba(75, 224, 138, 0.35); background: linear-gradient(180deg, rgba(75, 224, 138, 0.07), rgba(75, 224, 138, 0.02)); border-radius: 12px; padding: 9px 11px; margin-bottom: 10px; font-size: 12px; }
.rec-card .ec-h { color: #b9f5d2; }
.rec-card .ec-x { margin-left: auto; }
.rc-kv { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--dim); font-size: 11px; margin-bottom: 6px; line-height: 1.45; }
.warnc { color: var(--amber); font-weight: 600; }
.rc-in { display: flex; align-items: center; gap: 6px; font-size: 11.5px; margin-bottom: 6px; }
.rc-in input { width: 80px; background: #070b10; border: 1px solid var(--line2); color: var(--text); border-radius: 6px; padding: 3px 6px; font-family: var(--mono); font-size: 11.5px; }
.rc-corr { margin-bottom: 6px; line-height: 1.4; align-items: flex-start; }
.rc-ch { margin: 4px 0 6px; }
.rc-ch summary { cursor: pointer; color: #8fc3ff; font-size: 11.5px; }
.rc-map { display: grid; gap: 4px; margin: 6px 0; }
.rc-map label { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.rc-map span { flex: 1; color: var(--dim); }
.rc-map select { width: 150px; background: #070b10; border: 1px solid var(--line2); color: var(--text); border-radius: 6px; padding: 3px 4px; font-size: 11px; }
.rc-note { margin: 4px 0 0; color: var(--dim); font-size: 10.5px; line-height: 1.45; word-break: break-word; }
.mtag { font-style: normal; font-family: var(--mono); font-size: 8px; letter-spacing: 0.05em; text-transform: uppercase; color: #9ff0c2; border: 1px solid rgba(75, 224, 138, 0.45); border-radius: 3px; padding: 0 3px; margin-left: 3px; vertical-align: 1px; }
.mtag.sim { color: #c9d3de; border-color: var(--line2); }
.prov.p-estimated { color: #ffe1b0; border-color: rgba(255, 181, 71, 0.45); }
#timelineSlot { min-width: 0; }
.timeline { border-top: 1px solid var(--line); background: #0a0f15; padding: 6px 10px 4px; }
.timeline.on-event { box-shadow: inset 3px 0 0 var(--amber); }
.tl-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 11.5px; }
.tl-b { background: #0f1620; border: 1px solid var(--line2); color: var(--text); border-radius: 6px; min-width: 30px; height: 26px; cursor: pointer; font-size: 11px; }
.tl-play { min-width: 40px; color: #9ff0c2; border-color: rgba(75, 224, 138, 0.5); }
.tl-rate { flex: 0 0 auto; width: auto; background: #0f1620; border: 1px solid var(--line2); color: var(--text); border-radius: 6px; height: 26px; font-size: 11.5px; }
.tl-time { font-family: var(--mono); color: #dfe7f0; margin-left: 4px; white-space: nowrap; }
.tl-src { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; border: 1px solid var(--line2); border-radius: 4px; padding: 1px 5px; color: var(--dim); cursor: help; white-space: nowrap; }
.tl-src.reconstructed { color: var(--amber); border-color: rgba(255, 181, 71, 0.5); }
.tl-loop { margin-left: auto; color: var(--dim); display: flex; align-items: center; gap: 4px; }
.tl-plot { position: relative; }
.tl-plot canvas { display: block; cursor: ew-resize; touch-action: none; }
@media (max-width: 900px) {
  .replay-on .main { grid-template-rows: clamp(190px, 34dvh, 380px) auto minmax(0, 1fr); }
  #timelineSlot { grid-row: 2; }
  .replay-on .controls, .replay-on .outputs, .replay-on .charts { grid-row: 3; }
  .tl-loop { display: none; }
  .tl-bar { flex-wrap: wrap; row-gap: 4px; }
  .tl-w { display: none; }
}
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .replay-on .main { grid-template-rows: minmax(0, 1fr) auto; }
  #timelineSlot { grid-row: 2; grid-column: 1; }
  .replay-on .controls, .replay-on .outputs, .replay-on .charts { grid-row: 1 / 3; }
}

/* ---------- tune editing + comparison (phase 4) ---------- */
.ews-edits { display: flex; align-items: center; gap: 5px; margin-left: 8px; flex-wrap: wrap; }
.ews-mod { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: #ffe1b0; border: 1px solid rgba(255, 181, 71, 0.5); border-radius: 4px; padding: 1px 6px; }
.ews-edits button[disabled], .ews-ed button[disabled] { opacity: 0.35; cursor: default; }
.ews-ed { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 4px 0 8px; font-size: 11.5px; }
.ews-ed .ed-sel { color: var(--dim); min-width: 150px; }
.ews-ed .ed-ops { display: inline-flex; align-items: center; gap: 4px; }
.ews-ed .ed-ops.off { opacity: 0.4; pointer-events: none; }
.ews-ed .ed-v { width: 78px; background: #070b10; border: 1px solid var(--line2); color: var(--text); border-radius: 6px; padding: 3px 6px; font-family: var(--mono); font-size: 11.5px; }
.ews-ed .ed-n { color: #ffe1b0; font-family: var(--mono); font-size: 10.5px; }
.ews-ed [data-op="reset"] { margin-left: auto; }
.hm canvas.selectable { cursor: cell; touch-action: none; }
.cmp-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.cmp-e { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line2); border-radius: 8px; padding: 5px 8px; font-size: 11.5px; cursor: pointer; background: #0c121a; }
.cmp-e i, .cmp-t th i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; flex: none; }
.cmp-t th i { margin-right: 5px; vertical-align: middle; }
.cmp-e span { display: flex; flex-direction: column; line-height: 1.25; }
.cmp-e small { color: var(--dim); font-size: 10px; }
.cmp-e button { margin-left: 2px; }
.cmp-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11.5px; color: var(--dim); margin-bottom: 8px; }
.cmp-plot { min-width: 0; }
.cmp-plot canvas { display: block; }
.cmp-tbl { overflow-x: auto; }
.cmp-t { border-collapse: collapse; font-size: 11.5px; width: 100%; min-width: 420px; }
.cmp-t th, .cmp-t td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cmp-t thead th { font-weight: 600; color: #dfe7f0; font-size: 11px; }
.cmp-t tbody th { color: var(--dim); font-weight: 500; white-space: nowrap; }
.cmp-t td { font-family: var(--mono); white-space: nowrap; }
.cmp-t td small { color: var(--dim); }
.cmp-t td .d { display: block; font-size: 9.5px; }
.cmp-t td.best { color: #9ff0c2; }
.ews-h { flex-wrap: wrap; row-gap: 6px; }
.ews-t { overflow: hidden; white-space: nowrap; }
.ews-t b { flex: none; }
.ews-file { overflow: hidden; text-overflow: ellipsis; }
.ews-flag { flex: none; }

/* ---------- virtual dyno (phase 4b) ---------- */
.vdsec .sec-h .tag.sim { color: #f2e56b; border-color: rgba(242, 229, 107, 0.4); }
.vd-f { display: grid; grid-template-columns: minmax(0, 1fr) 92px 46px; align-items: center; gap: 6px; font-size: 11.5px; margin: 3px 0; }
.vd-f span { color: var(--dim); }
.vd-f input, .vd-f select { width: 100%; background: #070b10; border: 1px solid var(--line2); color: var(--text); border-radius: 6px; padding: 3px 6px; font-family: var(--mono); font-size: 11.5px; }
.vd-f em { font-style: normal; color: var(--dim); font-size: 10.5px; font-family: var(--mono); }
.vd-type { grid-template-columns: 60px minmax(0, 1fr); margin-top: 8px; }
.vd-note { color: var(--dim); font-size: 10.5px; line-height: 1.45; margin: 4px 0 6px; }
.vd-b { display: flex; gap: 8px; margin-top: 8px; }
.primary { background: rgba(242, 229, 107, 0.12); border: 1px solid rgba(242, 229, 107, 0.55); color: #f6ee9a; border-radius: 8px; padding: 5px 14px; cursor: pointer; font-size: 12px; font-weight: 600; }
.primary:hover { background: rgba(242, 229, 107, 0.2); }
.ec-dot.vd { background: #f2e56b; box-shadow: 0 0 8px #f2e56b; }
.tl-src.simulated { color: #f2e56b; border-color: rgba(242, 229, 107, 0.5); }
.rec-card.vd { border-color: rgba(242, 229, 107, 0.35); background: linear-gradient(180deg, rgba(242, 229, 107, 0.06), rgba(242, 229, 107, 0.015)); }
.rec-card.vd .ec-h { color: #f6ee9a; }

/* ---------- hardware + model accuracy (phase 4c) ---------- */
.hw-t { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; border-radius: 4px; padding: 0 5px; border: 1px solid var(--line2); }
.hw-t.part { color: #ffe1b0; border-color: rgba(255, 181, 71, 0.5); }
.hw-t.user { color: #b9e9ff; border-color: rgba(79, 209, 255, 0.45); }
.accsec .sec-h .tag { color: #9ff0c2; border-color: rgba(75, 224, 138, 0.4); }
.acc-sum { display: grid; gap: 4px; margin: 8px 0; font-size: 12px; }
.acc-sum .k { display: inline-block; min-width: 108px; color: var(--dim); font-size: 11px; }
.acc-sum small { color: var(--dim); margin-left: 4px; }
.acc-h { margin: 12px 0 4px; font-size: 11.5px; color: #dfe7f0; font-weight: 600; }
.acc-h small { color: var(--dim); font-weight: 400; margin-left: 4px; }
.acc-t { width: 100%; border-collapse: collapse; font-size: 11px; }
.acc-t th, .acc-t td { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.acc-t th { color: var(--dim); font-weight: 500; font-size: 10.5px; }
.acc-t td { font-family: var(--mono); }
.acc-t td small { display: block; color: var(--dim); font-family: inherit; font-size: 9.5px; }
.acc-t .good { color: #9ff0c2; } .acc-t .ok { color: #ffe1b0; } .acc-t .poor { color: #ff8a7a; }
.acc-n { color: var(--dim); font-size: 10.5px; line-height: 1.45; margin: 4px 0 6px; }

/* ---------- shop: projects, branding, share links (phase 5) ---------- */
.shop-ws { grid-template-rows: auto minmax(0, 1fr); width: min(620px, 100vw); }
.sp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 10px; margin-bottom: 8px; }
.sp-grid label, .sp-notes { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--dim); }
.sp-grid label.w { grid-column: 1 / -1; }
.sp input:not([type=checkbox]):not([type=color]), .sp textarea { background: var(--panel2); border: 1px solid var(--line2); border-radius: 6px; color: var(--text); font: inherit; padding: 6px 8px; min-width: 0; }
.sp textarea { resize: vertical; }
.sp input[type=color] { width: 54px; height: 30px; padding: 0; border: 1px solid var(--line2); border-radius: 6px; background: none; }
.sp-notes { margin-bottom: 8px; }
.sp-b { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.sp-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.sp-list li { display: flex; align-items: center; gap: 6px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.sp-list li > div { flex: 1; min-width: 0; }
.sp-list b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-list small { color: var(--dim); font-size: 11px; }
.sp-logo span { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-logo img { max-height: 32px; max-width: 120px; background: #fff; border-radius: 4px; padding: 2px; }
.sp-curves { display: grid; gap: 5px; margin-bottom: 10px; }
.sp-curves label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.sp-curves i { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.sp-curves small { color: var(--dim); }
.sp-link { display: flex; gap: 6px; margin-bottom: 4px; }
.sp-link input { flex: 1; font-family: var(--mono); font-size: 11px; }
.sp-link a { text-decoration: none; display: inline-flex; align-items: center; }
.sh-k { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 9px; border: 1px solid currentColor; }
.sh-k.measured { color: var(--green); }
.sh-k.simulated { color: var(--cyan); }

/* customer share page */
body.share-page { height: auto; min-height: 100%; }
.sh { max-width: 920px; margin: 0 auto; padding: 22px 18px 50px; }
.sh-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 2px solid var(--brand, var(--amber)); }
.sh-shop { font-weight: 700; font-size: 16px; color: var(--brand, var(--amber)); letter-spacing: 0.02em; }
.sh h1 { font-size: 24px; margin: 18px 0 2px; }
.sh-d { color: var(--dim); margin: 0 0 14px; }
.sh-plot { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 8px 4px; }
.sh-o { position: absolute; left: 8px; top: 10px; cursor: crosshair; touch-action: none; }
.sh-play { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 16px; font-family: var(--mono); font-size: 11.5px; color: var(--dim); }
.sh-t { width: 100%; border-collapse: collapse; font-size: 13px; }
.sh-t th { text-align: left; color: var(--dim); font-weight: 500; font-size: 11px; padding: 6px 8px; border-bottom: 1px solid var(--line2); }
.sh-t td { padding: 8px; border-bottom: 1px solid var(--line); }
.sh-t td i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 7px; vertical-align: middle; }
.sh-t small { color: var(--dim); }
.sh-note { white-space: pre-wrap; background: var(--panel); border-left: 3px solid var(--brand, var(--amber)); padding: 10px 12px; margin: 18px 0; border-radius: 0 8px 8px 0; line-height: 1.55; }
.sh-f { margin-top: 26px; color: var(--dim); font-size: 11.5px; line-height: 1.55; }
.sh-f p { margin: 0 0 4px; }
.sh-load { color: var(--dim); padding: 40px 0; }
@media (max-width: 600px) { .sh-t th:nth-child(2), .sh-t td:nth-child(2) { display: none; } .sh h1 { font-size: 20px; } }

/* printed report */
#printArea { display: none; }
@media print {
  html, body { background: #fff !important; color: #111 !important; height: auto !important; }
  body.printing > :not(#printArea) { display: none !important; }
  body.printing #printArea { display: block; }
  .rp { font-size: 11pt; color: #111; }
  .rp-h { display: flex; align-items: center; gap: 14px; border-bottom: 3px solid var(--brand, var(--amber)); padding-bottom: 8px; }
  .rp-h img { max-height: 54px; max-width: 200px; }
  .rp-shop { font-size: 16pt; font-weight: 700; }
  .rp-d { color: #555; }
  .rp h1 { font-size: 18pt; margin: 14px 0 8px; }
  .rp h2 { font-size: 12pt; margin: 16px 0 6px; color: #333; }
  .rp table { border-collapse: collapse; width: 100%; }
  .rp-kv th { text-align: left; width: 110px; color: #555; font-weight: 500; padding: 2px 0; }
  .rp-t th, .rp-t td { text-align: left; padding: 5px 6px; border-bottom: 1px solid #ccc; }
  .rp-t td i { display: inline-block; width: 12px; height: 4px; margin-right: 6px; vertical-align: middle; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .rp-chart { width: 100%; border-radius: 6px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .rp-key { color: #555; font-size: 9pt; margin: 4px 0 10px; }
  .rp-f { margin-top: 20px; font-size: 9pt; color: #555; border-top: 1px solid #ccc; padding-top: 8px; }
}
.sp-conf { margin: 0 0 14px; padding: 8px 10px; border: 1px solid rgba(75, 224, 138, 0.35); background: rgba(75, 224, 138, 0.06); border-radius: 8px; font-size: 12px; line-height: 1.5; color: #b9d8c6; }
.sp-conf b { color: var(--green); }
.rc-exp { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; font-size: 11.5px; color: var(--dim); }

/* ---------- about page ---------- */
body.about-page { height: auto; min-height: 100%; font-size: 15px; line-height: 1.6; }
.ab-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(6, 9, 14, 0.92); backdrop-filter: blur(6px); z-index: 2; }
.ab-home { color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: 0.12em; font-size: 13px; }
.ab-cta { display: inline-block; text-decoration: none; padding: 8px 16px; border-radius: 8px; background: var(--amber); color: #120c02; font-weight: 600; font-size: 14px; }
.ab { max-width: 900px; margin: 0 auto; padding: 18px 20px 40px; }
.ab-crumb { font-size: 12.5px; color: var(--dim); }
.ab-crumb a, .ab a:not(.ab-cta) { color: #8fc3ff; }
.ab h1 { font-size: clamp(26px, 4vw, 38px); line-height: 1.15; margin: 10px 0 12px; }
.ab h2 { font-size: 22px; margin: 34px 0 12px; }
.ab-lead { font-size: 17px; color: #c3cfdb; }
.ab-hero { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); margin: 14px 0 4px; }
.ab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ab-f { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.ab-f h3 { margin: 0 0 6px; font-size: 15.5px; color: var(--amber); }
.ab-f p { margin: 0; color: #c3cfdb; font-size: 14px; }
.ab-list { columns: 2; padding-left: 18px; color: #c3cfdb; }
.ab-q { border-bottom: 1px solid var(--line); padding: 4px 0; }
.ab-q summary { cursor: pointer; list-style: none; }
.ab-q summary::-webkit-details-marker { display: none; }
.ab-q summary h3 { display: inline; font-size: 16px; margin: 0; }
.ab-q summary::before { content: '+'; display: inline-block; width: 18px; color: var(--amber); font-weight: 700; }
.ab-q[open] summary::before { content: '–'; }
.ab-q h3 { line-height: 2.4; }
.ab-q p { margin: 0 0 12px 18px; color: #c3cfdb; }
.ab-end { margin-top: 30px; }
.ab-foot { text-align: center; color: var(--dim); font-size: 12.5px; padding: 20px; border-top: 1px solid var(--line); }
@media (max-width: 600px) { .ab-list { columns: 1; } .ab-top .ab-cta { padding: 6px 12px; font-size: 13px; } }
.brand-sub a { color: var(--dim); text-decoration: underline; text-decoration-color: rgba(135, 150, 168, 0.4); }
.brand-sub a:hover { color: var(--text); }
.nojs { max-width: 640px; margin: 60px auto; padding: 0 20px; line-height: 1.6; }
.nojs a { color: #8fc3ff; }
