@media (max-width: 73.75rem) {
  body {
    padding: 0.75rem;
  }

  .app-shell,
  .app-shell[data-margin-state="closed"] {
    grid-template-columns: minmax(0, 1fr);
    min-height: calc(100dvh - 1.5rem);
    border-radius: 1.25rem;
  }

  .toolbar-button {
    width: auto;
  }

  .margin-panel {
    position: fixed;
    inset: 0.75rem 0.75rem 0.75rem auto;
    width: min(var(--margin-width), calc(100% - 1.5rem));
    height: calc(100% - 1.5rem);
    max-height: calc(100% - 1.5rem);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: var(--shadow-panel);
  }
}

@media (max-width: 56.25rem) {
  .toolbar-button {
    width: 2.75rem;
    padding: 0.5rem;
  }

  .toolbar-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (max-width: 47.5rem) {
  body {
    padding: 0;
    background: var(--paper);
  }

  .app-shell,
  .app-shell[data-margin-state="closed"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    min-height: auto;
    padding: 0.875rem 1rem;
  }

  .mode-button {
    min-height: 2.75rem;
    padding-inline: 1.25rem;
  }

  .paper-wrap {
    padding: 0.75rem;
  }

  .paper {
    min-height: 32rem;
    padding: clamp(1.5rem, 7vw, 2.25rem) clamp(1.125rem, 6vw, 2rem);
    border-radius: 1rem;
  }

  .editor-stage {
    min-height: 20rem;
  }

  .editor,
  .ambient-example-text {
    font-size: clamp(1.1875rem, 5.5vw, 1.375rem);
  }

  .margin-panel {
    inset: 0 0 0 auto;
    width: min(100%, 23rem);
    min-height: 0;
    height: 100%;
    max-height: 100%;
    border-block: 0;
    border-right: 0;
    border-radius: 0;
  }

}

@media (max-width: 37.5rem) and (orientation: portrait) {
  .orientation-note {
    display: block;
  }
}

@media (max-width: 35rem) {
  .dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .dialog-actions button {
    width: 100%;
  }
}

@media (max-width: 25rem) {
  .toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-context {
    text-align: center;
  }

  .workspace-controls {
    justify-content: center;
  }

  .workspace-context h1 {
    font-size: 1.0625rem;
  }

}

@media (max-height: 31.25rem) and (orientation: landscape) {
  .toolbar {
    min-height: 4.5rem;
    padding-block: 0.625rem;
  }

  .paper-wrap {
    padding-block: 0.75rem;
  }

  .paper {
    min-height: 22rem;
    padding-block: 1.5rem;
  }

  .editor-stage {
    min-height: 14rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
