:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #111827;
  --subtle: #475569;
  --line: #cbd5e1;
  --active: #1f9d8a;
  --active-dark: #137466;
  --warn: #d86f45;
  --gold: #eab308;
  --ok: #28784f;
  --error: #b42318;
  --panel: #f8fafc;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  min-width: 82px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.trainer-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 22px;
}

.workbench {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: calc(100vh - 44px);
  min-height: calc(100vh - 44px);
  height: calc(100dvh - 44px);
  min-height: calc(100dvh - 44px);
  max-width: 1500px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar {
  grid-row: 1;
  display: grid;
  grid-template-columns: minmax(190px, auto) minmax(440px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.debug-state-panel {
  grid-row: 2;
  display: grid;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #0f172a;
  color: #e2e8f0;
}

.debug-state-panel[hidden] {
  display: none;
}

.debug-state-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #bfdbfe;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.debug-state-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 76px;
  overflow-y: auto;
  padding-bottom: 1px;
}

.debug-state-item {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  min-height: 26px;
  padding: 3px 7px;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  white-space: nowrap;
}

.debug-state-name {
  color: #93c5fd;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.debug-state-value {
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
}

.brand-block {
  min-width: 210px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--subtle);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.top-weapon-switch {
  display: grid;
  grid-template-columns: repeat(7, minmax(58px, 1fr));
  overflow: hidden;
  width: 100%;
  max-width: 760px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  justify-self: center;
}

.top-weapon-switch .mode-button {
  min-width: 0;
  height: 42px;
  padding: 0 8px;
  font-size: 13px;
}

.setup-button {
  display: grid;
  min-width: 184px;
  height: 46px;
  padding: 5px 14px;
  text-align: left;
}

.task-library-return {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.setup-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-button span:first-child {
  font-size: 15px;
  line-height: 1.1;
}

.setup-button span:last-child {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.toolbar {
  display: grid;
  gap: 12px;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.procedure-switch .mode-button {
  min-width: 112px;
}

.weapon-switch {
  grid-template-columns: repeat(7, 1fr);
}

.mode-button {
  min-width: 82px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.mode-button.active {
  background: #0f766e;
  color: #ffffff;
}

.hint-lock {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #1f2937;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.hint-lock input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #0f766e;
}

.hint-lock.disabled {
  opacity: 0.45;
}

.setup-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
}

.setup-sheet[hidden] {
  display: none;
}

.setup-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: auto;
  height: auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: default;
}

.setup-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.setup-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.setup-panel-header h2 {
  margin: 0;
}

.setup-panel-header .eyebrow {
  margin-bottom: 2px;
}

.setup-panel-header button {
  min-width: 76px;
}

.browser-recommendation-lightbox {
  position: fixed;
  inset: 0;
  z-index: 48;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.browser-recommendation-lightbox[hidden] {
  display: none;
}

.browser-recommendation-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: auto;
  height: auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.58);
  cursor: default;
}

.browser-recommendation-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  width: min(390px, 100%);
  padding: 20px;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  box-shadow: 0 22px 54px rgba(15, 23, 42, 0.32);
}

.browser-recommendation-panel .eyebrow {
  color: #0f766e;
}

.browser-recommendation-panel h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.05;
}

.browser-recommendation-panel p {
  margin: 0;
  color: #334155;
  font-size: 15px;
  line-height: 1.45;
}

.browser-recommendation-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 58px;
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.browser-recommendation-primary {
  width: 100%;
  margin-top: 2px;
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}

.browser-recommendation-primary:hover {
  border-color: #115e59;
  background: #115e59;
}

.setup-selects {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.setup-selects label {
  display: grid;
  gap: 5px;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.setup-selects select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 850;
}

.setup-selects select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
  border-color: #0f766e;
}

.setup-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.stage-row {
  grid-row: 3;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  min-height: 0;
}

.sequence-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #f8fafc;
}

.step-drawer-toggle {
  display: none;
}

.sequence-drawer-content {
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr;
  min-height: 0;
  height: 100%;
}

.step-counter {
  width: fit-content;
  margin-bottom: 14px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.session-clock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 14px;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.session-clock strong {
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  font-size: 17px;
}

.session-clock.expired {
  border-color: #b91c1c;
  background: #fef2f2;
  color: #991b1b;
}

.session-clock.expired strong { color: #991b1b; }

h2 {
  margin: 0 0 8px;
  font-size: 21px;
  line-height: 1.2;
}

#stepText {
  min-height: 52px;
  margin: 0 0 10px;
  color: #334155;
  font-size: 16px;
  line-height: 1.45;
}

.feedback {
  min-height: 44px;
  margin: 0 0 16px;
  padding: 10px 11px;
  border-left: 4px solid #94a3b8;
  background: #ffffff;
  color: #334155;
  font-size: 14px;
  line-height: 1.35;
}

.feedback.ok {
  border-left-color: var(--ok);
  color: var(--ok);
}

.feedback.error {
  border-left-color: var(--error);
  color: var(--error);
}

.feedback.hint {
  border-left-color: var(--gold);
  color: #7c5a00;
}

.progress-list {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.progress-step {
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 8px;
  align-items: start;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #475569;
  font-size: 13px;
  line-height: 1.25;
}

.progress-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 23px;
  height: 23px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.progress-step.current {
  border-color: #7dd3c7;
  background: #ecfdf9;
  color: #134e4a;
  font-weight: 800;
}

.progress-step.done {
  color: #166534;
}

.progress-step.done .progress-index {
  background: #bbf7d0;
  color: #14532d;
}

.weapon-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #ffffff;
}

.mobile-quick-controls {
  display: none;
}

.weapon-view-switch {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 9;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.78);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.16);
}

.weapon-view-switch[hidden] {
  display: none;
}

.view-button {
  min-width: 72px;
  height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
}

.view-button.active {
  background: #0f766e;
  color: #ffffff;
}

.model-rotation-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: min(430px, calc(100% - 24px));
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.2);
  pointer-events: none;
}

.model-rotation-controls * {
  pointer-events: auto;
}

.model-rotation-controls[hidden] {
  display: none;
}

.model-rotation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  flex-wrap: wrap;
}

.model-rotation-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.model-rotation-actions button {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.model-zoom-control {
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr) 42px;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin-top: 4px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.model-zoom-control input {
  width: 100%;
  accent-color: #0f766e;
}

.model-zoom-control output {
  display: block;
  min-width: 42px;
  padding: 0;
  background: transparent;
  color: #0f172a;
  font-family: inherit;
  font-size: 12px;
  text-align: right;
}

.model-orientation-controls,
.model-camera-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 5px;
}

.model-orientation-control,
.model-camera-control {
  display: grid;
  grid-template-columns: 12px minmax(52px, 1fr) 34px;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: #334155;
  font-size: 11px;
  font-weight: 900;
}

.model-orientation-control input,
.model-camera-control input {
  width: 100%;
  min-width: 0;
  accent-color: #0f766e;
}

.model-orientation-control output,
.model-camera-control output {
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
  text-align: right;
}

.model-rotation-controls > output {
  display: block;
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  overflow-x: auto;
  line-height: 1.35;
  overflow-wrap: anywhere;
  pointer-events: none;
  white-space: normal;
}

.model-rotation-controls.unlocked {
  border-color: rgba(15, 118, 110, 0.72);
  background: rgba(240, 253, 250, 0.94);
}

.trainer-production #modelViewCopyButton,
.trainer-production #modelRotationValue,
.trainer-production .model-orientation-control output,
.trainer-production .model-camera-control output {
  display: none;
}

.trainer-production .model-orientation-control,
.trainer-production .model-camera-control {
  grid-template-columns: 12px minmax(52px, 1fr);
}

.trainer-production .model-rotation-controls {
  width: min(390px, calc(100% - 24px));
}

.m2-model-debug-picker {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 14;
  display: grid;
  gap: 6px;
  width: min(360px, calc(100% - 24px));
  padding: 10px;
  border: 1px solid rgba(20, 184, 166, 0.8);
  border-radius: 8px;
  background: rgba(240, 253, 250, 0.96);
  color: #0f172a;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.22);
}

.m2-model-debug-picker strong {
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.m2-model-debug-picker span {
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.m2-model-debug-output {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  padding: 8px;
  border: 1px solid #99f6e4;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
}

body:not(.debug-enabled) .m2-model-debug-picker {
  display: none !important;
}

.weapon-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 560px;
  padding: 16px;
  user-select: none;
  touch-action: none;
}

.weapon-stage.model-stage {
  align-items: stretch;
  padding: 16px;
  touch-action: auto;
}

.loading {
  color: var(--subtle);
  font-weight: 800;
}

.weapon-stage svg {
  display: block;
  width: min(100%, 1120px);
  height: auto;
  max-height: calc(100vh - 190px);
  max-height: calc(100dvh - 190px);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.m2-model-viewer {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  width: min(100%, 1120px);
  max-height: calc(100vh - 190px);
  max-height: calc(100dvh - 190px);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
}

.m2-model-frame {
  position: relative;
  min-height: 430px;
  background: #ffffff;
  isolation: isolate;
}

.m2-model-frame::before,
.m2-model-frame::after {
  display: none;
}

.m2-model-viewer.rotation-unlocked .m2-model-frame {
  cursor: grab;
}

.m2-model-viewer.rotation-unlocked .m2-model-frame.rotating {
  cursor: grabbing;
}

.m2-model-hit-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.m2-model-proxy-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.three-model-viewer .m2-model-hit-layer {
  z-index: 4;
}

.three-model-viewer .m2-model-proxy-layer {
  z-index: 3;
}

.m2-model-muzzle-flash {
  position: absolute;
  z-index: 3;
  width: 0;
  height: 0;
  pointer-events: none;
}

.m2-model-safety-status {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  display: grid;
  place-items: center;
  min-width: 64px;
  padding: 8px 10px;
  border: 1px solid rgba(226, 232, 240, 0.42);
  border-radius: 6px;
  background: rgba(31, 41, 55, 0.9);
  box-shadow:
    0 8px 18px rgba(15, 23, 42, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
}

.m2-model-safety-status[hidden] {
  display: none;
}

.m2-model-safety-value {
  color: #ffffff;
  font-size: 12px;
  font-weight: 950;
  text-align: center;
}

.m2-model-safety-status[data-safety-state="fire"],
.m2-model-safety-status[data-safety-state="semi"],
.m2-model-safety-status[data-safety-state="auto"] {
  border-color: rgba(248, 113, 113, 0.72);
}

.m2-model-safety-status[data-safety-state="fire"] .m2-model-safety-value,
.m2-model-safety-status[data-safety-state="semi"] .m2-model-safety-value,
.m2-model-safety-status[data-safety-state="auto"] .m2-model-safety-value {
  color: #f87171;
}

.m2-model-muzzle-flash::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 92px;
  height: 58px;
  opacity: 0;
  transform: translateY(-50%) rotate(var(--muzzle-flash-angle, 0rad)) scale(0.7);
  transform-origin: 0 50%;
  clip-path: polygon(0 40%, 9% 28%, 22% 18%, 42% 30%, 100% 50%, 42% 70%, 22% 82%, 9% 72%, 0 60%);
  background:
    radial-gradient(ellipse at 3% 50%, #ffffff 0 13%, rgba(253, 230, 138, 0.92) 18%, transparent 32%),
    radial-gradient(circle at 26% 50%, #ffffff 0 13%, transparent 31%),
    radial-gradient(circle at 47% 50%, #fde68a 0 24%, transparent 54%),
    radial-gradient(circle at 68% 50%, #f97316 0 20%, transparent 62%);
  content: "";
  filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.82));
}

.m2-model-viewer.rotation-unlocked .m2-model-hit,
.m2-model-viewer.rotation-unlocked .m2-model-proxy-control {
  pointer-events: none;
}

.m2-model-muzzle-flash.visible::before {
  animation: m2MuzzleFlash 150ms ease-out;
}

.m2-model-hit {
  position: absolute;
  min-width: 0;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.001);
  box-shadow: none;
  pointer-events: auto;
}

.m2-model-proxy-control {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.48);
  border-radius: 999px;
  background:
    radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.18), transparent 0 34%),
    var(--proxy-color, #8a9698);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.12),
    0 1px 2px rgba(15, 23, 42, 0.24);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  pointer-events: auto;
}

.m2-model-proxy-control.proxy-state-safe {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.9);
}

.m2-model-proxy-control.proxy-state-fire {
  color: #ef4444;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.9);
}

.m2-model-proxy-control.proxy-hidden-visual {
  border: 0;
  background: rgba(20, 184, 166, 0.001);
  box-shadow: none;
  color: transparent;
  text-shadow: none;
}

.m2-model-proxy-control:hover,
.m2-model-proxy-control:focus-visible,
.m2-model-proxy-control.current-target {
  outline: 2px solid rgba(20, 184, 166, 0.72);
  outline-offset: 2px;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.18),
    0 0 0 4px rgba(20, 184, 166, 0.18),
    0 1px 2px rgba(15, 23, 42, 0.24);
}

.m2-model-hit:hover,
.m2-model-hit:focus-visible,
.m2-model-hit.current-target {
  outline: 2px solid rgba(20, 184, 166, 0.72);
  outline-offset: 2px;
  background: rgba(20, 184, 166, 0.1);
}

.m2-model-viewer.visual-hotspots-off .m2-model-hit,
.m2-model-viewer.visual-hotspots-off .m2-model-hit:hover,
.m2-model-viewer.visual-hotspots-off .m2-model-hit:focus-visible,
.m2-model-viewer.visual-hotspots-off .m2-model-hit.current-target {
  outline: 0;
  background: rgba(20, 184, 166, 0.001);
  box-shadow: none;
}

.m2-model-viewer.visual-hotspots-off .m2-model-hit.current-target {
  outline: 2px solid rgba(249, 115, 22, 0.95);
  outline-offset: 2px;
  border-radius: 6px !important;
  clip-path: none !important;
  background: rgba(249, 115, 22, 0.14);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.18);
}

.m2-model-viewer.visual-hotspots-off .m2-model-proxy-control.proxy-hidden-visual,
.m2-model-viewer.visual-hotspots-off .m2-model-proxy-control.proxy-hidden-visual:hover,
.m2-model-viewer.visual-hotspots-off .m2-model-proxy-control.proxy-hidden-visual:focus-visible,
.m2-model-viewer.visual-hotspots-off .m2-model-proxy-control.proxy-hidden-visual.current-target {
  outline: 0;
  box-shadow: none;
}

.m2-model-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 430px;
}

.m2-model-loading {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #111827;
  font-weight: 900;
  text-align: center;
}

.m2-model-loading[hidden] {
  display: none;
}

@keyframes modelLoadingSpin {
  to { transform: rotate(360deg); }
}

.model-download-status {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  background: #fff;
  color: #142238;
  text-align: center;
}

.model-download-status strong { font-size: 16px; }
.model-download-status small { color: #5a6678; font-size: 12px; font-weight: 750; }
.model-download-spinner {
  width: 30px;
  height: 30px;
  margin-bottom: 5px;
  border: 3px solid #d8e1e8;
  border-top-color: #1f9d8a;
  border-radius: 50%;
  animation: modelLoadingSpin 0.85s linear infinite;
}

@keyframes m2MuzzleFlash {
  0% {
    opacity: 0;
    transform: translateY(-50%) rotate(var(--muzzle-flash-angle, 0rad)) scale(0.45);
  }

  35% {
    opacity: 1;
    transform: translateY(-50%) rotate(var(--muzzle-flash-angle, 0rad)) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) rotate(var(--muzzle-flash-angle, 0rad)) scale(1.2);
  }
}

.weapon-stage svg #labels,
.weapon-stage svg #legend {
  display: none;
}

.weapon-stage svg .hit {
  fill: rgba(0, 0, 0, 0.001);
  opacity: 1;
  stroke: transparent;
  cursor: pointer;
  touch-action: none;
}

.weapon-stage svg .hit.current-target {
  opacity: 1;
  stroke: transparent;
}

.weapon-stage svg .active-part {
  filter: drop-shadow(0 0 9px rgba(216, 111, 69, 0.85));
}

.weapon-stage svg .inspected {
  filter: drop-shadow(0 0 7px rgba(40, 120, 79, 0.72));
}

.weapon-stage svg .training-part.active-part .photo-outline {
  fill: rgba(216, 111, 69, 0.22);
  stroke: rgba(216, 111, 69, 0.92);
}

.weapon-stage svg .training-part.active-part .photo-detail {
  stroke: rgba(216, 111, 69, 0.95);
}

.weapon-stage svg .training-part.inspected .photo-outline {
  fill: rgba(40, 120, 79, 0.2);
  stroke: rgba(40, 120, 79, 0.82);
}

.weapon-stage svg .training-part.inspected .photo-detail {
  stroke: rgba(40, 120, 79, 0.9);
}

.weapon-stage svg .training-part.tap-confirm {
  animation: confirmPulse 520ms ease-out;
  filter: drop-shadow(0 0 12px rgba(31, 157, 138, 0.9));
}

.weapon-stage svg .training-part.tap-confirm .photo-outline {
  fill: rgba(31, 157, 138, 0.3);
  stroke: rgba(20, 184, 166, 0.98);
}

.weapon-stage svg .training-part.tap-confirm .photo-detail {
  stroke: rgba(20, 184, 166, 0.98);
}

.weapon-stage svg .training-part.tap-confirm .open-cover-body {
  fill: rgba(31, 157, 138, 0.32);
  stroke: rgba(20, 184, 166, 0.98);
}

.weapon-stage svg .training-part.tap-confirm .open-cover-detail {
  stroke: rgba(94, 234, 212, 0.98);
}

.weapon-stage svg .wrong-target {
  animation: shake 160ms linear 2;
}

.fullscreen-button {
  display: none;
}

.fullscreen-button[hidden] {
  display: none !important;
}

.event-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 4;
  justify-self: center;
  width: min(420px, calc(100% - 48px));
  min-height: 64px;
  margin: 22px auto 0;
  padding: 0 24px;
  border: 3px solid #0f766e;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  pointer-events: none;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.34);
}

.event-notice.danger {
  border-color: #b91c1c;
  background: rgba(254, 226, 226, 0.97);
  color: #7f1d1d;
}

.event-notice.empty {
  border-color: #c2410c;
  background: rgba(255, 237, 213, 0.97);
  color: #7c2d12;
}

.event-notice[hidden] {
  display: flex;
  visibility: hidden;
  opacity: 0;
  box-shadow: none;
}

.target-hold-modal {
  position: absolute;
  z-index: 7;
  top: 14px;
  right: 18px;
  width: min(190px, calc(100% - 36px));
  pointer-events: none;
}

.target-hold-modal[hidden] {
  display: none;
}

.target-hold-panel {
  padding: 7px 9px 8px;
  border: 1px solid #0f766e;
  border-radius: 8px;
  background: rgba(240, 253, 250, 0.97);
  color: #0f172a;
  text-align: center;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.22);
}

.target-hold-label,
.target-hold-status {
  margin: 0;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.target-hold-countdown {
  margin-top: 3px;
  font-size: 24px;
  font-weight: 950;
  line-height: 1;
}

.target-hold-track {
  height: 5px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #ccfbf1;
}

.target-hold-progress {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #0f766e;
}

.target-hold-status {
  margin-top: 6px;
  color: #115e59;
}

.maintenance-action {
  position: absolute;
  z-index: 6;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  padding: 10px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: rgba(255, 247, 237, 0.96);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.22);
}

.maintenance-action[hidden] {
  display: none;
}

.maintenance-action button {
  min-width: 154px;
  height: 54px;
  border-color: #d86f45;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 17px;
  font-weight: 900;
}

.maintenance-action button:hover {
  border-color: #c2410c;
  background: #ffedd5;
}

.component-identification {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 8px;
  max-width: min(520px, calc(100vw - 64px));
  max-height: min(58vh, 430px);
  overflow: auto;
}

.component-identification[hidden] {
  display: none;
}

.component-identification button {
  height: auto;
  min-height: 52px;
  padding: 8px 12px;
  line-height: 1.2;
}

.component-prompt {
  grid-column: 1 / -1;
  margin: 0;
  color: #431407;
  font-weight: 800;
  line-height: 1.35;
}


@keyframes confirmPulse {
  0% {
    opacity: 0.35;
  }

  35% {
    opacity: 1;
  }

  100% {
    opacity: 0.95;
  }
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }

  35% {
    transform: translateX(-5px);
  }

  70% {
    transform: translateX(5px);
  }

  100% {
    transform: translateX(0);
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(190px, 1fr) auto;
  }

  .brand-block {
    grid-column: 1;
    grid-row: 1;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .top-weapon-switch {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
  }
}

@media (max-width: 900px) {
  .trainer-shell {
    min-height: 100svh;
    min-height: 100dvh;
    padding: 0;
  }

  .workbench {
    width: 100%;
    min-height: 100svh;
    height: 100svh;
    min-height: 100dvh;
    height: 100dvh;
    grid-template-rows: 1fr;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar {
    display: none;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 10px 12px;
  }

  .eyebrow {
    margin-bottom: 1px;
    font-size: 11px;
  }

  h1 {
    font-size: 19px;
  }

  .toolbar {
    display: grid;
    width: 100%;
    gap: 7px;
  }

  .mode-switch {
    grid-column: 1 / -1;
    width: 100%;
  }

  .procedure-switch {
    grid-column: 1 / -1;
  }

  .mode-button,
  .toolbar > button,
  .hint-lock {
    width: 100%;
    min-width: 0;
    height: 42px;
  }

  .hint-lock {
    justify-content: center;
    padding: 0 8px;
    font-size: 13px;
  }

  .stage-row {
    grid-row: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .sequence-panel {
    order: 2;
    flex: 0 0 auto;
    grid-template-rows: auto minmax(0, 1fr);
    max-height: none;
    overflow: hidden;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid rgba(203, 213, 225, 0.86);
    background: rgba(248, 250, 252, 0.98);
    box-shadow: 0 -14px 30px rgba(15, 23, 42, 0.18);
  }

  .step-drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    width: min(190px, 52%);
    min-width: 112px;
    height: 28px;
    margin: 0 0 6px;
    border: 0;
    background: transparent;
    color: #334155;
    font-size: 12px;
    font-weight: 900;
  }

  .step-drawer-toggle::before {
    display: block;
    width: 42px;
    height: 5px;
    margin-right: 8px;
    border-radius: 999px;
    background: #94a3b8;
    content: "";
  }

  .sequence-drawer-content {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: 4px 8px;
    min-height: 0;
    overflow: hidden;
  }

  .step-counter {
    grid-row: 1 / 3;
    margin-bottom: 6px;
    padding: 4px 7px;
    border-radius: 999px;
    font-size: 12px;
  }

  h2 {
    grid-column: 2;
    margin-bottom: 5px;
    font-size: 18px;
  }

  #stepText {
    grid-column: 2;
    min-height: 0;
    margin-bottom: 7px;
    font-size: 14px;
    line-height: 1.3;
  }

  .feedback {
    grid-column: 1 / -1;
    min-height: 0;
    margin-bottom: 8px;
    padding: 8px 9px;
    border-radius: 0 7px 7px 0;
    font-size: 13px;
    line-height: 1.25;
  }

  .progress-list {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 0 0 3px;
  }

  .progress-step {
    grid-template-columns: 1fr;
    justify-items: center;
    flex: 0 0 42px;
    min-height: 34px;
    padding: 4px;
  }

  .progress-step > span:not(.progress-index) {
    display: none;
  }

  .progress-index {
    width: 27px;
    height: 27px;
  }

  .weapon-panel {
    order: 1;
    flex: 1 1 0;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    padding-top: 0;
    background: #ffffff;
  }

  .event-notice {
    position: absolute;
    top: calc(48px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    width: min(360px, calc(100% - 20px));
    min-height: 48px;
    margin: 0;
    padding: 0 16px;
    font-size: 22px;
  }

  .event-notice[hidden] {
    display: none;
  }

  .model-rotation-controls {
    top: calc(48px + env(safe-area-inset-top));
    right: calc(6px + env(safe-area-inset-right));
    bottom: auto;
    left: auto;
    width: auto;
    max-width: min(292px, calc(100% - 12px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    padding: 4px;
    border-radius: 7px;
  }

  .model-rotation-header {
    gap: 4px;
    margin-bottom: 0;
  }

  .model-rotation-header > span,
  .model-rotation-controls > output {
    display: none;
  }

  .model-rotation-controls.unlocked {
    width: min(292px, calc(100% - 12px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }

  .model-rotation-controls.unlocked > output {
    display: none;
    margin-top: 4px;
    padding: 5px 7px;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.2;
    white-space: normal;
  }

  .model-rotation-actions {
    gap: 4px;
  }

  .model-rotation-actions button {
    height: 30px;
    min-width: 54px;
    padding: 0 8px;
    font-size: 12px;
  }

  .model-zoom-control {
    grid-template-columns: 34px minmax(86px, 1fr) 38px;
    gap: 6px;
    margin-top: 3px;
    font-size: 11px;
  }

  .model-zoom-control output {
    min-width: 38px;
    font-size: 11px;
  }

  .model-orientation-controls,
  .model-camera-controls {
    gap: 4px;
    margin-top: 3px;
  }

  .model-orientation-control,
  .model-camera-control {
    grid-template-columns: 10px minmax(30px, 1fr);
    gap: 3px;
    font-size: 11px;
  }

  .model-orientation-control output,
  .model-camera-control output {
    display: none;
  }

  #modelRotationToggleButton {
    min-width: 88px;
  }

  .target-hold-modal {
    top: calc(96px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
    width: min(190px, calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }

  .target-hold-panel {
    padding: 7px 9px 8px;
  }

  .target-hold-countdown {
    font-size: 24px;
  }

  .maintenance-action {
    top: 44%;
    right: 10px;
    padding: 7px;
  }

  .maintenance-action button {
    min-width: 128px;
    height: 46px;
    font-size: 15px;
  }

  .weapon-stage {
    justify-content: flex-start;
    min-height: 0;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 6px;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .weapon-stage.model-stage {
    justify-content: center;
    overflow: hidden;
    padding: 4px;
    touch-action: none;
  }

  .weapon-stage svg {
    flex: 0 0 auto;
    width: auto;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 6px;
  }

  .m2-model-viewer {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 6px;
  }

  .m2-model-frame {
    min-height: 0;
  }

  .m2-model-canvas {
    min-height: 0;
  }

  .setup-sheet {
    align-items: end;
    justify-items: center;
    padding: 0;
  }

  .setup-panel {
    width: 100%;
    max-height: calc(88svh - env(safe-area-inset-top));
    max-height: calc(88dvh - env(safe-area-inset-top));
    overflow: auto;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
    border-radius: 12px 12px 0 0;
  }

  .setup-selects {
    display: grid;
  }

  .setup-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .setup-toolbar .mode-switch {
    display: none;
  }

  .mobile-quick-controls {
    position: absolute;
    top: calc(6px + env(safe-area-inset-top));
    left: calc(6px + env(safe-area-inset-left));
    z-index: 20;
    display: grid;
    grid-template-columns: 52px minmax(106px, 1fr) 42px 46px 48px;
    gap: 6px;
    max-width: calc(100% - 70px - env(safe-area-inset-left) - env(safe-area-inset-right));
    overflow-x: auto;
    padding: 4px;
    border: 1px solid rgba(148, 163, 184, 0.36);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.72);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(12px);
    -webkit-overflow-scrolling: touch;
  }

  .mobile-quick-controls button,
  .mobile-task-return {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    height: 36px;
    border: 1px solid rgba(203, 213, 225, 0.32);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    color: #111827;
    font: inherit;
    font-size: 12px;
    font-weight: 850;
    box-shadow: none;
  }

  .mobile-task-return {
    background: #ccfbf1;
    color: #115e59;
    text-decoration: none;
  }

  .mobile-action-button {
    min-width: 0;
    align-self: end;
    background: #ccfbf1;
    color: #115e59;
  }

  .mobile-session-button {
    display: grid;
    align-content: center;
    gap: 1px;
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.95) !important;
    color: #111827 !important;
    text-align: left;
  }

  .mobile-session-button span:first-child {
    overflow: hidden;
    font-size: 13px;
    font-weight: 950;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-session-button span:last-child {
    overflow: hidden;
    color: #475569;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fullscreen-button {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    right: calc(6px + env(safe-area-inset-right));
    z-index: 20;
    display: block;
    min-width: 56px;
    height: 34px;
    border-color: rgba(203, 213, 225, 0.38);
    background: rgba(15, 23, 42, 0.76);
    color: #ffffff;
    font-size: 12px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(12px);
  }

}

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

@media (max-width: 480px) {
  .topbar .toolbar {
    grid-template-columns: 1fr 78px 78px;
  }

  .setup-toolbar {
    grid-template-columns: 1fr;
  }

  .hint-lock span {
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
  }

}

@media (max-width: 900px) and (orientation: portrait) {
  body {
    overflow: hidden;
  }

  .workbench {
    pointer-events: auto;
  }

  .stage-row {
    position: relative;
  }

  .sequence-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 18;
    max-height: min(64svh, 520px);
    max-height: min(64dvh, 520px);
    border-radius: 14px 14px 0 0;
  }

  .sequence-panel:not(.drawer-open) {
    max-height: calc(130px + env(safe-area-inset-bottom));
  }

  .sequence-panel.drawer-open {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sequence-panel.drawer-open .step-drawer-toggle::before {
    background: #0f766e;
  }

  .sequence-panel.drawer-open .sequence-drawer-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto 1fr;
    overflow: visible;
  }

  .sequence-panel.drawer-open .step-counter,
  .sequence-panel.drawer-open h2,
  .sequence-panel.drawer-open #stepText,
  .sequence-panel.drawer-open .feedback,
  .sequence-panel.drawer-open .progress-list {
    grid-column: 1;
  }

  .sequence-panel.drawer-open .step-counter {
    grid-row: auto;
  }

  .sequence-panel:not(.drawer-open) #stepText {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .sequence-panel:not(.drawer-open) .feedback,
  .sequence-panel:not(.drawer-open) .progress-list {
    display: none;
  }

  .weapon-panel {
    flex-basis: 100%;
  }

  .mobile-quick-controls {
    right: calc(70px + env(safe-area-inset-right));
    max-width: none;
  }

  .mobile-quick-controls button {
    min-width: 0;
    padding: 0 6px;
  }

}

@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) {
  .workbench {
    grid-template-rows: 1fr;
  }

  .weapon-panel {
    padding-top: 0;
  }

  .topbar {
    display: none;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 4px 8px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    width: max-content;
    font-size: 15px;
  }

  .toolbar {
    gap: 6px;
  }

  .mode-switch {
    grid-column: auto;
  }

  .mode-button,
  .toolbar > button,
  .hint-lock {
    height: 32px;
    font-size: 13px;
  }

  .stage-row {
    height: 100svh;
    height: 100dvh;
  }

  .weapon-stage {
    align-items: center;
    padding: 4px 6px;
  }

  .event-notice {
    width: min(340px, calc(100% - 18px));
    min-height: 38px;
    margin-top: 4px;
    padding: 0 14px;
    font-size: 18px;
  }

  .weapon-stage svg {
    width: 100%;
    height: auto;
  }

  .sequence-panel {
    flex: 0 0 64px;
    grid-template-columns: 96px minmax(160px, 1fr) minmax(220px, 1.35fr);
    grid-template-rows: 1fr;
    gap: 4px 8px;
    height: 64px;
    max-height: none;
    overflow: hidden;
    padding: 4px 7px;
  }

  .step-drawer-toggle {
    display: none;
  }

  .sequence-drawer-content {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: 96px minmax(160px, 1fr) minmax(220px, 1.35fr);
    grid-template-rows: auto 1fr;
    gap: 4px 8px;
    min-width: 0;
  }

  .fullscreen-button {
    min-width: 78px;
    height: 30px;
    font-size: 12px;
  }

  .mobile-quick-controls {
    top: calc(5px + env(safe-area-inset-top));
    left: calc(5px + env(safe-area-inset-left));
    grid-template-columns: 52px minmax(106px, 1fr) 42px 46px 48px;
    gap: 4px;
    padding: 3px;
    max-width: calc(100% - 86px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  .mobile-quick-controls button,
  .mobile-task-return {
    min-width: 0;
    height: 28px;
    font-size: 12px;
  }

  .weapon-view-switch {
    top: 44px;
    right: 7px;
  }

  .model-rotation-controls {
    top: calc(40px + env(safe-area-inset-top));
    right: calc(6px + env(safe-area-inset-right));
    bottom: auto;
    left: auto;
  }

  .view-button {
    min-width: 58px;
    height: 30px;
    font-size: 12px;
  }

  .step-counter,
  #stepText,
  .feedback {
    margin-bottom: 0;
  }

  .step-counter {
    grid-row: 1 / 3;
    padding: 4px 6px;
    align-self: center;
    width: auto;
    white-space: nowrap;
  }

  h2 {
    grid-column: 2;
    font-size: 14px;
  }

  #stepText {
    grid-column: 2;
    overflow: hidden;
    font-size: 10.5px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }

  .feedback {
    grid-column: 3;
    grid-row: 1;
    height: 24px;
    min-height: 0;
    padding: 5px 8px;
    overflow: hidden;
    font-size: 10.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .progress-list {
    grid-column: 3;
    grid-row: 2;
    align-self: end;
    min-height: 0;
  }

  .progress-step {
    flex-basis: 30px;
    min-height: 25px;
    padding: 2px;
  }

  .progress-index {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }
}

.trainer-debug .model-rotation-header > span {
  display: inline;
}

.trainer-debug .model-rotation-controls > output:not([hidden]) {
  display: block;
}

.trainer-debug .model-orientation-control,
.trainer-debug .model-camera-control {
  grid-template-columns: 12px minmax(52px, 1fr) 34px;
}

.trainer-debug .model-orientation-control output:not([hidden]),
.trainer-debug .model-camera-control output:not([hidden]) {
  display: block;
}

@media (max-width: 900px) {
  .trainer-debug .model-orientation-control,
  .trainer-debug .model-camera-control {
    grid-template-columns: 10px minmax(30px, 1fr) 32px;
  }
}

/* Shared E3B field identity ------------------------------------------------ */
body {
  background:
    radial-gradient(circle at 8% 0%, rgba(31, 157, 138, 0.09), transparent 28rem),
    #edf1f5;
}

.workbench {
  border-color: #cbd4df;
  border-radius: 16px;
}

.topbar {
  position: relative;
  isolation: isolate;
  min-height: 92px;
  padding: 16px 22px;
  border-bottom-color: rgba(255, 255, 255, 0.12);
  background: #142238;
  color: #f8fafc;
}

.topbar::after {
  position: absolute;
  z-index: -1;
  inset: 0 0 0 auto;
  width: min(52%, 720px);
  background: url("./assets/terrain-contours.svg") right center / cover no-repeat;
  content: "";
  pointer-events: none;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-copy { min-width: 0; }
.field-mark { flex: 0 0 48px; filter: drop-shadow(0 5px 12px rgba(0, 0, 0, 0.22)); }
.topbar .eyebrow { margin: 0; color: #a9bacd; font-size: 10px; letter-spacing: 0.11em; }
.topbar h1 { margin-top: 4px; color: #fff; }

.trainer-discipline {
  padding: 3px 6px;
  border: 1px solid rgba(167, 226, 215, 0.32);
  border-radius: 999px;
  background: rgba(31, 157, 138, 0.2);
  color: #c9f3eb;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-weapon-switch {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.top-weapon-switch .mode-button { color: #d9e2ec; }
.top-weapon-switch .mode-button:hover { border-color: transparent; background: rgba(255, 255, 255, 0.12); }
.top-weapon-switch .mode-button.active { background: #1f9d8a; color: #fff; }

.topbar .setup-button,
.topbar #hintButton,
.topbar #undoButton,
.topbar #resetButton,
.topbar .task-library-return {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.topbar .setup-button { background: #f8fafc; color: #142238; }
.topbar .setup-button span:last-child { color: #526075; }
.topbar .task-library-return { background: #f8fafc; color: #142238; }
.topbar #undoButton:disabled { color: #b9c5d3; }
.sequence-panel { background: #f8fafc; }

.weapon-panel {
  background:
    linear-gradient(rgba(20, 34, 56, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 34, 56, 0.025) 1px, transparent 1px),
    #fff;
  background-size: 36px 36px;
}

@media (max-width: 760px) {
  .field-mark { width: 39px; height: 39px; flex-basis: 39px; }
  .trainer-discipline { display: none; }
}

/* Task-trainer parity ------------------------------------------------------ */
.topbar {
  grid-template-columns: 1fr auto;
}

.topbar h1 { margin: 0; font-size: clamp(24px, 2.2vw, 30px); }
.topbar .task-library-return { min-width: 108px; min-height: 44px; }

.stage-row { grid-template-columns: 290px minmax(0, 1fr); }

.sequence-panel {
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 13px;
  padding: 20px 16px;
}

.weapon-library-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.weapon-library-heading h2 { margin: 3px 0 0; font-size: 22px; }
.weapon-count {
  padding: 5px 8px;
  border-radius: 999px;
  background: #e8edf3;
  color: #435066;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.sequence-panel .top-weapon-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  overflow: visible;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.sequence-panel .top-weapon-switch .mode-button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: auto;
  min-height: 48px;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #101827;
  text-align: left;
}

.sequence-panel .top-weapon-switch .mode-button:hover { border-color: #b7cbc7; background: #fff; }
.sequence-panel .top-weapon-switch .mode-button.active { border-color: #a8d8cf; background: #fff; color: #101827; box-shadow: 0 5px 14px rgba(15, 23, 42, 0.06); }
.sequence-panel .top-weapon-switch .mode-button strong { font-size: 11px; line-height: 1.15; }
.weapon-code {
  display: grid;
  place-items: center;
  min-height: 32px;
  padding: 0 4px;
  border-radius: 7px;
  background: #e9eef4;
  color: #334155;
  font-size: 10px;
  font-weight: 900;
}
.sequence-panel .top-weapon-switch .mode-button.active .weapon-code { background: #1f9d8a; color: #fff; }

.sequence-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 13px;
  border-top: 1px solid #d7dee8;
}
.sequence-heading span { color: #78869a; font-size: 10px; font-weight: 850; text-transform: uppercase; }

.weapon-panel { grid-template-rows: auto minmax(0, 1fr); }

.weapon-studio-header {
  z-index: 12;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  min-height: 132px;
  padding: 20px 22px 16px 39px;
  border-bottom: 1px solid #d7dee8;
  background: rgba(255, 255, 255, 0.94);
}

.weapon-title-block { position: relative; min-width: 260px; }
.weapon-title-block::before {
  position: absolute;
  inset: 0 auto 0 -17px;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(#1f9d8a 0 64%, #f6c85f 64% 78%, #142238 78%);
  content: "";
}
.weapon-meta-line { display: flex; align-items: center; gap: 9px; color: #5a6678; font-size: 12px; font-weight: 750; }
.weapon-station-chip { padding: 5px 8px; border-radius: 999px; background: #142238; color: #fff; font-size: 11px; font-weight: 850; }
.weapon-title-block h2 { margin: 7px 0 4px; font-size: clamp(25px, 2.5vw, 36px); letter-spacing: -0.035em; }
.weapon-title-block p { margin: 0; color: #5a6678; font-size: 13px; }

.weapon-session-controls { display: grid; justify-items: end; gap: 8px; min-width: 390px; }
.weapon-learning-switch {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  min-width: 286px;
  border: 1px solid #d7dee8;
  border-radius: 9px;
  background: #f5f7fa;
}
.weapon-learning-switch button {
  display: grid;
  place-items: center;
  gap: 1px;
  min-width: 94px;
  min-height: 48px;
  height: auto;
  border: 0;
  border-right: 1px solid #d7dee8;
  border-radius: 0;
  background: transparent;
  color: #526076;
  font-weight: 850;
}
.weapon-learning-switch button:last-child { border-right: 0; }
.weapon-learning-switch button small { font-size: 8px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; opacity: .72; }
.weapon-learning-switch button.active { background: #1f9d8a; color: #fff; }
.weapon-action-row { display: flex; align-items: center; gap: 6px; }
.weapon-action-row .setup-button { min-width: 166px; height: 42px; }
.weapon-action-row > button:not(.setup-button) { min-width: 62px; height: 42px; }

.weapon-panel .model-rotation-controls { top: 144px; }
.weapon-panel .weapon-view-switch { top: 144px; }

@media (max-width: 1120px) and (min-width: 901px) {
  .stage-row { grid-template-columns: 255px minmax(0, 1fr); }
  .weapon-studio-header { padding-inline: 30px 14px; }
  .weapon-title-block p { display: none; }
  .weapon-session-controls { min-width: 300px; }
  .weapon-action-row #hintButton,
  .weapon-action-row #undoButton { display: none; }
}

@media (max-width: 900px) {
  .workbench { grid-template-rows: 62px minmax(0, 1fr); }
  .topbar {
    grid-row: 1;
    display: flex;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    min-height: 62px;
    padding: 10px 12px;
  }
  .topbar .field-mark { width: 39px; height: 39px; flex-basis: 39px; }
  .topbar h1 { display: block; font-size: 22px; }
  .topbar .task-library-return { min-width: 104px; min-height: 40px; }
  .stage-row { grid-row: 2; }
  .weapon-library-heading,
  .sequence-panel > .top-weapon-switch,
  .sequence-heading,
  .weapon-studio-header { display: none; }
  .sequence-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 0; padding: 14px; }
  .weapon-panel { grid-template-rows: auto minmax(0, 1fr); }
  .weapon-panel .model-rotation-controls { top: calc(52px + env(safe-area-inset-top)); }
  .weapon-panel .weapon-view-switch { top: calc(52px + env(safe-area-inset-top)); }
  .fullscreen-button { top: calc(72px + env(safe-area-inset-top)); }
  .mobile-task-return { display: none; }
  .mobile-quick-controls { grid-template-columns: minmax(112px, 1fr) 46px 48px 50px; }
}

/* Mobile trainer finish --------------------------------------------------- */
@media (max-width: 900px) {
  /* Keep the weapon canvas in the flexible row. The earlier auto row made a
     loaded 3D model look missing because it was squeezed to about 200px. */
  .weapon-panel { grid-template-rows: minmax(0, 1fr); }
  .weapon-stage,
  .weapon-stage.model-stage { min-height: 0; height: 100%; }
  .m2-model-viewer,
  .m2-model-frame,
  .m2-model-canvas { min-height: 0; height: 100%; }

  .mobile-quick-controls {
    top: calc(7px + env(safe-area-inset-top));
    right: calc(68px + env(safe-area-inset-right));
    left: calc(7px + env(safe-area-inset-left));
    grid-template-columns: minmax(132px, 1fr) 48px 50px 52px;
    gap: 5px;
    padding: 5px;
    overflow: visible;
    border-radius: 11px;
    background: rgba(20, 34, 56, .9);
  }
  .mobile-quick-controls button,
  .mobile-task-return { min-height: 44px; height: 44px; border-radius: 8px; }
  .mobile-quick-controls .mobile-session-button {
    display: grid;
    grid-template-columns: 1fr;
    align-content: center;
    justify-items: start;
    gap: 2px;
    padding-inline: 9px;
    text-align: left;
  }
  .mobile-session-button span:first-child { font-size: 12px; }
  .mobile-action-button { font-size: 11px; }

  .weapon-panel .model-rotation-controls {
    top: calc(68px + env(safe-area-inset-top));
    max-width: min(316px, calc(100% - 14px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    padding: 6px;
    border-radius: 10px;
  }
  .trainer-production .model-rotation-controls:not(.unlocked) .model-orientation-controls,
  .trainer-production .model-rotation-controls:not(.unlocked) .model-camera-controls { display: none; }
  .model-rotation-actions button { min-height: 44px; height: 44px; }
  .model-zoom-control { min-height: 38px; }
  .model-zoom-control input,
  .model-orientation-control input,
  .model-camera-control input { min-height: 32px; }
  .fullscreen-button { top: calc(76px + env(safe-area-inset-top)); min-height: 42px; height: 42px; border-radius: 9px; }

  .topbar .task-library-return { min-height: 44px; }
  .fullscreen-button { min-height: 44px; height: 44px; }
  .sequence-panel:not(.drawer-open) { max-height: calc(184px + env(safe-area-inset-bottom)); }
  .step-drawer-toggle { min-height: 44px; height: 44px; margin-bottom: 3px; }
  .sequence-panel:not(.drawer-open) h2 { align-self: end; margin-bottom: 2px; font-size: 17px; line-height: 1.15; }
  .sequence-panel:not(.drawer-open) #stepText { font-size: 13px; -webkit-line-clamp: 2; }

  .m2-model-hit[aria-label="Feed tray"] { min-height: 44px !important; margin-top: -4px; }
  .m2-model-hit[aria-label="Bolt catch"] { min-width: 44px !important; min-height: 44px !important; margin: -4px 0 0 -1px; }
  .m2-model-hit[aria-label="Magazine release button"] { min-width: 44px !important; margin-left: -11px; }
  .m2-model-hit[aria-label="Dust cover"] { min-height: 44px !important; margin-top: -8px; }
}

@media (max-width: 420px) {
  .mobile-quick-controls { grid-template-columns: minmax(124px, 1fr) 46px 48px 50px; }
  .model-rotation-actions { flex-wrap: nowrap; }
  .model-rotation-actions button { min-width: 0; padding-inline: 8px; }
}

/* Camera tools have their own row; never cover the model or its hotspots. */
.weapon-panel { grid-template-rows: auto minmax(0, 1fr) auto; }
.weapon-studio-header { grid-area: 1 / 1; }
.weapon-panel > .weapon-stage { grid-area: 2 / 1; min-height: 0; }
.weapon-panel > .event-notice {
  grid-area: 2 / 1;
  position: relative;
  align-self: start;
  top: auto;
  left: auto;
  margin: 22px auto 0;
  transform: none;
}
.weapon-panel > .model-rotation-controls {
  position: static;
  grid-area: 3 / 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  width: 100%;
  max-width: none;
  padding: 9px 16px;
  border: 0;
  border-top: 1px solid #d7dee8;
  border-radius: 0;
  background: #f8fafc;
  box-shadow: none;
  pointer-events: auto;
}
.weapon-panel > .model-rotation-controls[hidden] { display: none; }
.weapon-panel > .model-rotation-controls.unlocked { background: #edf8f5; }
.model-view-primary {
  display: flex;
  align-items: center;
  flex: 1 1 460px;
  flex-wrap: wrap;
  gap: 6px 18px;
  min-width: 0;
}
.model-view-primary .model-rotation-header { margin: 0; gap: 12px; flex-wrap: nowrap; }
.model-view-primary .model-rotation-actions { flex: none; flex-wrap: nowrap; }
.model-view-primary .model-rotation-actions button { min-height: 36px; height: 36px; }
.model-view-primary .model-zoom-control {
  flex: 1 1 180px;
  max-width: 280px;
  margin: 0;
  grid-template-columns: auto minmax(60px, 1fr) 42px;
}
.model-view-fine-controls { min-width: 0; }
.model-view-fine-controls summary {
  padding: 9px 2px;
  color: #526076;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.model-view-fine-controls[open] {
  flex-basis: 100%;
  border-top: 1px solid #d7dee8;
}
.model-view-gesture-help { display: none; margin: 0; color: #3d615b; font-size: 12px; }
.model-rotation-controls.unlocked .model-view-gesture-help { display: block; flex-basis: 100%; order: 3; }
.model-view-touch-help { display: none; }
.model-rotation-controls.unlocked #modelRotationToggleButton { background: #0f766e; border-color: #0f766e; color: white; }
.model-view-fine-controls summary:focus-visible { outline: 2px solid #0f766e; outline-offset: 2px; border-radius: 4px; }
.weapon-panel .m2-model-viewer,
.weapon-panel .m2-model-frame,
.weapon-panel .m2-model-canvas { min-height: 0; max-height: 100%; }
.weapon-panel .m2-model-frame { touch-action: none; }

@media (max-width: 1120px) and (min-width: 901px) {
  .model-view-primary { flex-basis: 360px; }
  .model-view-primary .model-rotation-header > span { display: none; }
}

@media (max-width: 900px) {
  .stage-row { height: 100%; }
  .weapon-panel {
    grid-template-rows: auto minmax(0, 1fr);
    padding-top: calc(66px + env(safe-area-inset-top));
  }
  .weapon-panel > .model-rotation-controls { grid-row: 1; padding: 6px 8px; gap: 5px; }
  .model-view-primary { flex-basis: 100%; }
  .model-view-primary .model-rotation-header { width: 100%; }
  .model-view-primary .model-rotation-actions { flex: 1; justify-content: center; gap: 6px; }
  .model-view-primary .model-rotation-actions button { flex: 1; min-width: 0; min-height: 44px; height: 44px; }
  .model-view-primary .model-rotation-header > span,
  .model-view-primary .model-zoom-control,
  .model-view-fine-controls,
  .model-view-fine-controls[open],
  .model-view-desktop-help { display: none; }
  .model-view-touch-help { display: inline; }
  .model-view-gesture-help { width: 100%; text-align: center; font-size: 11px; }
  .weapon-panel > .weapon-stage { grid-row: 2; }
}

@media (max-width: 900px) and (orientation: portrait) {
  /* Reserve the collapsed step drawer instead of placing camera tools over it. */
  .weapon-panel { padding-bottom: calc(184px + env(safe-area-inset-bottom)); }
}

@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) {
  /* Share the top control row on short screens, leaving room for the model. */
  .weapon-panel { padding-top: 0; }
  .mobile-quick-controls {
    right: calc(50% + 8px);
    grid-template-columns: minmax(106px, 1fr) 40px 42px 44px;
    gap: 4px;
  }
  .weapon-panel > .model-rotation-controls {
    justify-self: end;
    width: calc(50% - 92px - env(safe-area-inset-right));
    margin-right: calc(86px + env(safe-area-inset-right));
    padding: 7px 0;
    border-top: 0;
  }
  .model-view-primary .model-rotation-actions { gap: 4px; }
  .model-view-primary .model-rotation-actions button { padding-inline: 5px; }
  .model-view-gesture-help { font-size: 10px; }
}

/* Keep selection, optional reference, and active practice in distinct places. */
.sequence-panel .step-drawer-toggle { display: block; width: 100%; margin-top: 16px; }
.sequence-drawer-content[hidden] { display: none !important; }
.weapon-action-status { margin: 10px 16px; padding: 12px 16px; border: 1px solid #d6e0e7; border-radius: 10px; background: #f8fafc; }
.weapon-action-status h2 { margin: 4px 0; font-size: 16px; }
.weapon-action-status p { margin: 4px 0; font-size: 13px; }
.weapon-action-status .step-counter { margin: 0; font-size: 11px; }
.weapon-action-status .feedback { display: block; }
.weapon-action-status .session-clock { margin: 4px 0; }
@media (max-width: 900px) { .weapon-action-status { margin: 6px 10px; padding: 8px 10px; } }
.weapon-panel { grid-template-rows: auto auto minmax(0, 1fr) auto; }
.weapon-panel > .weapon-action-status { grid-area: 2 / 1; min-width: 0; }
.weapon-panel > .weapon-stage { grid-area: 3 / 1; }
.weapon-panel > .model-rotation-controls { grid-row: 4; }
@media (max-width: 900px) and (orientation: portrait) {
  .weapon-panel { grid-template-rows: auto auto minmax(0, 1fr); }
  .weapon-panel > .model-rotation-controls { grid-row: 1; }
  .weapon-panel > .weapon-action-status { grid-row: 2; }
  .weapon-panel > .weapon-stage { grid-row: 3; }
}
@media (max-width: 900px) and (orientation: portrait) {
  .weapon-panel { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
}
/* The same task library remains available while operating a weapon. */
.sequence-panel {
  --line: #d7dee8; --surface: #fff; --ink: #142238; --navy: #142238;
  --teal: #1f9d8a; --teal-soft: #e3f3ef;
  display: block; overflow: auto; padding: 20px 16px;
}
.sequence-panel .library-close { display: none; }
.sequence-panel .library-heading h2 { font-size: 22px; }
.sequence-panel .task-count { font-size: 11px; padding: 4px 8px; border-radius: 20px; }
.sequence-panel .lane-button { min-height: 44px; height: auto; }
.sequence-panel .task-button { min-height: 58px; align-items: center; }
.weapon-library-backdrop[hidden] { display: none; }
.weapon-library-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(15,23,42,.4); border: 0; }
.weapon-procedure-reference { position: absolute; right: 16px; bottom: 70px; z-index: 20; max-width: min(340px, 85%); }
.weapon-procedure-reference .step-drawer-toggle { display: block; margin: 0; width: auto; min-height: 36px; }
.weapon-procedure-reference .sequence-drawer-content { display: block; max-height: 40dvh; overflow: auto; background: #f8fafc; border: 1px solid #d7dee8; padding: 10px; border-radius: 8px; }
.weapon-procedure-reference .progress-list { display: grid; overflow: visible; }
@media (max-width: 900px) {
  .sequence-panel {
    position: fixed; inset: 0 auto 0 0; z-index: 90;
    width: min(390px,92vw); height: 100dvh; max-height: 100dvh !important;
    display: block; padding: 18px 15px 30px; border-radius: 0;
    transform: translateX(-105%); transition: transform .2s ease; overflow: auto;
  }
  .sequence-panel.library-open { transform: translateX(0); }
  .sequence-panel .library-close { display: block; min-width: 48px; min-height: 36px; }
  .sequence-panel .task-list { display: grid; overflow: visible; }
  .weapon-panel { padding-bottom: 0; }
  .weapon-procedure-reference { bottom: 8px; right: 8px; }
  .mobile-quick-controls { grid-template-columns: 52px minmax(106px,1fr) 42px 46px 48px; }
  .mobile-quick-controls [data-open-library] { display: block; }
}
.weapon-action-status #stepText { min-height: 0; }
.weapon-task-phases { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.weapon-task-phases[hidden] { display: none; }
.weapon-task-phases a { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 7px; color: #334155; background: #fff; font-size: 13px; font-weight: 750; text-decoration: none; }
.weapon-task-phases a.active { background: #e3f3ef; border-color: #7dbcae; color: #0b6358; }
.weapon-task-phases span { font-size: 11px; color: #526075; }
/* Phone layouts use normal document flow so controls never cover the workspace. */
.session-clock[hidden] { display: none !important; }
@media (max-width: 900px) {
  body { overflow: auto; }
  body.weapon-library-open { overflow: hidden; }
  .trainer-shell { padding: 0; min-height: 100dvh; }
  .workbench { display: block; height: auto; min-height: 100dvh; overflow: visible; border-radius: 0; }
  .topbar { min-height: 62px; padding: max(10px,env(safe-area-inset-top)) 12px 10px; }
  .stage-row { display: block; height: auto; overflow: visible; }
  .weapon-panel { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto auto auto auto auto; height: auto; min-height: 0; padding: 0 0 env(safe-area-inset-bottom); overflow: visible; }
  .mobile-quick-controls {
    position: sticky; grid-area: 1 / 1; top: 0; left: auto; right: auto;
    width: 100%; max-width: none; margin: 0; padding: 6px max(6px,env(safe-area-inset-right)) 6px max(6px,env(safe-area-inset-left));
    grid-template-columns: 44px minmax(0,1fr) 44px 44px 44px; gap: 4px;
    border-radius: 0; z-index: 25;
  }
  .mobile-quick-controls button { width: 100%; min-width: 0; min-height: 44px; height: auto; padding: 4px; }
  .mobile-quick-controls .mobile-session-button { min-width: 0; padding-inline: 5px; }
  .mobile-session-button span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-session-button span:first-child { font-size: 11px; }
  .mobile-session-button span:last-child { font-size: 10px; }
  .fullscreen-button { position: absolute; top: max(8px,env(safe-area-inset-top)); right: max(8px,env(safe-area-inset-right)); min-width: 52px; height: 44px; }
  .weapon-panel > .model-rotation-controls { grid-area: 2 / 1; width: 100%; max-width: none; margin: 0; justify-self: stretch; padding: 6px 8px; }
  .weapon-panel > .weapon-action-status { grid-area: 3 / 1; margin: 6px 8px; padding: 8px 10px; }
  .weapon-action-status #stepText { display: block; height: auto; overflow: visible; white-space: normal; font-size: 13px; line-height: 1.4; }
  .weapon-action-status .feedback { height: auto; min-height: 0; padding: 8px; white-space: normal; overflow: visible; font-size: 13px; }
  .weapon-action-status h2 { font-size: 16px; }
  .weapon-panel > .weapon-stage { grid-area: 4 / 1; width: 100%; height: clamp(340px,55svh,620px); min-height: 340px; padding: 4px; }
  .weapon-panel > .event-notice { grid-area: 4 / 1; position: relative; align-self: start; margin-top: 8px; z-index: 15; }
  .weapon-panel > .maintenance-action { grid-area: 4 / 1; position: relative; align-self: end; justify-self: center; top: auto; right: auto; transform: none; margin: 8px; max-width: calc(100% - 16px); }
  .weapon-procedure-reference { grid-area: 5 / 1; position: static; max-width: none; margin: 6px 8px; }
  .weapon-procedure-reference .step-drawer-toggle { width: 100%; min-height: 44px; border: 1px solid #cbd5e1; background: #f8fafc; }
  .weapon-procedure-reference .step-drawer-toggle::before { display: none; }
  .weapon-procedure-reference .sequence-drawer-content { height: auto; max-height: 50dvh; }
  .sequence-panel { padding-top: max(18px,env(safe-area-inset-top)); padding-bottom: max(24px,env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .sequence-panel .library-close { min-height: 44px; }
  .task-search input, .setup-selects select { font-size: 16px; min-height: 44px; }
  .setup-panel { max-height: calc(100dvh - 20px); }
  .setup-panel-header { flex-wrap: wrap; gap: 8px; }
  .setup-panel-actions { flex-wrap: wrap; }
  .weapon-task-phases a { min-height: 44px; flex: 1 1 130px; }
}
