.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,10,2,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--card-bg);
  border-radius: var(--r-xl);
  box-shadow: 0 20px 60px rgba(30,10,2,.18), 0 4px 16px rgba(30,10,2,.1);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-sm { max-width: 400px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  border: none;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 18px;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  flex-shrink: 0;
}

/* Turbo Frame modal pattern */
dialog.modal-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  border-radius: var(--r-xl);
  padding: 0;
  box-shadow: 0 20px 60px rgba(30,10,2,.18);
  max-width: 520px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
}

dialog.modal-dialog::backdrop {
  background: rgba(30,10,2,.45);
  backdrop-filter: blur(2px);
}

/* ── Mobile : bottom sheet ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal,
  .modal-sm,
  .modal-lg,
  .modal-xl {
    max-width: 100% !important;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92dvh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  dialog.modal-dialog {
    margin: 0;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92dvh;
  }
}
