/*
  Paired with chrome-lock.js: absolute top/bottom chrome,
  middle pane top/bottom from JS — real iOS scrollport.
*/
html.chrome-lock {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #1d4a3a;
}
:root[data-theme="dark"].chrome-lock,
html.chrome-lock[data-theme="dark"],
:root[data-theme="dark"] html.chrome-lock {
  background: #000;
}
html.chrome-lock:has(.preview-bar) {
  background: #111;
}
html.chrome-lock body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg, #e8eee9);
  box-shadow: none;
}
html.chrome-lock body.doctor-deck {
  background: var(--ui-page, #e8eee9);
}
.app.chrome-lock {
  position: relative;
  height: 100%;
  max-height: 100%;
  min-height: 0 !important;
  width: 100%;
  overflow: hidden;
}
body.doctor-deck.chrome-lock {
  /* body stays position:fixed (from rule above); it's the positioning root */
  max-height: 100%;
  min-height: 0 !important;
  overflow: hidden;
}
.app.chrome-lock > .chrome-top,
body.chrome-lock > #top-bar.chrome-top,
body.doctor-deck.chrome-lock > .chrome-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
}
.app.chrome-lock > .chrome-bot,
#mode-shell.app.chrome-lock > .chrome-bot,
body.chrome-lock > #bot-bar.chrome-bot,
body.doctor-deck.chrome-lock > .chrome-bot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  width: 100%;
  max-width: none;
  z-index: 40;
}
.app.chrome-lock > .chrome-rail,
#mode-shell.app.chrome-lock > .chrome-rail,
body.chrome-lock > #sub-bar.chrome-rail {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 39;
  /* top set by chrome-lock.js / --chrome-top */
  top: var(--chrome-top, 48px);
}
.app.chrome-lock > .chrome-mid,
#mode-shell.app.chrome-lock > .chrome-mid,
#mode-shell.chrome-lock > #mode-pane > .chrome-mid,
#mode-shell.chrome-lock > #mode-pane > main.page,
#mode-shell.chrome-lock > #mode-pane > .page,
#mode-shell.chrome-lock > #mode-pane > form.page,
#mode-shell.chrome-lock > #mode-pane > .deck,
#mode-shell.chrome-lock > #mode-pane > .desk-wrap > .chrome-mid,
#mode-shell.chrome-lock > #mode-pane > .desk-wrap > .desk-main,
body.chrome-lock > #mode-shell.app > main.page,
body.chrome-lock > #mode-shell > .desk-wrap > .desk-main,
body.doctor-deck.chrome-lock > .chrome-mid {
  position: absolute;
  left: 0;
  right: 0;
  /* Prefer CSS vars so a fresh HTMX shell lands in the right place before JS. */
  top: calc(var(--chrome-top, 48px) + var(--chrome-rail, 44px));
  bottom: var(--chrome-bot, 56px);
  z-index: 1;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  overflow-anchor: none;
  touch-action: pan-y;
  padding-bottom: 24px;
}
/* Mode shell fills the viewport; top/sub/bot stay mounted (HTMX). */
body.chrome-lock > #mode-shell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}
body.chrome-lock > #mode-shell.app {
  /* same box; class kept for app chrome rules */
}
/* Stable pane inside shell — HTMX swaps this node, not the shell. */
body.chrome-lock > #mode-shell > #mode-pane {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Clinic desk — same lock; side tabs stay under the green bar. */
html.chrome-lock body.desk {
  background: #e8eee9;
}
body.desk.chrome-lock {
  max-height: 100%;
  min-height: 0 !important;
  overflow: hidden;
}
body.desk.chrome-lock > .chrome-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
}
body.desk.chrome-lock .desk-wrap,
body.desk.chrome-lock > #mode-shell > .desk-wrap {
  display: block;
  min-height: 0;
  height: 100%;
  position: relative;
}
body.desk.chrome-lock .desk-side {
  position: absolute;
  z-index: 35;
  background: #fff;
}
body.desk.chrome-lock .chrome-mid {
  position: absolute;
  z-index: 1;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
