/* ==========================================================================
   协作编辑平台 · 手机端全新 App 主题（深浅双感）
   设计语言：深色渐变头部（App 沉浸感） + 浅色柔和内容区
   生效范围：全部规则限定在 ≤640px，桌面端完全不受影响；
             本文件在 main.css 之后加载，同权重规则覆盖 §22 响应式样式
   版本：v=1（改动请同步各视图引用的版本号）
   ========================================================================== */

@media (max-width: 640px) {

  /* ---------- 1. 全局基调：浅色画布 ---------- */
  html { -webkit-text-size-adjust: 100%; }
  body {
    background: #eef0f7;
    background-image: none;
    font-size: 15px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .container { padding: 0 12px calc(30px + env(safe-area-inset-bottom)); max-width: 640px; }

  /* ---------- 2. 深色渐变 App 顶栏（沉浸式头部） ---------- */
  .topbar {
    position: sticky; top: 0; z-index: 90;
    height: auto; padding: calc(10px + env(safe-area-inset-top)) 14px 12px;
    background:
      radial-gradient(340px 130px at 88% -30%, rgba(255,255,255,.22), transparent 65%),
      linear-gradient(135deg, #312e81 0%, #4338ca 48%, #6d28d9 100%);
    border-bottom: 0;
    border-radius: 0 0 22px 22px;
    box-shadow: 0 10px 26px rgba(49,46,129,.36);
    color: #fff;
    row-gap: 8px;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .topbar .brand,
  .topbar .brand:hover { color: #fff; }
  .topbar .brand-text small { color: rgba(255,255,255,.66); }
  .topbar .crumb { color: rgba(255,255,255,.68); border-left-color: rgba(255,255,255,.22); }
  .topbar .crumb b { color: #fff; }

  /* 深色顶栏内的用户胶囊 → 玻璃白 */
  .topbar .user-chip {
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.24);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    padding: 3px 10px 3px 3px;
  }
  .topbar .user-chip .user-meta b { color: #fff; }
  .topbar .user-chip .user-meta span { color: rgba(255,255,255,.62); }

  /* 深色顶栏内的按钮：白底实心为主、幽灵为玻璃描边 */
  .topbar .btn { border-radius: var(--r-full); min-height: 34px; padding: 6px 14px; font-size: 12.5px; }
  .topbar .btn.secondary { background: rgba(255,255,255,.92); border-color: transparent; color: #3730a3; }
  .topbar .btn.ghost { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.26); box-shadow: none; }
  .topbar .btn.danger { background: rgba(225,29,72,.92); }
  .topbar .btn { background: rgba(255,255,255,.92); color: #3730a3; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
  .topbar .btn:not(.secondary):not(.ghost):not(.danger) {
    background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #422006;
  }

  /* 景行豆徽章在深色顶栏：加亮描边 */
  .jxd-chip { border-color: rgba(245,214,123,.65); background: linear-gradient(135deg, #2e2618, #57431c); }

  /* ---------- 3. 页头 → 深色渐变 Hero 卡 ---------- */
  .page-head {
    background:
      radial-gradient(420px 160px at 90% -20%, rgba(255,255,255,.20), transparent 62%),
      linear-gradient(135deg, #4338ca 0%, #4f46e5 55%, #7c3aed 100%);
    color: #fff;
    border-radius: 18px;
    padding: 16px 16px 15px;
    margin-bottom: 14px;
    box-shadow: 0 8px 22px rgba(67,56,202,.30);
    align-items: center;
  }
  .page-head h1 { color: #fff; font-size: 20px; }
  .page-head h1::after {
    content: ''; display: block; width: 34px; height: 3px; border-radius: 2px;
    background: linear-gradient(90deg, #fbbf24, rgba(251,191,36,0)); margin-top: 7px;
  }
  .page-head .sub { color: rgba(255,255,255,.74); }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }

  /* ---------- 4. 卡片：大圆角浅色面板 ---------- */
  .card {
    border-radius: 18px;
    border-color: #e3e7f2;
    box-shadow: 0 2px 10px rgba(30,41,59,.06);
    padding: 15px;
    margin-bottom: 12px;
  }
  .card.flush { padding: 0; }
  .card-head h2, .card h2 { font-size: 15.5px; }
  .card-foot { border-radius: 0 0 18px 18px; }

  /* 统计卡 2×2 宫格 */
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-4 > .card,
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { border-radius: 16px; padding: 14px 13px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .st-icon { width: 40px; height: 40px; border-radius: 13px; }
  .st-num { font-size: 24px; }

  /* ---------- 5. 列表表格 → 卡片流（data-label 机制） ---------- */
  table.list, table.list tbody { display: block; }
  table.list thead { display: none; }
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  .card.flush .table-wrap { border: 0; }
  table.list tr {
    display: block; margin: 0 0 10px; padding: 3px 0;
    background: #fff; border: 1px solid #e3e7f2;
    border-radius: 16px; overflow: hidden;
    box-shadow: 0 2px 8px rgba(30,41,59,.05);
  }
  table.list tr:last-child { margin-bottom: 0; }
  table.list td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 9px 14px; text-align: right;
    border-bottom: 1px dashed #e8ecf5;
    font-size: 13.5px; white-space: normal;
  }
  table.list td:last-child { border-bottom: 0; padding-bottom: 12px; }
  table.list td[data-label]::before {
    content: attr(data-label);
    flex: none; text-align: left;
    font-size: 12px; font-weight: 600; color: #8a94a8;
  }
  table.list td[data-label="作业标题"],
  table.list td[data-label="文件名"],
  table.list td[data-label="标题"] {
    justify-content: flex-start; font-weight: 650; font-size: 14.5px; color: var(--text);
  }
  table.list td[colspan] { display: block; text-align: center; border-bottom: 0; }

  /* ---------- 6. 表单与按钮：44px 触控 ---------- */
  label, .label { font-size: 13px; }
  input[type=text], input[type=password], input[type=datetime-local], input[type=number],
  input[type=file], select, textarea {
    font-size: 16px;                       /* ≥16px 防 iOS 聚焦自动放大 */
    min-height: 44px; padding: 10px 13px;
    border-radius: 12px; background: #f7f8fd; border-color: #e0e5f1;
  }
  input:focus, select:focus, textarea:focus { background: #fff; }
  textarea { min-height: 96px; }
  input[type=file] { min-height: 0; padding: 10px; }
  input[type=file]::file-selector-button { min-height: 36px; padding: 6px 14px; border-radius: 10px; }

  .btn { min-height: 44px; border-radius: 13px; font-size: 15px; font-weight: 600; }
  .btn.sm { min-height: 36px; padding: 7px 13px; font-size: 13px; border-radius: 11px; }
  .btn.lg { width: 100%; min-height: 48px; font-size: 16px; border-radius: 14px; }
  .btn.block { width: 100%; }
  .card .actions .btn, .modal .actions .btn { flex: 1 1 auto; }

  /* 危险/次要按钮适配 */
  .btn.secondary { background: #fff; color: var(--text-2); border-color: #e0e5f1; }
  .btn.danger { background: linear-gradient(135deg, #f43f5e, #e11d48); }

  /* 行内操作链接放大点击区 */
  .act-links { gap: 10px; }
  .act { padding: 4px 0; font-size: 13.5px; }
  .act-links .sep { display: none; }

  /* ---------- 7. 页签 → 分段控件 ---------- */
  .tabs {
    width: 100%; padding: 4px; border-radius: 14px;
    background: #e3e7f4; margin-bottom: 14px;
  }
  .tabs .tab { flex: 1; justify-content: center; min-height: 40px; border-radius: 11px; font-size: 14px; }
  .tabs .tab.active {
    background: linear-gradient(135deg, #4f46e5, #6d28d9);
    color: #fff; font-weight: 650;
    box-shadow: 0 4px 12px rgba(79,70,229,.35);
  }

  /* ---------- 8. 弹窗 → 底部抽屉（带把手） ---------- */
  .modal-mask { align-items: flex-end; padding: 0; z-index: 130; }
  .modal {
    max-width: 100%; max-height: 92vh;
    border-radius: 22px 22px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: mSheetUp .26s cubic-bezier(.34,1.2,.64,1);
  }
  .modal::before {
    content: ''; display: block; width: 42px; height: 5px; border-radius: 3px;
    background: #d5dae6; margin: 9px auto 0;
  }
  @keyframes mSheetUp { from { transform: translateY(56px); opacity: .35; } to { transform: none; opacity: 1; } }
  .modal .actions { position: sticky; bottom: 0; background: #fff; padding: 12px 0 4px; margin-top: var(--sp-4); }
  .modal .actions .btn { flex: 1; }
  .pick-list { max-height: 42vh; }

  /* ---------- 9. Toast：顶部安全区 ---------- */
  #toast-box { top: calc(12px + env(safe-area-inset-top)); width: calc(100vw - 24px); }
  .toast { max-width: 100%; box-shadow: 0 10px 30px rgba(15,23,42,.22); }

  /* ---------- 10. 小组卡片 / 空状态 / 徽标 ---------- */
  .group-cards { grid-template-columns: 1fr; gap: 10px; }
  .group-card { border-radius: 16px; padding: 15px; }
  .empty-tip { padding: 34px 16px; }
  .badge { font-size: 12.5px; padding: 4px 11px; }

  /* ---------- 11. 登录页：浅色画布 + 居中白卡（按真实 DOM：.login-panel > .login-card） ---------- */
  /* 用与 main.css §22 同权重（0,3,1）选择器反制其对 .login-panel 的卡片化，恢复为画布容器 */
  .login-wrap { display: block; min-height: 100dvh; background: #eef0f7; padding: 0; }
  .login-hero { display: none; }
  .login-wrap > .card, .login-wrap > form, .login-wrap > div:not(.login-hero):not(.toast) {
    margin: 0; padding: calc(16px + env(safe-area-inset-top)) 14px calc(26px + env(safe-area-inset-bottom));
    border-radius: 0; box-shadow: none;
    min-height: 100dvh;
    display: flex; align-items: flex-start; justify-content: center;
    background: #eef0f7;
  }
  .login-card {
    width: 100%; max-width: 460px;
    padding: 24px 20px; border-radius: 22px;
    background: #fff;
    box-shadow: 0 14px 40px rgba(49,46,129,.14);
  }
  .login-wrap .mobile-brand {
    display: inline-flex; align-items: center; justify-content: center;
    width: 100%; padding: 14px; border-radius: 16px; margin-bottom: 18px;
    color: #fff; font-weight: 700; font-size: 15px;
    background: linear-gradient(135deg, #4338ca, #7c3aed);
    box-shadow: 0 8px 20px rgba(67,56,202,.30);
  }
  .login-wrap .mobile-brand .brand-logo { background: rgba(255,255,255,.18); box-shadow: none; }
  .login-card h1 { text-align: center; font-size: 22px; }
  .login-card .sub { text-align: center; margin-bottom: 22px; }
  .login-wrap input:not([type=checkbox]) { width: 100%; min-height: 46px; }
  .login-wrap .btn { width: 100%; min-height: 48px; font-size: 16px; }
  .login-card .foot { color: #9aa3b5; }

  /* ---------- 12. 协作编辑器 / 思维导图 ---------- */
  .editor-shell { padding: 0 0 26px; max-width: 640px; }
  .editor-head { padding: 12px 14px 0; }
  .editor-box { border-radius: 16px; }
  .block-content { padding: 9px 12px 9px 10px; font-size: 14px; }
  .block-gutter { width: 34px; font-size: 10.5px; }
  .editor-foot { padding: 10px 12px; }
  .editor-foot .keys { display: none; }        /* 快捷键提示在触屏无意义 */
  .mm-scroll { padding: 18px 14px; }
  .mm-node { max-width: 200px; font-size: 13.5px; }

  /* ---------- 13. 杂项 ---------- */
  .detail-grid { gap: 12px; }
  .profile-cols { grid-template-columns: 1fr; gap: 12px; }
  .ph-band { height: 76px; }
  .ph-body { padding: 0 16px 14px; gap: 14px; }
  .ph-avatar { width: 72px; height: 72px; margin-top: -36px; font-size: 28px; }
  .ph-name b { font-size: 19px; }
  .roster-list { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 12px; }
  .join-row input.code-input { width: 100%; }
  .dropzone { padding: 20px 14px; border-radius: 14px; }
  a, button, .act, .tab, .qg, .pick-row { -webkit-tap-highlight-color: transparent; }
  ::-webkit-scrollbar { width: 0; height: 0; } /* 触屏无需滚动条 */
}
