/* mf6 modal and drawer system */
body.mf6.mf-modal-open {
  overflow: hidden;
}

body.mf6 .mf6-modal-backdrop,
body.mf6 [class*="modal-backdrop"],
body.mf6 .mf-confirm-backdrop {
  position: fixed !important;
  inset: 0 !important;
  z-index: var(--mf6-z-modal) !important;
  display: grid;
  place-items: center;
  padding: 2.5rem;
  background: rgba(15, 23, 42, .38) !important;
}

body.mf6 .mf6-modal-backdrop[hidden],
body.mf6 [class*="modal-backdrop"][hidden],
body.mf6 .mf-confirm-backdrop[hidden] {
  display: none !important;
}

body.mf6 .mf6-modal-card,
body.mf6 .mf6-dialog-card,
body.mf6 .mf6-drawer-card,
body.mf6 [class*="modal-card"],
body.mf6 [class*="modal-dialog"],
body.mf6 .mf-confirm-dialog {
  width: min(58rem, calc(100vw - 7rem));
  max-height: calc(100vh - 6rem);
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden !important;
  border: 1px solid var(--mf6-line) !important;
  border-radius: var(--mf6-radius-md) !important;
  background: var(--mf6-surface) !important;
  box-shadow: 0 1.25rem 3rem rgba(15, 23, 42, .18) !important;
  color: var(--mf6-text);
}

body.mf6 .mf6-modal-head,
body.mf6 .mf6-dialog-head,
body.mf6 .mf6-drawer-head,
body.mf6 [class*="modal-head"] {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--mf6-space-5);
  padding: 1.05rem 1.35rem !important;
  border-bottom: 1px solid var(--mf6-line) !important;
  background: #fff !important;
}

body.mf6 .mf6-modal-head h2,
body.mf6 .mf6-dialog-head h2 {
  margin: 0;
}

body.mf6 .mf6-modal-body,
body.mf6 .mf6-dialog-body,
body.mf6 .mf6-drawer-body,
body.mf6 [class*="modal-body"] {
  min-height: 0 !important;
  overflow: auto !important;
  padding: 1.25rem 1.35rem !important;
}

body.mf6 .mf6-modal-actions,
body.mf6 .mf6-dialog-actions,
body.mf6 .mf6-drawer-actions,
body.mf6 [class*="modal-actions"],
body.mf6 [class*="modal-foot"] {
  display: flex !important;
  justify-content: flex-end !important;
  gap: var(--mf6-space-3);
  padding: 1rem 1.35rem !important;
  border-top: 1px solid var(--mf6-line) !important;
  background: #fff !important;
}

body.mf6 .mf6-modal-tabs {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  min-height: 0;
}

body.mf6 .mf6-modal-tab-list {
  display: grid;
  align-content: start;
  gap: .2rem;
  padding: .85rem;
  border-right: 1px solid var(--mf6-line);
  background: #f8fafc;
}

body.mf6 .mf6-modal-tab-list button {
  min-height: 2.35rem;
  padding: .55rem .7rem;
  border: 0;
  border-radius: var(--mf6-radius-sm);
  background: transparent;
  color: var(--mf6-text);
  font-weight: 800;
  text-align: left;
}

body.mf6 .mf6-modal-tab-list button[aria-selected="true"],
body.mf6 .mf6-modal-tab-list button.active {
  background: var(--mf6-surface);
  box-shadow: inset .18rem 0 0 var(--mf6-gold-500);
}

body.mf6 dialog.mf6-dialog,
body.mf6 dialog.mf-v6-dialog,
body.mf6 dialog.mf-modal-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: none;
  max-height: none;
}

body.mf6 dialog.mf6-dialog:not([open]),
body.mf6 dialog.mf-v6-dialog:not([open]),
body.mf6 dialog.mf-modal-dialog:not([open]) {
  display: none !important;
}

body.mf6 dialog.mf6-dialog[open],
body.mf6 dialog.mf-v6-dialog[open],
body.mf6 dialog.mf-modal-dialog[open] {
  position: fixed;
  inset: 0;
  z-index: var(--mf6-z-modal);
  width: 100vw;
  height: 100vh;
  display: grid;
  align-items: center !important;
  justify-items: center !important;
  padding: 3.5rem 0 !important;
  overflow: hidden !important;
}

body.mf6 dialog.mf6-dialog[open] > .mf6-dialog-card,
body.mf6 dialog.mf-v6-dialog[open] > .mf6-dialog-card,
body.mf6 dialog.mf-modal-dialog[open] > .mf-modal-card,
body.mf6 dialog.mf-modal-dialog[open] > .mf6-dialog-card {
  width: min(52rem, calc(100vw - 7rem)) !important;
  max-height: calc(100vh - 7rem) !important;
  margin: auto !important;
}

body.mf6 dialog::backdrop {
  background: rgba(15, 23, 42, .38);
}

body.mf6 .mf-modal-close-x-v525e,
body.mf6 .mf6-close {
  width: 2.35rem !important;
  height: 2.35rem !important;
  display: grid !important;
  place-items: center;
  padding: 0 !important;
  border-radius: var(--mf6-radius-sm) !important;
  font-size: 1.45rem !important;
}

body.mf6 .mf6-drawer,
body.mf6 .project-index-drawer {
  position: fixed !important;
  inset: 0 !important;
  z-index: var(--mf6-z-modal) !important;
  display: grid;
  place-items: center;
  padding: 2.5rem;
}

body.mf6 .mf6-drawer[hidden],
body.mf6 .project-index-drawer[hidden] {
  display: none !important;
}

body.mf6 .drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .38);
}

body.mf6 .drawer-panel {
  position: relative !important;
  top: auto;
  right: auto;
  bottom: auto;
  z-index: 1;
  width: min(46rem, calc(100vw - 7rem));
  max-height: calc(100vh - 6rem);
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden !important;
  padding: 0 !important;
  border-radius: var(--mf6-radius-md) !important;
  box-shadow: 0 1.25rem 3rem rgba(15, 23, 42, .18) !important;
}

body.mf6 .drawer-close {
  position: static !important;
  width: 2.35rem !important;
  height: 2.35rem !important;
  display: grid !important;
  place-items: center;
  border: 1px solid var(--mf6-line-strong);
  border-radius: var(--mf6-radius-sm);
  background: #fff;
  font-size: 1.35rem;
}

body.mf6 .drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--mf6-space-4);
  padding: 1.05rem 1.35rem;
  border-bottom: 1px solid var(--mf6-line);
  background: #fff;
}

body.mf6 .drawer-title-row {
  display: grid;
  grid-template-columns: 2.7rem minmax(0, 1fr);
  gap: var(--mf6-space-3);
  align-items: center;
}

body.mf6 .drawer-icon {
  width: 2.45rem;
  height: 2.45rem;
  display: grid;
  place-items: center;
  border-radius: var(--mf6-radius-md);
  background: var(--mf6-surface-soft);
}

body.mf6 .drawer-body {
  min-height: 0;
  overflow: auto;
  padding: 1.25rem 1.35rem;
}

body.mf6 .drawer-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--mf6-space-2);
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--mf6-line);
  background: #fff;
}

body.mf6 .drawer-meta,
body.mf6 .drawer-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--mf6-space-2);
  margin-bottom: var(--mf6-space-3);
}

body.mf6 .drawer-meta span,
body.mf6 .drawer-facts span {
  display: inline-flex;
  min-height: 1.75rem;
  align-items: center;
  padding: .3rem .58rem;
  border: 1px solid var(--mf6-line);
  border-radius: var(--mf6-radius-md);
  background: var(--mf6-surface-soft);
  font-size: var(--mf6-type-xs);
  font-weight: 850;
}

body.mf6 .module-detail-head-v524f,
body.mf6 .module-detail-body-v524f,
body.mf6 .module-detail-actions-v524f {
  background: #fff !important;
}

/* v6.2b QA: modal layer keeps the app visible behind dialogs. */
body.mf6 dialog.mf6-dialog[open],
body.mf6 dialog.mf-v6-dialog[open],
body.mf6 dialog.mf-modal-dialog[open] {
  background: rgba(15, 23, 42, .34) !important;
  backdrop-filter: blur(1px);
}

body.mf6 dialog::backdrop {
  background: rgba(15, 23, 42, .34) !important;
  backdrop-filter: blur(1px);
}

body.mf6 dialog.mf6-dialog[open] > .mf6-dialog-card,
body.mf6 dialog.mf-v6-dialog[open] > .mf6-dialog-card,
body.mf6 dialog.mf-modal-dialog[open] > .mf-modal-card,
body.mf6 dialog.mf-modal-dialog[open] > .mf6-dialog-card {
  position: relative;
  z-index: 2;
}

body.mf6 .mf6-dialog-actions,
body.mf6 .mf-modal-actions,
body.mf6 .mf-app-modal-actions-v524m1,
body.mf6 .module-detail-actions-v524f,
body.mf6 .module-form-actions-v524k {
  display: grid !important;
  grid-template-columns: minmax(2.5rem, auto) minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: var(--mf6-space-3) !important;
}

body.mf6 .mf6-dialog-actions > div,
body.mf6 .mf-modal-actions > div,
body.mf6 .mf-app-modal-actions-v524m1 > div {
  min-width: 0;
}

body.mf6 .mf6-dialog-actions > div:last-child,
body.mf6 .mf-modal-actions > div:last-child,
body.mf6 .mf-app-modal-actions-v524m1 > div:last-child,
body.mf6 .module-detail-actions-main-v524i,
body.mf6 .module-detail-actions-end-v524i {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--mf6-space-3);
}

body.mf6 .module-detail-actions-start-v524i {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
}

/* v6.2e - Global modal/detail standard.
   The same rules govern character, location, relationship, project data and future object modals. */
body.mf6 dialog.mf-modal-dialog[open] > .mf-modal-card,
body.mf6 dialog.mf-modal-dialog[open] > .mf6-dialog-card,
body.mf6 .mf6-modal-card,
body.mf6 .mf6-dialog-card,
body.mf6 .mf-app-modal-card-v524m1,
body.mf6 .module-detail-modal-v524f .mf-modal-card {
  width: min(54rem, calc(100vw - 6rem)) !important;
  max-height: calc(100vh - 5rem) !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
}

body.mf6 .mf-modal-head,
body.mf6 .mf-app-modal-head-v524m1,
body.mf6 .module-detail-head-v524f {
  min-height: 4.4rem !important;
  align-items: flex-start !important;
}

body.mf6 .module-detail-title-v524f,
body.mf6 .mf-modal-head > div:first-child,
body.mf6 .mf-app-modal-head-v524m1 > div:first-child {
  min-width: 0 !important;
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) !important;
  gap: .75rem !important;
  align-items: start !important;
}

body.mf6 .module-detail-title-v524f h2,
body.mf6 .mf-modal-head h2,
body.mf6 .mf-app-modal-head-v524m1 h2 {
  margin: 0 !important;
  font-family: var(--mf6-font-ui) !important;
  font-size: 1.32rem !important;
  line-height: 1.18 !important;
}

body.mf6 .mf-modal-body,
body.mf6 .mf-app-modal-body-v524m1,
body.mf6 .module-detail-body-v524f {
  display: grid !important;
  align-content: start !important;
  gap: .95rem !important;
  min-height: 0 !important;
  overflow: auto !important;
}

body.mf6 .module-detail-section-v524f,
body.mf6 .module-detail-facts-v524f,
body.mf6 .mf-app-modal-body-v524m1 .field,
body.mf6 .mf-app-modal-body-v524m1 label.field {
  margin: 0 !important;
}

body.mf6 .module-detail-section-v524f {
  padding: .85rem .9rem !important;
  border: 1px solid var(--mf6-line) !important;
  border-radius: var(--mf6-radius-md) !important;
  background: #fbfcfe !important;
}

body.mf6 .module-detail-section-v524f h3 {
  margin: 0 0 .35rem !important;
  font-family: var(--mf6-font-ui) !important;
  font-size: .98rem !important;
  line-height: 1.2 !important;
}

body.mf6 .module-detail-facts-v524f,
body.mf6 .drawer-facts,
body.mf6 .drawer-meta {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: .45rem !important;
}

body.mf6 .module-detail-facts-v524f span,
body.mf6 .drawer-facts span,
body.mf6 .drawer-meta span {
  min-height: 1.55rem !important;
  padding: .22rem .5rem !important;
  border-radius: .52rem !important;
  font-size: .72rem !important;
}

body.mf6 .mf-modal-actions,
body.mf6 .mf-app-modal-actions-v524m1,
body.mf6 .module-detail-actions-v524f {
  grid-template-columns: auto minmax(0, 1fr) auto !important;
  gap: .7rem !important;
  align-items: center !important;
}

body.mf6 .module-detail-actions-main-v524i,
body.mf6 .module-detail-actions-end-v524i,
body.mf6 .mf-modal-actions > div:last-child,
body.mf6 .mf-app-modal-actions-v524m1 > div:last-child {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: flex-end !important;
  align-items: center !important;
  gap: .55rem !important;
}

body.mf6 .module-detail-actions-main-v524i .btn,
body.mf6 .module-detail-actions-end-v524i .btn,
body.mf6 .mf-app-modal-actions-v524m1 .btn,
body.mf6 .mf-modal-actions .btn {
  width: auto !important;
  min-width: 0 !important;
}

body.mf6 .module-detail-actions-end-v524i:empty,
body.mf6 .module-detail-actions-main-v524i:empty {
  display: none !important;
}

@media (max-width: 900px) {
  body.mf6 dialog.mf-modal-dialog[open] > .mf-modal-card,
  body.mf6 dialog.mf-modal-dialog[open] > .mf6-dialog-card,
  body.mf6 .mf6-modal-card,
  body.mf6 .mf6-dialog-card,
  body.mf6 .mf-app-modal-card-v524m1 {
    width: min(100vw - 2rem, 54rem) !important;
  }

  body.mf6 .mf-modal-actions,
  body.mf6 .mf-app-modal-actions-v524m1,
  body.mf6 .module-detail-actions-v524f {
    grid-template-columns: 1fr !important;
  }

  body.mf6 .module-detail-actions-main-v524i,
  body.mf6 .module-detail-actions-end-v524i {
    justify-content: flex-start !important;
  }
}


/* v6.2f - Global modal footer and scroll contract.
   Detail modals use one shared footer: destructive left, all normal actions right. */
body.mf6 dialog.mf-modal-dialog[open] > .mf-modal-card,
body.mf6 dialog.mf-modal-dialog[open] > .mf6-dialog-card,
body.mf6 .mf-app-modal-card-v524m1,
body.mf6 .module-detail-modal-v524f .mf-modal-card {
  max-height: min(88vh, calc(100vh - 4rem)) !important;
  overflow: hidden !important;
}

body.mf6 .mf-modal-body,
body.mf6 .mf-app-modal-body-v524m1,
body.mf6 .module-detail-body-v524f {
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable !important;
}

body.mf6 .module-detail-actions-v524f {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex-wrap: wrap !important;
  gap: .55rem !important;
}

body.mf6 .module-detail-actions-start-v524i {
  margin-right: auto !important;
  flex: 0 0 auto !important;
}

body.mf6 .module-detail-actions-main-v524i,
body.mf6 .module-detail-actions-end-v524i {
  flex: 0 1 auto !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: .55rem !important;
}

body.mf6 .module-detail-actions-v524f .btn {
  min-height: 2.12rem !important;
  padding: .4rem .68rem !important;
  font-size: .8rem !important;
}

body.mf6 .module-detail-actions-v524f .mf-btn-icon-only-v524i,
body.mf6 .module-detail-actions-v524f .icon-btn,
body.mf6 .module-detail-actions-v524f .btn.icon-btn {
  width: 2.15rem !important;
  min-width: 2.15rem !important;
  height: 2.15rem !important;
  padding: 0 !important;
}

@media (max-width: 760px) {
  body.mf6 .module-detail-actions-v524f {
    justify-content: flex-start !important;
  }
  body.mf6 .module-detail-actions-start-v524i {
    margin-right: 0 !important;
  }
}


/* v6.2g - GLOBAL POPUP CONTRACT AUDIT
   One rule for all popups/forms/detail dialogs/tool dialogs. No page-specific modal styling.
   Checked against: _app_form_modal, mf6/_modal, mf6/_drawer, detail dialogs, timeline/secret/codex/location/character forms,
   editor tools Live-Pruefer, Logik-Kontext and Textpruefung. */

body.mf6 {
  --mf6-modal-width: min(56rem, calc(100vw - 6rem));
  --mf6-modal-wide-width: min(66rem, calc(100vw - 6rem));
  --mf6-modal-max-height: min(90vh, calc(100vh - 3rem));
  --mf6-modal-pad-x: 1.35rem;
  --mf6-modal-pad-y: 1rem;
}

/* Dialog layer: app stays visible behind the modal; the modal never becomes a replacement page. */
body.mf6 dialog.mf6-dialog[open],
body.mf6 dialog.mf-v6-dialog[open],
body.mf6 dialog.mf-modal-dialog[open] {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: clamp(1rem, 3vh, 2rem) 0 !important;
  display: grid !important;
  place-items: center !important;
  border: 0 !important;
  background: rgba(15, 23, 42, .36) !important;
  overflow: hidden !important;
}

body.mf6 dialog.mf6-dialog[open]::backdrop,
body.mf6 dialog.mf-v6-dialog[open]::backdrop,
body.mf6 dialog.mf-modal-dialog[open]::backdrop,
body.mf6 dialog::backdrop {
  background: rgba(15, 23, 42, .36) !important;
  backdrop-filter: blur(2px) !important;
}

/* Cards: one modal shell, regardless of old v5/v52x hook names. */
body.mf6 dialog.mf6-dialog[open] > .mf6-dialog-card,
body.mf6 dialog.mf-v6-dialog[open] > .mf6-dialog-card,
body.mf6 dialog.mf-modal-dialog[open] > .mf-modal-card,
body.mf6 dialog.mf-modal-dialog[open] > .mf6-dialog-card,
body.mf6 .mf6-modal-card,
body.mf6 .mf6-dialog-card,
body.mf6 .mf-app-modal-card-v524m1,
body.mf6 .module-detail-modal-v524f .mf-modal-card,
body.mf6 .mf-confirm-dialog {
  width: var(--mf6-modal-width) !important;
  max-width: calc(100vw - 2rem) !important;
  max-height: var(--mf6-modal-max-height) !important;
  min-height: 0 !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  overflow: hidden !important;
  padding: 0 !important;
  border: 1px solid var(--mf6-line) !important;
  border-radius: var(--mf6-radius-md) !important;
  background: var(--mf6-surface) !important;
  box-shadow: 0 1.35rem 3.5rem rgba(15, 23, 42, .2) !important;
}

/* The shared form wrapper inside _app_form_modal is the scroll container contract. */
body.mf6 .mf-modal-form,
body.mf6 .mf-app-modal-form-v524m1,
body.mf6 .mf-v6-dialog-form {
  min-height: 0 !important;
  height: 100% !important;
  display: grid !important;
  grid-template-rows: minmax(0, 1fr) auto !important;
  overflow: hidden !important;
}

/* Header: copy stays left, X stays right. Prevent older grid rules from splitting title to the right. */
body.mf6 .mf6-modal-head,
body.mf6 .mf6-dialog-head,
body.mf6 .mf-modal-head,
body.mf6 .mf-app-modal-head-v524m1,
body.mf6 .module-detail-head-v524f,
body.mf6 .drawer-header {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: start !important;
  gap: 1rem !important;
  min-height: 0 !important;
  padding: .95rem var(--mf6-modal-pad-x) !important;
  border-bottom: 1px solid var(--mf6-line) !important;
  background: rgba(255, 255, 255, .98) !important;
}

body.mf6 .mf6-modal-head > div:first-child,
body.mf6 .mf6-dialog-head > div:first-child,
body.mf6 .mf-modal-head > div:first-child,
body.mf6 .mf-app-modal-head-v524m1 > div:first-child,
body.mf6 .module-detail-title-v524f,
body.mf6 .drawer-header > div,
body.mf6 .drawer-title-row {
  min-width: 0 !important;
  width: 100% !important;
  display: block !important;
  grid-template-columns: none !important;
  gap: 0 !important;
}

body.mf6 .mf6-modal-head .eyebrow,
body.mf6 .mf6-dialog-head .eyebrow,
body.mf6 .mf-modal-head .eyebrow,
body.mf6 .mf-app-modal-head-v524m1 .eyebrow,
body.mf6 .module-detail-head-v524f .eyebrow,
body.mf6 .drawer-header .eyebrow {
  margin: 0 0 .22rem !important;
}

body.mf6 .mf6-modal-head h2,
body.mf6 .mf6-dialog-head h2,
body.mf6 .mf-modal-head h2,
body.mf6 .mf-app-modal-head-v524m1 h2,
body.mf6 .module-detail-title-v524f h2,
body.mf6 .drawer-header h2 {
  margin: 0 !important;
  max-width: 42rem !important;
  font-family: var(--mf6-font-ui) !important;
  font-size: clamp(1.16rem, 1.55vw, 1.45rem) !important;
  line-height: 1.18 !important;
  overflow-wrap: anywhere !important;
}

body.mf6 .mf6-modal-head .muted,
body.mf6 .mf6-dialog-head .muted,
body.mf6 .mf-modal-head .muted,
body.mf6 .mf-app-modal-head-v524m1 .muted,
body.mf6 .module-detail-title-v524f .muted,
body.mf6 .drawer-header .muted {
  margin: .35rem 0 0 !important;
  max-width: 58rem !important;
  line-height: 1.45 !important;
}

/* Body: this is always the only vertical scroll zone. */
body.mf6 .mf6-modal-body,
body.mf6 .mf6-dialog-body,
body.mf6 .mf6-drawer-body,
body.mf6 .mf-modal-body,
body.mf6 .mf-app-modal-body-v524m1,
body.mf6 .module-detail-body-v524f,
body.mf6 .drawer-body {
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable !important;
  padding: var(--mf6-modal-pad-y) var(--mf6-modal-pad-x) !important;
  display: grid !important;
  align-content: start !important;
  gap: .9rem !important;
}

/* Footer: destructive left, all normal actions right. Main/end wrappers are flattened. */
body.mf6 .mf6-modal-actions,
body.mf6 .mf6-dialog-actions,
body.mf6 .mf6-drawer-actions,
body.mf6 .mf-modal-actions,
body.mf6 .mf-app-modal-actions-v524m1,
body.mf6 .module-detail-actions-v524f,
body.mf6 .drawer-actions {
  min-height: 4.1rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex-wrap: wrap !important;
  gap: .55rem !important;
  padding: .85rem var(--mf6-modal-pad-x) !important;
  border-top: 1px solid var(--mf6-line) !important;
  background: rgba(255, 255, 255, .98) !important;
}

body.mf6 .module-detail-actions-start-v524i,
body.mf6 .mf-app-modal-actions-v524m1 > div:first-child,
body.mf6 .mf-modal-actions > div:first-child {
  margin-right: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: .5rem !important;
  min-width: 2.2rem !important;
}

body.mf6 .module-detail-actions-main-v524i,
body.mf6 .module-detail-actions-end-v524i,
body.mf6 .mf-app-modal-actions-v524m1 > div:last-child,
body.mf6 .mf-modal-actions > div:last-child {
  display: contents !important;
}

body.mf6 .mf6-modal-actions .btn,
body.mf6 .mf6-dialog-actions .btn,
body.mf6 .mf-modal-actions .btn,
body.mf6 .mf-app-modal-actions-v524m1 .btn,
body.mf6 .module-detail-actions-v524f .btn,
body.mf6 .drawer-actions .btn {
  width: auto !important;
  min-width: 0 !important;
  min-height: 2.12rem !important;
  padding: .4rem .68rem !important;
  border-radius: .58rem !important;
  font-size: .8rem !important;
  line-height: 1.1 !important;
  white-space: nowrap !important;
}

body.mf6 .mf-modal-close-x-v525e,
body.mf6 .mf6-close,
body.mf6 .drawer-close {
  justify-self: end !important;
  width: 2.18rem !important;
  min-width: 2.18rem !important;
  height: 2.18rem !important;
  min-height: 2.18rem !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  border-radius: .62rem !important;
  font-size: 1.2rem !important;
  line-height: 1 !important;
}

/* Form rhythm inside modals. Long selects/textareas may scroll with the body, never push footer off screen. */
body.mf6 .mf-app-modal-body-v524m1 .field,
body.mf6 .mf-app-modal-body-v524m1 label,
body.mf6 .mf-modal-body .field,
body.mf6 .mf-modal-body label {
  min-width: 0 !important;
  max-width: 100% !important;
}

body.mf6 .mf-app-modal-body-v524m1 textarea,
body.mf6 .mf-modal-body textarea {
  min-height: 7rem !important;
  resize: vertical !important;
}

body.mf6 .mf-app-modal-body-v524m1 select,
body.mf6 .mf-modal-body select,
body.mf6 .mf-app-modal-body-v524m1 input,
body.mf6 .mf-modal-body input,
body.mf6 .mf-app-modal-body-v524m1 textarea,
body.mf6 .mf-modal-body textarea {
  max-width: 100% !important;
}

@media (max-width: 760px) {
  body.mf6 {
    --mf6-modal-width: min(100vw - 1rem, 56rem);
    --mf6-modal-max-height: calc(100vh - 1rem);
    --mf6-modal-pad-x: 1rem;
  }
  body.mf6 dialog.mf6-dialog[open],
  body.mf6 dialog.mf-v6-dialog[open],
  body.mf6 dialog.mf-modal-dialog[open] {
    padding: .5rem 0 !important;
  }
  body.mf6 .mf6-modal-actions,
  body.mf6 .mf6-dialog-actions,
  body.mf6 .mf-modal-actions,
  body.mf6 .mf-app-modal-actions-v524m1,
  body.mf6 .module-detail-actions-v524f,
  body.mf6 .drawer-actions {
    justify-content: flex-start !important;
  }
  body.mf6 .module-detail-actions-start-v524i,
  body.mf6 .mf-app-modal-actions-v524m1 > div:first-child,
  body.mf6 .mf-modal-actions > div:first-child {
    margin-right: 0 !important;
  }
}

/* BEGIN v6.2h-single-close-modal-contract */
.mf6-duplicate-close-hidden,
.mf6-modal-footer .mf6-duplicate-close-hidden,
.mf-app-modal-actions-v524m1 .mf6-duplicate-close-hidden,
.mf-modal-actions-v525e .mf6-duplicate-close-hidden,
.drawer-actions .mf6-duplicate-close-hidden {
  display: none !important;
}

.mf6-modal-footer-empty-after-close-cleanup,
.mf-app-modal-actions-v524m1.mf6-modal-footer-empty-after-close-cleanup,
.mf-modal-actions-v525e.mf6-modal-footer-empty-after-close-cleanup,
.drawer-actions.mf6-modal-footer-empty-after-close-cleanup {
  display: none !important;
}

.mf6-modal-footer-no-close,
.mf-app-modal-actions-v524m1.mf6-modal-footer-no-close,
.mf-modal-actions-v525e.mf6-modal-footer-no-close,
.drawer-actions.mf6-modal-footer-no-close {
  justify-content: space-between;
}
/* END v6.2h-single-close-modal-contract */

/* v6.2i12-mf6-dark-surface-audit-contract
   Modal, drawer and editor-tool dialogs use semantic surfaces so Dark Mode does
   not inherit white dialog heads/feet with dark-theme text. */
body.mf6 :is(.mf6-modal-backdrop, [class*="modal-backdrop"], .mf-confirm-backdrop, .drawer-backdrop),
body.mf6 dialog.mf6-dialog[open],
body.mf6 dialog.mf-v6-dialog[open],
body.mf6 dialog.mf-modal-dialog[open],
body.mf6 dialog::backdrop {
  background: var(--mf6-backdrop) !important;
}

body.mf6 :is(
  .mf6-modal-card,
  .mf6-dialog-card,
  .mf6-drawer-card,
  .mf-modal-card,
  .mf-app-modal-card-v524m1,
  .module-detail-modal-v524f .mf-modal-card,
  .mf-confirm-dialog,
  .drawer-panel,
  [class*="modal-card"],
  [class*="modal-dialog"]
) {
  background: var(--mf6-surface-raised) !important;
  color: var(--mf6-text) !important;
  border-color: var(--mf6-line) !important;
}

body.mf6 :is(
  .mf6-modal-head,
  .mf6-dialog-head,
  .mf6-drawer-head,
  .mf-modal-head,
  .mf-app-modal-head-v524m1,
  .module-detail-head-v524f,
  .drawer-header,
  [class*="modal-head"]
) {
  background: var(--mf6-surface-modal-head) !important;
  color: var(--mf6-text) !important;
  border-color: var(--mf6-line) !important;
}

body.mf6 :is(
  .mf6-modal-body,
  .mf6-dialog-body,
  .mf6-drawer-body,
  .mf-modal-body,
  .mf-app-modal-body-v524m1,
  .module-detail-body-v524f,
  .drawer-body,
  [class*="modal-body"]
) {
  background: var(--mf6-surface-raised) !important;
  color: var(--mf6-text) !important;
}

body.mf6 :is(
  .mf6-modal-actions,
  .mf6-dialog-actions,
  .mf6-drawer-actions,
  .mf-modal-actions,
  .mf-app-modal-actions-v524m1,
  .module-detail-actions-v524f,
  .drawer-actions,
  [class*="modal-actions"],
  [class*="modal-foot"]
) {
  background: var(--mf6-surface-modal-foot) !important;
  color: var(--mf6-text) !important;
  border-color: var(--mf6-line) !important;
}

body.mf6 :is(.module-detail-section-v524f, .mf6-modal-tab-list, .drawer-meta span, .drawer-facts span) {
  background: var(--mf6-surface-soft) !important;
  color: var(--mf6-text) !important;
  border-color: var(--mf6-line) !important;
}

body.mf6 :is(.mf-modal-close-x-v525e, .mf6-close, .drawer-close) {
  background: var(--mf6-surface-control) !important;
  color: var(--mf6-text) !important;
  border-color: var(--mf6-line-strong) !important;
}
