/* ============================================================
   mobile-pages.css · 移动端五个独立页面覆盖层
   （admin / platforms / publish / channel / scene）
   归属：C 线独占。其他线不许编辑本文件。
   规则：只写 @media (max-width:900px) 与 (pointer:coarse) 内的覆盖。
   原则：同一份 DOM 做 CSS 重排，不复制结构；不用 overflow-x:hidden 盖真溢出。
   注意：本文件被 pages.css（platforms/channel/scene 引入）和 publish 内联 style
   之后加载，因此关键布局规则用父级选择器前缀提高 specificity 压过后加载的规则。
   ============================================================ */

/* ---------- 全局：五页共用（≤900px） ---------- */
@media (max-width: 900px) {

  html, body { max-width: 100%; }

  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  img, video { max-width: 100%; }

  button, a[role="button"], .btn, .step, .chip, .sc-opt, .art-opt, .plat, .sc-cat, .bcard {
    -webkit-tap-highlight-color: transparent;
  }
  .btn:active, .step:active, .chip:active, .sc-opt:active, .art-opt:active, .plat:active,
  .sc-cat:active, .bcard:active, a.btn:active, button:active {
    filter: brightness(1.18);
    transform: scale(.985);
  }

  /* 顶栏压缩 + 安全区 */
  body .top, body .pb-top {
    height: auto;
    min-height: 56px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
    padding-bottom: 10px;
    gap: 8px;
    flex-wrap: wrap;
  }
  body .top .muted, body .pb-top .muted { font-size: 12px; }
  body .top .vsep, body .pb-top .pb-sep { display: none; }
  /* 手机上顶栏那段长描述隐藏，避免换行挤压按钮 */
  body .pb-top > .muted:first-of-type { display: none; }

  body .top .btn, body .pb-top .btn {
    min-height: 44px;
    padding: 0 14px;
    white-space: nowrap;
  }

  /* 主内容区 padding 收紧 */
  body .wrap, body .pb-wrap, body .rv-wrap {
    padding-left: 14px;
    padding-right: 14px;
  }
  body .wrap { padding-top: 14px; }

  /* 卡片内边距收紧 */
  body .card, body .box { padding: 14px; }
  body .card h2, body .box h2 { font-size: 15px; }

  /* 列表项：手机上改单列堆叠，长文本不挤 */
  body .list .li {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 12px;
  }
  body .list .li .t1, body .list .li .t2 { word-break: break-word; min-width: 0; }
  body .list .li .r { max-width: 100%; text-align: left; word-break: break-word; }

  /* tag 不换行挤出 */
  body .tag { white-space: normal; }
  body .tags { row-gap: 4px; }

  /* 输入框触控 */
  body .inp, body .ta, body .sel, body .login-field input {
    min-height: 44px;
    font-size: 16px;
  }

  /* toast 不被 tabbar 挡 */
  body .toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 32px); }

  /* 表格横向滚动容器（admin 已登录态用） */
  body .stage-body table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  body .stage-body thead, body .stage-body tbody { min-width: 640px; display: table; width: 100%; }
}

/* ---------- admin.html ---------- */
@media (max-width: 900px) {
  body .login-mask { padding: 16px; align-items: flex-start; padding-top: calc(40px + env(safe-area-inset-top, 0px)); }
  body .login-card { width: 100%; max-width: 420px; padding: 24px 20px; }
  body .login-btn { min-height: 48px; }

  body .shell { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  body .shell .drawer {
    width: 100% !important;
    flex: none;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  body .drawer-head { border-bottom: none; height: 48px; flex: none; padding: 0 8px; }
  body .drawer-group { display: none; }
  body .drawer-nav {
    flex: 1; display: flex; flex-direction: row; align-items: center;
    overflow-x: auto; overflow-y: hidden; padding: 6px 4px;
  }
  body .drawer-item {
    flex: none; width: auto; height: 44px; margin: 0 4px; padding: 0 12px;
    white-space: nowrap;
  }
  body .drawer-item span { display: inline !important; }
  body .shell.narrow .drawer-item span, body .shell.narrow .badge { display: inline !important; }
  body .drawer-foot { display: none; }

  body .stage { min-height: 0; }
  body .stage-head {
    flex-wrap: wrap; gap: 8px; padding: 12px 14px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  body .stage-title { font-size: 18px; }
  body .stage-actions .btn { min-height: 44px; }
  body .stage-body { padding: 14px 14px 40px; overflow: visible; }

  body .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  body .kpi-v { font-size: 20px; }

  body .log-row { grid-template-columns: 90px 44px 1fr; gap: 8px; padding: 9px 12px; }

  body .gate-row { padding: 10px 12px; }
  body .gate-reply, body .gate-row-mid { word-break: break-word; }
}

/* ---------- platforms.html ---------- */
@media (max-width: 900px) {
  body .wrap.split .plat-grid { grid-template-columns: 1fr; gap: 10px; }
  body .plat { padding: 14px; }
  body .plat .nt { word-break: break-word; }
  /* .st tag 在右上角 absolute，手机上改成文档流内，不与标题重叠 */
  body .plat .st { position: static; display: inline-block; margin-bottom: 8px; }
  body .plat .ph { margin-bottom: 4px; }

  body .wrap.split { gap: 0; }
  body .wrap.split aside { margin-top: 0; }

  body .kv { grid-template-columns: 1fr; gap: 4px; }
  body .kv .k { font-size: 11.5px; }

  body .tool-row { flex-wrap: wrap; row-gap: 8px; padding: 12px; }
  body .tool-row > span, body .tool-row > button { flex: none; }

  body #agentPrompt { margin-bottom: 8px; }
  body .wrap.split aside .card { margin-bottom: 12px; }
}

/* ---------- publish.html（重表单页） ---------- */
@media (max-width: 900px) {
  body .pb-wrap {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px 14px 110px; /* 底部给常驻动作条 + tabbar 留位 */
  }
  body .pb-left { min-width: 0; }

  /* 步骤条：横向可滚，不换行挤 */
  body .pb-wrap .steps {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    margin-bottom: 14px;
  }
  body .pb-wrap .step { flex: none; min-height: 40px; }

  body .box { padding: 14px; margin-bottom: 12px; }

  body .scene-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  body .sc-opt { padding: 12px 10px; min-height: 80px; }

  body .art-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  body .art-opt .cap { font-size: 10px; padding: 4px 6px; }

  body .row2 { grid-template-columns: 1fr; gap: 0; }

  body .chip { padding: 8px 12px; min-height: 36px; }

  body .drop { padding: 20px 14px; }

  body .pb-preview { position: static; order: -1; }
  body .pv-art { height: 160px; }

  /* 底部动作条：常驻底部，在 tabbar 上方（tabbar 高度由 A 线 --m-tabbar-h 暴露，fallback 60px） */
  body .pb-actions {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(var(--m-tabbar-h, 65px) + env(safe-area-inset-bottom, 0px));
    z-index: 40;
    padding: 10px 14px;
    background: rgba(10, 12, 15, .92);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    gap: 10px;
    justify-content: stretch;
    margin-top: 0;
  }
  body .pb-actions .btn { flex: 1; min-height: 46px; justify-content: center; }

  body .rv-wrap { padding: 0 14px 40px; }
  body .rv-head { flex-wrap: wrap; gap: 8px; }
  body .rv-item {
    grid-template-columns: 64px 1fr;
    grid-template-rows: auto auto;
    gap: 10px;
  }
  body .rv-item img { width: 64px; height: 64px; grid-row: 1 / span 2; }
  body .rv-acts { grid-column: 2; justify-content: flex-end; }
  body .rv-acts .btn { min-height: 36px; }

  body .done-card { padding: 22px 16px; }
}

/* ---------- channel.html（矩阵/渠道页） ---------- */
@media (max-width: 900px) {
  body .wrap.split { grid-template-columns: 1fr; gap: 0; }

  body .chat-log { max-height: 60vh; }
  body .msg { max-width: 92%; font-size: 13px; }

  body .qr img { width: 180px; height: 180px; }

  body #bindBody .btn { min-height: 44px; flex: 1; justify-content: center; }
  body #bindBody > div[style*="flex"] { flex-wrap: wrap; }
}

/* ---------- scene.html ---------- */
@media (max-width: 900px) {
  body .scene-head { gap: 10px; margin-bottom: 12px; }
  body .scene-head h1 { font-size: 18px; }
  body .scene-head .ico { font-size: 22px; }

  /* 分类 chips 横向可滚（用 .wrap 前缀提 specificity） */
  body .wrap .sc-cats { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  body .wrap .sc-cat { flex: none; min-height: 36px; display: inline-flex; align-items: center; }

  body .wrap .grid3 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  body .bcard .im { height: 130px; }
  body .bcard .bd { padding: 10px; }
  body .bcard .bn { font-size: 13px; }
}

/* ---------- 红色面积治理（2026-11-10）：宽 CTA 不许满红块 ----------
   纪律见 mobile.css 头注释。宽度 > 200px 的主 CTA 一律走：
     红边框 rgba(200,16,46,.55) + 深红渐变底 + 白字
   窄按钮（.btn-sm、38px 圆形 send-round）保留实红点缀。
   保留 44px 热区与 :active 亮度反馈，不改尺寸。 */
@media (max-width: 900px) {
  body .login-btn,
  body .pb-actions .btn-primary,
  body .btn-primary.block,
  body .btn-primary[style*="width:100%"],
  body .btn-primary[style*="width: 100%"],
  body #publishEntry {
    background: linear-gradient(180deg, rgba(200,16,46,.22), rgba(138,11,32,.14)) !important;
    border: 1px solid rgba(200,16,46,.55) !important;
    color: #fff !important;
    box-shadow: none !important;
    text-shadow: 0 1px 2px rgba(0,0,0,.45);
  }
  body .login-btn:active,
  body .pb-actions .btn-primary:active,
  body .btn-primary.block:active,
  body #publishEntry:active {
    filter: brightness(1.25);
  }
}
/* 浅色主题：白字在浅粉底上没对比，改成红字 + 浅红底 + 红边框 */
@media (max-width: 900px) {
  html[data-theme="light"] body .login-btn,
  html[data-theme="light"] body .pb-actions .btn-primary,
  html[data-theme="light"] body .btn-primary.block,
  html[data-theme="light"] body .btn-primary[style*="width:100%"],
  html[data-theme="light"] body .btn-primary[style*="width: 100%"],
  html[data-theme="light"] body #publishEntry {
    background: linear-gradient(180deg, rgba(200,16,46,.12), rgba(200,16,46,.05)) !important;
    color: #C8102E !important;
    text-shadow: none;
  }
}

/* ---------- 浅色主题：五页在 html[data-theme="light"] 下不残留黑底 ---------- */
@media (max-width: 900px) {
  html[data-theme="light"] { background-color: #f4f6fa; }
  html[data-theme="light"] body,
  html[data-theme="light"] .top,
  html[data-theme="light"] .pb-top,
  html[data-theme="light"] .card,
  html[data-theme="light"] .box,
  html[data-theme="light"] .li,
  html[data-theme="light"] .plat,
  html[data-theme="light"] .bcard,
  html[data-theme="light"] .sc-cat,
  html[data-theme="light"] .pv-card,
  html[data-theme="light"] .rv-item,
  html[data-theme="light"] .kpi {
    background-color: #f4f6fa;
    color: #101828;
  }
  html[data-theme="light"] .top,
  html[data-theme="light"] .pb-top {
    background: rgba(255, 255, 255, .92);
    border-bottom-color: rgba(16, 24, 40, .09);
  }
  html[data-theme="light"] .card,
  html[data-theme="light"] .box,
  html[data-theme="light"] .plat,
  html[data-theme="light"] .bcard,
  html[data-theme="light"] .pv-card,
  html[data-theme="light"] .rv-item {
    border-color: rgba(16, 24, 40, .09);
  }
  html[data-theme="light"] .inp,
  html[data-theme="light"] .ta,
  html[data-theme="light"] .sel {
    background: #ffffff;
    border-color: rgba(16, 24, 40, .15);
    color: #101828;
  }
  html[data-theme="light"] .pb-actions {
    background: rgba(255, 255, 255, .95);
    border-top-color: rgba(16, 24, 40, .09);
  }
  html[data-theme="light"] .step {
    background: #ffffff;
    border-color: rgba(16, 24, 40, .09);
    color: #4b5668;
  }
  html[data-theme="light"] .step.on {
    background: rgba(200, 16, 46, .08);
    color: #101828;
  }
}

/* ---------- 粗指针（手机/平板）：再加大热区 ---------- */
@media (pointer: coarse) and (max-width: 900px) {
  .btn, .step, .chip, .sc-cat { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .li { min-height: 48px; }
}
