/* ─────────────────────────────────────────────────────────────
   Unimail — premium UI. Light + dark, fully responsive.
   ───────────────────────────────────────────────────────────── */
/* The hidden attribute must always win, even over flex/grid displays. */
[hidden] { display: none !important; }
:root {
  --accent: #2f5be6;
  --accent-2: #5a7cff;
  --accent-soft: rgba(47, 91, 230, 0.12);
  --danger: #ef4444;
  --star: #f5b301;

  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-hover: #f0f1f8;
  --border: #e6e8f0;
  --border-strong: #d6d9e6;
  --text: #1b1e2b;
  --text-2: #5b6072;
  --text-3: #9096a8;
  --shadow-sm: 0 1px 2px rgba(23, 25, 40, 0.06), 0 1px 3px rgba(23, 25, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(23, 25, 40, 0.1);
  --shadow-lg: 0 20px 60px rgba(23, 25, 40, 0.22);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 264px;
  --list-w: 380px;
}

:root[data-theme='dark'],
html[data-theme='auto'] {
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme='auto'] {
    --bg: #0e0f16;
    --surface: #171923;
    --surface-2: #1d2030;
    --surface-hover: #232636;
    --border: #262a3b;
    --border-strong: #333852;
    --text: #eef0f7;
    --text-2: #a2a8bd;
    --text-3: #6b7288;
    --accent-soft: rgba(47, 91, 230, 0.2);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  }
}

html[data-theme='dark'] {
  --bg: #0e0f16;
  --surface: #171923;
  --surface-2: #1d2030;
  --surface-hover: #232636;
  --border: #262a3b;
  --border-strong: #333852;
  --text: #eef0f7;
  --text-2: #a2a8bd;
  --text-3: #6b7288;
  --accent-soft: rgba(47, 91, 230, 0.2);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }
::selection { background: var(--accent-soft); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ── Layout ── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; height: 100dvh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 14px; gap: 6px; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; }
.brand-mark { display: grid; place-items: center; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }

.compose-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: none;
  padding: 12px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: 0 6px 18px rgba(47, 91, 230, 0.35);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
  margin-bottom: 8px;
}
.compose-btn:hover { filter: brightness(1.05); box-shadow: 0 10px 24px rgba(47, 91, 230, 0.45); }
.compose-btn:active { transform: scale(0.97); }

/* Bulk send button (secondary) */
.bulk-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 13.5px; cursor: pointer; margin-bottom: 10px; transition: border-color 0.15s, background 0.15s; }
.bulk-btn:hover { border-color: var(--accent); color: var(--accent); }
.bulk-btn .ic { font-size: 15px; }

/* Bulk send modal */
.bulk-warn { background: color-mix(in srgb, var(--star) 14%, transparent); color: var(--text-2); border: 1px solid color-mix(in srgb, var(--star) 40%, transparent); border-radius: 10px; padding: 9px 12px; font-size: 12.5px; line-height: 1.45; margin: 8px 0; }
.bulk-paste { width: 100%; min-height: 90px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); padding: 10px 12px; outline: none; resize: vertical; font-size: 13px; line-height: 1.5; margin-top: 6px; }
.bulk-paste:focus { border-color: var(--accent); }
.bulk-import { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; flex-wrap: wrap; }
.bulk-import .ghost-btn { margin: 0; }
.bulk-import-hint { font-size: 11.5px; color: var(--text-3); }
.bulk-listsave { display: flex; gap: 8px; margin: 8px 0; }
.bulk-listsave input { flex: 1; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; color: var(--text); outline: none; font-size: 13px; }
.bulk-listsave .ghost-btn { margin: 0; }
.bulk-count { font-size: 12px; font-weight: 600; color: var(--accent); padding: 4px 0 8px; }
.compose-body #bulkBody { width: 100%; min-height: 160px; border: none; outline: none; background: transparent; color: var(--text); resize: vertical; padding: 12px 0; line-height: 1.6; border-top: 1px solid var(--border); margin-top: 4px; }
.bulk-opts { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.bulk-opts select { border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 6px 8px; color: var(--text); margin-left: 6px; }
.bulk-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.bulk-check input { accent-color: var(--accent); }
.bulk-progress { margin: 12px 0 4px; }
.bulk-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bulk-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }
.bulk-status { font-size: 12.5px; color: var(--text-2); margin-top: 6px; font-weight: 500; }
.bulk-ai-btn { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 2px; background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 8px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.bulk-ai-btn:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.bulk-ai-btn:disabled { opacity: 0.6; cursor: default; }

/* AI reply action button */
.action-btn.ai { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.action-btn.ai:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }

.folders { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: none; color: var(--text-2);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  text-align: left; width: 100%; transition: background 0.14s ease, color 0.14s ease;
}
.nav-item .ic { font-size: 15px; width: 18px; text-align: center; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--text-3); font-weight: 600; }
.nav-item.active .count { color: var(--accent); }

.section-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); padding: 16px 12px 6px; }
.accounts { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; flex: 1; }
.acc-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none; color: var(--text-2);
  padding: 8px 10px; border-radius: var(--radius-sm); width: 100%; text-align: left;
  transition: background 0.14s ease; min-height: 40px;
}
.acc-item:hover { background: var(--surface-hover); }
.acc-item.active { background: var(--accent-soft); }
.acc-item.active .acc-addr { color: var(--accent); font-weight: 600; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px;
}
.avatar.all { background: linear-gradient(135deg, var(--accent), #b06dfd); }
.acc-meta { min-width: 0; flex: 1; }
.acc-addr { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.acc-sub { font-size: 11px; color: var(--text-3); }
.badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
}
.badge.zero { display: none; }
.acc-skel { height: 40px; border-radius: var(--radius-sm); margin: 2px 0; background: linear-gradient(90deg, var(--surface-2), var(--surface-hover), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.sidebar-foot { font-size: 11px; color: var(--text-3); padding: 10px 8px 2px; border-top: 1px solid var(--border); margin-top: 6px; }

/* ── Main ── */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.view-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 0; white-space: nowrap; }
.search {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; color: var(--text-3); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: none; background: transparent; outline: none; width: 100%; color: var(--text); }
.icon-btn {
  display: grid; place-items: center; background: transparent; border: none; color: var(--text-2);
  width: 38px; height: 38px; border-radius: 10px; transition: background 0.14s ease, color 0.14s ease;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.only-mobile { display: none; }

.panes { flex: 1; display: grid; grid-template-columns: var(--list-w) 1fr; min-height: 0; }

/* ── Message list ── */
.list-pane { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); position: relative; }
.list-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); min-height: 46px; }
.selall { display: flex; align-items: center; }
.list-count { font-size: 12px; color: var(--text-3); font-weight: 600; }
.list-head-actions { margin-left: auto; }
.text-btn { background: transparent; border: none; color: var(--accent); font-weight: 600; font-size: 12.5px; padding: 4px 6px; border-radius: 8px; }
.text-btn:hover { background: var(--accent-soft); }

.errors { display: flex; flex-direction: column; gap: 6px; padding: 0 12px; }
.errors:not(:empty) { padding: 10px 12px 0; }
.err-chip { font-size: 12px; color: var(--danger); background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.25); border-radius: 8px; padding: 7px 10px; }

.msg-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; min-height: 0; }
.msg {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: start;
  padding: 12px 12px; border-radius: 12px; cursor: pointer; position: relative;
  transition: background 0.12s ease; margin-bottom: 2px;
}
.msg:hover { background: var(--surface-hover); }
.msg.selected { background: var(--accent-soft); }
.msg.unread .msg-from, .msg.unread .msg-subject { font-weight: 700; color: var(--text); }
.msg.unread::before { content: ''; position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 4px; height: 22px; border-radius: 4px; background: var(--accent); }

.msg-avatar { grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.msg-line1 { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-from { font-size: 13.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-time { margin-left: auto; font-size: 11.5px; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }
.msg-subject { font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-snippet { grid-column: 2 / 4; font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-meta { grid-column: 2 / 4; display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.chip { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip.dot::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: middle; background: var(--chip-color, var(--accent)); }
.msg-star { background: none; border: none; color: var(--text-3); padding: 2px; font-size: 14px; line-height: 1; }
.msg-star.on { color: var(--star); }
.attach-ic { font-size: 11px; color: var(--text-3); }

/* skeleton rows */
.skel-row { display: flex; gap: 12px; padding: 12px; }
.skel-av { width: 36px; height: 36px; border-radius: 50%; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.skel-line { height: 10px; border-radius: 6px; }
.skel-av, .skel-line { background: linear-gradient(90deg, var(--surface-2), var(--surface-hover), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.list-empty, .reader-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; color: var(--text-3); }
.empty-emoji { font-size: 44px; margin-bottom: 12px; opacity: 0.9; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-2); margin: 0 0 4px; }
.empty-sub { font-size: 13px; margin: 0; }

/* ── Reading pane ── */
.read-pane { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.reader { overflow-y: auto; padding: 26px 32px 60px; max-width: 860px; width: 100%; margin: 0 auto; }
.reader-back { display: none; }
.reader-subject { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 16px; line-height: 1.3; }
.reader-head { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.reader-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.reader-who { min-width: 0; flex: 1; }
.reader-from { font-weight: 600; font-size: 15px; }
.reader-to { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-date { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.reader-mailbox { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); padding: 5px 10px; border-radius: 999px; margin-bottom: 16px; }

.reader-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.action-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13px; transition: background 0.14s, border-color 0.14s, transform 0.1s; box-shadow: var(--shadow-sm); }
.action-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.action-btn:active { transform: scale(0.97); }
.action-btn.danger { color: var(--danger); }
.action-btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.action-btn.primary:hover { filter: brightness(1.06); }

.reader-body { font-size: 14.5px; line-height: 1.65; color: var(--text); word-wrap: break-word; overflow-wrap: anywhere; }
.reader-body.html-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.reader-body img { max-width: 100%; height: auto; }
.reader-body a { color: var(--accent); }
.reader-body pre { white-space: pre-wrap; }
.reader-body table { max-width: 100%; }

.attachments { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 10px; }
.attach-title { width: 100%; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.attach { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-width: 200px; max-width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); transition: border-color 0.14s, box-shadow 0.14s; }
.attach:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.attach-ico { font-size: 20px; width: 40px; height: 40px; display: grid; place-items: center; background: var(--surface-2); border-radius: 8px; flex-shrink: 0; }
.attach-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--surface-2); }
.attach-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.attach-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { font-size: 11.5px; color: var(--text-3); }

/* ── Compose ── */
.modal-scrim, .scrim { position: fixed; inset: 0; background: rgba(10, 12, 20, 0.5); backdrop-filter: blur(3px); z-index: 60; display: grid; place-items: end center; }
.scrim { z-index: 40; display: none; }
.modal-scrim[hidden] { display: none; }
.compose {
  width: min(680px, 100%); max-height: 92vh; margin: 0 20px 20px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px 18px 14px 14px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; animation: slideUp 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.compose-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; }
.compose-body { padding: 6px 18px; overflow-y: auto; }
.field { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.field label { width: 58px; font-size: 12.5px; color: var(--text-3); font-weight: 600; flex-shrink: 0; }
.field input, .field select { flex: 1; border: none; background: transparent; outline: none; color: var(--text); padding: 12px 0; }
.field select { cursor: pointer; }
.compose-body textarea { width: 100%; min-height: 220px; border: none; outline: none; background: transparent; color: var(--text); resize: vertical; padding: 14px 0; line-height: 1.6; }

/* ── Rich-text editor ── */
.rt-toolbar { display: flex; align-items: center; gap: 2px; padding: 8px 0 6px; margin-top: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rt-btn { min-width: 30px; height: 30px; padding: 0 7px; border: none; background: transparent; color: var(--text-2); border-radius: 7px; cursor: pointer; font-size: 14px; line-height: 1; display: inline-grid; place-items: center; }
.rt-btn:hover { background: var(--surface-hover); color: var(--text); }
.rt-btn b, .rt-btn i, .rt-btn u { font-size: 14px; }
.rt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }
.rt-editor { width: 100%; min-height: 200px; max-height: 46vh; overflow-y: auto; outline: none; background: transparent; color: var(--text); padding: 14px 2px; line-height: 1.6; font-size: 14px; }
.rt-editor:empty:before { content: attr(data-placeholder); color: var(--text-3); }
.rt-editor img { max-width: 100%; }
.rt-editor a { color: var(--accent); }
.rt-editor blockquote { margin: 0 0 0 4px; padding-left: 12px; border-left: 2px solid var(--border); color: var(--text-2); }
.rt-sig { color: var(--text-2); }
.rt-quote { margin-top: 10px; color: var(--text-2); font-size: 13px; }

/* ── Signatures modal ── */
.sig-text { width: 100%; min-height: 120px; margin-top: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); padding: 12px; outline: none; resize: vertical; font-family: inherit; line-height: 1.5; }
.sig-text:focus { border-color: var(--accent); }
.sig-preview-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin: 14px 0 6px; }
.sig-preview { border: 1px dashed var(--border); border-radius: 10px; padding: 12px; min-height: 44px; color: var(--text); font-size: 13.5px; line-height: 1.5; }
.sig-empty { color: var(--text-3); }

/* ── Login screen ── */
.login-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), var(--bg)); }
.login-screen[hidden] { display: none; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 32px 28px; display: flex; flex-direction: column; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; margin-bottom: 20px; }
.login-title { font-size: 22px; font-weight: 700; margin: 0; }
.login-sub { color: var(--text-3); font-size: 13.5px; margin: 4px 0 22px; }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.login-field span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.login-field input { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 12px 14px; outline: none; font-size: 15px; }
.login-field input:focus { border-color: var(--accent); }
.login-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); color: #fff; border: none; padding: 13px; border-radius: 10px; font-weight: 700; font-size: 15px; margin-top: 6px; box-shadow: 0 6px 16px rgba(47, 91, 230, 0.35); }
.login-btn:hover { filter: brightness(1.06); }
.login-btn:disabled { opacity: 0.6; }
.login-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-radius: 8px; padding: 9px 12px; font-size: 13px; font-weight: 500; margin-bottom: 12px; }

/* Show/hide password toggle */
.pw-wrap { position: relative; display: flex; flex: 1; align-items: center; }
.pw-wrap input { flex: 1; padding-right: 40px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: transparent; border: none; color: var(--text-3); cursor: pointer; padding: 4px; display: grid; place-items: center; border-radius: 6px; line-height: 0; }
.pw-toggle:hover { color: var(--accent); background: var(--surface-hover); }

/* ── User row (sidebar) ── */
.user-row { display: flex; align-items: center; gap: 9px; padding: 8px 6px; }
.user-avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; margin-right: auto; }
.user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--text-3); }
.user-team, .user-logout { width: 30px; height: 30px; color: var(--text-3); }
.user-team:hover, .user-logout:hover { color: var(--accent); background: var(--surface-hover); }
.acct-summary { font-size: 11px; color: var(--text-3); padding: 0 6px; }

/* ── Team modal ── */
.team-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; }
.team-meta { display: flex; flex-direction: column; min-width: 0; margin-right: auto; line-height: 1.3; }
.team-name { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.team-sub { font-size: 11.5px; color: var(--text-3); }
.team-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 5px; }
.team-badge.admin { background: var(--accent-soft); color: var(--accent); }
.team-badge.member { background: var(--surface-2); color: var(--text-3); }
.team-add { margin-left: 0 !important; width: 100%; text-align: center; }
.tf-mailboxes { margin-top: 8px; }
.tf-mb-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin: 6px 0 8px; }
.tf-mb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; max-height: 240px; overflow-y: auto; }
.tf-mb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); cursor: pointer; }
.tf-mb input { accent-color: var(--accent); }
@media (max-width: 560px) { .tf-mb-grid { grid-template-columns: 1fr; } }
.compose-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.send-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--accent); color: #fff; border: none; padding: 10px 22px; border-radius: 10px; font-weight: 600; box-shadow: 0 6px 16px rgba(47, 91, 230, 0.35); transition: filter 0.15s, transform 0.1s; }
.send-btn:hover { filter: brightness(1.06); }
.send-btn:active { transform: scale(0.97); }
.send-btn:disabled { opacity: 0.6; cursor: not-allowed; filter: none; }
.ghost-btn { margin-left: auto; background: transparent; border: 1px solid var(--border); color: var(--text-2); padding: 10px 18px; border-radius: 10px; font-weight: 600; }
.ghost-btn:hover { background: var(--surface-hover); }

/* ── Add / manage mailboxes ── */
.section-label { display: flex; align-items: center; justify-content: space-between; }
.add-acc-btn { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--border); background: transparent; color: var(--text-2); border-radius: 7px; font-size: 15px; line-height: 1; cursor: pointer; transition: background 0.15s, color 0.15s; }
.add-acc-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.add-modal { width: min(460px, 100%); max-height: 88vh; margin: 0 20px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px 18px 14px 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: slideUp 0.22s cubic-bezier(0.2, 0.9, 0.3, 1); }
.add-hint { font-size: 12.5px; color: var(--text-3); margin: 10px 0 6px; line-height: 1.5; }
.manage-list { margin-top: 16px; }
.manage-head { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); padding: 6px 0; }
.manage-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.manage-addr { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manage-del { background: transparent; border: 1px solid var(--border); color: var(--text-3); font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 8px; cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.manage-del:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.spinner { width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Compose attachments ── */
.compose { position: relative; }
.attach-btn { color: var(--text-2); }
.attach-btn:hover { color: var(--accent); background: var(--surface-hover); }
.attach-total { font-size: 12px; color: var(--text-3); margin-right: auto; }
.attach-total.over { color: var(--danger); font-weight: 600; }
.ghost-btn { margin-left: 0; }

.attach-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; max-height: 140px; overflow-y: auto; }
.attach-tray:not(:empty) { border-top: 1px solid var(--border); }
.att-chip { display: flex; align-items: center; gap: 8px; max-width: 240px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; animation: chipIn 0.16s ease; }
@keyframes chipIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.att-thumb { width: 34px; height: 34px; border-radius: 7px; object-fit: cover; flex-shrink: 0; background: var(--surface); }
.att-emoji { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; font-size: 18px; background: var(--surface); flex-shrink: 0; }
.att-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.att-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { font-size: 11px; color: var(--text-3); }
.att-remove { border: none; background: transparent; color: var(--text-3); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 6px; flex-shrink: 0; }
.att-remove:hover { background: var(--danger); color: #fff; }

.compose-drop { position: absolute; inset: 0; z-index: 5; display: none; place-items: center; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 2px dashed var(--accent); border-radius: 18px; pointer-events: none; }
.compose-drop.show { display: grid; }
.drop-inner { font-weight: 700; color: var(--accent); font-size: 16px; }
.drop-ico { font-size: 22px; }

/* ── Toasts ── */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); box-shadow: var(--shadow-md); border-radius: 12px; padding: 12px 16px; font-size: 13.5px; font-weight: 500; min-width: 220px; max-width: 360px; animation: toastIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1); }
.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: var(--danger); }
.toast.leaving { animation: toastOut 0.25s forwards; }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(30px); opacity: 0; } }

/* ── Responsive ── */
@media (max-width: 980px) {
  :root { --list-w: 320px; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50;
    transform: translateX(-100%); transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .app.drawer-open .scrim { display: block; }
  .only-mobile { display: grid; }
  .search { max-width: none; }
  .panes { grid-template-columns: 1fr; }

  /* One column at a time on phones */
  .read-pane { position: fixed; inset: 0; z-index: 30; transform: translateX(100%); transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1); }
  .app.reading .read-pane { transform: translateX(0); }
  .list-pane { border-right: none; }
  .reader { padding: 18px 18px 80px; }
  .reader-subject { font-size: 19px; }
  .reader-back { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: none; color: var(--accent); font-weight: 600; font-size: 14px; padding: 4px 0 12px; }
  .compose { margin: 0; border-radius: 16px 16px 0 0; max-height: 96vh; width: 100%; }
  .modal-scrim { place-items: end stretch; }
  .action-btn { flex: 1; justify-content: center; }

  /* Floating compose on mobile */
  .compose-btn { position: fixed; bottom: 20px; right: 20px; z-index: 25; width: 56px; height: 56px; padding: 0; border-radius: 50%; }
  .compose-btn span.compose-text { display: none; }
}

@media (min-width: 761px) {
  .reader-back { display: none; }
}
