/* ── Overlay ── */
#modal__underlay {
  position: fixed;
  inset: 0;
  background: rgba(58, 40, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: var(--z-overlay);
}

/* ── Dialog ── */
.modal {
  background: var(--warm-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: calc(100vh - var(--space-8));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Width variants ── */
.modal.small        { max-width: 380px; }
.modal.medium-small { max-width: 480px; }
.modal.medium       { max-width: 580px; }
.modal.large        { max-width: 780px; }
.modal.full-screen  { max-width: none; height: calc(100vh - var(--space-8)); }

/* ── Header ── */
.modal__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 2px solid var(--paper);
  flex-shrink: 0;
}

.modal__title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.modal__title h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--ink);
  margin: 0;
}

.modal__title h3 strong {
  font-weight: inherit;
}

.modal__title .subheading h4 {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--ink-lt);
  font-weight: 400;
  margin: var(--space-1) 0 0;
}

.modal__close {
  color: var(--ink-lt);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 0;
  padding: var(--space-1);
  margin: -var(--space-1);
  transition: color var(--duration-fast);
}

.modal__close:hover { color: var(--coral); }

/* ── Body ── */
.modal__body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

/* ── Footer ── */
.modal__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 2px solid var(--paper);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(0);    opacity: 1; }
  to   { transform: translateY(24px); opacity: 0; }
}

.fade-in  { animation: fadeIn  var(--duration-base) ease both; }
.fade-out { animation: fadeOut var(--duration-base) ease both; }
.slide-up   { animation: slideUp   var(--duration-base) ease both; }
.slide-down { animation: slideDown var(--duration-base) ease both; }

/* ── Utility ── */
.block { display: block; }
.float-right { float: right; }

/* ── Mobile ── */
@media (max-width: 679px) {
  #modal__underlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 90vh;
  }
}
