@media (max-width: 640px) {

  header.topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
  }

  header.topbar .brand {
    width: 100%;
  }

  /* === LAYOUT: Connected (left) + Logout (right), Email below === */
  header.topbar .top-actions {
    width: 100% !important;

    display: grid !important;
    grid-template-columns: auto 1fr auto !important; /* key change */
    grid-auto-rows: auto !important;

    column-gap: 10px !important;
    row-gap: 10px !important;

    align-items: center !important;
  }

  /* Place items explicitly (more reliable than template-areas on iOS) */
  header.topbar .top-actions #auth-status {
    grid-column: 1 !important;
    grid-row: 1 !important;

    /* shrink-wrap for real */
    display: inline-flex !important;
    width: auto !important;
    justify-self: start !important;

    white-space: nowrap !important;
    max-width: 100% !important;
  }

  header.topbar .top-actions #btn-logout {
    grid-column: 3 !important;
    grid-row: 1 !important;

    width: auto !important;
    justify-self: end !important;

    white-space: nowrap !important;
    padding: 9px 12px !important;
  }

  header.topbar .top-actions #user-email {
    grid-column: 1 / -1 !important; /* span full grid width */
    grid-row: 2 !important;

    /* make it a pill like status, but NOT full width */
    display: inline-block !important;
    width: auto !important;
    justify-self: start !important;

    padding: 7px 12px !important;
    border-radius: 9999px !important;
    border: 1px solid rgba(255,255,255,0.14) !important;
    background: rgba(255, 255, 255, 0.06) !important;
    color: rgba(255,255,255,0.85) !important;

    /* wrapping allowed */
    white-space: normal !important;
    word-break: break-word !important;
    overflow: visible !important;

    /* keep it from overflowing screen */
    max-width: 100% !important;
    line-height: 1.2 !important;
  }
}


 
@media (max-width: 640px) {
  /* Hide the email pill if it has no text */
  header.topbar .top-actions #user-email:empty {
    display: none !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }
}

