/* 移动端底部导航栏 - 替代侧边栏的可靠方案 */

@media (max-width: 980px) {
  /* 底部导航栏 */
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
    background: var(--glass-strong, rgba(28,24,19,.92));
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line, rgba(255,255,255,.12));
    box-shadow: 0 -4px 12px rgba(0,0,0,0.2);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    color: var(--txt-dim, rgba(244,236,224,.62));
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 44px;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255, 138, 61, 0.2);
  }

  .mobile-nav-item:active {
    transform: scale(0.95);
    background: rgba(255,138,61,0.1);
  }

  .mobile-nav-item.active {
    color: var(--amber, #ff8a3d);
  }

  .mobile-nav-icon {
    font-size: 20px;
    line-height: 1;
  }

  .mobile-nav-label {
    font-size: 10px;
    line-height: 1;
  }

  /* 为底部导航留出空间 */
  body:has(.mobile-bottom-nav) .main {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
  }

  body:has(.mobile-bottom-nav) .composer {
    bottom: calc(60px + env(safe-area-inset-bottom, 0)) !important;
  }

  /* 独立聊天页使用固定三段布局：会话工具、消息滚动区、输入区 */
  body.chat-page-shell {
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
    padding-bottom: 0 !important;
  }

  body.chat-page-shell .app {
    height: calc(100vh - 60px - env(safe-area-inset-bottom, 0px)) !important;
    height: calc(100dvh - 60px - env(safe-area-inset-bottom, 0px)) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body.chat-page-shell .main {
    height: 100% !important;
    min-height: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden !important;
  }

  body.chat-page-shell .chat-page {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body.chat-page-shell .chat-page > .convs {
    display: none !important;
  }

  body.chat-page-shell .chat {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 0 14px !important;
  }

  body.chat-page-shell .mobile-conversation-tools {
    display: flex !important;
  }

  body.chat-page-shell .msgs {
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 14px 0 !important;
  }

  body.chat-page-shell .composer {
    position: relative !important;
    inset: auto !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 10px 0 12px !important;
    background: var(--ink, #161310) !important;
    box-shadow: 0 -4px 12px rgba(0,0,0,.15) !important;
  }

  body.chat-page-shell .composer .box {
    margin: 0 !important;
  }

  /* 隐藏原有的侧边栏和汉堡菜单 */
  .mobile-menu-toggle {
    display: none !important;
  }

  .side {
    display: none !important;
  }

  .mobile-overlay {
    display: none !important;
  }

  /* 顶部栏调整 */
  .top, .topbar {
    padding-left: 18px !important;
  }

  /* 更多菜单 */
  .mobile-more-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 60px;
    z-index: 999;
    background: var(--glass-strong, rgba(28,24,19,.92));
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line, rgba(255,255,255,.12));
    padding: 12px;
    display: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .mobile-more-menu.show {
    display: block;
    max-height: 400px;
  }

  .mobile-more-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--txt, #f4ece0);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    min-height: 44px;
  }

  .mobile-more-item:active {
    background: rgba(255,138,61,0.12);
    transform: scale(0.98);
  }

  .mobile-more-icon {
    width: 24px;
    text-align: center;
    font-size: 18px;
  }

  .mobile-more-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    display: none;
  }

  .mobile-more-overlay.show {
    display: block;
  }
}

@media (max-width: 980px) {
  body.chat-page-shell .composer {
    padding: 6px 0 8px !important;
  }

  body.chat-page-shell .suggest {
    gap: 5px !important;
    margin: 0 auto 6px !important;
    max-height: 34px !important;
    overflow: hidden !important;
  }

  body.chat-page-shell .suggest button {
    padding: 6px 9px !important;
    border-radius: 10px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  body.chat-page-shell .attach-list {
    margin-bottom: 6px !important;
  }

  body.chat-page-shell .box {
    gap: 7px !important;
    padding: 6px 7px !important;
    border-radius: 16px !important;
  }

  body.chat-page-shell .attach,
  body.chat-page-shell .attach-btn {
    width: 34px !important;
    height: 34px !important;
    border-radius: 11px !important;
    font-size: 15px !important;
  }

  body.chat-page-shell textarea {
    min-height: 34px !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
  }

  body.chat-page-shell .send {
    width: 38px !important;
    height: 38px !important;
    border-radius: 12px !important;
    font-size: 15px !important;
  }
}
