/* ════════════════════════════════════════════════════════════
   fekzmail — premium dashboard UI
   ════════════════════════════════════════════════════════════ */
:root {
  --bg: #09090c;
  --panel: rgba(255, 255, 255, 0.028);
  --panel-solid: #101014;
  --card: rgba(255, 255, 255, 0.04);
  --card-hover: rgba(255, 255, 255, 0.065);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #f4f4f6;
  --muted: #8b8b96;
  --faint: #55555f;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --danger: #fb7185;
  --green: #34d399;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --topbar-h: 58px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(99, 102, 241, 0.4); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); background-clip: content-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

/* ── Ambient background ─────────────────────────────── */
.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.glow { position: absolute; border-radius: 50%; filter: blur(120px); opacity: .16; }
.glow-a { width: 560px; height: 560px; background: var(--accent); top: -200px; left: -120px; }
.glow-b { width: 480px; height: 480px; background: var(--accent-2); bottom: -220px; right: -100px; opacity: .11; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font: 600 13px 'Inter', sans-serif;
  cursor: pointer;
  transition: all .18s var(--ease);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:hover { background: var(--card-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 4px 20px rgba(99, 102, 241, .35);
}
.btn.primary:hover { filter: brightness(1.12); box-shadow: 0 4px 26px rgba(99, 102, 241, .5); }
.btn.primary:disabled { opacity: .55; cursor: default; filter: none; }

.btn.ghost { background: transparent; }
.btn.icon { padding: 8px; }
.btn.icon.danger:hover { color: var(--danger); border-color: rgba(251,113,133,.4); background: rgba(251,113,133,.08); }
.btn.block { width: 100%; justify-content: center; padding: 11px; }

/* ── Live dot ───────────────────────────────────────── */
.dot-live {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2.2s infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

/* ═══ LOGIN ═════════════════════════════════════════ */
.login-wrap {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  padding: 20px;
}
.login-card {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 40px 36px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  animation: rise .6s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

.logo-mark {
  width: 54px; height: 54px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 28px rgba(99,102,241,.45), inset 0 1px 0 rgba(255,255,255,.25);
}
.logo-mark svg { width: 26px; height: 26px; color: #fff; }
.logo-mark.sm { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.logo-mark.sm svg { width: 17px; height: 17px; }

.wordmark {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.wordmark.sm { font-size: 16px; }
.tagline { color: var(--muted); font-size: 13px; line-height: 1.6; margin-top: -8px; }

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: rgba(0,0,0,.25);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 14px;
  transition: border-color .18s;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-icon { width: 16px; height: 16px; color: var(--faint); flex-shrink: 0; }
.field input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font: 500 14px 'Inter', sans-serif;
  padding: 13px 0;
}
.field input::placeholder { color: var(--faint); }

.form-error {
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 500;
  animation: shake .35s;
}
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.login-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 500;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  width: 100%;
  justify-content: center;
}

/* ═══ DASHBOARD SHELL ═══════════════════════════════ */
.dash { height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 1; }

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  background: rgba(9,9,12,.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tb-left { display: flex; align-items: center; gap: 11px; }
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 700 10px 'Inter', sans-serif;
  letter-spacing: .1em;
  color: var(--green);
  background: rgba(52,211,153,.09);
  border: 1px solid rgba(52,211,153,.22);
  padding: 4px 10px;
  border-radius: 99px;
}
.tb-mid { flex: 1; text-align: center; color: var(--faint); font-size: 12.5px; font-weight: 500; }
.tb-right { display: flex; gap: 8px; }

.dash-body {
  flex: 1;
  display: grid;
  grid-template-columns: 272px 360px 1fr;
  min-height: 0;
}

/* ═══ SIDEBAR ═══ */
.sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(255,255,255,.012);
}
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
}
.side-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
}
.side-count {
  font: 600 11px var(--mono);
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 99px;
}
.inbox-list { list-style: none; overflow-y: auto; flex: 1; padding: 0 10px 14px; }

.inbox-list li.item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: var(--r-md);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 3px;
  transition: all .15s var(--ease);
  animation: fadeSlide .3s var(--ease) backwards;
}
@keyframes fadeSlide { from { opacity: 0; transform: translateX(-6px); } }
.inbox-list li.item:hover { background: var(--card); }
.inbox-list li.item.active { background: var(--accent-soft); border-color: rgba(99,102,241,.3); }

.inbox-list .avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font: 700 13px 'Inter', sans-serif;
  color: rgba(255,255,255,.92);
  flex-shrink: 0;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
}
.inbox-list .meta { flex: 1; min-width: 0; }
.inbox-list .addr {
  font: 500 12px var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-list .sub { font-size: 11px; color: var(--faint); margin-top: 1px; }
.inbox-list .badge {
  font: 700 10.5px 'Inter', sans-serif;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  padding: 2.5px 8px;
  box-shadow: 0 2px 8px rgba(99,102,241,.4);
}
.inbox-list .badge.zero {
  background: var(--card);
  color: var(--faint);
  border: 1px solid var(--border);
  box-shadow: none;
  font-family: var(--mono);
}
/* ═══ EMPTY STATES ═══ */
.inbox-list li.empty, .email-list li.empty {
  background: none !important;
  border: none !important;
  cursor: default;
  color: var(--faint);
  text-align: center;
  padding: 48px 16px;
  font-size: 12.5px;
  line-height: 1.9;
  display: block;
  animation: none;
}
.empty-art {
  width: 44px; height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
}
.empty-art svg { width: 20px; height: 20px; }

/* ═══ MAIL LIST ═══ */
.maillist {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pane-title {
  font: 600 12.5px var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-list { list-style: none; overflow-y: auto; flex: 1; padding: 10px; }

.email-list li.mail {
  padding: 12px 13px;
  border-radius: var(--r-md);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 3px;
  transition: all .15s var(--ease);
  animation: fadeSlide .3s var(--ease) backwards;
}
.email-list li.mail:hover { background: var(--card); }
.email-list li.mail.active { background: var(--accent-soft); border-color: rgba(99,102,241,.3); }

.mail-top { display: flex; align-items: center; gap: 8px; }
.mail-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}
.mail-dot.read { visibility: hidden; }
.mail-from {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
li.mail.unread .mail-from { color: var(--text); font-weight: 700; }
.mail-time { font: 500 11px var(--mono); color: var(--faint); flex-shrink: 0; }
.mail-subject {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent-2);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
li.mail.unread .mail-subject { color: #b3a5ff; font-weight: 600; }
.mail-preview {
  font-size: 12px;
  color: var(--faint);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ═══ READER ═══ */
.reader { display: flex; flex-direction: column; min-height: 0; }
.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.reader-subject {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-actions { display: flex; gap: 8px; flex-shrink: 0; }

.reader-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.reader-meta .avatar {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font: 700 14px 'Inter', sans-serif;
  color: rgba(255,255,255,.92);
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
}
.reader-meta .from-name { font-size: 13.5px; font-weight: 600; }
.reader-meta .from-sub {
  font: 500 11.5px var(--mono);
  color: var(--faint);
  margin-top: 1px;
}
.reader-meta .when { margin-left: auto; font: 500 11.5px var(--mono); color: var(--faint); }

.reader-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--faint);
}
.reader-empty svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 8px; }
.reader-empty p { font-size: 14px; font-weight: 600; color: var(--muted); }
.reader-empty span { font-size: 12px; }

.reader-frame {
  width: 100%;
  flex: 1;
  border: none;
  background: #fff;
}
.reader-text {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.7;
  padding: 22px;
  overflow-y: auto;
}
/* ═══ MODAL ═══ */
.modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn .18s ease;
  padding: 20px;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 26px;
  width: 400px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
  animation: rise .35s var(--ease);
}
.modal h3 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.modal-sub { color: var(--muted); font-size: 12.5px; margin-top: -10px; }

.mode-toggle {
  display: flex;
  background: rgba(0,0,0,.3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  gap: 4px;
}
.mode {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font: 600 12.5px 'Inter', sans-serif;
  cursor: pointer;
  transition: all .18s var(--ease);
}
.mode.active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(99,102,241,.35);
}

.addr-row { display: flex; align-items: center; gap: 8px; }
.addr-row input {
  flex: 1;
  min-width: 0;
  background: rgba(0,0,0,.3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  color: var(--text);
  font: 500 13px var(--mono);
  outline: none;
  transition: border-color .18s;
}
.addr-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.at { color: var(--faint); font-weight: 600; }
.addr-row select {
  flex: 1;
  background: rgba(0,0,0,.3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  color: var(--text);
  font: 500 13px var(--mono);
  outline: none;
  cursor: pointer;
}
.addr-row select:focus { border-color: var(--accent); }
.addr-row option { background: var(--panel-solid); }

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

/* ═══ TOAST ═══ */
.toast {
  position: fixed;
  bottom: 26px;
  right: 26px;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  z-index: 99;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  animation: toastIn .3s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1100px) {
  .dash-body { grid-template-columns: 232px 1fr; }
  .reader { display: none; }
  .tb-mid { display: none; }
}
@media (max-width: 640px) {
  .dash-body { grid-template-columns: 1fr; }
  .maillist { display: none; }
  .btn span { display: none; }
  .btn { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
