:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-rgb: 56, 189, 248;
  --border: #334155;
  --unread-bg: rgba(56, 189, 248, 0.08);
  --danger: #ef4444;
  --success: #10b981;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 20px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.compose-btn-wrap {
  padding: 16px;
}

.btn-primary {
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.mailboxes-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.mailbox-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.mailbox-item:hover, .mailbox-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.badge {
  background: var(--accent);
  color: #0f172a;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}

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

/* Main Area */
.main-view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.header-bar {
  height: 60px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}

.search-input {
  flex: 1;
  max-width: 500px;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.9rem;
}

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

.message-list-pane {
  width: 400px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.message-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

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

.message-item.active {
  background: var(--bg-tertiary);
}

.message-item.unread {
  background: var(--unread-bg);
  border-left: 3px solid var(--accent);
}

.msg-sender {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

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

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

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

.reading-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow-y: auto;
  padding: 24px;
}

.msg-detail-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.detail-subject {
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.detail-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.detail-body {
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 520px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-card h3 {
  margin-bottom: 16px;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

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

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.hidden {
  display: none !important;
}
