/* Shared ServGo Air controls. No page-wide resets or floating banners. */
.sg-pwa-entry {
  display:inline-flex; align-items:center; justify-content:center;
  gap:6px; min-height:44px; min-width:44px; padding:8px 12px;
  max-width:100%; white-space:normal; overflow-wrap:anywhere;
  border:1px solid var(--s-border,#dce5ef); border-radius:12px;
  background:var(--s-surface-2,#f4f7fb); color:var(--s-text,#1b2d42);
  font:inherit; font-size:13px; font-weight:600; cursor:pointer;
  touch-action:manipulation; user-select:none; -webkit-user-select:none;
}
.sg-pwa-panel {
  box-sizing:border-box; width:min(440px,calc(100% - 32px)); max-width:100%;
  max-height:calc(100dvh - 32px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
  margin:auto; padding:22px; overflow:auto; overscroll-behavior:contain;
  border:1px solid #dce5ef; border-radius:22px;
  background:#fff; color:#1b2d42; font:15px/1.5 Onest,system-ui,sans-serif;
  box-shadow:0 12px 48px rgb(15 34 58 / 20%);
  color-scheme:light; overflow-wrap:anywhere;
}
.sg-pwa-panel:not([open]) { display:none; }
.sg-pwa-panel[open] { display:grid; gap:12px; }
.sg-pwa-panel::backdrop { background:rgb(8 15 26 / 54%); }
.sg-pwa-head { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.sg-pwa-head h2 { font-size:20px; font-weight:700; line-height:1.25; margin:0; }
.sg-pwa-panel p { margin:0; }
.sg-pwa-summary { font-weight:650; }
.sg-pwa-instructions { display:grid; gap:7px; color:#53677d; font-size:14px; }
.sg-pwa-panel button {
  box-sizing:border-box; font:inherit; font-weight:600; min-width:44px; min-height:44px;
  border-radius:12px; padding:10px 14px; border:1px solid #dce5ef;
  cursor:pointer; touch-action:manipulation; user-select:none; -webkit-user-select:none;
  transition:opacity 120ms ease-out;
}
.sg-pwa-panel [hidden] { display:none !important; }
.sg-pwa-panel button:disabled { opacity:.5; cursor:default; }
.sg-pwa-close { flex:none; background:#f4f7fb; color:#1b2d42; font-size:20px !important; }
.sg-pwa-primary { background:#3478d6; color:white; border-color:#3478d6 !important; }
.sg-pwa-secondary { background:#f4f7fb; color:#1b2d42; }
.sg-pwa-message { min-height:1.5em; color:#53677d; font-size:13px; }
.sg-pwa-entry:focus-visible,.sg-pwa-panel button:focus-visible { outline:2px solid #3478d6; outline-offset:3px; }
.sg-pwa-entry:active,.sg-pwa-panel button:active:not(:disabled) { opacity:.75; }
@media(hover:hover) and (pointer:fine) {
  .sg-pwa-entry:hover,.sg-pwa-panel button:not(:disabled):hover { filter:brightness(.96); }
}
:is(html[data-theme="dark"],body[data-theme="dark"]) .sg-pwa-panel {
  color-scheme:dark; background:#172237; color:#f0f5fc; border-color:#34455e;
}
:is(html[data-theme="dark"],body[data-theme="dark"]) .sg-pwa-entry,
:is(html[data-theme="dark"],body[data-theme="dark"]) .sg-pwa-secondary,
:is(html[data-theme="dark"],body[data-theme="dark"]) .sg-pwa-close {
  background:#25354b; color:#f0f5fc; border-color:#34455e;
}
:is(html[data-theme="dark"],body[data-theme="dark"]) :is(.sg-pwa-instructions,.sg-pwa-message) { color:#b6c4d5; }
@media(max-width:600px) {
  .sg-pwa-panel {
    width:calc(100% - max(24px,env(safe-area-inset-left,0px) + env(safe-area-inset-right,0px)));
    margin:auto auto max(12px,env(safe-area-inset-bottom,0px)); padding:20px;
  }
}
@media(prefers-reduced-motion:reduce) { .sg-pwa-entry,.sg-pwa-panel button { transition:none; } }

/* Native shell contract. Scope layout changes to installed ServGo, not Telegram,
   ordinary websites, or the Studio v4 keyboard controller already in use. */
.sg-route-loading {
  min-height:100dvh; display:grid; place-content:center;
  padding:24px; color:var(--s-text,#1b2d42); background:var(--s-bg,#fff);
}
html[data-theme="dark"] .sg-route-loading { background:var(--s-bg,#111a29); color:var(--s-text,#f0f5fc); }
html[data-pwa-mode="installed"]:not(.tg-webapp) :is(.bf-root,.ds-screen) {
  box-sizing:border-box; top:var(--sg-keyboard-top,0px); bottom:var(--sg-keyboard-bottom,0px);
  overscroll-behavior:contain;
}
html[data-pwa-mode="installed"]:not(.tg-webapp) :is(.ds-shell-content,.bf-inner,.ds-sheet,.bf-sheet) {
  overscroll-behavior-y:contain; scroll-padding-block:12px;
}
@media (max-width:899px) {
  html[data-pwa-mode="installed"]:not(.tg-webapp) :is(.bf-root,.ds-screen):not(.is-focus) {
    padding-top:env(safe-area-inset-top,0px);
    padding-left:env(safe-area-inset-left,0px);
    padding-right:env(safe-area-inset-right,0px);
  }
  html[data-pwa-mode="installed"]:not(.tg-webapp) .bf-device:has(.bf-inner):not(:has(.bf-tabbar,.bf-bottombar,.bf-chat-bar,.bf-home-footer)) {
    padding-bottom:env(safe-area-inset-bottom,0px);
  }
  html[data-pwa-mode="installed"][data-sg-keyboard="open"]:not(.tg-webapp) :is(.bf-tabbar,.ds-bottomnav) {
    display:none;
  }
  html[data-pwa-mode="installed"][data-sg-keyboard="open"] :is(.bf-sheet-ov,.ds-sheet-ov:not(dialog),.ds-center-ov) {
    top:var(--sg-keyboard-top,0px); bottom:var(--sg-keyboard-bottom,0px);
  }
  html[data-pwa-mode="installed"][data-sg-keyboard="open"] :is(.bf-sheet,.ds-sheet,.ds-dialog) {
    max-height:calc(var(--sg-keyboard-height,100dvh) - 24px);
    overflow-y:auto;
  }
  html[data-pwa-mode="installed"][data-sg-keyboard="open"] dialog.sg-create-business-dialog[open] {
    top:var(--sg-keyboard-top,0px); bottom:auto; height:var(--sg-keyboard-height,100dvh);
  }
  html[data-pwa-mode="installed"][data-sg-keyboard="open"] dialog.sg-create-business-dialog .sg-create-business-form {
    max-height:var(--sg-keyboard-height,100dvh);
  }
}
@media(pointer:coarse) {
  html[data-pwa-mode="installed"] :is(.bf-root,.ds-screen,.sg-create-business-dialog) :is(input:not([type=checkbox],[type=radio],[type=range],[type=file],[type=color]),textarea,select) {
    font-size: max(16px,1em);
  }
  html[data-pwa-mode="installed"] :is(.bf-user,.ds-sheet-head .ds-icon-btn,.bf-sheet button) {
    min-height:44px; min-width:44px;
  }
}
html[data-pwa-mode="installed"] :is(.bf-user,.ds-bn,.bf-tab,.ds-more-item) {
  touch-action:manipulation; user-select:none; -webkit-user-select:none;
}
html[data-pwa-mode="installed"] .bf-screen { animation:none; }
/* Mail uses native document scrolling; do not make a second fixed viewport. */
html[data-pwa-mode="installed"] body.servgo-mail-v2 {
  box-sizing:border-box; min-height:100dvh;
  padding-top:env(safe-area-inset-top,0px);
  padding-left:env(safe-area-inset-left,0px);
  padding-right:env(safe-area-inset-right,0px);
}
html[data-pwa-mode="installed"] body.servgo-mail-v2 :is(main,.app) { min-height:100dvh; }
html[data-pwa-mode="installed"] body.servgo-mail-v2 .mail-workspace-links {
  min-width:0; flex-wrap:wrap;
}
@media(max-width:850px) {
  html[data-pwa-mode="installed"][data-sg-keyboard="open"] body.servgo-mail-v2 :is(.mail-v3-nav,.fab) { visibility:hidden; }
  html[data-pwa-mode="installed"][data-sg-keyboard="open"] body.servgo-mail-v2 :is(dialog,#search-dialog) {
    max-height:calc(var(--sg-keyboard-height,100dvh) - 24px); overflow:auto;
  }
}
@media(pointer:coarse) {
  html[data-pwa-mode="installed"] body.servgo-mail-v2 :is(input:not([type=checkbox],[type=radio]),textarea,select) { font-size:16px; }
  html[data-pwa-mode="installed"] body.servgo-mail-v2 .mail-workspace-links :is(a,button) {
    min-height:44px; touch-action:manipulation;
  }
}
/* Studio v4 owns its fixed header and home composer keyboard math. Only protect
   the existing shared navigation and inputs, without overriding its gesture logic. */
@media(pointer:coarse) {
  html[data-pwa-mode="installed"] body[data-growth-design="v4"] :is(input:not([type=checkbox],[type=radio],[type=range],[type=file]),textarea,select) {
    font-size: max(16px,1em);
  }
  html[data-pwa-mode="installed"] body[data-growth-design="v4"] .mobile-nav :is(a,summary) {
    min-height:44px; touch-action:manipulation;
  }
}
html[data-pwa-mode="installed"] body[data-growth-design="v4"] .shell { min-height:100dvh; }
@media(prefers-reduced-motion:reduce) {
  html[data-pwa-mode="installed"] :is(.bf-root,.ds-screen) :is(.bf-screen,.ds-sheet,.bf-sheet) { animation:none!important; transition:none!important; }
}
