/* ============================================================
   Outlook-style webmail
   ============================================================ */

:root {
  /* Brand */
  --c-brand: #0078d4;
  --c-brand-hover: #106ebe;
  --c-brand-active: #005a9e;
  --c-brand-light: #deecf9;
  --c-brand-tint: #f3f9fd;
  --c-brand-band: #0078d4;

  /* Surfaces */
  --c-bg: #ffffff;
  --c-actionbar-bg: #faf9f8;
  --c-list-bg: #ffffff;
  --c-divider: #edebe9;
  --c-hover: #f3f2f1;
  --c-page-bg: #f5f5f5;

  /* Text */
  --c-text: #201f1e;
  --c-text-secondary: #424242;
  --c-text-muted: #605e5c;
  --c-text-subtle: #a19f9d;
  --c-text-on-brand: #ffffff;

  /* Borders */
  --c-border: #e1dfdd;
  --c-border-strong: #d2d0ce;

  /* Status */
  --c-error: #d13438;
  --c-error-bg: #fde7e9;
  --c-success: #107c10;
  --c-success-bg: #dff6dd;
  --c-warning: #f7e9c1;
  --c-warning-text: #8a6f12;

  /* Avatar palette */
  --c-av-1: #0078d4;
  --c-av-2: #8764b8;
  --c-av-3: #038387;
  --c-av-4: #d13438;
  --c-av-5: #498205;
  --c-av-6: #ca5010;
  --c-av-7: #e3008c;
  --c-av-8: #8e562e;

  /* Sizes */
  --topbar-h: 48px;
  --actionbar-h: 48px;
  --list-w: 380px;
  --drawer-w: 260px;

  /* Type */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.14);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--c-text);
  background: var(--c-bg);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}
button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

/* === Login page === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-page-bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 32px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 28px;
}
.login-brand-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.login-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--c-brand);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.login-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 6px;
}
.login-subtitle {
  font-size: 13px;
  color: var(--c-text-muted);
  margin-bottom: 24px;
}
.form-field { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input::placeholder { color: var(--c-text-subtle); }
.form-input:focus {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.18);
}
.advanced-toggle {
  font-size: 12px;
  color: var(--c-brand);
  margin: 4px 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}
.advanced-toggle:hover { text-decoration: underline; }
.advanced-toggle .chev { transition: transform 0.15s; }
.advanced-toggle.open .chev { transform: rotate(90deg); }
.advanced-fields {
  display: none;
  padding: 14px;
  background: var(--c-actionbar-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}
.advanced-fields.open { display: block; }
.advanced-row { display: flex; gap: 8px; }
.advanced-row .form-field { flex: 1; }
.advanced-fields .form-field:last-child { margin-bottom: 0; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.checkbox-row input { accent-color: var(--c-brand); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.btn-primary {
  background: var(--c-brand);
  color: white;
  width: 100%;
  padding: 11px 16px;
}
.btn-primary:hover { background: var(--c-brand-hover); }
.btn-primary:disabled { background: #a19f9d; cursor: not-allowed; }
.error-banner {
  padding: 10px 12px;
  background: var(--c-error-bg);
  color: var(--c-error);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid rgba(209, 52, 56, 0.25);
}
.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 11px;
  color: var(--c-text-subtle);
  font-family: var(--font-mono);
}

/* === Main app shell === */
.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top blue band */
.topbar {
  height: var(--topbar-h);
  background: var(--c-brand-band);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  position: relative;
  flex-shrink: 0;
}
.topbar-search {
  width: 100%;
  max-width: 720px;
  position: relative;
}
.topbar-search-input {
  width: 100%;
  height: 32px;
  padding: 0 14px 0 38px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.18);
  color: white;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.topbar-search-input::placeholder { color: rgba(255, 255, 255, 0.85); font-weight: 400; }
.topbar-search-input:focus {
  outline: none;
  background: white;
  color: var(--c-text);
  border-color: white;
}
.topbar-search-input:focus::placeholder { color: var(--c-text-subtle); }
.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.95);
  pointer-events: none;
}
.topbar-search-input:focus + .topbar-search-icon,
.topbar-search-input:not(:placeholder-shown) + .topbar-search-icon { color: var(--c-text-muted); }

.topbar-end {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-start {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  max-width: 280px;
}
.topbar-email {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: white;
  background: rgba(255, 255, 255, 0.18);
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  letter-spacing: 0;
}
.topbar-brand-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: -0.005em;
  max-width: 240px;
}
.topbar-brand-mini-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 3px 12px 3px 3px;
  color: white;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s;
}
.topbar-user:hover { background: rgba(255, 255, 255, 0.28); }
.topbar-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  color: var(--c-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.topbar-icon-light {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.15s;
}
.topbar-icon-light:hover { background: rgba(255, 255, 255, 0.3); }

/* Action bar */
.actionbar {
  height: var(--actionbar-h);
  background: var(--c-actionbar-bg);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 2px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.actionbar::-webkit-scrollbar { display: none; }
.ab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 400;
  color: var(--c-text);
  white-space: nowrap;
  transition: background 0.1s;
}
.ab-btn:hover:not(:disabled) { background: var(--c-hover); }
.ab-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.ab-btn.ab-icon-only { width: 36px; padding: 0; justify-content: center; }
.ab-btn.ab-primary {
  background: var(--c-brand);
  color: white;
  font-weight: 500;
}
.ab-btn.ab-primary:hover:not(:disabled) { background: var(--c-brand-hover); }
.ab-btn .ab-chev { color: var(--c-text-muted); margin-left: -2px; }
.ab-divider {
  width: 1px;
  height: 24px;
  background: var(--c-border);
  margin: 0 4px;
}

/* Main two-pane area */
.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  background: var(--c-bg);
}

/* Folder pane (pinned by default) */
.folder-pane {
  width: var(--drawer-w);
  background: white;
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.app-main.folders-collapsed .folder-pane { display: none; }
.folder-pane-header {
  padding: 14px 18px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.folder-pane-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.folder-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 8px;
}
.folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px;
  font-size: 13px;
  color: var(--c-text);
  cursor: pointer;
  position: relative;
  width: 100%;
  text-align: left;
  border-radius: 0;
  transition: background 0.1s;
}
.folder-item:hover { background: var(--c-hover); }
.folder-item.active {
  background: var(--c-brand-light);
  color: var(--c-brand-active);
  font-weight: 500;
}
.folder-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--c-brand);
  border-radius: 0 3px 3px 0;
}
.folder-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--c-text-muted);
}
.folder-item.active .folder-icon { color: var(--c-brand); }
.folder-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-badge {
  background: var(--c-brand);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  font-family: var(--font-mono);
}
.folder-item.active .folder-badge { background: var(--c-brand-active); }
.folder-pane-footer {
  border-top: 1px solid var(--c-divider);
  padding: 6px 0;
}
.folder-pane-footer .folder-item { padding: 8px 18px; }

/* Message list pane */
.list-pane {
  width: var(--list-w);
  background: var(--c-list-bg);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.list-tabs {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  border-bottom: 1px solid var(--c-divider);
  gap: 4px;
}
.list-tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-muted);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.list-tab:hover { color: var(--c-text); }
.list-tab.active {
  color: var(--c-brand);
  border-bottom-color: var(--c-brand);
}
.tab-count {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  background: var(--c-border);
  color: var(--c-text-muted);
  font-feature-settings: 'tnum';
  font-weight: 600;
  font-family: var(--font-mono);
  vertical-align: 1px;
}
.list-tab.active .tab-count { background: var(--c-brand); color: white; }
.list-tab-spacer { flex: 1; }
.list-filter-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--c-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.list-filter-btn:hover { background: var(--c-hover); color: var(--c-text); }
.list-folder-name {
  padding: 12px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  font-family: var(--font-mono);
  background: var(--c-list-bg);
}

.list-items {
  flex: 1;
  overflow-y: auto;
}
.list-group-header {
  padding: 12px 16px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-secondary);
  background: var(--c-list-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}
.msg-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px 8px 22px;
  border-bottom: 1px solid var(--c-divider);
  cursor: pointer;
  position: relative;
  transition: background 0.08s;
}
.msg-item:hover { background: var(--c-hover); }
.msg-item.active { background: var(--c-brand-light); }
.msg-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--c-brand);
}
.msg-dot {
  position: absolute;
  left: 9px;
  top: 17px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-brand);
  display: none;
}
.msg-item.unread .msg-dot { display: block; }
.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  margin-top: 1px;
}
.msg-body {
  flex: 1;
  min-width: 0;
}
.msg-row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 1px;
  line-height: 1.35;
}
.msg-from {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.msg-item:not(.unread) .msg-from { font-weight: 500; }
.msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.msg-indicator {
  color: var(--c-text-muted);
  flex-shrink: 0;
}
.msg-indicator-pin { color: var(--c-brand); }
.msg-time {
  font-size: 11px;
  color: var(--c-text-muted);
  flex-shrink: 0;
  font-feature-settings: 'tnum';
  letter-spacing: 0;
}
.msg-item.unread .msg-time { color: var(--c-brand); font-weight: 500; }
.msg-subject {
  font-size: 13px;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
  line-height: 1.35;
}
.msg-item.unread .msg-subject {
  color: var(--c-brand);
  font-weight: 500;
}
.msg-preview {
  font-size: 12px;
  color: var(--c-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.msg-preview:empty { display: none; }

.list-pagination {
  padding: 8px 14px;
  border-top: 1px solid var(--c-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  background: white;
}
.pager-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--c-text-muted);
  font-size: 12px;
  transition: background 0.15s;
}
.pager-btn:hover:not(:disabled) { background: var(--c-hover); color: var(--c-text); }
.pager-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pager-info { font-family: var(--font-mono); color: var(--c-text-muted); font-size: 11px; }
.list-empty,
.list-loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--c-text-muted);
  font-size: 13px;
}

/* Reading pane */
.reading-pane {
  flex: 1;
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.reading-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--c-text-subtle);
  padding: 40px;
}
.reading-empty-icon {
  width: 64px;
  height: 64px;
  color: #d2d0ce;
  margin-bottom: 12px;
}
.reading-empty-text {
  font-size: 14px;
  color: var(--c-text-muted);
}

.reading-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px 64px;
  position: relative;
}
.reading-actions {
  position: absolute;
  top: 22px;
  right: 28px;
  display: flex;
  gap: 4px;
}
.reading-action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--c-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.reading-action-btn:hover { background: var(--c-hover); color: var(--c-text); }
.reading-action-btn.danger:hover { background: var(--c-error-bg); color: var(--c-error); }

.reading-subject {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
  padding-right: 130px;
  color: var(--c-text);
}
.reading-meta {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 0;
}
.reading-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.reading-meta-text { flex: 1; min-width: 0; }
.reading-from-line {
  font-size: 13px;
  margin-bottom: 2px;
}
.reading-from-name { font-weight: 600; color: var(--c-text); }
.reading-from-email {
  color: var(--c-text-muted);
  margin-left: 6px;
  font-weight: 400;
}
.reading-to-line {
  font-size: 12px;
  color: var(--c-text-muted);
}
.reading-to-line span { color: var(--c-text); }
.reading-date {
  font-size: 12px;
  color: var(--c-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-feature-settings: 'tnum';
}

.reading-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--c-warning);
  color: var(--c-warning-text);
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 18px;
}
.reading-banner svg { color: var(--c-warning-text); flex-shrink: 0; }
.reading-banner-msg { flex: 1; }

.reading-body {
  line-height: 1.6;
  color: var(--c-text);
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 14px;
  margin-top: 12px;
}
.reading-body img { max-width: 100%; height: auto; }
.reading-body a { color: var(--c-brand); text-decoration: underline; }
.reading-body p { margin-bottom: 12px; }
.reading-body blockquote {
  border-left: 3px solid var(--c-border);
  padding-left: 16px;
  color: var(--c-text-muted);
  margin: 12px 0;
}
.reading-body pre {
  font-family: var(--font-mono);
  background: var(--c-actionbar-bg);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 12px;
}
.reading-body table { border-collapse: collapse; margin: 12px 0; max-width: 100%; }
.reading-body td, .reading-body th { padding: 6px 10px; border: 1px solid var(--c-divider); }

/* Thread (conversation) */
.reading-thread-summary {
  font-size: 12px;
  color: var(--c-text-muted);
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--c-divider);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}
.reading-thread { display: flex; flex-direction: column; gap: 10px; }
.thread-msg {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.thread-msg:hover { border-color: var(--c-border-strong); }
.thread-msg.expanded {
  box-shadow: var(--shadow-sm);
  border-color: var(--c-border-strong);
}

.thread-msg-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  width: 100%;
  text-align: left;
  background: white;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.1s;
}
.thread-msg-header:hover { background: var(--c-actionbar-bg); }
.thread-msg.expanded .thread-msg-header { border-bottom: 1px solid var(--c-divider); }

.thread-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.thread-msg-meta {
  flex: 1;
  min-width: 0;
}
.thread-msg-from {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.thread-msg-from-name { font-weight: 600; color: var(--c-text); }
.thread-msg-from-email { color: var(--c-text-muted); font-weight: 400; font-size: 12px; }
.thread-msg-to {
  font-size: 12px;
  color: var(--c-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-msg-to span { color: var(--c-text-secondary); }
.thread-msg-date {
  font-size: 12px;
  color: var(--c-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-feature-settings: 'tnum';
}
.thread-msg-body {
  padding: 14px 18px 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-text);
  max-height: 0;
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.thread-msg.expanded .thread-msg-body {
  max-height: none;
}
.thread-msg-body img { max-width: 100%; height: auto; }
.thread-msg-body a { color: var(--c-brand); text-decoration: underline; }
.thread-msg-body p { margin-bottom: 12px; }
.thread-msg-body blockquote {
  border-left: 3px solid var(--c-border);
  padding-left: 14px;
  color: var(--c-text-muted);
  margin: 10px 0;
}
.thread-msg-body pre {
  font-family: var(--font-mono);
  background: var(--c-actionbar-bg);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 12px;
}

.thread-folder-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  background: var(--c-brand-light);
  color: var(--c-brand-active);
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
}

/* Compose modal */
.compose-modal {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 600px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  z-index: 200;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  overflow: hidden;
  border: 1px solid var(--c-border);
}
.compose-modal.open {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}
.compose-header {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--c-brand);
  color: white;
}
.compose-title { font-size: 13px; font-weight: 500; }
.compose-close {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}
.compose-close:hover { background: rgba(255, 255, 255, 0.18); color: white; }

.compose-fields { padding: 4px 18px 0; }
.compose-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--c-divider);
  padding: 4px 0;
}
.compose-row-label {
  width: 50px;
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 500;
}
.compose-row-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 8px 4px;
  font-size: 13px;
  background: transparent;
}
.compose-toolbar {
  padding: 8px 18px;
  border-bottom: 1px solid var(--c-divider);
  display: flex;
  gap: 2px;
}
.compose-tool {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  font-size: 12px;
  font-weight: 600;
}
.compose-tool:hover { background: var(--c-hover); color: var(--c-text); }
.compose-body {
  padding: 14px 18px;
  outline: none;
  min-height: 220px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
}
.compose-body:empty::before {
  content: attr(data-placeholder);
  color: var(--c-text-subtle);
  pointer-events: none;
}
.compose-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.compose-status {
  font-size: 12px;
  color: var(--c-text-muted);
  flex: 1;
}
.compose-status.success { color: var(--c-success); }
.compose-status.error { color: var(--c-error); }
.btn-send {
  background: var(--c-brand);
  color: white;
  padding: 8px 22px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-send:hover:not(:disabled) { background: var(--c-brand-hover); }
.btn-send:disabled { background: #a19f9d; cursor: not-allowed; }

/* Move-to dropdown */
.dropdown {
  position: fixed;
  min-width: 220px;
  max-height: 360px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 200;
  padding: 4px;
}
.dropdown.open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  font-size: 13px;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  color: var(--c-text);
}
.dropdown-item:hover { background: var(--c-hover); }
.dropdown-item .icon { color: var(--c-text-muted); }
.ab-btn-wrap { position: relative; }

/* === Settings page === */
.settings-page {
  background: var(--c-page-bg);
  min-height: 100vh;
}
.settings-topbar {
  height: var(--topbar-h);
  background: var(--c-brand-band);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  color: white;
  position: sticky;
  top: 0;
  z-index: 5;
}
.settings-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.18);
  font-size: 13px;
  font-weight: 500;
  color: white;
  transition: background 0.15s;
}
.settings-back:hover { background: rgba(255, 255, 255, 0.28); }
.settings-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.settings-main {
  display: flex;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 80px;
  gap: 28px;
}
.settings-nav {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 76px;
  align-self: flex-start;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-secondary);
  transition: background 0.15s, color 0.15s;
}
.settings-nav-item:hover { background: white; color: var(--c-text); }
.settings-nav-item.active {
  background: white;
  color: var(--c-brand);
  box-shadow: var(--shadow-sm);
}
.settings-nav-item .icon { color: var(--c-text-muted); }
.settings-nav-item.active .icon { color: var(--c-brand); }

.settings-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.settings-section {
  scroll-margin-top: 70px;
}
.settings-section-header {
  margin-bottom: 14px;
}
.settings-section h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 4px;
}
.settings-section-desc {
  font-size: 13px;
  color: var(--c-text-muted);
  line-height: 1.5;
  max-width: 640px;
}

.settings-card {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.settings-row {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-divider);
  gap: 16px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label {
  flex: 0 0 160px;
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.settings-row-value {
  flex: 1;
  font-size: 13px;
  color: var(--c-text);
  word-break: break-all;
}
.settings-row-value.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}
.pill-ok, .pill-warn {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-left: 6px;
  font-family: var(--font-mono);
}
.pill-ok { background: var(--c-success-bg); color: var(--c-success); }
.pill-warn { background: var(--c-warning); color: var(--c-warning-text); }

.signature-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-divider);
  background: var(--c-actionbar-bg);
}
.sig-tool {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.sig-tool:hover { background: white; color: var(--c-text); }
.sig-tool-divider {
  width: 1px;
  height: 18px;
  background: var(--c-border);
  margin: 0 6px;
}
.signature-editor {
  padding: 18px;
  min-height: 160px;
  max-height: 420px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  transition: background 0.15s, box-shadow 0.15s;
}
.signature-editor:focus { background: #fcfcfc; }
.signature-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--c-text-subtle);
  pointer-events: none;
}
.signature-editor.drag-active {
  background: var(--c-brand-tint);
  box-shadow: inset 0 0 0 2px var(--c-brand);
}
.signature-editor img {
  max-width: 100%;
  height: auto;
  border: 0;
  vertical-align: middle;
}
.signature-hint {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 8px;
  line-height: 1.5;
  font-style: italic;
}

.settings-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}
.settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 0;
  font-size: 13px;
  user-select: none;
}
.settings-toggle input { display: none; }
.toggle-track {
  width: 32px;
  height: 18px;
  background: var(--c-border-strong);
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.18s;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.settings-toggle input:checked + .toggle-track { background: var(--c-brand); }
.settings-toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(14px); }
.toggle-label { color: var(--c-text); }

.settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
}
.settings-actions .btn {
  width: auto;
  padding: 9px 18px;
}
.settings-status {
  font-size: 12px;
  color: var(--c-text-muted);
  font-feature-settings: 'tnum';
}
.settings-status.success { color: var(--c-success); font-weight: 500; }
.settings-status.error { color: var(--c-error); font-weight: 500; }
.settings-hint {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 12px;
  font-style: italic;
}

/* Email signature wrapper inside reading & compose */
.email-signature {
  font-size: 13px;
  color: var(--c-text-secondary);
  line-height: 1.55;
  padding-top: 4px;
}

/* Footer */
.app-footer {
  position: fixed;
  bottom: 6px;
  right: 14px;
  font-size: 10px;
  color: var(--c-text-muted);
  font-family: var(--font-mono);
  z-index: 5;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 3px 9px;
  border-radius: 12px;
  letter-spacing: 0.01em;
  pointer-events: auto;
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.app-footer a { color: var(--c-brand); }
.app-footer a:hover { text-decoration: underline; }

/* Utilities */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner.dark {
  border-color: var(--c-border);
  border-top-color: var(--c-brand);
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon { width: 16px; height: 16px; flex-shrink: 0; }
.hidden { display: none !important; }

/* Scrollbar polish */
.list-items::-webkit-scrollbar,
.reading-content::-webkit-scrollbar,
.compose-body::-webkit-scrollbar,
.folder-list::-webkit-scrollbar,
.dropdown::-webkit-scrollbar { width: 8px; height: 8px; }
.list-items::-webkit-scrollbar-thumb,
.reading-content::-webkit-scrollbar-thumb,
.compose-body::-webkit-scrollbar-thumb,
.folder-list::-webkit-scrollbar-thumb,
.dropdown::-webkit-scrollbar-thumb { background: #d2d0ce; border-radius: 4px; }
.list-items::-webkit-scrollbar-thumb:hover,
.reading-content::-webkit-scrollbar-thumb:hover { background: #a19f9d; }

/* Responsive */
@media (max-width: 1180px) {
  .folder-pane { width: 220px; }
  .list-pane { width: 340px; }
  .topbar-brand-mini { display: none; }
  .topbar-start { max-width: 220px; }
  .topbar-email { max-width: 220px; }
}
@media (max-width: 1000px) {
  .topbar-start { display: none; }
}
@media (max-width: 960px) {
  .folder-pane { width: 200px; }
  .list-pane { width: 300px; }
}
@media (max-width: 820px) {
  .folder-pane { display: none; }
  .app-main.folders-collapsed .folder-pane { display: none; }
}
@media (max-width: 720px) {
  .list-pane { width: 100%; max-width: none; }
  .reading-pane { display: none; }
  .reading-pane.mobile-active { display: flex; position: absolute; inset: 0; z-index: 30; }
  .ab-btn span { display: none; }
  .ab-btn { padding: 0 10px; }
  .topbar-user span { display: none; }
}
