/* ============================================================================
   Soda Bash — Mobile UI
   A touch-first shell for phones. Everything here is gated behind
   `html.sb-mobile`, a class added by mobile.js only on touch/phone devices, so
   the desktop layout is never affected.

   Design language is inherited from the desktop app (dark neon, Space Mono /
   Space Grotesk, color-coded materials). The mobile additions:
     · a slim translucent top bar (history + framing)
     · a thumb-zone bottom bar (mode + the glowing Simulate button)
     · a build dock (color-coded material palette) shown while editing
     · bottom sheets for Models, Build extras, Properties, Settings, Wave
   Touch targets are >= 48px, spaced >= 8px, primary actions sit low.
   ========================================================================== */

html.sb-mobile,
html.sb-mobile body { overflow: hidden; overscroll-behavior: none; }

/* Real visible height, set by JS (--app-h). dvh is the no-JS fallback. */
:root { --app-h: 100dvh; }
.sb-mobile {
  --m-bg:        #0a0c14;
  --m-panel:     rgba(13,15,24,.94);
  --m-panel-sld: #0d0f18;
  --m-border:    #232842;
  --m-border-hi: #2e3450;
  --m-tap:       48px;            /* minimum comfortable target */
  --m-radius:    14px;
  --m-safe-t:    env(safe-area-inset-top, 0px);
  --m-safe-b:    env(safe-area-inset-bottom, 0px);
  --m-safe-l:    env(safe-area-inset-left, 0px);
  --m-safe-r:    env(safe-area-inset-right, 0px);
  font-size: 12px;
}

/* ── Full-bleed canvas; desktop chrome removed ───────────────────────────── */
.sb-mobile #app { display: block; width: 100vw; height: var(--app-h); }
.sb-mobile #header,
.sb-mobile #sidebar,
.sb-mobile #statusbar,
.sb-mobile #wave-dock,
.sb-mobile #cam-panel,
.sb-mobile #tool-stack { display: none !important; }

.sb-mobile #canvas-wrap {
  position: fixed; inset: 0;
  width: 100vw; height: var(--app-h);
  touch-action: none;                 /* we own every canvas gesture */
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.sb-mobile canvas#canvas { width: 100%; height: 100%; }

/* The mobile UI layer floats over the canvas but lets touches fall through to
   the canvas everywhere except on actual controls. */
.sb-mobile #mobile-ui { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
.sb-mobile #mobile-ui > * { pointer-events: auto; }

.sb-mobile button { font-family: var(--mono); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.sb-mobile #m-top {
  position: absolute; top: 0; left: 0; right: 0;
  height: calc(52px + var(--m-safe-t));
  padding: var(--m-safe-t) calc(8px + var(--m-safe-r)) 0 calc(8px + var(--m-safe-l));
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(180deg, rgba(10,12,20,.92) 0%, rgba(10,12,20,.72) 70%, rgba(10,12,20,0) 100%);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.sb-mobile #m-logo {
  font-family: var(--sans); font-weight: 600; font-size: 20px; letter-spacing: .02em;
  color: var(--node); text-shadow: 0 0 16px #00c89655; white-space: nowrap;
  margin-left: 2px; pointer-events: none;
}
.sb-mobile #m-logo span { color: var(--dim); font-weight: 300; }
.sb-mobile .m-top-right { margin-left: auto; display: flex; gap: 6px; }

.sb-mobile .m-icon-btn {
  width: var(--m-tap); height: var(--m-tap);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--m-border); border-radius: 11px;
  background: rgba(13,15,24,.6); color: var(--text);
  font-size: 19px; line-height: 1; transition: border-color .12s, color .12s, background .12s;
}
.sb-mobile .m-icon-btn:active { background: rgba(0,200,150,.14); border-color: var(--node); color: var(--node); }
.sb-mobile .m-icon-btn:disabled { opacity: .32; }
/* Examine: desktop's wave-header button is hidden on mobile (the dock-bar button covers it). */
.sb-mobile #wave-examine-btn { display: none !important; }
.sb-mobile #m-examine-btn.on { border-color: #2dd4bf; color: #2dd4bf; background: rgba(45,212,191,.16); }

/* ── Bottom bar (thumb zone) ─────────────────────────────────────────────── */
.sb-mobile #m-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px calc(12px + var(--m-safe-r)) calc(10px + var(--m-safe-b)) calc(12px + var(--m-safe-l));
  display: flex; align-items: flex-end; gap: 10px;
  background: linear-gradient(0deg, rgba(8,9,14,.94) 30%, rgba(8,9,14,.55) 75%, rgba(8,9,14,0) 100%);
}

/* Edit / Move segmented control */
.sb-mobile #m-modeseg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--m-panel); border: 1px solid var(--m-border);
  border-radius: var(--m-radius); backdrop-filter: blur(6px);
}
.sb-mobile .m-mode {
  min-width: 62px; height: 44px; padding: 0 12px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--dim); font-size: 12px; letter-spacing: .02em;
  transition: all .14s;
}
.sb-mobile .m-mode .ic { font-size: 15px; }
.sb-mobile .m-mode[data-mode="edit"].active { color: var(--node);   border-color: var(--node);   background: rgba(0,200,150,.12); text-shadow: 0 0 8px #00c89650; }
.sb-mobile .m-mode[data-mode="move"].active { color: var(--spring); border-color: var(--spring); background: rgba(14,184,212,.12); }

.sb-mobile .m-grow { flex: 1; }

/* Reset button (only while simulating) */
.sb-mobile #m-reset {
  display: none; height: 52px; padding: 0 16px;
  align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--m-border); border-radius: var(--m-radius);
  background: var(--m-panel); color: var(--dim); font-size: 13px;
  backdrop-filter: blur(6px);
}
.sb-mobile #m-reset:active { color: var(--text); border-color: var(--m-border-hi); }

/* The signature element: the big glowing Simulate / Pause button. */
.sb-mobile #m-sim {
  height: 52px; min-width: 128px; padding: 0 22px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--node); border-radius: var(--m-radius);
  background: rgba(0,200,150,.16); color: var(--node);
  font-size: 15px; font-weight: 700; letter-spacing: .03em;
  text-shadow: 0 0 12px #00c89670;
  box-shadow: 0 0 22px #00c89630, inset 0 0 14px #00c8961a;
  transition: all .16s;
}
.sb-mobile #m-sim .ic { font-size: 16px; }
.sb-mobile #m-sim:active { transform: translateY(1px) scale(.985); }
.sb-mobile #m-sim.running {
  border-color: var(--muscle); color: var(--muscle);
  background: rgba(240,120,48,.16); text-shadow: 0 0 12px #f0783070;
  box-shadow: 0 0 22px #f0783035, inset 0 0 14px #f078301a;
}

/* While simulating: hide the mode picker, reveal Reset. */
.sb-mobile.is-playing #m-modeseg { display: none; }
.sb-mobile.is-playing #m-reset  { display: flex; }
.sb-mobile.is-playing #m-dock   { display: none; }

/* ── Build dock (material palette) ───────────────────────────────────────── */
/* Sits just above the bottom bar, only while editing & paused. */
.sb-mobile #m-dock {
  position: absolute; left: 0; right: 0;
  bottom: calc(72px + var(--m-safe-b));
  padding: 0 calc(10px + var(--m-safe-r)) 0 calc(10px + var(--m-safe-l));
  display: none; gap: 8px; align-items: stretch;
  pointer-events: none;
}
.sb-mobile.is-edit:not(.is-playing):not(.is-arming) #m-dock { display: flex; }
/* When a selection bar is also showing, lift the dock above it. */
.sb-mobile.is-edit.has-sel:not(.is-playing):not(.is-arming) #m-dock {
  bottom: calc(72px + 56px + var(--m-safe-b));
}

.sb-mobile #m-mats {
  flex: 1; display: none; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding: 6px; pointer-events: auto;
  background: var(--m-panel); border: 1px solid var(--m-border);
  border-radius: var(--m-radius); backdrop-filter: blur(8px);
  box-shadow: 0 6px 22px rgba(0,0,0,.4);
}
/* Line-types appear only when a line is selected (they convert it). */
.sb-mobile.has-line #m-mats { display: grid; }

/* ── Build / Physics object bar (scrolls horizontally; press-hold to drag) ──── */
/* Shown in Build mode whenever NO line is selected — replaces the line-types. */
.sb-mobile #m-buildbar {
  display: none; flex: 1; min-width: 0; align-items: center; gap: 6px;
  padding: 6px 8px; pointer-events: auto;
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
  touch-action: pan-x; scrollbar-width: none;
  background: var(--m-panel); border: 1px solid var(--m-border);
  border-radius: var(--m-radius); backdrop-filter: blur(8px);
  box-shadow: 0 6px 22px rgba(0,0,0,.4);
}
.sb-mobile #m-buildbar::-webkit-scrollbar { display: none; }
.sb-mobile.is-edit:not(.has-line):not(.is-playing):not(.is-arming) #m-buildbar { display: flex; }
.sb-mobile .m-bb-label {
  flex: 0 0 auto; align-self: center; white-space: nowrap;
  font-size: 8px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--dim); padding: 0 3px 0 2px;
}
.sb-mobile .m-bb-label:not(:first-child) { border-left: 1px solid var(--m-border); padding-left: 9px; }
.sb-mobile .m-bbtn {
  flex: 0 0 auto; width: 50px; height: 46px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 1px solid var(--m-border); border-radius: 10px;
  background: transparent; color: var(--dim);
  transition: transform .1s, background .12s, border-color .12s, color .12s;
}
.sb-mobile .m-bbtn .m-bbic  { font-size: 17px; line-height: 1; }
.sb-mobile .m-bbtn .m-bblbl { font-size: 8.5px; letter-spacing: .02em; white-space: nowrap; }
.sb-mobile .m-bbtn.picking {
  border-color: var(--node); color: var(--node);
  background: rgba(0,200,150,.16); transform: scale(.92);
}
.sb-mobile .m-mat {
  height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 1px solid var(--m-border); border-radius: 10px;
  background: transparent; color: var(--dim); font-size: 10px; letter-spacing: .02em;
  transition: all .12s;
}
.sb-mobile .m-mat .mdot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 7px currentColor; }
.sb-mobile .m-mat[data-mat="spring"] .mdot { background: var(--spring); color: var(--spring); }
.sb-mobile .m-mat[data-mat="muscle"] .mdot { background: var(--muscle); color: var(--muscle); }
.sb-mobile .m-mat[data-mat="rod"]    .mdot { background: #d0d8ff;        color: #d0d8ff; }
.sb-mobile .m-mat[data-mat="rope"]   .mdot { background: #d4a24e;        color: #d4a24e; }
.sb-mobile .m-mat.active[data-mat="spring"] { border-color: var(--spring); color: var(--spring); background: rgba(14,184,212,.12); }
.sb-mobile .m-mat.active[data-mat="muscle"] { border-color: var(--muscle); color: var(--muscle); background: rgba(240,120,48,.12); }
.sb-mobile .m-mat.active[data-mat="rod"]    { border-color: #d0d8ff;        color: #d0d8ff;        background: rgba(208,216,255,.12); }
.sb-mobile .m-mat.active[data-mat="rope"]   { border-color: #d4a24e;        color: #d4a24e;        background: rgba(212,162,78,.12); }

.sb-mobile #m-add {
  width: 52px; pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid var(--m-border); border-radius: var(--m-radius);
  background: var(--m-panel); color: var(--node); font-size: 10px; letter-spacing: .02em;
  backdrop-filter: blur(8px); box-shadow: 0 6px 22px rgba(0,0,0,.4);
}
.sb-mobile #m-add .ic { font-size: 20px; line-height: 1; }
.sb-mobile #m-add:active { background: rgba(0,200,150,.14); border-color: var(--node); }

/* "Tap to place" hint shown while a shape/prop is armed */
.sb-mobile #m-arm-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(132px + var(--m-safe-b));
  display: none; align-items: center; gap: 8px;
  max-width: 86vw; padding: 8px 14px;
  background: rgba(13,15,24,.96); border: 1px solid var(--node); border-radius: 999px;
  color: var(--node); font-size: 12px; box-shadow: 0 0 18px #00c89630;
  pointer-events: auto;
}
.sb-mobile.is-arming #m-arm-hint { display: flex; }
.sb-mobile #m-arm-hint button {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--m-border-hi);
  background: transparent; color: var(--dim); font-size: 13px; line-height: 1;
}

/* ── Contextual selection bar ────────────────────────────────────────────── */
/* Floats just above the bottom bar whenever something is selected (and we're
   not simulating or placing a shape). Gives quick Tune / Delete without a sheet. */
.sb-mobile #m-selbar {
  position: absolute; left: calc(10px + var(--m-safe-l)); right: calc(10px + var(--m-safe-r));
  bottom: calc(72px + var(--m-safe-b));
  display: none; align-items: center; gap: 9px;
  height: 48px; padding: 0 8px 0 14px;
  background: var(--m-panel); border: 1px solid var(--m-border-hi);
  border-radius: var(--m-radius); backdrop-filter: blur(8px);
  box-shadow: 0 6px 22px rgba(0,0,0,.42);
}
.sb-mobile.has-sel:not(.is-playing):not(.is-arming) #m-selbar { display: flex; }
.sb-mobile #m-sel-type { color: var(--text); font-size: 13px; letter-spacing: .02em; text-transform: capitalize; }
.sb-mobile #m-selbar .m-grow { flex: 1; }
.sb-mobile #m-sel-tune {
  height: 36px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--m-border-hi); background: transparent;
  color: var(--text); font-size: 12px; letter-spacing: .02em;
}
.sb-mobile #m-sel-tune:active { border-color: var(--node); color: var(--node); background: rgba(0,200,150,.12); }
.sb-mobile #m-sel-del {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--m-border); background: transparent;
  color: var(--muscle); font-size: 15px; line-height: 1;
}
.sb-mobile #m-sel-del:active { border-color: var(--muscle); background: rgba(240,120,48,.14); }

/* ── Bottom sheets ───────────────────────────────────────────────────────── */
.sb-mobile .msheet { position: fixed; inset: 0; z-index: 180; display: none; }
.sb-mobile .msheet.open { display: block; }
.sb-mobile .msheet-scrim {
  position: absolute; inset: 0; background: rgba(4,5,10,.5);
  backdrop-filter: blur(2px); opacity: 0; transition: opacity .22s ease;
}
.sb-mobile .msheet.open .msheet-scrim { opacity: 1; }

.sb-mobile .msheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: min(82vh, calc(var(--app-h) - 48px));
  display: flex; flex-direction: column;
  background: var(--m-panel-sld);
  border-top: 1px solid var(--m-border);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.55);
  padding-bottom: var(--m-safe-b);
  transform: translateY(100%); transition: transform .26s cubic-bezier(.22,.9,.3,1);
}
.sb-mobile .msheet.open .msheet-panel { transform: translateY(0); }

.sb-mobile .msheet-grip { padding: 9px 0 4px; display: flex; justify-content: center; flex-shrink: 0; touch-action: none; }
.sb-mobile .msheet-grip::before { content: ""; width: 42px; height: 5px; border-radius: 3px; background: var(--m-border-hi); }
.sb-mobile .msheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 16px 12px; flex-shrink: 0;
}
.sb-mobile .msheet-title {
  font-family: var(--sans); font-weight: 600; font-size: 16px; color: var(--text);
}
.sb-mobile .msheet-x {
  margin-left: auto; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--m-border); background: transparent; color: var(--dim); font-size: 16px;
}
.sb-mobile .msheet-body {
  padding: 0 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Generic list rows inside sheets */
.sb-mobile .m-row {
  width: 100%; min-height: var(--m-tap); padding: 12px 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 1px solid var(--m-border); border-radius: 12px;
  background: rgba(255,255,255,.015); color: var(--text); font-size: 14px;
}
.sb-mobile .m-row:active { border-color: var(--node); background: rgba(0,200,150,.08); }
.sb-mobile .m-row .ic { font-size: 18px; width: 22px; text-align: center; }
.sb-mobile .m-row .sub { color: var(--dim); font-size: 11px; margin-top: 2px; }
.sb-mobile .m-row .col { display: flex; flex-direction: column; }
.sb-mobile .m-row.danger { color: #f0768a; }
.sb-mobile .m-row.danger:active { border-color: #f0768a; background: rgba(240,118,138,.08); }
.sb-mobile .m-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }

.sb-mobile .m-sec {
  padding: 6px 2px 8px; color: var(--dim);
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
}

/* Grid of tappable tiles (shapes / props) */
.sb-mobile .m-tilegrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.sb-mobile .m-tile {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--m-border); border-radius: 12px;
  background: rgba(255,255,255,.015); color: var(--dim); font-size: 10px;
}
.sb-mobile .m-tile .ic { font-size: 22px; line-height: 1; color: var(--text); }
.sb-mobile .m-tile:active { border-color: var(--node); color: var(--node); background: rgba(0,200,150,.08); }

/* ── Relocated: Properties (the existing #info-box renders into this) ─────── */
.sb-mobile #sheet-props .msheet-body { padding-top: 2px; }
.sb-mobile #sheet-props #info-box {
  margin: 0; border: none; padding: 0; background: transparent;
  font-size: 13px; line-height: 1.9; color: var(--text);
}
/* Make property panel controls finger-sized */
.sb-mobile #info-box b { font-size: 14px; }
.sb-mobile #info-box .pp-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.sb-mobile #info-box .pp-lbl { min-width: 66px; color: var(--dim); font-size: 12px; }
.sb-mobile #info-box .pp-tog,
.sb-mobile #info-box button {
  min-height: 40px; padding: 8px 14px; font-size: 13px; border-radius: 9px;
}
.sb-mobile #info-box input[type=range] { height: 6px; }
.sb-mobile #info-box input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; }
.sb-mobile #info-box input[type=number],
.sb-mobile #info-box input[type=text] { min-height: 40px; font-size: 14px; padding: 6px 8px; }
.sb-mobile #m-prop-empty { color: var(--dim); font-size: 13px; line-height: 1.7; padding: 4px 2px 8px; }
.sb-mobile #m-prop-delete {
  width: 100%; min-height: var(--m-tap); margin-top: 14px;
  border: 1px solid #f0768a; border-radius: 12px;
  background: rgba(240,118,138,.1); color: #f0768a; font-size: 14px; letter-spacing: .03em;
}
.sb-mobile #m-prop-delete:active { background: rgba(240,118,138,.2); }

/* ── Relocated: Settings (the existing #env-panel flows inside the sheet) ─── */
.sb-mobile #sheet-settings #env-panel {
  position: static; width: 100%; background: transparent; border: none;
  box-shadow: none; backdrop-filter: none; border-radius: 0;
}
.sb-mobile #sheet-settings #env-title { display: none; }     /* sheet header replaces it */
.sb-mobile #sheet-settings #env-body { display: flex !important; padding: 0; gap: 16px; }
.sb-mobile #sheet-settings #env-body .param { gap: 6px; }
.sb-mobile #sheet-settings #env-body .plabel { font-size: 13px; }
.sb-mobile #sheet-settings #env-body input[type=range] { height: 6px; }
.sb-mobile #sheet-settings #env-body input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; }
.sb-mobile #sheet-settings #env-body input[type=checkbox] { width: 22px; height: 22px; }

/* ── Relocated: Muscle wave (the existing #wave-panel flows inside) ───────── */
.sb-mobile #sheet-wave .msheet-body { padding-bottom: 22px; }
.sb-mobile #sheet-wave #wave-panel {
  position: static !important; left: auto; right: auto; bottom: auto;
  width: 100%; background: transparent !important; border: none !important; z-index: auto;
}
.sb-mobile #sheet-wave #wave-canvas { width: 100% !important; height: 150px !important; }
.sb-mobile #sheet-wave #wave-hint { font-size: 11px; }
.sb-mobile #sheet-wave .chp-btn,
.sb-mobile #sheet-wave .wave-mode { min-width: 30px; min-height: 30px; }

/* ── Camera-follow panel: restyled in place as a floating card ────────────── */
.sb-mobile #cam-panel {
  position: absolute; left: calc(10px + var(--m-safe-l)); right: calc(10px + var(--m-safe-r));
  bottom: calc(76px + var(--m-safe-b)); top: auto; width: auto;
  z-index: 160;
}
.sb-mobile #cam-panel .cp-body { padding: 10px 14px 14px; }
.sb-mobile #cam-panel input[type=range] { height: 6px; }
.sb-mobile #cam-panel input[type=range]::-webkit-slider-thumb { width: 20px; height: 20px; }

/* ── Workshop drawer: full-screen sheet on mobile ────────────────────────── */
.sb-mobile #ws-drawer {
  width: 100% !important; max-width: 100vw !important;
  border-radius: 18px 18px 0 0; top: auto !important; bottom: 0; height: 92dvh !important;
  padding-bottom: var(--m-safe-b);
}
.sb-mobile #ws-grid, .sb-mobile .ws-grid { grid-template-columns: 1fr 1fr !important; }
.sb-mobile #ws-close { width: 40px !important; height: 40px !important; font-size: 17px; }
.sb-mobile #ws-save-form { flex-wrap: wrap; }
.sb-mobile #ws-save-form input { min-height: 44px; font-size: 15px; }
.sb-mobile #ws-save-btn { min-height: 44px; }

/* ── Dev splash: comfortable on a phone ──────────────────────────────────── */
.sb-mobile #dev-splash { max-width: 92vw; padding: 24px 20px calc(20px + var(--m-safe-b)); }
.sb-mobile #dev-splash .ds-ok { min-height: 46px; padding: 10px 32px; font-size: 14px; }

/* ── Error toast clears the top bar ──────────────────────────────────────── */
.sb-mobile #err-toast { top: calc(60px + var(--m-safe-t)) !important; max-width: 88vw !important; }

@media (prefers-reduced-motion: reduce) {
  .sb-mobile .msheet-panel,
  .sb-mobile .msheet-scrim { transition: none; }
}

/* ── Muscle-wave bottom dock ─────────────────────────────────────────────────
   The wave editor docks along the bottom (instead of a modal sheet that hid the
   creature). The canvas shrinks to the area above it so the creature stays in
   view, centred and locked horizontally while you shape the wave. */
.sb-mobile { --m-wave-h: min(340px, 46dvh); }

.sb-mobile #m-wavedock {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--m-wave-h); z-index: 145;
  display: none; flex-direction: column;
  background: var(--m-panel-sld);
  border-top: 1px solid var(--m-border);
  box-shadow: 0 -12px 32px rgba(0,0,0,.5);
  padding-bottom: var(--m-safe-b);
}
.sb-mobile.m-wave #m-wavedock { display: flex; }

/* Shrink the (fixed, inset:0) canvas to the space above the dock. */
.sb-mobile.m-wave #canvas-wrap { bottom: auto; height: calc(var(--app-h) - var(--m-wave-h)); }

/* The dock owns Simulate + close, so hide the normal bottom chrome while open. */
.sb-mobile.m-wave #m-bottom,
.sb-mobile.m-wave #m-dock,
.sb-mobile.m-wave #m-arm-hint { display: none !important; }

.sb-mobile #m-wavedock-bar {
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto; height: 48px; padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--m-border);
}
.sb-mobile #m-wavedock-title {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
}
.sb-mobile #m-wavedock-bar .m-icon-btn { width: 40px; height: 40px; border-radius: 10px; font-size: 16px; }
.sb-mobile #m-wavedock-host {
  flex: 1 1 auto; min-height: 0; overflow: hidden;
  padding: 8px 12px calc(8px + var(--m-safe-b));
}
.sb-mobile #m-wavedock-host #wave-panel { width: 100%; height: 100%; }

/* Wave editor fills the dock height so the graph and its dots are large/grabbable. */
.sb-mobile #m-wavedock-host #wave-panel {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  padding: 6px 12px calc(4px + var(--m-safe-b));
}
.sb-mobile #m-wavedock-host #wave-title { flex: 0 0 auto; margin-bottom: 6px; }
.sb-mobile #m-wavedock-host #wave-canvas { flex: 1 1 auto; min-height: 120px; height: auto; }
.sb-mobile #wave-amp-slider { width: 132px; height: 22px; }
.sb-mobile #wave-hint { font-size: 10px; }

/* Menu toggle pill (e.g. Battery saver On/Off). */
.sb-mobile .m-row .m-toggle {
  margin-left: auto; flex: 0 0 auto;
  font-size: 11px; letter-spacing: .06em;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--m-border); color: var(--dim);
}
.sb-mobile .m-row .m-toggle.on {
  color: var(--node); border-color: var(--node); background: rgba(0,200,150,.12);
}
