/* ── Excavator Simulator ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --surface:   #161b27;
  --surface2:  #1f2535;
  --border:    #2a3050;
  --accent:    #f4c430;
  --accent-lo: rgba(244,196,48,.22);
  --green:     #3ddc84;
  --red:       #ff5555;
  --gold:      #f5c842;
  --text:      #dde3f0;
  --text-dim:  #8b97ab;
  --font:      'Segoe UI', system-ui, sans-serif;
  --mono:      'Courier New', monospace;
  --radius:    12px;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; padding: 0 16px; }
#app { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
[hidden] { display: none !important; }

/* ── Header ───────────────────────────────────────────────────── */
header { text-align: center; padding: 4px 0; }
header h1 {
  font-size: 1.8rem; font-weight: 700;
  background: linear-gradient(120deg, #f4c430 0%, #ffe08a 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.subtitle { color: var(--text-dim); font-size: 0.85rem; margin-top: 3px; }

/* ── Controls bar ─────────────────────────────────────────────── */
.controls-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.ctrl-group { display: flex; align-items: center; gap: 8px; }
.ctrl-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); white-space: nowrap; }
.pill-tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.pill-tabs.pill-wrap { flex-wrap: wrap; }
.pill {
  padding: 5px 13px; border: none; background: transparent; color: var(--text-dim);
  border-radius: 6px; cursor: pointer; font-size: 0.81rem; min-height: 30px;
  transition: background .18s, color .18s, box-shadow .18s;
}
.pill.active { background: var(--accent); color: #1a1a1a; box-shadow: 0 0 12px var(--accent-lo); }
.pill:hover:not(.active) { background: var(--surface2); color: var(--text); }
.pill:focus-visible, .tbtn:focus-visible, .vt-pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ── Canvas card ──────────────────────────────────────────────── */
.canvas-card {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; position: relative; overflow-x: clip;
  display: flex; flex-direction: column; gap: 6px;
}
.canvas-wrap { position: relative; }
.canvas-card #sim-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1000 / 560; border-radius: 8px; touch-action: pan-y; outline: none; }
.chart-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1000 / 220; border-radius: 8px; }
.view-strip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.preset-pick { flex: 0 1 auto; min-width: 0; }
.preset-pick select { min-width: 0; width: 100%; max-width: 280px; }
.unit-pick { margin-left: auto; }
.vt-tabs { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.vt-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 0; border-radius: 6px; background: transparent; color: var(--text-dim); font-weight: 700; font-size: 0.82rem; cursor: pointer; min-height: 32px; }
.vt-pill.active { background: var(--accent); color: #1a1a1a; }
.vt-pill:hover:not(.active) { background: var(--surface2); color: var(--text); }
.preset-pick, .speed-pick { display: inline-flex; align-items: center; gap: 8px; }
.preset-pick select, .speed-pick select, .sel-group select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 0.82rem; min-height: 32px; max-width: 100%;
}
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tbtn {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  background: var(--surface2); color: var(--text); font-weight: 700; font-size: 0.82rem; min-height: 34px;
  transition: background .15s, border-color .15s, color .15s;
}
.tbtn:hover { border-color: var(--accent); }
.tbtn.on { background: var(--accent); border-color: var(--accent); color: #1a1a1a; }
.tbtn-go { border-color: rgba(61,220,132,.5); }
.tbtn-quiet { background: transparent; color: var(--text-dim); }
.speed-pick { margin-left: auto; }
.chart-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }

.sim-warn { background: rgba(255,159,67,.12); border: 1px solid rgba(255,159,67,.45); color: #ffcf99; border-radius: 8px; padding: 7px 12px; font-size: 0.82rem; }
.verdict { background: var(--bg); border-left: 3px solid var(--accent); border-radius: 6px; padding: 6px 10px; font-size: 0.78rem; line-height: 1.45; color: var(--text); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  padding: 8px 18px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 0.84rem; font-weight: 600; transition: filter .18s, box-shadow .18s, opacity .18s; min-height: 36px;
}
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #1a1a1a; }
.btn-primary:not(:disabled):hover { filter: brightness(1.12); box-shadow: 0 0 12px var(--accent-lo); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }

/* ── Under the stage: grouped panels ── */
.wb-dock { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px 8px; min-width: 0; }
.res-list { display: grid; grid-template-columns: 1fr; column-gap: 14px; }
.res-list .readout-card {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
  background: none; border: 0; border-bottom: 1px solid rgba(42,48,80,.7); border-radius: 0;
  padding: 2px 2px; text-align: left; min-width: 0;
}
.res-list .readout-card.res-wide { grid-column: 1 / -1; }
.res-list .readout-card.live { border-bottom-style: dashed; }
.res-list .readout-label { text-transform: none; letter-spacing: 0; font-size: 0.72rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-list .readout-card > div:last-child { white-space: nowrap; }
.res-list .readout-val { font-size: 0.8rem; }
.res-list .readout-unit { font-size: 0.64rem; margin-left: 2px; }
.res-list .readout-card.bad { background: rgba(255,85,85,.08); }

.rail-groups, .rail-col { display: flex; flex-direction: column; gap: 8px; }
.ctl-group {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 11px; display: flex; flex-direction: column; gap: 7px; min-width: 0;
}
.ctl-head { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 800; }
.type-tabs .pill { padding: 4px 9px; font-size: 0.76rem; min-height: 28px; }
.ctl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
.sel-group { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sel-group select { padding: 4px 8px; min-height: 30px; font-size: 0.8rem; width: 100%; }
.sim-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sim-slider-group { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l v" "s s"; align-items: center; column-gap: 8px; row-gap: 1px; }
.sim-slider-group .sim-slider-label { grid-area: l; }
.sim-slider-group .sim-slider { grid-area: s; }
.sim-slider-group .sim-slider-val { grid-area: v; }
.sim-slider-label { font-size: 0.72rem; font-weight: 700; color: var(--text-dim); line-height: 1.25; min-width: 0; }
.sim-slider {
  width: 100%; -webkit-appearance: none; appearance: none; height: 5px; margin: 6px 0;
  background: var(--surface2); border-radius: 3px; outline: none;
}
.sim-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 0 8px var(--accent-lo); }
.sim-slider::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer; }
.sim-slider:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.sim-slider-val { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; color: var(--accent); text-align: right; white-space: nowrap; }

.readout-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; text-align: center; min-width: 0; }
.readout-card.bad { border-color: rgba(255,85,85,.7); background: rgba(255,85,85,.07); }
.readout-card.bad .readout-val { color: #ff8a80; }
.readout-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout-val { font-family: var(--mono); font-size: 1rem; font-weight: 700; color: var(--accent); }
.readout-unit { font-size: 0.64rem; color: var(--text-dim); margin-left: 3px; }
.key-results .readout-card > div:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sim-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.8rem; color: var(--text); }
.sim-toggle input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* ── SEO article tables & FAQ ─────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 10px 0; }
.data-table { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
.data-table th, .data-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: right; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { background: var(--surface2); color: var(--text); }
.table-note { font-size: 0.8rem; color: var(--text-dim); }
.faq h4 { margin-top: 12px; }

/* ── 3D view (cyl3d.js) ───────────────────────────────────────── */
.e3d-stage { position: relative; width: 100%; }
.e3d-view { position: relative; width: 100%; aspect-ratio: 1000 / 560; border-radius: 8px; overflow: hidden; background: #0f1319; }
.e3d-stage .e3d-gl, .e3d-stage .e3d-hud { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.e3d-stage .e3d-gl { cursor: grab; outline: none; touch-action: none; }
.e3d-stage .e3d-gl.grabbing { cursor: grabbing; }
.e3d-stage .e3d-gl:focus-visible { box-shadow: inset 0 0 0 2px var(--gold); }
.e3d-stage .e3d-hud { pointer-events: none; }
.e3d-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.e3d-seg { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.e3d-seg button { padding: 5px 11px; border: 0; border-radius: 6px; background: transparent; color: var(--text-dim); font-weight: 700; font-size: 0.76rem; cursor: pointer; min-height: 30px; }
.e3d-seg button:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.e3d-seg button.on { background: var(--accent); color: #1a1a1a; }
.e3d-seg button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.e3d-info { position: absolute; right: 10px; bottom: 10px; width: 300px; max-width: calc(100% - 20px); background: rgba(10,13,19,.94); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 0.8rem; line-height: 1.5; color: var(--text); }
.e3d-ititle { font-weight: 800; color: #ffbe5a; font-size: 0.9rem; margin: 0 22px 4px 0; }
.e3d-x { position: absolute; right: 6px; top: 5px; border: 0; background: transparent; color: var(--text-dim); font-size: 0.9rem; cursor: pointer; min-width: 26px; min-height: 26px; border-radius: 6px; }
.e3d-x:hover { background: rgba(255,255,255,0.1); }
.e3d-hint { position: absolute; left: 10px; bottom: 10px; font-size: 0.74rem; color: var(--text-dim); background: rgba(10,13,19,.7); padding: 4px 8px; border-radius: 6px; }
.cy3d-note { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 6; padding: 8px 34px 8px 12px; border-radius: 10px; background: rgba(13,17,23,.92); border: 1px solid var(--border); font-size: 0.8rem; color: var(--text); }
.cy3d-note button { position: absolute; right: 6px; top: 5px; border: 0; background: transparent; color: var(--text-dim); font-size: 0.9rem; cursor: pointer; min-width: 24px; min-height: 24px; }

/* ── Explore mode ─────────────────────────────────────────────── */
.item-selector {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.is-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 8px; margin-top: 10px; }
.is-btn {
  padding: 10px 14px; border: 2px solid var(--border); border-radius: 10px;
  background: var(--surface2); color: var(--text-dim); font-size: 0.82rem;
  font-weight: 600; cursor: pointer; text-align: left;
  transition: border-color .18s, color .18s, background .18s, box-shadow .18s;
}
.is-btn:hover { border-color: rgba(244,196,48,.45); color: var(--text); }
.is-btn.active { border-color: var(--accent); color: #fff; background: rgba(244,196,48,.15); box-shadow: 0 0 14px var(--accent-lo); }
.is-btn-name { display: block; font-size: 0.82rem; font-weight: 700; }
.is-btn-sym  { display: block; font-size: 0.68rem; color: var(--accent); margin-top: 2px; font-family: var(--mono); }

.item-info {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px;
}
.ii-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ii-name { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.ii-cat-badge {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; padding: 3px 10px; border-radius: 20px;
  background: var(--accent-lo); color: var(--accent);
}
.ii-desc { font-size: 0.85rem; color: var(--text-dim); line-height: 1.65; }

.formula-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.fb-formula { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.fb-unit { font-size: 0.78rem; color: var(--text-dim); }

.example-box {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px;
}
.example-box h4 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 8px; }
.example-box .ex-problem { font-size: 0.84rem; color: var(--text); margin-bottom: 8px; line-height: 1.6; }
.example-box .ex-step { font-size: 0.8rem; color: var(--text-dim); line-height: 1.6; padding: 2px 0; }
.example-box .ex-step strong { color: var(--green); font-family: var(--mono); }

/* ── Practice mode ────────────────────────────────────────────── */
.practice-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.pp-prompt { font-size: 0.92rem; font-weight: 600; color: var(--text); margin-bottom: 14px; line-height: 1.6; }
.pp-input-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pp-input {
  flex: 1; min-width: 120px; max-width: 220px;
  padding: 10px 14px; border: 2px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font-family: var(--mono);
  font-size: 1rem; font-weight: 700; transition: border-color .18s;
}
.pp-input:focus { outline: none; border-color: var(--accent); }
.pp-unit { font-size: 0.88rem; color: var(--text-dim); font-weight: 600; }
.pp-bottom { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.feedback { font-size: 0.88rem; font-weight: 600; }
.feedback.ok  { color: var(--green); }
.feedback.err { color: var(--red); }

.solution-panel {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; margin-top: 12px;
}
.solution-panel h4 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 8px; }
.sol-step { font-size: 0.82rem; color: var(--text-dim); line-height: 1.7; padding: 2px 0; }
.sol-step strong { color: var(--green); font-family: var(--mono); }

.practice-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.pbar-score { font-size: 0.84rem; color: var(--text-dim); margin-left: auto; white-space: nowrap; }
.pbar-score span { color: var(--text); font-weight: 700; }

/* ── Quiz panels ──────────────────────────────────────────────── */
.question-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.qp-prompt { font-size: 0.88rem; font-weight: 600; color: var(--text); margin-bottom: 12px; line-height: 1.6; }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer-btn {
  padding: 14px 16px; border: 2px solid var(--border); border-radius: 10px;
  background: var(--surface2); color: var(--text); font-size: 0.88rem;
  font-weight: 600; cursor: pointer; text-align: center;
  transition: border-color .18s, background .18s, color .18s, transform .12s;
}
.answer-btn:hover:not(.locked) { border-color: var(--accent); background: rgba(244,196,48,.06); }
.answer-btn.correct { border-color: var(--green); background: rgba(61,220,132,.12); color: var(--green); }
.answer-btn.wrong { border-color: var(--red); background: rgba(255,85,85,.08); color: var(--red); }
.answer-btn.locked { cursor: default; opacity: 0.6; }
.answer-btn.correct.locked { opacity: 1; }

.quiz-input-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.qi-input {
  flex: 1; min-width: 120px; max-width: 200px;
  padding: 10px 14px; border: 2px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font-family: var(--mono);
  font-size: 1rem; font-weight: 700; transition: border-color .18s;
}
.qi-input:focus { outline: none; border-color: var(--accent); }
.qi-unit { font-size: 0.84rem; color: var(--text-dim); font-weight: 600; }

.quiz-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.qbar-counter { display: flex; align-items: baseline; gap: 3px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 4px 12px; }
.qbar-q-label { font-size: 0.7rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.qbar-q-num { font-family: var(--mono); font-size: 1.3rem; font-weight: 700; color: var(--text); line-height: 1; }
.qbar-q-sep { font-size: 0.82rem; color: var(--text-dim); }
.qbar-q-total { font-family: var(--mono); font-size: 0.88rem; color: var(--text-dim); }
.quiz-feedback { font-size: 0.88rem; font-weight: 600; }
.quiz-feedback.ok  { color: var(--green); }
.quiz-feedback.err { color: var(--red); }

/* Quiz result */
.quiz-result {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; display: flex; flex-direction: column; gap: 14px;
}
.qr-header { display: flex; align-items: flex-start; justify-content: space-between; }
.qr-title-wrap { display: flex; flex-direction: column; gap: 5px; }
.qr-title  { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.qr-stars  { font-size: 1.2rem; letter-spacing: 3px; }
.qr-score-wrap { text-align: right; }
.qr-score { font-family: var(--mono); font-size: 2.2rem; font-weight: 700; line-height: 1; text-shadow: 0 0 14px currentColor; }
.qr-score.perfect { color: var(--gold); }
.qr-score.good { color: var(--green); }
.qr-score.poor { color: var(--red); }
.qr-verdict { font-size: 0.72rem; color: var(--text-dim); margin-top: 3px; }
.qr-rows { display: flex; flex-direction: column; gap: 7px; }
.qr-row {
  display: grid; grid-template-columns: 30px 1fr 26px; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border); border-left-width: 3px;
  border-radius: 8px; padding: 9px 12px;
}
.qr-row.ok  { border-left-color: var(--green); }
.qr-row.err { border-left-color: var(--red); }
.qr-qnum { font-size: 0.72rem; font-weight: 700; color: var(--accent); }
.qr-detail { font-size: 0.78rem; color: var(--text-dim); }
.qr-detail strong { color: var(--text); }
.qr-mark { text-align: right; font-size: 1rem; font-weight: 700; }
.qr-row.ok .qr-mark { color: var(--green); }
.qr-row.err .qr-mark { color: var(--red); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .answer-grid { grid-template-columns: 1fr 1fr; }
  .is-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .controls-bar { gap: 10px; }
  .speed-pick { margin-left: 0; }
}
@media (max-width: 560px) {
  .unit-pick { order: 2; }
  .preset-pick { order: 3; flex: 1 1 100%; }
  .preset-pick select { max-width: none; }
}
@media (max-width: 500px) {
  header h1 { font-size: 1.35rem; }
  .subtitle  { font-size: 0.78rem; }
  .controls-bar { padding: 10px 12px; gap: 8px; }
  .pill { padding: 5px 10px; font-size: 0.76rem; }
  .answer-grid { grid-template-columns: 1fr; }
  .is-grid { grid-template-columns: 1fr 1fr; }
  .tbtn { padding: 8px 10px; font-size: 0.8rem; }
}

/* INTERLINK-START  header quick-links */
.head-actions{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:wrap;justify-content:flex-end;}
.btn-link{display:inline-flex;align-items:center;gap:7px;padding:5px 12px;border-radius:8px;font-size:.82rem;font-weight:700;text-decoration:none;cursor:pointer;background:var(--surface2,#1f2535);color:var(--text,#dde3f0);border:1.5px solid var(--border,#2a3050);white-space:nowrap;transition:border-color .18s,background .18s,color .18s;}
.btn-link:hover{border-color:var(--accent,#4fc3f7);background:var(--accent-lo,rgba(79,195,247,.18));color:#fff;}
.btn-link img{width:20px;height:20px;border-radius:4px;flex:none;}
.btn-link .lbl{line-height:1;}
@media(max-width:560px){.btn-link .lbl{display:none;}.btn-link{padding:5px 9px;}}
/* INTERLINK-END */


/* Mobile: enlarge the slider touch target without moving the visuals.
   The visible track is the input's own background, so transparent vertical
   padding plus background-clip:content-box keeps the bar exactly where it was
   while growing the hit box. Measured on beam-bending: the effective touch
   band goes from 18px to 30px, clearing the WCAG 2.5.8 minimum of 24px.
   box-sizing must be content-box because the global reset sets border-box. */
@media (max-width: 720px) {
  .sim-slider {
    box-sizing: content-box;
    padding: 12px 0;
    background-clip: content-box;
  }
}

/* ═══ In-canvas display controls (collapsible) ═══════════════════ */
.canvas-toggles {
  position: absolute; top: 8px; left: 8px; z-index: 4;
  background: rgba(13,17,30,0.82);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  border: 1px solid rgba(139,157,195,0.22); border-radius: 9px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.32);
}
.canvas-toggles > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 10px; white-space: nowrap;
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text); border-radius: 9px;
  transition: background 0.12s, color 0.12s;
}
.canvas-toggles > summary::-webkit-details-marker { display: none; }
.canvas-toggles > summary::marker { content: ''; }
.canvas-toggles > summary:hover { background: rgba(124,179,66,0.10); color: var(--accent); }
.canvas-toggles .cvt-ico { flex-shrink: 0; color: var(--accent); }
.canvas-toggles .cvt-caret { margin-left: auto; padding-left: 4px; color: var(--text-dim); font-size: 0.7rem; transition: transform 0.2s; }
.canvas-toggles[open] > summary .cvt-caret { transform: rotate(180deg); color: var(--accent); }
.canvas-toggles[open] > summary { border-bottom: 1px solid rgba(139,157,195,0.18); border-radius: 9px 9px 0 0; }
.canvas-toggles .cvt-body { display: flex; flex-direction: column; gap: 5px; padding: 8px 11px 9px; }
.canvas-toggles .cvt-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem; color: var(--text-dim); cursor: pointer; white-space: nowrap;
  transition: color 0.12s;
}
.canvas-toggles .cvt-item:hover { color: var(--text); }
.canvas-toggles .cvt-item input[type="checkbox"] {
  accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; flex-shrink: 0;
}

/* the toggles keep their .sim-toggle class; drop the pill chrome inside the panel */
.canvas-toggles .cvt-body .sim-toggle {
  background: none; border: none; border-radius: 0;
  padding: 0; min-height: 0; font-size: 0.72rem;
}
.canvas-toggles .cvt-body .sim-toggle:has(input:checked) { border-color: transparent; }

/* ═══ Mobile: collapse the canvas display-controls to an icon-only chip ═══ */
@media (max-width: 768px) {
  .canvas-toggles > summary {
    padding: 0; gap: 0;
    min-width: 44px; min-height: 44px;
    justify-content: center;
  }
  .canvas-toggles > summary .cvt-title,
  .canvas-toggles > summary .cvt-caret { display: none; }
  .canvas-toggles .cvt-ico { width: 18px; height: 18px; }
  .canvas-toggles[open] > summary {
    padding: 7px 10px; gap: 7px;
    min-height: 0; justify-content: flex-start;
  }
  .canvas-toggles[open] > summary .cvt-title { display: inline; }
  .canvas-toggles[open] > summary .cvt-caret { display: inline; margin-left: auto; padding-left: 4px; }
}

/* ═══ Parts library ═══ */
.parts-panel { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 10px; }
.pp-group { margin-bottom: 6px; }
.pp-ghead { font-size: 0.64rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 800; margin: 2px 0 4px; }
.pp-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.pp-btn { padding: 4px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface2); color: var(--text-dim); font-size: 0.74rem; font-weight: 600; cursor: pointer; min-height: 28px; }
.pp-btn:hover { color: var(--text); border-color: rgba(244,196,48,.5); }
.pp-btn.active { background: var(--accent); border-color: var(--accent); color: #1a1a1a; }
.part-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 0.8rem; line-height: 1.5; color: var(--text); display: flex; flex-direction: column; gap: 6px; }
.pc-name { font-weight: 800; color: #ffd75a; font-size: 0.95rem; }
.pc-specs { display: grid; grid-template-columns: 1fr; gap: 2px; }
.pc-specs div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid rgba(42,48,80,.7); padding: 2px 0; }
.pc-specs span { color: var(--text-dim); font-size: 0.74rem; } .pc-specs b { font-family: var(--mono); color: var(--accent); font-size: 0.78rem; white-space: nowrap; }
.pc-needs { color: var(--text-dim); font-size: 0.74rem; }

/* ═══ Build ═══ */
.build-panel { display: flex; flex-direction: column; gap: 8px; }
.bp-msg { background: var(--bg); border-left: 3px solid var(--accent); border-radius: 6px; padding: 7px 10px; font-size: 0.8rem; line-height: 1.45; }
.bp-msg.bad { border-left-color: var(--red); color: #ffc9c9; } .bp-msg.ok { border-left-color: var(--green); }
.bp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bp-order { margin-left: auto; font-size: 0.76rem; }
.bp-tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.bt-card { position: relative; text-align: left; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 1px; min-height: 44px; }
.bt-card:hover { border-color: rgba(244,196,48,.6); }
.bt-card.fitted { background: rgba(61,220,132,.08); border-color: rgba(61,220,132,.45); }
.bt-card.fitted .bt-name { color: var(--green); }
.bt-card.hint, .bt-card.next { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 12px rgba(245,200,66,.3); }
.bt-card.shake { animation: btshake .35s; }
@keyframes btshake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.bt-num { position: absolute; right: 6px; top: 5px; font-family: var(--mono); font-size: 0.7rem; color: var(--gold); font-weight: 800; }
.bt-name { font-size: 0.76rem; font-weight: 700; padding-right: 18px; }
.bt-grp { font-size: 0.62rem; color: var(--text-dim); }
.bp-report { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; line-height: 1.45; }
.br-head { font-weight: 800; color: #ffd75a; }
.br-line { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 6px; }
.br-line span { font-weight: 800; } .br-line.ok span { color: var(--green); } .br-line.bad span { color: var(--red); }
.br-line b { color: var(--text); margin-right: 4px; }
.bp-report .btn { align-self: flex-start; margin-top: 6px; }

@media (max-width: 900px) {
  .parts-panel { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .joy-col { padding: 18px 8px 0; }
  .jl-l, .jl-r { display: none; }
}
@media (max-width: 500px) {
  .bp-tray { grid-template-columns: 1fr 1fr; }
  .bp-order { margin-left: 0; }
}

.verdict:empty { display: none; }


/* ═══ The stage: the machine full width; everything you operate it with is laid over it ═══ */
.sim-area { display: flex; flex-direction: column; gap: 10px; }
.sim-area > .canvas-card { padding: 0; gap: 0; overflow: hidden; }
.stage { position: relative; width: 100%; height: clamp(460px, calc(100vh - 110px), 800px); background: #0e141d; border-radius: 12px; }
.stage .canvas-wrap { position: absolute; inset: 0; }
.canvas-card #sim-canvas { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; border-radius: 12px; touch-action: none; cursor: default; }
.canvas-card #sim-canvas.can-grab { cursor: grab; } .canvas-card #sim-canvas.grabbing { cursor: grabbing; }
.stage .e3d-stage { position: absolute; inset: 0; }
.stage .e3d-view { aspect-ratio: auto; height: 100%; border-radius: 12px; }
.stage .e3d-bar { position: absolute; top: 50px; right: 10px; z-index: 6; margin: 0; flex-direction: column; align-items: flex-end; gap: 6px; }
.stage .e3d-seg { background: rgba(13,17,23,.82); backdrop-filter: blur(4px); }
.stage .e3d-hint { display: none; }
.stage .e3d-info { bottom: 160px; }

.stage-top { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 7; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; pointer-events: none; }
.stage-top > * { pointer-events: auto; }
.stage-top .vt-tabs, .stage-top .unit-pick { background: rgba(13,17,23,.82); backdrop-filter: blur(4px); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.stage-top .vt-pill { min-height: 30px; padding: 5px 12px; }
.stage-top-r { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.stage-top .unit-pick { margin-left: 0; }
.stage-top .unit-pick .pill { min-height: 28px; padding: 4px 10px; }
.st-icon { width: 36px; height: 36px; border-radius: 10px; border: 1px solid rgba(139,157,195,.3); background: rgba(13,17,23,.82); color: var(--text); font-size: 1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.st-icon:hover { border-color: var(--accent); }
.st-icon[aria-pressed="false"]#btn-sound { opacity: .55; }
.st-icon:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.stage-top .canvas-toggles { position: relative; top: auto; left: auto; }
.stage-top .canvas-toggles .cvt-body { position: absolute; top: calc(100% + 4px); left: 0; min-width: 220px; background: rgba(13,17,30,.95); border: 1px solid rgba(139,157,195,.25); border-radius: 9px; box-shadow: 0 8px 22px rgba(0,0,0,.45); }
.stage-top .canvas-toggles[open] > summary { border-bottom: 0; border-radius: 9px; }

.stage .hud { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; gap: 4px; pointer-events: none; grid-template-columns: none; }
.stage .hud .readout-card { background: rgba(8,11,18,.78); border: 1px solid rgba(139,157,195,.2); border-radius: 9px; padding: 3px 10px; min-width: 76px; backdrop-filter: blur(3px); }
.stage .hud .readout-label { font-size: 0.55rem; margin: 0; }
.stage .hud .readout-val { font-size: 0.92rem; }
.stage .hud .readout-card.bad { border-color: rgba(255,85,85,.8); background: rgba(80,10,10,.75); }

.stage .verdict { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); z-index: 5; width: max-content; max-width: min(620px, calc(100% - 330px)); background: rgba(8,11,18,.84); backdrop-filter: blur(4px); pointer-events: none; }
.stage .cv-hint { bottom: 128px; z-index: 8; }
.stage .grab-tip { position: absolute; z-index: 9; pointer-events: none; background: rgba(8,11,18,.9); border: 1px solid rgba(244,196,48,.6); color: #ffe08a; font-size: 0.74rem; font-weight: 700; padding: 4px 8px; border-radius: 7px; transform: translate(14px, -130%); white-space: nowrap; }
.stage .mission-banner { position: absolute; left: 50%; top: 104px; transform: translateX(-50%); z-index: 7; background: rgba(13,17,23,.94); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 16px; text-align: center; color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: calc(100% - 40px); }
.mission-banner .mb-title { font-weight: 800; color: #ffd75a; font-size: 1rem; }
.mission-banner .mb-stars { font-size: 1.3rem; letter-spacing: 3px; color: var(--gold); }
.mission-banner .mb-line { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }
.mission-banner button { margin-top: 8px; }

/* the joysticks in the stage's lower corners, travel and Show me between them */
.stage .drive { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 12px 10px; gap: 10px; pointer-events: none; }
.stage .drive > * { pointer-events: auto; }
.joy-col { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 50px 0; }
.joy {
  position: relative; width: 118px; height: 118px; border-radius: 50%; cursor: grab; touch-action: none; user-select: none;
  background: radial-gradient(circle at 50% 50%, rgba(31,37,53,.85) 0 36%, rgba(22,27,39,.78) 37% 100%); border: 2px solid rgba(139,157,195,.35);
  box-shadow: 0 6px 18px rgba(0,0,0,.4), inset 0 6px 14px rgba(0,0,0,.45); backdrop-filter: blur(3px);
}
.joy::before, .joy::after { content: ''; position: absolute; background: rgba(139,157,195,.22); }
.joy::before { left: 50%; top: 10px; bottom: 10px; width: 1px; } .joy::after { top: 50%; left: 10px; right: 10px; height: 1px; }
.joy.on { border-color: var(--accent); cursor: grabbing; }
.joy:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 42px; height: 42px; margin: -21px 0 0 -21px; border-radius: 50%; z-index: 2;
  background: radial-gradient(circle at 35% 30%, #5a606a, #16181c 70%); border: 2px solid #0b0c0f; box-shadow: 0 4px 10px rgba(0,0,0,.5); transition: transform .06s linear; }
.joy.on .joy-knob { background: radial-gradient(circle at 35% 30%, #ffe08a, #b98a00 70%); }
.jl { position: absolute; font-size: 0.6rem; font-weight: 800; color: #c9d2e3; white-space: nowrap; pointer-events: none; text-transform: uppercase; letter-spacing: .03em; text-shadow: 0 1px 3px #000; }
.jl-u { top: -16px; left: 50%; transform: translateX(-50%); } .jl-d { bottom: -16px; left: 50%; transform: translateX(-50%); }
.jl-l { left: -6px; top: 50%; transform: translate(-100%, -50%); } .jl-r { right: -6px; top: 50%; transform: translate(100%, -50%); }
.joy-cap { font-size: 0.62rem; color: var(--text-dim); margin-top: 14px; }
.joy-cap kbd, .user-guide kbd { font-family: var(--mono); font-size: 0.64rem; background: rgba(31,37,53,.85); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; color: var(--text); }
.drive-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; background: rgba(8,11,18,.78); border: 1px solid rgba(139,157,195,.2); border-radius: 12px; padding: 7px 9px; backdrop-filter: blur(4px); margin-bottom: 4px; }
.drive-mid #btn-auto { width: 100%; }
.travel { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.tr-btn { min-width: 36px; padding: 5px 8px; touch-action: none; }
.drive-row { display: contents; }
/* the two travel levers, one each side of the middle box: spring-centred, proportional */
.dm-row { display: flex; align-items: stretch; gap: 8px; }
.dm-core { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.trk { position: relative; width: 28px; min-height: 76px; border-radius: 14px; cursor: grab; touch-action: none; user-select: none; flex: none;
  background: linear-gradient(90deg, rgba(22,27,39,.9), rgba(31,37,53,.9) 50%, rgba(22,27,39,.9)); border: 2px solid rgba(139,157,195,.35); box-shadow: inset 0 4px 10px rgba(0,0,0,.5); }
.trk::before { content: ''; position: absolute; left: 6px; right: 6px; top: 50%; height: 1px; background: rgba(139,157,195,.35); }
.trk.on { border-color: var(--accent); cursor: grabbing; }
.trk:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.trk-knob { position: absolute; left: 2px; right: 2px; top: 50%; height: 22px; margin-top: -11px; border-radius: 8px; z-index: 2; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #5a606a, #16181c 75%); border: 2px solid #0b0c0f; box-shadow: 0 3px 8px rgba(0,0,0,.5); transition: transform .06s linear; }
.trk.on .trk-knob { background: radial-gradient(circle at 35% 30%, #ffe08a, #b98a00 75%); }
.trk-cap { position: absolute; left: 0; right: 0; top: 3px; text-align: center; font-size: 0.58rem; font-weight: 800; color: #c9d2e3; pointer-events: none; text-shadow: 0 1px 2px #000; }
#btn-lock.on { background: #c0392b; border-color: #e74c3c; color: #fff; }
.stage .speed-pick { display: none; }
.stage[data-view="parts"] .hud, .stage[data-view="parts"] .verdict, .stage[data-view="build"] .hud, .stage[data-view="build"] .verdict,
.stage[data-view="parts"] .cv-hint, .stage[data-view="build"] .cv-hint { display: none; }
.ctx-menu { position: absolute; z-index: 20; min-width: 160px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 0; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.ctx-item { display: block; width: 100%; padding: 8px 16px; border: none; background: transparent; color: var(--text); font-size: 0.82rem; text-align: left; cursor: pointer; }
.ctx-item:hover { background: var(--accent-lo); color: var(--accent); }
.cv-hint { position: absolute; left: 50%; transform: translateX(-50%); max-width: calc(100% - 20px); background: rgba(13,17,23,.92); border: 1px solid rgba(244,196,48,.5); border-radius: 10px; padding: 7px 34px 7px 12px; font-size: 0.78rem; color: var(--text); }
.cv-hint .hint-close, .ex-note button { position: absolute; right: 6px; top: 4px; border: 0; background: transparent; color: var(--text-dim); font-size: 0.9rem; cursor: pointer; min-width: 26px; min-height: 26px; border-radius: 6px; }
.ex-note { position: absolute; left: 50%; top: 100px; transform: translateX(-50%); z-index: 8; padding: 8px 34px 8px 12px; border-radius: 10px; background: rgba(13,17,23,.92); border: 1px solid var(--border); font-size: 0.8rem; color: var(--text); max-width: calc(100% - 20px); }

/* fill the screen */
.canvas-card.is-full { position: fixed; inset: 0; z-index: 1000; border-radius: 0; border: 0; overflow-y: auto; }
.canvas-card.is-full .stage { height: 100vh; border-radius: 0; }
.canvas-card.is-full #sim-canvas, .canvas-card.is-full .e3d-view { border-radius: 0; }
body.ex-full { overflow: hidden; }

/* parts and build sit under the stage, in the same card */
.sim-area .parts-panel, .sim-area .build-panel { padding: 10px; }

/* under the stage */
.below-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "task mach live" "chart chart rated"; align-items: start; }
.below-grid .task-group { grid-area: task; } .below-grid .mach-group { grid-area: mach; } .below-grid .live-group { grid-area: live; }
.below-grid .chart-group { grid-area: chart; } .below-grid .rated-group { grid-area: rated; }
.below-grid .res-list { grid-template-columns: 1fr; }
.task-note { font-size: 0.76rem; color: var(--text-dim); line-height: 1.45; }
.task-stats { display: grid; grid-template-columns: 1fr; gap: 2px; }
.task-stats .readout-card { display: flex; align-items: baseline; justify-content: space-between; background: none; border: 0; border-bottom: 1px solid rgba(42,48,80,.7); border-radius: 0; padding: 2px; }
.task-stats .readout-label { text-transform: none; letter-spacing: 0; font-size: 0.72rem; margin: 0; }
.task-stats .readout-val { font-size: 0.8rem; }
.task-done { color: var(--green); font-size: 0.78rem; font-weight: 700; margin-top: 4px; }
.task-tabs .pill { padding: 4px 9px; font-size: 0.76rem; min-height: 28px; }
.ctl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-canvas { aspect-ratio: 1000 / 300; }
@media (max-width: 999px) {
  .below-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "task mach" "chart chart" "live rated"; }
  .stage .verdict { max-width: calc(100% - 300px); }
}
@media (max-width: 640px) {
  .below-grid { grid-template-columns: 1fr; grid-template-areas: "task" "mach" "chart" "live" "rated"; }
}

/* ═══ Phone layout (mobile-ui.js) ═══════════════════════════════
   Scoped to body.ex-m, which mobile-ui.js sets only while the screen is ≤ 720 px — none of this can
   reach desktop. Nothing is position:fixed on the page (a fixed bottom bar stopped the Auto Ads anchor
   ad on utm-testing): the joysticks are part of the stage, in its lower corners, as in a phone game. */
.m-dock, .m-setchip { display: none; }
@media (max-width: 720px) {
  body.ex-m header { padding: 0; }
  body.ex-m header h1 { font-size: 1.15rem; line-height: 1.2; }
  body.ex-m .subtitle { font-size: 0.7rem; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.ex-m .m-banner { padding: 6px; gap: 6px; flex-direction: column; align-items: stretch; }
  body.ex-m .m-banner .ctrl-label { display: none; }
  body.ex-m .m-banner .ctrl-group { display: block; }
  body.ex-m #mode-tabs { display: grid; grid-template-columns: repeat(4, 1fr); }
  body.ex-m #mode-tabs .pill { min-height: 36px; padding: 0 4px; font-size: 0.8rem; font-weight: 700; }
  body.ex-m .m-banner .head-actions { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 6px; margin: 0; width: 100%; }
  body.ex-m .m-banner .head-actions > a, body.ex-m .m-banner .head-actions > button { flex: 1 1 0; min-width: 0; height: 38px; padding: 0 !important; justify-content: center; border-radius: 9px; }
  body.ex-m .m-banner .btn-link .lbl, body.ex-m .m-banner .btn-share-ext { display: none; }
  body.ex-m .m-banner .btn-link img { width: 22px; height: 22px; }
  body.ex-m .m-banner .head-actions > button.btn-link, body.ex-m .m-banner .btn-guide { font-size: 0 !important; display: inline-flex; align-items: center; }
  body.ex-m .m-banner .head-actions > button.btn-link::before { content: '\1F517'; font-size: 17px; }
  body.ex-m .m-banner .btn-guide::before { content: '\1F4D6'; font-size: 17px; }
  body.ex-m .m-setchip { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 6px 12px; margin-top: -6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font: 600 0.76rem/1.2 var(--font); cursor: pointer; text-align: left; }
  body.ex-m .m-chip-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.ex-m .m-chip-ic, body.ex-m .m-chip-car { color: var(--accent); }

  /* the stage: as tall as a phone allows with the controls on it */
  body.ex-m .stage { height: clamp(430px, calc(100svh - 150px), 640px); }
  body.ex-m .stage-top { gap: 4px; top: 6px; left: 6px; right: 6px; }
  body.ex-m .stage-top .vt-pill { padding: 4px 8px; font-size: 0.72rem; min-height: 32px; }
  body.ex-m .stage-top .unit-pick { display: none; }
  body.ex-m .stage-top .cvt-title, body.ex-m .stage-top .cvt-caret { display: none; }
  body.ex-m .stage-top .canvas-toggles > summary { min-width: 34px; min-height: 34px; padding: 0; justify-content: center; }
  body.ex-m .stage-top .canvas-toggles .cvt-body { right: auto; }
  body.ex-m .st-icon { width: 34px; height: 34px; }
  body.ex-m #btn-full { display: none; }
  body.ex-m .stage-top { flex-wrap: nowrap; }
  body.ex-m .stage-top .vt-tabs { flex: none; }
  body.ex-m .stage .hud { top: 46px; left: 6px; right: 6px; transform: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
  body.ex-m .stage .hud .readout-card { min-width: 0; padding: 2px 5px; }
  body.ex-m .stage .hud .readout-label { font-size: 0.5rem; }
  body.ex-m .stage .hud .readout-val { font-size: 0.78rem; }
  body.ex-m .stage .verdict { bottom: 142px; max-width: calc(100% - 16px); font-size: 0.7rem; padding: 4px 8px; }
  body.ex-m .stage .cv-hint { bottom: auto; top: 124px; font-size: 0.7rem; }
  body.ex-m .stage .e3d-bar { top: 128px; right: 6px; }
  body.ex-m .stage .e3d-seg button { padding: 4px 7px; min-height: 32px; font-size: 0.7rem; }
  body.ex-m .stage .drive { padding: 0 4px 6px; gap: 4px; align-items: flex-end; }
  body.ex-m .joy-col { padding: 14px 4px 0; }
  body.ex-m .joy { width: 96px; height: 96px; }
  body.ex-m .joy-knob { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
  body.ex-m .jl { font-size: 0.5rem; } body.ex-m .jl-l, body.ex-m .jl-r, body.ex-m .joy-cap { display: none; }
  body.ex-m .drive-mid { padding: 4px; gap: 4px; flex: 1; min-width: 0; margin-bottom: 0; }
  body.ex-m .drive-mid #btn-auto { font-size: 0.66rem; padding: 6px 4px; min-height: 38px; }
  body.ex-m .travel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; width: 100%; }
  body.ex-m .trk { display: none; }
  body.ex-m .dm-row, body.ex-m .dm-core { width: 100%; min-width: 0; }
  body.ex-m .travel .ctrl-label { display: none; }
  body.ex-m .tr-btn, body.ex-m #btn-hispeed, body.ex-m #btn-reset, body.ex-m #btn-lock { min-width: 0; padding: 3px 2px; min-height: 36px; font-size: 0.78rem; width: 100%; }
  body.ex-m #btn-reset, body.ex-m #btn-lock { font-size: 0.64rem; }
  body.ex-m .below-grid { grid-template-columns: 1fr; grid-template-areas: "task" "mach" "chart" "live" "rated"; }
  body.ex-m .bp-tray { grid-template-columns: 1fr 1fr; }
  body.ex-m .parts-panel { grid-template-columns: 1fr; }
  /* the Setup dock: sticky inside #sim-area, never page-fixed (the Auto Ads anchor must keep working) */
  body.ex-m .m-dock { display: block; position: sticky; bottom: var(--m-anchor, 0px); z-index: 60; padding: 0 0 env(safe-area-inset-bottom); pointer-events: none; }
  body.ex-m .m-dock.m-off { display: none; }
  body.ex-m .m-dock > * { pointer-events: auto; }
  body.ex-m .m-bar { display: flex; gap: 6px; align-items: stretch; margin: 0 0 8px; padding: 6px; background: rgba(18,22,32,0.95); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 -6px 24px rgba(0,0,0,.45); }
  body.ex-m .m-setup { flex: 1; min-height: 46px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface2); color: var(--text); display: flex; align-items: center; justify-content: center; gap: 8px; font-family: inherit; cursor: pointer; }
  body.ex-m .m-setup-ic { font-size: 1.05rem; line-height: 1; color: var(--accent); }
  body.ex-m .m-setup-lbl { font-size: 0.78rem; font-weight: 700; }
  body.ex-m .m-setup[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #0d1117; }
  body.ex-m .m-setup[aria-expanded="true"] .m-setup-ic { color: #0d1117; }
  body.ex-m .m-sheet { display: flex; flex-direction: column; margin: 0 0 6px; overflow: hidden; background: rgba(22,27,38,0.97); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 -8px 30px rgba(0,0,0,.5); }
  body.ex-m .m-sheet[hidden] { display: none; }
  body.ex-m .m-sheet-tabs { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); }
  body.ex-m .m-sheet-tabs button { min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--text-dim); font-family: inherit; font-size: 0.74rem; font-weight: 700; cursor: pointer; }
  body.ex-m .m-sheet-tabs button[aria-selected="true"] { background: var(--surface2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
  body.ex-m .m-pane { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
  body.ex-m .m-pane[hidden] { display: none; }
  body.ex-m .m-pane .ctl-group { padding: 8px; }
  body.ex-m .m-pane .pill { min-height: 36px; }
  body.ex-m .m-pane .unit-pick { display: flex; margin-left: 0; align-self: flex-start; background: none; box-shadow: none; }
  body.ex-m .m-pane .wb-dock { padding: 4px; }
  body.ex-m .m-pane .canvas-toggles { position: static; }
  body.ex-m .m-pane .canvas-toggles > summary { display: none; }
  body.ex-m .m-pane .canvas-toggles .cvt-body { position: static; display: flex; flex-direction: column; box-shadow: none; border: 0; background: none; }
  body.ex-m .m-pane .cvt-item { min-height: 34px; font-size: 0.8rem; }
  body.ex-m .m-pane .cvt-item input { width: 20px; height: 20px; }
  body.ex-m .m-pane .res-list { grid-template-columns: 1fr; }
  body.ex-m .below-grid[hidden] { display: none; }
}
