:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;


  --bg-app: #f4f5f8;
  --bg-composer: #ffffff;
  --bg-elevated: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-light: #e5e7eb;
  --border-subtle: #f3f4f6;

  /* Accent Colors */
  --accent-orange: #ff4d2d;
  --accent-orange-hover: #e03e20;
  --accent-blue: #2563eb;
  --accent-purple: #8b5cf6;

  /* Terminal Dark Theme Palette */
  --bg-terminal: #181818;
  --bg-terminal-header: #181818;
  --text-terminal: #c9d1d9;
  --border-terminal: #30363d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  overflow: hidden;
}

/* App 2-Column Split Layout */
.app-container {
  display: grid;
  grid-template-columns: 1fr 480px;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr 380px;
  }
}

@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    overflow-y: auto;
  }
}

/* ==========================================================================
   LEFT PANE: EMAIL COMPOSER (Matching Screenshots 1 & 2)
   ========================================================================== */
.composer-pane {
  background: var(--bg-composer);
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--border-light);
  overflow: hidden;
  position: relative;
}

.composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.composer-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #111;
  letter-spacing: -0.01em;
}

.window-controls {
  display: flex;
  gap: 0.85rem;
  color: #999;
}

.win-btn {
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

.win-btn:hover {
  color: #333;
}

/* Composer Form Body */
.composer-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.5rem 2rem 0;
  overflow-y: auto;
  position: relative;
}

.field-row {
  display: flex;
  align-items: flex-start;
  min-height: 2.75rem;
  padding: 0.4rem 0;
}

.field-label {
  width: 75px;
  font-weight: 500;
  color: #6b7280;
  font-size: 0.95rem;
  padding-top: 0.4rem;
}

/* FROM ROW & PROFILE BADGE */
.from-row {
  position: relative;
  align-items: center;
}

.profile-badge-wrapper {
  position: relative;
}

.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f2937;
  transition: all 0.2s ease;
}

.profile-badge:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.chevron-icon {
  color: #6b7280;
  margin-left: 2px;
}

/* POPOVER MODAL FOR CREDENTIALS (Centered Modal & Blur Background) */
.popover-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: popoverFadeIn 0.2s ease-out;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.popover-modal.hidden {
  display: none !important;
}

.google-modal-card {
  position: relative;
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  border-radius: 22px;
  box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.35), 0 4px 16px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.8);
  padding: 1.75rem 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow: hidden;
  animation: popoverCardScale 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.google-modal-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #4285F4 0%, #EA4335 33%, #FBBC05 66%, #34A853 100%);
}

.modal-close-icon-btn {
  position: absolute;
  top: 1rem;
  right: 1.1rem;
  background: #f1f5f9;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close-icon-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.google-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-top: 0.2rem;
}

.google-modal-icon-badge {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.6rem;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.google-header-text h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.2;
}

.google-modal-subtitle {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 0.25rem;
  margin-bottom: 0;
  line-height: 1.35;
}

.google-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

[hidden],
.hidden {
  display: none !important;
}

.google-status-banner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  font-size: 0.84rem;
  color: #334155;
}

#google-account-status {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-email-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: -4px -6px -4px 0;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.copy-email-btn:hover {
  background: #e2e8f0;
  color: #334155;
}

.copy-email-btn .copy-icon-done {
  display: none;
}

.copy-email-btn.copied {
  color: #10b981;
}

.copy-email-btn.copied:hover {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.copy-email-btn.copied .copy-icon-default {
  display: none;
}

.copy-email-btn.copied .copy-icon-done {
  display: block;
}

.status-dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-connected {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: modePulseGreen 1.5s infinite;
}

.dot-disconnected {
  background: #cbd5e1;
}

.google-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: end;
  background: #ffffff;
  border: 1px solid #f1f5f9;
  padding: 0.85rem 1rem;
  border-radius: 14px;
}

.input-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-field-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
}

.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit input {
  width: 100%;
  padding: 0.45rem 2.2rem 0.45rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #0f172a;
  outline: none;
  transition: border-color 0.2s ease;
}

.input-with-unit input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.unit-badge {
  position: absolute;
  right: 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  pointer-events: none;
}

.toggle-option-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  user-select: none;
  height: 100%;
}

.mini-toggle {
  width: 34px !important;
  height: 18px !important;
}

.google-modal-footer {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.25rem;
}

.btn-google-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: #ffffff;
  border: 1.5px solid #dadce0;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  color: #3c4043;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-google-signin:hover {
  background: #f8fafc;
  border-color: #d1d5db;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.action-field-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.field-spacer-label {
  font-size: 0.78rem;
  user-select: none;
}

.btn-disconnect-red {
  width: auto;
  height: 38px;
  padding: 0.4rem 1.1rem;
  white-space: nowrap;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #ef4444;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-disconnect-red:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

@keyframes popoverCardScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.popover-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}

.popover-subtitle {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 0.2rem;
  margin-bottom: 1rem;
}

.popover-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-group span {
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
}

.input-group input[type="email"],
.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: #0f172a;
  background: #ffffff;
  transition: all 0.15s ease;
}

.input-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.input-hint {
  font-size: 0.7rem;
  color: #9ca3af;
}

.input-row-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: center;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-top: 1rem;
}

.popover-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f3f4f6;
}

.btn-secondary {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-primary {
  background: var(--accent-orange);
  color: white;
  border: none;
  padding: 0.45rem 0.95rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--accent-orange-hover);
}

/* TO ROW & RECIPIENT CHIPS */
.to-row {
  align-items: center;
  flex-wrap: nowrap;
}

.to-content {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.to-content::-webkit-scrollbar {
  display: none;
}

.recipients-list {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* Recipient Chip styled exactly like Ajay Goel badge in screenshot */
.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.35rem 0.85rem 0.35rem 0.4rem;
  border-radius: 22px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  user-select: none;
  flex-shrink: 0;
  white-space: nowrap;
}

.chip-avatar-num,
.chip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-sans);
  flex-shrink: 0;
}

.chip-text {
  font-weight: 200;
  color: #0f172a;
}

.chip-remove {
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
}

.chip-remove:hover {
  color: #ef4444;
}

/* Responsive Chip visibility for mobile vs desktop */
@media (min-width: 769px) {
  .recipients-list .main-count-chip {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .recipients-list .individual-chip {
    display: none !important;
  }

  .recipients-list .main-count-chip {
    display: inline-flex !important;
  }
}

.csv-summary-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  padding: 0.35rem 0.85rem 0.35rem 0.4rem;
  border-radius: 22px;
  font-size: 0.92rem;
  font-weight: 700;
}

.to-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Custom CSV button styled identically to recipient email badge */
.custom-csv-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.35rem 0.85rem 0.35rem 0.4rem;
  border-radius: 22px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.custom-csv-btn:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.chip-avatar-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-pill {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  padding: 0.35rem 0.65rem;
  border-radius: 18px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
}

.btn-pill:hover {
  background: #f3f4f6;
  color: #111;
}

.divider {
  border: none;
  border-bottom: 1px solid #e2e8f0;
  margin: 1.15rem -2rem;
  width: calc(100% + 4rem);
}

/* SUBJECT ROW (Full-width soft grey background strip) */
.subject-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  width: calc(100% + 4rem);
  margin-left: -2rem;
  margin-right: -2rem;
  margin-top: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.85rem 2rem;
}

.subject-field {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  font-weight: 400;
  color: #111827;
  padding: 0.2rem 0;
  font-family: inherit;
}

.subject-field::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.subject-field:focus {
  outline: none;
}

.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;

  /* min-height: 250px; */
}

.editor-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.editor-mode-toggle {
  display: inline-flex;
  align-items: center;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 19px;
  padding: 6px;
  gap: 4px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.editor-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.2rem;
  border: none;
  background: transparent;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.editor-tab svg {
  stroke: #94a3b8;
  transition: stroke 0.2s ease;
}

.editor-tab:hover {
  color: #e2e8f0;
}

.editor-tab:hover svg {
  stroke: #e2e8f0;
}

.editor-tab.active {
  background: #ddd6fe;
  color: #0f0c1b;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.editor-tab.active svg {
  stroke: #0f0c1b;
}

.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.format-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.55rem;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}



.toolbar-divider {
  width: 1px;
  height: 18px;
  background: #cbd5e1;
  margin: 0 0.2rem;
}

.editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 180px;
}

.message-visual {
  width: 100%;
  height: 100%;
  min-height: 160px;
  flex: 1;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1.6;
  color: #1f2937;
  outline: none;
  overflow-y: auto;
}

.message-visual:focus {
  border-color: transparent;
}

.message-visual[data-placeholder]:empty:before {
  content: attr(data-placeholder);
  color: #9ca3af;
  cursor: text;
}

.message-textarea.hidden,
.rich-toolbar.hidden {
  display: none !important;
}

.message-textarea.code-mode {
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.92rem;
  background: #0f172a;
  color: #f8fafc;
  padding: 0.85rem;
  border-radius: 8px;
  border: none;
  resize: vertical;
}

.message-textarea::placeholder {
  color: #9ca3af;
}

.message-textarea:focus {
  outline: none;
}

/* ATTACHMENTS SECTION (Matching Screenshot 1) */
.attachments-section {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.section-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.75rem;
}

.attachments-container {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
}

/* EMPTY DASHED UPLOAD BOX DROPZONE */
.attachment-upload-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  background: #232323;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.attachment-upload-box:hover,
.attachment-upload-box.dragover {
  border-color: var(--accent-orange);
  background: #fff5f2;
}

.upload-box-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  /* color: var(--accent-orange); */
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.upload-box-text {
  display: flex;
  flex-direction: column;
}

.upload-main-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: #d7d8d9;
}

.upload-sub-text {
  font-size: 0.76rem;
  color: #64748b;
  margin-top: 0.15rem;
}

.attachment-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #f3f4f6;
  border-radius: 12px;
  padding: 0.6rem 1rem 0.6rem 0.75rem;
  min-width: 220px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.pdf-icon-badge {
  background: #ef4444;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attachment-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f2937;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-delete {
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.attachment-delete:hover {
  color: #ef4444;
}

/* FOOTER TOOLBAR & ACTIONS (Fixed / Sticky at bottom - Dark Theme) */
.composer-footer {
  position: sticky;
  bottom: 0;
  background: #171717;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 3rem;
  margin-top: auto;
  margin-left: -2rem;
  margin-right: -2rem;
  border-top: 1px solid #232323;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  flex-wrap: wrap;
  gap: 1rem;
}

.formatting-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* DYNAMIC VARIABLE BUTTON & POPOVER (Dark Theme) */
.variable-picker-wrapper {
  position: relative;
}

.variable-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  background: #6363634e;
  border-radius: 8px;
  padding: 0.7rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  user-select: none;
}

.variable-trigger-btn * {
  pointer-events: none;
}

.variable-trigger-btn:hover {
  background: #334155;
  border-color: #475569;
}

.var-symbol {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-purple);
}

.var-trigger-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f8fafc;
}

.variable-menu {
  position: absolute;
  bottom: 125%;
  left: 0;
  background: #181b20;
  border: 1px solid #2d3139;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  padding: 0.75rem;
  width: 180px;
  z-index: 50;
  animation: varMenuFade 0.15s ease-out;
}

@keyframes varMenuFade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.variable-menu.hidden {
  display: none;
}

.variable-menu-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 0.5rem;
}

.variable-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Variable Chips Styled Exactly Like Screenshot 2 */
.variable-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #232730;
  border: 1px solid #353a45;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s ease;
  font-family: var(--font-mono);
}

.variable-chip-btn:hover {
  background: #2e3440;
  border-color: var(--accent-purple);
}

.var-badge-icon {
  color: #a78bfa;
  font-weight: 700;
  font-size: 0.85rem;
}

.var-badge-text {
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ACTION BUTTONS GROUP */
.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-left: auto;
}

/* MODERN BROADCAST TOGGLE SWITCH BUTTON */
.broadcast-toggle-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: #e2e8f0;
}

.broadcast-toggle-wrapper input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  background-color: #334155;
  border-radius: 20px;
  transition: background-color 0.25s ease;
  cursor: pointer;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.broadcast-toggle-wrapper input[type="checkbox"]:checked+.toggle-slider {
  background-color: var(--accent-orange);
}

.broadcast-toggle-wrapper input[type="checkbox"]:checked+.toggle-slider::before {
  transform: translateX(16px);
}

.info-icon {
  color: #94a3b8;
  font-size: 0.8rem;
}

.btn-discard {
  background: #3d3d3d78;
  border: none;
  padding: 0.7rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-discard:hover {
  background: #334155;
  color: #ffffff;
  border-color: #475569;
}

.btn-send-email {
  background: #029925;
  color: white;
  border: none;
  padding: 0.7rem 3.45rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  /* box-shadow: 0 4px 16px rgba(255, 77, 45, 0.4); */
  transition: all 0.2s ease;
}

.btn-send-email:hover {
  background: var(--accent-orange-hover);
  box-shadow: 0 6px 20px rgba(255, 77, 45, 0.5);
  transform: translateY(-1px);
}

.btn-send-email:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-send-email:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* RESPONSIVE FOOTER LAYOUT (Send email button on next line in mobile) */
@media (max-width: 768px) {
  .composer-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .formatting-toolbar {
    width: 100%;
    display: flex;
    justify-content: flex-start;
  }

  .action-buttons-group {
    width: 100%;
    margin-left: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .broadcast-checkbox-wrapper {
    font-size: 0.88rem;
    white-space: nowrap;
  }

  .btn-discard {
    padding: 0.6rem 1.1rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .btn-send-email {
    width: 100%;
    flex-basis: 100%;
    margin-top: 0.25rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    text-align: center;
    white-space: nowrap;
  }
}


/* ==========================================================================
   RIGHT PANE: LIVE TERMINAL WINDOW
   ========================================================================== */
/* ==========================================================================
   RIGHT PANE: LIVE TERMINAL WINDOW (Premium Minimalist CLI Theme)
   ========================================================================== */
.terminal-pane {
  background: #0b0d0c;
  color: #c8d3ce;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-left: 1px solid #141917;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  padding: 0.85rem 1.25rem;
  background: #12100f;
  border-bottom: 1px solid #1c211f;
  user-select: none;
}

/* "OXIDE INSTANCE / TERMINAL" style stacked brand label */
.terminal-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  color: #6f7d77;
}

.terminal-brand strong {
  font-weight: 600;
  color: #e6efea;
}

.terminal-tabs {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  margin-right: auto;
}

.terminal-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.terminal-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: rgba(128, 128, 128, 0.288);
  color: #6f7d77;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.terminal-collapse-btn svg {
  width: 25px;
  height: 25px;
  transition: transform 0.2s ease;
}

.terminal-collapse-btn:hover {
  color: #e6efea;
  background: rgba(255, 255, 255, 0.06);
}

/* Chevron points right when open (collapse), left when collapsed (expand) */
.terminal-pane.collapsed .terminal-collapse-btn svg {
  transform: rotate(180deg);
}

/* Collapsed: only a slim header strip stays visible */
.terminal-pane.collapsed .terminal-stats,
.terminal-pane.collapsed .terminal-console,
.terminal-pane.collapsed .progress-container,
.terminal-pane.collapsed .terminal-tab,
.terminal-pane.collapsed .terminal-brand,
.terminal-pane.collapsed #clear-terminal-btn {
  display: none;
}

.terminal-pane.collapsed .terminal-header {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.9rem;
  height: 100%;
  padding: 0.9rem 0.4rem;
  border-bottom: none;
}

.terminal-pane.collapsed .terminal-tabs {
  flex-direction: column;
  margin-right: 0;
}

.app-container.terminal-collapsed {
  grid-template-columns: 1fr 56px;
}

.terminal-tab {
  position: relative;
  padding: 0.35rem 0.1rem;
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  color: #6f7d77;
  cursor: default;
}

.terminal-tab.active {
  color: #48d597;
}

.terminal-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.9rem;
  height: 2px;
  background: #48d597;
}

/* Instance-stats strip under the header */
.terminal-stats {
  display: flex;
  gap: 2.6rem;
  padding: 1.1rem 1.25rem 0.9rem;
  background: #0b0d0c;
}

.terminal-stat {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.terminal-stat-label {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: #6f7d77;
}

.terminal-stat-value {
  font-size: 0.86rem;
  color: #e6efea;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-indicator-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #22c55e;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }

  100% {
    opacity: 1;
  }
}

.terminal-mini-btn {
  background: #18181b;
  border: 1px solid #27272a;
  color: #a1a1aa;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  padding: 0.6rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.terminal-mini-btn:hover {
  background: #27272a;
  color: #ffffff;
}

/* Square icon-only variant (settings gear next to Clear) */
.terminal-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  text-decoration: none;
  padding: 0;
}

.terminal-icon-btn svg {
  width: 17px;
  height: 17px;
}

/* Progress — CLI block meter (▮▮▮▮░░░░) */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.2rem 1.25rem 1rem;
  padding: 0;
  background: none;
  border: none;
}

.progress-container.hidden {
  display: none;
}

.progress-blocks {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 1.8rem;
  line-height: 1;
  letter-spacing: 0em;
  white-space: nowrap;
  overflow: hidden;
}

.progress-blocks .blk-on {
  color: #48d597;
}

.progress-blocks .blk-off {
  color: #2a3230;
}

.progress-container.done .progress-blocks .blk-on {
  color: #4ade80;
}

.progress-container.done .progress-text {
  color: #4ade80;
}

.progress-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  color: #f3f4f6;
  letter-spacing: 0.02em;
}

/* Terminal Console Viewport */
.terminal-console {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 0.84rem;
  line-height: 1.7;
  background: #0b0d0c;
}

#terminal {
  white-space: pre-wrap;
  word-break: break-word;
  color: #c8d3ce;
  font-family: inherit;
}

/* Syntax Highlighted CLI Log Lines */
.log-line {
  display: block;
  white-space: normal;
  margin-bottom: 0.35rem;
  line-height: 1.6;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 0.83rem;
  word-break: break-word;
}

/* System lines rendered as status bullets (● Bold lead + muted rest) */
.log-bullet-line {
  display: block;
  white-space: normal;
  margin: 0.7rem 0 0.35rem;
  line-height: 1.6;
}

.log-bullet {
  display: inline-block;
  margin-right: 0.55rem;
  font-size: 0.7rem;
  color: #6f7d77;
}

.log-bullet.is-done {
  color: #48d597;
}

.log-bullet-lead {
  font-weight: 600;
  color: #e6efea;
}

.log-bullet-rest {
  color: #8a968f;
}

/* Checklist rows nested under a bullet line */
.log-checklist {
  margin: 0.15rem 0 0.9rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.log-check {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  white-space: normal;
  color: #5d6a64;
  line-height: 1.7;
}

.log-check-box {
  flex: none;
  width: 1ch;
  color: inherit;
}

.log-check.done {
  color: #4a564f;
}

.log-check.active {
  color: #e6efea;
  font-weight: 600;
}

/* Glyph that replaces the old [TAG] prefix */
.log-icon {
  display: inline-block;
  width: 1.2ch;
  margin-right: 0.65rem;
  font-weight: 600;
}

.log-time {
  color: #52525b;
  font-size: 0.78rem;
  white-space: nowrap;
}

.log-sys {
  color: #38bdf8;
  font-weight: 600;
  white-space: nowrap;
}

.log-info {
  color: #a1a1aa;
  white-space: nowrap;
}

.log-csv {
  color: #c084fc;
  font-weight: 600;
  white-space: nowrap;
}

.log-sent {
  color: #22c55e;
  font-weight: 600;
  white-space: nowrap;
}

.log-dry {
  color: #facc15;
  font-weight: 600;
  white-space: nowrap;
}

.log-error {
  color: #f87171;
  font-weight: 600;
  white-space: nowrap;
}

.log-warning {
  color: #fb923c;
  font-weight: 600;
  white-space: nowrap;
}

.log-text {
  color: #e4e4e7;
}

/* CLI Card / Box Styling for Batch Info */
.cli-box {
  background: #000000;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 0.5rem 0;
  font-family: inherit;
}

.cli-box-title {
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.5rem;
  display: inline-block;
  background: #27272a;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
}

.cli-box-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
}

.cli-box-label {
  color: #71717a;
  width: 100px;
}

.cli-box-val {
  color: #e4e4e7;
  font-weight: 600;
}

.cli-box-val.running {
  color: #22c55e;
}

.terminal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background: #000000;
  border-top: 1px solid #18181b;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: #71717a;
}

/* ==========================================================================
   VARIABLE DRAWER OVERLAY (Matching Screenshot 2)
   ========================================================================== */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  transition: visibility 0.25s ease;
}

.drawer-overlay.hidden {
  display: none !important;
}

.drawer-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.drawer-content {
  position: relative;
  z-index: 2;
  width: min(92vw, 540px);
  background: #181b20;
  border: 1px solid #2d3139;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
  padding: 1.25rem 1.5rem 1.75rem;
  color: #ffffff;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 0;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.drawer-handle-bar {
  width: 36px;
  height: 4px;
  background: #374151;
  border-radius: 2px;
  margin: 0 auto 1rem;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.drawer-icon {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.15);
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
}

.drawer-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.drawer-close-btn {
  background: #232730;
  border: 1px solid #353a45;
  color: #9ca3af;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.drawer-close-btn:hover {
  color: white;
  background: #2e3440;
}

.drawer-subtitle {
  font-size: 0.85rem;
  color: #9ca3af;
  margin-bottom: 1.25rem;
}

.drawer-variable-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drawer-variable-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: #232730;
  border: 1px solid #353a45;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  width: 100%;
}

.drawer-variable-card:hover {
  background: #2c323e;
  border-color: #8b5cf6;
  transform: translateY(-1px);
}

.var-card-details {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.var-card-name {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: #f1f5f9;
}

.var-card-desc {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 0.15rem;
}

.var-insert-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #c084fc;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
}

/* TEMPLATE DRAWER STYLES */
.side-drawer-content {
  width: min(94vw, 680px) !important;
  max-height: 85vh;
  overflow-y: auto;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.template-card {
  background: #232730;
  border: 1px solid #353a45;
  border-radius: 12px;
  padding: 1.1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

.template-card:hover {
  background: #2b313d;
  border-color: #3b82f6;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.template-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.template-card-header h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}

.template-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-blue {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-gray {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.badge-purple {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.badge-green {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.template-desc {
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.45;
  margin: 0;
}

.template-preview-box {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.76rem;
  color: #cbd5e1;
  padding: 0.6rem;
}

.mini-header-gradient {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
  padding: 0.4rem 0.6rem;
  font-weight: 700;
  font-size: 0.78rem;
  border-radius: 4px;
  margin-bottom: 0.4rem;
}

.mini-text {
  line-height: 1.4;
  color: #94a3b8;
}

.btn-use-template {
  width: 100%;
  padding: 0.55rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.template-card:hover .btn-use-template {
  background: #1d4ed8;
}

/* RIGHT SIDE PANEL DRAWER FOR HTML CODE EDITOR */
.btn-open-side-drawer {
  color: #282828 !important;
  cursor: pointer;
}

.btn-open-side-drawer:hover {
  background: #dbeafe !important;
  border-color: #93c5fd !important;
}

.side-panel-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(580px, 92vw);
  height: 100vh;
  background: #0f172a;
  border-left: 1px solid #1e293b;
  box-shadow: -12px 0 48px rgba(0, 0, 0, 0.5);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  z-index: 10000;
  color: #f8fafc;
  animation: slideFromRight 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideFromRight {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

.code-quick-tags {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tag-insert-btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  background: #1e293b;
  border: 1px solid #334155;
  color: #38bdf8;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-insert-btn:hover {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

/* MINIMALIST SIDE PANEL DRAWER (Matching Screenshot 2) */
.side-panel-drawer.minimalist-editor-drawer {
  background: #1e1e1e;
  color: #e4e4e7;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #18181b;
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.7);
}

.minimal-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: #141414;
  border-bottom: 1px solid #18181b;
  user-select: none;
}

.minimal-editor-title {
  font-family: 'JetBrains Mono', 'Fira Code', var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: #e4e4e7;
  letter-spacing: -0.01em;
}

.minimal-editor-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.minimal-tool-btn {
  background: transparent;
  border: none;
  color: #71717a;
  font-size: 1rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.minimal-tool-btn:hover {
  color: #f4f4f5;
  background: #18181b;
}

.minimal-close-btn:hover {
  color: #ef4444;
}

.minimal-tags-strip {
  padding: 0.65rem 1.25rem;
  background: #121215;
  border-bottom: 1px solid #18181b;
  margin-bottom: 0;
}

.minimal-editor-body {
  flex: 1;
  display: flex;
  background: #141414;
  position: relative;
  overflow: hidden;
}

.minimal-line-numbers {
  width: 44px;
  min-width: 44px;
  background: #232323;
  color: #3f3f46;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.88rem;
  line-height: 1.65;
  padding: 1.25rem 0.6rem 1.25rem 0;
  text-align: right;
  user-select: none;
  border-right: 1px solid #18181b;
  overflow: hidden;
}

.minimal-line-numbers div {
  height: 1.65em;
}

.minimal-textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.65;
  background: #232323;
  border: none;
  color: #e4e4e7;
  padding: 1.25rem 1.25rem;
  resize: none;
  outline: none;
  white-space: pre;
  tab-size: 2;
  overflow-y: auto;
}

.minimal-textarea::placeholder {
  color: #3f3f46;
}

.minimal-editor-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: #232323;
  border-top: 1px solid #18181b;
}

.btn-minimal-cancel {
  background: #18181b;
  border: 1px solid #27272a;
  color: #a1a1aa;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-minimal-cancel:hover {
  background: #27272a;
  color: #ffffff;
}

.btn-minimal-apply {
  background: var(--accent-orange);
  border: none;
  color: #ffffff;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255, 77, 45, 0.4);
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-minimal-apply:hover {
  background: var(--accent-orange-hover);
  box-shadow: 0 6px 18px rgba(255, 77, 45, 0.5);
  transform: translateY(-1px);
}

.drawer-footer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid #1e293b;
}

/* ==========================================================================
   HTML ATTACHMENT CONVERTER & DUAL OPTIONS UI STYLES
   ========================================================================== */
.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.section-subtitle {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 500;
}

.attachment-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  width: 100%;
}

@media (max-width: 600px) {
  .attachment-options-grid {
    grid-template-columns: 1fr;
  }
}

.attachment-html-convert-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  background: #232323;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  text-align: left;
  font-family: inherit;
}

.attachment-html-convert-box:hover {
  border-color: #ec4899;
  background: #fdf2f8;
}

.html-convert-icon {
  background: #ffffff;
  border: 1px solid #fbcfe8;
}

/* HTML ATTACHMENT CONVERTER SIDE PANEL DRAWER */
.html-attachment-panel {
  width: min(780px, 94vw) !important;
}

.drawer-header-subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
  display: block;
  margin-top: 0.15rem;
}

/* LIVE DYNAMIC FILENAME BANNER */
.attachment-filename-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid #334155;
  border-left: 4px solid #ec4899;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filename-banner-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filename-banner-label {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 500;
}

.filename-banner-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: #f472b6;
  background: rgba(244, 114, 182, 0.15);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}

.filename-banner-hint {
  font-size: 0.75rem;
  color: #64748b;
  font-style: italic;
}

/* FORMAT SELECTION SEGMENTED CONTROL */
.format-selection-group {
  margin-bottom: 1.1rem;
}

.format-option-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 0.45rem;
}

.format-segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  background: #020617;
  border: 1px solid #1e293b;
  padding: 4px;
  border-radius: 10px;
}

.format-segment-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.18s ease;
}

.format-segment-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.05);
}

.format-segment-btn.active {
  background: #1e293b;
  color: #ffffff;
  border-color: #ec4899;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.format-icon {
  font-size: 1rem;
}

.quick-tags-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
}

.tag-highlight-btn {
  background: rgba(236, 72, 153, 0.15) !important;
  border-color: rgba(236, 72, 153, 0.4) !important;
  color: #f472b6 !important;
}

.tag-highlight-btn:hover {
  background: #ec4899 !important;
  color: white !important;
}

/* SPLIT HTML EDITOR & LIVE PREVIEW */
.attachment-editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  flex: 1;
  min-height: 280px;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .attachment-editor-split {
    grid-template-columns: 1fr;
    grid-template-rows: 200px 200px;
  }
}

.split-editor-pane,
.split-preview-pane {
  display: flex;
  flex-direction: column;
}

.pane-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 0.4rem;
}

.preview-scroll-wrapper {
  flex: 1;
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 0.75rem;
  overflow: auto;
  min-height: 220px;
}

.attachment-preview-frame {
  background: #ffffff;
  color: #1e293b;
  border-radius: 6px;
  padding: 1.25rem;
  min-height: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  word-break: break-word;
}

.preview-placeholder {
  color: #94a3b8;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 3rem;
  font-style: italic;
}

/* GENERATE BUTTON WITH FORMAT BADGE */
.btn-generate-attachment {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #ec4899, #db2777) !important;
  padding: 0.55rem 1.15rem !important;
}

.btn-generate-attachment:hover {
  background: linear-gradient(135deg, #db2777, #be185d) !important;
}

.format-badge-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.25);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
}

/* FORMAT BADGES FOR ATTACHMENT CARDS */
.attachment-card .doc-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.badge-pdf-icon {
  background: #ef4444;
}

.badge-image-icon {
  background: #2563eb;
}

.badge-docx-icon {
  background: #1d4ed8;
}

.attachment-format-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  margin-right: 0.4rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.format-badge-pdf {
  background: #fee2e2;
  color: #dc2626;
}

.format-badge-image {
  background: #dbeafe;
  color: #2563eb;
}

.format-badge-docx {
  background: #e0e7ff;
  color: #4338ca;
}

/* MANUAL RECIPIENTS MODAL & FORMULA STYLING */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-overlay.hidden {
  display: none;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-card.manual-recipients-card {
  background: #ffffff;
  width: 100%;
  max-width: 640px;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.modal-header-info h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.modal-subtitle {
  font-size: 0.83rem;
  color: #64748b;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.modal-tabs {
  display: flex;
  background: #f8fafc;
  padding: 0.35rem 1.5rem 0;
  border-bottom: 1px solid #e2e8f0;
  gap: 0.5rem;
}

.modal-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 600;
  color: #64748b;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-tab:hover {
  color: #0f172a;
}

.modal-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: #ffffff;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-tab-content.hidden {
  display: none;
}

.formula-controls-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.formula-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.formula-group.hidden {
  display: none;
}

.formula-group label {
  font-size: 0.83rem;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

.formula-select {
  height: 36px;
  padding: 0 0.75rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 0.85rem;
  color: #0f172a;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.formula-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.delimiter-input {
  width: 70px;
  height: 36px;
  padding: 0 0.5rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 0.85rem;
  text-align: center;
  font-weight: 600;
}

.bulk-textarea-wrapper {
  margin-top: 0.25rem;
}

.manual-bulk-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-family: var(--font-mono, monospace), sans-serif;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #0f172a;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease;
}

.manual-bulk-textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.manual-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  margin-bottom: 0.4rem;
}

.preview-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.parsed-count-badge {
  font-size: 0.78rem;
  font-weight: 700;
  background: #dbeafe;
  color: #1e40af;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
}

.manual-preview-scroll {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fafafa;
  padding: 0.5rem;
}

.manual-preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.preview-empty {
  font-size: 0.83rem;
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  padding: 1rem 0;
}

.preview-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #f1f5f9;
  font-size: 0.83rem;
}

.preview-item-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
}

.preview-item-name {
  font-weight: 600;
  color: #0f172a;
}

.preview-item-email {
  color: #64748b;
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
}

.single-entry-fields {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: #f8fafc;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.input-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-field-group label {
  font-size: 0.83rem;
  font-weight: 600;
  color: #334155;
}

.modal-text-input {
  height: 38px;
  padding: 0 0.85rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 0.88rem;
  color: #0f172a;
  outline: none;
}

.modal-text-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.add-single-btn {
  align-self: flex-start;
  height: 34px;
  padding: 0 1rem;
  font-size: 0.83rem;
  margin-top: 0.25rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  gap: 1rem;
  flex-wrap: wrap;
}

.import-mode-options {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.83rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
}

.radio-label input[type="radio"] {
  accent-color: #2563eb;
  cursor: pointer;
}

.modal-footer-btns {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* STOP SENDING BUTTON STYLES */
.btn-stop-send {
  background: #ef4444;
  color: #ffffff;
  border: 1px solid #dc2626;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
  user-select: none;
}

.btn-stop-send:hover {
  background: #dc2626;
  border-color: #b91c1c;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

.btn-stop-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-stop-send.hidden {
  display: none !important;
}

/* ==========================================================================
   TOP MODE BANNER STRIP (TEST MODE & LIVE MODE TOGGLE)
   ========================================================================== */
.top-mode-banner-strip {
  width: 100%;
  background: #ffffff;
  border-top: 8px solid #eab308;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.3s ease, background-color 0.3s ease;
  z-index: 20;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.top-mode-banner-strip.test-mode {
  border-top-color: #f59e0b;
}

.top-mode-banner-strip.live-mode {
  border-top-color: #10b981;
}

.mode-ribbon-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.3rem 1.4rem 0.35rem 1.4rem;
  background: #fde047;
  color: #0f172a;
  font-weight: 800;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  font-family: var(--font-sans);
  border-radius: 0 0 10px 10px;
  clip-path: polygon(0 0, 100% 0, 93% 100%, 7% 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: all 0.3s ease;
  user-select: none;
}

.top-mode-banner-strip.test-mode .mode-ribbon-pill {
  background: #facc15;
  color: #1e293b;
}

.top-mode-banner-strip.live-mode .mode-ribbon-pill {
  background: #10b981;
  color: #ffffff;
}

.mode-dot {
  font-size: 0.65rem;
  display: inline-block;
}

.top-mode-banner-strip.test-mode .mode-dot {
  color: #451a03;
}

.top-mode-banner-strip.live-mode .mode-dot {
  color: #d1fae5;
  animation: modePulseGreen 1.5s infinite;
}

@keyframes modePulseGreen {
  0% {
    opacity: 0.5;
    transform: scale(0.9);
  }

  50% {
    opacity: 1;
    transform: scale(1.1);
  }

  100% {
    opacity: 0.5;
    transform: scale(0.9);
  }
}

.mode-title-text {
  text-transform: uppercase;
}

/* TOGGLE SWITCH STYLING */
.mode-switch-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 18px;
  margin-left: 0.2rem;
  cursor: pointer;
}

.mode-switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-switch-slider {
  position: absolute;
  inset: 0;
  background-color: #3b82f6;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 20px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.mode-switch-slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.mode-switch-toggle input:checked+.mode-switch-slider {
  background-color: #2563eb;
}

.mode-switch-toggle input:checked+.mode-switch-slider:before {
  transform: translateX(18px);
}

.top-mode-banner-strip.live-mode .mode-switch-slider {
  background-color: #064e3b;
}

.top-mode-banner-strip.live-mode .mode-switch-toggle input:checked+.mode-switch-slider {
  background-color: #047857;
}

/* ==========================================================================
   CHUNK CHIPS (TO row)
   ========================================================================== */
.chunk-chips-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chunk-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #334155;
  cursor: default;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.chunk-chip.active-chunk {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
  font-weight: 600;
}

.chunk-chip.sent-chunk {
  background: #d1fae5;
  border-color: #6ee7b7;
  color: #065f46;
  text-decoration: line-through;
  opacity: 0.6;
}

.chunk-chip .chunk-label {
  pointer-events: none;
}

/* ==========================================================================
   CHUNK COOLDOWN MODAL
   ========================================================================== */
.chunk-cooldown-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeInOverlay 0.3s ease;
}

.chunk-cooldown-overlay.hidden {
  display: none;
}

.chunk-cooldown-card {
  background: #ffffff;
  border-radius: 1.25rem;
  padding: 2.5rem 2.5rem 2rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
  animation: scaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cooldown-icon-ring {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 1.5rem;
}

.cooldown-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.cooldown-ring-bg {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 6;
}

.cooldown-ring-fg {
  fill: none;
  stroke: #6366f1;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.cooldown-timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.6rem;
  font-weight: 700;
  color: #1e293b;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
}

.cooldown-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.35rem;
}

.cooldown-subtitle {
  font-size: 0.88rem;
  color: #64748b;
  margin: 0 0 1rem;
}

.cooldown-chunk-info {
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.82rem;
  color: #475569;
  font-weight: 500;
  margin-bottom: 1.5rem;
}

.cooldown-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.cooldown-skip-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.cooldown-cancel-btn {
  width: 100%;
  padding: 0.65rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeInOverlay {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ==========================================================================
   LEFT PANE: LIGHT / DARK THEME SUPPORT
   Light is the default (no attribute). `:root[data-theme="dark"]` flips the
   composer surfaces; the terminal pane is dark in both themes by design.
   ========================================================================== */

/* Theme switch — lives in the terminal header next to the settings gear */
.composer-theme-toggle {
  font-family: var(--font-sans);
  font-weight: 600;
}

.composer-theme-toggle #composer-theme-icon {
  display: inline-flex;
}

.composer-theme-toggle svg {
  width: 17px;
  height: 17px;
  display: block;
}

/* Label is for screen readers / tooltips only — the header stays icon-only */
.sr-only-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:root[data-theme="dark"] {
  --bg-app: #0f1210;
  --bg-composer: #141715;
  --bg-elevated: #1c201e;
  --text-primary: #e6efea;
  --text-secondary: #9aa8a2;
  --text-muted: #6f7d77;
  --border-light: #262b28;
  --border-subtle: #1e2321;
}

:root[data-theme="dark"] .composer-pane {
  background: var(--bg-composer);
  border-right-color: var(--border-light);
  color: var(--text-primary);
}

:root[data-theme="dark"] .composer-header {
  border-bottom-color: var(--border-subtle);
}

:root[data-theme="dark"] .composer-title,
:root[data-theme="dark"] .section-title,
:root[data-theme="dark"] .popover-header h3 {
  color: var(--text-primary);
}

:root[data-theme="dark"] .win-btn:hover {
  color: var(--text-primary);
}

:root[data-theme="dark"] .field-label,
:root[data-theme="dark"] .chevron-icon,
:root[data-theme="dark"] .popover-subtitle,
:root[data-theme="dark"] .input-hint {
  color: var(--text-secondary);
}

/* From row / profile badge */
:root[data-theme="dark"] .profile-badge {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  color: var(--text-primary);
}

:root[data-theme="dark"] .profile-badge:hover {
  background: #232825;
  border-color: #333a36;
}

/* Recipient chips, CSV badge, pills */
:root[data-theme="dark"] .recipient-chip,
:root[data-theme="dark"] .csv-summary-badge,
:root[data-theme="dark"] .custom-csv-btn {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  color: var(--text-primary);
}

:root[data-theme="dark"] .custom-csv-btn:hover {
  background: #232825;
  border-color: #333a36;
}

:root[data-theme="dark"] .chip-text {
  color: var(--text-primary);
}

:root[data-theme="dark"] .chip-avatar,
:root[data-theme="dark"] .chip-avatar-num,
:root[data-theme="dark"] .chip-avatar-icon {
  background: #2a302d;
  color: #d3ded8;
}

:root[data-theme="dark"] .btn-pill {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  color: var(--text-secondary);
}

:root[data-theme="dark"] .btn-pill:hover {
  background: #232825;
  color: var(--text-primary);
}

:root[data-theme="dark"] .divider {
  border-bottom-color: var(--border-light);
}

/* Subject + editor */
:root[data-theme="dark"] .subject-row {
  background: #111413;
  border-top-color: var(--border-light);
  border-bottom-color: var(--border-light);
}

:root[data-theme="dark"] .subject-field {
  caret-color: var(--text-primary);
}

:root[data-theme="dark"] .subject-field::placeholder,
:root[data-theme="dark"] .message-textarea::placeholder,
:root[data-theme="dark"] .message-visual[data-placeholder]:empty:before {
  color: var(--text-muted);
}

:root[data-theme="dark"] .editor-header-bar {
  border-bottom-color: var(--border-light);
}

:root[data-theme="dark"] .message-visual {
  color: #d8e2dd;
}

:root[data-theme="dark"] .toolbar-divider {
  background: #333a36;
}

/* Attachments */
:root[data-theme="dark"] .attachment-card {
  background: var(--bg-elevated);
}

:root[data-theme="dark"] .attachment-name {
  color: var(--text-primary);
}

:root[data-theme="dark"] .attachment-delete {
  color: var(--text-secondary);
}

:root[data-theme="dark"] .upload-box-icon {
  background: #232825;
  border-color: #333a36;
}

/* Top mode banner strip */
:root[data-theme="dark"] .top-mode-banner-strip {
  background: var(--bg-composer);
  border-bottom-color: var(--border-subtle);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Modals / popovers on the left pane */
:root[data-theme="dark"] .google-modal-card,
:root[data-theme="dark"] .popover-card {
  background: var(--bg-composer);
  border-color: var(--border-light);
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.7), 0 4px 16px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .modal-close-icon-btn {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

:root[data-theme="dark"] .modal-close-icon-btn:hover {
  background: #2a302d;
  color: var(--text-primary);
}

:root[data-theme="dark"] .google-modal-icon-badge,
:root[data-theme="dark"] .google-status-banner {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  color: var(--text-primary);
}

:root[data-theme="dark"] .google-header-text h3 {
  color: var(--text-primary);
}

:root[data-theme="dark"] .google-modal-subtitle,
:root[data-theme="dark"] .unit-badge,
:root[data-theme="dark"] .field-spacer-label {
  color: var(--text-secondary);
}

:root[data-theme="dark"] .google-settings-grid {
  background: #111413;
  border-color: var(--border-subtle);
}

:root[data-theme="dark"] .input-field-group label,
:root[data-theme="dark"] .toggle-option-label,
:root[data-theme="dark"] .input-group span,
:root[data-theme="dark"] .checkbox-label {
  color: var(--text-primary);
}

:root[data-theme="dark"] .input-with-unit input,
:root[data-theme="dark"] .input-group input[type="number"] {
  background: var(--bg-elevated);
  border-color: #333a36;
  color: var(--text-primary);
}

:root[data-theme="dark"] .btn-google-signin {
  background: var(--bg-elevated);
  border-color: #333a36;
  color: var(--text-primary);
}

:root[data-theme="dark"] .btn-google-signin:hover {
  background: #232825;
  border-color: #414a45;
}

:root[data-theme="dark"] .btn-disconnect-red {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}

:root[data-theme="dark"] .btn-disconnect-red:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

:root[data-theme="dark"] .popover-footer {
  border-top-color: var(--border-subtle);
}

:root[data-theme="dark"] .btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  color: var(--text-primary);
}

:root[data-theme="dark"] .btn-secondary:hover {
  background: #2a302d;
}


/* Chunk cooldown modal */
:root[data-theme="dark"] .chunk-cooldown-card {
  background: var(--bg-composer);
}

:root[data-theme="dark"] .cooldown-timer-text,
:root[data-theme="dark"] .cooldown-title {
  color: var(--text-primary);
}

:root[data-theme="dark"] .cooldown-subtitle {
  color: var(--text-secondary);
}

:root[data-theme="dark"] .cooldown-chunk-info {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Sender name input (theme-aware; was previously inline-styled) */
.from-name-input {
  height: 40px;
  padding: 10px 16px;
  border: 1px solid var(--border-light);
  border-radius: 22px;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text-primary);
  min-width: 220px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.from-name-input::placeholder {
  color: var(--text-muted);
}

.from-name-input:focus {
  border-color: var(--accent-blue);
}

/* Editor tab / toolbar buttons keep readable text in both themes */
.btn-open-side-drawer {
  color: var(--text-primary) !important;
  cursor: pointer;
}

.btn-open-side-drawer svg {
  stroke: currentColor;
}

:root[data-theme="dark"] .btn-open-side-drawer:hover {
  background: var(--bg-elevated) !important;
  border-color: #414a45 !important;
  color: #ffffff !important;
}

:root[data-theme="dark"] .editor-tab {
  color: var(--text-secondary);
}

:root[data-theme="dark"] .editor-tab svg {
  stroke: currentColor;
}

:root[data-theme="dark"] .editor-tab:hover,
:root[data-theme="dark"] .editor-tab:hover svg {
  color: var(--text-primary);
  stroke: currentColor;
}

/* Chunk chips */
:root[data-theme="dark"] .chunk-chip {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  color: var(--text-primary);
}

:root[data-theme="dark"] .chunk-chip.active-chunk {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93c5fd;
}

:root[data-theme="dark"] .chunk-chip.sent-chunk {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

:root[data-theme="dark"] .editor-mode-toggle {
  border-color: var(--border-light);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Footer attachment trigger + attachment drawer body */
.attachment-trigger-btn.has-attachment {
  border-color: rgba(2, 153, 37, 0.6);
}

.attachment-trigger-btn.has-attachment .var-trigger-text {
  color: #6ee7b7;
}

.drawer-attachments-section {
  margin-top: 0.25rem;
}

.drawer-attachments-section .attachments-container {
  margin-top: 0;
}

/* ==========================================================================
   VARIABLE TOKENS ({name}, {email}) — rendered as pills wherever they appear
   ========================================================================== */
.var-token {
  display: inline-block;
  padding: 0.05em 0.5em;
  margin: 0 1px;
  border-radius: 6px;
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #7c3aed;
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
  vertical-align: baseline;
  user-select: all;
}

:root[data-theme="dark"] .var-token {
  background: rgba(167, 139, 250, 0.18);
  border-color: rgba(167, 139, 250, 0.4);
  color: #c4b5fd;
}

/* Subject line: the input text is transparent and a mirror layer behind it
   paints the same string with the {variables} highlighted in place. The token
   style here must not change text metrics, so it uses background + box-shadow
   instead of padding/border and inherits the input's font. */
.subject-field-wrap {
  position: relative;
  flex: 1;
  display: flex;
  min-width: 0;
}

.subject-highlight-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  padding: 0.2rem 0;
  font-size: 1rem;
  font-weight: 400;
  font-family: inherit;
  line-height: normal;
  white-space: pre;
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.subject-field {
  color: transparent;
  caret-color: var(--text-primary);
  background: transparent;
  position: relative;
  z-index: 1;
}

.subject-field::selection {
  background: rgba(139, 92, 246, 0.3);
}

.subject-var-token {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  white-space: pre;
  border-radius: 3px;
  background: rgba(139, 92, 246, 0.16);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.16);
  color: #7c3aed;
}

:root[data-theme="dark"] .subject-var-token {
  background: rgba(167, 139, 250, 0.22);
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.22);
  color: #c4b5fd;
}

/* ==========================================================================
   ADD VARIABLE DRAWER
   Clean and flat, but every action stays visible and easy to hit.
   ========================================================================== */
#variable-drawer .drawer-content {
  width: min(94vw, 540px);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: #17191e;
  border-color: #262a31;
  padding: 1.25rem 1.5rem 1.4rem;
}

#variable-drawer .drawer-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

#variable-drawer .drawer-subtitle {
  font-size: 0.8rem;
  color: #9aa3af;
  margin-bottom: 0.85rem;
}

/* Scrollable list of variables */
#variable-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: #2f343c transparent;
}

#variable-list::-webkit-scrollbar {
  width: 6px;
}

#variable-list::-webkit-scrollbar-thumb {
  background: #2f343c;
  border-radius: 3px;
}

#variable-list .drawer-variable-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.75rem 0.85rem;
  background: #1d2027;
  border: 1px solid #262a31;
  border-radius: 10px;
  box-shadow: none;
  transform: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#variable-list .drawer-variable-card:hover,
#variable-list .drawer-variable-card:focus-visible {
  background: #232730;
  border-color: #8b5cf6;
  transform: none;
  box-shadow: none;
  outline: none;
}

#variable-list .var-badge-icon {
  width: auto;
  background: none;
  border: none;
  color: #8b5cf6;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  flex-shrink: 0;
}

#variable-list .var-card-name {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: #f1f5f9;
}

#variable-list .var-card-name::before {
  content: "{";
  color: #8b5cf6;
}

#variable-list .var-card-name::after {
  content: "}";
  color: #8b5cf6;
}

#variable-list .var-card-desc {
  font-size: 0.76rem;
  color: #9aa3af;
}

/* Always-visible insert action, so the row reads as clickable */
#variable-list .var-insert-pill {
  margin-left: auto;
  padding: 0.35rem 0.7rem;
  border-radius: 7px;
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.35);
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 700;
  color: #c4b5fd;
  opacity: 1;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

#variable-list .drawer-variable-card:hover .var-insert-pill {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #ffffff;
}

.custom-vars-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #6b7280;
  padding: 0.85rem 0.15rem 0.15rem;
}

/* ==========================================================================
   CUSTOM VARIABLES — remove control + add form
   ========================================================================== */
.custom-variable-list {
  display: contents;
}

.var-remove-btn {
  position: static;
  width: 26px;
  height: 26px;
  margin-left: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  line-height: 1;
  color: #9aa3af;
  background: rgba(255, 255, 255, 0.04);
  opacity: 1;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.var-remove-btn:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

/* Add form — labelled, with real fields and a solid button */
.add-variable-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border: none;
  border-top: 1px solid #262a31;
  background: none;
  flex-shrink: 0;
}

.add-variable-title {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #e2e8f0;
}

.add-variable-fields {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.add-variable-input {
  flex: 1 1 150px;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid #2f343c;
  border-radius: 9px;
  background: #1d2027;
  color: #f1f5f9;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.add-variable-input::placeholder {
  color: #6b7280;
}

.add-variable-input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.btn-add-variable {
  flex: 0 0 auto;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 9px;
  background: #8b5cf6;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.btn-add-variable:hover {
  background: #7c3aed;
}

.add-variable-hint {
  font-size: 0.73rem;
  color: #6b7280;
}
