
@media (max-width: 700px) {
  html.ph { --ph-top: 0px; --ph-sat: env(safe-area-inset-top, 0px); --ph-bot: var(--ph-tabs-h); --ph-sab: env(safe-area-inset-bottom, 0px); }
  /* the email bar sits at the very top, so it takes the notch space and the screen under it does not add it again */
  html.ph body.has-mail-bar { --ph-top: calc(36px + env(safe-area-inset-top, 0px)); --ph-sat: 0px; }
  html.ph:not(.desk-tb) #mail-bar.show { height: var(--ph-top); padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  html.ph:not(.desk-tb) #mail-bar .mb-x { top: calc(50% + env(safe-area-inset-top, 0px) / 2); }
  html.desk-tb.ph body { --ph-top: 32px; --ph-sat: 0px; }
  html.desk-tb.ph body.has-mail-bar { --ph-top: 68px; }

  /* full-screen app layers start under the top strip instead of sliding under the email bar */
  html.ph body.vc-open #voice-call-screen { top: var(--ph-top); }
  html.ph .main.stage-split > #chat-view { top: var(--ph-top) !important; }
  /* toasts and the offline dot: under the top strip and the notch */
  html.ph #toast-container { top: calc(var(--ph-top) + var(--ph-sat) + 8px); }
  html.ph #offline-banner { top: calc(var(--ph-top) + var(--ph-sat) + 6px); }
  /* the stream mini on the call screen: under the call's top buttons */
  html.ph #stream-mini { top: calc(var(--ph-top) + var(--ph-sat) + 66px); }

  /* ---------- the float stack ---------- */
  html.ph #ux-tip, html.ph #act-chip, html.ph #music-mini, html.ph body:not(.vc-open) #stream-mini {
    top: auto !important; bottom: var(--ph-fl-b, calc(var(--ph-bot) + 10px)) !important; z-index: 300 !important;
    transition: bottom .2s cubic-bezier(.2,.8,.2,1);
  }
  html.ph #ux-tip, html.ph #music-mini { left: 12px !important; right: 12px !important; width: auto !important; max-width: none !important; inset-inline: 12px !important; }
  html.ph #act-chip, html.ph body:not(.vc-open) #stream-mini { inset-inline-end: 12px !important; inset-inline-start: auto !important; max-width: calc(100vw - 24px); }
  html.ph #music-mini .mm-t b { max-width: none; }
  /* while a sheet, the game window or the keyboard is up, floats step aside */
  html.ph body.kb-open :is(#ux-tip, #act-chip, #music-mini), html.ph body:has(#ph-plus.on, #ph-status.on, #vc-prejoin.open) :is(#ux-tip, #act-chip, #music-mini, #stream-mini) { visibility: hidden; }

  /* the quick profile menu: a sheet above the bottom strip instead of a popup that lands on the call's top buttons */
  html.ph #ux-menu { left: 8px !important; right: 8px !important; top: auto !important; bottom: calc(var(--ph-bot) + 8px) !important; min-width: 0; max-width: none;
    max-height: calc(var(--vvh, 100dvh) - var(--ph-top) - var(--ph-sat) - var(--ph-bot) - 16px); overflow-y: auto; border-radius: 16px; z-index: 410; }
  html.ph #ux-menu button { min-height: 44px; }

  /* ---------- call screen ---------- */
  /* one person: the square tile shrinks to the room between the top buttons and the "Add people" card, so the card never covers it */
  html.ph body #voice-call-screen #stage-members .tile:only-child {
    max-width: max(140px, calc(var(--vvh, 100dvh) - var(--ph-top) - var(--ph-sat) - 66px - 210px - var(--ph-sab)));
    justify-self: center; width: 100%;
  }
  /* the name pill is centred on phones; the regular themes' corner pill reset the position but kept the centring shift, so it slid off the tile's left edge */
  html.ph #voice-call-screen .tile .tile-label { min-width: 0; }

  /* ---------- the "Voice Connected" box under the channel list ---------- */
  /* its six buttons stay on one row on narrow phones instead of wrapping into a second row */
  html.ph .channels-pane .voice-connected-dock .voice-dock-tiles { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
  html.ph .channels-pane .voice-connected-dock .voice-dock-tile { min-width: 0; }

  /* ---------- small phones (iPhone SE / mini, small Androids) ---------- */
  html.ph .ph-addf { white-space: nowrap; flex: none; }
  html.ph .ph-dmrow b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 359px) {
  html.ph .ph-addf { width: 34px; padding: 0; justify-content: center; }
  html.ph .ph-addf span { display: none; }
  html.ph .channels-pane .voice-connected-dock .voice-dock-tile { height: 40px; }
  /* call screen: the top buttons give the channel name a little more room, and the invite card stays one line tall */
  html.ph body #voice-call-screen .vc-top { gap: 6px; left: 10px; right: 10px; }
  html.ph #voice-call-screen .vc-sq { width: 40px; height: 40px; flex-basis: 40px; }
  html.ph #voice-call-screen .vc-pill { padding: 0 8px; }
  html.ph #voice-call-screen .vc-addcard i { display: none; }
  html.ph #voice-call-screen .vc-addcard b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.ph #voice-call-screen .vc-addcard .vc-addtxt { min-width: 0; }
  /* the call controls: five round buttons and the red one fit inside the bar (they ran 4px past it at 320px) */
  html.ph body #voice-call-screen .voice-floating-bar { padding-inline: 10px; }
  html.ph body #voice-call-screen .voice-floating-bar .control-pill-btn { width: 42px; height: 46px; }
  html.ph body #voice-call-screen .voice-floating-bar .control-pill-btn.danger-leave, html.ph body #voice-call-screen .voice-floating-bar .vc-leave { width: 54px; height: 48px; }
}
/* ---------- short screens: phones on their side, or a small window ---------- */
@media (max-width: 700px) and (max-height: 560px) {
  /* the call: the invite card gives its room back to the tile (Invite stays in the top bar) */
  html.ph body #voice-call-screen .vc-addcard { display: none !important; }
  html.ph body #voice-call-screen .voice-stage-grid { padding-bottom: calc(118px + var(--ph-sab)) !important; }
  html.ph body #voice-call-screen #stage-members .tile:only-child { max-width: max(120px, calc(var(--vvh, 100dvh) - var(--ph-top) - var(--ph-sat) - 66px - 128px - var(--ph-sab))); }
  html.ph body #voice-call-screen .voice-floating-bar { padding-top: 18px; padding-bottom: 8px; }
  /* the channel list keeps most of the height: the voice box shows its status line only */
  html.ph .channels-pane .voice-connected-dock .voice-dock-tiles { display: none; }
  html.ph .channels-pane .voice-connected-dock { padding: 8px 10px; }
}
@media (max-width: 700px) and (max-height: 420px) {
  html.ph { --ph-tabs-h: calc(48px + env(safe-area-inset-bottom, 0px)); }
  .ph-tab > span:not(.ph-tab-av) { display: none; }
}
