/* SuperMail — Component Styles
   ═══════════════════════════════════════════════════════════════════════
   All UI components. Organized by feature area.
   ─────────────────────────────────────────────────────────────────────── */

/* ═══ TOP NAV (sidebar) ═══════════════════════════════════════════════ */

.sidebar {
  width: 100%;
  min-width: 0;
  height: 42px;
  flex-shrink: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  border-right: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0;
  overflow: hidden;
  user-select: none;
}

.sidebar-header {
  padding: 0 4px 0 16px;
  border: none;
  margin: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  height: 100%;
}

.sidebar-logo {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.sidebar-logo span { color: var(--primary); }

.ai-toggle-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: var(--radius-sm);
  margin-left: 6px; transition: all var(--transition);
  display: inline-flex; align-items: center; justify-content: center;
}
.ai-toggle-btn svg { opacity: 0.6; }
.ai-toggle-btn:hover { color: var(--text-strong); background: var(--hover); }
.ai-toggle-btn:hover svg { opacity: 1; }

.compose-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  margin: 0 10px 0 6px;
  padding: 0;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition);
  flex-shrink: 0;
}
.compose-btn:hover { background: var(--primary-hover); }
.compose-btn span:nth-child(2), .compose-btn kbd { display: none; }

/* ── Folder tabs ── */
.folder-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  height: 100%;
  flex-shrink: 0;
  gap: 0;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  height: 100%;
  white-space: nowrap;
  user-select: none;
}
.folder-item:hover { color: var(--text); background: var(--hover); }
.folder-item.active {
  color: var(--text-strong);
  border-bottom-color: transparent;
  font-weight: 500;
  background: var(--selected);
  border-radius: var(--radius-sm);
}
.folder-item .folder-icon { display: none; }
.folder-item .folder-count {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  margin-left: 2px; min-width: auto; text-align: left;
}
.folder-item.active .folder-count { color: var(--text-secondary); }

/* ── Bucket list in nav ── */
#bucketList {
  border-left: 1px solid var(--border);
  margin-left: 6px;
  padding-left: 4px;
}

.bucket-dot {
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.bucket-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
  flex: 1;
  min-width: 0;
}

.sidebar-section-title { display: none !important; }
.shortcuts-hint { display: none !important; }
.sidebar .bucket-manage-btn { display: none; }

/* ── Theme toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  border-radius: 6px;
  transition: all var(--transition);
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: 4px;
  height: 28px;
}
.theme-toggle:hover { color: var(--text); background: var(--hover); }
.theme-icon { font-size: 13px; }

/* Marco 2: Settings button (gear) in sidebar-footer, next to avatar */
.settings-btn {
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 6px; color: var(--text-secondary);
  margin-right: 6px; flex-shrink: 0; height: 30px; width: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.settings-btn:hover { color: var(--text-strong); background: var(--hover); }
.settings-btn svg { opacity: 0.85; }
.settings-btn:hover svg { opacity: 1; }

/* ── User (right side) ── */
.sidebar-footer {
  margin-left: auto;
  padding: 0 12px;
  border: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.sidebar-user span { display: none; }

.user-avatar {
  width: 26px; height: 26px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* ═══ MAIN AREA ═══════════════════════════════════════════════════════ */

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* ═══ TOOLBAR ═════════════════════════════════════════════════════════ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  height: 32px;
  min-height: 32px;
  flex-shrink: 0;
}

.toolbar-title {
  font-size: 11px; font-weight: 500;
  color: var(--text-muted);
  min-width: 60px; white-space: nowrap;
}

.search-box {
  flex: 0 1 280px;
  max-width: 280px;
  position: relative;
  transition: flex-basis 180ms ease, max-width 180ms ease;
}
.search-box:focus-within { flex-basis: 360px; max-width: 360px; }

.search-box input {
  width: 100%;
  padding: 4px 28px 4px 28px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

.search-box input::placeholder { color: var(--text-muted); }
.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.search-box .search-icon {
  position: absolute; left: 8px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex; align-items: center;
}

.search-box kbd {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px;
}

.toolbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.toolbar-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-muted); border-radius: 6px;
  cursor: pointer; font-size: 14px;
  transition: all var(--transition);
}
.toolbar-btn:hover { background: var(--hover); color: var(--text); }

/* ═══ CONTENT SPLIT ═══════════════════════════════════════════════════ */

.content-split {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ═══ EMAIL LIST ══════════════════════════════════════════════════════ */

.email-list {
  width: 100%;
  overflow-y: auto;
  background: var(--card);
  user-select: none;
  padding-bottom: 24px;
  container-type: inline-size;
}

/* ── Container queries: progressively collapse columns as list narrows ── */
@container (max-width: 820px) {
  .email-list .email-preview { display: none; }
  .email-list .email-sep { display: none; }
}
@container (max-width: 680px) {
  .email-list .email-sender { width: 100px; min-width: 100px; }
  .email-list .bucket-badge {
    font-size: 0;
    padding: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    line-height: 0;
  }
}
@container (max-width: 520px) {
  .email-list .email-badges { display: none; }
  .email-list .email-sender { width: 90px; min-width: 90px; }
}

/* ─ Split view (B.2): inbox + reader side-by-side on desktop ─ */
.email-reader {
  display: none;
  width: 520px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
}
#app.reader-open .email-reader { display: flex; }
.email-list { flex: 1; min-width: 0; }

/* ─ Overlay mode (Superhuman-style): reader opens as centered overlay
   over a dimmed inbox. Active when #app has .reader-mode-overlay class. ─ */
@media (min-width: 769px) {
  #app.reader-mode-overlay.reader-open .email-reader {
    display: flex;
    position: fixed;
    top: 42px;
    left: 50%;
    transform: translateX(-50%);
    width: min(880px, 92vw);
    height: calc(100vh - 64px);
    max-height: 100vh;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 10px);
    box-shadow: 0 20px 60px rgba(30, 25, 20, 0.20), 0 4px 16px rgba(30, 25, 20, 0.08);
    z-index: 200;
    background: var(--card);
    overflow: hidden;
  }
  #app.reader-mode-overlay.reader-open .email-list {
    filter: blur(1px) brightness(0.92);
    transition: filter 160ms ease;
    /* pointer-events MANTIDOS — permite scroll wheel e click outside
       para fechar reader; JS handler na lista gere o fecho */
  }
  #app.reader-mode-overlay.reader-open .split-divider { display: none; }
  /* Dim backdrop — nao bloqueia scroll nem interaccao (so visual) */
  #app.reader-mode-overlay.reader-open::before {
    content: '';
    position: fixed;
    inset: 42px 0 0 0;
    background: rgba(31, 30, 28, 0.28);
    z-index: 150;
    animation: puiFade 160ms ease;
    pointer-events: none;
  }
}

/* Divider between list and reader (drag to resize)
   Hitbox is 10px but visual line is 2px centered via pseudo-element */
.split-divider,
.ai-divider {
  display: none;
  width: 10px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 2;
}
.split-divider::before,
.ai-divider::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  transform: translateX(-50%);
  background: var(--border);
  transition: background 120ms ease, width 120ms ease;
}
.split-divider:hover::before,
.split-divider.dragging::before,
.ai-divider:hover::before,
.ai-divider.dragging::before {
  background: var(--primary);
  width: 3px;
}
#app.reader-open .split-divider { display: block; }
.ai-divider { display: none; }
.ai-divider.visible { display: block; }

/* Mobile (<768px): keep the swap behavior */
@media (max-width: 768px) {
  #app.reader-open .email-list { display: none; }
  #app.reader-open .email-reader {
    display: flex !important;
    width: 100% !important;
    border-left: none;
  }
  #app.reader-open .split-divider { display: none; }
  #app.reader-open .folder-list,
  #app.reader-open #bucketList,
  #app.reader-open .compose-btn,
  #app.reader-open .theme-toggle,
  #app.reader-open .toolbar { display: none !important; }
}

.email-list::-webkit-scrollbar { width: 4px; }
.email-list::-webkit-scrollbar-track { background: transparent; }
.email-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.email-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Date Group Separator (leveza: sem linha, subtitulo subtil) ── */
.email-date-group {
  display: flex; align-items: center;
  padding: 12px 12px 4px 20px;
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  background: var(--card);
  position: sticky; top: 0; z-index: 2;
  letter-spacing: 0.01em;
  opacity: 0.65;
}

/* ── Email item ── */
.email-item {
  display: flex; flex-direction: row; align-items: center;
  padding: 0 14px 0 20px;
  height: 36px;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  overflow: hidden;
  gap: 0;
}
.email-item:hover { background: var(--hover); }
.email-item + .email-item { border-top: none; }
.email-item.selected { background: var(--selected); }

.email-item.selected::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--primary);
  opacity: 0.7;
}

.email-item.unread::after {
  content: '';
  position: absolute;
  left: 8px; top: 50%;
  transform: translateY(-50%);
  width: 5px; height: 5px;
  background: var(--primary);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  opacity: 0.6;
}

.email-item.multi-selected { background: var(--primary-light); }
.email-item.multi-selected .email-date::after {
  content: '\2713';
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: 3px;
  background: var(--primary); color: #fff;
  font-size: 10px; margin-left: 4px;
}

.load-more-btn {
  text-align: center; padding: 14px 16px;
  color: var(--primary); font-size: 13px; font-weight: 500;
  cursor: pointer; border-top: 1px solid var(--border);
  transition: background var(--transition);
}
.load-more-btn:hover { background: var(--primary-light); }

/* ── Sender column (leveza: read = muted normal, unread = strong 600) ── */
.email-sender {
  font-size: 12px; font-weight: 400; color: var(--text-muted);
  width: 140px; min-width: 140px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex-shrink: 0; padding-right: 8px;
}
.email-item.unread .email-sender { font-weight: 600; color: var(--text-strong, var(--text)); }

/* ── Subject + preview ── */
.email-subject-line {
  flex: 1; display: flex; align-items: center;
  min-width: 0; overflow: hidden; gap: 0;
}
.email-subject {
  font-size: 12px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex-shrink: 1; max-width: none;
}
.email-item.unread .email-subject { font-weight: 500; }

/* B.5 leveza: esconder preview do corpo — so assunto na lista.
   Rows mais leves, assuntos com mais espaco horizontal. Container
   queries continuam validas (colapsam badges, etc). */
.email-sep { display: none; }
.email-preview { display: none; }

/* ── Date column ── */
.email-date {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
  min-width: 44px; text-align: right; padding-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* ── Badges & buckets ── */
.email-badges {
  display: flex; gap: 3px; align-items: center;
  flex-shrink: 0; margin-right: 4px;
}
.badge-attachment { font-size: 11px; color: var(--text-muted); opacity: 0.7; }

.email-buckets {
  display: flex; gap: 3px; margin: 0;
  flex-shrink: 0; margin-right: 6px;
}

/* B.3 leveza: badge como dot inline + texto muted (sem pill colorido) */
.bucket-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 400;
  padding: 0 2px;
  background: transparent !important;
  color: var(--text-muted) !important;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 1;
}
.bucket-badge .bb-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}
.bucket-badge.suggested {
  opacity: 0.55;
  cursor: pointer;
  font-style: italic;
  transition: opacity 0.15s;
}
.bucket-badge.suggested:hover { opacity: 0.9; }
.bb-conf { font-size: 9px; opacity: 0.7; margin-left: 2px; font-style: normal; }

.email-row-top { display: contents; }

/* ═══ EMAIL READER ════════════════════════════════════════════════════ */

/* Desktop (split view): fixed 520px width, does NOT flex-grow.
   Mobile (swap view): flex: 1 so it fills width when taking over. */
.email-reader {
  overflow-y: auto; padding: 0;
  flex-direction: column;
  background: var(--card);
}
@media (max-width: 768px) {
  .email-reader { flex: 1; }
}

.email-reader::-webkit-scrollbar { width: 6px; }
.email-reader::-webkit-scrollbar-track { background: transparent; }
.email-reader::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.reader-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted); gap: 12px;
}
.reader-empty .empty-icon { font-size: 48px; opacity: 0.3; }
.reader-empty p { font-size: 13px; }
.reader-empty .shortcuts-list {
  font-size: 11px; color: var(--text-muted);
  text-align: center; line-height: 2; margin-top: 20px;
}
.reader-empty .shortcuts-list kbd {
  display: inline-block; padding: 2px 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 11px;
  font-family: inherit; min-width: 22px; text-align: center;
}

.reader-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px;
  color: var(--text-secondary);
  margin-right: 16px; flex-shrink: 0;
  transition: all var(--transition);
}
.reader-back:hover { background: var(--hover); color: var(--text); }

/* B.2: on desktop split view, the back arrow is replaced by a close (×) */
@media (min-width: 769px) {
  .reader-back { display: none; }
}
@media (max-width: 768px) {
  .reader-close { display: none; }
}
.reader-close {
  background: transparent;
  border: none;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  flex-shrink: 0;
}
.reader-close:hover { background: var(--hover); color: var(--text); }

.reader-header {
  padding: 14px 24px 10px;
  border-bottom: 1px solid var(--border);
}

.reader-subject {
  font-size: 16px; font-weight: 500;
  color: var(--text-strong);
  margin-bottom: 8px; line-height: 1.35;
  letter-spacing: -0.01em;
}

.reader-meta { display: flex; align-items: center; gap: 10px; }

.reader-avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  background: var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}

.reader-meta-info { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.reader-from { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; }
.reader-from-email { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.reader-to { font-size: 11px; color: var(--text-muted); width: 100%; margin-top: 1px; }
.reader-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; margin-left: auto; }

.reader-actions {
  display: flex; gap: 4px; padding: 4px 24px;
  background: transparent; opacity: 0.5;
  transition: opacity 0.15s;
}
.reader-actions:hover { opacity: 1; }

/* B.3 leveza: action buttons mais respiravel, opacity natural baixa */
.action-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px; font-size: 11px; font-weight: 400;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
  cursor: pointer; font-family: inherit;
  transition: all var(--transition);
  opacity: 0.75;
}
.action-btn:hover {
  background: var(--hover);
  color: var(--text);
  opacity: 1;
}
.action-btn kbd { display: none; }
.action-btn svg { flex-shrink: 0; display: block; opacity: 0.9; }

/* Claude-like editorial body: serif Source Serif Pro, generous line-height,
   slightly larger size for readability, letter-spacing natural (0) */
.reader-body {
  flex: 1; max-width: 720px;
  padding: 24px 28px;
  font-family: var(--font-serif, 'Source Serif Pro', Georgia, serif);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  letter-spacing: 0;
  overflow-y: auto; padding-bottom: 40px;
}
/* Emails com HTML inline styles podem sobrescrever — serif aplica-se
   a paragrafos soltos e texto simples. Emails-newsletter com CSS inline
   pesado mantem o seu proprio rendering. */
.reader-body p, .reader-body li, .reader-body blockquote { font-family: inherit; }
.reader-body img { max-width: 100%; height: auto; }
.reader-body a { color: var(--primary); }
.reader-body blockquote {
  border-left: 3px solid var(--border);
  margin: 12px 0; padding: 4px 16px;
  color: var(--text-secondary);
}

/* ═══ ATTACHMENTS ═════════════════════════════════════════════════════ */

.reader-attachments {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.attachments-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.attachments-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.download-all-btn {
  font-size: 11px; color: var(--primary); background: none; border: none;
  cursor: pointer; font-family: inherit; font-weight: 500; padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.download-all-btn:hover { background: var(--primary-light); }
.attachments-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--hover);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; cursor: pointer; max-width: 260px;
  transition: border-color 0.15s, background 0.15s;
}
.attachment-chip:hover { border-color: var(--primary); background: var(--selected); }

.att-icon { width: 16px; height: 16px; flex-shrink: 0; }
.att-icon svg { width: 16px; height: 16px; }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.att-size { color: var(--text-secondary); font-size: 11px; white-space: nowrap; }
.att-download {
  background: none; border: none; cursor: pointer;
  padding: 0 2px; color: var(--text-secondary);
  opacity: 0.5; transition: opacity 0.15s;
}
.att-download:hover { opacity: 1; color: var(--primary); }

/* ═══ COMPOSE ═════════════════════════════════════════════════════════ */

.compose-overlay {
  position: fixed; inset: 0;
  background: rgba(31, 30, 28, 0.45);
  z-index: 1000; display: none;
  align-items: center; justify-content: center;
  padding: 40px;
}
.compose-overlay.open { display: flex; }

.compose-window {
  width: 640px; max-width: 100%; max-height: 80vh;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideUp 0.2s ease;
}

.compose-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.compose-title { font-size: 13px; font-weight: 600; color: var(--text); }

.compose-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-radius: 6px; font-size: 16px;
}
.compose-close:hover { background: var(--hover); color: var(--text); }

.compose-fields { padding: 0 16px; border-bottom: 1px solid var(--border); }
.compose-field {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.compose-field:last-child { border-bottom: none; }
.compose-field label { font-size: 12px; color: var(--text-muted); min-width: 50px; font-weight: 500; }
.compose-field input {
  flex: 1; border: none; font-size: 13px; color: var(--text);
  outline: none; font-family: inherit; background: transparent;
}
.compose-field input::placeholder { color: var(--text-muted); }

.compose-body-wrap { flex: 1; min-height: 200px; overflow-y: auto; }
.compose-body {
  padding: 16px; font-size: 14px; line-height: 1.65;
  color: var(--text); outline: none; min-height: 200px;
  font-family: var(--font-serif, inherit);
}
.compose-body:empty::before { content: attr(data-placeholder); color: var(--text-muted); }

.compose-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.send-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 20px; background: var(--primary); color: #fff;
  border: none; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  transition: background var(--transition);
}
.send-btn:hover { background: var(--primary-hover); }
.send-btn kbd {
  font-size: 10px; background: rgba(255, 255, 255, 0.2);
  padding: 1px 5px; border-radius: 3px;
}

.compose-toolbar-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-radius: 6px; font-size: 14px;
}
.compose-toolbar-btn:hover { background: var(--hover); color: var(--text); }

.compose-toolbar-separator { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

.compose-toolbar-btn.ai-btn {
  background: var(--primary);
  color: #fff; width: auto; padding: 0 10px;
  font-size: 11px; font-weight: 500; gap: 4px;
  letter-spacing: 0;
}
.compose-toolbar-btn.ai-btn:hover {
  background: var(--primary-hover);
  color: #fff;
}

.discard-btn {
  margin-left: auto; padding: 6px 12px;
  font-size: 12px; color: var(--text-muted);
  background: transparent; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-family: inherit;
}
.discard-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ── Compose attachments ── */
.compose-attachments {
  padding: 8px 16px; border-top: 1px solid var(--border);
  max-height: 120px; overflow-y: auto;
}
.compose-attachments-list { display: flex; flex-wrap: wrap; gap: 6px; }
.compose-att-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 8px; background: var(--hover);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; position: relative; overflow: hidden;
}
.compose-att-chip.uploading { opacity: 0.7; }
.compose-att-chip.error { border-color: #ef4444; color: #ef4444; }
.compose-att-chip.done { border-color: #10b981; }
.att-progress { position: absolute; bottom: 0; left: 0; height: 2px; background: var(--primary); transition: width 0.3s; }
.att-remove {
  background: none; border: none; cursor: pointer;
  padding: 0; font-size: 14px; line-height: 1;
  color: var(--text-secondary);
}
.att-remove:hover { color: #ef4444; }

.compose-body-wrap.drag-over {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  background: var(--primary-light);
}

/* ═══ AI DRAFT MODAL ══════════════════════════════════════════════════ */

.ai-draft-modal {
  position: absolute; bottom: 56px; left: 16px; right: 16px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  z-index: 10; animation: cmdIn 0.15s ease;
}
.ai-draft-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg); border-radius: var(--radius) var(--radius) 0 0;
}
.ai-draft-header span { font-size: 12px; font-weight: 600; color: var(--text); }
.ai-draft-close {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-radius: var(--radius-sm); font-size: 14px;
}
.ai-draft-close:hover { background: var(--hover); }
.ai-draft-body { padding: 12px; }

.ai-draft-textarea {
  width: 100%; min-height: 60px; max-height: 120px;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; font-family: inherit;
  color: var(--text); resize: vertical; outline: none;
  background: var(--card);
}
.ai-draft-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.12); }
.ai-draft-textarea::placeholder { color: var(--text-muted); }

.ai-draft-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }

.ai-draft-btn {
  padding: 6px 14px; font-size: 12px; font-weight: 500;
  border: none; border-radius: 6px; cursor: pointer;
  font-family: inherit; transition: all var(--transition);
}
.ai-draft-btn.primary { background: var(--primary); color: #fff; }
.ai-draft-btn.primary:hover { background: var(--primary-hover); }
.ai-draft-btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-draft-btn.secondary { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.ai-draft-btn.secondary:hover { background: var(--hover); }

.ai-draft-spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff; border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
  margin-right: 4px; vertical-align: middle;
}

/* ═══ TEMPLATES DRAWER ════════════════════════════════════════════════ */

.templates-drawer {
  position: absolute; bottom: 56px; left: 16px;
  width: 300px; max-height: 320px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  z-index: 10; display: flex; flex-direction: column;
  animation: cmdIn 0.15s ease;
}
.templates-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg); border-radius: var(--radius) var(--radius) 0 0;
}
.templates-drawer-header span { font-size: 12px; font-weight: 600; color: var(--text); }
.templates-drawer-close {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-radius: var(--radius-sm); font-size: 14px;
}
.templates-drawer-close:hover { background: var(--hover); }
.templates-drawer-search { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.templates-drawer-search input {
  width: 100%; padding: 6px 10px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 6px;
  outline: none; font-family: inherit; color: var(--text);
  background: var(--bg);
}
.templates-drawer-search input:focus { border-color: var(--primary); }
.templates-list { flex: 1; overflow-y: auto; padding: 4px 0; }

.template-item {
  padding: 10px 12px; cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.template-item:last-child { border-bottom: none; }
.template-item:hover { background: var(--hover); }
.template-item-name { font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.template-item-preview { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-item-category {
  display: inline-block; font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--primary); background: var(--primary-light);
  padding: 1px 6px; border-radius: 3px; margin-top: 4px;
}
.templates-empty { padding: 24px 12px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* ── Snippet chips ── */
.snippet-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.snippet-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; font-size: 11px; font-weight: 500;
  color: var(--text-secondary); background: var(--bg);
  border: 1px solid var(--border); border-radius: 20px;
  cursor: pointer; transition: all var(--transition);
}
.snippet-chip:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ═══ BUCKET MANAGER MODAL ════════════════════════════════════════════ */

/* Bucket sidebar section */
.sidebar-section-title {
  font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted);
  padding: 12px 16px 4px; font-weight: 600;
}

.bucket-dot { width: 8px; height: 8px; border-radius: var(--radius-full); flex-shrink: 0; }
.bucket-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }

.bucket-manage-btn {
  float: right; background: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px; line-height: 1;
  padding: 1px 6px; cursor: pointer; font-family: inherit;
  transition: all var(--transition);
}
.bucket-manage-btn:hover { color: var(--primary); border-color: var(--primary); }

.bucket-mgr-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.3); align-items: center; justify-content: center;
}
.bucket-mgr-overlay.open { display: flex; }
.bucket-mgr {
  background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  width: 420px; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column;
}
.bucket-mgr-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.bucket-mgr-header h3 { font-size: 15px; font-weight: 600; }
.bucket-mgr-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.bucket-mgr-body { padding: 12px 20px; overflow-y: auto; flex: 1; }
.bucket-mgr-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.bucket-mgr-item:last-child { border-bottom: none; }
.bucket-mgr-dot {
  width: 14px; height: 14px; border-radius: var(--radius-full); flex-shrink: 0; cursor: pointer;
  border: 2px solid transparent; transition: border-color 0.15s;
}
.bucket-mgr-dot:hover { border-color: var(--text-muted); }
.bucket-mgr-name { flex: 1; font-size: 13px; }
.bucket-mgr-name input {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px 8px; font-size: 13px; font-family: inherit;
}
.bucket-mgr-del {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 14px; padding: 4px 6px; border-radius: var(--radius-sm); transition: all 0.15s;
}
.bucket-mgr-del:hover { color: var(--danger); background: rgba(234, 67, 53, 0.08); }
.bucket-mgr-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: space-between;
}
.bucket-mgr-add {
  background: none; border: 1px dashed var(--border); border-radius: 6px;
  padding: 6px 14px; font-size: 13px; cursor: pointer; color: var(--text-secondary);
  font-family: inherit; transition: all 0.15s;
}
.bucket-mgr-add:hover { border-color: var(--primary); color: var(--primary); }
.bucket-mgr-save {
  background: var(--primary); color: #fff; border: none; border-radius: 6px;
  padding: 6px 18px; font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: inherit; transition: background 0.15s;
}
.bucket-mgr-save:hover { background: var(--primary-hover); }

.color-picker-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  padding: 8px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  position: absolute; z-index: 210;
}
.color-picker-swatch {
  width: 22px; height: 22px; border-radius: var(--radius-full); cursor: pointer;
  border: 2px solid transparent; transition: border-color 0.15s, transform 0.1s;
}
.color-picker-swatch:hover { border-color: var(--text); transform: scale(1.15); }
.color-picker-swatch.active { border-color: var(--text); }

/* ═══ LABEL MENU ══════════════════════════════════════════════════════ */

.label-menu-overlay { position: fixed; inset: 0; z-index: 1500; display: none; }
.label-menu-overlay.open { display: block; }

.label-menu {
  position: absolute; width: 220px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  overflow: hidden; animation: cmdIn 0.12s ease;
}
.label-menu-header {
  padding: 8px 12px; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.label-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; font-size: 13px; color: var(--text);
  cursor: pointer; transition: background var(--transition);
}
.label-menu-item:hover { background: var(--hover); }
.label-menu-item .label-check { width: 16px; font-size: 12px; color: var(--primary); text-align: center; }
.label-menu-item .label-key {
  margin-left: auto; font-size: 10px; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  padding: 0 5px; border-radius: 3px;
}

/* ═══ COMMAND PALETTE ═════════════════════════════════════════════════ */

.cmd-overlay {
  position: fixed; inset: 0;
  background: rgba(31, 30, 28, 0.5);
  z-index: 2000; display: none;
  align-items: flex-start; justify-content: center;
  padding-top: 20vh;
}
.cmd-overlay.open { display: flex; }

.cmd-palette {
  width: 560px; max-width: 90vw;
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden; animation: cmdIn 0.15s ease;
}

.cmd-input-wrap { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cmd-input {
  width: 100%; border: none; font-size: 15px;
  color: var(--text); outline: none;
  font-family: inherit; background: transparent;
}
.cmd-input::placeholder { color: var(--text-muted); }

.cmd-results { max-height: 320px; overflow-y: auto; }
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer;
  transition: background var(--transition);
}
.cmd-item:hover, .cmd-item.active { background: var(--selected); }
.cmd-item .cmd-icon { font-size: 16px; width: 24px; text-align: center; color: var(--text-muted); }
.cmd-item .cmd-label { font-size: 13px; color: var(--text); flex: 1; }
.cmd-item .cmd-shortcut { font-size: 11px; color: var(--text-muted); }
.cmd-item .cmd-shortcut kbd {
  display: inline-block; padding: 1px 5px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 3px; font-size: 10px; font-family: inherit;
}

/* ═══ SHORTCUTS PANEL ═════════════════════════════════════════════════ */

.shortcuts-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2000; display: none;
  align-items: center; justify-content: center;
}
.shortcuts-overlay.open { display: flex; }

.shortcuts-panel {
  width: 480px; max-width: 90vw; max-height: 80vh;
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow-y: auto; padding: 24px;
}
.shortcuts-panel h2 { font-size: 16px; font-weight: 600; margin-bottom: 20px; color: var(--text); }
.shortcuts-section { margin-bottom: 20px; }
.shortcuts-section h3 {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted);
  margin-bottom: 8px; font-weight: 600;
}
.shortcut-row {
  display: flex; justify-content: space-between;
  align-items: center; padding: 4px 0; font-size: 13px;
}
.shortcut-row .shortcut-desc { color: var(--text-secondary); }
.shortcut-row kbd {
  display: inline-block; padding: 2px 7px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 11px;
  font-family: inherit; min-width: 24px; text-align: center;
}

/* ═══ LIGHTBOX ════════════════════════════════════════════════════════ */

.lightbox-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000; display: flex;
  align-items: center; justify-content: center;
}
.lightbox-close {
  position: absolute; top: 16px; right: 24px;
  background: none; border: none; color: #fff;
  font-size: 32px; cursor: pointer; z-index: 2001; line-height: 1;
}
.lightbox-close:hover { opacity: 0.7; }
.lightbox-content img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: var(--radius-sm); }
.lightbox-content iframe { width: 80vw; height: 85vh; border: none; border-radius: var(--radius-sm); background: #fff; }

/* ═══ TOAST NOTIFICATIONS ═════════════════════════════════════════════ */

.toast-container {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
}

.toast {
  padding: 10px 20px; background: var(--text); color: #fff;
  border-radius: var(--radius); font-size: 13px;
  box-shadow: var(--shadow-md); animation: toastIn 0.2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.toast-undo {
  margin-left: 12px; padding: 2px 10px;
  background: rgba(255, 255, 255, 0.2); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.toast-undo:hover { background: rgba(255, 255, 255, 0.35); }

/* ═══ SHORTCUT BAR ════════════════════════════════════════════════════ */

.shortcut-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 24px; background: var(--card);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; user-select: none; flex-shrink: 0;
}
.shortcut-item {
  display: flex; align-items: center; gap: 5px;
  padding: 0 14px; height: 100%;
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap;
  opacity: 0.65;
  transition: opacity var(--transition);
}
.shortcut-item:hover { opacity: 0.95; }
.shortcut-item kbd {
  display: inline-block; padding: 1px 5px;
  border: 1px solid var(--border); border-bottom-width: 1px;
  border-radius: 3px; font-size: 10px; font-family: inherit;
  background: var(--bg); color: var(--text-secondary);
  font-weight: 600; line-height: 1.5;
}
