/* ─── Compose shell override ──────────────────────────────────────────────── */
.compose-shell {
  max-width: min(960px, 94vw);
}

.compose-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.compose-header h2 {
  margin: 0;
  font-size: 1.6rem;
  flex: 1;
}

/* ─── SMTP status badge ──────────────────────────────────────────────────── */
.smtp-status {
  font-size: 0.88rem;
  font-family: 'IBM Plex Mono', monospace;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: #f4f1ea;
}

.smtp-ok {
  background: color-mix(in srgb, #22c55e 15%, white 85%);
  border-color: #22c55e;
  color: #166534;
}

.smtp-warn {
  background: color-mix(in srgb, #f59e0b 15%, white 85%);
  border-color: #f59e0b;
  color: #92400e;
}

/* ─── Section card ────────────────────────────────────────────────────────── */
.compose-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
  background: color-mix(in srgb, var(--card) 60%, white 40%);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 14px;
  color: var(--ink);
}

/* ─── Badge ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--accent);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
}

/* ─── Recipient toolbar ───────────────────────────────────────────────────── */
.recipient-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.recipient-assign-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fcfbf8;
}

.recipient-assign-toolbar label {
  font-size: 0.88rem;
  color: var(--muted);
}

.recipient-assign-toolbar select {
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  background: #fff;
}

.btn-sm {
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-sm:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-sm.primary {
  background: var(--accent);
  color: white;
}

.btn-sm.secondary {
  background: #ece6dc;
  color: #2b261f;
}

.btn-sm.danger {
  background: #fee2e2;
  color: #991b1b;
}

/* ─── Manual add form ─────────────────────────────────────────────────────── */
.manual-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 12px;
  background: #fafaf5;
  border: 1px dashed var(--line);
  border-radius: 10px;
  margin-bottom: 10px;
}

.manual-form input {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 11px;
  font: inherit;
  font-size: 0.93rem;
}

.manual-form .form-actions {
  display: flex;
  gap: 6px;
}

/* ─── Recipient chips ─────────────────────────────────────────────────────── */
.recipient-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 2px;
}

.recipient-grid {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  max-height: 300px;
}

.recipient-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1.2fr) minmax(220px, 1.6fr) 100px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid #f1eee8;
}

.recipient-row:last-child {
  border-bottom: none;
}

.recipient-row-head {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--muted);
  background: #faf7f1;
  border-radius: 8px;
  border-bottom: none;
}

.recipient-variant {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  font-size: 0.84rem;
  background: #fff;
}

.recipient-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--accent) 10%, white 90%);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, white 75%);
  border-radius: 99px;
  padding: 4px 10px 4px 12px;
  font-size: 0.86rem;
}

.chip-email {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--accent);
  font-size: 0.82rem;
}

.chip-name {
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-remove {
  background: #f5efe6;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  color: #6b6458;
  font-size: 0.8rem;
  line-height: 1.2;
  padding: 6px 8px;
}

.chip-remove:hover {
  color: #dc2626;
  border-color: #fca5a5;
}

.recipient-empty {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
  margin: 0;
  padding: 8px 0;
}

/* ─── Compose grid (subject + reply-to) ──────────────────────────────────── */
.compose-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}

.ai-grid {
  grid-template-columns: 2fr 1fr;
}

.delivery-grid {
  grid-template-columns: 2fr 1fr;
}

#aiPrompt,
#emailsPerHour,
#scheduleAt,
#smtpAccounts,
#aiVariations,
#aiTone {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: 0.92rem;
  background: #fff;
  width: 100%;
}

#smtpAccounts {
  min-height: 132px;
}

.ai-live-preview {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafaf5;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.variants-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.variant-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.variant-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.variant-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.variant-subject {
  margin: 8px 0;
  font-size: 0.86rem;
}

.variant-subject span {
  color: var(--muted);
}

.variant-body {
  border: 1px solid #efe9de;
  border-radius: 8px;
  background: #fcfbf8;
  padding: 8px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.ai-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}

.ai-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.compose-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.compose-field label {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
}

.compose-field input {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
}

/* ─── Anti-spam tips ─────────────────────────────────────────────────────── */
.antispam-tips {
  margin-top: 12px;
  border: 1px dashed #fbbf24;
  border-radius: 8px;
  background: #fffbeb;
  font-size: 0.88rem;
}

.antispam-tips summary {
  cursor: pointer;
  padding: 9px 12px;
  font-weight: 600;
  color: #92400e;
  list-style: none;
  user-select: none;
}

.antispam-tips summary::before {
  content: '⚠ ';
}

.antispam-tips ul {
  margin: 0;
  padding: 0 16px 12px 28px;
  color: #78350f;
  line-height: 1.7;
}

/* ─── Quill editor container ──────────────────────────────────────────────── */
.editor-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.editor-wrap .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--line);
  background: #fafaf5;
}

.editor-wrap .ql-container {
  border: none;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.95rem;
}

.editor-wrap .ql-editor {
  min-height: 280px;
  max-height: 480px;
}

/* ─── Send bar ────────────────────────────────────────────────────────────── */
.send-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0 0;
}

.send-actions {
  display: flex;
  gap: 8px;
}

#sendStatus {
  color: var(--muted);
  font-size: 0.88rem;
}

/* ─── Preview modal ───────────────────────────────────────────────────────── */
.modal-preview .modal-box {
  width: min(820px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
}

.modal-preview .modal-box h3 {
  margin-bottom: 12px;
}

.preview-frame {
  flex: 1;
  min-height: 400px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.modal-preview .modal-footer {
  margin-top: 12px;
}

/* ─── Progress modal ─────────────────────────────────────────────────────── */
.modal-progress .modal-box {
  width: min(540px, 95vw);
}

.progress-bar-wrap {
  background: #ede8df;
  border-radius: 99px;
  height: 10px;
  margin: 10px 0 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s ease;
}

#progressText {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 10px;
  font-family: 'IBM Plex Mono', monospace;
}

.progress-log {
  max-height: 200px;
  overflow-y: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  background: #fafaf5;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.log-entry {
  color: var(--muted);
}

.log-error {
  color: #dc2626;
}

.log-info {
  color: #2563eb;
  font-style: italic;
}

.log-ok {
  color: #16a34a;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .compose-grid {
    grid-template-columns: 1fr;
  }

  .ai-grid,
  .delivery-grid {
    grid-template-columns: 1fr;
  }

  .recipient-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .recipient-row-head {
    display: none;
  }
}
