/* ============================================================
   responsive.css — any screen size, any device
   ------------------------------------------------------------
   Loaded AFTER style.css. Two parts:
   A. App-wide: real screen height on phones (dvh), notch/safe
      areas, touch-friendly behaviour.
   B. THERAPY MODE (body.therapy-mode): each therapy step fills
      the screen exactly — no page scrolling. responsive.js
      scales the content of the "fit areas" to the space.
   Many therapy elements have inline styles, so some rules here
   use !important on purpose to override them.
   ============================================================ */

/* ---------- A. APP-WIDE ---------- */
html, body { height: 100%; }
body {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;            /* no double-tap zoom delay on tablets/phones */
  overscroll-behavior: none;             /* no "rubber band" bounce of the whole app */
}
/* Phones: 100vh includes the browser bars; dvh is the real visible height */
.app-shell { height: 100vh; height: 100dvh; }
.login-wrap { min-height: 100vh; min-height: 100dvh; }

/* Respect notches / rounded corners / home indicator (iPhone, Android) */
.app-shell {
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.content { padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)); }

/* Buttons and controls easy to hit with a finger */
button, .btn, .btn-small, select, input[type=checkbox], input[type=radio] { touch-action: manipulation; }
@media (pointer: coarse) {
  .btn-small { min-height: 38px; }
  .nav-item { min-height: 42px; }
  .therapy-btn { min-height: 48px; }
}

/* Fit engine (responsive.js): the slot takes the place in the layout,
   the box inside is drawn at "design size" and scaled to the slot. */
.fit-slot { position: relative; flex: 1 1 0; min-height: 0; min-width: 0; width: 100%; overflow: hidden; }
.fit-box {
  position: absolute !important; top: 0; left: 0;
  transform-origin: 0 0;
  margin: 0 !important; flex: none !important;
  max-width: none !important; max-height: none !important; min-height: 0 !important;
}
/* Used only when a list is too long to shrink further: that area scrolls, nothing else */
.fit-scroll { overflow-y: auto !important; -webkit-overflow-scrolling: touch; }

/* ---------- B. THERAPY MODE ---------- */
/* The menu is hidden while a therapy step is open: the step gets the whole screen.
   "End Session" (and the small 🔒) are in every step's header. */
body.therapy-mode .sidebar { display: none !important; }

body.therapy-mode .content {
  max-width: none !important;
  height: 100% !important;
  overflow: hidden !important;
  padding: clamp(6px, 1.2vmin, 16px) clamp(8px, 2vmin, 24px) max(clamp(6px, 1.2vmin, 16px), env(safe-area-inset-bottom, 0px)) !important;
}
body.therapy-mode .screen.active {
  height: 100%;
  min-height: 0 !important;
  overflow: hidden;
  animation: none;   /* the slide-in animation briefly makes the screen taller */
}

/* Every step is a column that is exactly the screen height */
body.therapy-mode .screen.active > .therapy-shell {
  height: 100% !important;
  max-height: 100% !important;
  width: 100% !important;
  max-width: min(1500px, 100%) !important;
  margin: 0 auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: clamp(4px, 1vmin, 12px) !important;
  min-height: 0 !important;
  overflow: hidden !important;
  padding-bottom: 0 !important;
}

/* Header: name on the left, tools on the right, one compact row */
body.therapy-mode .therapy-top {
  flex-wrap: nowrap !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 8px !important;
  min-height: 0;
}
body.therapy-mode .therapy-info { min-width: 64px; flex: 1 1 auto; }
body.therapy-mode .therapy-child-label,
body.therapy-mode .therapy-target-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
body.therapy-mode .therapy-tools {
  flex-wrap: nowrap !important;
  overflow-x: auto;
  scrollbar-width: none;
  margin-top: 0 !important;
  width: auto !important;
  justify-content: flex-start !important;   /* + auto margin below: right-aligned, but still scrollable when too many */
  max-width: 75%;
}
body.therapy-mode .therapy-tools > :first-child { margin-left: auto; }
body.therapy-mode .therapy-tools::-webkit-scrollbar { display: none; }
body.therapy-mode .therapy-tools > * { flex-shrink: 0; }
.tm-lock-btn { display: none; }
body.therapy-mode .tm-lock-btn { display: inline-flex; align-items: center; justify-content: center; }

/* Fixed-size parts never shrink; the stage takes whatever height is left */
body.therapy-mode .therapy-top,
body.therapy-mode .token-bar-row,
body.therapy-mode .reward-preview,
body.therapy-mode .therapy-tally,
body.therapy-mode .therapy-controls,
body.therapy-mode .banner { flex-shrink: 0 !important; margin-top: 0 !important; margin-bottom: 0 !important; }

body.therapy-mode .therapy-stage {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* Scoring buttons: always 3 side by side (stacking them would push the picture off screen) */
body.therapy-mode .therapy-controls { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: clamp(4px, 1vmin, 12px) !important; }
body.therapy-mode .therapy-shell.baseline-mode .therapy-controls { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
body.therapy-mode #handwriting-scoring-controls { grid-template-columns: 1fr !important; }
body.therapy-mode .therapy-btn {
  padding: clamp(8px, 1.8vmin, 20px) 6px !important;
  font-size: clamp(13px, 2vmin, 18px) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.therapy-mode .therapy-tally { padding: 4px 8px !important; font-size: clamp(11px, 1.6vmin, 14px) !important; }
body.therapy-mode .token-bar-row { padding-top: 0 !important; padding-bottom: 0 !important; min-height: 0 !important; }

/* ----- Ear training ----- */
body.therapy-mode #screen-ear-training .therapy-stage {
  padding: clamp(6px, 1.5vmin, 20px) !important;
  gap: clamp(6px, 1.2vmin, 14px) !important;
}
body.therapy-mode #screen-ear-training .therapy-stage > div:first-child { flex-shrink: 0; flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; justify-content: center; }
body.therapy-mode #screen-ear-training .therapy-stage > div:first-child > * { flex-shrink: 0; }
body.therapy-mode #ear-body {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  width: 100% !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}
body.therapy-mode #ear-body > * { flex-shrink: 0; max-width: none; }

/* ----- Isolation ----- */
body.therapy-mode #screen-isolation .therapy-stage {
  padding: clamp(6px, 1.5vmin, 20px) !important;
  gap: clamp(6px, 1.5vmin, 20px) !important;
  min-height: 0 !important;
}
body.therapy-mode #screen-isolation .therapy-stage > div { min-height: 0 !important; }
body.therapy-mode #screen-isolation .therapy-stage img { max-width: 100% !important; max-height: 100% !important; }
/* The tall bottom block (goal text, buttons, tally) */
body.therapy-mode #screen-isolation .therapy-shell > div:last-child { padding: 0 !important; flex-shrink: 0; }
body.therapy-mode #iso-info-text { margin-bottom: clamp(4px, 1vmin, 12px) !important; font-size: clamp(11px, 1.6vmin, 14px) !important; }
body.therapy-mode #screen-isolation .therapy-shell > div:last-child > div[style*="grid"] { gap: clamp(4px, 1vmin, 12px) !important; }
body.therapy-mode #screen-isolation .therapy-btn { padding: clamp(8px, 1.8vmin, 16px) 6px !important; }
body.therapy-mode #iso-tally { margin-top: clamp(4px, 1vmin, 12px) !important; }
body.therapy-mode #iso-token-bar-wrap { margin-top: 4px !important; }
/* Clinical guide: the header stays as one line; the guide opens as a panel ON TOP of the
   step (with its own scroll) instead of pushing the step off the screen */
body.therapy-mode #iso-clinical-guide { margin: 0 !important; position: relative; overflow: visible !important; flex-shrink: 0; }
body.therapy-mode #iso-clinical-guide > button { padding: clamp(6px, 1.2vmin, 14px) 14px !important; }
body.therapy-mode #iso-guide-content {
  position: absolute;
  left: 0; right: 0; bottom: calc(100% + 6px);
  max-height: min(70dvh, 560px) !important;
  overflow-y: auto !important;
  background: #f5f5f7;
  border: 1px solid #d2d2d7;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  padding-top: 14px !important;
  z-index: 50;
}

/* ----- Syllables / phrases / sentences ----- */
body.therapy-mode #screen-syllable .therapy-stage { padding: clamp(6px, 1.2vmin, 12px) !important; }
body.therapy-mode #syl-grid-container { flex: 1 1 0 !important; min-height: 0 !important; height: auto !important; overflow: hidden; }
body.therapy-mode #screen-syllable .therapy-shell > div[style*="justify-content: center"] { margin-top: 0 !important; }
body.therapy-mode #syl-record-btn, body.therapy-mode #syl-play-rec-btn { padding: clamp(6px, 1.2vmin, 10px) 18px !important; }

/* ----- Story ----- */
body.therapy-mode #screen-story .therapy-shell > div[style*="text-align: center"]:not(#story-finish-wrap) { padding: 0 !important; flex-shrink: 0; }
body.therapy-mode #story-title { margin-bottom: clamp(4px, 0.8vmin, 8px) !important; font-size: clamp(15px, 2.4vmin, 24px) !important; }
body.therapy-mode #story-title span { font-size: clamp(10px, 1.4vmin, 13px) !important; padding: 3px 10px !important; }
body.therapy-mode #screen-story .therapy-shell > div[style*="text-align: center"] > div[style*="margin-bottom: 12px"] { margin-bottom: clamp(4px, 0.8vmin, 12px) !important; }
body.therapy-mode #story-phase-tracker button { padding: clamp(4px, 1vmin, 8px) clamp(10px, 2vmin, 20px) !important; font-size: clamp(12px, 1.7vmin, 14px) !important; }
body.therapy-mode #story-next-phase-btn { padding: clamp(4px, 1vmin, 8px) 20px !important; }
body.therapy-mode #screen-story .therapy-shell > div > div[style*="margin-top: 10px"] { margin-top: clamp(4px, 0.8vmin, 10px) !important; }
body.therapy-mode #screen-story .therapy-stage { overflow: hidden !important; padding: clamp(6px, 1.2vmin, 12px) !important; display: flex !important; align-items: center !important; justify-content: center !important; }
body.therapy-mode #story-panels-container { width: 100% !important; }
body.therapy-mode #story-finish-wrap { margin-top: 0 !important; }
body.therapy-mode #story-finish-wrap > div { margin-bottom: 6px !important; padding: 6px 12px !important; }
body.therapy-mode #story-finish-wrap > button { padding: clamp(8px, 1.6vmin, 14px) 24px !important; }

/* ----- Word level ----- */
body.therapy-mode #screen-therapy .therapy-stage { padding: clamp(6px, 1.5vmin, 16px) !important; gap: clamp(4px, 1vmin, 12px) !important; }
body.therapy-mode #handwriting-mode-ui { flex: 1 1 0; min-height: 0; overflow: hidden; padding: clamp(8px, 2vmin, 20px) !important; }
body.therapy-mode .reward-preview { font-size: 11px; padding: 0 !important; }

/* Big round buttons over pictures (play / record) scale with the screen */
body.therapy-mode .therapy-image-wrap > div[style*="position: absolute"] button,
body.therapy-mode #screen-isolation .therapy-stage button[style*="border-radius: 50%"] {
  width: clamp(40px, 7vmin, 60px) !important;
  height: clamp(40px, 7vmin, 60px) !important;
}
body.therapy-mode .therapy-image-wrap > div[style*="position: absolute"] { top: 8px !important; right: 8px !important; gap: 8px !important; }

/* ----- Guided assessment ----- */
body.therapy-mode #screen-guided-assessment { display: none; }
body.therapy-mode #screen-guided-assessment.active { display: flex !important; flex-direction: column; }
body.therapy-mode #screen-guided-assessment .page-header { margin-bottom: clamp(4px, 1vmin, 16px) !important; flex-shrink: 0; }
body.therapy-mode #screen-guided-assessment .page-header button { margin-bottom: 4px !important; }
body.therapy-mode #screen-guided-assessment .page-header h1 { font-size: clamp(16px, 2.6vmin, 28px) !important; }
body.therapy-mode .guided-fit { display: flex; align-items: center; justify-content: center; padding: 4px; }
body.therapy-mode .guided-fit > .card { margin: 0 auto !important; padding: clamp(14px, 3vmin, 32px) !important; }

/* ============================================================
   PHONE / SMALL TABLET HELD SIDEWAYS (short and wide screens)
   Picture area on the left, header + scoring on the right,
   so the picture can be big and the buttons are still visible.
   ============================================================ */
@media (orientation: landscape) and (max-height: 560px) {
  body.therapy-mode #screen-therapy > .therapy-shell,
  body.therapy-mode #screen-syllable > .therapy-shell,
  body.therapy-mode #screen-isolation > .therapy-shell,
  body.therapy-mode #screen-story > .therapy-shell {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) clamp(220px, 34vw, 340px);
    /* right column: up to 10 rows sized to their content; the last row takes the rest */
    grid-template-rows: repeat(10, min-content) 1fr;
    grid-auto-flow: row dense;
    column-gap: clamp(8px, 2vmin, 16px) !important;
    row-gap: 6px !important;
  }
  body.therapy-mode #screen-therapy > .therapy-shell > *,
  body.therapy-mode #screen-syllable > .therapy-shell > *,
  body.therapy-mode #screen-isolation > .therapy-shell > *,
  body.therapy-mode #screen-story > .therapy-shell > * { grid-column: 2; min-width: 0; }
  /* left column: the picture / stage area, full height */
  body.therapy-mode #screen-therapy > .therapy-shell > .fit-slot,
  body.therapy-mode #screen-syllable > .therapy-shell > .therapy-stage,
  body.therapy-mode #screen-isolation > .therapy-shell > .fit-slot-stage,
  body.therapy-mode #screen-story > .therapy-shell > .fit-slot-stage {
    grid-column: 1;
    grid-row: 1 / -1;
    min-height: 0 !important;
    height: auto !important;
    align-self: stretch;
  }
  /* Header in the narrow right column: name above the tools */
  body.therapy-mode .therapy-top { flex-wrap: wrap !important; }
  body.therapy-mode .therapy-tools { max-width: 100% !important; width: 100% !important; justify-content: flex-start !important; flex-wrap: wrap !important; overflow: visible !important; gap: 6px !important; }
  body.therapy-mode .therapy-tools > :first-child { margin-left: 0; }
  /* Scoring buttons stacked in the right column */
  body.therapy-mode #screen-therapy .therapy-controls,
  body.therapy-mode #screen-syllable .therapy-controls,
  body.therapy-mode #screen-isolation .therapy-shell > div:last-child > div[style*="grid"],
  body.therapy-mode #screen-therapy .therapy-shell.baseline-mode .therapy-controls { grid-template-columns: 1fr !important; }
  body.therapy-mode .therapy-btn { padding: 8px 6px !important; }
  /* Isolation: the two pictures side by side inside the left area */
  body.therapy-mode #screen-isolation .therapy-stage { grid-template-columns: 1fr 1fr !important; }
  body.therapy-mode #iso-guide-content { position: fixed; left: 8px; right: 8px; bottom: 8px; top: 8px; max-height: none !important; }
  /* Ear training: exercise on the left (full height), round buttons stacked on the right */
  body.therapy-mode #screen-ear-training > .therapy-shell {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) clamp(150px, 22vw, 220px);
    grid-template-rows: min-content 1fr;
    column-gap: 10px !important; row-gap: 8px !important;
  }
  body.therapy-mode #screen-ear-training .therapy-stage { display: contents !important; }
  body.therapy-mode #screen-ear-training .therapy-top { grid-column: 2; grid-row: 1; }
  body.therapy-mode #screen-ear-training .therapy-stage > div:first-child {
    grid-column: 2; grid-row: 2; align-self: start;
    flex-direction: column !important; flex-wrap: nowrap !important; overflow: visible !important; gap: 6px !important;
  }
  body.therapy-mode #screen-ear-training .therapy-stage > div:first-child > button { width: 100%; }
  /* 2026-12-05 night check: the 5 step circles did not fit under the tools (step 5 was off the screen) ->
     small rows: circle + step name side by side, no connecting lines */
  body.therapy-mode #screen-ear-training .therapy-stage > div.es-bar:first-child { gap: 2px !important; }
  body.therapy-mode #screen-ear-training .es-bar > .btn-small { flex: 0 0 auto !important; flex-direction: row !important; justify-content: flex-start !important;
    gap: 7px !important; height: 28px !important; min-height: 0 !important; padding: 0 4px !important; }
  body.therapy-mode #screen-ear-training .es-bar > .btn-small::before { display: none !important; }
  body.therapy-mode #screen-ear-training .es-bar .es-n { width: 24px !important; height: 24px !important; font-size: 12px !important; box-shadow: none !important; }
  body.therapy-mode #screen-ear-training .es-bar .es-l { font-size: 12px !important; text-align: left; }
  body.therapy-mode #screen-ear-training .therapy-stage > .fit-slot {
    grid-column: 1; grid-row: 1 / -1; height: auto;
    background: white; border: 1px solid var(--border-light); border-radius: var(--radius);
  }
  /* Story: compact controls in the right column */
  body.therapy-mode #story-phase-tracker { display: flex !important; flex-wrap: wrap; justify-content: center; border-radius: 16px !important; }
  body.therapy-mode #story-title { font-size: 15px !important; }
}

/* ============================================================
   PHONE HELD UPRIGHT (narrow screens)
   ============================================================ */
@media (orientation: portrait) and (max-width: 700px) {
  /* Isolation: the two pictures one above the other */
  body.therapy-mode #screen-isolation .therapy-stage { grid-template-columns: 1fr !important; grid-template-rows: 1fr 1fr; }
  body.therapy-mode .therapy-tools { max-width: 70%; }
  body.therapy-mode .therapy-tools .btn-small { padding: 6px 10px !important; font-size: 12px !important; }
  /* Story: tighter sentence boxes so the 4 panels can sit 2 x 2 */
  body.therapy-mode #story-panels-container { gap: 8px !important; }
  body.therapy-mode #story-panels-container > div { padding: 6px !important; gap: 6px !important; }
  body.therapy-mode #story-panels-container [id^="story-text-"] { font-size: 13px !important; line-height: 1.3 !important; padding: 6px !important; }
}

/* ============================================================
   PHONES & SMALL TABLETS: ☰ MENU
   (replaces the old horizontal strip, which hid Sign Out / Lock /
   Change Password / workspace). Desktop layout is unchanged.
   ============================================================ */
.mobile-topbar, .nav-backdrop { display: none; }
@media (max-width: 900px) {
  .app-shell { flex-direction: column !important; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
    padding: 8px 12px; min-height: 52px;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
  }
  .mt-menu-btn {
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
    background: white; font-size: 20px; line-height: 1; cursor: pointer; flex-shrink: 0;
  }
  .mt-logo { height: 28px; width: auto; }
  .mt-title { font-weight: 600; font-size: 15px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* The full side menu becomes a drawer */
  .sidebar {
    position: fixed !important; top: 0; left: 0; bottom: 0;
    width: min(300px, 85vw) !important; height: 100% !important;
    flex-direction: column !important; align-items: stretch !important;
    padding: max(16px, env(safe-area-inset-top, 0px)) 14px max(16px, env(safe-area-inset-bottom, 0px)) !important;
    overflow-y: auto !important; overflow-x: hidden !important;
    background: #ffffff !important;
    border-right: 1px solid var(--border-light) !important; border-bottom: none !important;
    transform: translateX(-105%); transition: transform 0.25s ease;
    z-index: 5000; gap: 0 !important;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,0.25); }
  .sidebar-brand, .workspace-switcher, .sidebar-footer { display: block !important; }
  .sidebar-footer { display: flex !important; }
  .sidebar-nav { flex-direction: column !important; overflow: visible !important; flex: none !important; padding-bottom: 12px !important; }
  .nav-item { width: 100% !important; white-space: normal !important; padding: 12px !important; font-size: 15px !important; }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 4999; }
  body.nav-open .nav-backdrop { display: block; }
  .content { padding: 12px 12px max(24px, env(safe-area-inset-bottom, 0px)) !important; }

  /* Setup screens on phones: button rows wrap instead of running off the screen */
  .screen .btn { white-space: normal; text-align: center; }
  .screen div[style*="display: flex"]:not([style*="flex-direction: column"]):not([style*="flex-direction:column"]), .screen div[style*="display:flex"]:not([style*="flex-direction: column"]):not([style*="flex-direction:column"]) { flex-wrap: wrap; }
  body.therapy-mode .screen div[style*="display: flex"], body.therapy-mode .screen div[style*="display:flex"] { flex-wrap: revert-layer; }
  /* Wide tables (audit log) scroll sideways inside their own box */
  #audit-list { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Therapy steps: no top bar at all — the step gets the whole screen */
  body.therapy-mode .mobile-topbar { display: none; }
}

/* ============================================================
   RECORDING INDICATOR (see setRecordingUI in platform.js)
   While recording: red STOP button that pulses + "● REC 0:05".
   ============================================================ */
@keyframes recPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.65); }
  70%  { box-shadow: 0 0 0 14px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}
@keyframes recDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.rec-active {
  background: #ff3b30 !important;
  color: #ffffff !important;
  animation: recPulse 1.2s infinite !important;
  position: relative;
  overflow: visible !important;
}
/* Round mic buttons: the timer label sits to the left of the button */
.rec-active.rec-round::after {
  content: "\25CF  " attr(data-rec-time);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #ffffff;
  color: #d70015;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.3px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 2px solid #ff3b30;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.rec-active:not(.rec-round) { font-variant-numeric: tabular-nums; }

/* While something is being dragged in a therapy step: the page must not scroll, bounce or select text */
html.slpa-dragging, html.slpa-dragging body { overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; }
body.therapy-mode .ear-word-tile, body.therapy-mode #ear-s1-cow { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }

/* ---------- Phone camera scanner (smsscan.js, 2026-11-22) ----------
   The camera picture is BEHIND the app: while scanning, everything is made see-through
   except the scanning frame and the Cancel button. */
html.slpa-scanning, html.slpa-scanning body, html.slpa-scanning #main-app, html.slpa-scanning .main-content {
  background: transparent !important; background-image: none !important;
}
html.slpa-scanning body > *:not(#slpa-scan-ui) { visibility: hidden !important; }
#slpa-scan-ui { position: fixed; inset: 0; z-index: 2147483000; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px calc(env(safe-area-inset-bottom, 0px) + 22px); pointer-events: none; font-family: var(--font-ui, system-ui, sans-serif); }
#slpa-scan-ui .ss-top { pointer-events: auto; background: rgba(10, 14, 22, 0.72); color: #fff; border-radius: 14px; padding: 12px 18px; text-align: center; max-width: 420px; }
#slpa-scan-ui .ss-top strong { display: block; font-size: 17px; }
#slpa-scan-ui .ss-top .ss-note { display: block; font-size: 13.5px; opacity: .85; margin-top: 2px; }
#slpa-scan-ui .ss-frame { position: relative; width: min(72vw, 300px); aspect-ratio: 1; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(10, 14, 22, 0.38); }
#slpa-scan-ui .ss-frame i { position: absolute; width: 34px; height: 34px; border: 4px solid #ffffff; }
#slpa-scan-ui .ss-frame i:nth-child(1) { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-radius: 16px 0 0 0; }
#slpa-scan-ui .ss-frame i:nth-child(2) { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-radius: 0 16px 0 0; }
#slpa-scan-ui .ss-frame i:nth-child(3) { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-radius: 0 0 0 16px; }
#slpa-scan-ui .ss-frame i:nth-child(4) { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-radius: 0 0 16px 0; }
#slpa-scan-ui .ss-bottom { pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 420px; }
#slpa-scan-ui .ss-cancel { min-width: 200px; padding: 14px 28px; border: 0; border-radius: 999px; background: #ffffff; color: #111827; font: 700 17px var(--font-ui, system-ui, sans-serif); box-shadow: 0 6px 20px rgba(0,0,0,0.35); cursor: pointer; }
#slpa-scan-ui .ss-help { color: #fff; font-size: 12.5px; text-align: center; background: rgba(10, 14, 22, 0.6); padding: 6px 12px; border-radius: 10px; }
#slpa-scan-ui .ss-top, #slpa-scan-ui .ss-bottom { position: relative; z-index: 2; }

/* 2026-12-05 (Natanael's phone test): Therapy Setup on a phone / small screen. The "No assessment / baseline" box sits above the
   lists and squeezed the sound + step lists to almost nothing, and the window could not scroll. Here the WHOLE window scrolls
   and every part keeps its natural height (setup screens may scroll — therapy screens never). */
@media (max-width: 700px), (max-height: 700px) {
  #therapy-setup-modal > .modal-card { max-height: calc(100dvh - 16px) !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  #therapy-setup-modal > .modal-card > * { flex-shrink: 0 !important; }
  #therapy-setup-modal > .modal-card > div[style*="flex: 1"] { flex: none !important; overflow: visible !important; min-height: auto !important; }
  #therapy-setup-modal > .modal-card > div[style*="flex: 1"] [style*="min-height: 0"] { min-height: auto !important; }
  #therapy-setup-modal .sb-banner { margin-left: 12px !important; margin-right: 12px !important; padding: 10px 12px !important; font-size: 13px !important; }
  #therapy-setup-modal .sb-banner button { padding: 8px 12px !important; font-size: 13px !important; }
}
