/* Keep template actions within the dialog, regardless of list or prompt length. */
.modal.workspace-template-modal {
  box-sizing: border-box;
  flex-direction: column;
  width: min(1120px, calc(100vw - 36px));
  height: min(860px, calc(100vh - 36px));
  height: min(860px, calc(100dvh - 36px));
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overflow: hidden;
}
.modal.workspace-template-modal[open] {
  display: flex;
}
.workspace-template-modal > header {
  flex: 0 0 auto;
  padding-block: 16px;
}
.workspace-template-modal .workspace-template-dialog {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.workspace-template-modal .workspace-template-list,
.workspace-template-modal .workspace-template-editor {
  min-height: 0;
  overflow: hidden;
}
.workspace-template-modal .workspace-template-list-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.workspace-template-modal .workspace-template-editor-head {
  flex: 0 0 auto;
}
.workspace-template-modal .workspace-template-form {
  padding: 0;
  overflow: hidden;
}
.workspace-template-form-scroll {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 20px 24px 16px;
  overflow: auto;
  overscroll-behavior: contain;
}
.workspace-template-form-scroll > .workspace-template-fields,
.workspace-template-form-scroll > .workspace-template-preview {
  flex: 0 0 auto;
}
.workspace-template-form-scroll > .workspace-template-prompt {
  flex: 1 0 240px;
  min-height: 240px;
}
.workspace-template-form-scroll .workspace-template-prompt textarea {
  flex: 1 1 0;
  min-height: 160px;
}
.workspace-template-modal .workspace-template-form > footer {
  flex: 0 0 auto;
  flex-wrap: wrap;
  margin-top: 0;
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.workspace-template-modal .workspace-template-form > footer > span {
  flex: 1 1 140px;
  min-width: 0;
}
.workspace-template-modal .workspace-template-form > footer > button {
  flex: 0 0 auto;
}
.workspace-template-modal .workspace-template-readonly {
  overflow: hidden;
}
.workspace-template-modal .workspace-template-readonly > .workspace-template-facts,
.workspace-template-modal .workspace-template-readonly > footer {
  flex: 0 0 auto;
}
@media (max-width: 760px) {
  .modal.workspace-template-modal {
    width: min(650px, calc(100vw - 20px));
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }
  .workspace-template-modal .workspace-template-dialog {
    grid-template-rows: minmax(150px, 35%) minmax(0, 1fr);
  }
  .workspace-template-modal .workspace-template-list {
    display: block;
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .workspace-template-modal .workspace-template-list-scroll {
    overflow: visible;
  }
  .workspace-template-form-scroll {
    padding: 16px;
  }
  .workspace-template-modal .workspace-template-form > footer {
    padding: 10px 16px;
  }
}
