/* =========================================================================
   手机端精修层 v2 —— 与桌面客户端完全同一套视觉语言
   -------------------------------------------------------------------------
   桌面端有的：品牌三色渐变、护盾水印、点阵壁纸、超椭圆群头像、E2EE 徽章、
   消息分组、胶囊输入区、磨砂弹层、悬浮圆角控件
   手机端这里逐项对齐，同时按触屏习惯加大尺寸、留出安全区
   ========================================================================= */

@media (max-width: 860px) {

  /* ---------- 布局骨架：列表/会话都要给底部 Tab 让位 ---------- */
  .shell { height: 100dvh; position: relative; overflow: hidden; }
  .list-panel {
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: calc(58px + var(--safe-b));
    width: 100%;
    z-index: 4;
    display: flex;
    flex-direction: column;
  }
  .chat-panel {
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: calc(58px + var(--safe-b));
    z-index: 8;
  }
  .app-chat-open .chat-panel { bottom: 0; }
  .app-chat-open .list-panel { transform: translateX(-22%); opacity: 0; pointer-events: none; }

  /* ---------- 顶部：☰ + 头像 + 动作（与桌面同构） ---------- */
  .list-head {
    padding: calc(10px + var(--safe-t)) 12px 10px;
    background: var(--panel);
    box-shadow: 0 1px 0 var(--hairline);
  }
  .list-title-row { padding: 0 0 10px; gap: 10px; }
  .list-head .menu-btn { width: 38px; height: 38px; border-radius: 12px; }
  .me-avatar-btn { width: 40px; height: 40px; }
  .me-avatar-btn .avatar { width: 40px; height: 40px; font-size: 15px; }
  .list-actions .icon-btn { width: 38px; height: 38px; border-radius: 12px; }
  .search-wrap input {
    padding: 11px 12px 11px 38px;
    font-size: 14.5px;                /* ≥16 会触发 iOS 缩放，这里用 14.5 + 已设 viewport 限制 */
    border-radius: 14px;
  }
  .search-wrap .search-ico { left: 13px; width: 17px; height: 17px; }
  .list-mode-tag { padding: 0 2px 8px; font-size: 11.5px; }

  /* ---------- 列表：卡片化、触摸目标 ≥ 60px ---------- */
  .list-scroll { padding: 8px 8px 16px; }
  .list-item {
    padding: 11px 12px;
    margin: 3px 0;
    border-radius: 18px;
    gap: 13px;
  }
  .list-item::before { height: 30px; width: 3.5px; }
  .list-item .avatar { width: 52px; height: 52px; font-size: 18px; }
  .li-name { font-size: 16.5px; font-weight: 650; }
  .li-preview { font-size: 13.5px; margin-top: 3px; }
  .li-time { font-size: 11.5px; }
  .li-badge { min-width: 22px; height: 22px; font-size: 12px; border-radius: 11px; }
  .list-item:active { background: var(--row-hover); transform: scale(.985); }
  .section-label { padding: 16px 14px 8px; font-size: 11.5px; }

  /* ---------- 底部 Tab：品牌渐变 + 动效 ---------- */
  .rail {
    background: var(--panel-glass);
    backdrop-filter: blur(20px) saturate(1.4);
    border-top: 1px solid var(--hairline);
    box-shadow: 0 -8px 24px -18px rgba(16, 40, 70, .7);
    padding: 6px 8px calc(6px + var(--safe-b));
  }
  .rail-btn { width: 62px; height: 48px; border-radius: 14px; }
  .rail-btn svg { width: 24px; height: 24px; }
  .rail-btn.active { color: var(--accent); }
  .rail-btn.active::after {
    height: 3px; width: 22px; border-radius: 3px;
    background: var(--brand-grad);
    box-shadow: 0 4px 12px -4px var(--accent-glow);
    bottom: 3px;
  }
  .rail-btn:active { transform: scale(.92); }
  .rail-badge { top: 3px; right: 10px; min-width: 18px; height: 18px; font-size: 11px; }

  /* ---------- 会话页：头部与桌面同构 ---------- */
  .chat-head {
    padding: calc(9px + var(--safe-t)) 8px 9px;
    gap: 8px;
    background: var(--panel);
    box-shadow: 0 1px 0 var(--hairline), 0 12px 28px -26px rgba(16, 40, 70, .8);
  }
  .back-btn { width: 38px; height: 38px; border-radius: 12px; }
  .back-btn svg { width: 24px; height: 24px; }
  .chat-head-avatar .avatar { width: 38px; height: 38px; font-size: 14px; }
  .chat-head-name { font-size: 16px; }
  .chat-head-name .e2ee { font-size: 9.5px; padding: 1px 6px; margin-left: 6px; }
  .chat-head-sub { font-size: 12px; margin-top: 1px; }
  .chat-head-actions .icon-btn { width: 36px; height: 36px; border-radius: 12px; }

  /* ---------- 消息：气泡与桌面同尺寸语言 ---------- */
  .msg-inner { padding: 14px 0 8px; }
  .msg-row { padding: 0 12px; margin-bottom: 4px; }
  .msg-col { max-width: 84%; }
  .bubble {
    font-size: 15.5px; line-height: 1.48;
    padding: 9px 13px 8px;
    border-radius: 18px;
  }
  .msg-row.in .bubble { border-bottom-left-radius: 6px; }
  .msg-row.out .bubble { border-bottom-right-radius: 6px; }
  .msg-row.cont.in .bubble { border-top-left-radius: 6px; }
  .msg-row.cont.out .bubble { border-top-right-radius: 6px; }
  .msg-row .avatar { width: 30px; height: 30px; font-size: 12px; }
  .msg-sender { font-size: 12.5px; margin: 2px 9px 4px; }
  .msg-meta { font-size: 11px; margin: 4px 7px 2px; }
  .msg-sep { margin: 16px 0 12px; }
  .msg-sep span, .msg-system span { font-size: 11.5px; padding: 5px 13px; }
  .bubble .quote { padding: 6px 10px; margin-bottom: 6px; font-size: 13px; }
  .bubble .quote .q-text { max-width: 56vw; }
  .fwd-flag { font-size: 11.5px; }

  /* 图片 / 相册：贴屏更宽 */
  .bubble.media { border-radius: 18px; }
  .img-single { max-width: 66vw; border-radius: 14px; }
  .album { width: 68vw; max-width: 68vw; border-radius: 14px; }
  .album-cell:first-child { border-top-left-radius: 11px; }
  .bubble-caption { padding: 8px 8px 4px; font-size: 15px; }
  .media-meta { font-size: 11px; padding: 4px 8px 3px; }

  /* 文件卡片 */
  .bubble.file-card { border-radius: 18px; }
  .bubble.file-card .file-row { padding: 13px 14px; }
  .file-ico { width: 44px; height: 44px; border-radius: 13px; }
  .file-name { font-size: 14.5px; }
  .file-dl { width: 38px; height: 38px; }

  /* ---------- 输入区：胶囊条 + 大方按钮 ---------- */
  .composer { padding: 6px 10px calc(10px + var(--safe-b)); }
  .composer-row {
    border-radius: 24px;
    padding: 5px 5px 5px 8px;
    gap: 3px;
    border: 1px solid var(--hairline);
    background: var(--panel);
    box-shadow: var(--shadow-2);
  }
  .composer textarea {
    font-size: 16px;                 /* iOS 聚焦不缩放 */
    min-height: 42px;
    padding: 10px 6px;
    border-radius: 20px;
  }
  .composer .icon-btn { width: 38px; height: 38px; border-radius: 13px; }
  .send-btn { width: 42px; height: 42px; border-radius: 50%; }
  .send-btn svg { width: 20px; height: 20px; }
  .attach-preview { padding: 4px 2px 10px; gap: 8px; }
  .att-chip { width: 74px; height: 74px; border-radius: 14px; }
  .reply-bar { padding: 8px 12px; border-radius: 12px; font-size: 13px; }
  .reply-bar .rb-text { max-width: 52vw; }

  /* 多选操作条 */
  .multi-bar { padding: 10px 12px; border-radius: 16px; gap: 8px; flex-direction: column; align-items: stretch; }
  .multi-bar .mb-count { text-align: center; font-size: 13px; }
  .multi-bar .mb-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .multi-bar .mb-btn { padding: 9px 4px; font-size: 13px; text-align: center; }

  /* 表情面板：贴底大面板 */
  .emoji-panel {
    left: 8px; right: 8px; bottom: calc(100% + 6px);
    height: 44vh; max-height: 380px;
    border-radius: 20px;
    box-shadow: var(--shadow-3);
  }
  .emoji-tabs { padding: 8px 8px 0; gap: 4px; }
  .emoji-tabs button { font-size: 19px; padding: 7px 9px; }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); gap: 3px; padding: 10px; }
  .emoji-grid button { height: 46px; font-size: 25px; }
  .emoji-stickers { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
  .emoji-stickers button { height: 92px; font-size: 48px; }

  /* ---------- 弹层：全屏 sheet，带头部 ---------- */
  .modal {
    border-radius: 0;
    background: var(--panel);
    animation: sheetUp .26s var(--ease);
  }
  @keyframes sheetUp { from { opacity: 0; transform: translateY(18px); } }
  .modal-head {
    padding: calc(14px + var(--safe-t)) 16px 13px;
    position: sticky; top: 0;
    background: var(--panel-glass);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--hairline);
  }
  .modal-head h3 { font-size: 17px; font-weight: 700; }
  .modal-body { padding: 16px 16px calc(24px + var(--safe-b)); }
  .modal-foot {
    padding: 12px 16px calc(16px + var(--safe-b));
    position: sticky; bottom: 0;
    background: var(--panel-glass);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--hairline);
  }
  .modal .row { padding: 14px 4px; }
  .modal .row-title { font-size: 15px; }
  .modal .row-sub { font-size: 12.5px; }
  .field input, .field textarea { padding: 13px 15px; font-size: 16px; border-radius: 14px; }
  .field > span { font-size: 12px; }
  .btn { padding: 12px 18px; font-size: 15px; border-radius: 13px; }
  .btn.big { padding: 15px; font-size: 16px; border-radius: 16px; }
  .settings-tabs { gap: 7px; padding-bottom: 14px; overflow-x: auto; }
  .settings-tabs .btn { padding: 9px 15px; font-size: 13.5px; white-space: nowrap; }
  .switch-row { padding: 15px 4px; }
  .switch { width: 50px; height: 30px; }
  .switch::after { width: 24px; height: 24px; }
  .switch.on::after { transform: translateX(20px); }
  .dev-item { padding: 14px 4px; }
  .kbd-row { padding: 11px 4px; }
  .fav-item { padding: 13px 6px; }
  .fav-thumbs img { width: 62px; height: 62px; }
  .read-row { font-size: 13.5px; }

  /* 左上角菜单：贴边全宽 */
  .app-menu {
    left: 10px !important; right: 10px;
    width: auto; border-radius: 20px;
    padding: 10px;
    box-shadow: var(--shadow-3);
    max-height: 76vh; overflow-y: auto;
  }
  .app-menu .mi { padding: 11px 10px; border-radius: 13px; gap: 12px; }
  .app-menu .mi .ico { width: 34px; height: 34px; border-radius: 11px; }
  .app-menu .mi .t { font-size: 15px; }
  .app-menu .mi .d { font-size: 12px; }
  .app-menu .mi .kbd { display: none; }        /* 手机没有键盘，隐藏快捷键提示 */

  /* 大图查看器：全屏 */
  .lb-stage img { max-width: 100vw; max-height: 78vh; border-radius: 0; }
  .lb-actions { top: calc(12px + var(--safe-t)); left: 12px; right: 12px; justify-content: center; }
  .lb-actions button { flex: 0 1 auto; }
  .lb-close { top: calc(12px + var(--safe-t)); right: 14px; font-size: 26px; }

  /* 滚动到底部按钮 */
  .scroll-down { width: 44px; height: 44px; right: 14px; bottom: 14px; }
  .scroll-down svg { width: 24px; height: 24px; }

  /* 截图取景（手机一般用不到，仍保留可用） */
  .shot-bar { padding: 10px 14px calc(18px + var(--safe-b)); }

  /* 空状态 */
  .empty-inner { padding: 0 24px; gap: 14px; }
  .empty-inner h3 { font-size: 19px; }
  .empty-inner p { font-size: 14px; line-height: 1.75; }
  .chat-empty .empty-inner > svg { width: 88px; height: 88px; }
}

/* 超小屏（iPhone SE 等） */
@media (max-width: 380px) {
  .li-name { font-size: 15.5px; }
  .bubble { font-size: 15px; }
  .emoji-grid { grid-template-columns: repeat(6, 1fr); }
  .rail-btn { width: 56px; }
}

/* 横屏 / 大屏手机 */
@media (min-width: 600px) and (max-width: 860px) {
  .list-panel { max-width: 560px; margin: 0 auto; }
  .item-row { max-width: 720px; }
  .msg-col { max-width: 68%; }
}
