.mobile-workspace-nav { display: none; }
.palette-quick {
  position: relative; display: none; place-items: center; min-height: 44px;
  padding-inline: 6px; border: 1px solid var(--line); border-radius: 4px;
  font-size: 12px; font-weight: 600; background: #fffdf8;
}
.palette-quick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.palette-quick:focus-within { outline: 2px solid var(--rust); outline-offset: 1px; }
@media (max-width: 680px), (pointer: coarse) and (max-height: 540px) {
  .palette-quick { display: grid; }
}
@media (max-width: 960px) and (max-height: 540px) and (orientation: landscape) {
  .stage:is(:fullscreen,.expanded) .palette-quick { display: grid; }
}

/* Phone controls keep their own touch targets around the unobstructed drag area. */
@media (max-width: 680px), (pointer: coarse) and (max-height: 540px) and (orientation: landscape) {
  main, .mast {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .intro { padding: 12px 0 10px; }
  .intro h1 { font-size: clamp(38px, 10.5vw, 52px); margin-top: 4px; }
  .spec { margin-top: 5px; }
  .mobile-workspace-nav {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 4;
    gap: 3px;
    align-self: stretch;
    width: fit-content;
    grid-column: 1 / -1;
    padding: max(2px, env(safe-area-inset-top)) 3px 2px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--paper);
  }
  .mobile-workspace-nav a {
    display: grid;
    place-items: center;
    min-height: 44px;
    padding-inline: 12px;
    font-size: 13px;
  }
  #model-column, #design-desk { scroll-margin-top: calc(54px + env(safe-area-inset-top)); }
  .stage-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }
  .tour-select { max-width: 100%; padding: 0 3px; }
  .tour-select select { min-height: 44px; width: 100%; font-size: 16px; }
  .tour-select span { display: none; }
  .model-label { justify-self: start; }
  .mode button, .zoom button, #expand {
    min-width: 44px;
    min-height: 44px;
    padding: 3px 5px;
  }
  #render-options summary {
    display: flex;
    min-height: 44px;
    gap: 3px;
    align-items: center;
    justify-content: center;
  }
  .stage-bottom:has(#render-options[open]) { top: 8px; z-index: 2; }
  #render-options[open] { position: static; }
  .render-panel {
    top: 0;
    bottom: auto;
    width: min(270px, 100%);
    max-width: 100%;
    max-height: calc(100% - 112px);
    overflow: auto;
    overscroll-behavior: contain;
    padding: 10px 12px;
  }
  .render-panel label { display: inline-flex; min-height: 44px; padding-right: 10px; }
  #capture-4k { min-height: 44px; }
  .stage:is(:fullscreen, .expanded) { overscroll-behavior: contain; }
  body:has(.stage.expanded) { overflow: hidden; }
  .tabs button, .history button, .dialog-head button,
  .library-heading button, .light-presets button {
    min-width: 44px;
    min-height: 44px;
  }
  .tabs button { flex: 1; }
  .field :is(select, input, textarea) { min-height: 44px; font-size: 16px; }
  .field select, .tour-select select {
    -webkit-appearance: none;
    appearance: none;
    height: 44px;
    padding-left: 8px;
    padding-right: 26px;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 13px) 52%, calc(100% - 9px) 52%;
    background-size: 4px 4px;
    background-repeat: no-repeat;
  }
  .field { font-size: 13px; }
  .part summary, .material { align-items: center; min-height: 44px; }
  .part button, .primary, #samples button, .card-foot button, .source-shortcut,
  .menu button, #project-menu summary { min-height: 44px; }
  #project-menu summary { display: flex; align-items: center; padding: 6px 8px; }
  #project-menu .menu { top: calc(100% + 3px); }
  .caption { align-items: center; padding: 2px 0; }
  .render-panel small { min-height: 16px; }
}
@media (max-width: 389px) {
  .stage-top, .stage-bottom { left: 6px; right: 6px; }
  .zoom { display: grid; grid-template-columns: repeat(2, minmax(44px, auto)); }
  #expand { border-left: 0; }
  .render-panel { max-height: calc(100% - 153px); }
}
@media (pointer: coarse) and (orientation: landscape) and (min-width: 640px) and (max-height: 540px) {
  .mast { min-height: 44px; }
  .intro { display: flex; align-items: center; padding: 7px 0 8px; }
  .intro h1 { font-size: 33px; margin: 0; }
  .intro .eyebrow, .mobile-workspace-nav { display: none; }
  .intro .spec { padding: 0; margin: 0; }
  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(212px, 32%);
    gap: 8px;
  }
  .workspace .stage { height: max(240px, calc(100svh - 103px)); }
  .workspace .stage:is(:fullscreen, .expanded) { height: 100dvh; }
  .desk-body { max-height: max(170px, calc(100svh - 159px)); }
  #model-column, #design-desk { scroll-margin-top: 8px; }
}
#walk-pad, #walk-pad button { touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
#destinations button { touch-action: manipulation; }
@media (max-width: 680px), (pointer: coarse) {
  #walk-pad .forward { font-size: 12px; }
  .render-panel p, .render-panel small { font-size: 12px; color: #4f5146; }
  .tabs { gap: 2px; padding-inline: 6px; }
  .tabs button { min-width: 0; padding-inline: 3px; }
  #fitting-dialog { padding: 12px; max-height: 92dvh; }
}

@media (max-width: 680px), (pointer: coarse) and (max-height: 540px) {
  .workspace .stage { height: auto; }
  .stage .scene-image { height:clamp(330px,56svh,560px); }
  .stage .stage-top, .stage .stage-bottom, .stage .stage-bottom:has(#render-options[open]) { position: relative; inset: auto; padding: 2px 5px; gap: 4px; }
  .stage .stage-top .tour-select { flex: 1; }
  .stage #render-options[open] { position: relative; }
  .stage #render-options .render-panel { top: auto; bottom: calc(100% + 4px); max-height: min(52dvh,350px); width: min(240px,78vw); max-width: 78vw; }
  .stage #expand, .stage #render-options summary, #walk-tools-toggle { min-height:44px; min-width:44px; }
  .stage:is(:fullscreen,.expanded) { height:100dvh; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .stage:is(:fullscreen,.expanded) .scene-image { height:0; }
  #walk-tools-panel .zoom { display: flex; }
  #walk-tools-panel .zoom button { min-width: 44px; }
  #arrows-choice { min-height: 44px; }
}
@media (pointer:coarse) and (orientation:landscape) and (max-height:540px) {
  .stage .scene-image { height:max(184px,calc(100svh - 166px)); }
}

/* Show both sides of the entrance on an upright phone. Expand retains the
   taller walk surface. Plan and Orbit retain room for editing and placement. */
@media (max-width:680px) and (orientation:portrait) {
  .stage:not(:is(:fullscreen,.expanded)):has([data-mode="walk"][aria-pressed="true"]) .scene-image {
    height: auto;
    aspect-ratio: 3 / 2;
  }
}

#walk-zoom-reset { min-width: 40px; min-height: 36px; padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; background: #fffdf8; color: var(--ink); font-size: 13px; font-weight: 650; }
#walk-picked { position: absolute; z-index: 3; bottom: 8px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; max-width: calc(100% - 24px); padding: 2px 3px 2px 10px; border-radius: 5px; background: #fffdf5; color: var(--ink); box-shadow: 0 1px 7px #0002; font-size: 13px; }
#walk-picked-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#walk-edit-picked { min-height: 36px; min-width: 44px; border-radius: 3px; color: #fff; background: #384233; }
#tour-control #walk-location { display: inline; }
@media (max-width: 680px) {
  #tour-control { flex-wrap: wrap; }
  #tour-control #walk-location { display: block; flex-basis: 100%; padding: 1px 3px 0; line-height: 1.1; color: var(--muted); font-size: 10px; }
  #tour-control select { flex: 1; min-width: 0; }
}
@media (pointer: coarse) {
  #walk-edit-picked, #walk-zoom-reset { min-height: 44px; min-width: 44px; }
}

@media (max-width:340px) {
  .stage-bottom:has(#walk-zoom-reset:not([hidden])) .quality-prefix { display: none; }
}
