/* MailApp – Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #08080f; --surface: #0f0f1a; --surface2: #14141f;
  --border: #1e1e30; --border2: #252538;
  --text: #e2e2f0; --text2: #9898b8; --muted: #5a5a7a;
  --accent: #22d3ee; --accent2: #818cf8; --accent-dim: rgba(34,211,238,.12);
  --success: #34d399; --error: #f87171; --warning: #fbbf24;
  --radius: 10px; --sidebar: 260px;
  --font: 'Sora', sans-serif; --mono: 'JetBrains Mono', monospace;
}
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5;
}
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: var(--font); }
a { color: inherit; text-decoration: none; }
/* ── Layout ── */
#app { display: flex; height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .25s ease;
}
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
/* ── Sidebar ── */
.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.logo-text { font-size: 17px; font-weight: 600; color: #fff; letter-spacing: -.02em; }
.logo-text span { color: var(--accent); }
.compose-btn {
  width: 100%; padding: 9px 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: var(--radius); color: #000;
  font-size: 13px; font-weight: 600; display: flex; align-items: center;
  gap: 8px; justify-content: center;
  transition: opacity .2s;
}
.compose-btn:hover { opacity: .85; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 8px; }
.nav-section { margin-bottom: 4px; }
.nav-label {
  font-size: 10px; font-weight: 600; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase;
  padding: 12px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text2); font-size: 13px; cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item .nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }
.nav-item .nav-count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--accent); color: #000;
  padding: 1px 6px; border-radius: 10px; min-width: 20px; text-align: center;
}
.account-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; margin-left: auto;
}
/* ── Toolbar ── */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.toolbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.search-wrap {
  flex: 1; max-width: 360px; position: relative;
}
.search-wrap input {
  width: 100%; background: var(--bg); border: 1px solid var(--border2);
  border-radius: 8px; padding: 7px 12px 7px 34px;
  font-size: 13px; color: var(--text); outline: none;
  transition: border-color .2s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.icon-btn {
  width: 34px; height: 34px; display: flex; align-items: center;
  justify-content: center; border-radius: 8px; color: var(--text2);
  font-size: 17px; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.menu-btn { display: none; }
/* ── Mail List ── */
.mail-list { flex: 1; overflow-y: auto; }
.mail-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .12s;
  position: relative;
}
.mail-item:hover { background: var(--surface); }
.mail-item.active { background: var(--accent-dim); border-left: 3px solid var(--accent); }
.mail-item.unread .mail-subject { font-weight: 600; color: #fff; }
.unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; margin-top: 6px;
}
.mail-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; flex-shrink: 0;
  color: #000;
}
.mail-meta { flex: 1; min-width: 0; }
.mail-from { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-subject { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.mail-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.badge {
  font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 500;
}
.badge-attach { background: rgba(129,140,248,.15); color: var(--accent2); }
.badge-flagged { background: rgba(251,191,36,.15); color: var(--warning); }
.badge-account { color: #000; }
/* ── Mail Detail ── */
.mail-detail {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
}
.detail-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.detail-subject { font-size: 20px; font-weight: 600; color: #fff; margin-bottom: 12px; line-height: 1.3; }
.detail-meta { display: flex; align-items: flex-start; gap: 12px; }
.detail-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; flex-shrink: 0; color: #000;
}
.detail-from { font-size: 14px; font-weight: 500; color: var(--text); }
.detail-email { font-size: 12px; color: var(--muted); }
.detail-date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.detail-actions {
  display: flex; gap: 8px; padding: 12px 24px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.action-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  font-size: 12px; font-weight: 500; color: var(--text2);
  background: var(--surface2); border: 1px solid var(--border2);
  transition: all .15s;
}
.action-btn:hover { color: var(--text); border-color: var(--border); }
.action-btn.danger:hover { color: var(--error); border-color: var(--error); background: rgba(248,113,113,.08); }
.action-btn.warn:hover   { color: var(--warning); border-color: var(--warning); background: rgba(251,191,36,.08); }
.action-btn.success:hover { color: var(--success); border-color: var(--success); background: rgba(52,211,153,.08); }
.unsub-banner {
  margin: 12px 24px; padding: 10px 16px;
  background: rgba(251,191,36,.07); border: 1px solid rgba(251,191,36,.2);
  border-radius: 8px; display: flex; align-items: center; gap: 10px;
}
.unsub-banner span { font-size: 12.5px; color: #c9a84c; flex: 1; }
.unsub-btn {
  font-size: 12px; font-weight: 600; color: #000;
  background: var(--warning); padding: 5px 12px; border-radius: 6px;
  transition: opacity .15s;
}
.unsub-btn:hover { opacity: .85; }
.detail-body { padding: 24px; flex: 1; }
.body-html { max-width: 700px; }
.body-html img { max-width: 100%; height: auto; }
.body-html a { color: var(--accent); }
.body-text { font-family: var(--mono); font-size: 13px; line-height: 1.7; color: var(--text2); white-space: pre-wrap; word-break: break-word; }
/* ── Compose ── */
.compose-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 16px; z-index: 100;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.compose-box {
  width: 100%; max-width: 560px; height: 520px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 16px; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity:0; } to { transform: translateY(0); opacity:1; } }
.compose-header {
  display: flex; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px;
}
.compose-header span { flex: 1; }
.compose-fields { padding: 0 16px; }
.compose-field {
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border); padding: 10px 0;
}
.compose-field label { font-size: 12px; color: var(--muted); width: 44px; flex-shrink: 0; }
.compose-field input, .compose-field select {
  flex: 1; background: none; border: none; outline: none;
  font-size: 13px; color: var(--text);
}
.compose-field select option { background: var(--surface); }
.compose-body {
  flex: 1; margin: 0; padding: 12px 16px;
  background: none; border: none; outline: none; resize: none;
  font-size: 13px; color: var(--text); line-height: 1.6;
  font-family: var(--font);
}
.compose-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-top: 1px solid var(--border);
}
.send-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #000; font-size: 13px; font-weight: 600;
  transition: opacity .15s;
}
.send-btn:hover { opacity: .85; }
/* ── Settings ── */
.settings-panel {
  flex: 1; overflow-y: auto; padding: 24px;
}
.settings-panel h2 { font-size: 20px; font-weight: 600; margin-bottom: 20px; }
.settings-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; margin-bottom: 20px; overflow: hidden;
}
.settings-section-title {
  padding: 14px 18px; font-size: 12px; font-weight: 600;
  color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.settings-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row .row-icon { font-size: 18px; width: 24px; text-align: center; }
.settings-row .row-text { flex: 1; }
.settings-row .row-name { font-size: 13px; font-weight: 500; }
.settings-row .row-sub { font-size: 12px; color: var(--muted); }
.settings-row .row-actions { display: flex; gap: 6px; }
.small-btn {
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border2); color: var(--text2);
  transition: all .15s;
}
.small-btn:hover { border-color: var(--accent); color: var(--accent); }
.small-btn.danger:hover { border-color: var(--error); color: var(--error); }
/* ── Form modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 200; animation: fadeIn .2s ease;
}
.modal {
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 16px; padding: 28px;
  animation: slideUp .25s ease;
}
.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.form-field { margin-bottom: 16px; }
.form-field label {
  display: block; font-size: 11px; font-weight: 500; color: var(--muted);
  letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px;
}
.form-field input, .form-field select {
  width: 100%; background: var(--bg); border: 1px solid var(--border2);
  border-radius: 8px; padding: 9px 12px; font-size: 13px;
  color: var(--text); outline: none; transition: border-color .2s;
}
.form-field input:focus, .form-field select:focus {
  border-color: var(--accent);
}
.form-row { display: grid; grid-template-columns: 1fr 90px 70px; gap: 10px; }
.color-row { display: flex; gap: 8px; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent; transition: border-color .15s;
}
.color-swatch.selected { border-color: #fff; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }
.btn-primary {
  flex: 1; padding: 10px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #000; font-size: 13px; font-weight: 600;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }
.btn-secondary {
  padding: 10px 20px; border-radius: 8px; font-size: 13px;
  border: 1px solid var(--border2); color: var(--text2);
  transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--border); color: var(--text); }
/* ── Empty / Loading states ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; padding: 40px; text-align: center; gap: 12px;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 4px; }
.empty-state h3 { font-size: 16px; font-weight: 500; }
.empty-state p { font-size: 13px; color: var(--muted); }
.spinner {
  width: 24px; height: 24px; border: 2px solid var(--border2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* ── Toast ── */
.toast-container { position: fixed; bottom: 80px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 300px;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { background: rgba(52,211,153,.15); border: 1px solid rgba(52,211,153,.3); color: var(--success); }
.toast-error   { background: rgba(248,113,113,.15); border: 1px solid rgba(248,113,113,.3); color: var(--error); }
.toast-info    { background: rgba(34,211,238,.1);   border: 1px solid rgba(34,211,238,.25); color: var(--accent); }
/* ── Mobile ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,.5); }
  .menu-btn { display: flex; }
  .detail-subject { font-size: 17px; }
  .compose-box { max-width: 100%; height: 480px; }
  .compose-overlay { padding: 0; align-items: flex-end; }
  .compose-box { border-radius: 16px 16px 0 0; }
}
@media (min-width: 769px) {
  .back-btn { display: none !important; }
}
/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
/* ── Login ── */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
  background-image:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(34,211,238,.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(129,140,248,.05) 0%, transparent 60%);
}
.login-card {
  width: 100%; max-width: 360px; padding: 40px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: 0 32px 80px rgba(0,0,0,.6);
  animation: slideUp .4s ease;
}
