/* ==========================================================================
   Overlay layer — direct adaptation of subanapp/web AppModal.vue
   Scoped to #modalRoot. Loaded after studio.css.
   ========================================================================== */

html #modalRoot {
  display: none;
}

html #modalRoot.show {
  display: block;
}

/* Modal — AppModal.vue */
html #modalRoot .modal-mask {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.44);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: modal-mask-in 0.24s ease both;
}

html #modalRoot .modal {
  position: relative;
  display: block;
  width: min(440px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.28), 0 2px 8px rgba(15, 23, 42, 0.08);
  transform-origin: center;
  will-change: transform, opacity;
  animation: modal-panel-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}

html #modalRoot .modal.wide {
  width: min(860px, 100%);
}

html #modalRoot .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 0;
  border: 0;
  background: transparent;
}

html #modalRoot .modal-head h3 {
  min-width: 0;
  margin: 0;
  color: #333333;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
}

html #modalRoot .modal-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #9ca3af;
  font-size: 0;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

html #modalRoot .modal-close .ico {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

html #modalRoot .modal-close:hover {
  background: #f5f7fa;
  color: #4b5563;
  transform: rotate(90deg);
}

html #modalRoot .modal-close:focus-visible,
html #modalRoot .modal-foot .btn:focus-visible {
  outline: 2px solid rgba(24, 141, 249, 0.5);
  outline-offset: 2px;
}

html #modalRoot .modal-body {
  padding: 10px 22px 4px;
  overflow: visible;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.75;
}

html #modalRoot .modal-body > :first-child {
  margin-top: 0;
}

html #modalRoot .modal-body > :last-child {
  margin-bottom: 0;
}

html #modalRoot .modal-body .modal-text {
  margin: 0;
  color: #4b5563;
}

html #modalRoot .modal-body input:not([type="checkbox"]):not([type="radio"]),
html #modalRoot .modal-body select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid #e2e8f2;
  border-radius: 5px;
  background: #fff;
  color: #333;
  font-size: 14px;
  line-height: 1.4;
}

html #modalRoot .modal-body textarea {
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid #e2e8f2;
  border-radius: 5px;
  background: #fff;
  color: #333;
  font-size: 14px;
  line-height: 1.6;
}

html #modalRoot .modal-body label {
  display: block;
  margin: 0 0 14px;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.6;
}

html #modalRoot .modal-body label > input,
html #modalRoot .modal-body label > select,
html #modalRoot .modal-body label > textarea {
  margin-top: 6px;
}

html #modalRoot .modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 22px 20px;
  border: 0;
  background: transparent;
}

/* Reference button palette inside the dialog */
html #modalRoot .modal-foot .btn {
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  box-shadow: none;
  transform: none;
}
html #modalRoot .modal-foot .btn:not(.primary) {
  border-color: #e2e8f2;
  background: #fff;
  color: #4b5563;
}
html #modalRoot .modal-foot .btn:not(.primary):hover {
  border-color: #c7d9ff;
  background: #eef4ff;
  color: #0d6efd;
  box-shadow: 0 5px 14px rgba(13, 110, 253, 0.1);
}
html #modalRoot .modal-foot .btn.primary {
  border-color: #0d6efd;
  background: #0d6efd;
  color: #fff;
}
html #modalRoot .modal-foot .btn.primary:hover {
  border-color: #0b5ed7;
  background: #0b5ed7;
  box-shadow: 0 7px 18px rgba(13, 110, 253, 0.28);
}
html #modalRoot .modal-foot .btn.primary:active {
  border-color: #0a58ca;
  background: #0a58ca;
}

html #modalRoot.is-closing .modal-mask,
html #modalRoot .modal-mask.modal-mask--leaving {
  pointer-events: none;
  animation: modal-mask-out 0.18s ease both;
}

html #modalRoot.is-closing .modal,
html #modalRoot .modal-mask.modal-mask--leaving .modal {
  animation: modal-panel-out 0.18s cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes modal-mask-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-panel-in {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-mask-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes modal-panel-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(6px) scale(0.97); }
}
