/* ============================================================
   InfraSquad LMS — Module 2 (Fiber 101 + safety)
   Module-specific stylesheet. Loaded after shared/lms.css for
   design tokens; this file owns layout + scene aesthetics.

   Module 2 is structurally different from Module 1: it's four
   interactive scenes (sims) rather than one infographic with
   hot spots. So the layout is its own beast — no shared .app /
   .stage / .sheet classes.
   ============================================================ */

:root {
  /* Module-2 specific tokens */
  --m2-orange: #E8651A;
  --m2-orange-soft: #FAEEDA;
  --m2-orange-deep: #c9531a;
  --m2-green: #5FA85C;
  --m2-green-soft: #E2F0DE;
  --m2-yellow: #DAA520;
  --m2-yellow-soft: #FCF1C9;
  --m2-red: #C9531A;
  --m2-red-deep: #A23E0F;
  --m2-red-soft: #FCDCD0;
  --m2-blue: #3B7DB7;
  --m2-blue-soft: #DDEAF4;

  --m2-scope-bg: #0a0a0a;
  --m2-scope-mid: #1a1a1a;
  --m2-scope-edge: #000;
  --m2-scope-bezel: rgba(255, 255, 255, 0.06);
  --m2-scope-glow: rgba(232, 101, 26, 0.18);
  --m2-scope-reticle: rgba(232, 101, 26, 0.28);

  --m2-radius-sm: 6px;
  --m2-radius-md: 10px;
  --m2-radius-lg: 16px;
  --m2-radius-xl: 22px;

  --m2-shadow-sm: 0 1px 3px rgba(10, 10, 10, 0.05), 0 1px 2px rgba(10, 10, 10, 0.04);
  --m2-shadow-md: 0 4px 14px rgba(10, 10, 10, 0.08), 0 2px 6px rgba(10, 10, 10, 0.05);
  --m2-shadow-lg: 0 10px 30px rgba(10, 10, 10, 0.12), 0 4px 10px rgba(10, 10, 10, 0.06);

  --m2-ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --m2-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   App shell
   ============================================================ */
body.m2-body {
  background: var(--color-bg);
  color: var(--page-text);
  overflow-x: hidden;
}

.m2-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1280px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ============================================================
   Header
   ============================================================ */
.m2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 4px;
  flex-shrink: 0;
}
.m2-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.m2-back {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: transparent;
  border: 0.5px solid var(--page-border);
  color: var(--page-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
.m2-back:hover { background: var(--page-soft-bg); }
.m2-back:active { transform: scale(0.92); }
.m2-back svg { width: 16px; height: 16px; }
.m2-header-text { min-width: 0; }
.m2-eyebrow {
  font-size: 10.5px;
  color: var(--page-text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 1px;
  font-weight: 500;
}
.m2-title {
  font-size: 17px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--page-text);
}
.m2-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.m2-incidents {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--page-soft-bg);
  border: 0.5px solid var(--page-border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--page-text);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  font-variant-numeric: tabular-nums;
}
.m2-incidents.has-incidents {
  background: var(--m2-red-soft);
  border-color: var(--m2-red);
  color: var(--m2-red-deep);
}
[data-theme="dark"] .m2-incidents.has-incidents {
  background: rgba(201, 83, 26, 0.2);
  color: #FFB69A;
}
.m2-incidents-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--page-text-muted);
  display: inline-block;
}
.m2-incidents.has-incidents .m2-incidents-dot {
  background: var(--m2-red);
  animation: m2-pulse-soft 2s ease-in-out infinite;
}
@keyframes m2-pulse-soft {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.m2-incidents.bumped {
  animation: m2-shake 0.4s var(--m2-ease-spring);
}
@keyframes m2-shake {
  0% { transform: scale(1); }
  30% { transform: scale(1.15); }
  60% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
.m2-incidents-count { font-weight: 600; }
.m2-incidents-label { color: inherit; opacity: 0.75; }

.m2-theme-toggle, .m2-voice-toggle {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: transparent;
  border: 0.5px solid var(--page-border);
  color: var(--page-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}
.m2-theme-toggle:hover, .m2-voice-toggle:hover { background: var(--page-soft-bg); }
.m2-theme-toggle svg, .m2-voice-toggle svg { width: 16px; height: 16px; }
.m2-theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .m2-theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .m2-theme-toggle .icon-moon { display: inline-block; }
.m2-voice-toggle .icon-vol-off { display: none; }
.m2-voice-toggle.muted { color: var(--page-text-muted); }
.m2-voice-toggle.muted .icon-vol-on { display: none; }
.m2-voice-toggle.muted .icon-vol-off { display: inline-block; }
.m2-voice-toggle.speaking {
  border-color: var(--m2-orange);
  color: var(--m2-orange);
  animation: m2-pulse-soft 1.4s ease-in-out infinite;
}

/* Help (?) button — fixed top-right of stage card while a scene is active */
.m2-help-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 0.5px solid var(--color-border-strong);
  color: var(--color-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 5;
  backdrop-filter: blur(4px);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  box-shadow: 0 2px 6px rgba(10, 10, 10, 0.08);
}
.m2-help-btn:hover {
  background: var(--m2-orange);
  border-color: var(--m2-orange);
  color: #FFFFFF;
  transform: scale(1.06);
}
.m2-help-btn:active { transform: scale(0.94); }
.m2-help-btn svg { width: 18px; height: 18px; }
.m2-help-btn[hidden] { display: none; }
/* Help button looks correct on dark scenes (Scene 4) too */
.s4-root + .m2-help-btn,
.m2-stage-card:has(.s4-root) .m2-help-btn {
  background: rgba(40, 40, 38, 0.85);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.18);
}

/* ============================================================
   Stage (holds active scene)
   ============================================================ */
.m2-stage {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 12px 14px;
  position: relative;
}
.m2-stage-card {
  width: 100%;
  background: #FFFFFF;
  border-radius: var(--m2-radius-lg);
  border: 0.5px solid rgba(10, 10, 10, 0.10);
  box-shadow: var(--m2-shadow-md);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.m2-scene-mount {
  flex: 1;
  display: flex;
  flex-direction: column;
  outline: none;
  position: relative;
  min-height: 0;
}

.m2-scene {
  display: none;
  width: 100%;
  flex: 1;
  flex-direction: column;
  animation: m2-scene-in 0.35s var(--m2-ease-out);
}
.m2-scene.active { display: flex; }
@keyframes m2-scene-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Caption strip (scene-driven)
   ============================================================ */
.m2-caption {
  flex-shrink: 0;
  padding: 8px 18px 4px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.m2-caption-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--page-text-soft);
  margin: 0;
  max-width: 60ch;
}
.m2-caption-text strong { color: var(--page-text); font-weight: 500; }

/* ============================================================
   Day plan (timeline) — sits between header and stage. On phone,
   collapses behind a toggle so the stage card has more room.
   ============================================================ */
.m2-plan {
  flex-shrink: 0;
  padding: 4px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.m2-plan-toggle {
  display: none;  /* hidden on desktop; revealed by mobile media query */
  width: 100%;
  background: var(--page-soft-bg);
  border: 0.5px solid var(--page-border);
  border-radius: var(--m2-radius-md);
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  color: var(--page-text);
  cursor: pointer;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.m2-plan-toggle:hover { background: var(--page-border); }
.m2-plan-toggle-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--page-text-muted);
  font-weight: 500;
  flex-shrink: 0;
}
.m2-plan-toggle-current {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  color: var(--page-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m2-plan-toggle-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--page-text-muted);
  transition: transform 0.25s var(--m2-ease-out);
}
.m2-plan.open .m2-plan-toggle-chevron { transform: rotate(180deg); }

.m2-timeline {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.m2-ts-step {
  flex: 1;
  background: transparent;
  border: 0.5px solid var(--page-border);
  border-radius: var(--m2-radius-md);
  padding: 10px 12px 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--page-text);
  transition: background 0.18s, border-color 0.18s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.m2-ts-step:hover {
  background: var(--page-soft-bg);
  border-color: var(--page-text-muted);
}
.m2-ts-step.completed {
  border-color: var(--m2-green);
  background: var(--m2-green-soft);
  color: #1F4F1B;
}
[data-theme="dark"] .m2-ts-step.completed {
  background: rgba(95, 168, 92, 0.18);
  color: #C5E5C2;
}
.m2-ts-step.active {
  border-color: var(--m2-orange);
  background: var(--m2-orange-soft);
  color: #633806;
}
[data-theme="dark"] .m2-ts-step.active {
  background: rgba(232, 101, 26, 0.20);
  color: #FFD2B0;
}
.m2-ts-step.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--m2-orange);
}
.m2-ts-num {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0.85;
}
.m2-ts-name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m2-ts-tag {
  font-size: 10px;
  color: inherit;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 720px) {
  /* Mobile: timeline is collapsible behind a toggle */
  .m2-plan-toggle { display: flex; }
  .m2-timeline {
    flex-direction: column;
    gap: 6px;
    max-height: 0;
    overflow: hidden;
    padding: 0;
    transition: max-height 0.3s var(--m2-ease-out), padding 0.3s var(--m2-ease-out);
  }
  .m2-plan.open .m2-timeline {
    max-height: 360px;
    padding: 6px 0 2px;
  }
  .m2-ts-step { padding: 10px 12px; }
  .m2-ts-tag { display: none; }
  .m2-ts-name { font-size: 13px; }
  .m2-ts-num { font-size: 9.5px; }
}

/* ============================================================
   Buttons (shared)
   ============================================================ */
.m2-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--m2-radius-md);
  padding: 11px 18px;
  cursor: pointer;
  border: 0.5px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
  letter-spacing: -0.005em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.m2-btn:active { transform: scale(0.97); }
.m2-btn-primary {
  background: var(--m2-orange);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(232, 101, 26, 0.25);
}
.m2-btn-primary:hover { background: var(--m2-orange-deep); }
.m2-btn-ghost {
  background: transparent;
  color: var(--color-text-soft);
  border-color: var(--color-border-strong);
}
.m2-btn-ghost:hover { background: var(--color-bg-soft); color: var(--color-text); }
.m2-btn-danger {
  background: var(--m2-red);
  color: #FFFFFF;
}
.m2-btn-danger:hover { background: var(--m2-red-deep); }
.m2-btn-disabled, .m2-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================
   Overlays (copper intro + scorecard)
   ============================================================ */
.m2-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.m2-overlay.open {
  pointer-events: auto;
  opacity: 1;
}
.m2-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.m2-overlay-card {
  position: relative;
  background: var(--color-bg-card);
  color: var(--color-text);
  border-radius: var(--m2-radius-xl);
  padding: 28px 28px 24px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(10, 10, 10, 0.25), 0 6px 18px rgba(10, 10, 10, 0.10);
  animation: m2-overlay-in 0.32s var(--m2-ease-spring);
}
@keyframes m2-overlay-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.m2-overlay-tag {
  font-size: 10.5px;
  color: var(--m2-orange);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  margin: 0 0 10px;
}
.m2-overlay-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  color: var(--color-text);
}
.m2-overlay-prompt {
  font-size: 14.5px;
  color: var(--color-text-soft);
  line-height: 1.55;
  margin: 0 0 16px;
}
.m2-overlay-quote {
  background: var(--m2-orange-soft);
  border-left: 3px solid var(--m2-orange);
  border-radius: var(--m2-radius-md);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: #633806;
  margin: 0 0 22px;
}
.m2-overlay-quote b { font-weight: 600; }
.m2-overlay-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Listen / voice play button */
.m2-voice-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--m2-radius-md);
  padding: 9px 14px 9px 12px;
  cursor: pointer;
  border: 0.5px solid var(--m2-orange);
  background: var(--m2-orange-soft);
  color: var(--m2-orange-deep);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background 0.15s, color 0.15s, transform 0.08s;
}
.m2-voice-btn:hover { background: var(--m2-orange); color: #FFFFFF; }
.m2-voice-btn:active { transform: scale(0.97); }
.m2-voice-btn svg { width: 13px; height: 13px; }
.m2-voice-btn.playing { background: var(--m2-orange); color: #FFFFFF; }
.m2-voice-btn.playing svg { animation: m2-pulse-soft 1.2s ease-in-out infinite; }

/* Tour overlay (intro walkthrough) */
.m2-tour-card { max-width: 540px; }
.m2-tour-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.m2-overlay-actions-top {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: flex-start;
}
.m2-overlay-close, .m2-overlay-mute {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: 0.5px solid var(--color-border-strong);
  color: var(--color-text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.m2-overlay-close:hover, .m2-overlay-mute:hover {
  background: var(--color-bg-soft);
  color: var(--color-text);
}
.m2-overlay-mute svg { width: 14px; height: 14px; }
.m2-overlay-mute .icon-vol-off { display: none; }
.m2-overlay-mute.muted .icon-vol-on { display: none; }
.m2-overlay-mute.muted .icon-vol-off { display: inline-block; }
.m2-overlay-mute.muted {
  border-color: var(--color-text-muted);
  color: var(--color-text-muted);
}
.m2-overlay-mute.speaking {
  border-color: var(--m2-orange);
  color: var(--m2-orange);
  animation: m2-pulse-soft 1.4s ease-in-out infinite;
}
.m2-tour-listen-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  flex-wrap: wrap;
}
.m2-tour-listen-hint {
  font-size: 11.5px;
  color: var(--color-text-muted);
  line-height: 1.4;
}
.m2-tour-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  justify-content: center;
}
.m2-tour-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border-strong);
  cursor: pointer;
  border: 0;
  padding: 0;
  transition: background 0.15s, transform 0.1s;
}
.m2-tour-dot:hover { transform: scale(1.3); }
.m2-tour-dot.active { background: var(--m2-orange); }
.m2-tour-dot.visited { background: var(--m2-orange-deep); opacity: 0.6; }
.m2-tour-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.m2-tour-actions .m2-btn { padding: 9px 14px; font-size: 13px; }

/* Hint overlay (per-scene help) */
.m2-hint-card { max-width: 480px; }
.m2-hint-section { margin: 0 0 14px; }
.m2-hint-section h3 {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
}
.m2-hint-section p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--color-text);
  margin: 0;
}
.m2-hint-section ol {
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0;
  padding-left: 22px;
  color: var(--color-text);
}
.m2-hint-section ol li { margin-bottom: 5px; }
.m2-hint-section.m2-hint-stuck {
  background: var(--m2-orange-soft);
  border-left: 3px solid var(--m2-orange);
  border-radius: var(--m2-radius-md);
  padding: 12px 14px;
  margin-top: 14px;
}
.m2-hint-section.m2-hint-stuck h3 { color: var(--m2-orange-deep); }
.m2-hint-section.m2-hint-stuck p { color: #633806; }

/* Landing CTA (when no scene is active yet) */
.m2-landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  background: linear-gradient(180deg, #FAFAF6 0%, #F4F1EA 100%);
  gap: 16px;
}
.m2-landing-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--m2-orange-soft);
  border: 0.5px solid var(--m2-orange);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--m2-orange);
  margin-bottom: 4px;
}
.m2-landing-icon svg { width: 32px; height: 32px; }
.m2-landing-title {
  font-size: 24px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.m2-landing-eyebrow {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--m2-orange);
  font-weight: 500;
  margin: 0;
}
.m2-landing-body {
  font-size: 15px;
  line-height: 1.55;
  color: var(--color-text-soft);
  max-width: 480px;
  margin: 0 0 8px;
}
.m2-landing-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.m2-landing-actions .m2-btn { padding: 12px 22px; font-size: 14px; }
.m2-landing-actions .m2-btn-primary svg {
  width: 14px; height: 14px; margin-right: 2px;
}
.m2-landing-tip {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 8px 0 0;
  font-style: italic;
}

/* Scorecard layout */
.m2-scorecard { max-width: 540px; }
.m2-scorecard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}
.m2-score-card {
  background: var(--color-bg-soft);
  border: 0.5px solid var(--color-border);
  border-radius: var(--m2-radius-md);
  padding: 12px;
  text-align: center;
}
.m2-score-card.has {
  background: var(--m2-red-soft);
  border-color: var(--m2-red);
  color: #5C2406;
}
.m2-score-card.zero {
  opacity: 0.55;
}
.m2-score-num {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: block;
  line-height: 1.05;
}
.m2-score-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: 4px;
  display: block;
}
.m2-score-card.has .m2-score-label { color: inherit; opacity: 0.85; }

/* ============================================================
   Toasts (transient feedback)
   ============================================================ */
.m2-toast-stack {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}
.m2-toast {
  background: #2C2C2A;
  color: #FFFFFF;
  padding: 10px 14px;
  border-radius: var(--m2-radius-md);
  font-size: 13px;
  line-height: 1.4;
  max-width: 320px;
  box-shadow: var(--m2-shadow-lg);
  animation: m2-toast-in 0.3s var(--m2-ease-spring);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  pointer-events: auto;
}
.m2-toast.warn   { background: #BA7517; }
.m2-toast.danger { background: #A23E0F; }
.m2-toast.ok     { background: #3D7A3A; }
.m2-toast-icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  margin-top: 4px;
}
.m2-toast-text { flex: 1; min-width: 0; }
.m2-toast-text b { font-weight: 600; display: block; margin-bottom: 1px; }
.m2-toast.exit { animation: m2-toast-out 0.25s ease forwards; }
@keyframes m2-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes m2-toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* ============================================================
   Full-screen flash (corneal-burn etc.)
   ============================================================ */
.m2-flash {
  position: fixed;
  inset: 0;
  background: #FFFFFF;
  pointer-events: none;
  opacity: 0;
  z-index: 200;
}
.m2-flash.fire {
  animation: m2-flash-burn 0.7s ease-out;
}
@keyframes m2-flash-burn {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  60%  { opacity: 0.6; }
  100% { opacity: 0; }
}

/* ============================================================
   SCENE 1 — Verify-dark patch panel
   ============================================================ */
.s1-root {
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  padding: 18px;
  background: linear-gradient(180deg, #FAFAF6 0%, #F4F1EA 100%);
}
.s1-workorder {
  background: #FFFFFF;
  border: 0.5px solid var(--color-border);
  border-radius: var(--m2-radius-md);
  padding: 10px 14px;
  box-shadow: var(--m2-shadow-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.s1-workorder-tag {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--m2-orange);
  font-weight: 500;
}
.s1-workorder-text {
  font-size: 13px;
  color: var(--color-text);
  margin: 0;
  flex: 1;
}
.s1-workorder-text b { font-weight: 600; color: var(--color-text); }
.s1-workorder-tasks {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.s1-workorder-task {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  background: var(--color-bg-soft);
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  border: 0.5px solid var(--color-border);
}
.s1-workorder-task.done {
  background: var(--m2-green-soft);
  color: #1F4F1B;
  border-color: var(--m2-green);
  text-decoration: line-through;
  text-decoration-color: rgba(31, 79, 27, 0.4);
}
.s1-stage {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 16px;
  min-height: 0;
}
@media (max-width: 720px) {
  .s1-stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
}
.s1-panel-wrap {
  background: #1c1c1a;
  border-radius: var(--m2-radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.s1-panel-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.04), transparent 60%);
  pointer-events: none;
}
.s1-panel-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  color: #9b9b95;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.s1-panel-label-spec { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s1-panel-label-warn {
  color: #DAA520;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.s1-panel-label-warn::before {
  content: '⚠';
  font-size: 11px;
}
.s1-panel-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  flex: 1;
  align-content: stretch;
}
.s1-port {
  background: #2a2a28;
  border: 0.5px solid #1a1a18;
  border-radius: 6px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  cursor: pointer;
  transition: transform 0.12s, background 0.18s, box-shadow 0.18s;
  font-family: inherit;
  color: #d8d8d2;
  text-align: left;
}
.s1-port:hover {
  background: #353532;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.s1-port.selected {
  outline: 2px solid var(--m2-orange);
  outline-offset: 2px;
}
.s1-port-id {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: #9b9b95;
  font-weight: 500;
}
.s1-port-body {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.s1-port-clip {
  width: 12px;
  height: 8px;
  border-radius: 1.5px;
  background: #4a4a47;
}
.s1-port-clip.has-cable {
  background: #6a6a65;
  box-shadow: inset 0 0 0 1px #2a2a28;
}
.s1-port-cable {
  width: 30px;
  height: 6px;
  border-radius: 3px;
  margin-left: 2px;
}
.s1-port-cable.green { background: linear-gradient(90deg, #5FA85C, #4a8a48); }
.s1-port-cable.orange { background: linear-gradient(90deg, #E8651A, #c9531a); }
.s1-port-cable.blue { background: linear-gradient(90deg, #3B7DB7, #2D6396); }
.s1-port-cap {
  width: 32px;
  height: 8px;
  border-radius: 1.5px;
  background: #f0eee5;
}
.s1-port-status {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-align: center;
  padding: 2px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  color: #b0b0a8;
  min-height: 14px;
}
.s1-port.tested-dark .s1-port-status { background: rgba(95, 168, 92, 0.25); color: #B6E3B3; }
.s1-port.tested-live .s1-port-status { background: rgba(218, 165, 32, 0.25); color: #F5DC9A; }
.s1-port.tested-dark { box-shadow: inset 0 0 0 1px rgba(95, 168, 92, 0.4); }
.s1-port.tested-live { box-shadow: inset 0 0 0 1px rgba(218, 165, 32, 0.4); }
.s1-port.completed {
  background: rgba(95, 168, 92, 0.15);
  box-shadow: inset 0 0 0 1px rgba(95, 168, 92, 0.5);
}
.s1-port.completed::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 6px;
  color: var(--m2-green);
  font-weight: 600;
  font-size: 11px;
}

.s1-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.s1-opm {
  background: #1a1a18;
  border-radius: var(--m2-radius-md);
  padding: 14px;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.s1-opm-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9b9b95;
  font-weight: 500;
}
.s1-opm-display {
  background: #0d0d0c;
  border-radius: 4px;
  padding: 10px 12px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 22px;
  font-weight: 600;
  color: #5FA85C;
  text-align: center;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  border: 0.5px solid #222220;
  text-shadow: 0 0 8px rgba(95, 168, 92, 0.4);
  position: relative;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.s1-opm-display.live {
  color: #DAA520;
  text-shadow: 0 0 8px rgba(218, 165, 32, 0.4);
}
.s1-opm-display.empty {
  color: #4a4a47;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-shadow: none;
  text-transform: uppercase;
}
.s1-opm-display.testing {
  color: #6FA9D5;
  text-shadow: 0 0 6px rgba(111, 169, 213, 0.4);
  animation: m2-opm-flicker 0.5s steps(8) infinite;
}
@keyframes m2-opm-flicker {
  0%, 100% { opacity: 1; }
  20% { opacity: 0.7; }
  40% { opacity: 1; }
  60% { opacity: 0.85; }
}
.s1-opm-help {
  font-size: 10.5px;
  color: #9b9b95;
  line-height: 1.4;
  margin: 0;
}
.s1-action-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.s1-action-row .m2-btn {
  font-size: 12.5px;
  padding: 10px 12px;
  width: 100%;
}
.s1-info {
  font-size: 11px;
  line-height: 1.45;
  color: var(--color-text-muted);
  background: var(--color-bg-soft);
  border-radius: var(--m2-radius-sm);
  padding: 10px 12px;
}

/* ============================================================
   SCENE 2 — Strip & cleave
   ============================================================ */
.s2-root {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(180deg, #FAFAF6 0%, #F0EBDA 100%);
  position: relative;
  overflow: hidden;
}
.s2-bench {
  background: #FFFFFF;
  border: 0.5px solid var(--color-border);
  border-radius: var(--m2-radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--m2-shadow-sm);
  min-height: 0;
}
.s2-bench-eyebrow {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 10px;
  align-self: flex-start;
  font-weight: 500;
}
.s2-cable-stage {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.s2-cable-svg {
  width: 100%;
  height: auto;
  max-height: 100%;
  max-width: 580px;
}
.s2-stage-label {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--m2-orange-soft);
  color: #633806;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.s2-stage-num {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.s2-toolbar {
  background: #FFFFFF;
  border: 0.5px solid var(--color-border);
  border-radius: var(--m2-radius-md);
  padding: 12px;
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: var(--m2-shadow-sm);
}
.s2-tool {
  flex: 1 1 calc(20% - 8px);
  min-width: 80px;
  background: var(--color-bg-soft);
  border: 0.5px solid var(--color-border);
  border-radius: var(--m2-radius-sm);
  padding: 10px 8px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.s2-tool:hover {
  border-color: var(--color-border-strong);
  transform: translateY(-1px);
  background: #FFFFFF;
}
.s2-tool.selected {
  background: var(--m2-orange-soft);
  border-color: var(--m2-orange);
  color: #633806;
  box-shadow: 0 0 0 2px rgba(232, 101, 26, 0.2);
}
.s2-tool.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.s2-tool-svg {
  width: 38px;
  height: 28px;
}
.s2-tool-name {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.s2-tool-spec {
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.s2-tool.selected .s2-tool-spec { color: inherit; opacity: 0.7; }

.s2-action {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 110px;
}
.s2-action .m2-btn { width: 100%; padding: 10px 14px; font-size: 12.5px; }
@media (max-width: 720px) {
  /* On phones, action wraps to its own full-width row below the tools */
  .s2-action {
    flex: 1 1 100%;
    flex-direction: row;
  }
  .s2-action .m2-btn { flex: 1; padding: 12px 14px; font-size: 13px; }
}
.s2-bench-instruction {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 10, 0.85);
  color: #FFFFFF;
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
  font-weight: 500;
  max-width: calc(100% - 24px);
  text-align: center;
}
.s2-bench-instruction.show { opacity: 1; }

/* Spark animation (wrong tool) */
.s2-spark {
  position: absolute;
  pointer-events: none;
  width: 80px;
  height: 80px;
  transform: translate(-50%, -50%);
}
.s2-spark-line {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 22px;
  background: linear-gradient(180deg, #FFD700, transparent);
  transform-origin: 50% 0;
  animation: s2-spark-fly 0.6s ease-out forwards;
  opacity: 0;
}
@keyframes s2-spark-fly {
  0%   { opacity: 1; transform: translate(-50%, 0) rotate(var(--ang)) scale(0.4); }
  60%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, 0) rotate(var(--ang)) scale(1.4) translateY(60px); }
}

/* Cleave puck pulse */
.s2-puck-glow {
  filter: drop-shadow(0 0 8px rgba(232, 101, 26, 0.5));
}

/* Sliver pop on hand */
.s2-sliver-pop {
  position: absolute;
  bottom: 56px;
  right: 30px;
  background: #1a1a18;
  color: #FFFFFF;
  padding: 8px 12px;
  border-radius: var(--m2-radius-sm);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--m2-shadow-md);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
}
.s2-sliver-pop.show { opacity: 1; transform: translateY(0); }
.s2-sliver-pop b { color: #FFB69A; font-weight: 600; }

/* Zoom view (shown after clean cleave). Desktop: overlays the bench card.
   Mobile: takes over the full viewport via position: fixed so the visual
   actually lands. Portrait/landscape SVG variants swap by viewport. */
.s2-zoom {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #2a2a28 0%, #1a1a18 100%);
  border-radius: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  z-index: 30;
}
.s2-zoom.show { opacity: 1; pointer-events: auto; }
.s2-zoom-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
  width: 100%;
  max-width: 720px;
  max-height: 100%;
  overflow-y: auto;
}
.s2-zoom-title {
  font-size: 18px;
  font-weight: 500;
  margin: 0;
  color: #FFB69A;
  text-align: center;
}
.s2-zoom-text-desktop, .s2-zoom-text-mobile {
  text-align: center;
  color: #d8d8d2;
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0;
  max-width: 480px;
}
.s2-zoom-text-desktop b, .s2-zoom-text-mobile b { color: #FFB69A; font-weight: 600; }
.s2-zoom-text-mobile { display: none; }  /* hidden on desktop */
.s2-zoom-svg {
  width: 100%;
  height: auto;
}
.s2-zoom-svg-landscape { display: block; max-width: 520px; }
.s2-zoom-svg-portrait { display: none; max-height: 60vh; max-width: 360px; }
.s2-zoom-cta { min-width: 200px; padding: 12px 22px; font-size: 14px; }

/* Mobile: full-viewport overlay, portrait SVG, larger CTA */
@media (max-width: 720px) {
  .s2-zoom {
    position: fixed;
    inset: 0;
    border-radius: 0;
    z-index: 250;  /* above flash, overlays, etc. */
    background: linear-gradient(180deg, #1a1a18 0%, #0d0d0c 100%);
  }
  .s2-zoom-inner {
    padding: 22px 18px max(22px, env(safe-area-inset-bottom)) 18px;
    gap: 10px;
    height: 100%;
    justify-content: space-between;
  }
  .s2-zoom-title { font-size: 17px; flex-shrink: 0; }
  .s2-zoom-text-desktop { display: none; }
  .s2-zoom-text-mobile {
    display: block;
    font-size: 13px;
    flex-shrink: 0;
  }
  .s2-zoom-svg-landscape { display: none; }
  .s2-zoom-svg-portrait {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    width: auto;
    max-width: 100%;
  }
  .s2-zoom-cta {
    width: 100%;
    padding: 14px 22px;
    font-size: 15px;
    flex-shrink: 0;
  }
}

/* ============================================================
   SCENE 3 — Bend radius
   ============================================================ */
.s3-root {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(180deg, #FAFAF6 0%, #F4F1EA 100%);
  position: relative;
  overflow: hidden;
}
.s3-stage {
  background: #FFFFFF;
  border: 0.5px solid var(--color-border);
  border-radius: var(--m2-radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--m2-shadow-sm);
  min-height: 0;
}
.s3-cable-svg {
  width: 100%;
  height: auto;
  max-width: 600px;
  max-height: 100%;
}
.s3-readout {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  border: 0.5px solid var(--color-border);
  border-radius: var(--m2-radius-sm);
  padding: 8px 12px;
}
.s3-readout-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 500;
}
.s3-readout-value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.s3-readout-status {
  font-size: 11px;
  color: var(--m2-green);
  font-weight: 500;
}
.s3-readout-status.warn { color: var(--m2-yellow); }
.s3-readout-status.danger { color: var(--m2-red); }

.s3-controls {
  background: #FFFFFF;
  border: 0.5px solid var(--color-border);
  border-radius: var(--m2-radius-md);
  padding: 14px 18px;
  box-shadow: var(--m2-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.s3-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.s3-slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.s3-slider-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 500;
}
.s3-slider-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.s3-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg,
    var(--m2-red) 0%,
    var(--m2-red) 20%,
    var(--m2-yellow) 35%,
    var(--m2-green) 50%,
    var(--m2-green) 100%);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.s3-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--color-text);
  cursor: grab;
  box-shadow: var(--m2-shadow-md);
}
.s3-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--color-text);
  cursor: grab;
}
.s3-slider:active::-webkit-slider-thumb { cursor: grabbing; }
.s3-slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.s3-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.s3-actions .m2-btn { flex: 1; }

/* Fast-forward overlay */
.s3-fastforward {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
.s3-fastforward.show { opacity: 1; pointer-events: auto; }
.s3-ff-calendar {
  width: 80px;
  height: 80px;
  position: relative;
}
.s3-ff-calendar::before, .s3-ff-calendar::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--color-text);
  border-radius: var(--m2-radius-sm);
  background: #FFFFFF;
}
.s3-ff-calendar::after {
  animation: s3-cal-flip 1.4s steps(8) 0s 1;
}
@keyframes s3-cal-flip {
  0% { transform: rotateX(0deg); opacity: 1; }
  100% { transform: rotateX(720deg); opacity: 1; }
}
.s3-ff-text {
  font-size: 14px;
  color: var(--color-text-soft);
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.s3-ff-otdr {
  background: #1a1a18;
  border-radius: var(--m2-radius-sm);
  padding: 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  box-shadow: var(--m2-shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
}
.s3-fastforward.otdr-show .s3-ff-otdr { opacity: 1; transform: translateY(0); }
.s3-ff-otdr-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9b9b95;
}
.s3-ff-otdr-num {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.s3-ff-otdr-num.pass { color: #5FA85C; text-shadow: 0 0 6px rgba(95, 168, 92, 0.4); }
.s3-ff-otdr-num.warn { color: #DAA520; text-shadow: 0 0 6px rgba(218, 165, 32, 0.4); }
.s3-ff-otdr-num.fail { color: #E8651A; text-shadow: 0 0 6px rgba(232, 101, 26, 0.5); }
.s3-ff-result {
  font-size: 12px;
  color: var(--color-text-soft);
  margin: 0;
  text-align: center;
  max-width: 360px;
  line-height: 1.5;
}
.s3-ff-actions { display: flex; gap: 8px; }

/* Quiz mode */
.s3-quiz-overlay {
  position: absolute;
  inset: 0;
  background: rgba(250, 250, 246, 0.98);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}
.s3-quiz-overlay.show { display: flex; }
.s3-quiz-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}
.s3-quiz-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border-strong);
}
.s3-quiz-dot.active { background: var(--m2-orange); }
.s3-quiz-dot.correct { background: var(--m2-green); }
.s3-quiz-dot.wrong { background: var(--m2-red); }
.s3-quiz-question {
  font-size: 15px;
  color: var(--color-text);
  text-align: center;
  margin: 0;
  font-weight: 500;
}
.s3-quiz-coil {
  flex: 0 0 auto;
}
.s3-quiz-actions {
  display: flex;
  gap: 12px;
}
.s3-quiz-actions .m2-btn { min-width: 100px; }
.s3-quiz-feedback {
  font-size: 13px;
  text-align: center;
  margin: 0;
  min-height: 36px;
  color: var(--color-text-soft);
  max-width: 380px;
}
.s3-quiz-feedback.correct { color: var(--m2-green); font-weight: 500; }
.s3-quiz-feedback.wrong { color: var(--m2-red); font-weight: 500; }
.s3-quiz-final {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.s3-quiz-final-num {
  font-size: 44px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--color-text);
}
.s3-quiz-final-text {
  font-size: 14px;
  color: var(--color-text-soft);
  max-width: 380px;
  margin: 0;
  line-height: 1.5;
}

/* ============================================================
   SCENE 4 — IBC simulator (centerpiece)
   ============================================================ */
.s4-root {
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 18px;
  background: linear-gradient(180deg, #0d0d0c 0%, #1a1a18 100%);
  color: #FFFFFF;
  position: relative;
  overflow: hidden;
}
.s4-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-width: 0;
}
.s4-round, .s4-meter { min-width: 0; }
.s4-round {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.s4-round-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9b9b95;
  font-weight: 500;
}
.s4-round-num {
  font-size: 16px;
  font-weight: 600;
  color: #FFFFFF;
  font-variant-numeric: tabular-nums;
}
.s4-round-num em {
  font-style: normal;
  color: #9b9b95;
  font-weight: 500;
}
.s4-round-dots {
  display: flex;
  gap: 5px;
  margin-left: 12px;
}
.s4-round-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2a2a28;
  border: 1px solid #3a3a37;
}
.s4-round-dot.passed { background: var(--m2-green); border-color: var(--m2-green); }
.s4-round-dot.failed { background: var(--m2-red); border-color: var(--m2-red); }
.s4-round-dot.active {
  background: transparent;
  border-color: var(--m2-orange);
  box-shadow: 0 0 0 2px rgba(232, 101, 26, 0.25);
  animation: m2-pulse-soft 2s ease-in-out infinite;
}
.s4-meter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.s4-meter-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9b9b95;
  font-weight: 500;
}
.s4-meter-value {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: #5FA85C;
  text-shadow: 0 0 6px rgba(95, 168, 92, 0.3);
}
.s4-meter-value.warn { color: #DAA520; text-shadow: 0 0 6px rgba(218, 165, 32, 0.4); }
.s4-meter-value.fail { color: #E8651A; text-shadow: 0 0 6px rgba(232, 101, 26, 0.5); }
.s4-meter-value.idle { color: #4a4a47; text-shadow: none; }

.s4-scope-area {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}
.s4-scope-view {
  position: relative;
  width: min(380px, 80%);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #2a2a26 0%, #161614 50%, #060604 100%);
  box-shadow:
    inset 0 0 50px rgba(255, 200, 140, 0.04),
    inset 0 0 0 2px rgba(255, 255, 255, 0.05),
    0 0 80px rgba(232, 101, 26, 0.08),
    0 8px 30px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.s4-scope-view::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.7'/></svg>");
  opacity: 0.06;
  pointer-events: none;
  mix-blend-mode: overlay;
}
.s4-scope-view::after {
  /* faint reticle ring at zone-A boundary (about 12% radius) */
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16%;
  height: 16%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 0.5px dashed rgba(232, 101, 26, 0.25);
  pointer-events: none;
}
.s4-scope-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Animations on scope-svg layer */
.s4-scope-svg.shake { animation: s4-scope-shake 0.4s ease-in-out; }
@keyframes s4-scope-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}
/* Cleaner sweep animation overlay */
.s4-sweep {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 50%;
}
.s4-sweep-bar {
  position: absolute;
  top: -20%;
  left: -10%;
  width: 120%;
  height: 30px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.15) 30%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0.15) 70%, transparent 100%);
  transform: rotate(-12deg);
  filter: blur(2px);
  opacity: 0;
}
.s4-sweep.run .s4-sweep-bar {
  animation: s4-sweep-pass 1.0s ease-in-out;
}
@keyframes s4-sweep-pass {
  0%   { opacity: 0; transform: translateY(-30px) rotate(-12deg); }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(140%) rotate(-12deg); }
}
/* IPA droplet drop */
.s4-droplet {
  position: absolute;
  top: 0;
  left: 50%;
  width: 14px;
  height: 18px;
  background: radial-gradient(circle at 50% 35%, rgba(180, 220, 255, 0.95), rgba(150, 200, 240, 0.6));
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  transform: translate(-50%, -200%);
  pointer-events: none;
  filter: blur(0.4px);
  box-shadow: inset 0 -2px 4px rgba(255, 255, 255, 0.3);
  opacity: 0;
}
.s4-droplet.drop {
  animation: s4-droplet-fall 0.7s cubic-bezier(0.45, 0, 0.55, 1) forwards;
}
@keyframes s4-droplet-fall {
  0%   { opacity: 0; transform: translate(-50%, -200%); }
  20%  { opacity: 1; }
  85%  { opacity: 1; transform: translate(-50%, 50%); }
  100% { opacity: 0; transform: translate(-50%, 50%) scale(2.6); }
}

/* Scope overlay (PASS / FAIL stamp) */
.s4-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-8deg) scale(0.7);
  font-family: 'Helvetica Neue', sans-serif;
  font-weight: 700;
  font-size: 56px;
  letter-spacing: 0.04em;
  padding: 4px 14px;
  border: 4px solid currentColor;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s var(--m2-ease-spring);
}
.s4-stamp.show { opacity: 0.85; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
.s4-stamp.pass { color: #5FA85C; }
.s4-stamp.fail { color: #E8651A; }

/* Tools row */
.s4-tools {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.s4-tool {
  background: #1f1f1d;
  border: 0.5px solid #2a2a28;
  border-radius: var(--m2-radius-md);
  padding: 12px 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  color: #FFFFFF;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}
.s4-tool:hover {
  background: #2a2a28;
  border-color: #3f3f3c;
  transform: translateY(-1px);
}
.s4-tool:active { transform: scale(0.97); }
.s4-tool.busy {
  pointer-events: none;
  opacity: 0.5;
}
.s4-tool.connect {
  background: var(--m2-orange);
  border-color: var(--m2-orange);
  color: #FFFFFF;
}
.s4-tool.connect:hover { background: var(--m2-orange-deep); border-color: var(--m2-orange-deep); }
.s4-tool-name {
  font-size: 12px;
  font-weight: 500;
}
.s4-tool-sub {
  font-size: 9.5px;
  color: #9b9b95;
  letter-spacing: 0.04em;
}
.s4-tool.connect .s4-tool-sub { color: rgba(255, 255, 255, 0.75); }
.s4-tool-svg { width: 26px; height: 18px; opacity: 0.85; }
@media (max-width: 580px) {
  .s4-tools { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .s4-tool { padding: 8px 4px; }
  .s4-tool-name { font-size: 10.5px; }
  .s4-tool-sub { display: none; }
}

/* Action log strip */
.s4-log {
  display: flex;
  gap: 5px;
  font-size: 10px;
  color: #9b9b95;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
  flex-wrap: wrap;
  min-height: 14px;
}
.s4-log-step {
  background: #2a2a28;
  border-radius: 999px;
  padding: 2px 8px;
  color: #d8d8d2;
}
.s4-log-step.miss { background: rgba(232, 101, 26, 0.25); color: #FFB69A; }
.s4-log-step.good { background: rgba(95, 168, 92, 0.25); color: #B6E3B3; }

/* Ferrule callout (zone legend) — now a sibling of .s4-scope-view, not
   a child, so the round overflow:hidden doesn't clip the labels. */
.s4-zones {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  color: #9b9b95;
  background: rgba(15, 15, 14, 0.85);
  padding: 8px 10px;
  border-radius: var(--m2-radius-sm);
  pointer-events: none;
  z-index: 2;
}
.s4-zones-row { display: flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.s4-zones-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Mode banner — also a sibling of scope-view so it doesn't get clipped. */
.s4-mode {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(232, 101, 26, 0.18);
  color: #FFB69A;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 16px);
  text-align: center;
  z-index: 2;
}
.s4-mode.tutorial { background: rgba(232, 101, 26, 0.18); color: #FFB69A; }
.s4-mode.probabilistic { background: rgba(95, 168, 92, 0.15); color: #B6E3B3; }

/* The scope-area now needs to host the absolute-positioned mode + zones */
.s4-scope-area { position: relative; }

/* Round-end card */
.s4-round-end {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 12, 0.85);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  text-align: center;
}
.s4-round-end.show { display: flex; }
.s4-round-end-stamp {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 18px;
  border: 4px solid currentColor;
  border-radius: 8px;
  animation: s4-stamp-in 0.35s var(--m2-ease-spring);
}
.s4-round-end-stamp.pass { color: #5FA85C; }
.s4-round-end-stamp.fail { color: #E8651A; }
@keyframes s4-stamp-in {
  from { opacity: 0; transform: rotate(-12deg) scale(0.6); }
  to   { opacity: 1; transform: rotate(-8deg) scale(1); }
}
.s4-round-end-num {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.s4-round-end-text {
  font-size: 13px;
  color: #d8d8d2;
  max-width: 360px;
  line-height: 1.55;
  margin: 0;
}
.s4-round-end-actions { display: flex; gap: 10px; margin-top: 4px; }

/* Session-end card (after 5 rounds) */
.s4-session-end {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 12, 0.96);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 32px 24px;
  text-align: center;
}
.s4-session-end.show { display: flex; }
.s4-session-tally {
  display: flex;
  gap: 10px;
}
.s4-session-tally-cell {
  background: #1f1f1d;
  border-radius: var(--m2-radius-md);
  padding: 12px 18px;
  min-width: 90px;
}
.s4-session-tally-num {
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: block;
  line-height: 1;
}
.s4-session-tally-num.passed { color: #5FA85C; }
.s4-session-tally-num.failed { color: #E8651A; }
.s4-session-tally-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9b9b95;
  margin-top: 4px;
  display: block;
}

/* ============================================================
   Mobile / desktop behaviors
   ============================================================ */
@media (min-width: 900px) {
  .m2-stage { padding: 18px 22px; }
  .m2-stage-card { box-shadow: var(--m2-shadow-lg); }
  .m2-title { font-size: 19px; }
  .m2-caption { padding: 12px 22px 6px; min-height: 52px; }
  .m2-caption-text { font-size: 14.5px; }
}

/* ============================================================
   Phone-specific tightening (≤480px)
   ============================================================ */
@media (max-width: 480px) {
  /* Header: shrink padding + collapse "incidents" label to just the count */
  .m2-header { padding: 10px 12px 4px; gap: 8px; }
  .m2-incidents { padding: 5px 9px; font-size: 11.5px; gap: 5px; }
  .m2-incidents-label { display: none; }
  .m2-back, .m2-theme-toggle, .m2-voice-toggle { width: 32px; height: 32px; }
  .m2-title { font-size: 16px; }
  .m2-eyebrow { font-size: 10px; }

  /* Stage: tighter outer gutter */
  .m2-stage { padding: 8px 10px; }
  .m2-stage-card { border-radius: 12px; }

  /* Caption: smaller and tighter */
  .m2-caption { padding: 6px 12px 2px; min-height: 40px; }
  .m2-caption-text { font-size: 12.5px; }

  /* Day plan: tighter on phone */
  .m2-plan { padding: 4px 10px 0; gap: 6px; }
  .m2-plan-toggle { padding: 8px 12px; font-size: 12.5px; }
  .m2-plan-toggle-label { font-size: 9px; }
  .m2-ts-step { padding: 9px 11px; }
  .m2-ts-num { font-size: 9px; letter-spacing: 0.06em; }
  .m2-ts-name { font-size: 12.5px; }
  .m2-ts-tag { display: none; }

  /* Help button: a touch smaller in the corner */
  .m2-help-btn { width: 28px; height: 28px; top: 8px; right: 8px; }
  .m2-help-btn svg { width: 16px; height: 16px; }

  /* Scene 1 — panel grid tighter */
  .s1-root { padding: 12px; gap: 12px; }
  .s1-panel-wrap { padding: 12px; gap: 8px; }
  .s1-panel-grid { gap: 5px; }
  .s1-port { padding: 8px 5px; gap: 4px; }
  .s1-port-id { font-size: 9px; }
  .s1-port-cap { width: 28px; height: 7px; }
  .s1-port-cable { width: 24px; height: 5px; }
  .s1-port-clip { width: 10px; height: 6px; }
  .s1-port-status { font-size: 8.5px; padding: 1px 3px; }
  .s1-panel-label { font-size: 8.5px; gap: 6px; }
  .s1-opm { padding: 10px; }
  .s1-opm-display { font-size: 18px; padding: 8px 10px; min-height: 38px; }
  .s1-opm-help { font-size: 10px; }
  .s1-info { font-size: 10.5px; padding: 8px 10px; }
  .s1-action-row .m2-btn { padding: 9px 10px; font-size: 12px; }

  /* Scene 2 — bench tighter, toolbar grid wraps */
  .s2-root { padding: 12px; gap: 10px; }
  .s2-bench { padding: 12px; }
  .s2-toolbar { padding: 8px; gap: 8px; }
  .s2-tool {
    flex: 1 1 calc(33.33% - 8px);
    min-width: 0;
    padding: 8px 4px;
  }
  .s2-tool-svg { width: 32px; height: 22px; }
  .s2-tool-name { font-size: 10.5px; }
  .s2-tool-spec { font-size: 8.5px; }
  .s2-bench-instruction { font-size: 11px; padding: 6px 10px; bottom: 10px; }
  .s2-stage-label { font-size: 10px; padding: 4px 8px; top: 6px; right: 6px; }

  /* Scene 3 — slider lab */
  .s3-root { padding: 12px; gap: 10px; }
  .s3-stage { padding: 14px; }
  .s3-controls { padding: 12px; }
  .s3-readout { top: 8px; left: 8px; padding: 6px 9px; }
  .s3-readout-value { font-size: 14px; }
  .s3-quiz-overlay { padding: 14px; gap: 12px; }
  .s3-quiz-question { font-size: 13px; }

  /* Scene 4 — IBC simulator */
  .s4-root { padding: 12px; gap: 8px; }
  .s4-scope-view { width: min(300px, 92%); }
  .s4-round-label, .s4-meter-label { font-size: 9px; }
  .s4-round-num, .s4-meter-value { font-size: 14px; }
  .s4-round-dots { margin-left: 8px; gap: 4px; }
  .s4-round-dot { width: 8px; height: 8px; }
  /* Mode banner: compact and allow wrap on extreme widths */
  .s4-mode {
    font-size: 9.5px;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    top: 4px;
    white-space: normal;
    line-height: 1.3;
  }
  /* Zones legend: collapse to a tight horizontal row at the bottom of the
     scope area instead of the floating right-corner card */
  .s4-zones {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 6px 10px;
    background: transparent;
    color: #888880;
    font-size: 9.5px;
    margin-top: 4px;
  }
  .s4-zones-row { gap: 4px; }
  .s4-zones-dot { width: 7px; height: 7px; }
  /* Tools row: keep 5 columns but compact */
  .s4-tools { gap: 5px; }
  .s4-tool { padding: 8px 3px; }
  .s4-tool-name { font-size: 10.5px; }
  .s4-tool-svg { width: 22px; height: 14px; }

  /* Round-end + session-end card text scaled */
  .s4-round-end-stamp { font-size: 42px; padding: 2px 14px; border-width: 3px; }
  .s4-round-end-num { font-size: 22px; }
  .s4-round-end-text { font-size: 12px; }
  .s4-session-tally-cell { padding: 10px 14px; min-width: 76px; }
  .s4-session-tally-num { font-size: 22px; }

  /* Overlays: tighter padding and smaller titles */
  .m2-overlay { padding: 14px; }
  .m2-overlay-card { padding: 22px 20px 18px; border-radius: 18px; }
  .m2-overlay-title { font-size: 19px; }
  .m2-overlay-prompt { font-size: 13.5px; }
  .m2-overlay-quote { font-size: 13px; padding: 11px 13px; }
  .m2-tour-actions, .m2-overlay-actions { gap: 6px; }
  .m2-tour-actions .m2-btn { padding: 8px 12px; font-size: 12px; }

  /* Landing CTA on phone */
  .m2-landing { padding: 22px 16px; gap: 12px; }
  .m2-landing-icon { width: 60px; height: 60px; }
  .m2-landing-title { font-size: 20px; }
  .m2-landing-body { font-size: 13.5px; }
  .m2-landing-actions { flex-direction: column; width: 100%; }
  .m2-landing-actions .m2-btn { width: 100%; }
}

/* Very narrow phones (≤360px) — extra-tight */
@media (max-width: 360px) {
  .m2-eyebrow { display: none; }
  .m2-incidents { padding: 4px 8px; }
  .s1-port-cap { width: 24px; }
  .s1-port-cable { width: 20px; }
  .s4-tools { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .s4-tool { padding: 7px 2px; }
}

/* Reduce motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
