/* Active route tools: action first, optional detail second. */
@media screen {
  /* A large sheet must not grow its grid tracks or push route controls below
     the browser. Focus and Tab should scroll a panel, never the whole plan. */
  html[data-workspace="floor"] .studio-shell {
    height: 100dvh;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }
  html[data-workspace="floor"] .studio-shell > .workspace {
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  html[data-workspace="floor"] .studio-shell > .workspace:not(:has(.tablet-design-drawers)) {
    grid-template-rows: minmax(0, 1fr);
  }
  html[data-workspace="floor"] .workspace > .canvas-stage {
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }
  html[data-workspace="floor"] .canvas-scroll {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }
}
@media screen and (max-width: 1180px) and (hover: hover) and (pointer: fine) and (not (any-pointer: coarse)) {
  /* Narrow desktop used to stack inspectors in extra rows below the drawing.
     Keep the left navigation/tools tracks, but open one bounded right overlay.
     Touch tablets retain their existing drawer layout. */
  html[data-workspace="floor"] .studio-shell {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
  html[data-workspace="floor"] .studio-shell > .workspace {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "canvas";
    grid-template-rows: minmax(0, 1fr);
  }
  html[data-workspace="floor"] .studio-shell > .workspace:has(> .left-rail):has(> .tool-palette) {
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-areas: "left canvas" "tools canvas";
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }
  html[data-workspace="floor"] .workspace > :is(.inspector, .product-panel, .pipe-panel, .results-panel) {
    position: absolute;
    z-index: 35;
    grid-area: auto;
    top: 8px;
    right: 8px;
    bottom: 8px;
    width: min(340px, calc(100% - 16px));
    height: auto;
    min-height: 0;
    max-height: calc(100% - 16px);
    box-sizing: border-box;
    overflow: auto;
    background: var(--surface-solid, #fff);
  }
  html[data-workspace="floor"] .workspace > :is(.inspector, .product-panel, .pipe-panel, .results-panel).closed-panel {
    display: none;
  }
}
.pipe-draft-panel:has(#finishPipe, #finishDuct, #finishMultiDuct) {
  max-height: min(520px, calc(100% - 120px), calc(100dvh - 180px));
  scrollbar-width: thin;
}
.pipe-draft-panel:has(#finishPipe, #finishDuct, #finishMultiDuct) > .pipe-draft-actions {
  justify-content: stretch;
  position: sticky;
  top: 28px;
  z-index: 3;
  padding: 6px 0;
  background: var(--surface-solid, #fff);
}
.pipe-draft-panel:has(#finishPipe, #finishDuct, #finishMultiDuct) > .pipe-draft-summary {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 28px;
  background: var(--surface-solid, #fff);
}
.pipe-draft-panel:has(#finishPipe, #finishDuct, #finishMultiDuct) > .pipe-draft-actions button {
  min-height: 36px;
  flex: 1 1 auto;
}
.pipe-draft-placement-options {
  border-top: 1px solid var(--border, #d5e0ed);
  padding-top: 6px;
  font-size: 12px;
}
.pipe-draft-placement-options summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  padding: 4px 0;
}
.pipe-draft-placement-options .pipe-draft-inline-tools { margin-top: 6px; }
.pipe-draft-panel select:disabled { opacity: .75; cursor: default; }
@media (pointer: coarse) {
  .pipe-draft-panel:has(#finishPipe, #finishDuct, #finishMultiDuct) button,
  .pipe-draft-panel:has(#finishPipe, #finishDuct, #finishMultiDuct) select,
  .pipe-draft-panel:has(#finishPipe, #finishDuct, #finishMultiDuct) input,
  .pipe-draft-placement-options summary { min-height: 44px; }
}
