/* OBIC Scholarship AI — Noor (نور / 努尔) · design 2c floating widget */

.obic-sa-dock {
  --sa-navy: #0b1f3a;
  --sa-navy-2: #122a4a;
  --sa-blue: #1a6dff;
  --sa-soft: #e8f1ff;
  --sa-bg: #f5f7fb;
  --sa-vv-top: 0px;
  --sa-vv-height: 100dvh;
  /* FAB (~104px) + dock gap + bottom inset — keep panel (and chat form) above FAB */
  --sa-fab-stack: calc(6.5rem + 0.55rem + 1.1rem + env(safe-area-inset-bottom, 0px));
  position: fixed;
  z-index: 60;
  inset-inline-end: 0.85rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  width: auto;
  max-width: 100vw;
  pointer-events: none;
  box-sizing: border-box;
}

.obic-sa-dock > * {
  pointer-events: auto;
}

.obic-sa-fab {
  position: relative;
  width: 78px;
  height: 104px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  filter: drop-shadow(0 10px 18px rgba(11, 31, 58, 0.28));
  animation: obic-sa-bob 3.6s ease-in-out infinite;
  flex-shrink: 0;
  will-change: transform;
}

/* Bigger grab area without changing visual size */
.obic-sa-fab::before {
  content: "";
  position: absolute;
  inset: -14px;
  z-index: -1;
}

.obic-sa-fab.is-dragging {
  cursor: grabbing;
  animation: none !important;
  /* Drop filter while dragging — cheaper / smoother on phone */
  filter: none;
  transform: scale(1.05);
  box-shadow: 0 12px 28px rgba(11, 31, 58, 0.28);
  border-radius: 18px 18px 12px 12px;
  z-index: 2;
}

/* After user moves Noor, stop bob so it doesn’t fight the finger next time */
.obic-sa-dock.is-user-placed .obic-sa-fab {
  animation: none;
}

/* User-dragged FAB: free left/top (closed only; open panel keeps sheet layout) */
.obic-sa-dock.is-user-placed:not(.is-open),
body.page-study .obic-sa-dock.is-user-placed:not(.is-open),
body.page-study-portal .obic-sa-dock.is-user-placed:not(.is-open) {
  inset-inline-end: auto !important;
  inset-inline-start: auto !important;
  right: auto !important;
  left: var(--sa-fab-left) !important;
  bottom: auto !important;
  top: var(--sa-fab-top) !important;
}

/* While open: drop dragged left/top so the panel can use default dock layout */
.obic-sa-dock.is-user-placed.is-open,
body.page-study .obic-sa-dock.is-user-placed.is-open,
body.page-study-portal .obic-sa-dock.is-user-placed.is-open {
  left: auto !important;
  top: auto !important;
}

.obic-sa-fab img {
  display: block;
  width: 78px;
  height: 104px;
  object-fit: cover;
  object-position: top center;
  border-radius: 18px 18px 12px 12px;
  background: linear-gradient(165deg, #d6e4f0 0%, #f5f7fb 55%, #ffffff 100%);
}

.obic-sa-fab::after {
  content: "";
  position: absolute;
  inset-inline-end: 4px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px #fff;
}

/* Hide Noor (× on FAB) — phone-first; desktop also gets it so drag users can clear the corner */
.obic-sa-hide {
  position: absolute;
  inset-inline-end: -6px;
  top: -8px;
  z-index: 3;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #0b1f3a;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(11, 31, 58, 0.35);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.obic-sa-hide:hover,
.obic-sa-hide:focus-visible {
  background: #1a6dff;
  outline: none;
}
.obic-sa-dock.is-open .obic-sa-hide,
.obic-sa-hide[hidden],
.obic-sa-fab[hidden] .obic-sa-hide {
  display: none !important;
}
.obic-sa-dock.is-fab-hidden {
  pointer-events: none;
}
.obic-sa-dock.is-fab-hidden .obic-sa-fab {
  display: none !important;
}

/* Bring Noor back — slim edge stick. Label stays for screen readers. */
.obic-sa-show {
  position: fixed;
  z-index: 88;
  inset-inline-end: 0;
  bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 0.15rem 0.18rem 0.15rem 0.22rem;
  border: 1px solid rgba(26, 109, 255, 0.35);
  border-inline-end: 0;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(135deg, #0b1f3a 0%, #122a4a 70%, #1a6dff 160%);
  color: #fff;
  font-family: "Sora", "Noto Sans Arabic", system-ui, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: -4px 6px 14px rgba(11, 31, 58, 0.28);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
html[dir="rtl"] .obic-sa-show {
  border-radius: 0 10px 10px 0;
  border-inline-end: 1px solid rgba(26, 109, 255, 0.35);
  border-inline-start: 0;
  padding: 0.15rem 0.22rem 0.15rem 0.18rem;
  box-shadow: 4px 6px 14px rgba(11, 31, 58, 0.28);
}
.obic-sa-show [data-sa="showLabel"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.obic-sa-show[hidden] {
  display: none !important;
}
.obic-sa-show img {
  display: block;
  width: 18px;
  height: 22px;
  object-fit: cover;
  object-position: top center;
  border-radius: 5px;
  background: #e8f1ff;
}
.obic-sa-show:active {
  transform: translateX(-2px);
}
html[dir="rtl"] .obic-sa-show:active {
  transform: translateX(2px);
}
body.obic-sa-open .obic-sa-show,
body.ssp-drawer-open .obic-sa-show {
  display: none !important;
}

.obic-sa-panel {
  width: min(420px, calc(100vw - 1.25rem));
  /* Reserve full FAB stack (was 5.25rem — too short vs 104px FAB) so form stays on-screen */
  max-height: min(78dvh, calc(var(--sa-vv-height, 100dvh) - var(--sa-fab-stack, 8.25rem)));
  height: min(720px, calc(var(--sa-vv-height, 100dvh) - var(--sa-fab-stack, 8.25rem)));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(26, 109, 255, 0.12), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, var(--sa-bg) 100%);
  border: 1px solid rgba(11, 31, 58, 0.1);
  box-shadow: 0 18px 40px rgba(11, 31, 58, 0.18);
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
}

.obic-sa-panel[hidden] {
  display: none !important;
}

.obic-sa-panel header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  background: linear-gradient(120deg, var(--sa-navy), var(--sa-navy-2));
  color: #fff;
  flex-shrink: 0;
  min-width: 0;
}

.obic-sa-panel header img {
  width: 44px;
  height: 58px;
  object-fit: cover;
  object-position: top;
  border-radius: 10px;
  background: #d6e4f0;
  flex-shrink: 0;
}

.obic-sa-panel header > div {
  flex: 1;
  min-width: 0;
}

.obic-sa-panel header strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.3;
  word-break: normal;
  overflow-wrap: break-word;
  text-wrap: pretty;
}

.obic-sa-panel header span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  opacity: 0.82;
  font-weight: 500;
  word-break: normal;
  overflow-wrap: break-word;
  text-wrap: pretty;
}

.obic-sa-panel header button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
}

.obic-sa-panel header button.obic-sa-hist {
  width: auto;
  min-width: 32px;
  padding: 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.obic-sa-history {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  /* 0 — not 120px — so footer form is never clipped by panel overflow */
  min-height: 0;
}

.obic-sa-history[hidden] {
  display: none !important;
}

.obic-sa-history-head {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.obic-sa-history-head button {
  border: 1px solid rgba(11, 31, 58, 0.14);
  background: #f3f7fc;
  color: var(--sa-navy, #0b1f3a);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.obic-sa-history-title {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
}

.obic-sa-history-empty {
  margin: 0.5rem 0 0;
  color: #64748b;
  font-size: 0.88rem;
}

.obic-sa-history-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-align: start;
  width: 100%;
  border: 1px solid rgba(11, 31, 58, 0.1);
  background: #fff;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
}

.obic-sa-history-item strong {
  font-size: 0.88rem;
  color: var(--sa-navy, #0b1f3a);
  font-weight: 700;
}

.obic-sa-history-item span {
  font-size: 0.72rem;
  color: #64748b;
}

.obic-sa-log,
.obic-sa-history {
  /* Desktop: chain to page at edges (wheel breakout / native). Touch: contain below. */
  overscroll-behavior: auto;
}

.obic-sa-log {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0.95rem 0.9rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  /* Critical: was min-height 200px — blocked flex shrink and clipped .obic-sa-form */
  min-height: 0;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(11, 31, 58, 0.03) 0%, transparent 2.5rem),
    transparent;
}

@media (hover: none), (pointer: coarse) {
  .obic-sa-log,
  .obic-sa-history {
    overscroll-behavior: contain;
  }
}

.obic-sa-log[hidden],
.obic-sa-pay[hidden],
.obic-sa-note[hidden],
.obic-sa-human[hidden],
.obic-sa-form[hidden] {
  display: none !important;
}

.obic-sa-pay {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  max-height: 100%;
  overflow: hidden;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.obic-sa-panel.is-paying {
  max-height: min(720px, calc(var(--sa-vv-height, 100dvh) - var(--sa-fab-stack, 8.25rem)));
}

.obic-sa-panel.is-paying .obic-sa-pay {
  flex: 1 1 auto;
  min-height: 0;
  /* Do not force a tall min that overflows short phones */
  max-height: 100%;
}

/* When pay sheet is open, chat log must not steal touch scroll */
.obic-sa-panel.is-paying .obic-sa-log {
  display: none !important;
  pointer-events: none;
  touch-action: none;
}

/* Chat row: who label + bubble (user end / bot start) */
.obic-sa-msg {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  /* fit-content so short “ok” rows don’t shrink under flex min-width:0 */
  width: fit-content;
  max-width: 92%;
  min-width: min(2.75rem, 100%);
  box-sizing: border-box;
}

.obic-sa-msg.is-me {
  align-self: flex-end;
  align-items: flex-end;
  margin-inline-start: auto;
}

.obic-sa-msg.is-ai {
  align-self: flex-start;
  align-items: flex-start;
  margin-inline-end: auto;
}

.obic-sa-msg-who {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #64748b;
  padding: 0 0.2rem;
  line-height: 1.2;
  white-space: nowrap;
}

.obic-sa-bubble {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  min-width: 2.75rem;
  box-sizing: border-box;
  padding: 0.7rem 0.95rem;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  /* Keep short Latin/Arabic words intact; break only long tokens/URLs */
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
  line-break: strict;
  hyphens: none;
  text-wrap: wrap;
  font-family: "Sora", "Noto Sans Arabic", system-ui, sans-serif;
  box-shadow: 0 1px 2px rgba(11, 31, 58, 0.06);
}

.obic-sa-msg.is-me .obic-sa-bubble,
.obic-sa-bubble.is-me {
  align-self: flex-end;
  background: var(--sa-navy);
  color: #fff;
  border-bottom-right-radius: 5px;
  text-align: start;
}

html[dir="rtl"] .obic-sa-msg.is-me .obic-sa-bubble,
html[dir="rtl"] .obic-sa-bubble.is-me,
.obic-sa-panel[dir="rtl"] .obic-sa-msg.is-me .obic-sa-bubble {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 5px;
}

.obic-sa-msg.is-ai .obic-sa-bubble,
.obic-sa-bubble.is-ai {
  align-self: flex-start;
  background: #fff;
  color: var(--sa-navy);
  border: 1px solid rgba(11, 31, 58, 0.1);
  border-bottom-left-radius: 5px;
  text-align: start;
}

html[dir="rtl"] .obic-sa-msg.is-ai .obic-sa-bubble,
html[dir="rtl"] .obic-sa-bubble.is-ai,
.obic-sa-panel[dir="rtl"] .obic-sa-msg.is-ai .obic-sa-bubble {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 5px;
}

/* Unicode-bidi: honor per-bubble dir=rtl|auto from JS */
.obic-sa-bubble[dir="rtl"] {
  text-align: start;
  unicode-bidi: isolate;
}

.obic-sa-bubble[dir="ltr"],
.obic-sa-bubble[dir="auto"] {
  unicode-bidi: isolate;
}

.obic-sa-bubble-text {
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

.obic-sa-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.15rem 0.85rem 0.45rem;
}

.obic-sa-chips[hidden] {
  display: none !important;
}

.obic-sa-chip {
  appearance: none;
  border: 1px solid rgba(11, 31, 58, 0.16);
  background: #fff8ee;
  color: var(--sa-navy);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
}

.obic-sa-chip:hover,
.obic-sa-chip:focus-visible {
  border-color: rgba(196, 120, 28, 0.55);
  background: #fff1d9;
  outline: none;
}

/* Compact step thumbs — separate from chat bubbles, not a wall of screenshots */
.obic-sa-teach-wrap {
  align-self: stretch;
  max-width: 100%;
  min-width: 0;
  margin: -0.15rem 0 0.15rem;
}

.obic-sa-teach {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem 0.6rem 0.65rem;
  border-radius: 14px;
  border: 1px solid rgba(11, 31, 58, 0.1);
  background: linear-gradient(165deg, #f3f7fc 0%, #eef3f9 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.obic-sa-teach-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 780;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #475569;
}

.obic-sa-teach-rail {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding: 0.1rem 0.05rem 0.2rem;
  scrollbar-width: thin;
}

.obic-sa-teach-step {
  margin: 0;
  flex: 0 0 auto;
  width: 104px;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid rgba(11, 31, 58, 0.12);
  background: #fff;
  position: relative;
}

.obic-sa-teach-num {
  position: absolute;
  z-index: 1;
  top: 0.28rem;
  inset-inline-start: 0.28rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
  background: var(--sa-navy);
  box-shadow: 0 1px 2px rgba(11, 31, 58, 0.25);
  pointer-events: none;
}

.obic-sa-teach-zoom {
  appearance: none;
  display: block;
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: #e2e8f0;
  cursor: zoom-in;
}

.obic-sa-teach-zoom img {
  display: block;
  width: 104px;
  height: 68px;
  object-fit: cover;
  object-position: top center;
}

.obic-sa-teach-zoom-hint {
  position: absolute;
  right: 0.28rem;
  bottom: 0.28rem;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  background: rgba(11, 31, 58, 0.78);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  pointer-events: none;
  max-width: calc(100% - 0.5rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[dir="rtl"] .obic-sa-teach-zoom-hint,
.obic-sa-panel[dir="rtl"] .obic-sa-teach-zoom-hint {
  right: auto;
  left: 0.28rem;
}

.obic-sa-teach-step figcaption {
  padding: 0.32rem 0.4rem 0.4rem;
  font-size: 0.65rem;
  line-height: 1.3;
  color: rgba(11, 31, 58, 0.78);
  font-weight: 650;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.obic-sa-lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  background: rgba(8, 18, 36, 0.88);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.obic-sa-lightbox[hidden] {
  display: none !important;
}

.obic-sa-lightbox-figure {
  margin: 0;
  max-width: min(960px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.obic-sa-lightbox-figure img {
  display: block;
  max-width: 100%;
  max-height: min(78dvh, 820px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  background: #0b1f3a;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.obic-sa-lightbox-figure figcaption {
  color: #f8fafc;
  font-size: 0.85rem;
  font-weight: 650;
  text-align: center;
  max-width: 36rem;
  line-height: 1.4;
}

.obic-sa-lightbox-close {
  position: absolute;
  top: max(0.55rem, env(safe-area-inset-top));
  right: max(0.55rem, env(safe-area-inset-right));
  appearance: none;
  border: 0;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.obic-sa-lightbox-close:focus-visible {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}

body.obic-sa-lb-open {
  overflow: hidden;
}

.obic-sa-note {
  padding: 0 0.85rem 0.35rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #64748b;
  word-break: normal;
  overflow-wrap: break-word;
  text-wrap: pretty;
  flex-shrink: 0;
}

.obic-sa-form,
.obic-sa-contact {
  display: flex;
  gap: 0.45rem;
  /* Dock already clears safe-area; avoid double inset that grows chrome and clips input */
  padding: 0.65rem 0.75rem 0.8rem;
  border-top: 1px solid rgba(11, 31, 58, 0.08);
  background: rgba(255, 255, 255, 0.92);
  flex-shrink: 0;
  flex-grow: 0;
  min-width: 0;
  position: relative;
  z-index: 2;
}

.obic-sa-contact {
  flex-direction: column;
}

.obic-sa-contact input,
.obic-sa-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(11, 31, 58, 0.12);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  background: #fff;
  font-size: 16px; /* avoid iOS zoom */
}

.obic-sa-form button,
.obic-sa-contact button {
  border: 0;
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  background: var(--sa-blue);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.obic-sa-human {
  margin: 0 0.85rem 0.65rem;
  border: 0;
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  background: var(--sa-soft);
  color: var(--sa-navy);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  word-break: normal;
  overflow-wrap: break-word;
  text-wrap: pretty;
  flex-shrink: 0;
}

@keyframes obic-sa-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .obic-sa-fab {
    animation: none;
  }
}

body.page-study .obic-sa-dock {
  inset-inline-end: 0.65rem;
  bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  --sa-fab-stack: calc(6.5rem + 0.55rem + 0.95rem + env(safe-area-inset-bottom, 0px));
}

/* Desktop/tablet: when open, pin chat form in view above FAB */
@media (min-width: 431px) {
  .obic-sa-dock.is-open .obic-sa-panel {
    max-height: calc(var(--sa-vv-height, 100dvh) - var(--sa-fab-stack, 8.25rem));
    height: min(720px, calc(var(--sa-vv-height, 100dvh) - var(--sa-fab-stack, 8.25rem)));
  }

  .obic-sa-dock.is-open .obic-sa-log,
  .obic-sa-dock.is-open .obic-sa-history {
    min-height: 0;
  }

  .obic-sa-dock.is-open .obic-sa-form,
  .obic-sa-dock.is-open .obic-sa-contact,
  .obic-sa-dock.is-open .obic-sa-human,
  .obic-sa-dock.is-open .obic-sa-note {
    flex-shrink: 0;
  }
}

/* Hide generic site AI dock on scholarship surfaces when girl is present */
body.obic-sa-active .obic-ai-dock {
  display: none !important;
}

@media (max-width: 420px) {
  .obic-sa-fab,
  .obic-sa-fab img {
    width: 68px;
    height: 90px;
  }
}

/* —— Phone: full-width bottom sheet (360–430px) —— */
@media (max-width: 430px) {
  body.obic-sa-open {
    overflow: hidden;
  }

  .obic-sa-dock {
    inset-inline-end: 0.55rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: calc(100vw - 0.5rem);
  }

  .obic-sa-dock.is-open {
    inset: var(--sa-vv-top, 0px) 0 auto 0;
    width: 100%;
    max-width: 100vw;
    height: var(--sa-vv-height, 100dvh);
    bottom: auto;
    align-items: stretch;
    gap: 0;
    padding: 0;
    margin: 0;
    background: rgba(11, 31, 58, 0.42);
    pointer-events: auto;
    /* Above Study sticky Send (z 90) + Helper bar (z 85) */
    z-index: 110;
    overflow: hidden;
  }

  .obic-sa-dock.is-open .obic-sa-fab {
    display: none !important;
  }

  .obic-sa-dock.is-open .obic-sa-panel,
  .obic-sa-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-radius: 18px 18px 0 0;
    max-height: none;
    box-shadow: 0 -12px 36px rgba(11, 31, 58, 0.22);
  }

  .obic-sa-dock.is-open .obic-sa-panel {
    margin-top: auto;
    height: min(100%, calc(var(--sa-vv-height, 100dvh) - 0.35rem));
    max-height: min(100%, calc(var(--sa-vv-height, 100dvh) - 0.35rem));
    border: 0;
    border-radius: 16px 16px 0 0;
  }

  .obic-sa-dock.is-open .obic-sa-panel.is-paying {
    height: min(100%, calc(var(--sa-vv-height, 100dvh) - 0.35rem));
    max-height: min(100%, calc(var(--sa-vv-height, 100dvh) - 0.35rem));
  }

  .obic-sa-dock.is-open .obic-sa-panel.is-paying {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .obic-sa-dock.is-open .obic-sa-panel.is-paying .obic-sa-pay {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    height: auto;
    overflow: hidden;
    touch-action: pan-y;
  }

  .obic-sa-dock.is-open .obic-sa-panel.is-paying header {
    flex-shrink: 0;
  }

  .obic-sa-dock.is-open .obic-sa-form,
  .obic-sa-dock.is-open .obic-sa-contact {
    /* Phone sheet sits on the home indicator — restore safe-area here only */
    padding-bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
  }

  .obic-sa-panel header {
    padding-top: calc(0.7rem + env(safe-area-inset-top, 0px));
  }

  .obic-sa-panel header img {
    width: 40px;
    height: 52px;
  }

  .obic-sa-human {
    font-size: 0.86rem;
    padding: 0.65rem 0.85rem;
  }
}
