/* Mobile uses the same panel bodies and toolbar as the desktop shell. */
@media (max-width: 1180px) {
  .td-mobile-editor-shell { --td-shell-dock-height: 112px; padding-bottom: var(--td-shell-dock-height); min-width: 0; height: 100%; min-height: 0; overflow: clip; box-sizing: border-box; }
  .td-mobile-editor-shell .td-preview-column { min-width: 0; width: 100%; max-width: none !important; margin: 0 !important; padding: 0 !important; background: #f3f3f4 !important; }
  /* Legacy mobile polish adds a white bordered card; the shell preview should match the flat desktop gray surface. */
  .td-mobile-editor-shell .td-preview-panel { width: 100%; max-width: none !important; border: 0 !important; border-radius: 0; background: #f3f3f4 !important; padding: 0 !important; box-shadow: none !important; }
  .td-mobile-editor-shell .td-preview-aligner { border-radius: 0; background: transparent; }
  .td-mobile-editor-shell:has(.td-mobile-shell-sheet) .td-preview-column { height: var(--td-sheet-preview-height); min-height: 0; padding: 0 !important; overflow: hidden; }
  .td-mobile-editor-shell:has(.td-mobile-shell-sheet) .td-preview-panel { display: flex; flex-direction: column; height: 100%; max-height: 100%; min-height: 0; box-sizing: border-box; overflow: hidden; }
  .td-mobile-editor-shell:has(.td-mobile-shell-sheet) .td-preview-stage-wrap { flex: 1 1 0; height: auto !important; min-height: 0 !important; overflow: hidden; }
  .td-mobile-editor-shell:has(.td-mobile-shell-sheet) .td-preview-stage { max-height: 100%; min-height: 0 !important; box-sizing: border-box; }
  .td-mobile-editor-shell:has(.td-mobile-shell-sheet) .td-preview-zoom-stage { display: none; }

  .td-mobile-shell-dock { position: fixed; z-index: 100; bottom: 0; left: 0; right: 0; background: transparent; padding-bottom: env(safe-area-inset-bottom); }
  .td-mobile-shell-nav { display: flex; align-items: stretch; justify-content: flex-start; min-height: 56px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; touch-action: pan-x; -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-snap-type: x proximity; border-top: 1px solid #dedade; background: #fff; }
  .td-mobile-shell-nav::-webkit-scrollbar { display: none; }
  .td-mobile-shell-nav .td-shell-button { flex-direction: column; scroll-snap-align: start; }
  .td-mobile-editor-shell button:focus-visible { outline: 2px solid #bd4a78; outline-offset: -2px; }
  .td-mobile-editor-shell button:disabled { opacity: .45; }
  .td-mobile-editor-shell .td-context-toolbar { display: flex; overflow: hidden; align-items: center; scrollbar-width: none; height: 52px; box-sizing: border-box; gap: 6px; padding: 4px; border-bottom: 1px solid #dedade; border-top: 1px solid #dedade; background: #fff; }
  .td-mobile-editor-shell .td-shell-toolbar-actions, .td-mobile-editor-shell .td-shell-stepper { display: flex; align-items: center; gap: 4px; flex: none; }
  .td-mobile-editor-shell .td-shell-toolbar-actions { margin-left: 0; }
  .td-mobile-editor-shell .td-shell-font-label { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
  .td-mobile-shell-sheet { position: fixed; z-index: 99; bottom: calc(var(--td-shell-dock-height) + env(safe-area-inset-bottom)); left: 0; right: 0; height: auto; max-height: min(55dvh, calc(65dvh - var(--td-editor-header-height) - var(--td-shell-dock-height) - env(safe-area-inset-bottom))); display: flex; flex-direction: column; min-height: 0; background: #fff; border: 1px solid #dedade; border-radius: 14px 14px 0 0; box-shadow: 0 -4px 18px #0001; animation: td-shell-panel-enter 210ms cubic-bezier(.2, .8, .25, 1) both; }
  .td-mobile-shell-sheet .td-mobile-sheet-head { position: static; display: flex; justify-content: space-between; align-items: center; flex: none; height: 52px; font-size: 15px; font-weight: 900; color: #241f20; padding: 4px 12px; }
  .td-mobile-shell-sheet .td-left-panel-body { min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; padding: 12px; }
  .td-mobile-shell-sheet .td-layer-panel, .td-mobile-shell-sheet .create-desktop-sidebar { display: block !important; position: static; width: 100%; height: auto; max-height: none; margin: 0; }
  /* The sheet header already says "Layers"; drop the list's own heading and card frame inside it. */
  .td-mobile-shell-sheet .td-layer-panel-header { display: none; }
  /* Touch reorders with the step arrows instead of the drag grip. */
  .td-mobile-shell-sheet .td-layer-grip { display: none; }
  /* Without the grip column the row is name | status | arrows. */
  .td-mobile-shell-sheet .td-layer-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .td-mobile-shell-sheet .td-layer-group-row { grid-template-columns: 20px minmax(0, 1fr) auto auto; }
  .td-mobile-shell-sheet .td-layer-background { grid-template-columns: minmax(0, 1fr); }
  .td-mobile-shell-sheet .td-layer-background > span:first-child { display: none; }
  .td-mobile-shell-sheet .td-layer-background .td-layer-name { grid-column: 1 / -1; }
  .td-mobile-shell-sheet .td-layer-panel-inner { border: 0; background: transparent; padding: 0; box-shadow: none; }
  .td-mobile-shell-sheet .td-shell-detail { width: 100%; }
  .td-mobile-shell-sheet .td-shell-upload { display: grid; gap: 12px; }
  .td-mobile-shell-sheet .td-shell-text-input, .td-mobile-shell-sheet .td-shell-text-input form, .td-mobile-shell-sheet .td-shell-new-text { display: grid; gap: 12px; }
  .td-mobile-shell-sheet textarea { width: 100%; min-height: 100px; }
  .td-mobile-editor-shell .td-context-toolbar::-webkit-scrollbar { display: none; }
  .td-mobile-editor-shell .td-shell-stepper { gap: 0; }
  .td-mobile-shell-sheet .td-shell-text-input > button { width: 100%; }
  .td-mobile-shell-sheet .td-stamp-picker { min-width: 0; height: auto; max-height: none; margin: 0; padding: 0; border: 0; overflow: visible; overscroll-behavior: auto; }
  .td-mobile-shell-sheet :is(.td-stamp-row-scroll, .td-stamp-grid) { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); min-width: 0; overflow-x: hidden; }
  .td-mobile-shell-sheet :is(.td-stamp-row-scroll, .td-stamp-grid) > * { min-width: 0; max-width: 100%; }
  .td-mobile-editor-shell .td-preview-zoom-stage { display: flex; position: fixed; right: 10px; bottom: calc(var(--td-shell-dock-height) + env(safe-area-inset-bottom) + 8px); z-index: 98; }
  .td-app.is-mobile-input-focused .td-mobile-shell-sheet { top: calc(var(--td-visual-viewport-top, 0px) + var(--td-visual-viewport-height, 100dvh) - min(42dvh, 300px)); bottom: auto; height: min(42dvh, 300px); z-index: 110; }
  .td-app.is-mobile-input-focused .td-mobile-shell-dock { visibility: hidden; }
}

.td-input-candidate-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.td-input-candidate-close { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: 0; border-radius: 8px; background: transparent; color: #655d62; font-size: 24px; cursor: pointer; }
@media (max-width: 1180px) {
  .td-mobile-shell-sheet .td-emoji-grid { max-height: none; overflow: visible; overscroll-behavior: auto; }
}

@media (max-width: 1180px) {
  /* Inline font candidates contribute to sheet height; the sheet owns scrolling. */
  .td-mobile-shell-sheet .td-font-picker-field.is-inline .td-font-menu {
    position: static; margin: 0; padding: 0; border: 0; box-shadow: none;
  }
  .td-mobile-shell-sheet .td-font-picker-field.is-inline .td-font-menu-list {
    max-height: none; overflow: visible; overscroll-behavior: auto;
  }
}

@media (max-width: 1180px) {
  .td-mobile-editor-shell :is(.td-composer-tool-emoji, .td-composer-tool-icon, .td-emoji-panel, .td-mobile-input-tools),
  .td-mobile-input-tool-sheet { display: none; }
  .td-mobile-shell-sheet .td-text-writing-mode { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; }
}

@media (max-width: 1180px) {
  .td-toolbar-tooltip { display: none; }
}
