/* ================= 手机端适配 + PWA ================= */
#mBottomNav, #hamburger, #sideMask { display: none; }

@media (max-width: 820px) {
  /* 侧栏改为抽屉 */
  aside#sideNav {
    transform: translateX(-100%);
    transition: transform .22s ease;
    width: 78vw;
    max-width: 320px;
    z-index: 30 !important;
    box-shadow: 6px 0 24px rgba(11, 30, 79, .25);
  }
  aside#sideNav.open { transform: translateX(0); }

  #sideMask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 25;
  }
  #sideMask.show { display: block; }

  /* 顶部栏 */
  header {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  #hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #F3F5FA;
    margin-right: 8px;
    flex: none;
  }
  header .top-search { display: none !important; }
  header #userName { display: none !important; }
  header #logoutBtn { display: none !important; }
  header .sst-logo { height: 26px; }
  header .text-lg { font-size: 15px !important; }

  /* 主体留出底部导航空间 */
  main#mainArea {
    margin-left: 0 !important;
    padding: 12px 12px 78px !important;
    min-height: 100vh;
  }

  /* 栅格一律单列 */
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr !important; }
  #waGrid { grid-template-columns: 1fr !important; }
  #waThreads { max-height: 220px !important; }
  #waMsgs { min-height: 300px !important; max-height: none !important; }

  /* 卡片与标题缩小 */
  .card { border-radius: 12px !important; padding: 12px !important; }
  h2 { font-size: 17px !important; }
  .text-xl { font-size: 16px !important; }

  /* 表格横向滚动、字号收紧 */
  table { font-size: 12px; }
  .overflow-x-auto, .card { -webkit-overflow-scrolling: touch; }

  /* 弹窗铺满宽度 */
  .modal-box, .modal > div { max-width: 94vw !important; }
  #chatBox { padding: 10px !important; }

  /* 列表页两列并排（左侧列表+右侧详情）在手机上改为上下 */
  .flex.gap-4 > .w-64 { width: 100% !important; max-height: 200px; }
  .flex.gap-4 { flex-direction: column; height: auto !important; }

  /* 底部导航 */
  #mBottomNav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 28;
    background: #fff;
    border-top: 1px solid #ECEFF5;
    box-shadow: 0 -2px 12px rgba(11, 30, 79, .06);
    padding-bottom: env(safe-area-inset-bottom);
  }
  #mBottomNav > button {
    flex: 1;
    padding: 8px 0 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #64748B;
  }
  #mBottomNav > button i { font-size: 17px; }
  #mBottomNav > button.on { color: var(--sst-primary); font-weight: 600; }
}

/* 真机安全区 */
@supports (padding: env(safe-area-inset-bottom)) {
  @media (max-width: 820px) {
    main#mainArea { padding-bottom: calc(78px + env(safe-area-inset-bottom)) !important; }
  }
}

/* 安装提示条 */
#installBar {
  display: none;
  position: fixed;
  left: 10px; right: 10px; bottom: 70px;
  z-index: 40;
  background: #0B1E4F;
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(11, 30, 79, .3);
}
#installBar button { font-size: 12px; padding: 4px 10px; border-radius: 8px; }
