/* Prevent iOS zoom on input focus */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: 16px;
  }
}

/* ===========================================
   VMAIL - AOL Mail Inspired with Modern Polish
   =========================================== */

:root {
  /* AOL-inspired palette with grimy undertones */
  --primary: #0066cc;
  --primary-dark: #004499;
  --accent: #ffcc00;
  --accent-dark: #cc9900;
  --bg-main: #e8e8e8;
  --bg-sidebar: #d4d4d4;
  --bg-white: #ffffff;
  --bg-dark: #1a1a1a;
  --text-dark: #333333;
  --text-muted: #666666;
  --text-light: #999999;
  --border: #cccccc;
  --border-dark: #999999;
  --danger: #cc0000;
  --success: #339933;
  --warning: #ff9900;

  /* Spacing */
  --header-height: 60px;
  --sidebar-width: 220px;
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.5;
}

body.app-mode {
  overflow: hidden;
}

body.landing-mode {
  overflow: auto;
}

/* ===========================================
   LANDING PAGE
   =========================================== */

.landing-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 20px;
  padding-top: calc(40px + 36px); /* Account for Vagibond header */
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.landing-hero {
  max-width: 800px;
  text-align: center;
  color: #fff;
}

.landing-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.landing-logo-icon {
  width: 100px;
  height: 100px;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.3));
}

.landing-title {
  font-size: 3.5rem;
  font-weight: 800;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.3);
}

.landing-tagline {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--accent);
}

.landing-subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 40px;
  line-height: 1.8;
}

.landing-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--accent);
  color: var(--text-dark);
  border: none;
  padding: 16px 40px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  margin-bottom: 60px;
}

.landing-signin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  background: #ffe066;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
  margin-bottom: 50px;
}

.feature {
  background: rgba(255,255,255,0.1);
  padding: 30px 20px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.feature-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 16px;
}

.feature h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.feature p {
  font-size: 0.9rem;
  opacity: 0.8;
}

.landing-stats {
  display: flex;
  justify-content: center;
  gap: 60px;
  margin-bottom: 30px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.8;
}

.landing-footnote {
  font-size: 0.85rem;
  opacity: 0.6;
  font-style: italic;
}

@media (max-width: 768px) {
  .landing-title {
    font-size: 2.5rem;
  }

  .landing-tagline {
    font-size: 1.2rem;
  }

  .landing-subtitle {
    font-size: 1rem;
  }

  .landing-features {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .landing-stats {
    flex-direction: column;
    gap: 20px;
  }

  .stat-number {
    font-size: 2rem;
  }
}

/* ===========================================
   APP CONTAINER
   =========================================== */

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: 4px; 
}

/* ===========================================
   HEADER BAR
   =========================================== */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  height: var(--header-height);
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-bottom: 3px solid var(--accent);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  filter: brightness(0) invert(1);
}

.logo-text {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.notification-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--text-dark);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.badge-icon {
  font-size: 1.2rem;
}

.badge-count {
  background: var(--danger);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.compose-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--text-dark);
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.compose-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.compose-icon {
  font-size: 1.1rem;
}

.user-menu-container {
  position: relative;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 20px;
  transition: background 0.2s;
}

.user-menu-btn:hover {
  background: rgba(255,255,255,0.1);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
}

.dropdown-arrow {
  font-size: 0.6rem;
  opacity: 0.7;
  margin-left: 4px;
}

/* User Popover */
.user-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background: var(--bg-white);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.user-popover.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.popover-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.popover-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
}

.popover-info {
  flex: 1;
}

.popover-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.popover-email {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.popover-divider {
  height: 1px;
  background: var(--border);
  margin: 0 16px;
}

.popover-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 16px 20px;
}

.popover-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.popover-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.popover-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.popover-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 12px 16px;
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-dark);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.popover-btn:hover {
  background: #eee;
}

.popover-btn.logout {
  background: none;
  border-color: var(--danger);
  color: var(--danger);
}

.popover-btn.logout:hover {
  background: #fff0f0;
}

.popover-footer {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
}

.popover-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.popover-footer a:hover {
  text-decoration: underline;
}

.vagibond-footer {
  margin: 0 20px;
}

/* ===========================================
   FOLDER SELECTOR (Header Dropdown)
   =========================================== */

.folder-selector-container {
  position: relative;
  margin-left: 16px;
}

.folder-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  transition: all 0.15s ease;
}

.folder-selector-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.folder-selector-icon {
  font-size: 1rem;
}

.folder-selector-name {
  font-weight: 600;
}

.folder-selector-count {
  background: var(--danger);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.folder-selector-btn .dropdown-arrow {
  font-size: 0.6rem;
  opacity: 0.7;
  margin-left: 4px;
}

.folder-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-white);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  min-width: 200px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  padding: 8px;
}

.folder-popover.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.folder-popover-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dark);
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}

.folder-popover-item:hover {
  background: rgba(0,0,0,0.05);
}

.folder-popover-item.active {
  background: var(--primary);
  color: #fff;
}

.folder-popover-item.active .folder-popover-count {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

.folder-popover-icon {
  font-size: 1.1rem;
}

.folder-popover-name {
  flex: 1;
}

.folder-popover-count {
  background: var(--danger);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* ===========================================
   FILTER BANNER
   =========================================== */

.filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--primary-dark);
}

.filter-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-banner-icon {
  font-size: 1rem;
}

.filter-banner-text {
  font-weight: 500;
}

.filter-banner-clear {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-banner-clear:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

/* ===========================================
   MAIN CONTENT AREA
   =========================================== */

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===========================================
   SIDEBAR
   =========================================== */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.folder-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-dark);
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}

.folder-item:hover {
  background: rgba(0,0,0,0.05);
}

.folder-item.active {
  background: var(--primary);
  color: #fff;
}

.folder-item.active .folder-count {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

.folder-icon {
  font-size: 1.2rem;
}

.folder-name {
  flex: 1;
}

.folder-count {
  background: var(--danger);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.storage-info {
  margin-bottom: 16px;
}

.storage-bar {
  height: 8px;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.storage-used {
  height: 100%;
  background: linear-gradient(90deg, var(--warning), var(--danger));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.storage-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.stat-value {
  font-weight: 700;
  color: var(--text-dark);
}

.stat-label {
  color: var(--text-muted);
}

/* ===========================================
   MESSAGE LIST
   =========================================== */

.message-list-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  min-width: 350px;
  max-width: 450px;
  transition: max-width 0.3s ease;
  position: relative;
}

/* When no message selected, expand message list to full width */
.main-content.no-selection .message-list-container {
  max-width: none;
  border-right: none;
}

.main-content.no-selection .message-detail {
  display: none;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #f5f5f5;
}

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

.action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.action-btn.delete-all {
  background: #fff0f0;
  border-color: var(--danger);
  color: var(--danger);
}

.action-btn.delete-all:hover {
  background: var(--danger);
  color: #fff;
}

.list-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.list-warning {
  color: var(--warning);
  font-weight: 500;
}

.message-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 60px; /* Space for storage banner */
}

.message-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.message-item:hover {
  background: #f8f8ff;
}

.message-item.selected {
  background: #e8f0ff;
  border-left: 3px solid var(--primary);
}

.message-item.unread {
  background: #fff;
}

.message-item.unread .message-sender,
.message-item.unread .message-subject {
  font-weight: 700;
}

.message-item.read {
  background: #fafafa;
}

.message-item.read .message-sender,
.message-item.read .message-subject {
  color: var(--text-muted);
}

.message-checkbox {
  padding-top: 4px;
}

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

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-sidebar);
}

.message-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.message-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  gap: 8px;
}

.message-sender {
  font-size: 0.9rem;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.message-time {
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Hide time and show actions on hover */
.message-item:hover .message-time {
  visibility: hidden;
  width: 0;
  overflow: hidden;
}

.message-subject {
  font-size: 0.9rem;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.message-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Message hover actions - Gmail style */
.message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message-item:hover .message-actions {
  visibility: visible;
  opacity: 1;
}

.message-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease;
  padding: 0;
}

.message-action-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.message-action-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
}

.message-action-btn:hover svg {
  fill: var(--text-dark);
}

.message-action-btn.delete:hover {
  background: rgba(204, 0, 0, 0.1);
}

.message-action-btn.delete:hover svg {
  fill: var(--danger);
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.95rem;
}

/* Load More Button */
.load-more-container {
  display: flex;
  justify-content: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.load-more-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.load-more-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.load-more-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Storage Banner (bottom of message list) */
.storage-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: #f5f5f5;
  border-top: 1px solid var(--border);
  position: absolute;
  bottom: 30px;
  left: 0;
  right: 0;
}

.storage-banner .storage-bar {
  height: 6px;
  background: #fff;
  border-radius: 3px;
  overflow: hidden;
}

.storage-banner .storage-used {
  height: 100%;
  background: linear-gradient(90deg, var(--warning), var(--danger));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.storage-banner .storage-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.storage-banner .storage-text a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.storage-banner .storage-text a:hover {
  text-decoration: underline;
}

/* ===========================================
   MESSAGE DETAIL PANEL
   =========================================== */

.message-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
  overflow: hidden;
  position: relative;
}

.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.placeholder-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.detail-placeholder h3 {
  font-size: 1.2rem;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.detail-placeholder p {
  font-size: 0.95rem;
  max-width: 300px;
}

.detail-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: #f9f9f9;
  flex-shrink: 0;
}

.detail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 80px;
}

.detail-nav {
  display: flex;
  gap: 4px;
}

.detail-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.detail-nav-btn:hover:not(:disabled) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.detail-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.detail-actions {
  display: flex;
  gap: 4px;
}

.detail-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease;
  padding: 0;
}

.detail-action-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.detail-action-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--text-muted);
}

.detail-action-btn:hover svg {
  fill: var(--text-dark);
}

.detail-action-btn.delete:hover {
  background: rgba(204, 0, 0, 0.1);
}

.detail-action-btn.delete:hover svg {
  fill: var(--danger);
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sender-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-sidebar);
}

.sender-info {
  flex: 1;
}

.sender-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.sender-email {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.message-date {
  font-size: 0.85rem;
  color: var(--text-light);
}

.detail-subject {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-dark);
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.detail-body {
  padding: 24px;
  font-size: 0.95rem;
  line-height: 1.7;
}

.detail-body p {
  margin-bottom: 16px;
}

.detail-body ul, .detail-body ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.detail-body li {
  margin-bottom: 8px;
}

.detail-body a {
  color: var(--primary);
  text-decoration: none;
}

.detail-body a:hover {
  text-decoration: underline;
}

.detail-body blockquote {
  border-left: 3px solid var(--border);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Fix contrast for dark-background embedded content (Bindle, Shilling, Gutter, DumpsterDash, etc.)
   These override inline styles that have poor contrast */
.detail-body div[style*="#1a1a1a"],
.detail-body div[style*="#2d5a27"],
.detail-body div[style*="1a1a1a"],
.detail-body div[style*="2d5a27"] {
  color: #d0d0d0 !important;
}

.detail-body div[style*="#1a1a1a"] p,
.detail-body div[style*="#1a1a1a"] span,
.detail-body div[style*="#2d5a27"] p,
.detail-body div[style*="#2d5a27"] span,
.detail-body div[style*="1a1a1a"] p,
.detail-body div[style*="1a1a1a"] span {
  color: #d0d0d0 !important;
}

.detail-body div[style*="#1a1a1a"] strong,
.detail-body div[style*="#2d5a27"] strong,
.detail-body div[style*="1a1a1a"] strong {
  color: #fff !important;
}

/* Italic text in dark boxes */
.detail-body div[style*="#1a1a1a"] p[style*="italic"],
.detail-body div[style*="1a1a1a"] p[style*="italic"] {
  color: #bbb !important;
}

.reply-disabled-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #f0f0f0;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  position: absolute;
  bottom: 30px;
  left: 0;
  right: 0;
  justify-content: center;
}

.reply-disabled-notice span {
  font-size: 1.2rem;
}

/* ===========================================
   COMPOSE MODAL
   =========================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.compose-modal {
  background: var(--bg-white);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .compose-modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--primary);
  border-radius: 12px 12px 0 0;
}

.modal-header h2 {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.modal-close:hover {
  opacity: 1;
}

.compose-form {
  padding: 20px;
}

.compose-field {
  margin-bottom: 16px;
}

.compose-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.compose-field input,
.compose-field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.compose-field input:focus,
.compose-field textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.compose-field.disabled input {
  background: #f5f5f5;
  color: var(--text-muted);
  cursor: not-allowed;
}

.compose-field textarea {
  min-height: 150px;
  resize: vertical;
}

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
  font-style: italic;
}

.char-count {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.cancel-btn {
  padding: 10px 20px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}

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

.send-btn {
  padding: 10px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.send-btn:hover {
  background: var(--primary-dark);
}

/* ===========================================
   SENT CONFIRMATION MODAL
   =========================================== */

.sent-modal {
  background: var(--bg-white);
  border-radius: 16px;
  padding: 40px 60px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  transform: scale(0.8);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .sent-modal {
  transform: scale(1);
}

.sent-icon {
  width: 80px;
  height: 80px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 20px;
  animation: pop 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.sent-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.sent-subtext {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* ===========================================
   TOAST NOTIFICATIONS
   =========================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-dark);
  color: #fff;
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

.toast-warning {
  background: var(--warning);
  color: var(--text-dark);
}

/* ===========================================
   MOBILE RESPONSIVE
   =========================================== */

@media (max-width: 1024px) {
  .message-list-container {
    min-width: 300px;
    max-width: 350px;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 12px;
  }

  .notification-badge {
    display: none;
  }

  .user-name {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: calc(36px + var(--header-height));
    left: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .message-list-container {
    min-width: 100%;
    max-width: 100%;
  }

  .message-detail {
    position: fixed;
    top: calc(36px + var(--header-height));
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .message-detail.active {
    transform: translateX(0);
  }

  .reply-disabled-notice {
    bottom: 0;
  }

  .storage-banner {
    bottom: 0;
  }

  .list-warning {
    display: none;
  }

  .compose-modal {
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .logo-text {
    font-size: 1.4rem;
  }

  .compose-btn span:last-child {
    display: none;
  }

  .compose-btn {
    padding: 10px 14px;
  }

  .action-btn span:last-child {
    display: none;
  }

  .message-item {
    padding: 12px;
  }

  .message-avatar {
    width: 36px;
    height: 36px;
  }
}

/* ===========================================
   SCROLLBAR STYLING
   =========================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f0f0f0;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}
