/**
 * 官网移动端「组件级」适配 — 仅窄屏且非首页整体缩放时生效
 * html.official-home-scale / official-phone-scale 时本块跳过（首页走整体缩放）
 */
@media (max-width: 768px) {
  html:not(.official-phone-scale):not(.official-home-scale) {
  :root {
    --bce-m-tabbar-h: 50px;
  }

  html, body {
    overflow-x: clip;
  }

  body.bce-body {
    padding-bottom: calc(var(--bce-m-tabbar-h) + env(safe-area-inset-bottom, 0px));
  }

  /* —— 底部导航 —— */
  .bce-m-tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    height: calc(var(--bce-m-tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.05);
  }
  .bce-m-tabbar__item {
    appearance: none;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-width: 0;
    padding: 0;
    color: #64748b;
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .bce-m-tabbar__item.is-active {
    color: #2563eb;
  }
  .bce-m-tabbar__ico {
    display: block;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
  }

  /* IM / AI 嵌入页不显示底部导航（layout 已不输出，兜底隐藏） */
  body.wechat-im-layout .bce-m-tabbar,
  body.wechat-im-embed .bce-m-tabbar,
  body.ai-chat-layout .bce-m-tabbar,
  body.official-ai-embed .bce-m-tabbar,
  body.art-comp-publish-page .bce-m-tabbar {
    display: none !important;
  }
  body.wechat-im-layout,
  body.ai-chat-layout,
  body.official-ai-embed,
  body.art-comp-publish-page {
    padding-bottom: 0;
  }

  .bce-wrap { max-width: calc(100% - 32px); }

  .bce-head-inner--full { padding: 0 12px; gap: 12px; }
  .bce-head-logo { min-width: 0; }
  .bce-head-logo-text {
    font-size: 14px;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bce-user-dropdown {
    position: fixed;
    top: calc(var(--bce-head-h) + 8px);
    left: 12px;
    right: 12px;
    min-width: 0;
    max-width: none;
    max-height: calc(100dvh - var(--bce-head-h) - 24px);
    overflow-y: auto;
  }

  .bce-mobile-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    word-break: break-word;
  }

  .bce-main-minimal { min-height: calc(100dvh - var(--bce-head-h)); }

  body.wechat-im-layout .bce-main-minimal,
  body.ai-chat-layout .bce-main-minimal {
    min-height: 0 !important;
    height: auto;
    flex: 1;
  }

  body.wechat-im-layout .bce-head-inner--full,
  body.ai-chat-layout .bce-head-inner--full {
    padding: 0 10px;
    gap: 8px;
  }

  body.wechat-im-layout .wx-im-panel-zoom,
  body.ai-chat-layout .wx-im-panel-zoom {
    display: none !important;
  }

  .bce-float-sidebar { display: none; }

  .bce-foot--minimal .bce-foot-main,
  .bce-foot--minimal .footer-pc { padding-left: 0; padding-right: 0; }
  .bce-foot--minimal .bce-wrap { max-width: calc(100% - 24px); }
  .bce-foot--minimal .footer-pc,
  .bce-foot--minimal .bce-foot-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 16px;
  }
  .bce-foot--minimal .footer-col,
  .bce-foot--minimal .bce-foot-col { min-width: 0; }
  .bce-foot--minimal img {
    max-width: 100%;
    height: auto;
  }

  /* 商城 / 账户 */
  .bce-shop-inner { padding-left: 16px; padding-right: 16px; }
  .bce-shop--account { padding: 20px 0 48px; }
  .bce-account-head h1 { font-size: 18px; }
  .bce-account-table thead { display: none; }
  .bce-account-table tr {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--shop-line, #e8e9eb);
  }
  .bce-account-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border: none;
    text-align: right;
  }
  .bce-account-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--shop-muted, #84868c);
    text-align: left;
    flex-shrink: 0;
  }
  .bce-account-table td:last-child { justify-content: flex-end; }
  .bce-account-detail-card { padding: 20px 16px; }
  .bce-account-dl div { grid-template-columns: 1fr; gap: 4px; }

  /* 支付页 */
  .bce-pay-page { padding: 16px 12px 32px; }
  .bce-pay-card { padding: 20px 16px; }
  .bce-pay-order-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .bce-pay-actions { flex-direction: column; }
  .bce-pay-actions a { width: 100%; }

  /* 文档 / 文章 */
  .docs-wrap { max-width: calc(100% - 28px); }
  .docs-hero, .docs-article-hero { padding: 18px 0 12px; }
  .docs-hero h1, .docs-article-hero h1 { font-size: 18px !important; line-height: 1.35; }
  .docs-prose { font-size: 14px; line-height: 1.7; }
  .docs-prose h2 { font-size: 16px !important; }
  .docs-prose h3 { font-size: 14px !important; }
  .docs-prose img,
  .docs-prose video,
  .docs-prose table {
    max-width: 100% !important;
    height: auto !important;
  }
  .docs-prose pre,
  .docs-prose code {
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 13px;
  }
  .docs-paywall { max-width: none; padding: 16px; border-radius: 12px; }
  .docs-sidebar,
  .docs-toc { display: none; }

  /* 门户文章 */
  .bce-pg-layout {
    display: block !important;
    gap: 16px;
    padding: 0 14px;
  }
  .bce-portal-article-body { padding: 14px 0 36px; }
  .bce-portal-article-body h1 { font-size: 18px; line-height: 1.35; }
  .bce-portal-article-body h2 { font-size: 16px; }
  .bce-portal-article-body p { font-size: 14px; line-height: 1.7; }
  .bce-portal-article-body img { max-width: 100%; height: auto; border-radius: 8px; }
  .bce-pg-aside { margin-top: 20px; }

  /* 商城细化 */
  .bce-shop-inner { padding-left: 14px; padding-right: 14px; }
  .bce-shop-head h1,
  .shop-hero h1 { font-size: 18px !important; }
  .bce-shop-card h3,
  .shop-card h3,
  .bce-product-card h3 { font-size: 13px !important; }
  .bce-shop-card .price,
  .shop-card .price,
  .bce-product-card .price { font-size: 14px !important; }
  .bce-btn,
  .shop-btn,
  .bce-shop-btn,
  button.bce-btn,
  a.bce-btn {
    min-height: 34px;
    height: 34px;
    font-size: 13px;
    padding: 0 14px;
    box-sizing: border-box;
    line-height: 1;
  }
  input, select, textarea {
    font-size: 16px !important; /* 避免 iOS 自动放大 */
  }

  /* 关于 / 内容页 */
  .about-wrap,
  .about-site,
  .bce-about {
    padding: 18px 12px 32px;
  }
  .about-wrap h1,
  .about-site h1 { font-size: 18px !important; }
  .about-wrap p,
  .about-site p { font-size: 13px; line-height: 1.65; }

  /* 页脚字号 */
  .official-site-footer,
  .official-home-footer {
    font-size: 12px !important;
  }
  .official-footer-qr__list img {
    max-width: 88px !important;
    height: auto !important;
  }

  /* 开发者文档阅读器 */
  .developer-reader-body .dev-reader,
  .official-devdocs-body .devdocs-wrap {
    padding: 12px 14px 32px;
  }
  .developer-reader-body h1,
  .official-devdocs-body h1 {
    font-size: 18px !important;
  }

  /* 商城网格 */
  .bce-shop-grid,
  .shop-grid,
  .bce-product-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
  .bce-shop-card,
  .shop-card,
  .bce-product-card {
    min-width: 0;
  }
  .bce-shop-card img,
  .shop-card img,
  .bce-product-card img {
    width: 100%;
    height: auto;
  }

  /* 通用防撑破 */
  img, video, svg, canvas {
    max-width: 100%;
  }
  .bce-main-minimal img,
  .bce-main-minimal video {
    height: auto;
  }

  .home-campaign,
  .portal-campaign,
  .official-home-campaign {
    overflow-x: clip;
  }

  /* 卡片 / 框体通用收紧 */
  .bce-card,
  .shop-card,
  .docs-card,
  .about-card {
    border-radius: 12px;
    padding: 12px !important;
  }

  /* 全站通用：压扁过大按钮与标题 */
  .bce-main-minimal a.btn,
  .bce-main-minimal button:not(.bce-m-tabbar__item),
  .bce-main-minimal .btn,
  .bce-main-minimal [class*="btn"]:not(.bce-m-tabbar__item) {
    min-height: 34px;
    font-size: 13px;
    line-height: 1.3;
  }
  .bce-main-minimal h1 { font-size: 20px !important; line-height: 1.3 !important; }
  .bce-main-minimal h2 { font-size: 17px !important; line-height: 1.35 !important; }
  .bce-main-minimal h3 { font-size: 15px !important; line-height: 1.4 !important; }

  /* site.css 首页区块（非 campaign 快照） */
  .kv-title, .camp-title, .bce-kv h1, .bce-camp h2 {
    font-size: 20px !important;
    line-height: 1.3 !important;
  }
  .kv-desc, .camp-desc, .bce-kv p, .bce-camp p {
    font-size: 12px !important;
    line-height: 1.55 !important;
  }

  /* 聊天弹窗占满小屏 */
  .bce-chat-popup__panel {
    width: calc(100vw - 16px) !important;
    max-width: none !important;
    height: min(78vh, 640px) !important;
    right: 8px !important;
    left: 8px !important;
    bottom: calc(var(--bce-m-tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* —— 手机端页脚：隐藏版权/备案/友链多列/二维码（桌面保留） —— */
  .official-site-footer.cloud-footer,
  .official-home-footer.cloud-footer,
  body.bce-body .official-site-footer.cloud-footer {
    min-width: 0 !important;
    width: 100% !important;
    overflow-x: clip !important;
  }
  .official-site-footer .bce-foot-bar,
  .official-home-footer .bce-foot-bar,
  .official-site-footer .copy-right,
  .official-home-footer .copy-right,
  .official-site-footer .official-footer-grid__links,
  .official-home-footer .official-footer-grid__links,
  .official-site-footer .official-footer-grid__qr,
  .official-home-footer .official-footer-grid__qr,
  .official-site-footer .left-link,
  .official-home-footer .left-link {
    display: none !important;
  }
  /* 服务承诺条：两列紧凑 */
  .official-site-footer .footer-header.bce-foot-info,
  .official-home-footer .footer-header.bce-foot-info,
  .cloud-footer .footer-header {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0 !important;
    flex-wrap: unset !important;
    width: 100% !important;
  }
  .official-site-footer .footer-header > a,
  .official-site-footer .footer-header > .official-footer-line,
  .official-home-footer .footer-header > a,
  .official-home-footer .footer-header > .official-footer-line,
  .cloud-footer .footer-header > a,
  .cloud-footer .footer-header > .official-footer-line {
    flex: none !important;
    width: 100% !important;
    height: 40px !important;
    min-height: 40px !important;
    font-size: 11px !important;
    line-height: 1.25 !important;
    padding: 0 8px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .official-site-footer .footer-header .official-footer-line__icon,
  .official-home-footer .footer-header .official-footer-line__icon,
  .cloud-footer .footer-header .official-footer-line__icon {
    width: 18px !important;
    height: 18px !important;
  }
  /* 仅保留联系电话一行 */
  .official-site-footer .official-footer-grid,
  .official-home-footer .official-footer-grid,
  .official-site-footer .main-links.bce-foot-main,
  .official-home-footer .main-links.bce-foot-main {
    display: block !important;
    grid-template-columns: none !important;
    grid-template-areas: none !important;
    padding: 14px 0 10px !important;
    gap: 0 !important;
    width: 100% !important;
  }
  .official-site-footer .official-footer-grid__contact,
  .official-home-footer .official-footer-grid__contact {
    display: block !important;
    padding: 0 4px;
  }
  .official-site-footer .official-footer-grid__contact dt,
  .official-home-footer .official-footer-grid__contact dt {
    font-size: 11px !important;
    margin-bottom: 4px;
  }
  .official-site-footer .official-footer-grid__contact dd,
  .official-home-footer .official-footer-grid__contact dd {
    font-size: 13px !important;
    margin: 0 0 4px !important;
  }
  .official-site-footer .footer-pc,
  .official-home-footer .footer-pc {
    width: calc(100% - 24px) !important;
    max-width: none !important;
    margin: 0 auto !important;
  }
  }
}

/* PC：强制隐藏底部导航 */
@media (min-width: 769px) {
  .bce-m-tabbar {
    display: none !important;
  }
}

@media (max-width: 480px) {
  html:not(.official-phone-scale) .bce-head-search-inline { display: none; }
  html:not(.official-phone-scale) .bce-head-right { margin-left: auto; }

  html:not(.official-phone-scale) .bce-foot--minimal .footer-pc,
  html:not(.official-phone-scale) .bce-foot--minimal .bce-foot-cols {
    grid-template-columns: 1fr;
  }

  html:not(.official-phone-scale) .bce-shop-grid,
  html:not(.official-phone-scale) .shop-grid,
  html:not(.official-phone-scale) .bce-product-grid {
    grid-template-columns: 1fr !important;
  }
}
