/* 头尾固定，弹窗正文独立滚动，表单保留原生提交归属。 */
.modal {
  --modal-width: 540px;
  --modal-padding: 24px;
  --modal-title: 1.375rem;
  width: min(var(--modal-width), calc(100% - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-dialog);
  background: #fff;
  color: var(--body);
  font-size: .875rem;
  box-shadow: var(--shadow-dialog);
}
.modal[open], .modal-form { display: flex; flex-direction: column; }
.modal-form { flex: 1; min-height: 0; }
.modal-header, .modal-footer {
  display: flex;
  flex: none;
  gap: 12px;
  padding: 16px var(--modal-padding);
}
.modal-header {
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 { min-width: 0; font-size: var(--modal-title); line-height: 1.4; }
.modal-header .icon-button { margin-inline-end: -8px; border-radius: var(--field-radius); }
.modal-header .icon-button:focus-visible { outline-offset: 2px; }
.modal-body {
  display: grid;
  align-content: start;
  gap: 16px;
  flex: 1;
  min-height: 0;
  padding: var(--modal-padding);
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 12px;
}
.modal-footer {
  border-top: 1px solid var(--line);
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.modal-footer > .button { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.modal-form-dialog { --modal-width: 620px; }

@media (max-width: 767px) {
  .modal { --modal-padding: 16px; --modal-title: 1.25rem; }
  .modal-form-dialog {
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .modal-form-dialog .modal-header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: 12px;
  }
}
