/* Keep the work surface within a comfortable sweep on panoramic displays. */
@media screen {
  body:not([data-phone]) .board-bed {
    width: min(100%, max(1040px, calc(177.7778svh - 2 * var(--studio-gutter))));
    margin-inline: auto;
  }
}

@media screen and (min-width: 1000px) {
  body:not([data-application]):not([data-phone]) #board.instrument {
    padding-inline: clamp(20px, min(2vw, 3.55svh), 74px);
  }

  body:not([data-application]):not([data-phone]) .bench:not([data-tools-tiled]):not([data-tools-collapsed]) {
    --tool-width: clamp(112px, min(9.75vw, 17.35svh), 218px);
    --source-width: clamp(152px, min(14.2vw, 25.25svh), 325px);
    --aisle: clamp(13px, min(1.3vw, 2.32svh), 42px);
  }
}

@media screen and (min-width: 1000px) and (min-aspect-ratio: 3/2) {
  body:not([data-application]):not([data-phone]) #board > .bench {
    padding-block: clamp(8px, 1.2svh, 25px);
  }

  body:not([data-application]):not([data-phone]) .model-zone .view-case:not(:fullscreen,.is-expanded) {
    --view-height: clamp(224px, min(73cqw, calc(100svh - clamp(286px, 31.5svh, 450px))), 1648px);
  }
}

@media screen and (min-width: 1000px) and (max-height: 850px) {
  body:not([data-phone]) .bench > .inputs { gap: clamp(8px, 1.2svh, 14px); }
}

html:lang(zh) .order-paper .paper-title { font-size: 19px; letter-spacing: 0; }

body[data-phone] .inputs .engine-tools .engine-legend { display: block; }

@media screen and (min-aspect-ratio: 2/1) and (min-width: 1000px) {
  body:not([data-phone]) #board .mast { min-height: clamp(50px, 7.7svh, 138px); }
  body:not([data-phone]) #board .wordmark { font-size: clamp(36px, 5.35svh, 92px); }
}

/* The phone and tablet share their actual instruments and scroll navigation. */
@media screen and (min-width: 701px) and (min-height: 600px) {
  body[data-phone] #board.instrument {
    min-height: 100%;
    padding-inline: clamp(20px, 3.4vw, 48px);
  }

  body[data-phone] #board > .bench {
    display: grid;
    grid-template: "inputs inputs" auto "workspace workspace" auto "tools papers" auto "apps apps" auto / minmax(0, 1fr) minmax(0, 1fr);
    align-content: start;
    align-items: start;
    gap: 15px 24px;
    padding-block: 8px 12px;
  }

  body[data-phone] .bench > .inputs { grid-area: inputs; }
  body[data-phone] .bench > .model-zone { grid-area: workspace; }
  body[data-phone] .bench > .tool-drawer { grid-area: tools; }
  body[data-phone] .bench > .model-outputs { grid-area: papers; }
  body[data-phone] .bench > .app-dock { grid-area: apps; }

  body[data-phone] .inputs .engine-tools {
    width: min(100%, 480px);
    padding-block: 8px;
  }

  body[data-phone] .inputs .manual-key strong {
    display: inline;
    margin-top: 3px;
    font: 500 14px/1.2 var(--display);
  }

  body[data-phone] .inputs .engine-legend strong { font-size: 15px; }
  body[data-phone] .model-bar { min-height: 54px; }
  body[data-phone] .model-bar .phone-model-mark { display: none !important; }
  body[data-phone] .model-bar .model-mark {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    font: 500 clamp(18px, 2.5cqw, 28px)/1.1 var(--display);
  }

  body[data-phone] #view-case:not(:fullscreen,.is-expanded) .scene-stage {
    height: clamp(260px, min(60cqw, 47svh), 700px);
  }

  body[data-phone] .pm-read-progress { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

@media screen and (min-width: 950px) and (min-height: 600px) and (orientation: landscape) {
  body[data-phone] #board > .bench {
    grid-template: "inputs workspace" auto "papers workspace" 1fr "tools apps" auto / minmax(190px, 23%) minmax(0, 1fr);
    align-items: start;
  }

  body[data-phone] .inputs .engine-tools {
    grid-template: auto 24px auto / 1fr;
    gap: 8px;
  }

  body[data-phone] .inputs .engine-tools .engine-pod { grid-area: 1 / 1; }
  body[data-phone] .inputs .engine-tools .combine-sign { grid-area: 2 / 1; }
  body[data-phone] .inputs .engine-tools .handbook-pod { grid-area: 3 / 1; }
}

@media screen and (max-width: 700px) {
  .pm-account-nav .pm-project-link, .pm-account-nav .pm-account summary {
    min-width: 40px;
    min-height: 44px;
  }
}

.studio-brand-stack {
  display: grid;
  justify-items: start;
  gap: 3px;
  padding-block: 5px;
}
.pm-install-app {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-block: 4px;
  text-decoration: none;
  color: #dad8d2;
  font: 550 12px/1.25 var(--sans);
}
.studio-brand-stack .pm-install-app {
  justify-self: stretch;
  border-top: 1px solid #aaa9a34a;
}
.pm-install-app svg {width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6;}
.pm-install-app:is(:hover,:focus-visible) {color: #fff1d1; text-decoration: underline;}
.head-actions .surface-key {display: inline-flex; align-items: center; justify-content: center; gap: 5px; width: auto; padding-inline: 8px;}

body[data-phone] #board .mast,
body[data-phone][data-application] .phone-menu-sections,
body[data-phone] #phone-menu[hidden] {display: none;}
body[data-phone] {--phone-dock-space: calc(40px + env(safe-area-inset-bottom));}
body[data-phone] .studio-viewport {padding-block: max(5px, env(safe-area-inset-top)) var(--phone-dock-space);}
body[data-phone] #phone-dock {
  position: fixed;
  inset: auto max(8px, env(safe-area-inset-right)) max(3px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  flex-direction: column;
  width: fit-content;
  max-width: min(530px, calc(100% - 16px));
  max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  margin: 0 auto;
  padding: 0;
}
body[data-phone] #phone-dock:has(#phone-menu:not([hidden])) {width: min(530px, calc(100% - 16px));}
body[data-phone] #phone-dock .phone-menu-handle {
  display: flex; align-items: center; justify-content: center; gap: 7px; flex: none;
  width: 100%; height: 36px; padding-inline: 20px; color: #eeebe5; font: 550 12px var(--sans); touch-action: none;
}
.phone-menu-handle::before {content: ""; width: 20px; height: 3px; border-radius: 3px; background: #b9b8b2;}
body[data-phone] #phone-menu {box-sizing: border-box; width: 100%; padding: 4px 8px 8px; border-top: 1px solid #ffffff20;}
.phone-menu-account, .phone-menu-account .head-actions {display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 3px 6px;}
body[data-phone] #phone-menu .head-actions {margin: 0; padding: 0;}
body[data-phone] #phone-menu .phone-menu-account :is(a,button,summary) {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  width: auto; min-width: 40px; min-height: 44px; padding: 0 6px; border: 0;
  color: #f2f0ea; background: transparent; box-shadow: none; font: 550 12px/1.2 var(--sans);
}
body[data-phone] #phone-menu .pm-account-nav [hidden] {display: none;}
body[data-phone] #phone-menu .phone-menu-account :is(a,button,summary) span {display: inline;}
body[data-phone] #phone-menu .phone-menu-account svg {width: 16px; height: 16px;}
body[data-phone] #phone-menu .pm-account-menu {position: static;}
.phone-menu-sections {display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 3px; border-top: 1px solid #ffffff20; padding-top: 6px;}
body[data-phone] #phone-dock .phone-menu-sections button {
  align-content: center; gap: 3px; width: 100%; min-width: 0; height: auto; min-height: 46px; padding: 4px;
  font: 500 11px/1.15 var(--sans);
}
body[data-phone] #phone-dock :focus-visible {outline: 2px solid #e2cf9b; outline-offset: -2px;}
@media (min-width: 701px) {
  .phone-menu-sections {grid-template-columns: repeat(7,minmax(0,1fr));}
}
