/* Phone layout is last in the cascade. Keep desktop density and saved column widths. */
@media (max-width: 760px) {
  :root { --form-control-height:44px; --form-padding:16px; --form-column-gap:12px; }
  html { -webkit-text-size-adjust:100%; }
  body { min-width:0; }
  #app, main, #content, header, header>div { min-width:0; max-width:100%; }
  main { padding-left:max(12px,env(safe-area-inset-left)); padding-right:max(12px,env(safe-area-inset-right)); padding-bottom:calc(20px + env(safe-area-inset-bottom)); }
  .topbar { padding-left:max(8px,env(safe-area-inset-left)); padding-right:max(8px,env(safe-area-inset-right)); }
  button, .button, summary { touch-action:manipulation; }
  button:not(.text-button), .button { min-height:44px; }
  input:not([type=checkbox]):not([type=radio]), select, textarea,
  .reference-select>.combo-input, .global-search input { font-size:16px; }
  input:not([type=checkbox]):not([type=radio]), select, .reference-select>.combo-input { min-height:44px; }
  label { font-size:14px; line-height:1.45; }
  input[type=checkbox], input[type=radio] { width:20px; height:20px; flex-shrink:0; }
  .top-icon, .header-actions #refresh, #workspace-copy-link { width:44px; height:44px; min-width:44px; min-height:44px; }
  .global-search { height:44px; min-width:0; }
  .global-search input { width:100%; }
  .search-shortcut { display:none; }
  aside { height:100dvh; max-height:100dvh; padding-bottom:env(safe-area-inset-bottom); overflow-y:auto; overscroll-behavior:contain; }
  #close-mobile-nav { min-height:44px; top:8px; right:8px; }
  #nav button, .nav-collapsed #nav button { min-height:44px; }
  header { flex-wrap:wrap; align-items:flex-start; row-gap:12px; }
  header>div:first-child { flex:1 1 220px; }
  .header-actions { flex-wrap:wrap; gap:8px; }
  .header-actions button { font-size:14px; }
  h1 { line-height:1.3; }
  .view-description { font-size:13px; line-height:1.5; }
  .object-toolbar { align-items:stretch; gap:10px; }
  .object-toolbar>*, .toolbar>label { min-width:0; max-width:100%; }
  .object-toolbar>.reference-select { flex:1 1 140px; }
  .object-toolbar select { font-size:16px; }
  .toolbar { flex-wrap:wrap; gap:10px; }
  .toolbar>input, .toolbar>select, .toolbar>label { flex:1 1 140px; }
  .metrics-options { max-width:calc(100vw - 40px); }
  .metrics-options label, .status-checks label, .permission-choice { min-height:44px; align-items:center; }
  .table-card, .report-tree, .structured-table { max-width:100%; overflow:auto; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; }
  .column-resizer { display:none; }
  .campaign-grid .object-name { position:static; box-shadow:none; }
  .campaign-grid th:nth-child(4) { left:auto; box-shadow:none; }
  .table-card tfoot td, .table-card .total-row td { position:static; }
  .report-tree .report-row-name, .report-tree-head>span:first-child { position:static; box-shadow:none; }
  .row-actions button, .view-campaigns .campaign-grid .row-actions button { width:44px; height:44px; min-height:44px; }
  .campaign-grid .object-name .text-button { min-height:44px; }
  .table-footer { gap:10px; align-items:center; }
  .table-footer>div { flex-wrap:wrap; }
  .campaign-workspace { display:grid; grid-template-columns:minmax(0,1fr); gap:16px; }
  .campaign-settings, .campaign-flows { min-width:0; width:100%; }
  .workspace-tabs { display:flex; flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; }
  .workspace-tabs>button { flex-shrink:0; white-space:nowrap; min-height:48px; }
  .campaign-flows>.flows-heading { height:auto; min-height:60px; padding:8px 12px; gap:8px; flex-wrap:wrap; }
  .campaign-flows>.flows-list { padding:12px; }
  .flow-card { padding:12px; }
  .flow-heading { flex-wrap:wrap; }
  .flow-heading .text-button { overflow-wrap:anywhere; }
  .grid, #fields .grid, #campaign-inline-form .grid, .editor-panel .grid,
  .provider-grid, .registration-options { grid-template-columns:minmax(0,1fr); }
  .grid>*, .editor-panel>*, #fields>* { min-width:0; }
  .selection-row { grid-template-columns:minmax(0,1fr) 64px 44px; gap:8px; }
  .filter-row { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
  .filter-row>.reference-select, .filter-row>input { grid-column:1/-1; }
  .filter-row>button { grid-column:2; justify-self:end; width:44px; }
  .postback-url-row { grid-template-columns:minmax(0,1fr); gap:0; }
  .postback-card { padding:12px; }
  .parameter-row { flex-wrap:wrap; min-width:0; }
  .macro-picker-body { padding:10px; }
  .macro-option { min-height:44px; }
  .combo-popup { font-size:16px; max-width:calc(100vw - 16px); }
  .combo-option { padding:12px; min-height:44px; }
  .reference-select { min-width:0; max-width:100%; }
  dialog { width:calc(100% - 16px); max-width:calc(100% - 16px); max-height:calc(100dvh - 16px); margin:auto; padding:0; overflow-y:auto; overscroll-behavior:contain; }
  .dialog-head { position:sticky; top:0; z-index:5; padding:12px 16px; min-height:64px; gap:12px; }
  .dialog-head h2 { font-size:17px; min-width:0; overflow-wrap:anywhere; }
  .dialog-head button { flex-shrink:0; width:44px; padding:10px; }
  #fields, .editor-panel, #campaign-inline-form { padding:16px; }
  .stream-editor #fields { padding:0; }
  .dialog-footer { position:sticky; bottom:0; z-index:5; gap:10px; padding:12px 16px max(12px,env(safe-area-inset-bottom)); }
  .dialog-footer button { flex:1; font-size:15px; }
  #fields input[type=file] { width:100%; max-width:100%; padding:8px; }
  #fields input[type=file]::file-selector-button { max-width:100%; font:inherit; }
  .inline-save { flex-wrap:wrap; gap:10px; }
  #page-preview { width:calc(100% - 16px); height:calc(100dvh - 16px); max-height:calc(100dvh - 16px); }
  .preview-toolbar { gap:10px; }
  .preview-toolbar a { min-height:44px; display:flex; align-items:center; }
  .preview-devices { flex-wrap:wrap; }
  .login { min-height:100dvh; padding:16px; }
  .login-card { width:100%; max-width:410px; padding:24px; }
  #toast { left:12px; right:12px; bottom:calc(12px + env(safe-area-inset-bottom)); max-width:none; overflow-wrap:anywhere; }
}
/* Landscape phones: avoid desktop columns just because the device was rotated. */
@media (min-width:761px) and (max-width:1000px) and (max-height:500px) {
  .campaign-workspace { grid-template-columns:minmax(0,1fr); }
  dialog { max-height:calc(100dvh - 16px); }
  input:not([type=checkbox]):not([type=radio]), select, textarea, .reference-select>.combo-input { font-size:16px; min-height:44px; }
}
