/* =====================================================================
   爆更兔 · SPA 工作台移动端适配（手机/竖屏平板，<=899px）
   桌面结构：固定满屏 _shell/_body + 左/右 transform 抽屉 + 自定义绝对滚动视口
   移动目标：全部解除固定高度与位移 → 单栏纵向、页面整体滚动、无裁切
   ===================================================================== */

/* === 1. 等宽卡片/统计网格：窄屏降为自适应，最多两列，防止压扁 === */
@media (max-width: 899px){
[class*="_spendLadder_"],
[class*="_categoryGrid_"],
[class*="_vipWarehouseGrid_"],
[class*="_fontGrid_"],
[class*="_coinStats_"],
[class*="_referralRulesGrid_"],
[class*="_referralStats_"],
[class*="_skeletonGrid_"],
[class*="_heroStage_"],
[class*="_channelRow_"],
[class*="_summary_"],
[class*="_stats_"],
[class*="_ruleStrip_"],
[class*="_engineGrid_"],
[class*="_threeCol_"]{
  grid-template-columns: repeat(auto-fit, minmax(min(100%,150px),1fr)) !important;
  gap:10px !important;
}}

/* === 2. 顶部「生成」工具条 swx：允许横排换行，不裁切 === */
@media (max-width: 899px){
  .swx-toolbar{
    display:flex !important; flex-wrap:wrap !important; flex-direction:row !important;
    width:100% !important; max-width:100% !important; gap:8px !important;
  }
  .swx-toolbar > button,
  .swx-toolbar > a{ flex:0 0 auto !important; white-space:nowrap !important; }
}

/* === 3. 工作台外壳 _shell/_body：解除固定高度，纵向自然流 === */
@media (max-width: 899px){
  [class*="_shell_1oklx"],
  [class*="_uiLayer_1oklx"]{
    position:static !important;
    inset:auto !important;
    height:auto !important;
    min-height:0 !important;
    overflow:visible !important;
  }
  [class*="_body_1oklx"]{
    display:flex !important;
    flex:0 0 auto !important;
    flex-direction:column !important;
    flex-wrap:nowrap !important;
    height:auto !important;
    min-height:0 !important;
    overflow:visible !important;
  }
  /* 外层左抽屉（搜索 / 导航）：手机端隐藏（主导航用汉堡） */
  [class*="_leftColumn_1oklx"]{ display:none !important; }

  /* 主列：全宽、自然高 */
  [class*="_mainColumn_1oklx"]{
    width:100% !important;
    flex:0 0 auto !important;
    height:auto !important;
    min-width:0 !important;
    overflow:visible !important;
    margin:0 !important;
  }

  /* 顶部条 _bar：桌面固定 px 多列 grid → 单列纵向，按钮不竖排彩条 */
  [class*="_bar_1155g"]{
    grid-template-columns:1fr !important;
    grid-auto-flow:row !important;
    width:100% !important;
    gap:10px !important;
  }
  [class*="_bar_1155g"] > *{ width:100% !important; min-width:0 !important; }
  [class*="_leftGroup_"]{ width:100% !important; display:flex !important; flex-wrap:wrap !important; gap:8px !important; }
  [class*="_leftGroup_"] button{ flex:0 0 auto !important; white-space:nowrap !important; }

  /* _bar 右侧按钮组（缩放 / 保存草稿 / AI续写 / AI润色）：全宽横排换行 */
  [class*="_rightGroup_"]{
    width:100% !important; display:flex !important; flex-wrap:wrap !important; gap:8px !important;
  }
  [class*="_rightGroup_"] button{
    flex:1 1 auto !important; min-width:92px !important; width:auto !important; white-space:nowrap !important;
  }

  /* === 4. 自定义滚动视口链：解除绝对定位/固定高度/裁切，全部自然流动 === */
  [class*="_contentRow_1oklx"]{
    height:auto !important; flex:0 0 auto !important; overflow:visible !important;
  }
  [class*="_viewport_u1pex"]{
    position:static !important;
    height:auto !important; width:100% !important;
    overflow:visible !important;
  }
  [class*="_inner_u1pex"],
  [class*="_pageWrap_u1pex"]{
    height:auto !important; width:100% !important; transform:none !important;
  }

  /* === 5. 核心三栏写作台 _editor：纵向堆叠 === */
  [class*="_editor_1lylm"]{
    display:flex !important; flex-direction:column !important;
    width:100% !important; height:auto !important; min-width:0 !important;
  }
  /* 编辑器富文本工具条：按钮横排、可换行，不被挤窄竖排 */
  [class*="_toolbar_1lylm"]{ display:flex !important; flex-wrap:wrap !important; width:100% !important; }
  [class*="_toolBtn_1lylm"]{
    flex:0 0 auto !important; min-width:64px !important; height:auto !important;
    white-space:nowrap !important; writing-mode:horizontal-tb !important;
  }
  [class*="_leftSidebar_1lylm"]{ display:none !important; }
  [class*="_mainArea_1lylm"]{
    width:100% !important; flex:0 0 auto !important; min-width:0 !important;
  }
  [class*="_rightPanel_1lylm"]{
    width:100% !important; flex:0 0 auto !important;
    position:static !important; height:auto !important; margin:0 !important;
  }
  [class*="_panelSection_1lylm"],
  [class*="_panelTitle_1lylm"],
  [class*="_panelText_1lylm"]{ max-width:100% !important; box-sizing:border-box !important; }

  /* 正文输入：全宽、16px 防 iOS 聚焦自动缩放 */
  [class*="_mainArea_1lylm"] textarea,
  [class*="_mainArea_1lylm"] [contenteditable]{
    width:100% !important; max-width:100% !important; box-sizing:border-box !important; font-size:16px !important;
  }

  /* === 6. 外层右抽屉（生成/设置 _panel_g4kff）：清位移，常驻正文下方 === */
  [class*="_rightColumn_1oklx"]{
    transform:none !important;
    position:static !important;
    width:100% !important; max-width:100% !important;
    flex:0 0 auto !important;
    height:auto !important; overflow:visible !important;
    margin:0 !important; padding:0 !important;
  }
  [class*="_panel_g4kff"]{ width:100% !important; height:auto !important; max-width:100% !important; }
  [class*="_scroll_g4kff"]{ height:auto !important; max-height:none !important; overflow:visible !important; }
  [class*="_footer_g4kff"]{ position:static !important; width:100% !important; }
  [class*="_footer_g4kff"] button{ width:100% !important; }

  /* === 7. 设置页头像：父链收窄到屏内，网格 3 列自适应、不裁切 === */
  [class*="_avatarPicker_"],
  [class*="_control_1ixrm"]{
    width:100% !important; max-width:100% !important; min-width:0 !important; box-sizing:border-box !important;
  }
  [class*="_avatarGrid_"]{
    width:100% !important; max-width:100% !important;
    grid-template-columns:repeat(auto-fill,minmax(96px,1fr)) !important;
    gap:12px !important;
  }

  /* === 8. 通用防溢出兜底 === */
  img,video,canvas,table,pre,input,select{ max-width:100% !important; }
  [contenteditable]{ max-width:100% !important; box-sizing:border-box !important; }
}
