/* Phase 34 — Writer mobile fit + feature safety */
@media (max-width: 760px) {
  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #writer-app,
  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #writer-app .editor-column {
    min-height: 0 !important;
    height: 100% !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #writer-app .editor-frame {
    padding-bottom: calc(var(--cbs-writer-live-clearance, 102px) + 8px) !important;
    scroll-padding-bottom: calc(var(--cbs-writer-live-clearance, 102px) + 18px) !important;
    overscroll-behavior-y: contain !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #pages-container {
    gap: 10px !important;
    padding-bottom: 0 !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #writer-app .script-page-sheet {
    min-height: 0 !important;
    padding-bottom: 24px !important;
    margin-bottom: 10px !important;
    overflow: hidden !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #writer-app .page-content {
    min-height: 0 !important;
    height: 800px !important;
    overflow: hidden !important;
    overflow-y: clip !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #mobile-format-bar {
    touch-action: pan-x !important;
    max-width: calc(100vw - 20px) !important;
  }
  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #fmt-drag-handle {
    touch-action: none !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #mobile-format-bar,
  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #block-type-select,
  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #fmt-collapse-toggle,
  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed .format-chip,
  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed .inline-tag-chip,
  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #inline-tag-cancel-btn {
    font-size: 16px !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed .editor-statusbar {
    bottom: calc(var(--cbs-bottom-nav-height, 0px) + var(--sab, 0px) + 8px) !important;
    max-width: calc(100vw - 24px) !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-keyboard .editor-statusbar,
  html[data-ui-tier="phone"] body.cbs-writer-phone-keyboard #sn-toolbar-btn {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-keyboard #mode-indicator {
    display: none !important;
  }

  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #writer-app .page-content,
  html[data-ui-tier="phone"] body.cbs-writer-phone-fixed #writer-app .page-content .line {
    -webkit-text-size-adjust: 100% !important;
  }
}

@media (max-width: 760px) {
  html[data-ui-tier="phone"] body.cbs-writer-phone-keyboard #writer-app {
    position: fixed !important;
    top: var(--cbs-writer-fixed-top, 0px) !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(var(--cbs-writer-viewport-height, 100vh) - var(--cbs-writer-fixed-top, 0px)) !important;
    min-height: 0 !important;
    overflow: hidden !important;
    z-index: 20 !important;
  }
  html[data-ui-tier="phone"] body.cbs-writer-phone-keyboard #writer-app .editor-column {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  html[data-ui-tier="phone"] body.cbs-writer-phone-keyboard #writer-app .editor-frame {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
  }
  html[data-ui-tier="phone"] body.cbs-writer-phone-keyboard #writer-app #pages-container {
    min-height: 0 !important;
  }
}

html[data-ui-tier="phone"] body.cbs-writer-scroll-locked,
html[data-ui-tier="phone"] body.cbs-writer-delete-lock { overscroll-behavior: none !important; }
html[data-ui-tier="phone"] body.cbs-writer-scroll-locked #writer-app .editor-frame { touch-action: pan-y !important; }
