/* Spectra Free Editor iOS Focus + Touch Keyboard Guard
   Keeps phone text at the iOS-safe size and applies the temporary touch-device
   typing surface. Base viewport geometry remains owned by shell-position.css. */

@media (max-width:54rem){
  body.sp-app-shell.sv-freeEditor{
    --sv-editor-font-size:max(var(--sv-ios-focus-font-size),var(--sv-editor-font-size,var(--sv-ios-focus-font-size)));
    --sv-code-editor-font-size:max(var(--sv-ios-focus-font-size),var(--sv-code-editor-font-size,var(--sv-ios-focus-font-size)));
    --sv-ios-editor-line-height:var(--sv-code-editor-line-height,1.5);
  }

  /* The textarea, syntax overlay, and gutter must use identical typography.
     A different textarea line-height makes caret drift accumulate per line. */
  body.sv-freeEditor .sv-editorArea,
  body.sv-freeEditor .sv-editorSyntaxHighlight,
  body.sv-freeEditor .sv-editorLineNumbers{
    font-size:var(--sv-ios-focus-font-size) !important;
    line-height:var(--sv-ios-editor-line-height) !important;
    font-variant-ligatures:none;
    font-feature-settings:"liga" 0,"calt" 0;
  }

  body.sv-freeEditor .sv-languageSelect,
  body.sv-freeEditor .sv-languagePickerButton{
    font-size:var(--sv-ios-focus-font-size) !important;
  }

  body.sv-freeEditor .sv-editorArea{
    -webkit-text-size-adjust:100%;
    text-size-adjust:100%;
  }
}

@media (max-width:90rem) and (pointer:coarse){
  html.is-touch-keyboard-locked{
    block-size:100%;
    overflow:hidden;
  }

  body.sp-app-shell.sv-freeEditor.is-touch-keyboard-locked{
    position:absolute;
    inset-block-start:var(--sv-editor-visual-top,0px);
    inset-inline-start:var(--sv-editor-visual-left,0px);
    inset-block-end:auto;
    inset-inline-end:auto;
    inline-size:var(--sv-editor-visual-width,var(--sv-shell-app-w));
    block-size:var(--sv-editor-visual-height,var(--sv-shell-app-h));
    min-block-size:0;
    overflow:hidden;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorHeader,
  body.sv-freeEditor.is-keyboard-focus .sv-editorPanelHeader,
  body.sv-freeEditor.is-keyboard-focus .sv-editorFooter{
    display:none;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorMain{
    position:absolute;
    inset:0;
    padding:0;
    overflow:hidden;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorWorkspace{
    inline-size:100%;
    max-inline-size:none;
    block-size:100%;
    min-block-size:0;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorPanel{
    position:absolute;
    inset:0;
    block-size:auto;
    min-block-size:0;
    grid-template-rows:minmax(0,1fr);
    border:0;
    border-radius:0;
    box-shadow:none;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorPanelBody,
  body.sv-freeEditor.is-keyboard-focus .sv-editorCodeShell{
    block-size:100%;
    min-block-size:0;
    max-block-size:100%;
    overflow:hidden;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorArea,
  body.sv-freeEditor.is-keyboard-focus .sv-editorSyntaxHighlight{
    white-space:pre-wrap !important;
    overflow-wrap:anywhere !important;
    word-break:normal;
    overflow-x:hidden;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorArea{
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
    touch-action:pan-y;
    scroll-padding-block:var(--sv-keyboard-scroll-padding);
  }
}

/* Phone suggestions become a compact tray only while the touch keyboard
   editor surface is active. Desktop and tablet popover geometry is unchanged. */
@media (max-width:54rem) and (pointer:coarse){
  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray{
    --sv-suggest-mobile-pad-y:.125rem;
    inset-inline:var(--sp-2) !important;
    inset-block-start:auto !important;
    inset-block-end:var(--sp-2) !important;
    inline-size:auto;
    max-block-size:min(11.75rem,calc(100% - var(--sp-4)));
    border-radius:var(--sp-radius-2);
    backdrop-filter:blur(12px);
    overscroll-behavior:contain;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__header{
    min-block-size:2.25rem;
    gap:var(--sp-2);
    padding:var(--sv-suggest-mobile-pad-y) var(--sp-2);
    font-size:var(--sp-fs-1,.875rem);
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__hint{
    flex:0 0 auto;
    font-size:var(--sp-fs-1,.875rem);
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__list{
    padding:var(--sv-suggest-mobile-pad-y) var(--sp-1) var(--sp-1);
    overscroll-behavior:contain;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__option{
    min-block-size:var(--sp-8,2rem);
    grid-template-columns:minmax(5.25rem,.85fr) minmax(0,1.15fr);
    gap:var(--sp-2);
    padding:var(--sv-suggest-mobile-pad-y) var(--sp-2);
    touch-action:manipulation;
    -webkit-tap-highlight-color:transparent;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__option:hover:not([aria-selected="true"]),
  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__option:active:not([aria-selected="true"]){
    background:transparent;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__option[aria-selected="true"]{
    background:var(--sv-suggest-option-active);
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__option[hidden]{
    display:none;
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__label,
  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__preview{
    font-size:var(--sp-fs-1,.875rem);
  }

  body.sv-freeEditor.is-keyboard-focus .sv-editorSuggest.is-keyboard-tray .sv-editorSuggest__kind{
    display:none;
  }
}
