/* arc364 · small screens: the module stays in view when the Workspace opens.
   Loaded after fluent-shell.css and phone.css. */

/* Tablet and phone in landscape (761–1100px): the module keeps the wide column,
   the Workspace takes a narrow one on the right (the old rule gave the module 200px
   and the Workspace the middle). */
@media (min-width: 761px) and (max-width: 1100px) {
  html body main#main { grid-template-columns: minmax(0, 1fr) auto !important; }
  html body main#main.companion-open { grid-template-columns: minmax(0, 1fr) clamp(240px, 32vw, 320px) !important; }
  html body main#main > .workspace { min-width: 0 !important; }
}

/* Phone (≤760px) */
@media (max-width: 760px) {
  /* nothing wider than the screen: the header buttons wrap, the File menu fits */
  html, body { max-width: 100vw; overflow-x: hidden; }
  html body > header .header-zone { flex-wrap: wrap !important; min-width: 0 !important; max-width: 100% !important; gap: 6px !important; }
  html body > header .header-zone > * { flex: 0 0 auto; }
  html body .file-dropdown { max-width: calc(100vw - 16px) !important; }

  /* Workspace: a sheet over the lower part of the screen, above the module rail;
     the module stays visible above it and the rail stays reachable */
  html body main#main.companion-open .companion,
  html body .companion {
    position: fixed !important; inset: auto 0 calc(62px + env(safe-area-inset-bottom, 0px)) 0 !important;
    top: auto !important; height: 46vh !important; max-height: 46vh !important; padding: 0 !important;
    z-index: 45 !important; background: transparent !important;
  }
  html body main#main.companion-open .companion .glass {
    border-radius: 14px 14px 0 0 !important; box-shadow: 0 -8px 24px rgba(15,23,42,.18) !important; background: #fff !important;
  }
  html body main#main.companion-open { z-index: 1 !important; padding-bottom: calc(46vh + 66px + env(safe-area-inset-bottom, 0px)) !important; }
  html body main#main.companion-open .refinery-strip { display: none !important; }
  /* the sheet can grow to most of the screen when its header is tapped (body.ws-tall) */
  html body.ws-tall main#main.companion-open .companion { height: 78vh !important; max-height: 78vh !important; }
  html body.ws-tall main#main.companion-open { padding-bottom: calc(78vh + 66px + env(safe-area-inset-bottom, 0px)) !important; }
  html body main#main.companion-open .companion-head { cursor: pointer; }
}
