/* The entire sheet follows the visible viewport, including mobile keyboards. */
.modal:has(.form-sheet) {
  top: var(--form-viewport-top, 0px);
  bottom: auto;
  height: var(--form-viewport-height, 100dvh);
  box-sizing: border-box;
}
.modal .modal-panel.form-sheet {
  background: var(--surface, #fff);
  color: var(--ink, #29252c);
  max-height: calc(var(--form-viewport-height, 100dvh) - 32px);
  overflow: auto;
  scroll-padding-block: 92px 120px;
}
.form-sheet .form-sheet-header {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: -1px;
  z-index: 6;
  background: var(--surface, #fff);
  padding-block: 8px 12px;
  margin-block: -8px 16px;
}
.form-sheet-header > :first-child { min-width: 0; }
.form-sheet .form-sheet-close {
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  line-height: 1;
  font-size: 26px;
}
.form-sheet .form-sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  grid-column: 1 / -1;
  position: sticky;
  bottom: -1px;
  z-index: 5;
  background: var(--surface, #fff);
  border-top: 1px solid var(--line, #dedce1);
  padding-block: 12px;
  margin-block: 12px -12px;
}
.modal .form-action-pair {
  justify-content: flex-end;
  gap: 10px;
}
.form-sheet .form-sheet-actions > :is(button, input[type="submit"]),
.modal .form-action-pair > :is(button, input[type="submit"]) {
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  margin-inline: 0;
}
.form-sheet .form-sheet-actions .form-message { flex-basis: 100%; margin: 0; }
.form-sheet .form-message:empty { display: none; }
.form-message--error, .form-sheet .form-message--error {
  color: #a62a36;
  background: #fff1f2;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e9a9af;
}
[data-theme="dark"] .form-message--error {
  color: #ffb8bf;
  background: #3b202c;
  border-color: #a45265;
}
.session-recovery-modal { z-index: 1300; background: rgb(0 0 0 / 45%); }
.session-recovery-modal .modal-panel { width: min(460px, calc(100vw - 24px)); }
.session-recovery-content .login-form { width: 100%; }
@media (max-width: 900px) {
  .modal:has(.form-sheet) { padding: 8px 8px 0; align-items: flex-end; }
  .modal .modal-panel.form-sheet {
    max-height: calc(var(--form-viewport-height, 100dvh) - 8px);
    width: 100%;
    padding: 16px;
    border-radius: 18px 18px 0 0;
  }
  .form-sheet input, .form-sheet textarea, .form-sheet select { font-size: 16px; }
  .form-sheet .form-sheet-actions { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
.modal .form-sheet.form-sheet--fixed-actions {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.form-sheet--fixed-actions > .form-sheet-header { flex: 0 0 auto; }
.form-sheet--fixed-actions .form-sheet-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  gap: 0;
}
.form-sheet--fixed-actions .form-sheet-fields {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 4px;
  scroll-padding-block: 12px;
}
.form-sheet--fixed-actions .form-sheet-actions { position: static; flex: 0 0 auto; }
.form-sheet .task-form-section,
.form-sheet .task-detail-note,
.form-sheet input,
.form-sheet textarea,
.form-sheet select,
.form-sheet .reference-picker-trigger { background-color: var(--surface); color: var(--ink); }
