@media screen {
  .stage-progress.two-stage-flow ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  :is(#frame-editor, #black-frame-editor) {
    --workbench-height: clamp(28rem, calc(100dvh - 11rem), 47rem);
  }

  :is(#frame-editor, #black-frame-editor).is-expanded {
    --workbench-height: max(24rem, calc(100dvh - 9rem));
  }

  :is(#frame-editor, #black-frame-editor) .frame-workspace {
    grid-template-columns: minmax(0, 1fr) clamp(19rem, 31vw, 25rem);
    gap: clamp(.75rem, 1.5vw, 1.125rem);
  }

  :is(#frame-editor, #black-frame-editor) .frame-workspace:has(> .frame-settings[hidden]) {
    grid-template-columns: minmax(0, 1fr);
  }

  :is(#frame-editor, #black-frame-editor) :is(.frame-settings-scroll, #frame-plan-view, #black-frame-plan-view) {
    overscroll-behavior: auto;
    scrollbar-color: #7898b4 var(--soft);
  }

  :is(#frame-editor, #black-frame-editor) .frame-settings-scroll {
    padding: .875rem .875rem 1rem;
  }

  :is(#frame-editor, #black-frame-editor) :is(.frame-heading-actions button, .frame-plan-levels button, .frame-stair-button) {
    min-block-size: 2.75rem;
    font-size: .8125rem;
  }

  :is(#frame-editor, #black-frame-editor) .frame-plan-levels button {
    min-inline-size: 2.75rem;
  }

  :is(#frame-editor, #black-frame-editor) :is(.frame-help, .workspace-intro, .plan-edit-help, .plan-edit-message) {
    font-size: .8125rem;
  }

  :is(#frame-editor, #black-frame-editor) .plan-tools :is(button, select),
  #frame-editor .plan-balcony-controls button {
    min-block-size: 2.75rem;
    font-size: .8125rem;
  }

  :is(#calculator, #black-controls) .workbench-tabs button {
    min-block-size: 2.75rem;
    font-size: .8125rem;
  }

  :is(#calculator, #black-controls) .workbench-settings-header .calculator-heading h2 {
    font-size: 1rem;
  }

  :is(#calculator, #black-controls) .workbench-actions {
    padding: .75rem .875rem;
  }

  :is(#calculator, #black-controls) .workbench-actions :is(.structure-actions, .black-estimate-actions) button {
    padding: .5rem .625rem;
    min-block-size: 2.75rem;
    font-size: .8125rem;
  }

  :is(#calculator, #black-controls) .workbench-actions button:has(> span:only-child) {
    justify-content: center;
    text-align: center;
  }

  #workbench-actions .calculate-button > span:only-child { font: inherit; }

  #black-controls .workbench-actions .black-estimate-actions {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.25rem), 1fr));
  }

  :is(#frame-editor, #black-frame-editor) .frame-plan-toolbar {
    gap: .5rem .75rem;
    margin-block-end: .625rem;
  }

  :is(#frame-editor, #black-frame-editor) .frame-plan-levels {
    gap: .375rem;
  }

  :is(#frame-editor, #black-frame-editor) :is(.frame-stage, .frame-plan-stage):focus-visible {
    outline-offset: -3px;
  }

  .black-back-button { min-block-size: 2.75rem; }
  .black-stage-description { font-size: .875rem; }
}

@media screen and (max-width: 830px) {
  :is(#frame-editor, #black-frame-editor) .frame-workspace,
  :is(#frame-editor, #black-frame-editor) .frame-workspace:has(:is(#frame-plan-view, #black-frame-plan-view):not([hidden])) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    block-size: auto;
  }

  :is(#frame-editor, #black-frame-editor) :is(.frame-settings, .frame-main, .frame-settings .calculator-card) {
    grid-template-rows: auto;
  }

  :is(#frame-editor, #black-frame-editor) .frame-settings-scroll {
    overflow: visible;
    scrollbar-gutter: auto;
  }

  :is(#frame-editor, #black-frame-editor) .frame-stage {
    flex: none;
    block-size: clamp(14rem, 49vw, 25rem);
  }

  :is(#frame-editor, #black-frame-editor) .frame-help-row {
    justify-content: space-between;
    margin-block-start: .625rem;
  }

  :is(#frame-editor, #black-frame-editor) :is(#frame-help, #black-frame-help) {
    position: static;
    inline-size: auto;
    block-size: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
  }
}

@media screen and (max-width: 540px) {
  .stage-progress.two-stage-flow :is(a, button) {
    flex-direction: row;
    gap: .375rem;
    min-block-size: 2.875rem;
    padding: .375rem .5rem;
    font-size: .8125rem;
  }

  .stage-progress.two-stage-flow [data-complete]::after {
    position: static;
    margin: 0;
  }

  :is(#frame-editor, #black-frame-editor) .frame-heading-actions {
    gap: .375rem;
  }

  :is(#frame-editor, #black-frame-editor) .frame-view-switch {
    padding: 2px;
  }

  :is(#frame-editor, #black-frame-editor) .frame-stage {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto minmax(0, 1fr);
    gap: .375rem .25rem;
    padding: .375rem .375rem 0;
  }

  :is(#frame-editor, #black-frame-editor) .frame-stage > svg {
    grid-area: 2 / 1 / 3 / -1;
  }

  :is(#frame-editor, #black-frame-editor) :is(.frame-camera-buttons, .frame-view-buttons) {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 2.5rem));
    gap: .25rem;
  }

  :is(#frame-editor, #black-frame-editor) .frame-view-buttons {
    justify-content: end;
  }

  :is(#frame-editor, #black-frame-editor) :is(.frame-camera-buttons, .frame-view-buttons) button {
    inline-size: 100%;
    min-inline-size: 0;
    block-size: 2.5rem;
  }

  :is(#frame-editor, #black-frame-editor) .frame-camera-buttons [data-frame-camera] { font-size: 0; }
  :is(#frame-editor, #black-frame-editor) .frame-camera-buttons .tool-icon { inline-size: 1rem; block-size: 1rem; }

  #workbench-actions .structure-actions {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.25rem), 1fr));
  }
}

@media screen and (max-width: 400px) {
  #black-controls #black-workbench-tabs button { font-size: .75rem; }
}
