/* Instrument dashboard (InstrumentDashboard.razor, Tachometer/TachScale.razor).
   Graphite base with a quiet light behind the dial; colour roles:
   cyan = active controls and the live arc · lime = the chosen engine and highlights · red = redline/limiter or a real problem.
   Values from Revvolt's sound model carry the dashed .ins-sim mark.
   Performance: nothing here animates per frame except one opacity transition when the engine starts or stops;
   no filters, no animated shadows. The only per-frame drawing is the small pulse canvas (js pulse*). */

.ins {
  --ins-cyan: #22d3ee; --ins-cyan-2: #0ea5e9; --ins-cyan-soft: rgba(34, 211, 238, .14); --ins-lime: #bef264;
  --ins-ink: #f2f6fa; --ins-mute: #8a97a8; --ins-faint: rgba(140, 160, 185, .2); --ins-edge: rgba(255, 255, 255, .07);
  --ins-panel: rgba(20, 24, 30, .72);
  position: relative; isolation: isolate;
  grid-template-columns: 268px minmax(0, 1fr) 292px; grid-template-areas: "left center right"; grid-template-rows: minmax(0, 1fr);
  gap: 0 22px; padding: 14px 18px; border-radius: 18px; border: 1px solid var(--ins-edge);
  background:
    radial-gradient(560px 420px at 50% 44%, rgba(34, 211, 238, .045), transparent 72%),
    radial-gradient(900px 300px at 50% 100%, rgba(255, 255, 255, .025), transparent 70%),
    linear-gradient(180deg, #121519 0%, #0b0d10 100%);
}
.stage .cockpit.ins { grid-template-columns: 268px minmax(0, 1fr) 292px; grid-template-rows: minmax(0, 1fr); gap: 0 22px; }
/* The chosen engine is shown (and changed) in the dashboard itself; no second copy in the top bar. */
.shell.stage:not(.theme-wave) .topbar > .car-picker { visibility: hidden; }

/* Light behind the dial: fades in with the engine (opacity only, composited). */
.ins-light {
  position: absolute; z-index: -1; left: 50%; top: 46%; width: 620px; height: 620px; margin: -310px 0 0 -310px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(34, 211, 238, .11), rgba(34, 211, 238, .04) 55%, transparent 100%);
  opacity: 0; transition: opacity .8s ease;
}
.ins.is-on .ins-light { opacity: 1; }
.ins.is-calm .ins-light { opacity: .35; }

/* ---- Left: status panel ---- */
.ins-left { grid-area: left; display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 0; }
.ins-status { display: flex; flex-direction: column; border: 1px solid var(--ins-edge); border-radius: 12px; background: var(--ins-panel); }
.ins-row { position: relative; border-bottom: 1px solid var(--ins-edge); }
.ins-row:last-child { border-bottom: 0; }
.ins-k { display: block; font: 400 10px var(--label); letter-spacing: .2em; text-transform: uppercase; color: var(--ins-mute); }
.ins-k small { font: 400 10px var(--font); letter-spacing: .04em; text-transform: none; color: var(--text-3); }
.ins-select {
  width: 100%; min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "k chev" "v chev" "lvl chev";
  align-items: center; gap: 3px 10px; padding: 9px 14px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--ins-ink);
}
.ins-select .ins-k { grid-area: k; }
.ins-v { grid-area: v; font: 600 16px/1.2 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ins-chev { grid-area: chev; width: 22px; height: 22px; fill: none; stroke: var(--ins-cyan); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ins-select[aria-expanded="true"] { background: rgba(34, 211, 238, .06); }
.ins-select[aria-expanded="true"] .ins-chev { transform: rotate(180deg); }
.ins-select:disabled { cursor: not-allowed; color: var(--ins-mute); }
.ins-select:disabled .ins-chev { stroke: var(--ins-faint); }
.ins-level { grid-area: lvl; display: block; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: 4px; }
.ins-level i { display: block; height: 100%; background: var(--ins-cyan); }
.ins-accel { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 4px 10px; padding: 10px 14px 12px; }
.ins-accel .ins-level { grid-column: 1 / -1; }
.ins-accel .ins-level i { background: rgba(255, 255, 255, .55); }
.ins-accel-v { font: 300 20px var(--font); font-variant-numeric: tabular-nums; color: var(--ins-ink); }
.ins-accel-v small { font: 400 12px var(--font); color: var(--ins-mute); margin-left: 6px; }

/* Drop-down menus of the status rows. */
.ins-menu {
  position: absolute; z-index: 30; left: 6px; right: -150px; top: calc(100% - 4px); display: flex; flex-direction: column; padding: 6px;
  border: 1px solid rgba(34, 211, 238, .28); border-radius: 12px; background: #11161c; box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
}
.ins-menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 14px; border: 0; border-radius: 8px;
  background: none; color: var(--ins-ink); font: 500 16px var(--font); text-align: left; cursor: pointer;
}
.ins-menu button span { display: grid; gap: 2px; }
.ins-menu button small { font: 400 12.5px/1.3 var(--font); color: var(--ins-mute); }
.ins-menu button.active { background: rgba(34, 211, 238, .1); box-shadow: inset 3px 0 0 var(--ins-cyan); }
.ins-menu button.locked { color: var(--ins-mute); }
.ins-lock { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.ins-backdrop { position: absolute; inset: 0; z-index: 20; border: 0; padding: 0; background: transparent; cursor: default; border-radius: 18px; }
.ins-backdrop.dim { background: rgba(4, 6, 8, .55); }

/* Chosen engine: one larger card (picture, short model name, engine designation); the library opens from it. */
.ins-profile {
  flex: 1 1 auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 10px 12px; min-height: 0;
  border: 1px solid rgba(190, 242, 100, .28); border-radius: 12px; background: var(--ins-panel); color: var(--ins-ink); text-align: left; cursor: pointer;
}
.ins-profile .car-art { width: 100%; flex: 1 1 120px; min-height: 96px; height: 0; border-radius: 8px; display: block; object-fit: cover; }
.ins-profile-text { display: grid; gap: 3px; min-width: 0; padding: 0 4px; }
.ins-profile-text b { font: 600 17px/1.2 var(--font); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ins-engine { font: 400 12px var(--label); letter-spacing: .14em; color: var(--ins-lime); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ins-profile-text small { font: 400 12px var(--font); color: var(--ins-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ins-change {
  display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 0 12px; margin: 0 2px;
  border: 1px solid rgba(34, 211, 238, .4); border-radius: 8px; color: var(--ins-cyan); font: 400 11px var(--label); letter-spacing: .16em; text-transform: uppercase;
}
.ins-change svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Centre: the dial ---- */
.ins-center { grid-area: center; position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; }
.ins-dial { position: relative; width: min(100%, 600px); aspect-ratio: 600 / 560; max-height: 100%; }
.ins .tach { width: 100%; height: 100%; display: block; }
.ins .tach-face { fill: url(#insFace); }
.ins .tach-bezel { fill: none; stroke: rgba(255, 255, 255, .06); stroke-width: 1; }
.ins .tach-track { fill: none; stroke: rgba(170, 190, 210, .16); stroke-width: 3; }
.ins .tach-track.red { stroke: rgba(255, 59, 48, .5); }
.ins .tach-ring { fill: none; stroke: rgba(255, 255, 255, .06); stroke-width: 1; }
.ins.is-on .tach-ring { stroke: rgba(34, 211, 238, .2); }
.ins .tach-tick { stroke: rgba(200, 215, 230, .16); stroke-width: 1.5; }
.ins .tach-tick.major { stroke: rgba(220, 230, 240, .42); stroke-width: 2.5; }
.ins .tach-tick.red { stroke: rgba(255, 59, 48, .55); }
.ins .tach-num { fill: #7d8a9a; font: 300 32px var(--font); text-anchor: middle; dominant-baseline: middle; }
.ins.is-on .tach-num { fill: #c3ccd7; }
.ins .tach-num.red { fill: rgba(255, 90, 80, .75); }
.ins .tach-glow { fill: none; stroke: url(#insArc); stroke-width: 26; stroke-linecap: round; opacity: .13; }
.ins .tach-value { fill: none; stroke: url(#insArc); stroke-width: 7; stroke-linecap: round; }
.ins .tach-value.over { stroke: var(--red); }
.ins .tach-marker-halo { stroke: rgba(165, 243, 252, .28); stroke-width: 12; stroke-linecap: round; }
.ins .tach-marker { stroke: #fff; stroke-width: 4; stroke-linecap: round; }
.ins .tach-marker.over { stroke: #ffd9d6; }

.ins-readout {
  position: absolute; left: 50%; top: 53.6%; transform: translate(-50%, -50%); width: 62%;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; pointer-events: none;
}
.ins-big { display: flex; align-items: baseline; justify-content: center; font: 200 112px/0.92 var(--font); font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: var(--ins-ink); }
.ins-big .dim { color: var(--ins-faint); }
.ins-nospeed { gap: 14px; color: var(--ins-mute); }
.ins-nospeed .dash { font-size: 76px; font-weight: 200; color: #aab4c0; }
.ins-nospeed small { font: 300 30px var(--font); color: var(--ins-mute); }
.ins-unit { display: flex; align-items: center; justify-content: center; gap: 10px; font: 400 13px var(--label); letter-spacing: .24em; color: var(--text-2); }
.ins-unit.muted { font: 400 13px var(--font); letter-spacing: .04em; color: var(--ins-mute); }
.ins-under { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 8px; }
.ins-rpm { font: 300 28px var(--font); font-variant-numeric: tabular-nums; color: var(--ins-ink); }
.ins-rpm small { font: 400 11px var(--label); letter-spacing: .22em; color: var(--ins-mute); margin-left: 6px; }
.ins-gear {
  min-width: 52px; padding: 4px 12px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(0, 0, 0, .35);
  font: 400 22px var(--label); color: var(--ins-ink); text-align: center;
}
.ins-gear.limiter { color: var(--red); border-color: var(--red); }
.ins-mode-tag { padding: 6px 10px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, .14); font: 400 10px var(--label); letter-spacing: .18em; text-transform: uppercase; color: var(--text-2); }
/* The one mark for values from Revvolt's sound model or a simulation: dashed outline, never a colour of its own. */
.ins-sim {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; border: 1px dashed rgba(170, 190, 210, .5);
  font: 500 12px var(--font); letter-spacing: .03em; text-transform: none; color: #b4c2d2; white-space: nowrap;
}
.ins-sim::before { content: "≈"; font-weight: 600; color: var(--ins-mute); }
.ins-prov { padding: 2px 8px; border-radius: 6px; border: 1px solid rgba(170, 190, 210, .35); font: 500 12px var(--font); letter-spacing: .03em; color: #b4c2d2; }
.ins.is-off .ins-gear { color: var(--ins-mute); border-color: rgba(255, 255, 255, .08); }
.ins.is-off .ins-sim, .ins.is-off .ins-mode-tag { opacity: .6; }

/* Signature: the exhaust pulse strip in the dial's bottom opening (drawn by js pulse*). */
.ins-pulse { position: absolute; left: 31%; width: 38%; top: 84%; height: 8%; display: block; pointer-events: none; }

.ins-toast {
  position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); z-index: 5; max-width: 92%; padding: 10px 16px; border-radius: 10px;
  border: 1px solid rgba(255, 194, 61, .5); background: rgba(30, 24, 10, .92); color: var(--text); font-size: 15px; text-align: center;
}

/* ---- Right: one flow of controls ---- */
.ins-right { grid-area: right; display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }
.stage .ins .confirm, .ins .confirm {
  margin: 0; min-height: 62px; padding: 10px 14px; gap: 14px; border-radius: 12px; font-size: 15px; line-height: 1.3;
  border: 1px solid var(--ins-edge); background: var(--ins-panel);
}
.ins .confirm input { width: 28px; height: 28px; flex: none; accent-color: var(--ins-cyan); }
.ins .confirm.done { border-color: rgba(34, 211, 238, .35); }
.ins.is-on .confirm { opacity: .6; cursor: default; }

.ins .start-sound, .stage .ins .start-sound {
  width: 100%; min-height: 76px; padding: 10px 14px; border-radius: 12px; grid-template-columns: 30px minmax(0, 1fr) 22px; gap: 2px 8px;
  color: var(--ins-cyan); border: 1.5px solid var(--ins-cyan);
  background: linear-gradient(180deg, rgba(34, 211, 238, .16), rgba(14, 165, 233, .05)); box-shadow: inset 0 0 22px rgba(34, 211, 238, .08);
}
.ins .start-title { font-size: 16px; letter-spacing: .16em; }
.ins .start-title.long { font-size: 13px; letter-spacing: .1em; }
.ins .start-sound svg { width: 20px; height: 20px; }
.ins .start-sound .wave { transform: scale(.85); transform-origin: left center; }
.ins .start-sound:disabled { color: var(--ins-mute); border-color: rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .02); box-shadow: none; }
.ins .start-sound:disabled .start-title { color: var(--ins-mute); }
.ins .start-sound.on { color: var(--ins-cyan); border-color: rgba(34, 211, 238, .45); background: rgba(10, 14, 18, .8); box-shadow: none; }
.ins .start-sound:not(:disabled):active { background: rgba(34, 211, 238, .2); }

.ins-resume { width: 100%; }
.ins-throttle { flex: 1 1 auto; min-height: 120px; display: flex; gap: 12px; }
.ins .ins-throttle .pedal, .stage .ins .ins-throttle .pedal {
  flex: 1 1 0; width: auto; height: auto; border-radius: 14px; border: 1px solid rgba(34, 211, 238, .3);
  background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(0, 0, 0, .35));
}
.ins .ins-throttle .pedal:active { border-color: var(--ins-cyan); background: linear-gradient(180deg, rgba(34, 211, 238, .08), rgba(0, 0, 0, .3)); }
.ins .ins-throttle .pedal-fill {
  background: linear-gradient(0deg, rgba(14, 165, 233, .35), rgba(34, 211, 238, .7)); opacity: 1; border-top: 2px solid #cffafe;
}
.ins .ins-throttle .pedal-brake { border-color: rgba(255, 255, 255, .16); }
.ins .ins-throttle .pedal-brake .pedal-fill { background: linear-gradient(0deg, #4b5563, #9aa5b5); border-top-color: #e5e7eb; }
.ins .ins-throttle .pedal-label { top: 16px; font-size: 13px; color: var(--ins-ink); }
.ins .ins-throttle .pedal-value { bottom: 14px; font-size: 24px; font-weight: 300; }
.ins-throttle.waiting { opacity: .45; }
.ins-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ins-foot .hint { margin: 0; font-size: 12.5px; }
.ins-foot .remote-toggle { margin: 0; gap: 8px; }
.ins-foot .remote-state { font-size: 12px; max-width: 130px; }
.ins-later { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px dashed rgba(255, 255, 255, .1); border-radius: 12px; }
.ins-later .hint { margin: 0; font-size: 13px; line-height: 1.4; }
.ins-later .remote-toggle { margin: 0; }
.ins .remote-btn.on { border-color: var(--ins-cyan); color: var(--ins-cyan); }
.ins-gforce { padding: 12px 14px; border: 1px solid var(--ins-edge); border-radius: 12px; background: var(--ins-panel); }
.ins-gforce .ins-k { margin-bottom: 10px; }
.ins-gforce .gforce { grid-template-columns: 120px 1fr; gap: 12px; }
.ins-gforce .gforce dd { font-size: 20px; margin-bottom: 4px; }
.ins-gforce .gforce svg .gforce-dot { fill: var(--ins-cyan); filter: none; }

/* ---- Engine library (opens from the card; covers centre and right) ---- */
.ins-library {
  position: absolute; z-index: 40; top: 14px; bottom: 14px; right: 18px; left: calc(18px + 268px + 22px);
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 14px;
  border: 1px solid rgba(34, 211, 238, .25); background: #0f1317; box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
.ins-library-head { display: flex; align-items: center; gap: 12px; font: 400 13px var(--label); letter-spacing: .2em; text-transform: uppercase; color: var(--text-2); }
.ins-library-head a { font: 400 11px var(--label); letter-spacing: .14em; color: var(--text-2); text-decoration: none; padding: 0 6px; }
.ins-close { width: 44px; height: 40px; border-radius: 10px; border: 1px solid rgba(34, 211, 238, .4); background: none; color: var(--ins-cyan); display: grid; place-items: center; cursor: pointer; }
.ins-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ins-library-list { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 10px; padding-right: 4px; overscroll-behavior: contain; scrollbar-width: thin; }
.ins-lib-item {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto 22px; align-items: center; gap: 12px; min-height: 80px; padding: 8px 12px 8px 8px;
  border-radius: 10px; border: 1px solid var(--ins-edge); background: rgba(255, 255, 255, .02); color: var(--ins-ink); text-align: left; cursor: pointer;
}
.ins-lib-item .car-art { width: 96px; height: 60px; border-radius: 6px; display: block; }
.ins-lib-item .ins-profile-text b { font-size: 15px; }
.ins-lib-item .ins-lock { color: var(--ins-mute); }
.ins-lib-item.selected { border-color: rgba(190, 242, 100, .6); background: rgba(190, 242, 100, .05); }
.ins-lib-item.selected .radio { border-color: var(--ins-lime); }
.ins-lib-item.selected .radio::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--ins-lime); }
.ins-lib-item:active { border-color: var(--ins-cyan); }

@media (prefers-reduced-motion: reduce) { .ins-light { transition: none; } }
