/* ========================================
   INBOX LIST VIEW - Triage Client Pro
   Modern, polished email list component
   ======================================== */

/* ========================================
   Actions Alert Bar
   ======================================== */
.actions-alert-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #e8f4fd 0%, #f0f7ff 100%);
  border: 1px solid #b8d4f0;
  border-radius: 8px;
  padding: 10px 16px;
  margin: 0 16px 12px 16px;
  box-shadow: 0 2px 4px rgba(0, 51, 102, 0.08);
}

.actions-alert-bar .alert-bar-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}

.actions-alert-bar .alert-bar-title {
  font-weight: 600;
  color: #1a5490;
  font-size: 13px;
  white-space: nowrap;
}

.actions-alert-bar .alert-bar-items {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.actions-alert-bar .alert-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: white;
  border: 1px solid #d0e3f5;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.actions-alert-bar .alert-item:hover {
  background: #1a73e8;
  color: white;
  border-color: #1a73e8;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(26, 115, 232, 0.3);
}

.actions-alert-bar .alert-item .alert-icon {
  font-size: 14px;
}

.actions-alert-bar .alert-item .alert-count {
  background: #1a73e8;
  color: white;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
}

.actions-alert-bar .alert-item:hover .alert-count {
  background: white;
  color: #1a73e8;
}

.actions-alert-bar .alert-bar-dismiss {
  background: none;
  border: none;
  font-size: 18px;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.actions-alert-bar .alert-bar-dismiss:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

/* Dark mode support */
[data-theme="dark"] .actions-alert-bar {
  background: linear-gradient(135deg, #1e3a5f 0%, #1a2d47 100%);
  border-color: #2d4a6f;
}

[data-theme="dark"] .actions-alert-bar .alert-bar-title {
  color: #8bb8e8;
}

[data-theme="dark"] .actions-alert-bar .alert-item {
  background: #243b55;
  border-color: #3a5a7c;
  color: #e0e0e0;
}

[data-theme="dark"] .actions-alert-bar .alert-item:hover {
  background: #4a90d9;
  border-color: #4a90d9;
}

[data-theme="dark"] .actions-alert-bar .alert-bar-dismiss {
  color: #888;
}

[data-theme="dark"] .actions-alert-bar .alert-bar-dismiss:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

/* Mobile responsive */
@media (max-width: 600px) {
  .actions-alert-bar {
    margin: 0 8px 8px 8px;
    padding: 8px 12px;
  }

  .actions-alert-bar .alert-bar-title {
    display: none;
  }

  .actions-alert-bar .alert-item {
    padding: 3px 8px;
    font-size: 11px;
  }
}

/* ========================================
   Swipe Gestures (Mobile)
   ======================================== */

/* Swipe hint backgrounds during drag */
.email-row.swiping-right {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.15) 0%, transparent 50%) !important;
}

.email-row.swiping-left {
  background: linear-gradient(270deg, rgba(220, 38, 38, 0.15) 0%, transparent 50%) !important;
}

/* Pending undo state */
.email-row.swipe-pending {
  padding: 0 !important;
  min-height: auto !important;
}

.swipe-undo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  color: white;
  border-radius: 8px;
  margin: 2px 0;
}

.swipe-undo-btn {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.swipe-undo-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

.swipe-action-label {
  font-weight: 500;
  font-size: 14px;
}

.swipe-countdown {
  display: flex;
  align-items: center;
  gap: 8px;
}

.countdown-bar {
  width: 60px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.countdown-bar::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  background: white;
  animation: countdown 5s linear forwards;
}

@keyframes countdown {
  from { width: 100%; }
  to { width: 0%; }
}

.countdown-text {
  font-size: 13px;
  font-weight: 600;
  min-width: 24px;
}

.swipe-skip-btn {
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-left: auto;
}

.swipe-skip-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Hide actions bars when viewing an email */
body.viewing-email #actions-alert-bar,
body.viewing-email #actions-needed-bar {
  display: none !important;
}

/* Mobile touch feedback - enable horizontal swipe by restricting to vertical pan only */
@media (pointer: coarse) {
  .email-row,
  .inbox-email-row {
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
  }
}

/* Display Density Settings */
:root {
  --inbox-row-padding: 12px 16px;
  --inbox-row-gap: 12px;
  --inbox-row-min-height: 72px;
  --inbox-font-size: 14px;
  --inbox-subject-size: 14px;
  --inbox-snippet-size: 13px;
  --inbox-meta-size: 12px;
  --inbox-avatar-size: 40px;
  --inbox-checkbox-gap: 12px;
}

[data-density="compact"] {
  --inbox-row-padding: 3px 12px;
  --inbox-row-gap: 1px;
  --inbox-row-min-height: 32px;
  --inbox-font-size: 13px;
  --inbox-subject-size: 13px;
  --inbox-snippet-size: 11px;
  --inbox-meta-size: 11px;
  --inbox-avatar-size: 24px;
  --inbox-checkbox-gap: 4px;
}

/* Tighter info spacing - gap between sender/subject/summary */
[data-density="compact"] .email-info {
  gap: 0px;
}

/* Tighter meta spacing */
[data-density="compact"] .email-meta {
  gap: 2px;
}

/* Smaller attachment icon and action icons in compact mode */
[data-density="compact"] .email-attachment-icon {
  font-size: 12px;
}

[data-density="compact"] .action-icon {
  font-size: 11px;
}

[data-density="compact"] .action-icons {
  margin-left: 4px;
  gap: 2px;
}

/* Thread badge in compact mode */
[data-density="compact"] .thread-badge {
  margin-left: 5px;
  padding: 1px 5px;
  gap: 2px;
}

[data-density="compact"] .thread-icon {
  font-size: 10px;
}

[data-density="compact"] .thread-count {
  font-size: 10px;
}

[data-density="spacious"] {
  --inbox-row-padding: 16px 20px;
  --inbox-row-gap: 16px;
  --inbox-row-min-height: 88px;
  --inbox-font-size: 15px;
  --inbox-subject-size: 15px;
  --inbox-snippet-size: 14px;
  --inbox-meta-size: 13px;
  --inbox-avatar-size: 44px;
  --inbox-checkbox-gap: 16px;
}

/* Container */
#inbox-list-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  position: relative;
}

/* Empty State */
.inbox-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.inbox-empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.inbox-empty-state .empty-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.inbox-empty-state .empty-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Loading State */
.inbox-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.inbox-loading-state .loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: var(--primary, #1a73e8);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

.inbox-loading-state .loading-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pinned Section */
.inbox-pinned-section {
  background: #fffbf0;
  border-bottom: 2px solid #ffd54f;
  padding-bottom: 0.5rem;
}

.pinned-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #f57c00;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

/* Email Row */
.inbox-email-row {
  display: grid;
  grid-template-columns: var(--inbox-avatar-size) 90px 1fr 80px;
  gap: var(--inbox-row-gap);
  align-items: center;
  padding: var(--inbox-row-padding);
  border-bottom: 1px solid #f0f0f0;
  border-left: 4px solid transparent; /* default, overridden by JS */
  cursor: pointer;
  transition: all 0.15s ease, border-color 0.2s;
  background: #fff;
  min-height: var(--inbox-row-min-height);
}

.inbox-email-row:hover {
  background: #f8f9fa;
  box-shadow: inset 0 0 0 1px #e0e0e0;
  transform: translateX(2px);
}

.inbox-email-row.unread {
  background: #e8f4fd;  /* Light blue tint for unread */
}

.inbox-email-row.unread .email-sender {
  font-weight: 700;
  color: #1a1a1a;
}

.inbox-email-row.unread .email-subject-text {
  font-weight: 600;
  color: #1a1a1a;
}

/* Read emails - more muted */
.inbox-email-row:not(.unread) {
  background: #fafafa;
}

.inbox-email-row:not(.unread) .email-sender {
  font-weight: 400;
  color: #5f6368;
}

.inbox-email-row:not(.unread) .email-subject-text {
  font-weight: 400;
  color: #5f6368;
}

/* Removed unread blue left border - now using account colors instead */

.inbox-email-row.selected {
  background: #e3f2fd !important;
  box-shadow: inset 0 0 0 2px #1976d2;
}

.inbox-email-row.focused {
  outline: 2px solid #1976d2;
  outline-offset: -2px;
  z-index: 1;
}

.inbox-email-row.pinned {
  background: #fffbf0;
}

/* User verified badge - user has reviewed/corrected AI */
.email-verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: bold;
  color: #fff;
  background: #4caf50;
  border-radius: 50%;
  margin-left: 4px;
}

/* Completed action icon */
.action-icon.completed {
  opacity: 0.5;
  text-decoration: line-through;
  position: relative;
}

.action-icon.completed::after {
  content: '✓';
  position: absolute;
  top: -2px;
  right: -4px;
  font-size: 8px;
  color: #4caf50;
  font-weight: bold;
}

/* Checkbox */
.email-checkbox-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.email-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

/* Category + Urgency Column */
.email-category-urgency {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Legacy: Category + Actions Column (remove after migration) */
.email-category-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--inbox-row-gap);
}

/* Category Badge */
.email-category-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 4px;
  color: white;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* Email Info */
.email-info {
  display: flex;
  flex-direction: column;
  gap: var(--inbox-row-gap);
  min-width: 0; /* Allow text truncation */
}

.email-sender-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.email-sender {
  font-size: var(--inbox-font-size);
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
}

.inbox-email-row:not(.unread) .email-sender {
  font-weight: 500;
}

/* Thread Badge - for emails with multiple messages in a thread */
.thread-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  padding: 2px 7px;
  background: #e8f0fe;
  border: 1px solid #c2d9f7;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: #1967d2;
  vertical-align: middle;
  line-height: 1;
}

.thread-icon {
  font-size: 12px;
  line-height: 1;
  opacity: 0.9;
}

.thread-count {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.email-subject {
  font-size: var(--inbox-subject-size);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0; /* Allow flex item to shrink below content size */
}

/* Subject text wrapper to allow truncation while preserving icons */
.email-subject-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  color: inherit; /* Inherit color from parent */
}

.inbox-email-row:not(.unread) .email-subject,
.inbox-email-row:not(.unread) .email-subject-text {
  color: var(--text-secondary);
}

.email-summary {
  font-size: var(--inbox-snippet-size);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

/* Email Meta */
.email-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--inbox-row-gap);
  font-size: var(--inbox-meta-size);
}

.email-date-row {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.email-date {
  color: var(--text-secondary);
  white-space: nowrap;
}

.email-attachment-icon {
  font-size: 15px;
  opacity: 1;
  line-height: 1;
  filter: grayscale(0);
  color: #5f6368;
  font-weight: 500;
  transition: transform 0.2s ease;
}

.email-attachment-icon:hover {
  transform: scale(1.15);
}

.email-stale-indicator {
  font-size: 14px;
  color: #f59e0b;
  animation: pulse-stale 2s ease-in-out infinite;
  cursor: help;
}

@keyframes pulse-stale {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.email-stale-indicator:hover {
  animation: none;
  opacity: 1;
}

.email-confidence {
  padding: 2px 6px;
  border-radius: 10px;
  background: #4caf50;
  color: white;
  font-size: 11px;
  font-weight: 600;
}

.email-confidence.low {
  background: #ff9800;
}

/* Time display (replaces confidence for most users) */
.email-time {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
}

[data-theme="dark"] .email-time {
  color: #999;
}

/* Urgency Badge */
.email-urgency {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.email-urgency.urgency-medium {
  background: #fff3cd;
  color: #856404;
}

.email-urgency.urgency-high,
.email-urgency.urgency-urgent {
  background: #fce8e6;
  color: #c5221f;
}

.email-urgency.urgency-critical {
  background: #c5221f;
  color: white;
}

.email-urgency.urgency-overdue {
  background: #7b1113;
  color: white;
  animation: pulse-urgent 1.5s infinite;
}

@keyframes pulse-urgent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Quick Actions - now inside category column */
.email-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.inbox-email-row:hover .email-actions,
.inbox-email-row.focused .email-actions {
  opacity: 1;
}

/* Keep actions visible but compact */
.email-category-actions .email-actions {
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90px;
}

.action-btn {
  padding: 3px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
}

.action-btn:hover {
  background: #e0e0e0;
  border-color: #ccc;
  transform: scale(1.1);
}

.action-btn.active {
  background: #ffd54f;
  border-color: #ffc107;
}

/* Batch Actions Toolbar */
#inbox-batch-toolbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #e3f2fd;
  border-bottom: 2px solid #1976d2;
}

#inbox-batch-toolbar .selected-count {
  font-weight: 600;
  color: #1976d2;
  margin-right: auto;
}

#inbox-batch-toolbar .batch-btn {
  padding: 6px 12px;
  background: white;
  border: 1px solid #1976d2;
  border-radius: 4px;
  color: #1976d2;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

#inbox-batch-toolbar .batch-btn:hover {
  background: #1976d2;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#inbox-batch-toolbar .batch-btn.danger {
  border-color: #d32f2f;
  color: #d32f2f;
}

#inbox-batch-toolbar .batch-btn.danger:hover {
  background: #d32f2f;
  color: white;
}

/* Animations */
@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.inbox-email-row {
  animation: fadeIn 0.2s ease;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .inbox-email-row {
    grid-template-columns: 40px 70px 1fr 80px;
    gap: 8px;
  }

  .email-actions {
    display: none;
  }

  .email-summary {
    display: none;
  }
}

/* Mobile Responsive - Gmail/Outlook style compact list */
@media (max-width: 768px) {
  /* Three-panel layout - stack vertically on mobile */
  /* panel-viewport uses flex: 1 from base styles */

  .panel-container {
    flex-direction: column;
    width: 100%;
    height: 100%;
  }

  /* Panel list and viewer go full width on mobile */
  .panel-list,
  .panel-viewer {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: auto;
  }

  /* Panel actions (sidebar) - hidden off screen, fixed width */
  .panel-actions {
    position: fixed !important;
    left: -260px !important;
    top: 0 !important;
    width: 250px !important;
    min-width: 250px !important;
    max-width: 250px !important;
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport height for mobile */
    z-index: 1001 !important;
    background: white !important;
    transition: left 0.3s ease;
    box-shadow: none;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
  }

  .panel-actions.open {
    left: 0 !important;
    box-shadow: 4px 0 15px rgba(0,0,0,0.2);
  }

  /* Ensure sidebar content can scroll */
  .panel-actions .gmail-sidebar,
  .panel-actions .workflow-sidebar {
    height: auto !important;
    min-height: 100% !important;
    overflow-y: visible !important;
  }

  .panel-actions .label-list {
    padding-bottom: 80px; /* Extra space at bottom for scroll */
  }

  /* Email viewer - full screen overlay on mobile */
  .panel-viewer {
    position: fixed !important;
    top: 44px !important; /* Below header */
    left: 100% !important; /* Hidden off right side */
    width: 100% !important;
    height: calc(100vh - 44px - 56px) !important; /* Minus header and bottom nav */
    height: calc(100dvh - 44px - 56px) !important;
    z-index: 100 !important;
    background: white !important;
    transition: left 0.3s ease !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    border-left: none !important;
  }

  /* When viewing email, show viewer full screen */
  .panel-container.viewing-email .panel-viewer {
    left: 0 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  /* Ensure viewer content is visible */
  .panel-viewer .viewer-layout,
  .panel-viewer .viewer-main,
  .panel-viewer .viewer-content,
  .panel-viewer .viewer-email {
    display: block !important;
    visibility: visible !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Mobile sidebar - slide-up panel from bottom */
  .panel-viewer .viewer-sidebar {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 70vh;
    min-width: unset !important;
    background: #fff !important;
    border-left: none !important;
    border-top: 1px solid #e0e0e0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow-y: auto;
    padding: 16px !important;
    padding-bottom: 80px !important; /* Space for bottom nav */
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    display: block !important;
  }

  /* Show sidebar when .show-mobile class is added */
  .panel-viewer .viewer-sidebar.show-mobile {
    transform: translateY(0);
  }

  /* Mobile sidebar header with close button */
  .viewer-sidebar .mobile-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
  }

  .viewer-sidebar .mobile-sidebar-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
  }

  /* Backdrop for mobile sidebar */
  .viewer-sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
  }

  .viewer-sidebar-backdrop.show {
    display: block;
  }

  /* Hide compact list when viewing email on mobile */
  .panel-container.viewing-email .panel-list {
    display: none !important;
  }

  /* Disable the desktop sliding transform on mobile */
  .panel-container {
    transform: none !important;
    width: 100% !important;
  }

  .panel-container.viewing-email {
    transform: none !important;
  }

  /* Email rows - COMPACT Gmail-style, edge to edge */
  .inbox-email-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px;
    min-height: 52px;
    gap: 8px;
    border-left-width: 3px !important; /* Thinner account color bar */
    margin: 0;
  }

  /* Fix selected/viewing email row - white text on blue */
  .inbox-email-row.selected,
  .inbox-email-row.viewing {
    background: #1a73e8 !important;
  }

  .inbox-email-row.selected .email-sender,
  .inbox-email-row.selected .email-subject,
  .inbox-email-row.selected .email-subject-text,
  .inbox-email-row.selected .email-date,
  .inbox-email-row.viewing .email-sender,
  .inbox-email-row.viewing .email-subject,
  .inbox-email-row.viewing .email-subject-text,
  .inbox-email-row.viewing .email-date {
    color: white !important;
  }

  /* FULL WIDTH - Edge to edge on mobile */
  .dashboard-container,
  .tab-content,
  .tab-pane,
  .panel-viewport,
  .panel-container,
  .panel-list,
  .gmail-main,
  .triage-main,
  #inbox-list-container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-left: none !important;
    border-right: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Toolbar - compact for mobile, no space above */
  .triage-toolbar {
    margin: 0 !important;
    margin-top: 0 !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    padding: 6px 8px !important;
    min-height: 40px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }

  /* Ensure no padding/margin above toolbar */
  .gmail-main,
  .triage-main,
  .panel-list {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  .triage-toolbar .toolbar-left {
    flex-shrink: 0;
  }

  /* Hide search on mobile by default - toggle via search icon */
  .triage-toolbar .toolbar-center {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    padding: 8px;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 100;
  }

  .triage-toolbar .toolbar-center.visible {
    display: block !important;
  }

  .triage-toolbar .toolbar-center .search-container {
    max-width: 100%;
  }

  .triage-toolbar .toolbar-center .search-input {
    width: 100%;
    font-size: 16px; /* Prevent iOS zoom */
  }

  /* Make toolbar position relative for search dropdown */
  .triage-toolbar {
    position: relative !important;
  }

  .triage-toolbar .toolbar-right {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0;
  }

  /* Compact filter dropdown */
  .triage-toolbar .toolbar-select,
  #triage-filter-toggle {
    font-size: 11px !important;
    padding: 4px 6px !important;
    max-width: 100px !important;
  }

  /* Compact pagination */
  .pagination-controls {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
    border-left: none !important;
  }

  .pagination-info {
    font-size: 10px !important;
    white-space: nowrap !important;
  }

  .pagination-btn {
    min-width: 28px !important;
    min-height: 28px !important;
    padding: 2px 6px !important;
    font-size: 12px !important;
  }

  /* Hide select-all checkbox on mobile */
  #inbox-select-all {
    display: none !important;
  }

  .inbox-email-row:hover {
    transform: none;
  }

  /* Hide checkbox on mobile - use swipe gestures instead */
  .email-checkbox-wrapper {
    display: none;
  }

  /* Hide category/urgency column on mobile */
  .email-category-actions,
  .email-category-urgency {
    display: none;
  }

  /* Hide confidence badge */
  .email-confidence {
    display: none;
  }

  /* Email info - two tight lines */
  .email-info {
    flex: 1;
    min-width: 0;
    gap: 2px;
  }

  /* Sender line: Name + date on same row */
  .email-sender {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Thread badge - more compact on mobile */
  .thread-badge {
    margin-left: 4px;
    padding: 1px 5px;
    gap: 2px;
  }

  .thread-icon {
    font-size: 10px;
  }

  .thread-count {
    font-size: 10px;
  }

  /* Subject - single line, truncated */
  .email-subject {
    font-size: 13px;
    color: var(--text-secondary);
  }

  .email-subject-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Show snippet on same line as subject if space */
  .email-summary {
    display: none;
  }

  /* Meta column - compact, right side */
  .email-meta {
    flex-shrink: 0;
    gap: 2px;
    align-items: flex-end;
    min-width: 50px;
  }

  .email-date {
    font-size: 11px;
    color: var(--text-secondary);
  }

  /* Attachment icon smaller */
  .email-attachment-icon {
    font-size: 14px;
  }

  /* Hide action icons on mobile list - actions on tap */
  .action-icons {
    display: none;
  }

  /* Unread styling - bolder */
  .inbox-email-row.unread .email-sender {
    font-weight: 700;
  }

  .inbox-email-row.unread .email-subject,
  .inbox-email-row.unread .email-subject-text {
    color: var(--text-primary);
    font-weight: 500;
  }

  /* Batch toolbar - horizontal scroll on mobile */
  #inbox-batch-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 12px;
    gap: 6px;
  }

  #inbox-batch-toolbar .batch-btn {
    padding: 8px 12px;
    font-size: 12px;
    min-height: 36px;
    white-space: nowrap;
  }

  /* Empty state - compact */
  .inbox-empty-state {
    padding: 2rem 1rem;
  }

  .inbox-empty-state .empty-icon {
    font-size: 2.5rem;
  }

  .inbox-empty-state .empty-title {
    font-size: 1rem;
  }

  /* Context menu - bottom sheet style */
  .email-context-menu {
    position: fixed;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 60vh;
    overflow-y: auto;
  }

  .context-menu-item {
    padding: 14px 20px;
    font-size: 15px;
  }

  /* Viewer - full screen takeover */
  .viewer-header {
    padding: 8px 12px;
  }

  .viewer-back-btn {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 40px;
  }

  .viewer-email {
    padding: 12px;
  }

  .viewer-email-subject {
    font-size: 18px;
  }

  /* Editor panel - full width */
  .panel-editor {
    width: 100%;
    right: -100%;
  }

  /* Pinned header - compact */
  .pinned-header {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  /* Pinned section - less prominent */
  .inbox-pinned-section {
    padding-bottom: 4px;
  }

  /* Viewer sidebar - handled by slide-up panel in earlier media query */

  .viewer-main {
    max-width: 100%;
  }
}

/* Mobile Responsive - Small phones (iPhone SE, etc) */
@media (max-width: 480px) {
  /* Even tighter viewport */
  .panel-viewport {
    height: calc(100vh - 48px);
  }

  /* Ultra compact email rows */
  .inbox-email-row {
    padding: 6px 10px;
    min-height: 46px;
    gap: 6px;
  }

  .email-sender {
    font-size: 13px;
  }

  .email-subject {
    font-size: 12px;
  }

  .email-date {
    font-size: 10px;
  }

  /* Minimal meta column */
  .email-meta {
    min-width: 40px;
  }

  /* Viewer - tight */
  .viewer-email {
    padding: 10px;
  }

  .viewer-email-subject {
    font-size: 16px;
  }

  .viewer-email-body {
    font-size: 13px;
    line-height: 1.5;
  }

  /* Empty state compact */
  .inbox-empty-state {
    padding: 1.5rem 1rem;
  }

  .inbox-empty-state .empty-icon {
    font-size: 2rem;
  }
}

/* Account Badge */
.account-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f0f0f0;
  margin-right: 6px;
  flex-shrink: 0;
  line-height: 1;
  vertical-align: middle;
}

/* Only show badge when multiple accounts exist */
.single-account .account-badge {
  display: none;
}

/* Action Icons */
.action-icons {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0; /* Never shrink - always show icons */
  vertical-align: middle;
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: help;
  transition: transform 0.2s ease;
}

.action-icon:hover {
  transform: scale(1.2);
}

.action-icon-overflow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #5f6368;
  background: #f1f3f4;
  border-radius: 10px;
  padding: 2px 5px;
  cursor: help;
  margin-left: 2px;
}

.action-icon-overflow:hover {
  background: #e8eaed;
}

/* Dark Mode Support - Auto-detects device preference */
@media (prefers-color-scheme: dark) {
  /* Base backgrounds */
  body,
  .dashboard-container,
  .tab-content,
  .tab-pane {
    background: #1a1a1a !important;
    color: #e0e0e0;
  }

  /* Header */
  .dashboard-header {
    background: #1a1a1a !important;
    border-bottom-color: #333 !important;
  }

  .dashboard-header h1,
  .header-title {
    color: #fff !important;
  }

  /* New header elements dark mode */
  .header-nav .header-tab {
    color: #aaa !important;
  }

  .header-nav .header-tab:hover {
    background: #333 !important;
    color: #fff !important;
  }

  .header-nav .header-tab.active {
    background: #1a73e8 !important;
    color: #fff !important;
  }

  .header-status {
    background: #333 !important;
    color: #aaa !important;
  }

  .header-icon-btn {
    border-color: #444 !important;
    color: #aaa !important;
  }

  .header-icon-btn:hover {
    background: #333 !important;
    border-color: #555 !important;
    color: #fff !important;
  }

  .header-user-btn {
    background: #333 !important;
    border-color: #444 !important;
  }

  .header-user-btn:hover {
    background: #444 !important;
    border-color: #555 !important;
  }

  .user-email {
    color: #e0e0e0 !important;
  }

  .user-dropdown {
    background: #2a2a2a !important;
    border-color: #444 !important;
  }

  .dropdown-header {
    border-bottom-color: #444 !important;
    color: #aaa !important;
  }

  .dropdown-item {
    color: #e0e0e0 !important;
  }

  .dropdown-item:hover {
    background: #333 !important;
  }

  .dropdown-logout {
    color: #ff6b6b !important;
    border-top-color: #444 !important;
  }

  /* Email list */
  #inbox-list-container,
  .panel-list,
  .gmail-main {
    background: #1a1a1a !important;
  }

  .inbox-email-row {
    background: #1a1a1a !important;
    border-bottom-color: #333 !important;
  }

  /* Read emails - must override light mode :not(.unread) rule */
  .inbox-email-row:not(.unread) {
    background: #1a1a1a !important;
  }

  .inbox-email-row:hover {
    background: #2a2a2a !important;
  }

  .inbox-email-row.unread {
    background: #1e2a3a !important;
  }

  .inbox-email-row.selected,
  .inbox-email-row.viewing {
    background: #1a4a7a !important;
  }

  .inbox-email-row.selected .email-sender,
  .inbox-email-row.selected .email-subject,
  .inbox-email-row.selected .email-subject-text,
  .inbox-email-row.selected .email-date,
  .inbox-email-row.viewing .email-sender,
  .inbox-email-row.viewing .email-subject,
  .inbox-email-row.viewing .email-subject-text,
  .inbox-email-row.viewing .email-date {
    color: #fff !important;
  }

  .email-sender,
  .email-subject,
  .email-subject-text {
    color: #e0e0e0 !important;
  }

  /* Material Design dark theme text emphasis (adjusted ~25% darker) */
  .inbox-email-row.unread .email-sender,
  .inbox-email-row.unread .email-subject,
  .inbox-email-row.unread .email-subject-text {
    color: #b8b8b8 !important;
  }

  .inbox-email-row:not(.unread) .email-sender,
  .inbox-email-row:not(.unread) .email-subject,
  .inbox-email-row:not(.unread) .email-subject-text {
    color: #777 !important;
  }

  .email-summary,
  .email-date {
    color: #888 !important;
  }

  /* Thread badge in dark mode */
  .thread-badge {
    background: #1e3a5f;
    border-color: #2d5a8f;
    color: #6db3ff;
  }

  /* Toolbar */
  .triage-toolbar {
    background: #1a1a1a !important;
    border-bottom-color: #333 !important;
  }

  /* Sidebar */
  .panel-actions,
  .gmail-sidebar,
  .workflow-sidebar {
    background: #1a1a1a !important;
  }

  .sidebar-header {
    border-bottom-color: #333 !important;
  }

  .sidebar-header h3 {
    color: #e0e0e0 !important;
  }

  .queue-item {
    color: #ccc !important;
  }

  .queue-item .queue-name {
    color: #ccc !important;
  }

  .queue-item.primary:not(.active) {
    background: #222 !important;
    color: #e0e0e0 !important;
  }

  .queue-item.primary:not(.active) .queue-name {
    color: #e0e0e0 !important;
  }

  .queue-item:hover {
    background: #2a2a2a !important;
  }

  .queue-item.active {
    background: #1a73e8 !important;
    color: #fff !important;
  }

  .queue-item.active .queue-name {
    color: #fff !important;
  }

  /* Specific queue item color overrides for dark mode */
  .queue-item.urgent .queue-name {
    color: #f87171 !important;
  }

  .queue-item.spam .queue-name {
    color: #fbbf24 !important;
  }

  .queue-item.vip .queue-name {
    color: #fcd34d !important;
  }

  .label-section-title {
    color: #888 !important;
  }

  /* Email viewer */
  .panel-viewer,
  .viewer-layout,
  .viewer-main,
  .viewer-content {
    background: #1a1a1a !important;
  }

  .viewer-header {
    background: #222 !important;
    border-bottom-color: #333 !important;
  }

  .viewer-email {
    background: #1a1a1a !important;
  }

  .viewer-email-subject {
    color: #fff !important;
  }

  .viewer-email-body,
  .viewer-email-body * {
    color: #e0e0e0 !important;
    background: transparent !important;
  }

  .viewer-back-btn {
    background: #333 !important;
    border-color: #444 !important;
    color: #fff !important;
  }

  /* Bottom navigation */
  .mobile-bottom-nav {
    background: #1a1a1a !important;
    border-top-color: #333 !important;
  }

  .mobile-tab-btn {
    color: #888 !important;
    background: transparent !important;
  }

  .mobile-tab-btn.active {
    color: #4da3ff !important;
    background: rgba(77, 163, 255, 0.1) !important;
  }

  /* Hamburger menu button */
  .mobile-menu-btn span {
    background: #e0e0e0 !important;
  }

  /* Desktop tab buttons */
  .tab-btn {
    color: #888 !important;
    background: transparent !important;
  }

  .tab-btn:hover {
    color: #4da3ff !important;
  }

  .tab-btn.active {
    color: #4da3ff !important;
    border-bottom-color: #4da3ff !important;
  }

  /* Tab navigation container */
  .tab-navigation {
    background: #1a1a1a !important;
    border-bottom-color: #333 !important;
  }

  /* Buttons */
  .action-btn:hover,
  .triage-action-btn {
    background: #333;
    color: #e0e0e0;
  }

  .triage-action-btn.btn-primary {
    background: #1a73e8;
    color: #fff;
  }

  /* Badges */
  .account-badge,
  .queue-count {
    background: #333;
    color: #ccc;
  }

  /* Context menu */
  .email-context-menu {
    background: #2a2a2a !important;
    border-color: #444 !important;
  }

  .context-menu-item {
    color: #e0e0e0;
  }

  .context-menu-item:hover {
    background: #333;
  }

  /* Overlay */
  .sidebar-overlay.visible {
    background: rgba(0, 0, 0, 0.7);
  }
}

/* Empty Trash Button */
.btn-empty-trash {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-empty-trash:hover {
  background: #c82333;
}

/* Filter Toggle (Segmented Control) */
.filter-toggle {
  display: flex;
  background: #f1f3f4;
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}

.filter-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 500;
  color: #5f6368;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn:hover {
  color: #202124;
}

.filter-btn.active {
  background: white;
  color: #1a73e8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Mobile search icon */
.toolbar-search-icon {
  display: none;
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
}

.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex !important;
  }

  .filter-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .filter-toggle {
    padding: 1px;
  }
}

/* Dark mode filter toggle */
@media (prefers-color-scheme: dark) {
  .filter-toggle {
    background: #333;
  }

  .filter-btn {
    color: #aaa;
  }

  .filter-btn:hover {
    color: #fff;
  }

  .filter-btn.active {
    background: #1a1a1a;
    color: #4da3ff;
  }

  /* Dark mode search dropdown */
  .triage-toolbar .toolbar-center {
    background: #1a1a1a;
    border-bottom-color: #333;
  }

  .triage-toolbar .toolbar-center .search-input {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
  }
}

/* Search Close Button */
.search-close-btn {
  display: inline-flex;
  background: transparent;
  border: none;
  font-size: 18px;
  color: #5f6368;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  align-items: center;
  justify-content: center;
}

.search-close-btn:hover {
  color: #202124;
  background: rgba(0,0,0,0.05);
  border-radius: 50%;
}

@media (prefers-color-scheme: dark) {
  .search-close-btn {
    color: #aaa;
  }
  .search-close-btn:hover {
    color: #fff;
  }
}

/* Sidebar Account Selector */
.sidebar-account-selector {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-gray, #e0e0e0);
  position: relative;
}

.account-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  font-size: 13px;
  color: #202124;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.account-selector-btn:hover {
  background: #e8eaed;
  border-color: #c0c0c0;
}

.account-selector-btn .dropdown-arrow {
  margin-left: auto;
  font-size: 10px;
  color: #666;
}

#current-account-name {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 12px;
  right: 12px;
  background: white;
  border: 1px solid #dadce0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .sidebar-account-selector {
    border-bottom-color: #333;
  }
  .account-selector-btn {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
  }
  .account-selector-btn:hover {
    background: #3d3d3d;
    border-color: #555;
  }
  .account-dropdown-menu {
    background: #2d2d2d;
    border-color: #444;
  }
}

/* Sidebar Compose Button */
.sidebar-compose {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-gray, #e0e0e0);
}

.compose-btn-sidebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.compose-btn-sidebar:hover {
  background: #1557b0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.compose-btn-sidebar:active {
  background: #0d47a1;
}

/* Dark mode compose button */
@media (prefers-color-scheme: dark) {
  .sidebar-compose {
    border-bottom-color: #333;
  }

  .compose-btn-sidebar {
    background: #4da3ff;
  }

  .compose-btn-sidebar:hover {
    background: #3d8bdb;
  }
}

/* Mobile Floating Action Button (FAB) for Compose */
.compose-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.compose-fab:hover {
  background: #1557b0;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  transform: scale(1.05);
}

.compose-fab:active {
  background: #0d47a1;
  transform: scale(0.95);
}

/* Show FAB on mobile when sidebar is hidden */
@media (max-width: 600px) {
  .compose-fab {
    display: flex;
    /* Position above the mobile bottom nav (56px) + padding + safe area */
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
  }
}

/* Tablet: FAB above bottom nav */
@media (min-width: 601px) and (max-width: 768px) {
  .compose-fab {
    display: flex;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    right: 24px;
  }
}

/* Dark mode FAB */
@media (prefers-color-scheme: dark) {
  .compose-fab {
    background: #4da3ff;
  }

  .compose-fab:hover {
    background: #3d8bdb;
  }
}

/* Dark mode for thread message body (email content) */
@media (prefers-color-scheme: dark) {
  .thread-message-body {
    background: #1a1a1a !important;
    color: #b8b8b8 !important;
  }

  .thread-message-body pre {
    color: #b8b8b8 !important;
  }

  .thread-message {
    background: #1a1a1a !important;
    border-color: #333 !important;
  }

  .thread-message-header {
    background: #222 !important;
  }

  .thread-sender-name {
    color: #e0e0e0 !important;
  }

  .thread-message-date {
    color: #888 !important;
  }

  .thread-header-snippet {
    color: #888 !important;
  }

  .message-recipients {
    color: #888 !important;
    border-bottom-color: #333 !important;
  }

  .quoted-content pre {
    color: #666 !important;
  }

  .quoted-toggle-btn {
    color: #6db3ff !important;
    background: transparent !important;
  }

  /* Viewer sidebar (triage panel) dark mode */
  .viewer-sidebar {
    background: #1a1a1a !important;
    border-left-color: #333 !important;
  }

  .viewer-sidebar-section h4 {
    color: #888 !important;
  }

  .viewer-select {
    background: #222 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }

  .viewer-btn {
    background: #222 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }

  .viewer-btn:hover {
    background: #333 !important;
  }

  .viewer-action-item {
    background: #222 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }

  .viewer-action-importance {
    background: #2a3a5a !important;
    color: #6db3ff !important;
  }

  .viewer-summary-text {
    color: #b8b8b8 !important;
  }

  /* Category editor / edit panel dark mode */
  .category-editor,
  .edit-panel,
  .triage-edit-panel,
  .actions-editor {
    background: #1a1a1a !important;
    border-color: #333 !important;
    color: #e0e0e0 !important;
  }

  .category-editor input,
  .category-editor select,
  .category-editor textarea,
  .edit-panel input,
  .edit-panel select,
  .edit-panel textarea,
  .actions-editor input,
  .actions-editor select,
  .actions-editor textarea {
    background: #222 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }

  .category-editor label,
  .edit-panel label,
  .actions-editor label {
    color: #b8b8b8 !important;
  }

  /* Mobile sidebar panel dark mode */
  .mobile-sidebar-header {
    background: #222 !important;
    border-bottom-color: #333 !important;
    color: #e0e0e0 !important;
  }

  .mobile-sidebar-close {
    color: #888 !important;
  }

  /* Sidebar sections dark mode */
  .sidebar-section {
    border-bottom-color: #333 !important;
  }

  .sidebar-section-header {
    color: #888 !important;
  }

  /* Sidebar action items dark mode */
  .sidebar-action-item {
    background: #222 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }

  .sidebar-action-name {
    color: #e0e0e0 !important;
  }

  /* Email action buttons dark mode */
  .email-action-btn {
    background: #222 !important;
    border-color: #444 !important;
    color: #b8b8b8 !important;
  }

  .email-action-btn:hover {
    background: #333 !important;
    border-color: #555 !important;
  }

  .email-action-btn.danger {
    color: #f44336 !important;
    border-color: #5a2a2a !important;
  }

  .email-action-btn.danger:hover {
    background: #3d1a1a !important;
    border-color: #f44336 !important;
  }

  /* Sidebar confirm button (AI is Correct) */
  .sidebar-confirm-btn {
    /* Keep green gradient but maybe darken slightly */
  }

  .sidebar-confirm-btn .confirm-text {
    color: #fff !important;
  }

  .sidebar-action-importance.low { background: #1b3d1f !important; color: #4caf50 !important; }
  .sidebar-action-importance.medium { background: #3d2e1a !important; color: #ff9800 !important; }
  .sidebar-action-importance.high { background: #3d1a1a !important; color: #f44336 !important; }
  .sidebar-action-importance.critical { background: #c62828 !important; color: white !important; }

  .sidebar-sender-info {
    color: #b8b8b8 !important;
  }

  .sidebar-sender-relationship {
    background: #2a3a5a !important;
    color: #6db3ff !important;
  }

  .sidebar-summary-text {
    color: #888 !important;
  }

  .sidebar-no-actions {
    color: #666 !important;
  }

  .sidebar-action-btn {
    background: #222 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }

  .sidebar-action-btn:hover {
    background: #333 !important;
  }

  /* Editor panel dark mode */
  .panel-editor {
    background: #1a1a1a !important;
    border-left-color: #333 !important;
  }

  .editor-header {
    background: #222 !important;
    border-bottom-color: #333 !important;
  }

  .editor-header h3 {
    color: #e0e0e0 !important;
  }

  .editor-back-btn {
    background: #333 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }

  .editor-back-btn:hover {
    background: #444 !important;
  }

  .editor-autosave-indicator {
    color: #888 !important;
  }

  .editor-content {
    background: #1a1a1a !important;
  }

  .editor-section {
    background: #222 !important;
    color: #e0e0e0 !important;
  }

  .editor-section h4 {
    color: #e0e0e0 !important;
  }

  .editor-select {
    background: #333 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }

  .editor-input,
  .editor-textarea {
    background: #333 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }

  .editor-label {
    color: #b8b8b8 !important;
  }
}

/* Virtualization Helpers */
.inbox-virtual-spacer-top {
  height: 0;
  pointer-events: none;
}

.inbox-virtual-spacer-bottom {
  height: 0;
  pointer-events: none;
}

/* Category Subgroups */
.category-subgroup {
  margin-bottom: 12px;
}

.category-subgroup:last-child {
  margin-bottom: 0;
}

.subgroup-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  background: #f5f5f5;
  border-radius: 4px;
  margin-bottom: 4px;
}

.category-subgroup .queue-item {
  padding-left: 24px;
}

/* Loading State */
.inbox-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 14px;
}

.inbox-loading::before {
  content: '⏳';
  font-size: 24px;
  margin-right: 8px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Right-click Context Menu */
.email-context-menu {
  position: fixed;
  z-index: 10000;
  background: white;
  border: 1px solid #dadce0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 180px;
  padding: 6px 0;
  font-size: 13px;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  color: #202124;
  transition: background 0.1s;
}

.context-menu-item:hover {
  background: #f1f3f4;
}

.context-menu-item.danger {
  color: #c5221f;
}

.context-menu-item.danger:hover {
  background: #fce8e6;
}

.context-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.context-menu-divider {
  height: 1px;
  background: #e8eaed;
  margin: 6px 0;
}

.context-menu-item.admin-item {
  color: #7c3aed;
}

.context-menu-item.admin-item:hover {
  background: #ede9fe;
}

/* ========================================
   THREE-PANEL SLIDING LAYOUT
   Panel 1: Actions (240px) | Panel 2: List (flex) | Panel 3: Viewer (flex)

   Default: Actions + List visible
   Email view: Slide left, List compact (220px) + Viewer visible
   ======================================== */

/* Prevent body scroll - content scrolls inside tab-content */
html, body {
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#reviewer {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dashboard-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  max-width: 100vw;
}

/* Tab content is the scrollable area */
.tab-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0; /* Allow shrinking in flex */
}

/* Tab panes - default hidden */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Review tab: panel-viewport fills the tab and handles its own scrolling */
#tab-review.active {
  height: 100%;
  overflow: hidden; /* Panel viewport handles scrolling internally */
}

.panel-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Email list and sidebar scroll internally */
.panel-list .gmail-main {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-actions .gmail-sidebar {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-container {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease-in-out;
  /* Total width = actions(240) + list(vw-380) + viewer(vw-220) */
  width: calc(240px + 100vw - 380px + 100vw - 220px);
}

/* Default: show actions + list */
.panel-container {
  transform: translateX(0);
}

/* Email view: slide left by actions width */
.panel-container.viewing-email {
  transform: translateX(-240px);
}

.panel {
  height: 100%;
  flex-shrink: 0;
  overflow: hidden;
}

/* Panel 1: Actions Sidebar - fixed 240px */
.panel-actions {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
}

.panel-actions .gmail-sidebar {
  width: 100%;
  min-width: 0; /* Override gmail-style.css min-width to fit panel */
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Panel 2: Email List - fills space in default, compact in email view */
.panel-list {
  width: calc(100vw - 380px); /* viewport - actions(240) - scrollbar/padding(140) */
  min-width: 300px;
}

.panel-list .gmail-main {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Panel 3: Email Viewer - hidden by default */
/* Width = viewport - compact list(220px) - some padding/margins(~135px) */
.panel-viewer {
  width: calc(100vw - 355px);
  min-width: 500px;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  visibility: hidden;
  pointer-events: none;
}

/* When viewing email: show viewer, compact the list */
.panel-container.viewing-email .panel-viewer {
  visibility: visible;
  pointer-events: auto;
}

.panel-container.viewing-email .panel-list {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
}

.viewer-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  width: 100%;
  max-width: 100%;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
  flex-shrink: 0;
}

.viewer-back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #3c4043;
  transition: background 0.2s, box-shadow 0.2s;
}

.viewer-back-btn:hover {
  background: #f1f3f4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.viewer-nav {
  display: flex;
  gap: 8px;
}

.viewer-nav-btn {
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #5f6368;
  transition: background 0.2s;
}

.viewer-nav-btn:hover:not(:disabled) {
  background: #f1f3f4;
}

.viewer-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Highlight selected email in list when viewing */
.panel-container.viewing-email .inbox-email-row.viewing {
  background: #1a73e8 !important;
  border-left-width: 6px; /* Keep account color but make thicker */
}

.panel-container.viewing-email .inbox-email-row.viewing .email-sender,
.panel-container.viewing-email .inbox-email-row.viewing .email-subject,
.panel-container.viewing-email .inbox-email-row.viewing .email-subject-text,
.panel-container.viewing-email .inbox-email-row.viewing .email-date {
  color: white !important;
}

/* Filter title shown when viewing email */
.email-list-filter-title {
  display: none;
  padding: 10px 12px;
  background: linear-gradient(135deg, #e8f0fe 0%, #f0f7ff 100%);
  border-bottom: 1px solid #d0e3f5;
  font-size: 13px;
  font-weight: 600;
  color: #1a5490;
  position: sticky;
  top: 0;
  z-index: 10;
}

.panel-container.viewing-email .email-list-filter-title {
  display: block;
}

/* Make list compact when in email view */
.panel-container.viewing-email .panel-list {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  flex-grow: 0;
  flex-shrink: 0;
  overflow-y: auto;
}

/* Hide elements that don't fit in compact view */
.panel-container.viewing-email .panel-list .email-checkbox-wrapper,
.panel-container.viewing-email .panel-list .email-category-urgency,
.panel-container.viewing-email .panel-list .email-summary,
.panel-container.viewing-email .panel-list .email-meta,
.panel-container.viewing-email .panel-list .email-confidence,
.panel-container.viewing-email .panel-list .triage-toolbar {
  display: none;
}

.panel-container.viewing-email .panel-list .inbox-email-row {
  padding: 8px 10px;
  min-height: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel-container.viewing-email .panel-list .email-info {
  flex: 1;
  min-width: 0; /* Allow text to shrink */
  width: 100%;
}

.panel-container.viewing-email .panel-list .email-sender {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-container.viewing-email .panel-list .email-subject {
  font-size: 11px;
  color: #5f6368;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.panel-container.viewing-email .panel-list .email-subject-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Viewer Layout with Sidebar */
.viewer-layout {
  display: flex;
  height: 100%;
}

.viewer-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  /* Leave room for sidebar */
  max-width: calc(100% - 240px);
}

.viewer-sidebar {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  flex-shrink: 0;
  background: #f8f9fa;
  border-left: 1px solid #e0e0e0;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.viewer-sidebar-section {
  margin-bottom: 20px;
}

.viewer-sidebar-section h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  font-weight: 600;
  color: #5f6368;
  text-transform: uppercase;
}

.viewer-select {
  width: 100%;
  padding: 8px;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 8px;
}

.viewer-btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}

.viewer-btn:hover {
  background: #f1f3f4;
}

.viewer-btn-small {
  padding: 4px 8px;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.viewer-btn-small:hover {
  background: #1557b0;
}

.viewer-actions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.viewer-action-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 12px;
}

.viewer-action-importance {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: #e8f0fe;
  color: #1967d2;
}

.viewer-summary-text {
  font-size: 13px;
  color: #3c4043;
  line-height: 1.5;
  margin: 0;
}

/* ========================================
   CLEAN SIDEBAR STYLES
   ======================================== */

.sidebar-category-badge {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  margin-bottom: 16px;
  text-align: center;
  width: fit-content;
}

.sidebar-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e8eaed;
}

.sidebar-section:last-of-type {
  border-bottom: none;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #5f6368;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.sidebar-section-icon {
  font-size: 12px;
}

.sidebar-actions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-action-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
}

.sidebar-action-name {
  font-weight: 500;
  text-transform: capitalize;
}

.sidebar-action-importance {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.sidebar-action-importance.low { background: #e8f5e9; color: #2e7d32; }
.sidebar-action-importance.medium { background: #fff3e0; color: #ef6c00; }
.sidebar-action-importance.high { background: #fce4ec; color: #c62828; }
.sidebar-action-importance.critical { background: #c62828; color: white; }

.sidebar-no-actions {
  color: #9aa0a6;
  font-size: 12px;
  font-style: italic;
}

.sidebar-sender-info {
  font-size: 12px;
  color: #3c4043;
}

.sidebar-sender-relationship {
  display: inline-block;
  padding: 2px 8px;
  background: #e8f0fe;
  color: #1967d2;
  border-radius: 10px;
  font-size: 11px;
  margin-top: 4px;
}

.sidebar-summary-text {
  font-size: 12px;
  color: #5f6368;
  line-height: 1.5;
  margin: 0;
}

.sidebar-quick-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.sidebar-action-btn {
  width: 40px;
  height: 40px;
  border: 1px solid #dadce0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.sidebar-action-btn:hover {
  background: #f1f3f4;
  transform: scale(1.1);
}

.sidebar-edit-btn {
  width: 100%;
  padding: 12px;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.2s;
}

.sidebar-edit-btn:hover {
  background: #1557b0;
}

/* AI Confirmation Button - Large and prominent */
.sidebar-confirm-btn {
  width: 100%;
  padding: 14px 16px;
  background: linear-gradient(135deg, #34a853 0%, #2d8f47 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(52, 168, 83, 0.3);
}

.sidebar-confirm-btn:hover {
  background: linear-gradient(135deg, #2d8f47 0%, #267a3d 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(52, 168, 83, 0.4);
}

.sidebar-confirm-btn:active {
  transform: translateY(0);
}

.sidebar-confirm-btn .confirm-checkbox {
  width: 22px;
  height: 22px;
  background: rgba(255,255,255,0.25);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
}

.sidebar-confirm-btn .confirm-text {
  flex: 1;
  text-align: left;
}

/* Email Actions Grid */
.sidebar-email-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.email-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 6px;
  font-size: 11px;
  color: #3c4043;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 0;
  overflow: hidden;
}

.email-action-btn .action-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.email-action-btn .action-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-action-btn:hover {
  background: #f1f3f4;
  border-color: #c1c1c1;
}

.email-action-btn:active {
  background: #e8e8e8;
}

.email-action-btn.danger {
  color: #d93025;
  border-color: #f5c6cb;
}

.email-action-btn.danger:hover {
  background: #fce8e6;
  border-color: #d93025;
}

/* Badge styling - clearly non-interactive */
.sidebar-category-badge {
  background: #f1f3f4;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  pointer-events: none; /* Not clickable */
}

.sidebar-category-badge .badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: #e8f0fe;
  color: #1967d2;
}

/* Section headers - clearly labels, not buttons */
.sidebar-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #5f6368;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding: 0;
  background: none;
  border: none;
}

/* ========================================
   EDITOR OVERLAY PANEL (slides over viewer)
   ======================================== */

.panel-editor {
  position: fixed;
  top: 0;
  right: -420px; /* Hidden off-screen */
  width: 400px;
  height: 100vh;
  background: #f8f9fa;
  border-left: 1px solid #e0e0e0;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 1000;
  transition: right 0.3s ease-in-out;
}

.panel-editor.open {
  right: 0; /* Slide in */
}

/* Dim overlay behind editor */
.editor-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.editor-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.editor-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.editor-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.editor-back-btn {
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #3c4043;
}

.editor-back-btn:hover {
  background: #f1f3f4;
}

.editor-autosave-indicator {
  font-size: 12px;
  color: #5f6368;
  padding: 4px 8px;
}

.editor-autosave-indicator.saving {
  color: #1a73e8;
}

.editor-autosave-indicator.saved {
  color: #188038;
}

.editor-autosave-indicator.error {
  color: #c5221f;
}

.editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.editor-section {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.editor-section h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #202124;
}

.editor-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dadce0;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.editor-select:focus {
  border-color: #1a73e8;
  outline: none;
  box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}

.editor-actions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.editor-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 6px;
}

.editor-action-type {
  flex: 1;
  padding: 8px;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 13px;
}

.editor-action-importance {
  width: 100px;
  padding: 8px;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 13px;
}

.editor-action-delete {
  padding: 6px 10px;
  background: #fce8e6;
  color: #c5221f;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.editor-action-delete:hover {
  background: #f8d7da;
}

.editor-add-btn {
  padding: 8px 12px;
  background: #e8f0fe;
  color: #1967d2;
  border: 1px dashed #1967d2;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
}

.editor-add-btn:hover {
  background: #d2e3fc;
}

.editor-sender-info,
.editor-sender-box {
  font-size: 14px;
  font-weight: 500;
  color: #202124;
  margin-bottom: 16px;
  padding: 12px;
  background: #e8f0fe;
  border: 1px solid #1a73e8;
  border-radius: 8px;
  text-align: center;
  word-break: break-all;
}

.editor-hint {
  font-size: 12px;
  color: #9aa0a6;
  margin: 0 0 12px 0;
}

.editor-rules-list {
  margin-bottom: 12px;
}

.editor-rule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 12px;
}

/* Sender Rules UI */
.editor-rule-row {
  margin-bottom: 12px;
}

.editor-rule-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #5f6368;
  margin-bottom: 6px;
}

.editor-radio-group {
  display: flex;
  gap: 4px;
}

.editor-radio {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: #f1f3f4;
  border: 1px solid #dadce0;
  border-radius: 16px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.editor-radio:hover {
  background: #e8eaed;
}

.editor-radio input {
  margin-right: 4px;
}

.editor-radio:has(input:checked) {
  background: #e8f0fe;
  border-color: #1a73e8;
  color: #1a73e8;
}

.editor-rule-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.editor-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.editor-checkbox:hover {
  background: #f1f3f4;
}

.editor-checkbox input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.editor-unsubscribe-btn {
  width: 100%;
  padding: 10px;
  background: #fff;
  border: 1px dashed #dadce0;
  border-radius: 6px;
  color: #5f6368;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.editor-unsubscribe-btn:hover {
  background: #f1f3f4;
  border-color: #1a73e8;
  color: #1a73e8;
}

/* Auto-delete Confirmation Modal */
.confirm-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.confirm-modal h3 {
  margin: 0 0 12px 0;
  font-size: 18px;
  color: #c5221f;
}

.confirm-modal p {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: #5f6368;
  line-height: 1.5;
}

.confirm-modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.confirm-modal-btn {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: none;
}

.confirm-modal-btn.cancel {
  background: #f1f3f4;
  color: #3c4043;
}

.confirm-modal-btn.danger {
  background: #c5221f;
  color: white;
}

.confirm-modal-btn:hover {
  opacity: 0.9;
}

/* Viewer Content Styling */
.viewer-email {
  padding: 24px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.viewer-email-header {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e0e0e0;
}

.viewer-email-subject {
  font-size: 22px;
  font-weight: 400;
  color: #202124;
  margin-bottom: 8px;
}

.viewer-email-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.viewer-email-sender {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 16px;
}

.viewer-sender-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.viewer-sender-info strong {
  color: #202124;
  font-size: 14px;
}

.viewer-date {
  color: #5f6368;
  font-size: 12px;
}

.viewer-recipients {
  color: #5f6368;
  font-size: 12px;
  margin-top: 4px;
}

.viewer-summary {
  background: #f8f9fa;
  border-left: 3px solid #1a73e8;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #3c4043;
  border-radius: 0 4px 4px 0;
}

.viewer-email-body {
  font-size: 14px;
  line-height: 1.6;
  color: #202124;
  padding: 16px 0;
  min-height: 200px;
  /* Critical: contain HTML email content */
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

/* Contain HTML email content */
.viewer-email-body > * {
  max-width: 100% !important;
  box-sizing: border-box;
}

.viewer-email-body table {
  max-width: 100% !important;
  width: 100% !important;
  table-layout: fixed;
}

.viewer-email-body td,
.viewer-email-body th {
  max-width: 100% !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.viewer-email-body img {
  max-width: 100% !important;
  height: auto !important;
}

.viewer-email-body div {
  max-width: 100% !important;
  box-sizing: border-box;
}

.viewer-email-body pre {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Email body iframe - contains HTML email content */
.email-body-frame {
  width: 100%;
  max-width: 100%;
  min-height: 200px;
  height: auto;
  border: none;
  background: white;
  display: block;
}

/* Mobile: constrain email iframe to viewport width */
@media (max-width: 768px) {
  .email-body-frame {
    max-width: calc(100vw - 24px);
  }

  /* Ensure viewer content doesn't overflow */
  .viewer-content,
  .viewer-email,
  .viewer-email-body {
    overflow-x: auto;
    max-width: 100%;
  }
}

.viewer-email-actions {
  display: flex;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
  margin-top: 24px;
}

/* Viewer Attachments Panel */
.viewer-attachments-panel {
  margin-top: 16px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.attachments-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
}

.attachments-panel-header .panel-icon {
  font-size: 16px;
}

.attachments-panel-header .panel-title {
  font-size: 13px;
  font-weight: 600;
  color: #202124;
}

.attachments-panel-body {
  padding: 6px;
}

.attachment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  transition: background 0.15s;
}

.attachment-row:hover {
  background: #f1f3f4;
}

.attachment-row .attachment-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.attachment-row .attachment-details {
  flex: 1;
  min-width: 0;
}

.attachment-row .attachment-name {
  font-size: 13px;
  font-weight: 500;
  color: #202124;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-row .attachment-meta {
  font-size: 11px;
  color: #5f6368;
  margin-top: 1px;
}

.attachment-row .attachment-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-attachment {
  padding: 5px 10px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #1a73e8;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-attachment:hover {
  background: #e8f0fe;
  border-color: #1a73e8;
}

/* Sidebar Attachments List */
.sidebar-attachments-list {
  max-height: 200px; /* ~4 items */
  overflow-y: auto;
  padding: 4px 0;
}

.sidebar-attachment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  cursor: default;
}

.sidebar-attachment-row.viewable {
  cursor: pointer;
}

.sidebar-attachment-row:hover {
  background: #f1f3f4;
}

.sidebar-attachment-row.viewable:hover {
  background: #e8f0fe;
}

.sidebar-attachment-row .att-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-attachment-row .att-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sidebar-attachment-row .att-name {
  font-size: 12px;
  font-weight: 500;
  color: #202124;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-attachment-row .att-date {
  font-size: 10px;
  color: #5f6368;
  margin-top: 1px;
}

.sidebar-attachment-row .att-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.att-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.att-btn:hover {
  background: #e8f0fe;
  border-color: #1a73e8;
}

.viewer-action-btn {
  padding: 10px 20px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #3c4043;
  transition: background 0.2s, box-shadow 0.2s;
}

.viewer-action-btn:hover {
  background: #f1f3f4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Thread messages in viewer */
.thread-count-header {
  padding: 10px 16px;
  margin-bottom: 16px;
  background: #e8f0fe;
  border-radius: 8px;
  color: #1967d2;
  font-size: 14px;
  font-weight: 500;
}

.thread-messages-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.thread-message {
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.thread-message.message-sent {
  border-left: 4px solid #34a853;
}

.thread-message.message-received {
  border-left: 4px solid #1a73e8;
}

.thread-message-header {
  display: flex;
  align-items: flex-start;
  padding: 10px 14px;
  cursor: pointer;
  background: #3c4043;
  color: #fff;
  gap: 10px;
}

.thread-message.collapsed .thread-message-header {
  padding: 8px 14px;
}

.thread-message-header:hover {
  background: #4a4f54;
}

.thread-message.expanded .thread-message-header {
  background: #1a73e8;
}

.thread-message.message-sent.expanded .thread-message-header {
  background: #34a853;
}

.thread-header-content {
  flex: 1;
  min-width: 0;
}

.thread-header-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thread-sender-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.thread-header-snippet {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-message.expanded .thread-header-snippet {
  display: none;
}

.sender-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #3c4043;
  background: #fff;
  flex-shrink: 0;
}

.thread-message.expanded .sender-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.avatar-sent {
  color: #34a853;
}

.avatar-received {
  color: #1a73e8;
}

.thread-message-date {
  color: rgba(255,255,255,0.8);
  font-size: 11px;
  flex-shrink: 0;
}

.expand-icon {
  color: rgba(255,255,255,0.8);
  font-size: 10px;
  flex-shrink: 0;
}

.thread-message-body {
  padding: 16px;
  background: #fff;
}

.message-recipients {
  color: #5f6368;
  font-size: 12px;
  margin-bottom: 12px;
}

/* Quoted content toggle */
.quoted-content-container {
  margin-top: 16px;
  border-top: 1px solid #e0e0e0;
  padding-top: 12px;
}

.quoted-toggle-btn {
  background: #f1f3f4;
  border: 1px solid #dadce0;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  color: #5f6368;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.quoted-toggle-btn:hover {
  background: #e8eaed;
}

.quote-icon {
  font-size: 10px;
}

.quoted-content {
  margin-top: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 4px;
  border-left: 3px solid #dadce0;
}

/* Image warning banner */
.image-warning-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin-bottom: 12px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  color: #856404;
  font-size: 13px;
}

.image-warning-banner span {
  flex: 1;
}

.btn-load-images,
.btn-trust-sender {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  border: none;
}

.btn-load-images {
  background: #6c757d;
  color: white;
}

.btn-load-images:hover {
  background: #5a6268;
}

.btn-trust-sender {
  background: #28a745;
  color: white;
}

.btn-trust-sender:hover {
  background: #218838;
}

/* ========================================
   MOBILE NAVIGATION
   ======================================== */

.mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 30px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1001;
  margin-right: 12px;
}

.mobile-menu-btn span {
  width: 100%;
  height: 3px;
  background: var(--text-primary, #333);
  border-radius: 2px;
  transition: all 0.3s;
}

/* Sidebar overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

.sidebar-overlay.visible {
  display: block;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }

  /* Sidebar positioning handled in MOBILE BOTTOM TAB BAR section */

  /* Main content takes full width */
  .panel-list,
  .inbox-main,
  .panel-container {
    width: 100%;
    margin-left: 0;
  }

  /* Header - single line on mobile */
  .dashboard-header {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 6px 10px;
    margin-bottom: 0;
    border-bottom: 1px solid #e0e0e0;
    min-height: 48px;
    gap: 8px;
  }

  /* New header brand on mobile */
  .header-brand {
    gap: 8px !important;
  }

  .header-logo {
    width: 28px !important;
    height: 28px !important;
  }

  .header-title {
    font-size: 1rem !important;
  }

  /* Hide nav tabs on mobile (use bottom nav instead) */
  .header-nav {
    display: none !important;
  }

  /* Header actions on mobile */
  .header-actions {
    gap: 4px !important;
  }

  /* Hide status label on mobile, just show dot */
  .header-status .status-label {
    display: none !important;
  }

  .header-status {
    padding: 6px !important;
    border-radius: 50% !important;
  }

  /* Compact icon buttons on mobile */
  .header-icon-btn {
    padding: 6px !important;
    border: none !important;
  }

  .header-icon-btn .btn-label {
    display: none !important;
  }

  /* Compact user button on mobile */
  .header-user-btn {
    padding: 2px 6px 2px 2px !important;
  }

  .user-email,
  .dropdown-arrow {
    display: none !important;
  }

  .user-avatar {
    width: 22px !important;
    height: 22px !important;
    font-size: 10px !important;
  }

  /* Legacy header elements - hide */
  .dashboard-header .header-left,
  .dashboard-header .header-right,
  .dashboard-header .subtitle {
    display: none !important;
  }

  /* Hide less important header items on mobile */
  .dashboard-header .btn-logout,
  .dashboard-header #logout-btn-header,
  .dashboard-header #keyboard-shortcut-hint {
    display: none !important;
  }

  /* Account selector - match compose button size */
  .sidebar-account-selector {
    padding: 12px 16px;
  }

  #account-selector-btn,
  .account-selector-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 24px;
    min-height: 44px;
  }

  #current-account-name {
    flex: 1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Touch-friendly navigation items in sidebar */
  .sidebar-nav-item,
  .queue-item,
  .category-item {
    padding: 12px 14px;
    min-height: 44px;
    font-size: 14px;
  }
}

/* Small phone specific - even tighter */
@media (max-width: 480px) {
  .dashboard-header {
    padding: 4px 8px;
    min-height: 40px;
    max-height: 40px;
  }

  .dashboard-header h1 {
    font-size: 13px;
  }

  /* Account selector inherits 768px styles - keep same size on small phones */

  /* Tighter email rows */
  .inbox-email-row {
    padding: 6px 8px;
    min-height: 48px;
  }
}

/* ========================================
   MOBILE BOTTOM TAB BAR
   ======================================== */

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  /* Hide desktop tab nav on mobile */
  .tab-navigation.desktop-only {
    display: none;
  }

  /* Show mobile bottom nav */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  }

  .mobile-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    max-width: 80px;
    height: 100%;
    background: none;
    border: none;
    color: #5f6368;
    cursor: pointer;
    padding: 6px 4px;
    transition: color 0.2s;
  }

  .mobile-tab-btn.active {
    color: #1a73e8;
  }

  .mobile-tab-icon {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 2px;
  }

  .mobile-tab-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
  }

  /* Bottom nav containers */
  .bottom-nav-tabs,
  .bottom-nav-actions {
    display: flex;
    width: 100%;
    height: 100%;
    justify-content: space-around;
    align-items: center;
  }

  /* Email action buttons for bottom nav */
  .mobile-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    max-width: 65px;
    height: 100%;
    background: none;
    border: none;
    color: #5f6368;
    cursor: pointer;
    padding: 4px 2px;
    transition: all 0.2s;
  }

  .mobile-action-btn:hover,
  .mobile-action-btn:active {
    color: #1a73e8;
    background: rgba(26, 115, 232, 0.08);
  }

  .mobile-action-btn.primary {
    color: #34a853;
  }

  .mobile-action-btn.primary:hover,
  .mobile-action-btn.primary:active {
    color: #2d8f47;
    background: rgba(52, 168, 83, 0.1);
  }

  .mobile-action-btn .action-icon {
    font-size: 18px;
    line-height: 1;
    margin-bottom: 2px;
  }

  .mobile-action-btn .action-label {
    font-size: 9px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
  }

  /* Mobile bottom nav takes 56px - account for it in flex layout */
  .dashboard-container {
    padding-bottom: 56px; /* Space for fixed bottom nav */
  }

  /* panel-viewport uses flex: 1 from base styles, no fixed height needed */

  /* Sidebar content styling - positioned in earlier 768px block */
  /* Ensure sidebar content is visible */
  .panel-actions .gmail-sidebar,
  .panel-actions .workflow-sidebar {
    display: block !important;
    position: static !important;
    left: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100%;
    background: white;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .panel-actions .sidebar-header,
  .panel-actions .label-list,
  .panel-actions .label-section,
  .panel-actions .queue-item {
    display: block !important;
    visibility: visible !important;
  }

  .panel-actions .label-section-title {
    display: block !important;
  }
}

@media (max-width: 480px) {
  .mobile-bottom-nav {
    height: 52px;
  }

  .mobile-tab-icon {
    font-size: 18px;
  }

  .mobile-tab-label {
    font-size: 9px;
  }

  /* Smaller bottom nav on small phones */
  .dashboard-container {
    padding-bottom: 52px;
  }
}

/* ========================================
   SSE STATUS INDICATOR
   ======================================== */

.sse-status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  transition: background-color 0.3s ease;
  align-self: center;
}

/* Connected state - green */
.sse-status-indicator.connected {
  background-color: #10b981;
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
}

/* Connecting state - yellow with pulse */
.sse-status-indicator.connecting {
  background-color: #f59e0b;
  animation: sse-pulse 1.5s ease-in-out infinite;
}

/* Disconnected state - gray */
.sse-status-indicator.disconnected {
  background-color: #9ca3af;
}

/* Pulse animation for updates */
.sse-status-indicator.pulse {
  animation: sse-flash 1s ease-out;
}

@keyframes sse-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes sse-flash {
  0% {
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
  }
  50% {
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.8);
  }
  100% {
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
  }
}

/* Hide header elements on mobile when viewing email for more reading space */
@media (max-width: 768px) {
  body.viewing-email .header-right {
    display: none !important;
  }

  /* Also simplify the header when viewing email */
  body.viewing-email .page-header .header-left h1 {
    font-size: 16px;
  }

  body.viewing-email .page-header .header-left .subtitle {
    display: none;
  }
}

/* Current filter indicator in toolbar */
.current-filter-indicator {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  padding: 4px 10px;
  background: #f0f4f8;
  border-radius: 12px;
  white-space: nowrap;
  margin-left: 8px;
}

/* Inbox filter checkboxes */
.inbox-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #5f6368;
  cursor: pointer;
  user-select: none;
}

.filter-checkbox input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: #1a73e8;
}

.filter-checkbox span {
  white-space: nowrap;
}

.filter-checkbox:hover {
  color: #1a73e8;
}

.filter-checkbox input:checked + span {
  color: #1a73e8;
  font-weight: 500;
}

@media (max-width: 768px) {
  .current-filter-indicator {
    font-size: 12px;
    padding: 3px 8px;
  }

  /* Hide checkbox on mobile to give more room for filter name */
  .toolbar-left #inbox-select-all {
    display: none;
  }

  .current-filter-indicator {
    margin-left: 0;
  }

  .inbox-filters {
    gap: 8px;
    margin-left: 8px;
  }

  .filter-checkbox {
    font-size: 11px;
  }

  .filter-checkbox span {
    display: inline; /* Show labels on mobile too */
  }
}

/* ========================================
   MOBILE OVERFLOW PREVENTION
   Prevents horizontal scroll/pan that interferes with swipe
   ======================================== */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    position: relative;
  }

  /* Prevent any element from causing horizontal overflow */
  .dashboard-container,
  .panel-container,
  .inbox-main,
  #inbox-list-container {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  /* Viewer header - ensure nav buttons fit */
  .viewer-header {
    flex-wrap: nowrap;
    padding: 8px 10px;
    gap: 6px;
  }

  .viewer-nav {
    gap: 4px;
    flex-shrink: 0;
  }

  .viewer-nav-btn {
    padding: 6px 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Compact the back button */
  .viewer-back-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ========================================
   Snooze Modal
   ======================================== */
.snooze-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.snooze-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
}

.snooze-modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  min-width: 320px;
  max-width: 400px;
  overflow: hidden;
  animation: snoozeModalIn 0.2s ease-out;
}

@keyframes snoozeModalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.snooze-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #fafafa;
}

.snooze-modal-icon {
  font-size: 24px;
}

.snooze-modal-title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.snooze-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.snooze-modal-close:hover {
  color: #333;
}

.snooze-modal-body {
  padding: 16px 20px;
}

.snooze-quick-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.snooze-quick-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.snooze-quick-btn:hover {
  background: #f5f5f5;
  border-color: #1a73e8;
}

.snooze-btn-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.snooze-btn-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.snooze-btn-time {
  font-size: 12px;
  color: #666;
}

.snooze-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: #999;
  font-size: 13px;
}

.snooze-divider::before,
.snooze-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e0e0e0;
}

.snooze-divider span {
  padding: 0 12px;
}

.snooze-custom {
  display: flex;
  gap: 12px;
}

.snooze-custom-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.snooze-custom-row label {
  font-size: 13px;
  color: #666;
}

.snooze-input {
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
}

.snooze-input:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.snooze-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid #e0e0e0;
  background: #fafafa;
}

.snooze-btn-cancel {
  padding: 10px 20px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: white;
  color: #666;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.snooze-btn-cancel:hover {
  background: #f5f5f5;
}

.snooze-btn-confirm {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  background: #1a73e8;
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.snooze-btn-confirm:hover {
  background: #1557b0;
}

/* Snooze/Follow-up indicators on email rows */
.email-snooze-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
}

.email-snooze-badge.snoozed {
  background: #f3f4f6;
  color: #6b7280;
}

.email-snooze-badge.due {
  background: #fef3c7;
  color: #92400e;
  animation: pulse-due 2s ease-in-out infinite;
}

@keyframes pulse-due {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.email-snooze-badge.follow-up {
  background: #dbeafe;
  color: #1e40af;
}

/* Snoozed (not due) row dimming */
.inbox-email-row.snoozed-pending {
  opacity: 0.65;
}

.inbox-email-row.snoozed-pending:hover {
  opacity: 0.85;
}
