/* 手机适配（必须最后加载，覆盖前面的样式） */
/* ---------- 手机 ---------- */
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (max-width: 820px) {
  body { font-size: 16px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); z-index: 40; border-right: 0;
    border-radius: 0 22px 22px 0; transform: translateX(-104%);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow);
  }
  .sidebar-head { padding: 14px 12px 8px; gap: 10px; }
  .brand { font-size: 17px; padding: 4px 6px; }
  .brand img { width: 28px; height: 28px; }
  .search input { min-height: 40px; border-radius: 12px; }
  .conv { height: 44px; border-radius: 10px; font-size: 15px; }
  .nav-item { height: 46px; border-radius: 10px; font-size: 15px; }
  .layout.nav-open .sidebar { transform: none; }
  .overlay {
    display: block; position: fixed; inset: 0; z-index: 35; pointer-events: none;
    background: rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity .28s;
  }
  .layout.nav-open .overlay { opacity: 1; pointer-events: auto; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding-left: 6px; padding-right: 6px; gap: 2px; }
  .topbar .icon-btn { width: 40px; height: 40px; border-radius: 12px; }
  .topbar h2 { font-size: 17px; }
  .model-picker { flex: 0 1 auto; }
  .model-btn {
    height: 38px; padding: 0 10px 0 5px; border-radius: 99px; gap: 7px; font-size: 15px;
    background: var(--panel); border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }
  .model-btn .avatar { width: 26px; height: 26px; border-radius: 50%; font-size: 12px; }
  .model-btn .prov { display: none; }

  /* 模型选择：从底部弹出 */
  .sheet-bg { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 45; animation: fade .2s; }
  .model-menu {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 46; width: 100%;
    max-height: 72dvh; padding: 8px 10px calc(12px + env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0; border-width: 1px 0 0; animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1);
  }
  .sheet-title { display: block; text-align: center; font-weight: 600; font-size: 15px; padding: 18px 0 8px; position: relative; }
  .sheet-title::before, .modal::before {
    content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px;
    border-radius: 99px; background: var(--border);
  }
  .model-opt { padding: 11px 12px; border-radius: 12px; }
  .model-opt .avatar { width: 32px; height: 32px; border-radius: 10px; }

  .thread-inner { padding: 4px 16px 20px; }
  /* 对比：左右滑动，一屏一个模型，露出下一个的边缘提示可以滑 */
  .cmp-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 8px; padding: 0 16px; scrollbar-width: none; }
  .cmp-tabs::-webkit-scrollbar { display: none; }
  .cmp-tab {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; height: 32px; padding: 0 12px 0 5px;
    border-radius: 99px; border: 1px solid var(--border); background: var(--panel); font-size: 13px; color: var(--muted);
  }
  .cmp-tab .avatar { width: 22px; height: 22px; border-radius: 50%; font-size: 11px; }
  .cmp-tab.on { border-color: var(--accent); color: var(--text); font-weight: 600; background: var(--accent-soft); }
  .cmp-grid {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin: 0 -16px; padding: 0 16px 4px;
    scrollbar-width: none; overscroll-behavior-x: contain;
  }
  .cmp-grid::-webkit-scrollbar { display: none; }
  .cmp-col { flex: 0 0 88%; scroll-snap-align: center; padding: 12px 14px 6px; }
  .msg.user .bubble { max-width: 86%; }
  .msg .actions .icon-btn { width: 34px; height: 34px; }
  .welcome { min-height: 66vh; }
  .welcome h1 { font-size: 23px; }
  .md pre { font-size: 12.5px; }
  .composer-wrap { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 24px; }
  .att-img img { width: 110px; height: 110px; }
  .send-btn { width: 40px; height: 40px; }

  .admin-inner { padding: 4px 14px 32px; }
  .grid2 { grid-template-columns: 1fr; }
  .pw-form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .modal-bg { place-items: end center; padding: 0; }
  .modal {
    border-radius: 22px 22px 0 0; width: 100%; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom);
    position: relative; border-width: 1px 0 0; animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1);
  }
  .modal-head { padding-top: 22px; }
  .hide-sm { display: none; }
}

/* 手机：画图 / 视频参数收成一行，点开再改 */
@media (max-width: 820px) {
  .media-bar { flex-wrap: nowrap; gap: 8px; padding: 0 2px 2px; }
  .m-inline { display: none; }
  .m-summary {
    display: inline-flex; align-items: center; gap: 4px; min-width: 0; flex: 1 1 auto; justify-content: flex-start;
    border: 1px solid var(--border); background: var(--panel); border-radius: 99px; padding: 4px 8px 4px 12px;
    font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden;
  }
  .m-summary .m-caret { display: inline-grid; color: var(--faint); margin-left: auto; }
  .m-summary .m-caret svg { width: 14px; height: 14px; }
  .mest { flex-shrink: 0; margin-left: 0; }
}

/* 充值申请表单：手机上一列 */
@media (max-width: 820px) {
  .topup-form { grid-template-columns: 1fr; }
}

/* 收款码：手机上两列 */
@media (max-width: 820px) {
  .pay-qr { width: calc(50% - 6px); padding: 10px; }
  .pm-row { flex-direction: column; }
}
