:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --bg-app: #f4f4f6;
  --bg-sidebar: #eaebee;
  --bg-surface: #ffffff;
  --bg-hover: #e2e3e7;
  --bg-active: #d6d7dc;
  --bg-selected: #e7e8ec;
  
  --border-color: #dcdde2;
  --border-subtle: #cbccd2;
  
  --text-main: #19191b;
  --text-muted: #595a62;
  --text-subtle: #898a94;
  
  --primary: #222326;
  --primary-hover: #0d0d0f;
  --primary-light: #e2e3e7;
  --primary-text: #ffffff;
  
  --danger: #5a5c64;
  --danger-light: #e8e9ec;
  --success: #4a4b52;
  --success-light: #e8e9ec;
  --warning: #62646d;
  --warning-light: #e8e9ec;
  
  --star-color: #222326;
  --unread-dot: #222326;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.09), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
  
  --radius-sm: 4px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --radius-full: 9999px;
  
  --sidebar-width: 240px;
  --list-width: 360px;
  --header-height: 52px;
}

[data-theme="dark"] {
  --bg-app: #111113;
  --bg-sidebar: #17171a;
  --bg-surface: #1e1e22;
  --bg-hover: #26262b;
  --bg-active: #323238;
  --bg-selected: #2a2a30;
  
  --border-color: #2b2b30;
  --border-subtle: #3a3a42;
  
  --text-main: #f0f0f3;
  --text-muted: #9e9ea7;
  --text-subtle: #6e6e78;
  
  --primary: #f0f0f3;
  --primary-hover: #ffffff;
  --primary-light: #2c2c33;
  --primary-text: #111113;
  
  --danger: #a1a1aa;
  --danger-light: #2c2c33;
  --success: #d4d4d8;
  --success-light: #2c2c33;
  --warning: #a1a1aa;
  --warning-light: #2c2c33;
  
  --star-color: #f0f0f3;
  --unread-dot: #f0f0f3;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Top Navigation Bar */
.top-nav {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
  user-select: none;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
  width: var(--sidebar-width);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text-main);
  text-decoration: none;
}

.brand-icon {
  width: 26px;
  height: 26px;
  color: var(--primary);
}

.nav-center {
  flex: 1;
  max-width: 580px;
  margin: 0 20px;
  position: relative;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 36px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0 40px 0 36px;
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.15s ease;
}

.search-input:focus {
  background-color: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(100, 100, 110, 0.12);
}

.search-shortcut {
  position: absolute;
  right: 12px;
  padding: 2px 6px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  pointer-events: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Common Button Styles */
.btn-icon {
  background: none;
  border: 1px solid transparent;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.btn-icon.active {
  background-color: var(--bg-active);
  color: var(--primary);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-text);
}

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

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* Main Viewport */
.main-viewport {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  user-select: none;
}

.sidebar-header {
  padding: 16px 12px 12px;
}

.btn-compose {
  width: 100%;
  height: 40px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.sidebar-section {
  margin-top: 16px;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
}

.folder-list, .account-filter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s ease;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--bg-surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

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

.badge {
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--bg-active);
  color: var(--text-muted);
}

.nav-item.active .badge {
  background-color: var(--primary-light);
  color: var(--primary);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Message List Pane */
.message-list-pane {
  width: var(--list-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.list-toolbar {
  height: 48px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background-color: var(--bg-surface);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  overflow-x: auto;
}

.filter-chip {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.filter-chip:hover {
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.filter-chip.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}

.message-items-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.message-item {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  position: relative;
  transition: background-color 0.12s ease;
}

.message-item:hover {
  background-color: var(--bg-hover);
}

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

.message-item.unread .msg-from,
.message-item.unread .msg-subject {
  font-weight: 700;
  color: var(--text-main);
}

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

.msg-sender-box {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.msg-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--unread-dot);
  flex-shrink: 0;
  display: none;
}

.message-item.unread .msg-unread-dot {
  display: block;
}

.msg-from {
  font-size: 0.875rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.msg-date {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.msg-star-btn {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  transition: transform 0.1s ease;
}

.msg-star-btn:hover {
  transform: scale(1.15);
}

.msg-star-btn.starred {
  color: var(--star-color);
}

.msg-star-btn svg {
  width: 15px;
  height: 15px;
}

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

.msg-snippet {
  font-size: 0.8rem;
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.msg-account-badge {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  margin-right: 4px;
}

.msg-attach-icon {
  width: 14px;
  height: 14px;
  color: var(--text-subtle);
  margin-left: 4px;
}

/* Detail Pane */
.message-detail-pane {
  flex: 1;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.detail-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  gap: 12px;
  user-select: none;
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-subtle);
  opacity: 0.4;
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.empty-sub {
  font-size: 0.85rem;
}

.detail-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-surface);
}

.detail-toolbar {
  height: 48px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background-color: var(--bg-surface);
  flex-shrink: 0;
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.detail-header {
  margin-bottom: 24px;
}

.detail-subject {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 16px;
}

.detail-participants {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.sender-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.sender-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sender-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-from-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.detail-from-addr {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.detail-to-line {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detail-date {
  font-size: 0.8rem;
  color: var(--text-subtle);
  white-space: nowrap;
}

.privacy-banner {
  background-color: var(--warning-light);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-main);
}

.detail-body-container {
  min-height: 200px;
  line-height: 1.6;
  font-size: 0.95rem;
}

.email-iframe {
  width: 100%;
  min-height: 300px;
  border: none;
  background-color: transparent;
}

.email-plain-body {
  white-space: pre-wrap;
  font-family: var(--font-sans);
  color: var(--text-main);
  line-height: 1.6;
}

.attachments-section {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.attachments-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.attachments-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.attachment-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.85rem;
  transition: all 0.12s ease;
}

.attachment-pill:hover {
  background-color: var(--bg-hover);
  border-color: var(--primary);
}

.attachment-pill svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.att-size {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  max-width: 680px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(10px);
  transition: transform 0.2s ease;
}

.modal-backdrop.open .modal {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background-color: var(--bg-sidebar);
}

/* Compose Modal Specific */
.compose-modal {
  max-width: 800px;
  width: 95%;
  height: 600px;
}

.compose-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 0;
}

.compose-label {
  width: 70px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.compose-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
}

.compose-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.compose-body-area {
  flex: 1;
  min-height: 220px;
  padding: 12px 0;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  overflow-y: auto;
  line-height: 1.5;
}

.compose-attachments-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}

/* Form inputs & grids */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  background-color: var(--bg-surface);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-col {
  flex: 1;
}

.form-help {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-top: 4px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: slideIn 0.2s ease forwards;
}

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

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

.toast-info {
  background-color: var(--text-main);
  color: var(--bg-app);
}

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

/* Spin animation for sync button */
.spinning {
  animation: spin 1s linear infinite;
}

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

/* App Switcher Navigation */
.app-switcher {
  display: flex;
  align-items: center;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
  user-select: none;
}

.app-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.12s ease;
}

.app-tab:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.app-tab.active {
  color: var(--text-main);
  background-color: var(--bg-surface);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.app-tab svg {
  width: 15px;
  height: 15px;
}

/* View Containers */
.view-container {
  display: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.view-container.active {
  display: flex;
}

/* Contacts View Styles */
.contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.contact-item:hover {
  background-color: var(--bg-hover);
}

.contact-item.selected {
  background-color: var(--bg-selected);
  border-left: 3px solid var(--primary);
}

.contact-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.contact-card {
  max-width: 600px;
  margin: 32px auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.contact-card-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.contact-card-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: var(--primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  flex-shrink: 0;
}

.contact-card-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  row-gap: 14px;
  font-size: 0.9rem;
}

.contact-card-label {
  color: var(--text-subtle);
  font-weight: 500;
}

.contact-card-val {
  color: var(--text-main);
  word-break: break-all;
}

/* Calendar View Styles */
.calendar-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  height: 100%;
}

.calendar-header {
  height: 52px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.calendar-title-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.calendar-month-title {
  font-size: 1.15rem;
  font-weight: 700;
  min-width: 180px;
}

.calendar-grid {
  flex: 1;
  display: grid;
  grid-template-rows: 32px repeat(6, 1fr);
  grid-template-columns: repeat(7, 1fr);
  background-color: var(--border-color);
  gap: 1px;
  overflow: hidden;
}

.calendar-weekday {
  background-color: var(--bg-sidebar);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-day-cell {
  background-color: var(--bg-surface);
  padding: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.calendar-day-cell:hover {
  background-color: var(--bg-hover);
}

.calendar-day-cell.other-month {
  background-color: var(--bg-app);
  opacity: 0.6;
}

.calendar-day-number {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  margin-bottom: 4px;
}

.calendar-day-cell.today .calendar-day-number {
  background-color: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
}

.calendar-event-pill {
  background-color: var(--bg-sidebar);
  border-left: 3px solid var(--primary);
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 0.75rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  cursor: pointer;
  transition: opacity 0.1s ease;
}

.calendar-event-pill:hover {
  opacity: 0.8;
}

.agenda-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.12s ease;
}

.agenda-item:hover {
  background-color: var(--bg-hover);
}

.agenda-date-box {
  width: 60px;
  text-align: center;
  background-color: var(--bg-sidebar);
  border-radius: var(--radius-md);
  padding: 6px;
  flex-shrink: 0;
}

/* Tasks & Projects View Styles */
.task-project-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
}

.task-project-title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.task-quick-add {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  gap: 10px;
}

.task-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  transition: background-color 0.12s ease;
}

.task-item:hover {
  background-color: var(--bg-hover);
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-subtle);
}

.task-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  overflow: hidden;
}

.task-checkbox {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--text-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s ease;
  background-color: transparent;
}

.task-checkbox.checked {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.task-checkbox svg {
  width: 12px;
  height: 12px;
}

.task-title {
  font-size: 0.9rem;
  color: var(--text-main);
  word-break: break-word;
}

.task-meta-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.priority-badge {
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.priority-high {
  background-color: var(--border-color);
  color: var(--text-main);
  border: 1px solid var(--text-muted);
}

.priority-medium {
  background-color: var(--bg-sidebar);
  color: var(--text-muted);
}

.priority-low {
  background-color: var(--bg-sidebar);
  color: var(--text-subtle);
}

.due-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.due-badge.overdue {
  color: var(--text-main);
  font-weight: 600;
  text-decoration: underline;
}

/* Mobile controls hidden by default on desktop */
.mobile-menu-btn,
.mobile-back-btn,
.mobile-bottom-nav,
.sidebar-backdrop {
  display: none;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .sidebar {
    width: 200px;
  }
  .message-list-pane {
    width: 300px;
  }
}

@media (max-width: 680px) {
  .top-nav {
    padding: 0 10px;
    height: 52px;
  }

  .brand span {
    display: none;
  }

  .app-switcher {
    display: none !important;
  }

  .search-shortcut {
    display: none;
  }

  .mobile-menu-btn {
    display: flex;
    margin-right: 4px;
  }

  .mobile-back-btn {
    display: flex;
    margin-right: 8px;
    color: var(--text-main);
  }

  .mobile-back-btn svg {
    width: 18px;
    height: 18px;
  }

  /* Sidebar as slide-over drawer */
  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 56px;
    width: 280px;
    z-index: 60;
    background-color: var(--bg-sidebar);
    box-shadow: var(--shadow-lg);
    animation: slideInLeft 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.mobile-open {
    display: flex !important;
  }

  /* Backdrop for mobile drawer */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 55;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .message-list-pane {
    width: 100%;
    height: 100%;
  }

  .message-detail-pane {
    display: none;
    background-color: var(--bg-surface);
  }

  .message-detail-pane.mobile-open {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 56px;
    z-index: 45;
    animation: slideInRight 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .detail-scroll {
    padding: 16px;
  }

  .calendar-viewport {
    height: 100%;
  }

  .calendar-header {
    padding: 0 10px;
    height: 48px;
  }

  .calendar-month-title {
    font-size: 0.95rem;
    min-width: auto;
  }

  /* Mobile Bottom Navigation Bar */
  .mobile-bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    color: var(--text-subtle);
    font-size: 0.7rem;
    font-weight: 500;
    gap: 3px;
    cursor: pointer;
    transition: color 0.12s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-item svg {
    width: 20px;
    height: 20px;
  }

  .mobile-nav-item.active {
    color: var(--text-main);
    font-weight: 700;
  }

  .main-viewport {
    padding-bottom: 56px;
  }

  .task-project-header {
    padding: 14px 16px 10px;
  }

  .task-quick-add {
    padding: 10px 16px;
  }

  .task-item {
    padding: 10px 16px;
  }
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
