.frame-mobile-only { display: none; }

@media (max-width: 760px), (pointer: coarse) and (max-width: 1024px) {
  html[data-mobile-studio="frame"] body.zaoba-editor {
    height: var(--editor-height, 100dvh);
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
    background: #fbf6ea;
  }
  html[data-mobile-studio="frame"] .ms-header { order: -10; }
  html[data-mobile-studio="frame"] .ms-dock { order: 10; }
  html[data-mobile-studio="frame"] :is(.zaoba-header, .zaoba-intro, .work-menu, .workbench-toolbar, .workbench-bottom, .editor-bottom-note, .gift-commerce-status) {
    display: none !important;
  }
  html[data-mobile-studio="frame"] :is(.zaoba-main, .frame-workbench, .editor-layout, .editor-layout.library-open, .canvas-area) {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
  }
  html[data-mobile-studio="frame"] body.zaoba-editor .zaoba-main { order: 0; padding: 4px 14px 12px; }
  html[data-mobile-studio="frame"] .frame-workbench { background: transparent; }
  html[data-mobile-studio="frame"] body.zaoba-editor .canvas-area {
    border: 1px solid #e8e2d8;
    border-radius: 24px;
    background: #f1ece1;
  }
  html[data-mobile-studio="frame"] .zaoba-editor .canvas-surface,
  html[data-mobile-studio="frame"] .zaoba-editor #canvasArea.expanded .canvas-surface,
  html[data-mobile-studio="frame"] .zaoba-editor .editor-layout.library-open .canvas-surface {
    flex: 1 1 0;
    min-height: 0 !important;
    height: auto !important;
    max-height: none;
    padding: 48px 14px 70px !important;
    background-color: #f1ece1;
    background-image: radial-gradient(#71849b18 .65px, transparent .65px);
    background-size: 20px 20px;
  }
  html[data-mobile-studio="frame"] .canvas-meta {
    top: 8px;
    left: 16px;
    right: 100px;
    height: 32px;
    font-size: 11px;
  }
  html[data-mobile-studio="frame"] .canvas-view-tools { top: 2px; right: 8px; }
  html[data-mobile-studio="frame"] .canvas-view-tools button {
    min-width: 44px;
    min-height: 44px;
    font-size: 11px;
    color: #7a8796;
    background: transparent;
    box-shadow: none;
  }
  html[data-mobile-studio="frame"] #touchHint {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    font-size: 10px;
    line-height: 20px;
    z-index: 1;
  }
  html[data-mobile-studio="frame"] .zaoba-editor .canvas-help {
    top: 44px;
    left: 14px;
    right: 14px;
    z-index: 15;
    background: #fff9e8ed;
  }
  html[data-mobile-studio="frame"] #limitLegend { display: none !important; }
  html[data-mobile-studio="frame"] .zaoba-editor #canvasQuickbar,
  html[data-mobile-studio="frame"] .zaoba-editor .editor-layout.library-open #canvasQuickbar {
    bottom: 29px;
    gap: 3px;
    max-width: calc(100% - 24px);
    padding: 4px;
    border: 1px solid #173f731e;
    border-radius: 16px;
    background: #fffdf7;
    box-shadow: 0 4px 16px #173f7310;
  }
  html[data-mobile-studio="frame"] #canvasQuickbar > #flipControls { display: none; }
  html[data-mobile-studio="frame"] .frame-mobile-only:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; }
  html[data-mobile-studio="frame"] .zaoba-editor #canvasQuickbar button {
    min-width: 44px;
    min-height: 44px;
    height: 44px;
    padding: 4px 10px;
    font-size: 12px;
  }
  html[data-mobile-studio="frame"] .zaoba-editor #textFontControl select {
    min-height: 44px;
    max-width: min(155px, 39vw);
    font-size: 16px;
  }
  html[data-mobile-studio="frame"] :is(input, select, textarea) { font-size: 16px; }
  html[data-mobile-studio="frame"] #inlineTextInput { min-height: 44px; }
  html[data-mobile-studio="frame"] #inlineTextEditor { border-radius: 10px; }
  /* Phone keyboards shrink visualViewport, often without changing CSS media
     queries. While typing, the on-canvas Done button is the useful action. */
  html[data-mobile-studio="frame"] body:has(#inlineTextEditor:not([hidden])) .ms-dock { display: none; }
  html[data-mobile-studio="frame"] body:has(#inlineTextEditor:not([hidden])) .canvas-surface,
  html[data-mobile-studio="frame"] body:has(#inlineTextEditor:not([hidden])) #canvasArea.expanded .canvas-surface {
    padding: 36px 12px 62px !important;
  }
  html[data-mobile-studio="frame"] body:has(#inlineTextEditor:not([hidden])) #touchHint { display: none; }
  html[data-mobile-studio="frame"] body:has(#inlineTextEditor:not([hidden])) #canvasQuickbar { bottom: 5px; }
  html[data-mobile-studio="frame"] .zaoba-editor .toast { bottom: calc(140px + env(safe-area-inset-bottom)); }

  html[data-mobile-studio="frame"] .ms-sheet .design-start-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 2px 0 16px;
    background: none;
  }
  html[data-mobile-studio="frame"] .ms-sheet .design-start-controls label { display: grid; gap: 8px; }
  html[data-mobile-studio="frame"] .ms-sheet .design-start-controls label > span:not(.tool-art-icon) {
    display: block !important;
    color: #62758d;
    font-size: 13px;
  }
  html[data-mobile-studio="frame"] .ms-sheet .design-start-controls select {
    width: 100%;
    max-width: none;
    height: 48px;
    min-height: 48px;
    padding: 10px 32px 10px 13px;
    border: 1px solid #e5e3df;
    border-radius: 12px;
    background: #fffdf7;
    font-size: 16px;
  }
  html[data-mobile-studio="frame"] .ms-sheet #templateSeriesLink {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    margin: 0 !important;
    padding: 10px !important;
    border-radius: 12px;
    background: #edf1f7;
    color: #4d6b90 !important;
    font-size: 14px;
    text-decoration: none;
  }
  html[data-mobile-studio="frame"] .ms-sheet .icon-library {
    position: static;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  html[data-mobile-studio="frame"] .ms-sheet :is(.library-heading, #collapseIconLibrary, #libraryHint, .popover-heading) { display: none; }
  html[data-mobile-studio="frame"] .ms-sheet .image-motif-library-entry {
    flex: none;
    margin: 0;
    min-height: 44px;
    padding: 8px 2px;
    border: 0;
    border-bottom: 1px solid #173f7310;
    border-radius: 0;
    background: transparent;
    color: #62758d;
    font-size: 12px;
    box-shadow: none;
    text-align: left;
  }
  html[data-mobile-studio="frame"] .ms-sheet .image-motif-library-entry strong { font-weight: 400; }
  html[data-mobile-studio="frame"] .ms-sheet .image-motif-library-entry span { display: none; }
  html[data-mobile-studio="frame"] .ms-sheet .library-search { margin: 4px 0 10px; }
  html[data-mobile-studio="frame"] .ms-sheet .library-search input {
    min-height: 48px;
    border-radius: 12px;
    font-size: 16px;
  }
  html[data-mobile-studio="frame"] .ms-sheet .icon-categories {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    max-height: none;
    margin: 0 0 10px;
    padding: 0 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  html[data-mobile-studio="frame"] .ms-sheet .icon-categories button {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 12px;
    border-radius: 12px;
    white-space: nowrap;
    font-size: 13px;
    background: #f5f2ec;
    color: #7d8795;
    border: 0;
  }
  html[data-mobile-studio="frame"] .ms-sheet .icon-categories button[aria-pressed="true"] { background: #e9edf5; color: #3e5f83; }
  html[data-mobile-studio="frame"] .ms-sheet .icon-grid {
    display: grid;
    flex: none;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
    margin-top: 12px;
    padding-bottom: 8px;
  }
  html[data-mobile-studio="frame"] .ms-sheet .icon-tile { min-height: 88px; border: 1px solid #e9e6df; border-radius: 14px; background: #fcfaf5; }
  html[data-mobile-studio="frame"] .ms-sheet .icon-tile > :is(img, svg) { width: 47px; height: 47px; }
  html[data-mobile-studio="frame"] .ms-sheet .icon-tile > span { font-size: 11px; }
  html[data-mobile-studio="frame"] .ms-sheet #colorPopover {
    position: static;
    width: 100%;
    max-width: none;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  html[data-mobile-studio="frame"] .ms-sheet #colorChoices { gap: 10px; }
  html[data-mobile-studio="frame"] .ms-sheet .palette-choice {
    min-height: 56px;
    padding: 10px;
    gap: 10px;
    border: 1px solid #e5e3dd;
    border-radius: 12px;
    font-size: 13px;
  }
  html[data-mobile-studio="frame"] .ms-sheet .palette-choice.selected { background: #edf2f8; border-color: #8096b1; }
  html[data-mobile-studio="frame"] .ms-sheet #flipControls { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 10px; }
  html[data-mobile-studio="frame"] .ms-sheet #flipControls button {
    min-height: 48px;
    padding: 10px;
    border: 1px solid #e5e3df;
    border-radius: 12px;
    background: #faf8f2;
    font-size: 14px;
  }
  html[data-mobile-studio="frame"] .ms-sheet #flipControls button[aria-pressed="true"] { border-color: #8096b1; background: #edf2f8; }
  html[data-mobile-studio="frame"] .frame-text-panel { display: grid; gap: 14px; }
  html[data-mobile-studio="frame"] .frame-text-add {
    min-height: 48px;
    padding: 11px 14px;
    border: 1px dashed #a0afc3;
    border-radius: 14px;
    background: #f3f6fa;
    color: #547292;
    font-size: 13px;
  }
  html[data-mobile-studio="frame"] .frame-text-list { display: grid; gap: 9px; }
  html[data-mobile-studio="frame"] .frame-text-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 48px;
    padding: 11px 14px;
    border: 1px solid #e6e5df;
    border-radius: 13px;
    background: #fcfaf5;
    color: #465f7e;
    font-size: 14px;
    text-align: left;
  }
  html[data-mobile-studio="frame"] .frame-text-item > span { min-width: 0; overflow-wrap: anywhere; }
  html[data-mobile-studio="frame"] .frame-text-item > small { flex: none; color: #8d95a2; font-size: 11px; }
  html[data-mobile-studio="frame"] #giftAddToCart { display: none !important; }

  html[data-mobile-studio="frame"] #hostedFinishDialog {
    width: calc(100vw - 20px);
    max-height: calc(var(--editor-height, 100dvh) - 20px);
    padding: 16px;
    border: 1px solid #e5e3df;
    border-radius: 24px;
    background: #fffdf7;
    color: #173f73;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog .dialog-top { align-items: center; gap: 8px; }
  html[data-mobile-studio="frame"] #hostedFinishDialog .dialog-top > div { flex: 1; min-width: 0; }
  html[data-mobile-studio="frame"] #hostedFinishDialog .eyebrow { display: none; }
  html[data-mobile-studio="frame"] #hostedFinishTitle {
    margin: 0;
    font: 600 18px/1.45 -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
    word-break: keep-all;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog .hosted-back {
    flex: none;
    min-height: 44px;
    padding: 9px !important;
    border: 0;
    background: #f2f3f5;
    font-size: 12px !important;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog :is(.hosted-finish-intro, .hosted-preview-meta, .hosted-model-note, .hosted-status) {
    color: #748197;
    font-size: 12px;
    line-height: 1.65;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog .hosted-preview-stage {
    height: clamp(260px, 42dvh, 340px);
    padding: 16px 10px;
    border-radius: 18px;
    background: #f1ece1;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog .frame-mesh-viewer {
    border-color: #e5e3df !important;
    border-radius: 18px !important;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog .frame-mesh-viewer > div:first-child { padding: 8px 10px 0 !important; }
  html[data-mobile-studio="frame"] #hostedFinishDialog .frame-mesh-viewer [role="tablist"] { flex-wrap: nowrap !important; overflow-x: auto; width: 100%; }
  html[data-mobile-studio="frame"] #hostedFinishDialog .frame-mesh-viewer [role="tab"] {
    flex: none;
    min-height: 44px !important;
    padding: 8px 10px !important;
    color: #506681 !important;
    border-color: #e5e3df !important;
    background: #fffdf7 !important;
    font-size: 11px !important;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog .frame-mesh-viewer [role="tab"][aria-selected="true"] { background: #edf2f8 !important; border-color: #8096b1 !important; }
  html[data-mobile-studio="frame"] #hostedFinishDialog .frame-mesh-viewer canvas { height: clamp(280px, 42dvh, 340px) !important; }
  html[data-mobile-studio="frame"] #hostedFinishDialog .frame-mesh-viewer button { min-height: 44px !important; }
  html[data-mobile-studio="frame"] #hostedFinishDialog .hosted-finish-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    bottom: -16px;
    padding: 12px 0;
    border-top-color: #e5e3df;
    background: #fffdf7;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog .hosted-finish-actions button {
    min-width: 0;
    width: 100%;
    min-height: 46px;
    padding: 10px 8px;
    border-radius: 13px;
    font-size: 13px;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog #hostedGenerateModel { grid-column: 1 / -1; }
  html[data-mobile-studio="frame"] #hostedFinishDialog:has(#giftFinishAddToCart) #hostedDownloadModel {
    border: 1px solid #dbe2eb;
    background: #edf1f7;
    color: #4d6b90;
  }
  html[data-mobile-studio="frame"] #hostedFinishDialog #giftFinishAddToCart {
    grid-column: 1 / -1;
    min-height: 50px;
    border: 0;
    background: #173f73;
    color: #fffdf7;
    font-size: 15px;
  }
}

@media (max-width: 360px) {
  html[data-mobile-studio="frame"] .ms-sheet .icon-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) and (max-height: 540px), (pointer: coarse) and (max-width: 1024px) and (max-height: 540px) {
  html[data-mobile-studio="frame"] .zaoba-editor .canvas-surface,
  html[data-mobile-studio="frame"] .zaoba-editor .editor-layout.library-open .canvas-surface { padding: 36px 12px 54px !important; }
  html[data-mobile-studio="frame"] #touchHint { display: none; }
  html[data-mobile-studio="frame"] .zaoba-editor #canvasQuickbar { bottom: 5px; }
}
