/* v19：原生 App 移动端适配。仅 <768px 生效，桌面端沿用既有样式。 */
.mobileDraftTabs,.mobileActionBar{display:none}

@media (max-width:767px){
  /* 1. 48px 单行顶栏：抽屉 + 品牌图标 / 三步胶囊 / 设置 */
  .top{height:48px!important;flex:0 0 48px!important;grid-template-columns:auto minmax(0,1fr) auto!important;grid-template-rows:48px!important;gap:8px!important;padding:0 10px!important}
  .headerLeft{grid-column:1!important;grid-row:1!important;display:flex!important;align-items:center;gap:7px;min-width:0}
  .headerLeft .brand{display:flex!important;order:2;gap:0}
  .headerLeft .brand strong,.headerLeft .brandSub,.topActions .localDot,.topActions #assetsToggle{display:none!important}
  .headerLeft .brandmark{width:26px;height:26px;font-size:17px;border-radius:6px}
  .headerLeft #historyDrawer{order:1;width:32px;height:34px;padding:6px;margin:0;border:0;background:transparent}
  .topActions{grid-column:3!important;grid-row:1!important;gap:0!important}
  .topActions #settingsBtn{width:34px;height:34px;border:0;background:transparent}
  .top .steps{grid-column:2!important;grid-row:1!important;justify-self:stretch!important;width:100%!important;height:36px!important;min-width:0;margin:0!important;padding:3px;gap:2px!important;border:0!important;border-radius:999px;background:#f0f3ee;overflow:hidden}
  .top .steps button{flex:1 1 0!important;min-width:0!important;height:30px!important;padding:0 5px!important;gap:3px!important;border:0!important;border-radius:999px!important;background:transparent!important;font-size:11px!important;font-weight:600!important;white-space:nowrap!important;color:#68786d!important}
  .top .steps button.active{background:#1f4e3d!important;color:#fff!important}
  .top .steps button.completed:not(.active){background:transparent!important}
  .top .steps b{display:none}
  .top .steps button span{display:block;padding:0!important;line-height:30px;font-size:0}
  .top .steps button span::after{font-size:11px}
  .top .steps button[data-stage="source"] span::after{content:"① 素材"}
  .top .steps button[data-stage="angle"] span::after{content:"② 大纲"}
  .top .steps button[data-stage="draft"] span::after{content:"③ 精修"}
  /* 已锁步骤也保留短标签；只隐藏桌面用的锁形装饰，不能隐藏整个胶囊。 */
  .top .steps button.lockedStep span::after{display:block!important}

  /* 移动端工作区：侧栏保持抽屉，内容不再为桌面左右栏让位 */
  .workspace{display:block!important;position:relative;min-height:0;flex:1;--left-width:0px!important;--right-width:0px!important}
  .sidebar{position:fixed!important;display:flex!important;left:0;top:48px!important;bottom:0!important;width:min(282px,84vw)!important;z-index:55!important;padding:14px!important}
  .left-collapsed .sidebar{display:none!important}
  .previewRail{display:none!important}
  .editor{height:100%;min-width:0}
  .editorSurface{max-width:none!important;width:100%!important;padding:10px 12px 0!important}
  .documentHeader{margin-bottom:8px!important;min-height:36px!important;gap:6px!important}
  .documentIdentity input{font-size:16px!important}
  .editorFooter{padding-bottom:6px!important}
  #stageContent{padding-bottom:7rem!important;scroll-padding-bottom:7rem}

  /* 2. 第 3 步吸顶分段控制器，同一时刻只显示编辑或预览 */
  body.mobile-draft-mode .mobileDraftTabs{position:sticky;top:48px;z-index:35;display:grid;grid-template-columns:1fr 1fr;flex:0 0 44px;height:44px;padding:4px 12px;background:#fff;border-bottom:1px solid #e5eae2}
  .mobileDraftTabs button{border:0;border-radius:8px;background:transparent;color:#718076;font-size:13px;font-weight:600;min-height:34px;padding:0 8px}
  .mobileDraftTabs button[aria-selected="true"]{background:#eaf1e8;color:#164a38;box-shadow:inset 0 0 0 1px #d5e2d3}
  body.mobile-draft-mode .editorSurface{padding-top:6px!important}
  body.mobile-draft-mode:not(.mobile-draft-preview) .previewPanel{display:none!important}
  body.mobile-draft-preview .editor{display:none!important}
  body.mobile-draft-preview .workspace>.previewPanel{display:flex!important;position:absolute!important;inset:0!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;margin:0!important;padding:0!important;gap:0!important;overflow:hidden!important;border:0!important;border-radius:0!important;background:#fff!important;box-shadow:none!important;z-index:10!important}
  body.mobile-draft-preview .previewPanel .previewHead,
  body.mobile-draft-preview .previewPanel .titlePool,
  body.mobile-draft-preview .previewPanel .previewFooter{display:none!important}
  body.mobile-draft-preview .previewPanel #phoneScroll{width:100%!important;height:100%!important;max-height:none!important;padding:22px 16px calc(7rem + env(safe-area-inset-bottom))!important;border:0!important;border-radius:0!important;background:#fff!important}
  body.mobile-draft-preview .previewPanel #phoneArticle{max-width:none!important;margin:0!important}

  /* 编辑视野：px-3、块级正文、触控可发现的插入入口 */
  body.mobile-draft-mode:not(.mobile-draft-preview) .draftSurface{height:auto;min-height:100%;gap:6px}
  body.mobile-draft-mode:not(.mobile-draft-preview) .draftGuide{display:none}
  body.mobile-draft-mode:not(.mobile-draft-preview) .draftTitle{max-height:none;margin:0}
  body.mobile-draft-mode:not(.mobile-draft-preview) .blockEditor{padding:0}
  body.mobile-draft-mode:not(.mobile-draft-preview) .paraBlock{padding:0}
  body.mobile-draft-mode:not(.mobile-draft-preview) .paraBlock textarea{padding:12px 4px;font-size:16px!important;line-height:1.9}
  body.mobile-draft-mode:not(.mobile-draft-preview) .paraBlock.paraHeading textarea{padding-left:4px;font-size:17px!important}
  body.mobile-draft-mode:not(.mobile-draft-preview) .insertBar{height:34px;opacity:1}
  body.mobile-draft-mode:not(.mobile-draft-preview) .insertBar .insertTip{display:none}
  body.mobile-draft-mode:not(.mobile-draft-preview) .insertBar button{min-height:30px}
  body.mobile-draft-mode:not(.mobile-draft-preview) .draftBottom{position:static;flex-wrap:wrap;margin-top:8px;padding:12px 0;background:transparent}
  body.mobile-draft-mode:not(.mobile-draft-preview) .draftBottom .draftActions{flex-wrap:wrap}

  /* 3. 划选 AI 改写条：停靠主操作栏正上方，不跟随系统选区 */
  .selectionBubble.mobileSelectionDock{position:fixed!important;top:auto!important;left:8px!important;right:8px!important;bottom:calc(76px + env(safe-area-inset-bottom))!important;width:auto!important;max-width:none!important;transform:none!important;z-index:45!important;border-radius:12px!important;padding:9px!important;box-shadow:0 -4px 24px #101a1452!important}
  .selectionBubble.mobileSelectionDock .bubbleLabel{margin-bottom:6px!important}
  .selectionBubble.mobileSelectionDock .bubbleActions{gap:5px;margin-bottom:7px}
  .selectionBubble.mobileSelectionDock .bubbleActions button{min-height:36px;font-size:11px!important;padding:6px 3px!important;white-space:nowrap}
  .selectionBubble.mobileSelectionDock .selectionCommand input{font-size:16px!important;min-height:38px}
  .selectionBubble.mobileSelectionDock .selectionCommand button{min-width:42px;min-height:38px}
  .selectionBubble.mobileSelectionDock>small{display:none}

  /* 4. 图片工具栏：单行五键、34px 最小热区，375px 不溢出 */
  .imageCard{padding:8px!important;margin:8px 0!important}
  .imageCardTools{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:4px!important;flex-wrap:nowrap!important;width:100%!important;margin-bottom:7px!important;font-size:12px!important}
  .imageCardTools .heroTag,.imageCardTools .modeTag{display:none!important}
  .imageCardTools button{flex:1 1 0!important;min-width:0!important;min-height:34px!important;padding:4px 2px!important;font-size:11px!important;line-height:1.2!important;white-space:nowrap!important;border-radius:6px!important}
  .imageCardTools [data-img-up]{order:1}
  .imageCardTools [data-img-down]{order:2}
  .imageCardTools [data-img-redraw]{order:3}
  .imageCardTools [data-img-replace]{order:4}
  .imageCardTools [data-img-remove]{order:5}
  .imageMeta{flex-wrap:nowrap!important}
  .captionInput,.quoteInput{min-width:0!important;width:100%!important}
  .imageBar{gap:6px!important;padding:8px!important}
  .imageBar .layoutTabs{margin-left:auto}

  /* 偏好设置 / 锁定信源全屏模态；禁止 iOS 输入聚焦自动缩放 */
  #settingsDialog,#sourceDialog{inset:0!important;width:100vw!important;height:100dvh!important;max-width:none!important;max-height:100dvh!important;margin:0!important;padding:16px!important;border:0!important;border-radius:0!important}
  #settingsDialog{overflow:auto!important}
  #settingsDialog .dialogHeader,#sourceDialog .dialogHeader{position:sticky;top:-16px;z-index:2;margin:-16px -16px 16px;padding:16px;background:#fafcf7;border-bottom:1px solid #e3e8dd}
  #settingsDialog .dialogFooter,#sourceDialog .sourceFooter{padding-bottom:env(safe-area-inset-bottom)}
  .prefGrid{grid-template-columns:1fr!important}
  input,textarea,select{font-size:16px!important}
  input[type="checkbox"]{font-size:inherit!important}

  /* 5. 统一吸底双操作栏 + 全面屏安全区 */
  body.mobile-draft-mode .mobileActionBar{position:fixed;left:0;right:0;bottom:0;z-index:30;display:flex;align-items:center;gap:10px;padding:12px 12px calc(12px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid #e1e8de;box-shadow:0 -8px 22px #1f352914}
  .mobileActionBar button{flex:1 1 50%;min-width:0;min-height:46px;padding:10px 6px;border-radius:9px;font-size:13px;font-weight:600;white-space:nowrap}
  .mobileActionBar #mobileCopyBtn{background:#fff;border:1px solid #164a38;color:#164a38}
  .mobileActionBar #mobilePushBtn{background:#164a38;border:1px solid #164a38;color:#fff}
  body.mobile-draft-mode #toast{bottom:calc(86px + env(safe-area-inset-bottom))}
}

@media (min-width:768px){
  .mobileDraftTabs,.mobileActionBar{display:none!important}
}

/* v20：三步主操作都落在视口最底边，不再受editorFooter或父级sticky留缝影响。 */
@media(max-width:767px){
 .editorFooter{display:none!important}
 #stageContent{padding-bottom:calc(8rem + env(safe-area-inset-bottom))!important;scroll-padding-bottom:8rem}
 .stageAction,.planFooter,.basketFooter,.launchFooter,body.mobile-draft-mode .mobileActionBar{position:fixed!important;inset:auto 0 0!important;z-index:40!important;margin:0!important;width:100%!important;background:#f7f8f5!important;backdrop-filter:blur(10px);border-top:1px solid #e7e5e4!important;padding:12px 16px calc(12px + env(safe-area-inset-bottom))!important;box-sizing:border-box}
 .stageAction,.basketFooterRow{display:flex;gap:8px}
 .stageAction>button,.basketFooterRow>button{flex:1;min-width:0;white-space:nowrap;min-height:42px}
 .planFooter{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px!important}
 .planFooter button{min-width:0!important;white-space:nowrap!important;min-height:38px;padding:8px 4px!important;font-size:12px!important}
 .planFooter #simpleWrite{grid-column:1/-1;min-height:44px;font-size:14px!important}
 .planFooter .pickHint{grid-column:1/-1;grid-row:1;font-size:11px}
 .planFooter #angleConfirm{grid-column:1/-1}
 .basketPane{padding-bottom:8rem!important}
 body.mobile-draft-preview .previewPanel #phoneScroll{padding-bottom:calc(8rem + env(safe-area-inset-bottom))!important}
 #toast,body.mobile-draft-mode #toast{top:8px!important;bottom:auto!important}
}
