/* Compact mobile actions, uncompressed color targets and keyboard-safe dialogs. */
.mobile-confirm-bar,.mobile-text-fields{display:contents}
@media (max-width:700px), (max-height:500px) and (pointer:coarse){
  :root{--mobile-nav-height:44px;--mobile-header-height:44px}
  body .topbar{height:calc(44px + env(safe-area-inset-top));min-height:44px;padding:calc(4px + env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) 4px max(10px,env(safe-area-inset-left));gap:8px}
  .topbar .brand{font-size:21px;line-height:1;letter-spacing:-.8px}
  .brand-actions{gap:6px}
  .brand-actions>a,.brand-actions>button{height:34px;width:34px;min-width:34px;border-radius:8px}
  body .studio-commandbar{display:flex;flex-direction:row;align-items:center;justify-content:space-between;height:44px;min-height:44px;padding:4px 10px;gap:8px}
  .studio-commandbar .product-heading{flex:1;min-width:0;max-width:100%;gap:0}
  .studio-commandbar .product-heading .product-icon,.studio-commandbar .product-heading p{display:none}
  .studio-commandbar .product-heading h1{font-size:13px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}
  .studio-commandbar .command-actions{width:auto;max-width:none;flex:0 0 auto;gap:4px;justify-content:flex-end}
  .studio-commandbar .command-actions #switch-finish{padding:5px 8px;font-size:10px;max-width:132px}
  body.mobile-review .studio-commandbar{height:44px;min-height:44px}
  body.mobile-keyboard-open .topbar{display:none}
  body.mobile-keyboard-open .studio-commandbar .command-actions{display:none}

  /* Dialogs are outside .studio, so the panel swatch sizing never reached them.
     A fixed square hit target cannot shrink into an ellipse in Safari flexbox. */
  dialog:not(.studio-tour) .swatches{display:flex;flex-wrap:wrap;gap:8px;padding:4px;margin:4px 0 8px}
  dialog:not(.studio-tour) .swatches button.swatch{box-sizing:border-box;position:relative;flex:0 0 44px;width:44px;min-width:44px;max-width:44px;height:44px;min-height:44px;max-height:44px;aspect-ratio:1/1;margin:0;padding:0;border-radius:50%;transform:none;touch-action:manipulation}
  dialog:not(.studio-tour) .swatches button.swatch:active{transform:none}
  dialog:not(.studio-tour) .dialog-close{width:44px;min-width:44px;max-width:44px;height:44px;min-height:44px;max-height:44px;display:grid;place-items:center;padding:0;line-height:1}

  /* Keep only a small action row fixed within each sheet; content scrolls behind it. */
  .studio .mobile-confirm-bar{position:sticky;bottom:0;z-index:8;display:flex;flex-direction:column;gap:6px;padding:8px 0 calc(8px + env(safe-area-inset-bottom));margin:6px 0 0;background:#19191f;border-top:1px solid #ffffff16}
  .studio .mobile-confirm-bar>button,.studio .mobile-confirm-bar>button.wide,.studio .upload-workflow .mobile-confirm-bar>.up-use{width:100%;min-height:44px;height:44px;max-height:none;margin:0!important;padding:8px 12px;font-size:14px;line-height:1.2;touch-action:manipulation}
  .studio-light .studio .mobile-confirm-bar{background:#f8f9fb;border-color:#0002}
  body #design.studio>#sidebar>.mobile-sheet-content>.source-picker{display:none}
  body[data-tool="text"] #design.studio>#sidebar>.mobile-sheet-content{display:flex;flex-direction:column;padding:0;overflow:hidden}
  body[data-tool="text"] .studio #tool-text:not([hidden]){display:flex;flex-direction:column;flex:1 1 auto;min-height:0;height:100%;padding:0;overflow:hidden}
  .studio #tool-text .mobile-text-fields{display:block;flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:8px 14px;scroll-padding:12px 0}
  .studio #tool-text .reference-text-intro{justify-content:flex-end;font-size:11px;line-height:16px;margin:0 0 6px}
  .studio #tool-text .reference-text-intro>span:first-child{display:none}
  .studio #tool-text>.mobile-confirm-bar{position:relative;flex:0 0 auto;margin:0;padding:8px 14px calc(8px + env(safe-area-inset-bottom))}
  .studio .mobile-confirm-bar>button.primary:not(:disabled){background:#176cf1;color:#fff;border-color:#176cf1}
  .studio .mobile-confirm-bar>button.primary:not(:disabled):is(:hover,:focus-visible,:active){background:#215fe3;color:#fff}

  /* A separate content scroller prevents the sticky confirmation from jumping
     off-screen when the iOS keyboard changes the visual viewport. */
  #template-dialog[open]{display:flex;flex-direction:column;padding:0;overflow:hidden;max-height:calc(var(--mobile-vh,100dvh) - 20px)}
  #template-dialog .template-dialog-content{min-height:0;flex:1 1 auto;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:18px 18px 10px;scroll-padding:12px 0}
  #template-dialog .mobile-confirm-bar{display:block;flex:0 0 auto;position:relative;padding:8px 18px calc(8px + env(safe-area-inset-bottom));margin:0;background:var(--panel,#19191f);border-top:1px solid var(--line,#ffffff16)}
  #template-dialog .mobile-confirm-bar>button{width:100%;height:44px;min-height:44px;margin:0;padding:8px 12px;font-size:14px;line-height:1.2}
  #template-dialog .template-preview-stage{height:clamp(115px,22svh,180px)}
  #template-dialog h2{font-size:22px;margin:0 44px 12px 0}
  #template-dialog .eyebrow{font-size:10px;margin-bottom:8px}
  #template-dialog .preview-caption{font-size:11px;margin:7px 0 12px}
  #template-dialog label{font-size:13px;margin:10px 0 7px}
  #template-dialog #template-text{scroll-margin:12px 0}
  #template-dialog .helper{font-size:12px;line-height:1.4;margin:6px 0}
  #template-dialog .dialog-close{top:8px;right:8px;z-index:2}
  body.mobile-keyboard-open dialog:not(.studio-tour){top:calc(var(--mobile-viewport-top,0px) + 8px);bottom:auto;margin-top:0;margin-bottom:0;max-height:calc(var(--mobile-vh,100dvh) - 16px)}
  body.mobile-keyboard-open.mobile-review #review{padding-bottom:calc(var(--mobile-keyboard-offset,0px) + 24px + env(safe-area-inset-bottom))}
}
@media(max-height:500px) and (pointer:coarse){
  body .topbar{display:none}
  #template-dialog .template-preview-stage{height:110px}
}
