/**
 * WorkPilot Email Layout
 * Three-pane Outlook-style layout with nav, email-list, reading-pane
 * 
 * @version 1.0.0
 * @since UI Migration Phase 1
 */

/* ========================================
   EMAIL LAYOUT CSS VARIABLES
   ======================================== */

:root {
  /* Email layout dimensions */
  --email-header-h: 44px;
  --email-nav-w: 44px;
  --email-nav-w-expanded: 180px;
  --email-list-w: 260px;
  --email-list-min-w: 180px;
  --email-list-max-w: 400px;
  
  /* Email-specific colors (complement existing variables.css) */
  --email-surface: #ffffff;
  --email-border: #e5e5e5;
  --email-border-light: #f0f0f0;
  --email-text: #1a1a1a;
  --email-text-secondary: #666666;
  --email-text-muted: #999999;
  
  /* Outcome tag colors */
  --tag-red-bg: #FDECEC;
  --tag-red-fg: #B42318;
  --tag-amber-bg: #FFF4E5;
  --tag-amber-fg: #B54708;
  --tag-blue-bg: #E8F1FF;
  --tag-blue-fg: #175CD3;
  
  /* Email transitions */
  --email-transition: 0.2s ease;
}

/* ========================================
   EMAIL MODE MAIN LAYOUT
   ======================================== */

.main.main--email {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding: 0;
  gap: 0;
  max-width: 100%;
  width: 100%;
  margin: 0;
}

/* ========================================
   COMBINED SIDEBAR (Folders + Email List)
   Replaces separate email-nav + email-list panels
   ======================================== */

.main--email > .sidebar {
  width: 260px;
  min-width: 200px;
  max-width: 400px;
  background: var(--email-surface);
  border-right: 1px solid var(--email-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: width 0.25s ease, min-width 0.25s ease;
  /* Override layout.css floating card styles */
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  border-left: none;
  border-top: none;
  border-bottom: none;
  height: auto;
  top: auto;
}

.main--email > .sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

/* Sidebar header: account info + compose */
.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--email-border-light, #f0f0f0);
  flex-shrink: 0;
}

.sidebar__account {
  flex: 1;
  min-width: 0;
}

.sidebar__compose {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 5px 10px;
  flex-shrink: 0;
}

/* Account info (rendered by JS) */
.sidebar__account .email-list__account-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar__account .email-list__account-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar__account .email-list__account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar__account .email-list__account-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar__account .email-list__account-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--email-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__account .email-list__account-provider {
  font-size: 10px;
  color: var(--email-text-muted);
}

.sidebar__account .email-list__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--email-text);
}

/* Sidebar search */
.sidebar__search {
  padding: 6px 10px;
  position: relative;
  flex-shrink: 0;
}

.sidebar__search-input {
  width: 100%;
  padding: 5px 10px 5px 28px;
  border: 1px solid var(--email-border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--color-background-alt, #f8f8f8);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.sidebar__search-input:focus {
  border-color: var(--color-primary, #2563EB);
  background: var(--email-surface);
}

.sidebar__search-input::placeholder {
  color: var(--email-text-muted);
}

.sidebar__search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--email-text-muted);
  pointer-events: none;
}

/* Sidebar folder navigation */
.sidebar__nav {
  padding: 2px 8px;
  flex-shrink: 0;
}

.sidebar__nav .email-nav__tree {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Restyle folder items to match reference design */
.sidebar__nav .email-nav__folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--email-text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  min-height: 28px;
}

.sidebar__nav .email-nav__folder-item:hover {
  background: var(--color-background-alt, #f5f5f5);
  color: var(--email-text);
}

.sidebar__nav .email-nav__folder-item--active {
  background: var(--color-primary-light, rgba(37, 99, 235, 0.08));
  color: var(--color-primary, #2563EB);
  font-weight: 600;
}

/* Folder item elements within sidebar */
.sidebar__nav .email-nav__folder-icon {
  font-size: 13px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.sidebar__nav .email-nav__folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline !important;
}

.sidebar__nav .email-nav__folder-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-primary, #2563EB);
  background: var(--color-primary-light, rgba(37, 99, 235, 0.1));
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
  display: inline !important;
}

.sidebar__nav .email-nav__folder-badge:empty {
  display: none !important;
}

/* Folder expand/collapse chevrons in sidebar — same width as spacer for alignment */
.sidebar__nav .email-nav__folder-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 20px;
  min-width: 20px;
  font-size: 7px;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--email-text-muted);
  line-height: 1;
}

.sidebar__nav .email-nav__folder-chevron-spacer {
  width: 20px;
  min-width: 20px;
  flex-shrink: 0;
  display: inline-block;
}

/* Folder list wrapper — caps visible height in expanded mode */
.folder-tree__list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.folder-tree__list--expanded {
  max-height: 140px;  /* ~4.5 items × 32px */
  overflow-y: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.folder-tree__list--expanded::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.folder-tree__list--expanded::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.folder-tree__list--expanded::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
  background-clip: content-box;
}

/* Collapsible secondary folders */
.folder-tree__secondary {
  display: none;
  flex-direction: column;
  gap: 0;
}

.folder-tree__secondary--open {
  display: flex;
}

/* Expand / collapse toggle — thin divider with centered chevron */
.folder-tree__toggle {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 12px;
  margin: 4px 0 0;
  height: 10px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.folder-tree__toggle:hover .folder-tree__toggle-chevron::after {
  border-color: var(--color-primary, #2563EB);
}

.folder-tree__toggle--disabled {
  cursor: default;
  pointer-events: none;
}

.folder-tree__toggle--disabled:hover .folder-tree__toggle-chevron::after {
  border-color: var(--color-primary, #2563EB);
  opacity: 0.6;
}

.folder-tree__toggle-line {
  flex: 1;
  height: 1px;
  background: var(--email-border-light, #ddd);
}

.folder-tree__toggle-chevron {
  width: 14px;
  height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.folder-tree__toggle-chevron::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--color-primary, #2563EB);
  border-bottom: 2px solid var(--color-primary, #2563EB);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s ease;
  opacity: 0.6;
}

.folder-tree__toggle:hover .folder-tree__toggle-chevron::after {
  opacity: 1;
}

.folder-tree__toggle-chevron--open::after {
  transform: rotate(-135deg) translateY(-2px);
}

/* Folder tree vertical resize handle (drag to resize list height) */
.folder-tree__resize-handle {
  height: 5px;
  margin: 2px 0 0;
  cursor: row-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background 0.15s;
}

.folder-tree__resize-handle:hover,
.folder-tree__resize-handle--active {
  background: var(--color-primary, #2563EB);
}

/* Folder row wrapper (item + menu) for create subfolder */
.email-nav__folder-row {
  position: relative;
}

/* Three-dot menu button — visible on folder item hover (Outlook-style) */
.email-nav__folder-more {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0 2px 0 auto;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--email-text-secondary, #666);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.sidebar__nav .email-nav__folder-item:hover .email-nav__folder-more,
.email-nav__folder-more:hover,
.email-nav__folder-more[aria-expanded="true"] {
  opacity: 1;
}
.email-nav__folder-more:hover {
  background: var(--color-background-alt, rgba(0,0,0,0.06));
  color: var(--email-text, #333);
}

/* Dropdown menu for folder actions — fixed when open so not clipped by overflow */
.email-nav__folder-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 180px;
  margin-top: 2px;
  padding: 4px 0;
  background: var(--color-surface, #fff);
  border: 1px solid var(--email-border-light, #e5e5e5);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 10000;
}
.email-nav__folder-menu[hidden] {
  display: none !important;
}
.email-nav__folder-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  color: var(--email-text, #333);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}
.email-nav__folder-menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  flex-shrink: 0;
}
.email-nav__folder-menu-icon svg {
  width: 14px;
  height: 14px;
}
.email-nav__folder-menu-item:hover {
  background: var(--color-primary-light, rgba(37, 99, 235, 0.08));
  color: var(--email-text, #111);
}
.email-nav__folder-menu-item:active {
  background: var(--email-border-light, #ddd);
}
.email-nav__folder-menu-item--danger:hover {
  background: rgba(220, 53, 69, 0.1);
  color: var(--color-danger, #dc3545);
}
.email-nav__folder-menu-item--danger:active {
  background: rgba(220, 53, 69, 0.18);
}

/* Inline rename row (same layout as new subfolder) */
.email-nav__folder-rename-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  margin: 2px 0;
  min-height: 28px;
}

/* New folder button row (after all folder items) */
.email-nav__new-folder-row {
  flex-shrink: 0;
  padding: 4px 8px;
  margin-top: 2px;
}
.email-nav__new-folder-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-primary, #2563EB);
  cursor: pointer;
  transition: background 0.15s ease;
}
.email-nav__new-folder-btn:hover {
  background: var(--color-primary-light, rgba(37, 99, 235, 0.08));
}
.email-nav__new-folder-btn[hidden] {
  display: none !important;
}

/* Inline new folder / subfolder input (no modal) */
.email-nav__new-folder-inline,
.email-nav__folder-new-subfolder {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  margin: 2px 0;
  min-height: 28px;
}
.email-nav__new-folder-input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--email-border-light, #ddd);
  border-radius: 4px;
  font-size: 13px;
  outline: none;
}
.email-nav__new-folder-input:focus {
  border-color: var(--color-primary, #2563EB);
}
.email-nav__new-folder-confirm,
.email-nav__new-folder-cancel {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.email-nav__new-folder-confirm {
  background: var(--color-primary-light, rgba(37, 99, 235, 0.15));
  color: var(--color-primary, #2563EB);
}
.email-nav__new-folder-confirm:hover {
  background: var(--color-primary, #2563EB);
  color: #fff;
}
.email-nav__new-folder-cancel {
  background: transparent;
  color: var(--email-text-secondary, #666);
}
.email-nav__new-folder-cancel:hover {
  background: var(--color-background-alt, #f0f0f0);
  color: var(--email-text, #333);
}

/* Sidebar divider */
.sidebar__divider {
  height: 1px;
  background: var(--email-border-light, #f0f0f0);
  margin: 4px 14px;
  flex-shrink: 0;
}

/* Hide the explicit divider when folder nav is visible above it —
   the folder-tree toggle line already acts as a separator. */
.sidebar__nav + .sidebar__divider {
  display: none;
}

/* Manual input section */
.sidebar__manual {
  padding: 0 10px 4px;
  flex-shrink: 0;
}

.sidebar__manual-btn {
  width: 100%;
  justify-content: center;
  color: var(--email-text-secondary);
  font-size: 12px;
}

.sidebar__manual-btn:hover {
  color: var(--color-primary, #2563EB);
  background: rgba(37, 99, 235, 0.05);
}

/* Email items area (scrollable, takes remaining space) */
.sidebar__emails {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar__emails .email-list__items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 4px;
}

/* Compact email items inside sidebar */
.sidebar__emails .email-item {
  padding: 8px 8px;
  gap: 8px;
}

.sidebar__emails .email-item__from {
  font-size: 12px;
}

.sidebar__emails .email-item__subject {
  font-size: 11px;
}

.sidebar__emails .email-item__preview {
  font-size: 11px;
}

.sidebar__emails .email-item__time {
  font-size: 10px;
}

.sidebar__emails .email-item__tag {
  font-size: 8px;
  padding: 1px 5px;
}

.sidebar__emails .email-item__avatar {
  width: 34px;
  height: 34px;
  font-size: 13px;
}


.sidebar__emails .email-list__connect {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  text-align: center;
  flex: 1;
}

/* Bottom navigation bar */
.sidebar__bottom-nav {
  flex-shrink: 0;
  display: flex;
  border-top: 1px solid var(--email-border);
  background: var(--email-surface);
  padding: 1px 4px;
}

.sidebar__nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 4px 0 3px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.1s;
}

.sidebar__nav-btn:hover {
  background: var(--color-background-alt, #f5f5f5);
}

.sidebar__nav-btn--active {
  background: var(--color-primary-light, rgba(37, 99, 235, 0.08));
}

.sidebar__nav-icon {
  font-size: 14px;
  line-height: 1;
}

.sidebar__nav-label {
  font-size: 8px;
  font-weight: 600;
  color: var(--email-text-muted);
}

.sidebar__nav-btn--active .sidebar__nav-label {
  color: var(--color-primary, #2563EB);
}

/* Sidebar status bar (pinned to bottom) */
.sidebar__status {
  padding: 4px 12px;
  border-top: 1px solid var(--email-border);
  font-size: 10px;
  color: var(--email-text-muted, #999);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  height: 22px;
  background: var(--email-bg, #f9f9f9);
  margin-top: auto;
}

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

/* Sidebar resize handle (right edge) */
.sidebar__resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
  transition: background 0.15s;
}

.sidebar__resize-handle:hover,
.sidebar__resize-handle--active {
  background: var(--color-primary, #2563EB);
}

/* ========================================
   LEGACY NAV BAR (hidden in sidebar mode)
   Kept for backwards compatibility
   ======================================== */

.email-nav {
  display: flex;
  flex-direction: column;
  width: var(--email-nav-w);
  min-width: var(--email-nav-w);
  background: var(--email-surface);
  border-right: 1px solid var(--email-border);
  padding: 6px;
  gap: 2px;
  flex-shrink: 0;
  transition: width var(--email-transition), min-width var(--email-transition);
}

/* When inside sidebar, nav is a section, not a standalone panel */
.sidebar .email-nav,
.sidebar .sidebar__nav {
  width: auto !important;
  min-width: 0 !important;
  border-right: none;
  padding: 0;
  background: transparent;
}

/* R1: Expanded state - shows labels */
.email-nav--expanded {
  width: var(--email-nav-w-expanded);
  min-width: var(--email-nav-w-expanded);
}

/* R1: Nav toggle button (hidden in sidebar mode) */
.email-nav__toggle {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--email-text-muted);
  margin-top: auto;
  transition: background 0.1s, color 0.1s, transform 0.2s;
}

.sidebar .email-nav__toggle {
  display: none;
}

.email-nav__toggle:hover {
  background: var(--color-background-alt);
  color: var(--email-text);
}

.email-nav--expanded .email-nav__toggle {
  transform: rotate(180deg);
}

/* ========================================
   FOLDER TREE (Dynamic Nav)
   ======================================== */

/* Nav header: account label + toggle */
.email-nav__header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--email-border-light);
  flex-shrink: 0;
}

/* Hide nav header inside sidebar (account info is in sidebar header) */
.sidebar .email-nav__header {
  display: none;
}

.email-nav__header .email-nav__toggle {
  margin-top: 0;
  flex-shrink: 0;
}

.email-nav__account {
  font-size: 11px;
  color: var(--email-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Hide account label when collapsed */
.email-nav:not(.email-nav--expanded) .email-nav__account {
  display: none;
}

/* Folder tree container */
.email-nav__tree {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  padding: 4px 0;
}

/* Individual folder item */
.email-nav__folder-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  margin: 0 4px;
  color: var(--email-text-secondary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.1s, color 0.1s;
  min-height: 28px;
  user-select: none;
}

.email-nav__folder-item:hover {
  background: var(--color-background-alt);
  color: var(--email-text);
}

.email-nav__folder-item--active {
  background: var(--color-primary-light, rgba(37, 99, 235, 0.1));
  color: var(--color-primary, #2563EB);
}

.email-nav__folder-item:focus {
  outline: 2px solid var(--color-primary, #2563EB);
  outline-offset: -2px;
  border-radius: 4px;
}

.email-nav__folder-item:focus:not(:focus-visible) {
  outline: none;
}

/* Expand/collapse chevron — same width as spacer so same-level items align */
.email-nav__folder-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 20px;
  min-width: 20px;
  font-size: 8px;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s;
  color: var(--email-text-muted);
  line-height: 1;
  border-radius: 4px;
}

.email-nav__folder-chevron--open {
  transform: rotate(90deg);
}

/* Spacer for folders without children (same width as chevron for alignment) */
.email-nav__folder-chevron-spacer {
  width: 20px;
  min-width: 20px;
  flex-shrink: 0;
  display: inline-block;
}

/* Folder icon */
.email-nav__folder-icon {
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1;
}

/* Folder name */
.email-nav__folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Unread count badge */
.email-nav__folder-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--email-text-secondary);
  flex-shrink: 0;
  margin-left: auto;
  padding: 0 4px;
}

/* Collapsed state: folder items become icon-only (standalone nav only) */
.email-nav:not(.email-nav--expanded) .email-nav__folder-item {
  padding: 4px 0;
  justify-content: center;
  margin: 0 2px;
  position: relative;
}

.email-nav:not(.email-nav--expanded) .email-nav__folder-chevron,
.email-nav:not(.email-nav--expanded) .email-nav__folder-chevron-spacer,
.email-nav:not(.email-nav--expanded) .email-nav__folder-name,
.email-nav:not(.email-nav--expanded) .email-nav__folder-badge {
  display: none;
}

/* Unread dot indicator in collapsed mode */
.email-nav:not(.email-nav--expanded) .email-nav__folder-item[data-has-unread="true"]::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary, #2563EB);
}

/* Hide subfolders when nav is collapsed */
.email-nav:not(.email-nav--expanded) .email-nav__folder-item:not([data-depth="0"]) {
  display: none;
}

/* Override: inside sidebar, folder items always show full content regardless of expanded state */
.sidebar .email-nav__folder-item {
  padding-top: 5px !important;
  padding-right: 10px !important;
  padding-bottom: 5px !important;
  justify-content: flex-start !important;
  margin: 0 !important;
}

.sidebar .email-nav__folder-name {
  display: inline !important;
}

.sidebar .email-nav__folder-badge {
  display: inline !important;
}

.sidebar .email-nav__folder-badge:empty {
  display: none !important;
}

.sidebar .email-nav__folder-item[data-has-unread="true"]::after {
  display: none;
}

/* Loading / error state in folder tree */
.email-nav__tree-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--email-text-muted);
  font-size: 12px;
}

/* ========================================
   NAV RESIZE HANDLE (legacy - hidden in sidebar mode)
   ======================================== */

.email-nav__resize-handle {
  position: relative;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  z-index: 10;
  transition: background 0.15s;
  display: none;
}

.email-nav__resize-handle:hover,
.email-nav__resize-handle--active {
  background: var(--color-primary, #2563EB);
}

/* ========================================
   DRAG AND DROP STATES
   ======================================== */

/* Email item during drag */
.email-item--dragging {
  opacity: 0.5;
}

/* Compact drag ghost pill (positioned offscreen, captured by setDragImage) */
.email-drag-ghost {
  position: fixed;
  top: -200px;
  left: -200px;
  max-width: 220px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--color-primary, #2563EB);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 9999;
}

/* Folder as valid drop target */
.email-nav__folder-item--dragover {
  background: rgba(37, 99, 235, 0.12) !important;
  border-left: 2px dashed var(--color-primary, #2563EB);
  padding-left: 6px !important;
}

/* Drop success flash */
.email-nav__folder-item--drop-success {
  animation: folder-drop-flash 0.6s ease-out;
}

@keyframes folder-drop-flash {
  0% { background: rgba(16, 185, 129, 0.3); }
  100% { background: transparent; }
}

/* ========================================
   MANUAL MODE BANNER
   ======================================== */

.reading-pane__manual-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--tag-blue-bg, #E8F1FF);
  color: var(--tag-blue-fg, #175CD3);
  font-size: 12px;
  border-bottom: 1px solid rgba(23, 92, 211, 0.15);
  flex-shrink: 0;
}

.reading-pane__manual-banner-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 14px;
  opacity: 0.6;
  padding: 0 4px;
}

.reading-pane__manual-banner-dismiss:hover {
  opacity: 1;
}

/* ========================================
   EMAIL LIST (inside sidebar or standalone)
   ======================================== */

.email-list {
  width: var(--email-list-w);
  min-width: var(--email-list-min-w);
  max-width: var(--email-list-max-w);
  min-height: 0;
  background: var(--email-surface);
  border-right: 1px solid var(--email-border);
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.email-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--email-border);
  background: var(--email-surface);
  flex-shrink: 0;
}

/* Email list account info in header */
.email-list__account {
  flex: 1;
  min-width: 0;
}

.email-list__account-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.email-list__account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.email-list__account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.email-list__account-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.email-list__account-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--email-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.email-list__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--email-text);
}

.email-list__compose {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 5px 10px;
}

.email-list__search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--email-border-light);
  position: relative;
}

.email-list__search-input {
  width: 100%;
  padding: 8px 10px 8px 30px;
  border: 1px solid var(--email-border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--color-background-alt);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.email-list__search-input:focus {
  border-color: var(--color-primary, #2563EB);
  background: var(--email-surface);
}

.email-list__search-input::placeholder {
  color: var(--email-text-muted);
}

.email-list__search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--email-text-muted);
  pointer-events: none;
}

.email-list__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-compose {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: none;
  background: var(--color-primary, #2563EB);
  color: white;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-compose:hover {
  background: var(--color-primary-dark, #d45003);
  transform: translateY(-1px);
}

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

/* Email list content wrapper - enables scrolling */
.email-list__content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Email list items container */
.email-list__items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Connection prompt */
.email-list__connect {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  height: 100%;
}

.email-list__connect-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.email-list__connect-text {
  font-size: 14px;
  color: var(--email-text-secondary);
  margin-bottom: 16px;
}

/* OR divider */
.email-list__or {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 20px 0;
  color: var(--email-text-muted);
  font-size: 12px;
  font-weight: 500;
}

.email-list__or::before,
.email-list__or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--email-border);
}

.email-list__or span {
  padding: 0 12px;
}

/* Manual input button in connect prompt */
.email-list__connect .btn--outline {
  border: 1px solid var(--color-primary, #2563EB);
  color: var(--color-primary, #2563EB);
  background: transparent;
}

.email-list__connect .btn--outline:hover {
  background: rgba(37, 99, 235, 0.05);
}

/* Manual input option below search (when connected) */
.email-list__manual {
  padding: 0 12px 8px;
}

.email-list__manual-divider {
  height: 1px;
  background: var(--email-border-light);
  margin-bottom: 8px;
}

.email-list__manual-btn {
  width: 100%;
  justify-content: center;
  color: var(--email-text-secondary);
  font-size: 12px;
}

.email-list__manual-btn:hover {
  color: var(--color-primary, #2563EB);
  background: rgba(37, 99, 235, 0.05);
}

/* Loading state */
.email-list__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  color: var(--email-text-muted);
  font-size: 13px;
}

/* Empty state */
.email-list__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  color: var(--email-text-muted);
  font-size: 13px;
}

.email-list__load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  font-size: 12px;
  color: var(--email-text-muted, #6b7280);
}

.email-list__load-more-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--email-border, #e5e7eb);
  border-top-color: var(--color-primary, #2563eb);
  border-radius: 50%;
  animation: email-list-spin 0.7s linear infinite;
}

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

/* ========================================
   MANUAL INPUT MODAL
   ======================================== */

.manual-input-area {
  position: relative;
  border: 2px dashed var(--email-border);
  border-radius: 8px;
  background: var(--color-background-alt);
  transition: border-color 0.15s, background 0.15s;
}

.manual-input-area:focus-within {
  border-color: var(--color-primary, #2563EB);
  background: var(--email-surface);
}

.manual-input-area__textarea {
  width: 100%;
  min-height: 150px;
  padding: 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  font-family: inherit;
}

.manual-input-area__textarea::placeholder {
  color: var(--email-text-muted);
}

.manual-input-area__overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.05);
  border-radius: 6px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

.manual-input-area--dragover .manual-input-area__overlay {
  display: flex;
}

.manual-input-area__overlay-icon {
  font-size: 32px;
}

.manual-input-area__overlay-text {
  font-size: 14px;
  color: var(--color-primary, #2563EB);
  font-weight: 500;
}

.manual-input-goal {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  background: #fff7ed;
  border-radius: 6px;
  font-size: 13px;
}

.manual-input-goal__label {
  font-weight: 600;
  color: var(--color-primary, #2563EB);
  text-transform: uppercase;
  font-size: 11px;
}

.manual-input-goal__text {
  color: var(--email-text-secondary);
}

/* ========================================
   EMAIL ITEM
   ======================================== */

.email-item {
  display: flex;
  gap: 9px;
  padding: 10px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.12s;
  position: relative;
  overflow: hidden;
  margin-bottom: 1px;
}

.email-item__content {
  flex: 1;
  min-width: 0;
  position: relative;
}

/* Sender avatar — sits to the left of content */
.email-item__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

/* Slide-out action buttons */
.email-item__actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 16px;
  padding-right: 4px;
  transform: translateX(100%);
  transition: transform 0.15s ease-out;
  background: linear-gradient(to right, transparent, var(--email-surface-hover, #f8fafc) 12px, var(--email-surface-hover, #f8fafc));
  border-radius: 0 7px 7px 0;
  z-index: 1;
}

.email-item:hover .email-item__actions {
  transform: translateX(0);
}

.email-item__delete {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--email-text-muted);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}

.email-item__delete:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.email-item__delete:active {
  background: rgba(220, 38, 38, 0.2);
}

.email-item:hover {
  background: var(--email-surface-hover, #f8fafc);
}

.email-item--selected {
  background: var(--color-primary-light, rgba(37, 99, 235, 0.08));
}

.email-item--selected:hover {
  background: var(--color-primary-light, rgba(37, 99, 235, 0.12));
}

/* Unread state */
.email-item--unread {
  /* Dot indicator handled via bold text; rounded card shape preserved */
}

.email-item--unread .email-item__from {
  font-weight: 600;
  color: var(--email-text);
}

.email-item--unread .email-item__subject {
  font-weight: 500;
  color: var(--email-text);
}

/* Read state */
.email-item--read .email-item__from {
  font-weight: 400;
  color: var(--email-text-secondary);
}

.email-item--read .email-item__subject {
  color: var(--email-text-secondary);
}

.email-item--read .email-item__preview {
  color: var(--email-text-muted);
}

/* Email item rows */
.email-item__top {
  display: flex;
  align-items: center;
  gap: 4px;
}

.email-item__star {
  font-size: 12px;
  color: var(--email-border);
  cursor: pointer;
  transition: color 0.1s, transform 0.1s;
  flex-shrink: 0;
  opacity: 0;
}

.email-item:hover .email-item__star,
.email-item__star--active {
  opacity: 1;
}

.email-item__star:hover {
  color: #f59e0b;
  transform: scale(1.1);
}

.email-item__star--active {
  color: #f59e0b;
}

.email-item__from {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item__time {
  font-size: 11px;
  color: var(--email-text-muted);
  flex-shrink: 0;
  margin-left: 6px;
}

.email-item__attachment {
  font-size: 11px;
  flex-shrink: 0;
  opacity: 0.7;
  margin-left: auto;
  margin-right: 4px;
}

/* Conversation view: thread message count badge */
.email-item__thread-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 600;
  color: var(--email-text-muted);
  background: var(--color-border-light, #e2e8f0);
  border-radius: 9px;
  flex-shrink: 0;
  margin-left: 4px;
}

.email-item__middle {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.email-item__subject {
  font-size: 12px;
  color: var(--email-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Outcome Tags */
.email-item__tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 800;
  flex-shrink: 0;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.email-item__tag--red {
  background: var(--tag-red-bg);
  color: var(--tag-red-fg);
}

.email-item__tag--amber {
  background: var(--tag-amber-bg);
  color: var(--tag-amber-fg);
}

.email-item__tag--blue {
  background: var(--tag-blue-bg);
  color: var(--tag-blue-fg);
}

/* ========================================
   EMAIL PROCESSING INDICATORS
   ======================================== */

/* Processing state - spinner */
.email-item--processing {
  position: relative;
}

.email-item--processing .email-item__avatar {
  position: relative;
}

.email-item--processing .email-item__avatar::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 100%;
  height: 100%;
  border: 2px solid var(--color-border-solid, #e5e7eb);
  border-top-color: transparent;
  border-radius: 50%;
  animation: email-processing-spin 0.8s linear infinite;
}

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

/* Processing step badge */
.email-item__processing-badge {
  font-size: 10px;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 4px;
}

/* Processed indicator (checkmark) */
.email-item__processed-badge {
  font-size: 10px;
  color: var(--color-success, #10b981);
  line-height: 1;
  flex-shrink: 0;
  margin-left: 4px;
}

/* Guardian threat variant (shield icon) */
.email-item__processed-badge--guardian {
  color: var(--color-error, #ef4444);
}

/* New email highlight (from webhook) */
.email-item--new {
  animation: email-new-highlight 3s ease-out;
}

@keyframes email-new-highlight {
  0% { background-color: var(--tag-blue-bg); }
  100% { background-color: transparent; }
}

.email-item__preview {
  font-size: 12px;
  color: var(--email-text-muted, var(--email-text-secondary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  line-height: 1.4;
}

/* Quick actions on hover */
.email-item__quick-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 4px;
  background: var(--email-surface);
  padding: 4px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.email-item:hover .email-item__quick-actions {
  display: flex;
}

.email-item__quick-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--email-text-secondary);
  transition: background 0.1s, color 0.1s;
}

.email-item__quick-btn:hover {
  background: var(--color-background-alt);
  color: var(--email-text);
}

/* ========================================
   RESIZE HANDLE
   ======================================== */

.email-list__resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
  transition: background 0.15s;
}

.email-list__resize-handle:hover,
.email-list__resize-handle--active {
  background: var(--color-primary, #2563EB);
}

/* Prevent text selection during resize */
.is-resizing {
  user-select: none;
  cursor: col-resize !important;
}

.is-resizing * {
  cursor: col-resize !important;
}

/* ========================================
   READING PANE (Right Column)
   ======================================== */

.reading-pane {
  flex: 1;
  background: var(--color-background-alt);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Empty state */
.reading-pane__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--email-text-muted);
  gap: 12px;
  background: var(--email-surface);
  margin: 0;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--email-border);
}

.reading-pane__empty-icon {
  font-size: 48px;
  opacity: 0.4;
}

.reading-pane__empty-text {
  font-size: 14px;
}

.reading-pane__empty-user {
  font-size: 12px;
  color: var(--email-text-muted);
  margin-top: 4px;
}

/* Content wrapper - Minimal padding for compose-first design */
.reading-pane__content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--email-surface);
  margin: 0; /* Removed outer margin for edge-to-edge content */
  border-radius: 0;
}

/* ========================================
   THREAD VIEW (Gmail/Outlook-style email display)
   ======================================== */

.thread-view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.thread-view__header {
  padding: 16px 22px 8px;
  border-bottom: 1px solid var(--email-border);
  flex-shrink: 0;
}

.thread-view__subject {
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.thread-view__subject-text {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--email-text);
  margin: 0;
  
}

.thread-view__subject-input {
  display: none;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--email-text);
  margin: 0;
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  padding: 0;
  min-width: 0;
}

.thread-view__subject-input:focus {
  border-bottom: 1px solid var(--color-primary, #2563EB);
}

.thread-view__actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  align-items: center;
}

.thread-view__action-wrap {
  position: relative;
  display: inline-flex;
}

/* Outlook-style simple tooltip for Reply / Forward — below button so not clipped by overflow */
.thread-view__action-tooltip {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 4px 8px;
  background: var(--email-text, #1e293b);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1000;
}
.thread-view__action-wrap:hover .thread-view__action-tooltip {
  opacity: 1;
}

.thread-view__action {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--email-text-muted, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.thread-view__action:hover {
  background: var(--email-surface, #f1f5f9);
  color: var(--email-text);
}

.thread-view__action-icon {
  display: block;
  flex-shrink: 0;
}

/* More dropdown wrap */
.thread-view__action-more-wrap {
  position: relative;
  display: inline-flex;
}

.thread-view__action-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 140px;
  margin-top: 2px;
  padding: 4px 0;
  background: var(--color-surface, #fff);
  border: 1px solid var(--email-border-light, #e5e5e5);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 1100;
}
.thread-view__action-menu[hidden] {
  display: none !important;
}
.thread-view__action-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  color: var(--email-text, #333);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.thread-view__action-menu-item:hover {
  background: var(--color-primary-light, rgba(37, 99, 235, 0.08));
}
.thread-view__action-menu-item--danger:hover {
  background: rgba(220, 38, 38, 0.08);
  color: var(--color-danger, #dc2626);
}

.thread-view__meta {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.thread-view__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.thread-view__sender-info {
  flex: 1;
  min-width: 0;
}

.thread-view__sender-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--email-text);
  line-height: 1.2;
  padding-top: 1px;
}

.thread-view__sender-email {
  font-size: 12px;
  color: var(--email-text-secondary);
}

.thread-view__date {
  margin-left: auto;
  font-size: 12px;
  color: var(--email-text-secondary);
  flex-shrink: 0;
  padding-top: 2px;
}

.thread-view__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}

/* Attachment bar inside thread view body */
.thread-view__body > .outlook-email__attachments {
  margin: -18px -22px 12px;
}

.thread-view__message {
  font-size: 14px;
  line-height: 1.65;
  color: var(--email-text);
  border: 1px solid #EBEBEB;
  border-radius: 10px;
  padding: 15px 10px;
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
}

/* Conversation view: each message in thread has a header and separator */
.thread-view__message-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--email-border);
  font-size: 12px;
  color: var(--email-text-muted);
}

.thread-view__message-from {
  font-weight: 600;
  color: var(--email-text);
}

.thread-view__message-email {
  color: var(--email-text-muted);
}

.thread-view__message-date {
  margin-left: auto;
  flex-shrink: 0;
}

.thread-view__message--thread {
  margin-top: 20px;
  border-top: 1px solid var(--email-border);
}

/* Latest message in conversation: clear visual emphasis */
.thread-view__message--latest {
  border-color: var(--color-primary, #2563eb);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.04) 0%, var(--email-surface) 100%);
  box-shadow: 0 0 12px 0 rgba(37, 99, 235, 0.12);
}

.thread-view__message-badge {
  display: inline-block;
  padding: 2px 8px;
  margin-right: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-primary);
  background: rgba(37, 99, 235, 0.12);
  border-radius: 4px;
}

.thread-view__message p {
  margin-bottom: 10px;
}

.thread-view__message img {
  max-width: 100%;
  height: auto;
}

.thread-view__actions-output {
  overflow-y: auto;
  max-height: 40vh;
  flex-shrink: 0;
}

.thread-view__actions-output:empty {
  display: none;
}

/* Reply Trigger Bar */
.reply-trigger {
  padding: 10px 22px;
  border-top: 1px solid var(--email-border);
  background: linear-gradient(135deg, #f5f3ff 0%, var(--email-surface) 100%);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.reply-trigger__ai {
  padding: 6px 14px;
  border-radius: 6px;
  background: #7C3AED;
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.reply-trigger__ai:hover {
  filter: brightness(1.1);
}

.reply-trigger__manual {
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--email-surface);
  border: 1px solid var(--email-border);
  font-size: 12px;
  color: var(--email-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.reply-trigger__manual:hover {
  border-color: var(--color-primary, #2563EB);
  color: var(--color-primary, #2563EB);
}

.reply-trigger__spacer {
  flex: 1;
}

.reply-trigger__guard {
  font-size: 11px;
  color: #10B981;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Reply Zone */
.reply-zone {
  border-top: 1px solid var(--email-border);
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  animation: replySlideUp 0.3s ease;
}

.reply-zone--open {
  display: flex;
}

@keyframes replySlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.reply-zone .compose-area {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* ========================================
   COMPOSE-MODE FIELDS INSIDE THE HEADER
   Hidden in read mode, shown in compose mode.
   ======================================== */

/* To input — hidden in read mode */
.thread-view__to-input {
  display: none;
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--email-text);
  background: transparent;
  padding: 2px 0;
  font-family: inherit;
}

.thread-view__to-input::placeholder {
  color: var(--email-text-muted, #94a3b8);
}

/* Cc/Bcc toggle button — hidden in read mode */
.thread-view__ccbcc-btn {
  display: none;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--email-text-secondary, #64748b);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 3px;
  flex-shrink: 0;
}

.thread-view__ccbcc-btn:hover {
  color: var(--color-primary, #2563EB);
  background: var(--color-primary-bg, #fff7ed);
}

.thread-view__ccbcc-btn.is-expanded {
  color: var(--color-primary, #2563EB);
}

/* Expandable Cc/Bcc field rows — hidden by default via [hidden] */
.thread-view__ccbcc-fields:not([hidden]) {
  display: block;
  padding: 0 0 0 46px;
  margin-right: 200px;
}

.thread-view__ccbcc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
  border-bottom: 1px solid var(--email-border-light, #f1f5f9);
}

.thread-view__ccbcc-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--email-text-secondary, #64748b);
  min-width: 30px;
  flex-shrink: 0;
}

.thread-view__ccbcc-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--email-text);
  background: transparent;
  padding: 2px 0;
  font-family: inherit;
}

.thread-view__ccbcc-input::placeholder {
  color: var(--email-text-muted, #94a3b8);
}

/* ========================================
   COMPOSE MODE (full-pane, Outlook-style)
   Same header stays visible — fields become editable in place.
   Reorders flex children: header → compose → original body
   ======================================== */

.thread-view--compose {
  overflow-y: auto;
}

.thread-view--compose .thread-view__header {
  order: 1;
  flex-shrink: 0;
}

/* Subject: swap h2 for editable input */
.thread-view--compose .thread-view__subject-text {
  display: none;
}

.thread-view--compose .thread-view__subject-input {
  display: block;
}

/* Meta row: keep sender name visible, hide email address */
.thread-view--compose .thread-view__sender-email {
  display: none;
}

/* Hide suggested flow bar in compose mode */
.thread-view--compose .sf-bar {
  display: none !important;
}

/* Compose fields: To row — hidden in read mode, shown in compose */
.thread-view__compose-fields {
  display: none;
  padding: 0 0 0 46px;
  margin-top: -18px;
  margin-right: 200px;
}

.thread-view--compose .thread-view__compose-fields {
  display: block;
}

.thread-view--compose .thread-view__ccbcc-btn {
  display: inline-block;
}

.thread-view--compose .reply-zone {
  order: 2;
  border-top: none;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* Hide the original email body section — it's now inside the editor */
.thread-view--compose .thread-view__body {
  display: none !important;
}

.thread-view--compose .thread-view__actions-output {
  display: none;
}

.thread-view--compose .reply-trigger {
  display: none !important;
}

/* Editor fills all remaining vertical space */
.thread-view--compose .compose-area {
  flex: 1 1 0;
  min-height: 0;
}

.thread-view--compose .compose-editor-wrapper {
  flex: 1 1 0;
  min-height: 0;
}

.thread-view--compose .compose-editor {
  flex: 1 1 0;
  min-height: 0;
}

.thread-view--compose .compose-thread {
  display: none;
}

/* Original email thread inside compose */
.compose-thread {
  border-top: 1px solid var(--color-border, #e2e8f0);
  background: var(--color-surface-secondary, #f8fafc);
}

.compose-thread__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.compose-thread__toggle:hover {
  background: var(--color-slate-100, #f1f5f9);
}

.compose-thread__icon {
  font-size: 13px;
}

.compose-thread__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary, #64748b);
}

.compose-thread__chevron {
  margin-left: auto;
  font-size: 11px;
  color: var(--color-text-muted, #94a3b8);
}

.compose-thread__content {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-light, #e2e8f0);
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text, #1e293b);
}

.compose-thread__meta {
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
  margin-bottom: 4px;
}

.compose-thread__meta strong {
  color: var(--color-text, #1e293b);
}

.compose-thread__date {
  margin-left: 12px;
  font-size: 11px;
  color: var(--color-text-muted, #94a3b8);
}

.compose-thread__subject {
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
  margin-bottom: 8px;
}

.compose-thread__body {
  padding-left: 12px;
  border-left: 2px solid var(--color-border, #e2e8f0);
}

.compose-thread__body img {
  max-width: 100%;
  height: auto;
}

/* ========================================
   ICON BAR (Handler Dropdowns)
   ======================================== */

.icon-bar {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 8px;
  background: var(--email-surface);
  border-bottom: 1px solid var(--email-border);
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  min-width: 0;
  position: relative;
  z-index: 100;
}

.icon-bar__group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.icon-bar__group--left {
  flex-shrink: 0;
}

.icon-bar__group--right {
  margin-left: auto;
}

.icon-bar__group--tabs {
  gap: 0;
}

.icon-bar__new-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 5px 14px;
  white-space: nowrap;
}

.icon-bar__divider {
  width: 1px;
  height: 28px;
  background: var(--email-border);
  margin: 0 8px;
}

.icon-bar__btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--email-text-secondary);
  transition: background 0.1s, color 0.1s;
}

.icon-bar__btn:hover:not(:disabled) {
  background: var(--color-background-alt);
  color: var(--email-text);
}

.icon-bar__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: auto; /* Allow tooltip on disabled button */
}

.icon-bar__btn:disabled:hover {
  background: transparent;
  color: var(--email-text-secondary);
}

/* Icon bar disabled state (no email provider connected) */
.icon-bar.is-disabled {
  pointer-events: none;
  opacity: 0.4;
}

/* Daily Report Button in Icon Bar */
.icon-bar__eodr-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin-left: 8px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  height: 34px;
  flex-shrink: 0;
}

.icon-bar__eodr-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(245, 158, 11, 0.4);
}

.icon-bar__eodr-icon {
  font-size: 14px;
  color: white;
}

.icon-bar__eodr-label {
  font-size: 13px;
  font-weight: 500;
  color: white;
  white-space: nowrap;
}

.icon-bar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ========================================
   DROPDOWN MENUS
   ======================================== */

.dropdown {
  position: relative;
}

.dropdown__tab {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.dropdown__tab:hover {
  background: var(--color-background-alt);
}

.dropdown__tab:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--email-primary);
}

.dropdown__tab:focus:not(:focus-visible) {
  box-shadow: none;
}

.dropdown__tab:active,
.dropdown--open .dropdown__tab {
  background: var(--email-border-light);
}

.dropdown__tab-icon {
  font-size: 14px;
  line-height: 1;
}

.dropdown__tab-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--email-text);
}

.dropdown__tab-arrow {
  font-size: 8px;
  color: var(--email-text-muted);
  margin-left: 2px;
  transition: transform 0.15s;
}

.dropdown--open .dropdown__tab-arrow {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.dropdown__menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 180px;
  background: var(--email-surface);
  border: 1px solid var(--email-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.dropdown--open .dropdown__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown__item {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--email-text);
  cursor: pointer;
  transition: background 0.08s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dropdown__item:first-child {
  border-radius: 7px 7px 0 0;
}

.dropdown__item:last-child {
  border-radius: 0 0 7px 7px;
}

.dropdown__item:hover {
  background: var(--color-background-alt);
}

.dropdown__item:active {
  background: var(--email-border-light);
}

.dropdown__item:focus {
  outline: none;
  background: var(--color-background-alt);
  box-shadow: inset 0 0 0 2px var(--email-primary);
}

/* Selected/active state for current handler */
.dropdown__item--selected {
  background: rgba(0, 120, 212, 0.1);
  color: var(--email-primary);
  font-weight: 500;
}

.dropdown__item--selected::before {
  content: '✓';
  margin-right: 8px;
  font-size: 11px;
}

.dropdown__item-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ========================================
   AUTO VIEW
   ======================================== */

.auto-view {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}

.auto-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.08) 0%, rgba(16, 185, 129, 0.04) 100%);
  border: 1px solid rgba(5, 150, 105, 0.2);
  border-radius: 10px;
}

.auto-header__status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auto-header__icon {
  width: 24px;
  height: 24px;
  background: #059669;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.auto-header__text {
  font-size: 14px;
  font-weight: 500;
  color: var(--email-text);
}

.auto-header__note {
  font-size: 12px;
  color: var(--email-text-muted);
}

/* ========================================
   SUCCESS BAR (Plan Complete)
   ======================================== */

.success-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.08) 0%, rgba(16, 185, 129, 0.04) 100%);
  border: 1px solid rgba(5, 150, 105, 0.2);
  border-radius: 10px;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.success-bar[hidden] {
  display: none;
}

.success-bar__left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.success-bar__status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.success-bar__icon {
  width: 22px;
  height: 22px;
  background: #059669;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
}

.success-bar__text {
  font-size: 13px;
  font-weight: 500;
  color: var(--email-text);
}

.success-bar__goal {
  font-size: 12px;
  color: var(--email-text-muted);
  padding-left: 32px;
}

.success-bar__goal:empty {
  display: none;
}

.success-bar__alternatives {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.success-bar__alt-label {
  font-size: 11px;
  color: var(--email-text-muted);
  white-space: nowrap;
}

.success-bar__alt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: white;
  border: 1px solid rgba(5, 150, 105, 0.25);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--email-text);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.success-bar__alt:hover {
  background: rgba(5, 150, 105, 0.08);
  border-color: #059669;
}

.success-bar__alt-icon {
  font-size: 12px;
}

.success-bar__alt-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.success-bar__alt-score {
  font-size: 10px;
  color: #059669;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(5, 150, 105, 0.1);
  border-radius: 10px;
}

/* ========================================
   READING PANE CONTENT (Compose-First Design)
   ======================================== */

/* Content area wrapper - minimal padding for compose-first layout */
.reading-pane__content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0; /* Removed padding - content sections handle their own padding */
  gap: 0;
  background: var(--email-surface);
}

/* Empty state */
.reading-pane__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 24px; /* Add padding only for empty state */
}

.reading-pane__divider {
  width: 100%;
  max-width: 400px;
  height: 1px;
  background: #e5e7eb;
  margin: 8px 0;
}

.reading-pane__empty .empty-state {
  text-align: center;
  padding: 24px;
}

.reading-pane__empty .empty-state__icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.reading-pane__empty .empty-state__title {
  font-size: 18px;
  font-weight: 500;
  color: var(--email-text-secondary);
  margin: 0 0 8px 0;
}

.reading-pane__empty .empty-state__text {
  font-size: 14px;
  color: var(--email-text-muted);
  margin: 0 0 16px 0;
}

.reading-pane__empty .empty-state__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reading-pane__empty .empty-state__actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Input Section in reading pane */
.reading-pane__content .input-section {
  flex-shrink: 0;
  border-radius: var(--radius-lg, 12px);
  margin: 0;
}

/* Plan suggestions in reading pane */
.reading-pane__content .plan-suggestions {
  margin: 0;
}

/* ========================================
   ORIGINAL EMAIL SECTION (Collapsible)
   ======================================== */

.original-section {
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
}

.original-section__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--color-surface-secondary);
  border-bottom: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--email-text-secondary, #6b7280);
  user-select: none;
  list-style: none;
}

.original-section__toggle::-webkit-details-marker {
  display: none;
}

.original-section[open] .original-section__toggle {
  border-bottom-color: var(--email-border-light, #e5e7eb);
}

.original-section__icon {
  font-size: 14px;
}

.original-section__label {
  flex: 1;
}

.original-section__chevron {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.original-section[open] .original-section__chevron {
  transform: rotate(180deg);
}

.original-section__content {
  padding: 16px;
}

.original-email {
  font-size: 14px;
  line-height: 1.6;
}

.original-email__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}

.original-email__from {
  font-weight: 600;
  color: var(--email-text-primary, #111827);
}

.original-email__date {
  color: var(--email-text-muted, #9ca3af);
  font-size: 12px;
}

.original-email__subject {
  font-weight: 600;
  font-size: 15px;
  color: var(--email-text-primary, #111827);
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--email-border-light, #e5e7eb);
}

.original-email__body {
  color: var(--email-text-secondary, #374151);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.6;
  height: 400px;
  overflow-y: auto;
}

/* Formatted email body styles */
.original-email__body p {
  margin: 0 0 1em 0;
}

.original-email__body p:last-child {
  margin-bottom: 0;
}

.original-email__body ul,
.original-email__body ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.original-email__body li {
  margin: 0.25em 0;
}

.original-email__body a {
  color: var(--color-primary, #2563eb);
  text-decoration: none;
}

.original-email__body a:hover {
  text-decoration: underline;
}

.original-email__body strong,
.original-email__body b {
  font-weight: 600;
}

.original-email__body em,
.original-email__body i {
  font-style: italic;
}

.original-email__body blockquote {
  border-left: 3px solid var(--email-border, #e5e5e5);
  padding-left: 1em;
  margin: 1em 0;
  color: var(--email-text-muted, #666);
}

.original-email__body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

.original-email__body td,
.original-email__body th {
  border: 1px solid var(--email-border, #e5e5e5);
  padding: 0.5em;
  text-align: left;
}

.original-email__body th {
  background: var(--color-background-alt);
  font-weight: 600;
}

.original-email__body img {
  max-width: 100%;
  height: auto;
}

/* Hide original section when no content loaded */
.original-section:empty,
.original-section[hidden] {
  display: none;
}

/* Output section in reading pane - respect hidden attribute */
.reading-pane__content .output-section[hidden] {
  display: none !important;
}

.reading-pane__content .output-section:not([hidden]) {
  flex: 1;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg, 12px);
  margin: 0;
}

.reading-pane__content .output-content {
  flex: 1;
  overflow-y: auto;
  max-height: none;
}

/* Trust layer in reading pane */
.reading-pane__content .trust-layer {
  flex-shrink: 0;
  border-radius: var(--radius-lg, 12px);
  margin: 0;
}

/* ========================================
   LEGACY PLAN AREA (for backwards compat)
   ======================================== */

.reading-pane__plan {
  background: var(--email-surface);
  border-bottom: 1px solid var(--email-border);
  padding: 16px 20px;
  flex-shrink: 0;
}

.plan-header {
  margin-bottom: 12px;
}

.plan-goal {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plan-goal__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary, #2563EB);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.plan-goal__text {
  font-size: 14px;
  color: var(--email-text);
  font-weight: 500;
}

.plan-steps {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--color-background-alt);
  border-radius: 8px;
  min-height: 60px;
}

.plan-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--email-text-secondary);
  border-bottom: 1px solid var(--email-border-light);
}

.plan-step:last-child {
  border-bottom: none;
}

.plan-step__number {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--email-border);
  color: var(--email-text-secondary);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plan-step--active .plan-step__number {
  background: var(--color-primary, #2563EB);
  color: white;
}

.plan-step__text {
  flex: 1;
}

.plan-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ========================================
   OUTPUT AREA (scrollable content)
   ======================================== */

.reading-pane__output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Empty state */
.output-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--email-text-muted);
}

.output-empty__icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.output-empty__title {
  font-size: 16px;
  font-weight: 500;
  color: var(--email-text-secondary);
  margin-bottom: 8px;
}

.output-empty__text {
  font-size: 14px;
  color: var(--email-text-muted);
}

/* Output section inside reading pane */
.reading-pane__output .output-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  background: var(--email-surface);
}

.reading-pane__output .output-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--email-border);
  background: var(--email-surface);
  border-radius: 0;
}

.reading-pane__output .output-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ========================================
   ORIGINAL EMAIL (Collapsible)
   ======================================== */

.collapsible {
  border: 1px solid var(--email-border);
  border-radius: 8px;
  background: var(--email-surface);
  overflow: hidden;
}

.collapsible__toggle {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--email-text-secondary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}

.collapsible__toggle:hover {
  background: var(--color-background-alt);
}

.collapsible__toggle::-webkit-details-marker {
  display: none;
}

.collapsible__toggle::before {
  content: '▸';
  font-size: 10px;
  transition: transform 0.15s;
}

.collapsible[open] .collapsible__toggle::before {
  transform: rotate(90deg);
}

.collapsible__content {
  padding: 16px;
  border-top: 1px solid var(--email-border-light);
}

/* Original email display */
.original-email {
  font-size: 13px;
  line-height: 1.6;
}

.original-email__from {
  font-weight: 500;
  color: var(--email-text);
  margin-bottom: 4px;
}

.original-email__subject {
  color: var(--email-text-secondary);
  margin-bottom: 4px;
}

.original-email__date {
  font-size: 11px;
  color: var(--email-text-muted);
  margin-bottom: 12px;
}

.original-email__body {
  white-space: pre-wrap;
  color: var(--email-text);
}

/* ========================================
   SKELETON LOADING STATES
   ======================================== */

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.email-item--skeleton {
  pointer-events: none;
}

.email-item--skeleton .email-item__avatar {
  background: var(--email-border-light, #e5e7eb);
}

.email-item--skeleton .email-item__from {
  width: 60%;
  height: 14px;
}

.email-item--skeleton .email-item__time {
  width: 40px;
  height: 12px;
}

.email-item--skeleton .email-item__tag {
  width: 70px;
  height: 18px;
}

.email-item--skeleton .email-item__preview {
  width: 90%;
  height: 12px;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 1024px) {
  .main.main--email {
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  
  /* Sidebar responsive - narrower on tablet */
  .main--email > .sidebar {
    width: 220px !important;
    min-width: 200px;
    max-width: 260px;
  }
  
  .reading-pane {
    flex: 1 1 auto;
    min-width: 0;
  }
  
  /* Compact dropdown tabs - hide labels, show only icons */
  .dropdown__tab {
    padding: 0 8px;
    gap: 4px;
  }
  
  .dropdown__tab-label {
    display: none;
  }
  
  .dropdown__tab-icon {
    font-size: 16px;
  }
  
  .dropdown__tab-arrow {
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  .main--email {
    flex-direction: column;
  }
  
  /* Sidebar becomes top panel on mobile */
  .main--email > .sidebar {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    height: 40vh;
    min-height: 200px;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--email-border);
    flex-direction: column;
  }
  
  /* Hide bottom nav on small screens to save space */
  .sidebar__bottom-nav {
    display: none;
  }
  
  .sidebar__resize-handle {
    display: none;
  }
  
  /* Disable drag on mobile */
  .email-item[draggable] {
    -webkit-user-drag: none;
  }
  
  /* Compact horizontal layout for connect prompt on mobile */
  .email-list__connect {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    padding: 12px 16px;
    gap: 8px;
    height: auto;
    min-height: auto;
  }
  
  .email-list__connect-icon {
    font-size: 24px;
    margin-bottom: 0;
  }
  
  .email-list__connect-text {
    font-size: 12px;
    margin-bottom: 0;
    flex: 0 0 auto;
  }
  
  .email-list__or {
    display: none;
  }
  
  .email-list__connect .btn {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  .reading-pane {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  
  .icon-bar {
    margin: 0;
    border-radius: 0;
    padding: 0 4px;
    gap: 2px;
    flex-wrap: nowrap;
    height: auto;
    min-height: 40px;
  }
  
  /* Compact on mobile */
  .icon-bar__btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
  /* Compact Daily Report button on mobile - show icon only */
  .icon-bar__eodr-btn {
    padding: 6px;
    margin-left: 4px;
    height: 28px;
  }
  
  .icon-bar__eodr-label {
    display: none;
  }
  
  .dropdown__tab {
    height: 28px;
    padding: 0 4px;
  }
  
  .dropdown__tab-icon {
    font-size: 14px;
  }
  
  /* Hide arrow on very small screens */
  .dropdown__tab-arrow {
    display: none;
  }
  
  .reading-pane__content {
    margin: 0;
    border-radius: 0;
  }
  
  .reading-pane__empty {
    margin: 8px;
    border-radius: 8px;
  }
}

/* ========================================
   ATTACHMENT CONTEXT INDICATOR
   ======================================== */

.attachment-context-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  margin: 0 4px 0 0;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--color-text-muted);
  background: var(--color-success-light);
  border: 1px solid transparent;
  transition: opacity 0.2s ease, background 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.attachment-context-indicator[hidden] {
  display: none;
}

.attachment-context-indicator.is-parsing {
  background: var(--color-primary-light, rgba(59, 130, 246, 0.08));
  color: var(--color-primary, #3b82f6);
}

.attachment-context-indicator.is-ready {
  background: var(--color-success-light);
  color: var(--color-success-dark);
}

.attachment-context-indicator.is-warning {
  background: var(--color-warning-light);
  color: var(--color-warning-dark);
}

.attachment-context-indicator__icon {
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
}

.attachment-context-indicator__text {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-context-indicator__sep {
  opacity: 0.5;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .sidebar,
  .email-nav,
  .email-list,
  .icon-bar {
    display: none !important;
  }
  
  .reading-pane {
    margin: 0;
  }
  
  .reading-pane__content {
    margin: 0;
    border-radius: 0;
  }
}
