.reason-popup {
  position: fixed;
  z-index: 9999;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 260px;
  max-width: 90vw;
  max-height: 60vh;
  background: #fff;
  color: #222;
  border: 1px solid #b3c6e0;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  padding: 1.2em 2em 2em 2em;
  font-size: 1.05em;
  line-height: 1.5;
  transition: background 0.2s, color 0.2s, border 0.2s;
  pointer-events: auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.9rem;
}

body.reason-popup-open {
  overflow: hidden;
}

.reason-popup__content,
.reason-popup__body {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
  align-self: stretch;
}

.reason-popup__body--flow {
  white-space: normal;
}

.reason-popup__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #12407d;
}

.reason-popup__meta {
  margin: -0.35rem 0 0;
  font-size: 0.94rem;
  color: #4b5563;
}

.reason-popup__actions {
  display: flex;
  justify-content: flex-end;
}

.reason-popup__actions--dialog {
  gap: 0.75rem;
}

.reason-popup__prompt {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.reason-popup__prompt-label {
  font-weight: 600;
  color: #12407d;
}

.reason-popup__input {
  width: 100%;
  min-height: 6.5rem;
  resize: vertical;
  border-radius: 0.75rem;
  border: 1px solid #b3c6e0;
  padding: 0.75rem 0.9rem;
  background: #f8fbff;
  color: #1f2933;
  font: inherit;
  line-height: 1.45;
}

.reason-popup__input:focus {
  outline: 2px solid rgba(29, 135, 248, 0.22);
  border-color: #1d87f8;
}

.reason-popup__validation {
  margin: -0.25rem 0 0;
  color: #dc2626;
  font-size: 0.92rem;
  font-weight: 600;
}

.reason-popup__button {
  border: none;
  border-radius: 0.75rem;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.reason-popup__button:hover {
  transform: translateY(-1px);
}

.reason-popup__button--secondary {
  background: #e5edf7;
  color: #1f2933;
}

.reason-popup__button--secondary:hover {
  background: #d4e3f3;
}

.reason-popup__button--primary {
  background: #1d87f8;
  color: #fff;
}

.reason-popup__button--primary:hover {
  background: #0f6ed8;
}

.reason-popup .popup-close {
  background: #e3e3e3;
  border: none;
  color: #333;
  font-size: 1em;
  border-radius: 6px;
  padding: 0.5em 1.5em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.reason-popup .popup-close:hover {
  background: #1d87f8;
  color: #fff;
}

body.dark-mode .reason-popup {
  background: #23272e;
  color: #eee;
  border: 1px solid #444;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

body.dark-mode .reason-popup__title {
  color: #9cc8ff;
}

body.dark-mode .reason-popup__meta {
  color: #c0cad8;
}

body.dark-mode .reason-popup__prompt-label {
  color: #9cc8ff;
}

body.dark-mode .reason-popup__input {
  background: #161b22;
  color: #eef4ff;
  border-color: #3a4c63;
}

body.dark-mode .reason-popup__input:focus {
  border-color: #7abaff;
  outline-color: rgba(122, 186, 255, 0.25);
}

body.dark-mode .reason-popup__validation {
  color: #ff8f8f;
}

body.dark-mode .reason-popup__button--secondary {
  background: #334155;
  color: #eef4ff;
}

body.dark-mode .reason-popup__button--secondary:hover {
  background: #41536b;
}

body.dark-mode .reason-popup__button--primary {
  background: #327dde;
}

body.dark-mode .reason-popup__button--primary:hover {
  background: #4b93ef;
}

body.dark-mode .reason-popup .popup-close {
  background: #444;
  color: #eee;
}

body.dark-mode .reason-popup .popup-close:hover {
  background: #7abaff;
  color: #222;
}

/* Explicit hidden wins over the component's flex layout. */
.reason-popup[hidden], .reason-popup [hidden] { display: none !important; }
.reason-popup--runtime { box-sizing: border-box; width: min(38rem, calc(100vw - 2rem)); min-width: 0; overflow-wrap: anywhere; }
.reason-popup--runtime .reason-popup__input { font-size: 1rem; }
.reason-popup--runtime .reason-popup__button, .reason-popup--runtime .popup-close { min-height: 44px; }
@media (max-width: 600px) { .reason-popup--runtime { padding: 1rem; max-height: 85vh; max-height: 85dvh; } }
.reason-popup--runtime .popup-close { position: static; width: auto; height: auto; flex: 0 0 auto; }
