/* Platform-specific PWA install guide. Banner + modal share these tokens. */
.imd-ios-install {
  position: fixed;
  left: 0.7rem;
  right: 0.7rem;
  bottom: max(0.45rem, env(safe-area-inset-bottom));
  z-index: 45;
  padding: 0.8rem 2.35rem 0.7rem 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.42);
  color: var(--text);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
html[data-theme="light"] .imd-ios-install {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(20, 28, 48, 0.16);
}
.imd-ios-install-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}
.imd-ios-install-ico {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: var(--accent2);
}
.imd-ios-install-copy strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
}
.imd-ios-install-copy p {
  margin: 0.2rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.4;
}
.imd-ios-install-copy b { color: var(--text); font-weight: 700; }
button.imd-ios-install-x,
html[data-theme="light"] button.imd-ios-install-x {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0;
  font-weight: 400;
  line-height: 0;
  cursor: pointer;
}
button.imd-ios-install-x svg {
  display: block;
  width: 14px;
  height: 14px;
}
.imd-ios-install-go,
.imd-ios-install-how {
  display: inline-block;
  margin-top: 0.5rem;
  margin-right: 0.4rem;
  border: 0;
  border-radius: 10px;
  padding: 0.42rem 0.9rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.imd-ios-install-go {
  color: #0c0e14;
  background: var(--accent2, #40d9c4);
}
.imd-ios-install-how {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}
.imd-ios-install-arrow {
  width: 0;
  height: 0;
  margin: 0.45rem auto 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid var(--accent2);
}
/* iOS 27 iPhone Safari: point at the page menu at the right end of the
   address bar (Tabs sits to its right), not the middle of the toolbar. */
.imd-ios-install-arrow.is-right {
  margin: 0.45rem 18% 0 auto;
}
.imd-ios-install-arrow.is-up {
  border-top: 0;
  border-bottom: 8px solid var(--accent2);
  margin: 0 auto 0.45rem;
}
.imd-ios-install.is-top {
  bottom: auto;
  top: max(0.45rem, env(safe-area-inset-top));
}
/* Reserve the card's measured height (--imd-install-h, imd_ios_install.js
   measureCard) plus a gap: on narrow phones the card is ~150px, and a fixed
   7.2rem (115px) left the last Home rows under it, so tapping them did nothing. */
body.imd-ios-install-on {
  padding-bottom: calc(var(--imd-install-h, 7.2rem) + 1rem + env(safe-area-inset-bottom));
}
body.imd-ios-install-on.login-page .login-wrap {
  padding-bottom: 8rem;
}
body.imd-ios-install-on.imd-install-top {
  padding-bottom: 0;
  padding-top: calc(var(--imd-install-h, 7.2rem) + 1rem + env(safe-area-inset-top));
}
/* sweep1 #2613 follow-up: the iMD-style exam run (#tr-dock; USMLE has its own rules in
   qbank_exam_usmle.css) is sized to the window and scrolls inside #reader-content (or
   the zoom frame / split panes). The card's body padding (bottom, or top for the iPad
   card) made the page ~115-150px taller than the window, so the window scrolled and
   the exam toolbar slid off the top, while the card (z-index 45) sat under the dock
   and the bottom highlight strip. The card stays out of the way during an exam (it
   shows again on every other page until dismissed), and so does its padding. */
html:not([data-exam-style="usmle"]) body.exam-run.has-tr-dock.imd-ios-install-on {
  padding-top: 0;
  padding-bottom: 0;
}
html:not([data-exam-style="usmle"]) body.exam-run.has-tr-dock .imd-ios-install {
  display: none !important;
}

#imd-install-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0; inset: 0;
  z-index: 12060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1rem + var(--imd-vv-top, 0px)) 0.75rem calc(1rem + var(--imd-vv-bottom, 0px));
  box-sizing: border-box;
  background: rgba(6, 8, 16, 0.58);
}
#imd-install-overlay[hidden] { display: none !important; }
.imd-ig-sheet {
  width: min(100%, 28rem);
  max-height: min(88vh, 40rem);
  max-height: min(calc(var(--imd-frame, 100dvh) - var(--imd-vv-top, 0px) - var(--imd-vv-bottom, 0px) - 2rem), 40rem);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--card, #161b28);
  color: var(--text, #e8ecf7);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  border-radius: 16px;
  padding: 1rem 1rem 1.15rem;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}
html[data-theme="light"] .imd-ig-sheet {
  background: #fff;
  box-shadow: 0 16px 40px rgba(20, 28, 48, 0.18);
}
.imd-ig-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.imd-ig-head h2 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 750;
}
.imd-ig-lead {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}
button.imd-ig-close,
html[data-theme="light"] button.imd-ig-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0;
  font-weight: 400;
  line-height: 0;
  cursor: pointer;
}
html[data-theme="light"] button.imd-ig-close {
  background: #eef1f7;
}
button.imd-ig-close svg {
  display: block;
  width: 14px;
  height: 14px;
}
button.imd-ig-close:hover,
html[data-theme="light"] button.imd-ig-close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text);
}
html[data-theme="light"] button.imd-ig-close:hover {
  background: #dfe4ef;
}
.imd-ig-steps {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.imd-ig-step {
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}
html[data-theme="light"] .imd-ig-step {
  background: #f4f6fb;
}
.imd-ig-n {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  background: var(--accent2, #40d9c4);
  color: #0c0e14;
}
.imd-ig-step h3 {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
  font-weight: 750;
}
.imd-ig-step p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.4;
}
.imd-ig-step b { color: var(--text); font-weight: 700; }
.imd-ig-shot {
  margin-top: 0.55rem;
  max-width: 18rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0e121b;
  overflow: hidden;
}
html[data-theme="light"] .imd-ig-shot {
  background: #e8edf5;
}
.imd-ig-shot svg {
  display: block;
  width: 100%;
  max-width: 18rem;
  height: auto;
}
.imd-ig-note {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
.imd-ig-cta {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  color: #0c0e14;
  background: var(--accent2, #40d9c4);
}
#imd-install-inline .imd-ig-sheet {
  width: 100%;
  max-height: none;
  box-shadow: none;
  border-radius: 12px;
  padding: 0.85rem 0.85rem 1rem;
}
#imd-install-inline .imd-ig-close { display: none; }
@media print {
  html.imd-export-pdf .imd-ios-install,
  html.imd-export-pdf #imd-install-overlay,
  html.imd-export-pdf .imd-ig-sheet {
    display: none !important;
  }
  html.imd-export-pdf body.imd-ios-install-on,
  html.imd-export-pdf body.imd-ios-install-on.imd-install-top {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }
}
