* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #222;
  background: #f5f5f5;
  margin: 0;
  padding: 24px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  background: #fff;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

header {
  margin-bottom: 24px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 12px 0;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
}

.field input[type="text"],
.field select {
  width: 100%;
  padding: 8px 12px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.field .error {
  display: block;
  font-size: 0.875rem;
  color: #c00;
  margin-top: 4px;
}

.custom-title-wrap {
  margin-top: 8px;
  margin-left: 0;
}

.email-input-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
}

.email-input-wrap input {
  width: auto;
  min-width: 12em;
  max-width: 100%;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.email-suffix {
  padding: 8px 12px;
  font-size: 1rem;
  color: #555;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-left: 0;
  border-radius: 0 4px 4px 0;
  user-select: none;
}

.preview-section {
  margin: 24px 0;
  padding: 16px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 4px;
}


.preview {
  min-height: 420px;
  padding: 16px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: auto;
  background: #fff;
}

.preview iframe {
  width: 100%;
  min-width: 1060px;
  border: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: #0066cc;
  color: #fff;
}

.btn-primary:hover {
  background: #0052a3;
}

.btn-secondary {
  background: #eee;
  color: #333;
  border: 1px solid #ccc;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.btn.btn-success {
  background: #28a745;
  color: #fff;
  border-color: #28a745;
  position: relative;
}

.btn.btn-success::after {
  content: '✓';
  margin-left: 6px;
  font-weight: bold;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 8px;
  max-width: 90vw;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
}

.modal-close:hover {
  color: #000;
}

.modal-content pre {
  margin: 0;
  padding: 20px;
  overflow: auto;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1;
  min-height: 200px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: #333;
  color: #fff;
  border-radius: 4px;
  font-size: 0.9rem;
  z-index: 1001;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Mobile responsiveness ── */
@media (max-width: 600px) {
  body {
    padding: 8px;
  }

  .container {
    padding: 16px;
    border-radius: 4px;
  }

  .email-input-wrap input {
    min-width: 8em;
  }

  .preview-section {
    padding: 8px;
  }

  .preview {
    min-height: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
    text-align: center;
  }

  .modal {
    padding: 8px;
  }

  .modal-content {
    max-width: 100vw;
    max-height: 95vh;
    border-radius: 4px;
  }

  .modal-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
  }

  .modal-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .modal-content pre {
    padding: 12px;
    font-size: 0.75rem;
  }

  .toast {
    left: 8px;
    right: 8px;
    transform: none;
    text-align: center;
  }
}
