.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.chat-header {
  padding: 20px;
  background: #f9f9f9;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fetch-emails-btn {
  background: transparent;
  border: 1px solid #9333ea;
  color: #9333ea;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.fetch-emails-btn:hover:not(:disabled) {
  background: #9333ea;
  color: white;
}

.fetch-emails-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.floating-nav-pill {
  display: none;
}

.chat-title {
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 1;
  min-width: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 20px;
  display: flex;
  flex-direction: column-reverse;
  -webkit-overflow-scrolling: touch;
}

.message {
  max-width: 60%;
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  position: relative;
}

.message.email {
  max-width: 70%;
  border-left: 3px solid #c00;
}

.message.email.inbound {
  background: #fee;
  color: #c00;
}

.message.email.outbound {
  background: #fcc;
  color: #900;
}

.message-email-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 600;
}

.email-icon {
  font-size: 16px;
}

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

body.dark-mode .message.email.inbound {
  background: #900;
  color: #fcc;
}

body.dark-mode .message.email.outbound {
  background: #c00;
  color: #fee;
}

.message.outbound {
  align-self: flex-end;
  background: #9333ea;
  color: white;
}

.message.scheduled {
  align-self: flex-end;
  background: #3b82f6;
  color: white;
  border: 2px dashed #60a5fa;
}

.message.inbound {
  align-self: flex-start;
  background: #e5e5ea;
  color: black;
}

.message-text {
  margin-bottom: 4px;
}

.message-meta {
  font-size: 11px;
  opacity: 0.7;
}

.compose-area {
  display: flex;
  padding: 12px 12px 12px 4px;
  gap: 8px;
  transition: padding-left 0.3s ease;
  align-items: stretch;
  min-height: 68px;
  max-height: 200px;
}

.compose-area.sidebar-hidden {
  padding-left: calc(320px + 12px);
}

#compose-mode-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: #333;
  flex-shrink: 0;
  width: 30px;
  align-self: stretch;
}

#compose-mode-toggle svg,
#compose-mode-toggle img {
  width: 28px;
  height: 28px;
}

#compose-mode-toggle img {
  padding: 0 !important;
  margin: 0 !important;
}

#compose-mode-toggle {
  padding: 0 !important;
}

#message-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  resize: none;
  font-family: inherit;
  max-height: 120px;
  overflow-y: auto;
}

#message-input:focus {
  border-color: #9333ea;
}

#send-btn {
  padding: 6px 12px;
  background: #1ea600;
  color: white;
  border: 1px solid #1ea600;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 34px;
  flex-shrink: 0;
  margin-bottom: 3px;
}

#send-btn svg,
#send-btn img {
  width: 24px;
  height: 24px;
}

#send-btn:disabled {
  background: #ccc;
  border-color: #ccc;
  cursor: not-allowed;
}

.chat-area.conversation-active .messages,
.chat-area.conversation-active .chat-header,
.chat-area.conversation-active .compose-area {
  animation: slideInRight 0.25s ease-out;
}

.email-card {
  width: 85%;
  max-width: 85%;
  margin: 20px 0;
  padding: 12px 6px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
  .email-card {
    width: 85%;
    max-width: 85%;
  }
}

.email-card.inbound {
  align-self: flex-start;
  background: #e5e5ea;
}

.email-card.outbound {
  align-self: flex-end;
  background: #d1d5db;
}

.email-card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.email-subject {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.email-address {
  font-size: 12px;
  color: #6b7280;
}

.email-card-body {
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.email-main {
  white-space: pre-line;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  overflow-x: auto;
  padding: 0;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 6px;
  width: 100%;
  max-height: 400px;
  overflow-y: auto;
  box-sizing: border-box;
  overflow: auto;
}

.email-main.email-html {
  white-space: normal;
  overflow: auto;
  border-radius: 6px;
}

.email-main.email-html * {
  max-width: 100% !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  box-sizing: border-box !important;
  border-radius: 0 !important;
}

.email-main.email-html img {
  max-width: 200px !important;
  height: auto !important;
  border-radius: 0 !important;
}

.email-main.email-html table {
  border-radius: 6px !important;
  overflow: hidden !important;
}

.email-card-meta {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  color: #6b7280;
}

.email-card.email-preview {
  border: 2px solid #CBA136;
  box-shadow: 0 4px 12px rgba(203, 161, 54, 0.3);
}

body.dark-mode .email-card {
  background: #1f2937;
}

body.dark-mode .email-card-header {
  border-bottom-color: #374151;
}

body.dark-mode .email-subject {
  color: #f9fafb;
}

body.dark-mode .email-address {
  color: #9ca3af;
}

body.dark-mode .email-card-meta {
  border-top-color: #374151;
  color: #9ca3af;
}

.email-quoted {
  margin-top: 12px;
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
}

.email-quoted-toggle {
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  display: inline-block;
  user-select: none;
}

.email-quoted-toggle:hover {
  color: #374151;
}

.email-quoted-content {
  margin-top: 8px;
  color: #6b7280;
  font-size: 13px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  white-space: pre-line;
}

.email-quoted:not(.collapsed) .email-quoted-content {
  max-height: 2000px;
}

body.dark-mode .email-quoted {
  border-top-color: #374151;
}

body.dark-mode .email-quoted-toggle:hover {
  color: #d1d5db;
}

.email-attachments {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.email-attachment:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.email-attachment svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.attachment-name {
  flex: 1;
  font-size: 13px;
  color: #e9edf1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-size {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.email-attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 12px;
  color: #4a9eff;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.2s;
  margin-top: 14px;
}

.email-attachment-link:hover {
  background: rgba(74, 158, 255, 0.1);
  text-decoration: underline;
}

.email-attachment-link svg {
  flex-shrink: 0;
}

.attachment-viewer-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.attachment-viewer-content {
  background: #1a1d24;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.attachment-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #0f1115;
}

.attachment-viewer-title {
  font-size: 16px;
  font-weight: 600;
  color: #e9edf1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-viewer-close {
  background: none;
  border: none;
  color: #e9edf1;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s;
  flex-shrink: 0;
  margin-left: 16px;
}

.attachment-viewer-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.attachment-viewer-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  background: #2a2d35;
  min-height: 0;
}

.attachment-viewer-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: center;
  gap: 16px;
  background: #1a1d24;
}

.attachment-download-btn,
.attachment-viewer-close-btn {
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attachment-download-btn:hover,
.attachment-viewer-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 768px) {
  .attachment-viewer-modal {
    padding: 0;
  }

  .attachment-viewer-content {
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .attachment-viewer-body {
    padding: 12px;
  }
}

.message-reactions {
  position: absolute;
  top: -8px;
  left: -8px;
  display: flex;
  gap: 2px;
  z-index: 1;
}

.reaction-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.reaction-bubble:hover {
  transform: scale(1.3);
}

.reaction-picker {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  gap: 8px;
  z-index: 10000;
  animation: popIn 0.2s ease;
}

.reaction-option {
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s;
  line-height: 1;
}

.reaction-option:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: scale(1.2);
}

body.dark-mode .reaction-picker {
  background: #2c2c2e;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

body.dark-mode .reaction-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mobile-nav-bar {
  display: none;
  position: fixed;
  left: 10px;
  top: auto;
  bottom: 68px;
  background: transparent;
  border-right: none;
  padding: 16px 8px;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 24px;
  z-index: 100;
  width: 50px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.mobile-nav-bar.hidden {
  opacity: 0;
  pointer-events: none;
}

.mobile-nav-icon {
  cursor: pointer;
  flex-shrink: 0;
  width: 31px;
  height: 31px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  position: relative;
  color: #9333ea;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
  animation: nav-icon-sheen 8.4s linear infinite;
}

@keyframes nav-icon-sheen {
  0%   { color: #7e22ce; filter: drop-shadow(0 0 3px rgba(147,51,234,0.3)); }
  25%  { color: #c084fc; filter: drop-shadow(0 0 6px rgba(192,132,252,0.6)); }
  50%  { color: #e9d5ff; filter: drop-shadow(0 0 8px rgba(233,213,255,0.8)); }
  75%  { color: #c084fc; filter: drop-shadow(0 0 6px rgba(192,132,252,0.6)); }
  100% { color: #7e22ce; filter: drop-shadow(0 0 3px rgba(147,51,234,0.3)); }
}

body.dark-mode .mobile-nav-icon {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

body.dark-mode .mobile-nav-bar {
  background: transparent;
  border-right: none;
}

@media (min-width: 769px) {
  .mobile-nav-bar {
    display: none !important;
  }
}

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

  .compose-area {
    left: 0;
    right: 0;
    margin-bottom: 8px;
    padding: 8px 16px;
    width: 100%;
  }

  .chat-area {
    margin-left: 0;
    height: 100%;
    width: 100%;
  }

  #message-input {
    font-size: 16px;
  }
}

body.dark-mode .chat-area {
  background: #000;
}

body.dark-mode .chat-header {
  background: #1c1c1e;
  border-bottom-color: #38383a;
}

body.dark-mode .messages {
  background: #000;
}

body.dark-mode .message.inbound {
  background: #3a3a3c;
  color: #fff;
}

body.dark-mode .compose-area {
  background: transparent;
}

body.dark-mode #message-input {
  background: #1c1c1e;
  border-color: #38383a;
  color: #fff;
}

body.dark-mode #compose-mode-toggle {
  color: #fff;
}
