/* TOTEM phone shell — order cdf4e076, apps lane, 2026-10-13 (Hajib: "screens and all everything overlaps").
   Loaded by /meet/ after totem-mobile.css. ONE layout for phones in portrait AND landscape:
     top band   — Back (left) · host pill (centre, hosts only) · Chancery (right); the lobby's music pill sits centre
     body       — the call (or the lobby), scrolling inside its own box
     bottom bar — the call controls (#ctrl-bar); the AI button lives IN the bar on phones, not floating over video
   Panels (chat / people / notes / host) are full-width sheets BETWEEN the band and the bar; pickers and the Chancery are
   sheets above everything; nothing floats over video, chat or the keyboard. ONE stacking scale below — every layer
   that used to carry its own number (60 … 2147483600) is put on it. Desktop is untouched.
   Root cause it fixes: #call was its own stacking context (z-index 1), so the side panel inside it could never rise
   above body-level buttons, whatever z-index it had; and the band the floating pills sit in was reserved only in the
   portrait lobby (totem-mobile.css, max-width 600px) — not in a call, and not in landscape at all. */
:root{
  --tc-band: calc(env(safe-area-inset-top, 0px) + 58px);
  --tc-pill-top: calc(env(safe-area-inset-top, 0px) + 7px);
  --tc-bar: var(--bar-h, 66px);
  --tc-safe-b: env(safe-area-inset-bottom, 0px);
  --tc-kb: 0px;
  --z-tile-ui: 5; --z-edge: 250; --z-band: 300; --z-bar: 400; --z-panel: 500; --z-pop: 600; --z-sheet: 700; --z-modal: 800; --z-toast: 900;
}
/* Desktop: the bar's AI button exists only on phones (desktop keeps its floating ★). */
#ctrl-bar .cbar-btn[data-proxy="ai-fab"]{display:none}

@media (max-width: 600px), (max-height: 500px) and (max-width: 1000px){
  /* ── 1. Top band: three pills on one row, reserved space under them ── */
  #app-back, #chy-launch, #lobby-mute, #totem-host-float.min{
    position:fixed !important; top:var(--tc-pill-top) !important; bottom:auto !important; height:44px !important; min-width:44px !important;
    box-sizing:border-box !important; padding:0 12px !important; border-radius:999px !important;
    font:500 14px/42px Inter, system-ui, sans-serif !important; letter-spacing:0 !important;
    background:var(--tm-panel, #111829) !important; color:var(--tm-ink, #F4EFE2) !important;
    border:1px solid var(--tm-line, #26314A) !important; z-index:var(--z-band) !important; white-space:nowrap !important;
  }
  #app-back{left:calc(env(safe-area-inset-left, 0px) + 12px) !important; right:auto !important; padding-top:0 !important}
  #chy-launch{right:calc(env(safe-area-inset-right, 0px) + 12px) !important; left:auto !important; padding-top:0 !important; opacity:1 !important}
  #lobby-mute{left:50% !important; right:auto !important; transform:translateX(-50%) !important; color:var(--tm-gold-text, #D8BA62) !important}
  .topbar{padding-top:var(--tc-band) !important}
  /* the lobby help "?" stays bottom-right above the bottom nav; never in a call (the bar is there) */
  .ampam-help-btn{z-index:var(--z-band) !important}
  body.in-call .ampam-help-btn{display:none !important}
  .ampam-help-panel{z-index:var(--z-sheet) !important; height:100dvh !important}

  /* ── 2. In a call: band strip + the call box between band and bar ── */
  /* the call screen is dark in both themes, so its band and pills use the dark call palette */
  body.in-call{--tm-bg:#0A0E1A; --tm-panel:#111829; --tm-line:#26314A; --tm-ink:#F4EFE2; --tm-gold-text:#D8BA62}
  body.in-call::after{content:""; position:fixed; left:0; right:0; top:0; height:var(--tc-band);
    background:var(--tm-bg, #0A0E1A); border-bottom:1px solid var(--tm-line, #26314A); z-index:calc(var(--z-band) - 1); pointer-events:none}
  body.in-call .topbar, body.in-call #topbar-handle, body.in-call #header-toggle, body.in-call #toolbar-toggle{display:none !important}
  /* the lobby music pills leave with the lobby: in a call, music is in the bar's 🔊 menu (listener) and the host panel */
  body.in-call #lobby-mute, body.in-call #lobby-stopall{display:none !important}
  .topbar nav a{min-height:44px !important; display:inline-flex !important; align-items:center !important}
  .topbar nav .totem-theme-toggle, #totem-theme-toggle{min-width:44px !important; min-height:44px !important}
  .lobby .tabs .tab, #tab-host, #tab-join{min-height:44px !important}
  .ampam-help-btn{width:44px !important; height:44px !important}
  /* host-only "Stop music (all)" (lobby only): a pill bottom-left above the nav, mirroring the "?" on the right */
  #lobby-stopall{left:12px !important; right:auto !important; bottom:calc(var(--tc-safe-b) + 72px) !important; height:44px !important;
    border-radius:999px !important; z-index:var(--z-band) !important; font:500 14px/1 Inter, system-ui, sans-serif !important}
  #lo-rejoin, #lo-lobby{min-height:44px !important}
  html body.in-call #call.active{
    position:relative !important; z-index:auto !important;      /* no stacking context: panels can rise above the band */
    height:100dvh !important; max-height:none !important; box-sizing:border-box !important;
    padding-top:var(--tc-band) !important; margin-top:0 !important;
  }
  body.in-call .call-body{padding-bottom:calc(var(--tc-bar) + 8px + var(--tc-safe-b)) !important}
  #ctrl-bar{z-index:var(--z-bar) !important}
  body.in-call #sidebar-toggle{z-index:var(--z-edge) !important}
  body.side-open #sidebar-toggle{display:none !important}       /* the panel has its own close (x) */
  /* long names never overflow: one line, ellipsis */
  body.in-call .tile .label{white-space:nowrap !important; overflow:hidden !important; text-overflow:ellipsis !important;
    max-width:calc(100% - 16px) !important; box-sizing:border-box !important}
  body.in-call #rn-name, body.in-call #rn-meta{white-space:nowrap; overflow:hidden; text-overflow:ellipsis}

  /* ── 3. Panels: full-width sheet between the band and the bar ── */
  body.in-call .side{
    top:var(--tc-band) !important; bottom:calc(var(--tc-bar) + var(--tc-safe-b)) !important; height:auto !important;
    left:0 !important; right:0 !important; width:100% !important; max-width:none !important;
    padding-bottom:8px !important; box-sizing:border-box !important; z-index:var(--z-panel) !important;
    border-left:0 !important; border-top:1px solid var(--tm-line, #26314A) !important;
  }
  body.in-call .side .panel-tabs{padding-right:52px !important; overflow-x:auto !important; flex-wrap:nowrap !important; scrollbar-width:none}
  body.in-call .side .panel-tabs::-webkit-scrollbar{display:none}
  body.in-call .side .panel-tab{flex:none !important; min-height:44px !important; white-space:nowrap !important}
  body.in-call .side #side-close-btn{display:flex !important; position:absolute !important; top:4px !important; right:4px !important;
    width:44px !important; height:44px !important; align-items:center !important; justify-content:center !important; z-index:5 !important}
  body.in-call #sidebar-toggle{min-width:44px !important}
  /* panel controls at thumb size: checkbox rows, action buttons, the people panel's role buttons and inputs */
  body.in-call .side .toggle{min-height:44px !important; display:flex !important; align-items:center !important; justify-content:space-between !important; gap:12px}
  body.in-call .side input[type=checkbox]{width:24px !important; height:24px !important; flex:none}
  body.in-call .side button, body.in-call .side .act{min-height:44px !important}
  body.in-call .side input:not([type=checkbox]):not([type=radio]):not([type=file]), body.in-call .side select{min-height:44px !important; font-size:16px !important}
  #chat-file-btn{min-height:44px !important}
  /* keyboard open: the bar steps aside, the panel sits on the keyboard, the message box stays in view */
  body.tc-kb #ctrl-bar{display:none !important}
  body.in-call.tc-kb .side{bottom:var(--tc-kb) !important}
  body.in-call.tc-kb .call-body{padding-bottom:calc(var(--tc-kb) + 8px) !important}

  /* ── 4. Host controls: a pill in the band; opened, a sheet under the band ── */
  #totem-host-float{z-index:var(--z-panel) !important}
  #totem-host-float.min{left:50% !important; right:auto !important; transform:translateX(-50%) !important; width:auto !important;
    color:var(--tm-gold-text, #D8BA62) !important; align-items:center; gap:6px; cursor:pointer}
  #totem-host-float:not(.min){
    top:var(--tc-band) !important; left:8px !important; right:8px !important; bottom:auto !important; transform:none !important;
    width:auto !important; max-width:none !important; max-height:calc(100dvh - var(--tc-band) - var(--tc-bar) - var(--tc-safe-b) - 16px) !important;
    overflow:auto !important; box-sizing:border-box !important;
  }
  #totem-host-float .thf-hd{min-height:36px}
  #totem-host-float button{min-height:44px}
  /* while a panel is open on a phone the host pill steps back (meet.html already hides it there) */

  /* ── 5. Floating extras off the video: AI moves into the bar ── */
  body.in-call #ai-fab{display:none !important}
  #ctrl-bar .cbar-btn[data-proxy="ai-fab"]{display:flex}
  body.in-call #chat-input, body.in-call #chat-send, body.in-call #ai-input, body.in-call #ai-send{min-height:44px !important}
  .bgs-tab, #bgs-feather{min-height:44px !important}
  #bg-close, #ai-popup-close, #chy-close{min-width:44px !important; min-height:44px !important}
  #ai-popup-input, #ai-popup-send{min-height:44px !important; font-size:16px !important}
  #ai-popup{z-index:var(--z-sheet) !important; left:8px !important; right:8px !important; width:auto !important; max-width:none !important;
    top:var(--tc-band) !important; bottom:calc(var(--tc-bar) + var(--tc-safe-b) + 8px) !important; max-height:none !important; height:auto !important}
  body.tc-kb #ai-popup{bottom:var(--tc-kb) !important}

  /* ── 6. Popovers, sheets, modals, toasts on the one scale ── */
  #reactions-bar, #audio-pop{z-index:var(--z-pop) !important}
  #reactions-bar{max-width:calc(100vw - 16px) !important; overflow-x:auto !important; bottom:calc(var(--tc-bar) + var(--tc-safe-b) + 8px) !important}
  #audio-pop{bottom:calc(var(--tc-bar) + var(--tc-safe-b) + 8px) !important; max-width:calc(100vw - 16px) !important}
  #bg-sheet, .sheet-overlay{z-index:var(--z-sheet) !important}
  #chyovl{z-index:var(--z-sheet) !important}
  #chyovl > div{max-height:calc(100dvh - 24px) !important}
  .left-overlay, .connecting-overlay, #tis-overlay{z-index:var(--z-modal) !important}
}
/* Phones with the bottom nav (up to 768px wide): Help is the nav's fifth item; no "?" floating over the lobby form. */
@media (max-width: 768px){
  .bottom-nav-inner{grid-template-columns:repeat(5, 1fr) !important}
  .ampam-help-btn{display:none !important}
}
/* Wider screens keep the floating "?" (desktop) — and the nav's Help item never shows there (the nav is hidden). */
/* Landscape phones: a slimmer band, and the pills/lobby get the phone treatment portrait already has. */
@media (max-height: 500px) and (max-width: 1000px){
  :root{--tc-band: calc(env(safe-area-inset-top, 0px) + 54px); --tc-pill-top: calc(env(safe-area-inset-top, 0px) + 5px)}
  .topbar{height:auto !important}
  body:not(.in-call) .ampam-help-btn{left:auto !important; right:12px !important; bottom:calc(var(--tc-safe-b) + 12px) !important; width:44px !important; height:44px !important}
  #lobby-mute{bottom:auto !important}
}
/* Landscape phones are wider than 768px, so the 07-25 "one clean column" stage fix never reached them and the smart
   multi-row view stacked tiles on each other. Same unwrap, two columns, 16:9 tiles; extra tiles scroll inside the stage. */
@media (max-height: 500px) and (max-width: 1000px) and (min-width: 769px){
  body.in-call #stage{display:grid !important; grid-template-columns:repeat(2, minmax(0, 1fr)) !important; grid-template-rows:none !important; grid-template-areas:none !important; grid-auto-rows:auto !important;
    align-content:start !important; align-items:start !important; gap:6px !important; overflow:auto !important; height:100% !important}
  body.in-call #stage .medium-row, body.in-call #stage .name-row, body.in-call #stage .strip,
  body.in-call #stage .share-main, body.in-call #stage .share-people-strip{display:contents !important}
  body.in-call #stage .tile:not(.screen){grid-row:auto !important; grid-column:auto !important; width:auto !important; height:auto !important;
    max-width:none !important; aspect-ratio:auto !important; min-height:0 !important; height:calc((50vw - 12px) * 0.5625) !important; margin:0 !important; overflow:hidden !important}
  body.in-call #stage .tile:not(.screen) > video{width:100% !important; height:100% !important; object-fit:cover !important}
  body.in-call #stage .tile.screen{grid-column:1 / -1 !important}
  .topbar nav a{min-width:44px !important; justify-content:center !important}
}
