/* UniCell global touch layout. Keep the grid itself scrollable; the shell adapts around it. */
html { -webkit-text-size-adjust: 100%; }
button, input, select, textarea { touch-action: manipulation; }

@media (max-width: 720px) {
  #app { min-width: 0; }
  #ribbon { flex: none; }
  .rb-tabs { min-height: 46px; height: auto; padding: 6px 8px; gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rb-tabs::-webkit-scrollbar { display: none; }
  .rb-brand { width: 26px; height: 26px; margin-right: 1px; }
  .rb-title { display: none; }
  .rb-navigation { order: 3; flex: 1 1 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .rb-navigation::-webkit-scrollbar { display: none; }
  .rb-tab { height: 34px; padding: 0 12px; font-size: 13px; }
  .rb-tabs-fill { display: none; }
  .rb-tabs > #btn-share-workbook { order: 4; }
  .rb-tabs > #btn-ai-assistant { order: 5; }
  .rb-tabs > #btn-command-palette, .rb-tabs > #btn-shortcuts, .rb-tabs > #btn-theme { display: none; }
  .rb-tabs > #btn-account { order: 6; width: 36px; height: 36px; margin-left: auto; }
  .rb-account { min-width: 36px; min-height: 36px; padding: 0 5px; }
  .rb-account-avatar { width: 26px; height: 26px; }
  .rb-panels { border-bottom: 1px solid var(--m3-outline-variant); }
  .rb-panel { height: 64px; padding: 3px 5px 0; }
  .rb-group { padding: 2px 5px 0; }
  .rb-btn { min-width: 44px; height: 44px; padding: 2px 5px; }
  .rb-btn .rb-tx { font-size: 10px; }
  #formula-row { height: 40px; min-height: 40px; }
  #formula-row.expanded { height: 104px; }
  .formula-name-wrap { flex-basis: 86px; min-width: 70px; }
  #name-box { padding-left: 8px; padding-right: 21px; font-size: 12px; }
  #formula-grip { flex-basis: 22px; }
  #formula-edit-controls { flex-basis: 78px; }
  #formula-edit-controls button { width: 31px; }
  #formula-input { padding-left: 8px; padding-right: 28px; font-size: 13px; }
  #statusbar { height: 34px; padding: 0 8px; gap: 6px; }
  #status-msg { font-size: 11px; }
  #status-stats, #status-dim, .st-udoc { display: none; }
  .st-views button { height: 28px; padding: 0 7px; }
  .st-zoom { margin-left: auto; }
  #st-zoom-slider { display: none; }
  .st-zoom button { width: 28px; height: 28px; }
  #st-zoom-level { min-width: 48px; height: 28px; }
  .uk-dialog { padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); align-items: end; }
  .uk-dialog-card, .uk-dialog-wide { width: 100%; max-width: none; max-height: calc(100dvh - 16px); border-radius: 20px 20px 12px 12px; }
  .uk-dialog-head { padding: 16px 16px 10px; }
  .uk-dialog-body { padding: 0 16px max(16px, env(safe-area-inset-bottom)); }
  .account-card { width: 100%; }
  .account-actions { display: grid; grid-template-columns: 1fr; }
  .account-actions button { min-height: 42px; }
  .account-state-hero { padding: 13px; }
  .account-mark { width: 46px; height: 46px; font-size: 21px; }
  .cloud-toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .cloud-toolbar button { min-height: 42px; }
  .cloud-file { align-items: flex-start; flex-wrap: wrap; }
  .cloud-file > div { flex-basis: calc(100% - 10px); }
  .cloud-file > button { min-height: 38px; flex: 1; }
  .nte-dialog, .native-data-dialog, .query-connection-dialog, .pre-dialog, .native-editor { width: calc(100vw - 16px); height: calc(100dvh - 16px); max-height: none; border-radius: 14px; }
  .nte-main, .native-data-main, .qc-workbook, .pre-main { grid-template-columns: 1fr; }
  .nte-sidebar, .native-data-sidebar, .qc-nav, .pre-sidebar { max-height: 34dvh; border-right: 0; border-bottom: 1px solid #ddd; }
  .native-grid { grid-template-columns: 1fr 1fr; }
  .native-grid label.native-wide { grid-column: 1 / -1; }
}

@media (max-width: 420px) {
  .rb-navigation .rb-tab { padding: 0 10px; }
  .rb-panel { height: 60px; }
  .rb-btn { min-width: 40px; }
  .native-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
