/* 最后加载的窄屏布局。桌面模块与业务权限仍由原有样式和脚本控制。 */
.mobile-site-brand { display: none; }

@media screen and (max-width: 768px) {
  [hidden] { display: none !important; }
  :root { --mobile-nav-height: 68px; --mobile-gutter: 16px; }
  html { scroll-padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 16px); }
  body { min-width: 0; -webkit-text-size-adjust: 100%; }
  body.home-page-active,
  body.home-page-active:has(#home-task-list:empty),
  body:is(.generation-page-active,.policy-page-active,.asset-page-active,.video-page-active,.short-drama-page-active) { height: auto; min-height: 100dvh; overflow-y: auto; }

  .page-shell,
  body.home-page-active .page-shell,
  body:is(.generation-page-active,.policy-page-active,.asset-page-active,.video-page-active,.short-drama-page-active) .page-shell {
    width: 100%; height: auto; min-height: 100dvh; overflow: visible;
    padding: calc(78px + env(safe-area-inset-top)) max(var(--mobile-gutter), env(safe-area-inset-right)) calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 24px) max(var(--mobile-gutter), env(safe-area-inset-left));
  }
  .app-frame,
  .workspace,
  body.home-page-active .workspace,
  body:is(.generation-page-active,.policy-page-active,.asset-page-active,.video-page-active,.short-drama-page-active) :is(.app-frame,.workspace) { width: 100%; min-width: 0; max-width: 100%; height: auto; margin-left: 0; overflow: visible; }
  .page-screen { min-width: 0; max-width: 100%; }
  body:is(.policy-page-active,.asset-page-active,.video-page-active,.short-drama-page-active) :is(.page-screen,.videos-page-stack,.videos-layout) { height: auto; }
  #page-home.active { height: auto; min-height: 0; overflow: visible; }

  .mobile-site-brand {
    position: absolute; top: calc(18px + env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left));
    z-index: 901; display: inline-flex; align-items: center; gap: 9px;
    min-height: 40px; color: #eaf9f4; text-decoration: none; font-size: 15px; font-weight: 750;
  }
  .mobile-site-brand img { width: 29px; height: 29px; object-fit: contain; }

  .side-nav,
  .membership-page .side-nav,
  body.asset-page-active .side-nav {
    position: fixed; inset: auto 0 0; z-index: 1200; display: flex; flex-direction: row;
    justify-content: space-around; align-items: stretch; gap: 2px; width: 100vw; max-width: none; height: auto;
    min-height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); margin: 0;
    padding: 7px max(10px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    border: 0; border-top: 1px solid rgba(123, 216, 193, .15); border-radius: 0;
    background: rgba(4, 19, 19, .97); backdrop-filter: blur(22px); box-shadow: 0 -8px 32px rgba(0,0,0,.22);
  }
  .side-nav::before { display: none; }
  .side-nav .side-nav-brand { display: none; }
  .side-nav .side-nav-item,
  body.asset-page-active .side-nav .side-nav-item {
    flex: 1 0 48px; width: auto; max-width: 96px; height: 54px; min-height: 54px; margin: 0;
    padding: 5px 8px; gap: 5px; border-radius: 12px; justify-content: center; flex-direction: column;
  }
  .side-nav .side-nav-icon { width: 22px; height: 22px; }
  .side-nav .side-nav-icon svg { width: 21px; height: 21px; }
  .side-nav .side-nav-text { font-size: 11px; line-height: 1.2; letter-spacing: .04em; }
  .side-nav .side-nav-item.active { color: #7ce5c1; background: rgba(80,224,176,.09); box-shadow: none; }
  .side-nav .side-nav-membership-promo {
    flex: 1 0 54px; width: auto; max-width: 96px; min-height: 54px; margin: 0; padding: 5px 8px;
    border: 0; border-radius: 12px; background: transparent; box-shadow: none;
  }
  .side-nav-membership-promo::after,
  .side-nav .side-nav-membership-promo > strong,
  .side-nav .side-nav-membership-promo > b,
  .side-nav .side-nav-membership-promo > span:not(.side-nav-membership-promo-kicker) { display: none; }
  .side-nav .side-nav-membership-promo-kicker { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; line-height: 1.2; }
  .side-nav-membership-promo-kicker svg { width: 21px; height: 21px; }

  .global-account-menu { top: calc(15px + env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); }
  .global-account-menu .global-account-trigger { min-width: 44px; min-height: 44px; }
  .global-account-panel { max-width: calc(100vw - 32px); max-height: calc(100dvh - 100px); overflow-y: auto; }
  .workspace-page-header,
  .global-account-menu ~ .page-shell .workspace-page-header,
  .overseas-header.social-page-header { padding-right: 0; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
  .workspace-page-header h1 { font-size: 25px; line-height: 1.3; }
  .workspace-page-kicker { font-size: 10px; letter-spacing: .12em; }
  .workspace-page-actions,
  .detail-header-actions,
  .generation-page-actions { flex-wrap: wrap; min-width: 0; max-width: 100%; gap: 8px; }
  .workspace-page-heading { min-width: 0; }

  /* 输入与主要操作的触控尺寸；排除复选框、单选框、滑块。 */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]):not([type=color]),
  textarea, select { min-width: 0; max-width: 100%; font-size: 16px; }
  :is(.primary-button,.ghost-button,.auth-submit-button,.auth-code-button,.cf-button,.mkt-btn,.mini-btn,.close-sheet,.auth-close-button,.auth-policy-close,.modal-close,.close-button) { min-height: 44px; }
  :is(.modal-close,.close-button,.auth-close-button,.auth-policy-close,.close-sheet) { min-width: 44px; }
  .panel { min-width: 0; padding: 16px; border-radius: 18px; }
  :is(.panel-header,.detail-panel-header,.section-header,.table-footer,.account-bulkbar) { gap: 12px; flex-wrap: wrap; }

  /* 首页：释放首屏高度，输入和操作始终参与自然文档流。 */
  body.home-page-active #page-home .home-banner { height: auto; min-height: 0; max-height: none; overflow: hidden; mask-image: none; -webkit-mask-image: none; }
  body.home-page-active #page-home .home-banner-copy { padding: 8px 0 24px; width: 100%; min-height: 0; justify-content: flex-start; }
  #page-home .home-banner h1 { max-width: 100%; font-size: clamp(25px, 7.4vw, 38px); line-height: 1.2; }
  #page-home .home-banner h1 span,
  #page-home .home-banner h1 strong { white-space: normal; }
  #page-home .home-banner-copy p { max-width: 100%; font-size: 12px; }
  #page-home .home-banner-stage { display: none; }
  body.home-page-active #page-home .home-quick-composer { height: auto; min-height: 0; max-height: none; margin-top: -8px; }
  #page-home .home-quick-input-panel { min-width: 0; padding: 16px; border-radius: 20px; overflow: visible; }
  #page-home .home-composer-mode-row { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
  #page-home .home-mode-selectors { display: contents; }
  #page-home .home-mode-selectors::before,#page-home .home-mode-selectors::after { display: none; }
  #page-home .home-mode-button { min-width: 0; width: 100%; min-height: 44px; height: auto; padding: 8px 4px; font-size: 12px; border: 1px solid rgba(85,231,186,.2); border-radius: 12px; }
  #page-home .home-mode-button[aria-pressed=true] { background: linear-gradient(135deg,#62e6be,#45c9d4); color: #002019; }
  #page-home .home-intent-area { min-height: 144px; max-height: none; }
  #page-home .home-intent-area #home-intent-input { min-height: 144px; height: 144px; max-height: none; padding: 42px 10px 16px; font-size: 16px; line-height: 1.65; }
  #page-home .home-intent-area:has(> #reference-upload-stack:not([hidden])) #home-intent-input { padding: 42px 4px 16px 90px; }
  #page-home .home-intent-label { top: 16px; left: 10px; }
  #page-home .home-intent-area:has(> #reference-upload-stack:not([hidden])) .home-intent-label { left: 90px; }
  #page-home .home-intent-area > .reference-upload-stack { left: 0; top: 24px; transform: none; }
  #page-home .reference-upload-button { transform: none; width: 64px; height: 84px; }
  #page-home .home-intent-inline-hint { max-width: 100%; white-space: normal; font-size: 11px; }
  #page-home .home-composer-footer { flex-wrap: wrap; gap: 12px; padding: 12px 0 0; }
  #page-home .home-composer-footer-left { flex: 1 1 180px; min-width: 0; flex-wrap: wrap; gap: 8px; }
  #page-home .home-advanced-fields .workflow-structured-fields { grid-template-columns: minmax(0,1fr); }
  #page-home .home-business-shortcuts { grid-template-columns: minmax(0,1fr); gap: 12px; margin-top: 16px; }
  #page-home .home-business-entry { min-height: 110px; padding: 20px; }
  #page-home .home-business-entry-icon { width: 46px; height: 46px; border-radius: 14px; }
  #page-home .home-layout { height: auto; max-height: none; overflow: visible; }

  /* 生产、创作与作品 */
  :is(.generation-page-layout,.generation-request-content,.commercial-layout,.commercial-content-grid,.commercial-parameters,.commercial-composer-layout,.videos-layout,.split-layout,.assets-split-layout) { grid-template-columns: minmax(0,1fr); min-width: 0; }
  .generation-request-copy { min-width: 0; overflow-wrap: anywhere; }
  .generation-page-header { flex-direction: column; gap: 16px; align-items: stretch; }
  .generation-reference-tile { max-width: 100%; }
  #page-commercial-creation .commercial-inspiration-banner { min-height: 160px; padding: 20px 16px; }
  #page-commercial-creation .commercial-inspiration-copy { min-width: 0; max-width: 100%; padding: 0; }
  #page-commercial-creation .commercial-inspiration-copy h1 { font-size: 27px; white-space: normal; }
  #page-commercial-creation .commercial-composer { width: 100%; min-width: 0; padding: 16px; }
  :is(.commercial-script-actions,.commercial-submit-row,.commercial-toolbar,.commercial-parameters) { flex-wrap: wrap; gap: 10px; }
  .commercial-script-shell { min-width: 0; }
  .work-search-chip { min-width: 0; max-width: 100%; }
  .work-search-chip input { width: 100%; min-width: 0; }
  .videos-page-stack { width: 100%; min-width: 0; }
  .video-source-nav,
  .videos-page-tabs,
  .unified-library-tabs,
  .social-workspace-tabs,
  .segmented-tabs { max-width: 100%; min-width: 0; overflow-x: auto; flex-wrap: nowrap; overscroll-behavior-x: contain; scrollbar-width: none; }
  :is(.video-source-nav,.videos-page-tabs,.unified-library-tabs,.social-workspace-tabs,.segmented-tabs) > button { flex-shrink: 0; min-height: 44px; }
  .video-date-filter { min-width: 0; max-width: 100%; padding: 14px; }
  .date-range-shell { max-width: 100%; min-width: 0; flex-wrap: wrap; }
  .date-quick-group { flex-wrap: wrap; gap: 6px; }
  .video-batch-toolbar { flex-wrap: wrap; min-width: 0; max-width: 100%; }
  :is(.video-grid,.works-grid,.unified-works-grid,.asset-group-grid,.unified-asset-grid) { grid-template-columns: repeat(2,minmax(0,1fr)); min-width: 0; }
  :is(.task-list,.task-cards,.project-card-grid,.social-hub-modules) { grid-template-columns: minmax(0,1fr); min-width: 0; }
  .video-wall-compact { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .video-poster-card { min-width: 0; }

  /* 资产：目录收紧，详情完整可读。 */
  #page-assets .assets-split-layout { grid-template-columns: minmax(0,1fr); grid-template-areas: none; }
  #page-assets .unified-vehicle-explorer { display: grid; grid-template-columns: minmax(0,1fr); grid-template-areas: 'brand' 'vehicles' 'detail'; height: auto; min-height: 0; max-height: none; gap: 12px; }
  #page-assets .unified-brand-directory { grid-area: brand; height: auto; min-height: 0; max-height: 180px; overflow-y: auto; }
  #page-assets .unified-brand-index { display: flex; flex-direction: row; flex-wrap: wrap; height: auto; max-height: 120px; overflow-y: auto; align-content: flex-start; gap: 6px; }
  #page-assets .unified-brand-index > :is(.unified-brand-all,.unified-brand-group) { width: auto; max-width: 100%; flex: 0 1 auto; min-height: 44px; }
  #page-assets .unified-vehicle-directory { grid-area: vehicles; width: 100%; height: auto; min-height: 0; max-height: 240px; overflow-y: auto; }
  #page-assets .unified-vehicle-detail { grid-area: detail; width: 100%; height: auto; min-height: 280px; max-height: none; }
  #page-assets :is(.unified-assets-main,.unified-vehicle-content,.unified-vehicle-toolbar) { min-width: 0; max-width: 100%; }
  #page-assets :is(.unified-asset-toolbar,.asset-upload-row,.unified-upload-row,.unified-batch-toolbar) { flex-wrap: wrap; gap: 8px; }

  /* 社媒与看板：只让密集数据的所属区域滚动。 */
  .social-page-navigation { width: 100%; min-width: 0; flex-wrap: wrap; gap: 12px; }
  .social-hub-hero { padding: 22px 18px; }
  .social-hub-hero h2 { white-space: normal; font-size: 25px; line-height: 1.35; }
  :is(.social-hub-layout,.dashboard-grid,.insight-layout,.publish-layout,.schedule-layout,.project-board-grid) { grid-template-columns: minmax(0,1fr); min-width: 0; }
  .flow-progress { max-width: 100%; overflow-x: auto; }
  .flow-progress > * { flex-shrink: 0; }
  .publish-submitbar { position: static; flex-wrap: wrap; gap: 10px; }
  .platform-picker { flex-wrap: wrap; }
  #page-social-accounts .account-matrix-filters { flex-wrap: wrap; }
  #page-social-accounts .account-matrix-filters #account-market-filter,
  #page-social-accounts .account-matrix-filters #account-brand-filter { width: auto !important; min-width: 0 !important; max-width: 100% !important; flex: 1 1 100px; }
  .schedule-date-time { flex-wrap: wrap; max-width: 100%; }
  .dashboard-date-range .dashboard-filter-field { min-width: 0; max-width: 100%; }
  .dashboard-account-health-tooltip { position: fixed; top: auto; bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 16px); left: 16px; right: 16px; width: auto; }
  .schedule-date-cascade-columns { width: 100%; max-width: 100%; min-width: 0; }
  :is(.overseas-table-wrap,.dashboard-table-wrap,.points-table-wrap,.project-matrix-scroll,.project-gantt,.table-wrap,.cf-table-wrap) { min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
  .table-footer > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .project-table-row:not(.is-head) > span:nth-child(3) { display: block; grid-column: 1 / -1; white-space: normal; }
  .short-drama-screen { min-width: 0; max-width: 100%; }
  .short-drama-screen iframe { width: 100%; min-width: 0; max-width: 100%; }

  /* 登录：聚焦表单，不在手机堆叠桌面装饰面板。 */
  .auth-gate { padding: max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left)); align-items: safe center; overflow-y: auto; }
  .auth-card { display: block; width: min(100%,440px); margin: auto; border-radius: 24px; }
  .auth-visual-panel { display: none; }
  .auth-panel-content { min-height: 0; padding: 44px 24px 24px; gap: 0; }
  .auth-brand { justify-content: flex-start; margin-bottom: 28px; font-size: 16px; }
  .auth-brand img { width: 32px; height: 32px; }
  .auth-card h1 { margin-bottom: 28px; text-align: left; font-size: clamp(24px,6.8vw,31px); line-height: 1.3; }
  .auth-close-button { top: 12px; right: 12px; }
  .auth-phone-form,.auth-account-form { gap: 16px; }
  .auth-phone-form label,.auth-account-form label { gap: 9px; font-size: 13px; }
  .auth-code-row { grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: stretch; }
  .auth-code-button { width: auto; padding: 0 12px; font-size: 12px; }
  .auth-phone-form input:not([type=checkbox]),.auth-account-form input { min-height: 50px; padding: 13px 12px; border-radius: 12px; }
  .auth-consent-row { grid-template-columns: 20px minmax(0,1fr); gap: 9px; font-size: 12px; line-height: 1.7; }
  .auth-phone-form .auth-consent-checkbox { width: 18px; height: 18px; min-height: 18px; margin: 2px 0 0; padding: 0; }
  .auth-feedback:empty { min-height: 0; }
  .auth-submit-button { min-height: 50px; margin-top: 4px; }
  .auth-alt-actions { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; margin-top: 24px; padding-top: 20px; }
  .auth-alt-divider { display: none; }
  .auth-alt-button { min-height: 44px; width: 100%; padding: 4px 0; gap: 7px; justify-content: flex-start; }
  .auth-alt-button strong { font-size: 11px; }
  .auth-alt-button small { font-size: 10px; }

  /* 独立会员、订单与支付页面 */
  .membership-page .cf-app { display: block; min-width: 0; }
  .membership-page .cf-main,
  .membership-center-page .cf-main,
  .commerce-page .cf-main,
  .payment-prototype-page .cf-main { width: 100%; min-width: 0; margin-left: 0; padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); }
  .membership-page .cf-header { min-height: 72px; height: auto; padding: 18px 16px; padding-top: calc(18px + env(safe-area-inset-top)); gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
  .membership-page .cf-header .mobile-site-brand { position: static; }
  .membership-page .cf-header .cf-breadcrumb { display: none; }
  .membership-page .cf-header-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
  .membership-page .cf-content,.payment-prototype-page .cf-content { width: 100%; min-width: 0; padding: 20px 16px 32px; }
  .membership-page .cf-promo-bar { white-space: normal; padding: 12px 42px 12px 16px; line-height: 1.6; }
  .membership-page .cf-admin-link:not([hidden]) { display: inline-flex; min-height: 44px; align-items: center; }
  .membership-page .cf-hero-copy h1 { font-size: 29px; line-height: 1.3; }
  .membership-page .cf-membership-hero { display: block; padding: 24px 20px; }
  .membership-page .cf-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .membership-page .cf-plan-grid { grid-template-columns: minmax(0,1fr); }
  .cf-plan-main { padding: 22px 20px; }
  .cf-section-heading,.cf-heading-with-actions,.cf-detail-header,.cf-ledger-page-actions { flex-wrap: wrap; gap: 12px; }
  .cf-billing-controls { flex-wrap: wrap; gap: 12px; }
  .cf-tab,.cf-cycle-switch button { min-height: 44px; }
  .cf-detail-card,.cf-account-card { min-width: 0; }
  .prototype-safety { min-width: 0; max-width: 100%; }
  .prototype-intro { padding: 24px 20px; }
  .screen { min-width: 0; padding: 18px; }
  .screen-actions,.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
  .scenario-bar { max-height: none; overflow-x: auto; }

  /* 管理页没有主站壳，使用横向导航而非占宽侧栏。 */
  .admin-layout:not([hidden]) { display: block; }
  .admin-sidebar { position: static; width: 100%; height: auto; padding: calc(18px + env(safe-area-inset-top)) 16px 12px; border-right: 0; border-bottom: 1px solid #293a37; }
  .admin-sidebar .brand { margin-bottom: 16px; }
  .admin-sidebar .nav-title { display: none; }
  .admin-sidebar nav { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; }
  .admin-sidebar nav button { flex: 0 0 auto; min-height: 44px; white-space: nowrap; }
  .admin-main { min-width: 0; margin: 0; padding: 20px 16px 32px; }
  .page-heading,.heading-actions,.pager { flex-wrap: wrap; gap: 12px; }
  .usage-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .usage-charts,.sync-grid { grid-template-columns: minmax(0,1fr); }
  .admin-main .filters { flex-wrap: wrap; }
  .admin-main .filters > * { min-width: 0; max-width: 100%; }
  .admin-content { min-width: 0; padding: 20px 0; }
  .admin-header { padding: 0; gap: 12px; flex-wrap: wrap; }
  .admin-sidebar .sidebar-footer { display: none; }
  .admin-layout button { min-height: 44px; }

  /* 弹窗留足短屏滚动和安全区，不改变任何显示/隐藏状态。 */
  :is(.modal-card,.modal-content,.confirm-card,.prototype-drawer-panel,.mkt-modal,.cf-business-dialog) { min-width: 0; max-width: calc(100vw - 24px); max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px); overflow-y: auto; }
  :is(.confirm-dialog,.prototype-confirm-dialog) { min-width: 0; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
  #admin-modal { padding: 12px; }
  #admin-modal .modal-card { width: 100%; }
  #admin-modal .modal-heading button { min-width: 44px; min-height: 44px; }
  .form-actions,.modal-footer,.confirm-actions,.mkt-modal-foot { flex-wrap: wrap; gap: 8px; }
  .form-actions button,.modal-footer button,.cf-business-dialog button { min-height: 44px; }
  .admin-layout ~ .modal-root .modal-body { min-height: 0; overflow-y: auto; }
  .mkt-list { grid-template-columns: minmax(0,1fr); }
  .mkt-modal-foot { padding-bottom: max(16px,env(safe-area-inset-bottom)); }
  .mkt-close { min-width: 44px; min-height: 44px; }
  .mkt-card .mkt-more { flex-basis: 44px; }
  .mkt-card .mkt-more summary { width: 44px; height: 44px; }
  .marketing-claim-page .wrap { padding: 20px 16px max(32px,env(safe-area-inset-bottom)); }
  .marketing-claim-page .hero { padding: 22px 18px; }
  .marketing-claim-page .topic { grid-template-columns: minmax(0,1fr); gap: 12px; }
}

@media screen and (max-width: 430px) {
  :root { --mobile-gutter: 14px; }
  .auth-panel-content { padding-inline: 20px; }
  :is(.video-grid,.works-grid,.unified-works-grid,.asset-group-grid,.unified-asset-grid) { gap: 10px; }
  .commercial-parameters { grid-template-columns: minmax(0,1fr); }
  .membership-page .cf-metrics { grid-template-columns: minmax(0,1fr); }
  /* 领取页卡片需要容纳预览与领取两个操作。 */
  .marketing-claim-page .grid { grid-template-columns: minmax(0,1fr); }
}
