:root {
  --blue: #0a66c2;
  --border: #e1e1e1;
  --bg: #faf9f8;
  --panel: #ffffff;
  --text: #201f1e;
  --muted: #6b6a68;
  --unread: #f3f7fd;
  --danger: #c0392b;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; margin: 0; }

body { background: var(--bg); color: var(--text); }

.centered-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.auth-card input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; }

.app-shell { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--blue);
  color: white;
  height: 48px;
  flex-shrink: 0;
}
.topbar .brand { font-weight: 600; font-size: 16px; margin-right: 8px; }
.topbar .spacer { flex: 1; }
.error-banner {
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-body { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 220px;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-section { padding: 10px; border-bottom: 1px solid var(--border); }
.sidebar-section.grow { flex: 1; overflow-y: auto; }
.sidebar-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 4px 4px 8px;
}
.account-row, .folder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.account-row:hover, .folder-row:hover { background: #f2f2f2; }
.account-row.active, .folder-row.active { background: #e8f1fb; font-weight: 600; }
.account-row .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.account-labels { display: flex; flex-direction: column; overflow: hidden; flex: 1; }
.account-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-email { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-icon { width: 18px; text-align: center; }

.message-list {
  width: 340px;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
}
.message-list-header {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.message-list-scroll { flex: 1; overflow-y: auto; }
.message-row {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}
.message-row:hover { background: #f7f9fb; }
.message-row.active { background: #e8f1fb; }
.message-row.unread .message-subject { font-weight: 700; }
.message-row.unread .message-from { font-weight: 700; }
.message-row-top { display: flex; justify-content: space-between; align-items: center; }
.message-from { border-left: 3px solid transparent; padding-left: 6px; font-size: 13px; }
.message-subject { font-size: 13px; margin: 2px 0; color: #333; }
.message-meta { font-size: 11px; color: var(--muted); }
.star { background: none; border: none; cursor: pointer; color: #c9a227; font-size: 15px; }
.star.on { color: #d4a017; }

.reading-pane { flex: 1; background: var(--panel); display: flex; flex-direction: column; min-width: 0; }
.reading-pane.empty { align-items: center; justify-content: center; }
.reading-toolbar { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); align-items: center; }
.reading-header { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.reading-header h2 { margin: 0 0 8px; font-size: 18px; }
.reading-meta { font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.reading-body { flex: 1; overflow: auto; padding: 0; }
.body-frame { width: 100%; height: 100%; border: none; }
.body-text { padding: 20px; white-space: pre-wrap; font-family: inherit; }
.attachments { padding: 10px 20px; border-top: 1px solid var(--border); font-size: 13px; }
.attachment-chip { display: inline-block; background: #f2f2f2; border-radius: 4px; padding: 3px 8px; margin-right: 6px; }

.btn {
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { background: #f2f2f2; }
.btn.primary { background: white; color: var(--blue); border-color: white; font-weight: 600; }
.btn.primary:hover { background: #eef4fb; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.6; cursor: default; }
.topbar .btn { color: var(--blue); }

.link-btn { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.link-btn.danger { color: var(--danger); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 16px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: white;
  border-radius: 8px;
  padding: 20px;
  width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.modal-header strong { flex: 1; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.modal input, .modal select, .modal textarea {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}
.modal .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal .checkbox-row { flex-direction: row; align-items: center; gap: 6px; }
.modal-footer { display: flex; gap: 8px; margin-top: 8px; }
.compose-body { resize: vertical; min-height: 160px; }
.form-error { background: #fdecea; color: var(--danger); padding: 8px 10px; border-radius: 4px; font-size: 13px; }
.hint { background: #fff8e1; border: 1px solid #f0d98a; padding: 8px 10px; border-radius: 4px; font-size: 12px; }

.color-row { display: flex; gap: 8px; }
.color-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-swatch.selected { border-color: #333; }
