.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-container {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
  flex: 1;
  overflow-y: auto;
}

.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: modal-spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes modal-spin {
  to { transform: rotate(360deg); }
}

.modal-message {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.modal-message.ok {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--ok);
}

.modal-message.warn {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--warn);
}

.modal-message.danger {
  background: rgba(251, 113, 133, 0.1);
  border: 1px solid rgba(251, 113, 133, 0.3);
  color: var(--danger);
}

.modal-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}

.modal-response {
  margin-top: 12px;
}

.modal-response pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  overflow-x: auto;
  max-height: 300px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
}

.modal-detail {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}

.modal-state-starting p,
.modal-state-waiting p {
  text-align: center;
  color: var(--muted);
  margin: 0;
}

.modal-state-starting p:last-child,
.modal-state-waiting p:last-child {
  margin-top: 4px;
}

@media (max-width: 780px) {
  .modal-container {
    max-width: 100%;
    border-radius: 16px;
    max-height: 90vh;
  }
}
