/* ═══════════════════════════════════════════════════════════════
   QUICK MAIL — Ultra Premium Dark Theme v7
   Ambient glow, aurora gradients, glass depth, micro-interactions
═══════════════════════════════════════════════════════════════ */

:root {
  /* Base Colors — deep space palette */
  --bg-base:       hsl(228, 20%, 3%);
  --bg-surface:    hsl(228, 18%, 5%);
  --bg-elevated:   hsl(228, 15%, 8%);
  --bg-hover:      hsl(228, 14%, 11%);
  --bg-active:     hsl(228, 14%, 14%);
  --bg-panel:      hsl(228, 18%, 5.5%);

  /* Text Colors — crystal clear hierarchy */
  --text-primary:   hsl(220, 20%, 97%);
  --text-secondary: hsl(220, 10%, 70%);
  --text-muted:     hsl(220, 7%, 46%);
  --text-disabled:  hsl(220, 5%, 28%);
  --text-placeholder: hsl(220, 5%, 36%);

  /* Borders — ethereal depth layers */
  --border:        hsl(228, 12%, 9%);
  --border-soft:   hsl(228, 12%, 12%);
  --border-strong: hsl(228, 12%, 16%);
  --border-glow:   hsl(240, 70%, 60%, .10);

  /* Brand / Accent — electric indigo with aurora shift */
  --accent:        hsl(240, 90%, 66%);
  --accent-light:  hsl(240, 90%, 74%);
  --accent-hover:  hsl(240, 90%, 58%);
  --accent-subtle: hsl(240, 90%, 66%, .07);
  --accent-glow:   hsl(240, 90%, 66%, .14);
  --accent-text:   hsl(235, 100%, 86%);

  /* Semantic Colors */
  --red:           hsl(0, 80%, 62%);
  --red-bg:        hsl(0, 80%, 62%, .08);
  --red-border:    hsl(0, 80%, 62%, .16);

  --amber:         hsl(40, 95%, 58%);
  --amber-bg:      hsl(40, 95%, 58%, .07);
  --amber-border:  hsl(40, 95%, 58%, .16);

  --green:         hsl(160, 75%, 48%);
  --green-bg:      hsl(160, 75%, 48%, .07);
  --green-border:  hsl(160, 75%, 48%, .16);

  --blue:          hsl(215, 90%, 62%);
  --blue-bg:       hsl(215, 90%, 62%, .07);

  /* Layout */
  --sidebar-w:    264px;
  --list-w:       388px;
  --topbar-h:     56px;

  /* Radii — rounder, softer */
  --r-xs:  5px;
  --r-sm:  9px;
  --r:     13px;
  --r-md:  16px;
  --r-lg:  20px;
  --r-xl:  24px;
  --r-full: 9999px;

  /* Shadows — volumetric depth */
  --shadow-xs:  0 1px 3px hsl(228,20%,1%,.4);
  --shadow-sm:  0 2px 8px hsl(228,20%,1%,.5), 0 1px 3px hsl(228,20%,1%,.3);
  --shadow-md:  0 6px 24px hsl(228,20%,1%,.55), 0 2px 8px hsl(228,20%,1%,.3);
  --shadow-lg:  0 14px 44px hsl(228,20%,1%,.6), 0 4px 14px hsl(228,20%,1%,.3);
  --shadow-xl:  0 24px 64px hsl(228,20%,1%,.7), 0 8px 28px hsl(228,20%,1%,.4);

  /* Overlay */
  --overlay: hsl(228, 35%, 2%, .82);

  /* Transitions — silky smooth */
  --t-fast:   0.14s cubic-bezier(0.4, 0, 0.2, 1);
  --t-base:   0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow:   0.32s cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-smooth: 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  --t-bounce: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ═══ MIX MODE ACCENT OVERRIDE ═══ */
body.imap-mode {
  --accent:        hsl(170, 80%, 50%);
  --accent-light:  hsl(170, 80%, 62%);
  --accent-hover:  hsl(170, 80%, 42%);
  --accent-subtle: hsl(170, 80%, 50%, .07);
  --accent-glow:   hsl(170, 80%, 50%, .14);
  --accent-text:   hsl(170, 90%, 78%);
}

/* ═══ SKELETON LOADING ═══ */
@keyframes skeleton-pulse {
  0%, 100% { opacity: .06; }
  50% { opacity: .12; }
}
.skeleton {
  background: var(--bg-hover);
  border-radius: var(--r-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-line { height: 14px; margin-bottom: 10px; border-radius: 6px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.long { width: 90%; }
.skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.skeleton-row { display: flex; gap: 12px; align-items: center; padding: 14px 16px; }

/* ═══ SMOOTH PAGE TRANSITIONS ═══ */
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slide-in-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ RESET & BASE ═══ */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html { height: 100%; overflow: hidden; }
body {
  height: 100%; overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px; line-height: 1.5;
  background: var(--bg-base); color: var(--text-secondary);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
::selection { background: hsl(240, 90%, 66%, .3); color: var(--text-primary); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, hsl(240, 30%, 22%) 0%, hsl(228, 12%, 16%) 100%);
  border-radius: 6px;
  transition: background 0.3s;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, hsl(240, 50%, 36%) 0%, hsl(228, 20%, 26%) 100%); }
::-webkit-scrollbar-corner { background: transparent; }
input, button, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--accent-text); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--text-primary); }
button { cursor: pointer; border: none; background: none; color: inherit; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ═══ APP LAYOUT ═══ */
.app {
  display: flex;
  height: 100vh; height: 100dvh;
  max-height: 100dvh;
  background: var(--bg-base);
  overflow: hidden; position: relative;
}
/* Ambient glow orbs — subtle cosmic atmosphere */
.app::before {
  content: '';
  position: fixed; top: -20%; left: -10%;
  width: 600px; height: 600px;
  background: radial-gradient(circle, hsl(240, 80%, 50%, .04) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none; z-index: 0;
  animation: ambient-drift-1 25s ease-in-out infinite alternate;
}
.app::after {
  content: '';
  position: fixed; bottom: -15%; right: -8%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, hsl(270, 70%, 50%, .035) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none; z-index: 0;
  animation: ambient-drift-2 30s ease-in-out infinite alternate;
}
@keyframes ambient-drift-1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.1); }
  100% { transform: translate(-30px, 80px) scale(0.95); }
}
@keyframes ambient-drift-2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, -30px) scale(1.08); }
  100% { transform: translate(40px, -60px) scale(0.92); }
}

/* ═══════════════════════════════════════
   SIDEBAR — Deep Glass
═══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: hsl(228, 20%, 4%, .92);
  backdrop-filter: blur(32px) saturate(1.3); -webkit-backdrop-filter: blur(32px) saturate(1.3);
  border-right: 1px solid hsl(228, 14%, 9%, .7);
  display: flex; flex-direction: column;
  flex-shrink: 0; z-index: 50;
  position: relative; height: 100%;
  transition: transform var(--t-smooth);
}
.sidebar::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 160px;
  background: radial-gradient(ellipse at 50% 0%, hsl(240, 70%, 50%, .04) 0%, transparent 70%);
  pointer-events: none; z-index: -1;
}
.sidebar::after {
  content: '';
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, hsl(240, 90%, 66%, .12), hsl(270, 70%, 55%, .06) 25%, transparent 50%, hsl(270, 70%, 55%, .06) 75%, hsl(240, 90%, 66%, .12));
  pointer-events: none;
}
.sidebar-close {
  display: none;
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: hsl(228, 12%, 10%);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  align-items: center; justify-content: center;
  transition: all var(--t-base); z-index: 10;
}
.sidebar-close:hover { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.sidebar-close .ph { font-size: 13px; }

/* Brand Header */
.sidebar-header {
  display: flex; align-items: center; gap: 13px;
  padding: 24px 22px 20px;
  flex-shrink: 0;
}
.brand-logo { position: relative; width: 38px; height: 38px; flex-shrink: 0; }
.brand-logo-inner {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, hsl(240, 90%, 60%), hsl(270, 85%, 56%), hsl(200, 90%, 56%));
  background-size: 200% 200%;
  animation: aurora-shift 6s ease-in-out infinite;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px hsl(240, 90%, 60%, .35), 0 0 0 1px hsl(240, 90%, 60%, .12);
  transition: transform var(--t-spring), box-shadow var(--t-base);
}
body.imap-mode .brand-logo-inner {
  background: linear-gradient(135deg, hsl(160, 80%, 45%), hsl(180, 75%, 42%), hsl(140, 70%, 50%));
  box-shadow: 0 4px 20px hsl(160, 80%, 45%, .35), 0 0 0 1px hsl(160, 80%, 45%, .12);
}
body.imap-mode .brand-logo-inner:hover {
  box-shadow: 0 6px 24px hsl(160, 80%, 45%, .45), 0 0 0 1px hsl(160, 80%, 45%, .2);
}
body.imap-mode .brand-name { color: hsl(170, 80%, 65%); }
body.imap-mode .sidebar-header .conn-label { color: hsl(170, 60%, 55%); }
body.imap-mode .email-item.selected {
  background: linear-gradient(90deg, hsl(170, 70%, 50%, .08), hsl(170, 70%, 50%, .03) 40%, transparent);
  border-left-color: var(--accent);
}
body.imap-mode .email-item:hover:not(.selected):not(.blocked):not(.flagged) {
  border-left-color: hsl(170, 50%, 45%, .4);
}
body.imap-mode .filter-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
body.imap-mode .folder-item.active {
  background: var(--accent-subtle);
  color: var(--accent-light);
}
body.imap-mode .folder-item.active::before {
  background: var(--accent);
}
@keyframes aurora-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.brand-logo-inner:hover { transform: scale(1.06) rotate(-2deg); box-shadow: 0 6px 24px hsl(240, 90%, 60%, .45), 0 0 0 1px hsl(240, 90%, 60%, .2); }
.brand-logo-inner svg { width: 17px; height: 17px; }
.conn-dot { display: none; }
.brand-text { display: flex; flex-direction: column; gap: 3px; }
.brand-name {
  font-size: 16px; font-weight: 800;
  color: var(--text-primary); letter-spacing: -.5px; line-height: 1;
  background: linear-gradient(135deg, var(--text-primary) 20%, hsl(240, 70%, 82%) 60%, hsl(200, 80%, 78%));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.conn-label { font-size: 10.5px; font-weight: 500; line-height: 1; display: flex; align-items: center; gap: 5px; }
.conn-label::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.conn-label.online { color: hsl(160, 75%, 48%); }
.conn-label.online::before { background: hsl(160, 75%, 50%); box-shadow: 0 0 8px hsl(160, 75%, 50%, .6); animation: pulse-dot 2.5s ease-in-out infinite; }
.conn-label.offline { color: hsl(0, 80%, 60%); }
.conn-label.offline::before { background: hsl(0, 80%, 64%); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px hsl(160, 75%, 50%, .5); }
  50% { opacity: .6; box-shadow: 0 0 12px hsl(160, 75%, 50%, .8); }
}

.sidebar-sep {
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, hsl(228, 14%, 14%) 25%, hsl(240, 50%, 40%, .2) 50%, hsl(228, 14%, 14%) 75%, transparent 95%);
  margin: 2px 16px 6px;
  flex-shrink: 0;
  position: relative;
}
.sidebar-sep::after {
  content: '';
  position: absolute; inset: -1px 25% -1px 25%;
  background: linear-gradient(90deg, transparent, hsl(240, 70%, 60%, .05), transparent);
  filter: blur(3px);
  pointer-events: none;
}

/* Sidebar Nav */
.sidebar-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 6px 8px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.sidebar-scroll::-webkit-scrollbar { display: none; }

.sidebar-section-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.8px;
  color: hsl(228, 20%, 32%);
  padding: 14px 14px 8px;
  margin-bottom: 0;
  position: relative;
  background: linear-gradient(90deg, hsl(228, 20%, 32%), hsl(240, 30%, 42%));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 2px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 14px;
  border-radius: 10px;
  cursor: pointer; margin: 0;
  color: hsl(228, 15%, 55%);
  font-size: 13.5px; font-weight: 450;
  position: relative; user-select: none;
  transition: all .2s cubic-bezier(.4, 0, .2, 1);
  letter-spacing: -.01em;
}
.nav-item:hover {
  background: hsl(228, 16%, 11%);
  color: hsl(228, 20%, 78%);
  transform: translateX(2px);
}
.nav-item:active {
  transform: translateX(2px) scale(.98);
}
.nav-item.active {
  background: linear-gradient(135deg, hsl(240, 60%, 56%, .12), hsl(260, 55%, 52%, .08));
  color: hsl(0, 0%, 96%);
  font-weight: 550;
  box-shadow: 0 1px 4px hsl(240, 60%, 10%, .3), inset 0 1px 0 hsl(240, 60%, 70%, .08);
}
.nav-item.active::before {
  content: "";
  position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, hsl(240, 85%, 72%), hsl(270, 80%, 65%));
  box-shadow: 0 0 14px hsl(250, 85%, 66%, .55), 0 0 6px hsl(250, 85%, 66%, .35);
  animation: active-indicator-glow 3s ease-in-out infinite;
}
@keyframes active-indicator-glow {
  0%, 100% { box-shadow: 0 0 12px hsl(250, 85%, 66%, .5), 0 0 4px hsl(250, 85%, 66%, .3); }
  50% { box-shadow: 0 0 18px hsl(250, 85%, 66%, .7), 0 0 8px hsl(250, 85%, 66%, .5); }
}
.nav-icon {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: hsl(228, 12%, 40%);
  transition: color .2s ease, transform .2s cubic-bezier(.4, 0, .2, 1);
}
svg.nav-icon { fill: currentColor; }
.nav-item:hover .nav-icon { color: hsl(228, 20%, 65%); transform: scale(1.1); }
.nav-item.active .nav-icon {
  color: hsl(240, 80%, 78%);
  filter: drop-shadow(0 0 4px hsl(240, 80%, 70%, .3));
}
.nav-label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1;
}
.nav-badge {
  font-size: 10.5px; font-weight: 600;
  color: hsl(228, 12%, 38%);
  background: hsl(228, 14%, 9%);
  padding: 3px 9px; border-radius: var(--r-full);
  min-width: 24px; text-align: center;
  border: 1px solid hsl(228, 12%, 13%);
  line-height: 1.4;
  transition: all .2s ease;
  font-variant-numeric: tabular-nums;
}
.nav-item:hover .nav-badge {
  color: hsl(228, 15%, 52%);
  border-color: hsl(228, 14%, 18%);
  background: hsl(228, 14%, 11%);
}
.nav-item.active .nav-badge {
  color: hsl(240, 80%, 82%);
  background: linear-gradient(135deg, hsl(240, 60%, 56%, .15), hsl(270, 55%, 52%, .1));
  border-color: hsl(240, 60%, 56%, .25);
  box-shadow: 0 0 10px hsl(240, 70%, 60%, .15), inset 0 1px 0 hsl(240, 60%, 70%, .06);
}

/* User Footer */
.sidebar-footer {
  display: flex; align-items: center; gap: 11px;
  padding: 16px 18px;
  flex-shrink: 0;
  border-top: 1px solid hsl(228, 14%, 9%, .7);
  position: relative;
}
.sidebar-footer::before {
  content: '';
  position: absolute; top: -1px; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, hsl(240, 50%, 40%, .12), transparent);
  pointer-events: none;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(240, 70%, 56%), hsl(270, 65%, 52%), hsl(200, 80%, 52%));
  background-size: 200% 200%;
  animation: aurora-shift 6s ease-in-out infinite;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 12px;
  flex-shrink: 0;
  box-shadow: 0 3px 14px hsl(240, 70%, 56%, .35), 0 0 0 2px hsl(228, 20%, 8%);
  letter-spacing: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.user-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 18px hsl(240, 70%, 56%, .45), 0 0 0 2px hsl(228, 20%, 8%);
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.35;
}
.user-email {
  font-size: 11px; color: var(--text-disabled);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; transition: color var(--t-base);
  line-height: 1.35; margin-top: 1px;
}
.user-email:hover { color: var(--accent-text); }
.user-dots {
  width: 26px; height: 26px;
  border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-disabled);
  transition: all var(--t-base); flex-shrink: 0;
}
.user-dots:hover { color: var(--text-muted); background: var(--bg-hover); }

/* ═══ OVERLAY ═══ */
.overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 40; opacity: 0; pointer-events: none;
  transition: opacity var(--t-slow) ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ═══ MAIN LAYOUT ═══ */
.main-content {
  flex: 1; display: flex; overflow: hidden;
  min-width: 0; max-width: 100%; height: 100%;
}

/* ═══════════════════════════════════════
   LIST COLUMN
═══════════════════════════════════════ */
.list-column {
  display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg-surface);
  flex-shrink: 0; border-right: 1px solid var(--border);
  height: 100%; max-height: 100%;
}
.list-header {
  background: hsl(228, 18%, 5%, .96);
  backdrop-filter: blur(16px) saturate(1.1); -webkit-backdrop-filter: blur(16px) saturate(1.1);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  user-select: none;
  position: relative;
}
.list-header::after {
  content: '';
  position: absolute; bottom: -1px; left: 5%; right: 5%;
  height: 1px;
  background: linear-gradient(90deg, transparent, hsl(240, 50%, 40%, .08), transparent);
  pointer-events: none;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 6px;
  height: var(--topbar-h); padding: 0 16px;
}
.topbar-left {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1;
}
.topbar-right {
  display: flex; align-items: center; gap: 3px;
  flex-shrink: 0;
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-base); flex-shrink: 0;
  user-select: none; touch-action: manipulation;
}
.icon-btn .ph { font-size: 18px; line-height: 1; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); box-shadow: 0 0 8px hsl(228, 20%, 10%, .3); }
.icon-btn:active { transform: scale(.86); }
.menu-btn { display: none; }
.refresh-btn.spinning .ph { animation: spin .55s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Select-All Checkbox */
.checkbox-wrap {
  display: flex; align-items: center;
  cursor: pointer; position: relative;
  width: 17px; height: 17px; flex-shrink: 0;
  touch-action: manipulation;
}
.checkbox-wrap input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox-box {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-base);
}
.checkbox-wrap:hover .checkbox-box { border-color: hsl(240, 70%, 62%, .6); }
.checkbox-wrap input:checked + .checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.checkbox-wrap input:checked + .checkbox-box::after {
  content: '';
  display: block; width: 8px; height: 8px;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 5l3.5 3.5L11 1' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Folder Title */
.folder-title-wrap {
  display: flex; flex-direction: column;
  min-width: 0; flex: 1; padding-left: 2px;
}
.folder-title {
  font-size: 16px; font-weight: 700;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.3; letter-spacing: -.3px;
  text-shadow: 0 1px 2px hsl(228, 20%, 2%, .2);
}
.folder-meta {
  display: flex; align-items: center; gap: 5px;
  line-height: 1.2; margin-top: 2px;
}
.meta-count {
  font-size: 11px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.meta-new {
  font-size: 10px; font-weight: 700;
  color: var(--accent-text);
  background: linear-gradient(135deg, hsl(240, 70%, 60%, .1), hsl(270, 60%, 55%, .06));
  padding: 1px 7px; border-radius: var(--r-full);
  line-height: 1.5; white-space: nowrap;
  border: 1px solid hsl(240, 60%, 55%, .18);
  animation: new-badge-in .4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  box-shadow: 0 0 10px hsl(240, 70%, 60%, .06);
}
@keyframes new-badge-in { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.meta-dot { font-size: 9px; color: var(--text-disabled); }
.meta-updated {
  font-size: 11px; color: var(--text-disabled);
  font-variant-numeric: tabular-nums;
}

/* Search Bar */
.search-wrap { padding: 0 16px 10px; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: hsl(228, 15%, 7%);
  border: 1px solid hsl(228, 12%, 11%);
  border-radius: var(--r);
  padding: 0 14px; height: 38px;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}
.search-box:focus-within {
  border-color: var(--accent-glow);
  box-shadow: 0 0 0 3px var(--accent-subtle), 0 4px 20px hsl(240, 90%, 66%, .08), 0 0 40px hsl(240, 80%, 60%, .04);
  background: linear-gradient(135deg, var(--accent-subtle), hsl(228, 15%, 7%) 60%);
  transform: scale(1.01);
}
.search-icon {
  font-size: 15px; color: var(--text-muted);
  flex-shrink: 0; transition: color 0.25s; line-height: 1;
}
.search-box:focus-within .search-icon { color: var(--accent); }
.search-box input {
  flex: 1; background: none; border: none;
  color: var(--text-primary); font-size: 13px; outline: none; min-width: 0;
}
.search-box input::placeholder { color: var(--text-placeholder); }
.search-clear {
  display: none; color: var(--text-muted);
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  transition: all var(--t-base); flex-shrink: 0;
}
.search-clear:hover { background: var(--red-bg); color: var(--red); }
.search-clear .ph { font-size: 10px; line-height: 1; }

/* Filter Tabs */
.filter-tabs {
  display: flex; gap: 5px;
  padding: 0 16px 10px;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  padding: 5px 15px;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  user-select: none; touch-action: manipulation; flex-shrink: 0;
  line-height: 1.5;
  position: relative;
}
.filter-tab:hover { color: var(--text-secondary); background: var(--bg-hover); }
.filter-tab.active {
  color: var(--text-primary);
  background: linear-gradient(135deg, hsl(240, 70%, 60%, .1), hsl(200, 70%, 56%, .06));
  border-color: hsl(240, 70%, 60%, .22);
  box-shadow: 0 0 12px hsl(240, 70%, 60%, .08), inset 0 1px 0 hsl(240, 70%, 80%, .06);
}

/* Bulk Action Bar */
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; gap: 8px;
  background: linear-gradient(90deg, hsl(240, 70%, 60%, .05), hsl(240, 50%, 50%, .03) 50%, hsl(240, 70%, 60%, .05));
  border-bottom: 1px solid hsl(240, 70%, 60%, .1);
  animation: slideDown .22s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}
.bulk-bar::after {
  content: '';
  position: absolute; bottom: -1px; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, hsl(240, 70%, 60%, .12), transparent);
  pointer-events: none;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.bulk-count {
  font-size: 12px; font-weight: 600;
  color: var(--accent-text); white-space: nowrap;
}
.bulk-actions {
  display: flex; align-items: center; gap: 5px;
}
.action-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0 12px; height: 28px;
  border-radius: var(--r-full);
  border: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 11.5px; font-weight: 500;
  transition: all var(--t-base);
  touch-action: manipulation; white-space: nowrap;
}
.action-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }
.action-btn:active { transform: scale(.95); }
.action-btn .ph { font-size: 12px; line-height: 1; }
.action-btn--danger {
  border-color: var(--red-border);
  background: var(--red-bg);
  color: var(--red);
}
.action-btn--danger:hover { background: hsl(0, 80%, 62%, .16); }

/* ═══════════════════════════════════════
   EMAIL LIST
═══════════════════════════════════════ */
.email-list {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  min-height: 0;
  background: var(--bg-surface);
  overscroll-behavior: contain;
  contain: layout style paint;
  will-change: scroll-position;
}

.email-item {
  display: flex; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid hsl(228, 12%, 7%);
  cursor: pointer; position: relative;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  animation: itemIn .18s cubic-bezier(0.22, 1, 0.36, 1) both;
  contain: layout style;
}
@keyframes itemIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.email-item:hover {
  background: linear-gradient(90deg, hsl(240, 30%, 8%, .5) 0%, hsl(228, 14%, 7.5%) 30%, hsl(228, 14%, 7.5%) 100%);
  box-shadow: inset 0 0 0 0.5px hsl(228, 20%, 14%);
}
.email-item:hover:not(.selected):not(.blocked):not(.flagged) {
  border-left: 2px solid hsl(240, 50%, 45%, .4);
  padding-left: 14px;
}

.email-item.selected {
  background: linear-gradient(90deg, hsl(240, 70%, 60%, .08), hsl(240, 70%, 60%, .03) 40%, transparent);
  border-left: 2px solid var(--accent);
  padding-left: 14px;
  box-shadow: inset 0 0 0 0.5px hsl(240, 50%, 50%, .08);
}
.email-item.checked { background: hsl(240, 70%, 60%, .04); }
.email-item.kb-focus {
  outline: 1.5px solid hsl(240, 70%, 60%, .4);
  outline-offset: -1.5px;
  box-shadow: inset 0 0 20px hsl(240, 70%, 60%, .04);
}
.email-item.deleting {
  animation: itemOut .28s cubic-bezier(.4, 0, .2, 1) forwards;
}
@keyframes itemOut {
  to { opacity: 0; transform: translateX(-28px) scale(.97); height: 0; padding-top: 0; padding-bottom: 0; margin: 0; border: 0; overflow: hidden; }
}
.email-item.blocked { border-left: 2px solid var(--amber); padding-left: 14px; }
.email-item.flagged { border-left: 2px solid var(--amber); padding-left: 14px; }

/* Unread styling */
.email-item.unread .em-sender { font-weight: 600; color: var(--text-primary); }
.email-item.unread .em-subject { color: var(--text-secondary); font-weight: 500; }
.email-item.unread .em-preview { color: hsl(220, 7%, 50%); }
.email-item.read .em-sender { color: var(--text-secondary); font-weight: 400; }
.email-item.read .em-subject { color: var(--text-muted); }
.email-item.read .em-preview { color: var(--text-disabled); }

/* Left section */
.em-left {
  display: flex; align-items: flex-start; gap: 6px;
  flex-shrink: 0; padding-top: 2px;
}
.em-unread-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  margin-top: 6px; opacity: 0;
  transition: opacity 0.2s, transform var(--t-spring);
  box-shadow: 0 0 8px hsl(240, 90%, 66%, .5);
  animation: unread-pulse 2.8s ease-in-out infinite;
}
@keyframes unread-pulse {
  0%, 100% { box-shadow: 0 0 6px hsl(240, 90%, 66%, .4); }
  50% { box-shadow: 0 0 12px hsl(240, 90%, 66%, .7), 0 0 20px hsl(240, 90%, 66%, .2); }
}
.email-item.unread .em-unread-dot { opacity: 1; }
.email-item.blocked .em-unread-dot { background: var(--amber); opacity: 1; box-shadow: 0 0 8px hsl(40, 95%, 58%, .4); animation: none; }

.em-av-wrap {
  position: relative; width: 38px; height: 38px; flex-shrink: 0;
}
.em-avatar {
  width: 100%; height: 100%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; color: #fff;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1); user-select: none;
  letter-spacing: .5px;
  box-shadow: 0 2px 8px hsl(228, 20%, 2%, .35);
}
.em-checkbox {
  display: none; position: absolute; inset: 0; border-radius: 50%;
  align-items: center; justify-content: center;
  border: 1.5px solid var(--border-strong);
  color: var(--text-muted);
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1); cursor: pointer;
  background: var(--bg-elevated);
  touch-action: manipulation;
}
.email-item.checked .em-checkbox {
  display: flex !important;
  border-color: var(--accent); background: var(--accent); color: #fff;
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.email-item.checked .em-checkbox::after {
  content: ''; display: block; width: 8px; height: 8px;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 5l3.5 3.5L11 1' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
}
.email-item.checked .em-avatar { opacity: 0 !important; transform: scale(.82); }
.email-item.checked .em-checkbox .ph { display: none; }

@media (hover: hover) {
  .email-item:hover .em-avatar { opacity: 0; transform: scale(.82); }
  .email-item:hover .em-checkbox { display: flex; opacity: 1; }
  .email-item.selected:hover .em-avatar { opacity: 1; transform: scale(1); }
  .email-item.selected:hover .em-checkbox { display: none; }
}
.bulk-mode .em-checkbox { display: flex !important; opacity: 1 !important; transform: scale(1) !important; }
.bulk-mode .em-avatar { opacity: 0 !important; transform: scale(.82) !important; }

/* Email Content */
.em-content {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.em-row1 { display: flex; align-items: center; gap: 6px; }
.em-sender {
  font-size: 13.5px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.em-row1-right {
  display: flex; align-items: center; gap: 5px; flex-shrink: 0;
}
.em-flag { color: var(--amber); }
.em-flag .ph, .em-attach .ph { font-size: 11px; line-height: 1; }
.em-attach { color: var(--text-disabled); }
.em-date {
  font-size: 10.5px; color: var(--text-muted);
  white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1;
}
.em-row2 { display: flex; align-items: center; gap: 4px; }
.em-importance { display: inline-flex; align-items: center; color: var(--red); flex-shrink: 0; }
.em-importance .ph { font-size: 11px; line-height: 1; }
.em-subject {
  font-size: 12.5px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.em-preview {
  font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.5;
}

/* Quick Actions on hover */
.em-quick-actions {
  display: none; align-items: center; gap: 2px;
  flex-shrink: 0; margin-left: 2px; align-self: center;
}
@media (hover: hover) { .email-item:hover .em-quick-actions { display: flex; } }
.em-action-btn {
  display: flex; color: var(--text-muted);
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  align-items: center; justify-content: center;
  transition: all var(--t-base);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.em-action-btn .ph { font-size: 14px; line-height: 1; transition: transform 0.15s ease; }
.em-action-btn:hover { background: hsl(228, 14%, 14%, .8); color: var(--text-primary); box-shadow: 0 2px 8px hsl(228, 20%, 2%, .3); }
.em-action-btn:hover .ph { transform: scale(1.12); }
.em-action-btn:active { transform: scale(.86); }
.em-action-btn.danger:hover { background: var(--red-bg); color: var(--red); box-shadow: 0 2px 12px hsl(0, 70%, 50%, .15); }
.em-action-btn.warn:hover { background: var(--amber-bg); color: var(--amber); box-shadow: 0 2px 12px hsl(40, 70%, 50%, .15); }

/* ═══ SKELETON ═══ */
.sk-list { padding: 0; }
.sk-item {
  display: flex; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid hsl(228, 12%, 7%);
  animation: skIn .3s ease both;
}
.sk-item:nth-child(1) { animation-delay: 0s; }
.sk-item:nth-child(2) { animation-delay: .04s; }
.sk-item:nth-child(3) { animation-delay: .06s; }
.sk-item:nth-child(4) { animation-delay: .08s; }
.sk-item:nth-child(5) { animation-delay: .1s; }
.sk-item:nth-child(6) { animation-delay: .12s; }
.sk-item:nth-child(7) { animation-delay: .14s; }
.sk-item:nth-child(8) { animation-delay: .16s; }
@keyframes skIn { from { opacity: 0; } to { opacity: 1; } }

.sk-bone {
  background: linear-gradient(
    90deg,
    hsl(228, 15%, 7%) 25%,
    hsl(240, 18%, 13%) 50%,
    hsl(228, 15%, 7%) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 7px;
}
.sk-avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 3px 0; }
.sk-line { height: 9px; border-radius: 5px; }
.sk-w60 { width: 52%; }
.sk-w80 { width: 78%; }
.sk-w40 { width: 38%; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═══ PAGINATION ═══ */
.pagination {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-surface);
}
.pg-row {
  display: flex; align-items: center; justify-content: center;
  gap: 3px; flex-wrap: nowrap;
}
.pg-info {
  white-space: nowrap; color: var(--text-muted);
  font-size: 11px; font-variant-numeric: tabular-nums;
}
.pg-btn {
  color: var(--text-muted); height: 30px; min-width: 30px;
  padding: 0 7px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--t-base); font-variant-numeric: tabular-nums;
  touch-action: manipulation; flex-shrink: 0;
}
.pg-btn .ph { font-size: 12px; line-height: 1; }
.pg-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.pg-btn:active:not(:disabled) { transform: scale(.86); }
.pg-btn:disabled { opacity: .2; cursor: default; }
.pg-btn.active {
  background: linear-gradient(135deg, hsl(240, 70%, 60%, .12), hsl(200, 70%, 56%, .06));
  color: var(--accent-light);
  font-weight: 700;
  border: 1px solid hsl(240, 70%, 60%, .2);
  box-shadow: 0 0 10px hsl(240, 70%, 60%, .08), inset 0 1px 0 hsl(240, 70%, 80%, .05);
}
.pg-ellipsis { color: var(--text-disabled); font-size: 11px; padding: 0 2px; }

/* ═══ STATE CONTAINERS ═══ */
.state-container {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 64px 24px; min-height: 260px;
  animation: fadeIn .4s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
/* Premium orbital spinner */
.spinner {
  width: 32px; height: 32px;
  position: relative;
}
.spinner::before, .spinner::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2.5px solid transparent;
}
.spinner::before {
  border-top-color: var(--accent);
  border-right-color: hsl(240, 80%, 72%, .4);
  animation: spin .7s cubic-bezier(.55,.15,.45,.85) infinite;
}
.spinner::after {
  inset: 4px;
  border-bottom-color: hsl(270, 70%, 60%, .6);
  border-left-color: hsl(200, 80%, 56%, .3);
  animation: spin 1.1s cubic-bezier(.55,.15,.45,.85) infinite reverse;
}
.state-container p { margin-top: 12px; font-size: 13px; color: var(--text-muted); }
.state-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 64px 24px; min-height: 280px;
  text-align: center;
  animation: emptyIn .45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes emptyIn {
  from { opacity: 0; transform: scale(.93) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.state-icon-wrap {
  width: 72px; height: 72px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, hsl(228, 15%, 7%) 0%, hsl(240, 20%, 9%) 100%);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
  border: 1px solid hsl(240, 30%, 18%, .3);
  box-shadow: var(--shadow-sm), 0 0 40px hsl(240, 70%, 50%, .04), inset 0 1px 0 hsl(240, 50%, 60%, .06);
  position: relative;
}
.state-icon-wrap::after {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, hsl(240, 70%, 60%, .1), transparent 50%, hsl(270, 60%, 55%, .08));
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude; -webkit-mask-composite: xor;
  padding: 1px;
  pointer-events: none;
}
.state-icon-wrap .ph { font-size: 28px; color: hsl(240, 50%, 55%, .5); line-height: 1; }
.state-empty h3 {
  font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px;
  letter-spacing: -.2px;
}
.state-empty p {
  font-size: 13px; color: var(--text-muted); max-width: 260px; line-height: 1.7;
}
.state-error .state-icon-wrap .ph { color: var(--red); }
.state-error .state-icon-wrap {
  border-color: hsl(0, 60%, 40%, .2);
  box-shadow: var(--shadow-sm), 0 0 40px hsl(0, 70%, 50%, .04);
}
.state-error .state-icon-wrap::after {
  background: linear-gradient(135deg, hsl(0, 70%, 60%, .1), transparent 50%, hsl(0, 60%, 55%, .08));
}

/* ═══════════════════════════════════════
   READING PANE
═══════════════════════════════════════ */
.reading-pane {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg-base);
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  width: 100vw; max-width: 100vw;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(.22, 1, .36, 1);
  will-change: transform;
  contain: layout;
}
.reading-pane.open { transform: translateX(0); }
.reading-pane.open .reading-empty { display: none; }
.reading-pane:not(.open) .reading-toolbar { display: none; }
.reading-pane:not(.open) .reading-content { display: none; }

.reading-empty {
  display: flex; flex: 1;
  align-items: center; justify-content: center; padding: 40px;
}
.reading-empty-wrap {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  animation: emptyIn .5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.empty-icon-wrap {
  width: 80px; height: 80px;
  border-radius: var(--r-xl);
  background: linear-gradient(135deg, hsl(228, 15%, 7%) 0%, hsl(240, 20%, 9%) 100%);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 28px;
  border: 1px solid hsl(240, 30%, 18%, .25);
  box-shadow: var(--shadow-md), 0 0 60px hsl(240, 70%, 50%, .05), inset 0 1px 0 hsl(240, 50%, 60%, .06);
  position: relative;
  animation: empty-icon-breathe 4s ease-in-out infinite;
}
@keyframes empty-icon-breathe {
  0%, 100% { box-shadow: var(--shadow-md), 0 0 60px hsl(240, 70%, 50%, .05); }
  50% { box-shadow: var(--shadow-md), 0 0 80px hsl(240, 70%, 50%, .08); }
}
.empty-icon-wrap::after {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  background: conic-gradient(from 180deg, hsl(240, 70%, 60%, .12), transparent 60%, hsl(270, 60%, 55%, .1), transparent);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude; -webkit-mask-composite: xor;
  padding: 1px;
  pointer-events: none;
  animation: empty-border-rotate 8s linear infinite;
}
@keyframes empty-border-rotate {
  to { transform: rotate(360deg); }
}
.empty-icon-wrap .ph { font-size: 34px; color: hsl(240, 50%, 50%, .45); line-height: 1; }
.reading-empty h3 {
  font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px;
  letter-spacing: -.2px;
}
.reading-empty p { font-size: 13px; color: var(--text-muted); max-width: 240px; line-height: 1.7; }

/* Toolbar */
.reading-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: hsl(228, 18%, 5%, .96);
  backdrop-filter: blur(16px) saturate(1.1); -webkit-backdrop-filter: blur(16px) saturate(1.1);
  flex-shrink: 0; gap: 4px;
  flex-wrap: wrap;
  position: relative;
}
.reading-toolbar::after {
  content: '';
  position: absolute; bottom: -1px; left: 5%; right: 5%;
  height: 1px;
  background: linear-gradient(90deg, transparent, hsl(240, 50%, 40%, .1), transparent);
  pointer-events: none;
}
.toolbar-left { display: flex; align-items: center; gap: 4px; }
.toolbar-actions { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.toolbar-divider {
  width: 1px; height: 20px;
  background: var(--border-soft); margin: 0 5px; flex-shrink: 0;
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 12.5px; font-weight: 500;
  transition: all 0.18s ease;
  white-space: nowrap; user-select: none; touch-action: manipulation;
  border: 1px solid transparent;
}
.tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: hsl(228, 14%, 14%);
}
.tool-btn:active:not(:disabled) { transform: scale(.93); }
.tool-btn:disabled { opacity: .22; cursor: default; pointer-events: none; }
.tool-btn .ph { font-size: 15px; line-height: 1; transition: transform 0.15s ease; }
.tool-btn:hover .ph { transform: scale(1.08); }
.tool-label { font-size: 12px; }
.tool-btn--danger { color: var(--red); }
.tool-btn--danger:hover { background: var(--red-bg); border-color: var(--red-border); box-shadow: 0 0 12px hsl(0, 70%, 50%, .08); }
.tool-btn.flagged { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-border); }
.tool-btn.active { color: var(--accent-text); background: var(--accent-subtle); border-color: hsl(240, 60%, 50%, .15); }
.back-btn { display: flex; }

/* Reading Content Scroll */
.reading-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  min-height: 0; overscroll-behavior: contain;
}

/* Message Header */
.msg-header {
  padding: 30px 22px 24px;
  animation: msgIn .22s cubic-bezier(0.22, 1, 0.36, 1) both;
  overflow-x: hidden; max-width: 100%;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-subject {
  font-size: 21px; font-weight: 700;
  color: var(--text-primary); line-height: 1.4;
  margin-bottom: 22px; word-break: break-word; overflow-wrap: anywhere;
  letter-spacing: -.4px;
  display: flex; align-items: flex-start; gap: 8px;
  text-shadow: 0 1px 2px hsl(228, 20%, 2%, .3);
}
.importance-icon { display: inline-flex; align-items: center; color: var(--red); }
.importance-icon .ph { font-size: 16px; line-height: 1; }
.msg-meta {
  display: flex; gap: 14px; align-items: flex-start;
}
.msg-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0; user-select: none; letter-spacing: .5px;
  box-shadow: 0 4px 16px hsl(228, 20%, 2%, .5), 0 0 0 2px hsl(228, 20%, 12%);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.msg-avatar:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 20px hsl(228, 20%, 2%, .6), 0 0 0 2px hsl(240, 40%, 30%);
}
.msg-info { flex: 1; min-width: 0; }
.msg-sender-name {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-sender-email {
  font-size: 12px; color: var(--text-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-to {
  font-size: 12px; color: var(--text-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-to span { font-weight: 500; color: var(--text-secondary); }
.msg-date-wrap { text-align: right; flex-shrink: 0; }
.msg-date {
  font-size: 11.5px; color: var(--text-muted);
  line-height: 1.5; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.msg-attach-badge {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 8px; font-size: 11px;
  color: var(--text-secondary);
  background: linear-gradient(135deg, hsl(228, 15%, 8%), var(--bg-elevated));
  border: 1px solid hsl(228, 14%, 13%);
  border-radius: var(--r-sm); padding: 4px 10px;
  transition: all 0.18s ease;
}
.msg-attach-badge:hover {
  border-color: hsl(228, 16%, 18%);
  background: var(--bg-hover);
}
.msg-attach-badge .ph { font-size: 11px; line-height: 1; }
.msg-divider {
  height: 1px; margin: 0 20px;
  background: linear-gradient(90deg, transparent 0%, hsl(240, 40%, 30%, .15) 15%, hsl(240, 50%, 45%, .2) 50%, hsl(240, 40%, 30%, .15) 85%, transparent 100%);
  position: relative;
}
.msg-divider::after {
  content: '';
  position: absolute; inset: -2px 20% -2px 20%;
  background: linear-gradient(90deg, transparent, hsl(240, 70%, 60%, .04), transparent);
  filter: blur(4px);
  pointer-events: none;
}

/* Attachments */
.msg-attachments {
  padding: 18px 20px;
  display: flex; flex-wrap: wrap; gap: 10px;
  animation: msgIn .22s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.att-file {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, hsl(228, 15%, 8%) 0%, var(--bg-elevated) 100%);
  border: 1px solid hsl(228, 14%, 13%);
  border-radius: var(--r);
  cursor: pointer; transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  color: var(--text-secondary);
  max-width: 260px; text-decoration: none;
  touch-action: manipulation; text-align: left;
  position: relative;
}
.att-file::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, hsl(240, 50%, 50%, .08), transparent 50%);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude; -webkit-mask-composite: xor;
  padding: 1px; opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
.att-file:hover::before { opacity: 1; }
.att-file:hover {
  background: linear-gradient(135deg, hsl(228, 18%, 10%) 0%, var(--bg-hover) 100%);
  border-color: hsl(228, 16%, 18%);
  color: var(--text-primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), 0 0 30px hsl(228, 30%, 4%, .3);
}
.att-file:active { transform: scale(.98) translateY(0); }
.att-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.att-icon.img { background: var(--blue-bg); color: var(--blue); }
.att-icon.doc { background: var(--blue-bg); color: var(--blue); }
.att-icon.pdf { background: var(--red-bg); color: var(--red); }
.att-icon.zip { background: var(--amber-bg); color: var(--amber); }
.att-icon.other { background: var(--bg-elevated); color: var(--text-muted); }
.att-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.att-name {
  font-size: 12px; font-weight: 500; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att-size { font-size: 10.5px; color: var(--text-muted); }
.att-dl {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 13px; flex-shrink: 0;
  transition: color var(--t-base);
}
.att-file:hover .att-dl { color: var(--accent-text); }

/* Message Body */
.msg-body-html {
  margin: 16px 20px 40px;
  border: 1px solid hsl(228, 14%, 14%);
  border-radius: var(--r);
  overflow: hidden; overflow-x: auto;
  animation: msgIn .22s cubic-bezier(0.22, 1, 0.36, 1) both;
  max-width: 100%;
  background: #fff;
  box-shadow: var(--shadow-md), 0 0 40px hsl(228, 30%, 4%, .3);
  position: relative;
}
.msg-body-html::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, hsl(240, 40%, 40%, .08), transparent 30%, transparent 70%, hsl(270, 40%, 40%, .06));
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude; -webkit-mask-composite: xor;
  padding: 1px;
  pointer-events: none; z-index: 1;
}
.msg-iframe {
  width: 100%; border: none; background: #fff; display: block;
  transition: height .18s cubic-bezier(0.22, 1, 0.36, 1); min-height: 80px;
}
.msg-body-text {
  padding: 24px 20px 40px;
  font-size: 14px; line-height: 1.85;
  color: var(--text-secondary);
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  animation: msgIn .22s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.msg-loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 56px; animation: fadeIn .3s ease;
}
.msg-loading p { margin-top: 12px; font-size: 13px; color: var(--text-muted); }

/* ═══ TOAST ═══ */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(14px) scale(.96);
  background: linear-gradient(135deg, hsl(228, 20%, 10%) 0%, hsl(228, 18%, 8%) 100%);
  color: var(--text-primary);
  padding: 12px 22px;
  border-radius: var(--r);
  font-size: 13px; font-weight: 500;
  z-index: 600; opacity: 0; pointer-events: none;
  transition: all .3s cubic-bezier(.22, 1, .36, 1);
  box-shadow: var(--shadow-lg), 0 0 40px hsl(228, 40%, 4%, .5);
  border: 1px solid hsl(228, 14%, 16%, .6);
  border-left: 3px solid var(--accent);
  max-width: 420px; white-space: nowrap;
  backdrop-filter: blur(24px) saturate(1.2); -webkit-backdrop-filter: blur(24px) saturate(1.2);
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); pointer-events: auto; }
.toast.success {
  border-left-color: var(--green);
  box-shadow: var(--shadow-lg), 0 0 30px hsl(160, 75%, 48%, .06);
}
.toast.error {
  border-left-color: var(--red);
  box-shadow: var(--shadow-lg), 0 0 30px hsl(0, 80%, 50%, .06);
}
.toast.info {
  border-left-color: var(--accent);
  box-shadow: var(--shadow-lg), 0 0 30px hsl(240, 80%, 60%, .06);
}

/* ═══ TELEGRAM FLOAT ═══ */
.tg-float {
  position: fixed; bottom: 24px; right: 24px;
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, #2AABEE, #229ED9);
  color: #fff; display: flex; align-items: center; justify-content: center;
  z-index: 90;
  box-shadow: 0 4px 20px hsl(200, 80%, 55%, .3), 0 0 0 1px hsl(200, 80%, 55%, .1);
  transition: all 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  animation: tg-float-breathe 3.5s ease-in-out infinite;
}
@keyframes tg-float-breathe {
  0%, 100% { box-shadow: 0 4px 20px hsl(200, 80%, 55%, .3), 0 0 0 1px hsl(200, 80%, 55%, .1); }
  50% { box-shadow: 0 6px 28px hsl(200, 80%, 55%, .4), 0 0 0 1px hsl(200, 80%, 55%, .15), 0 0 40px hsl(200, 80%, 55%, .1); }
}
.tg-float:hover {
  transform: scale(1.12) translateY(-3px); color: #fff;
  box-shadow: 0 8px 32px hsl(200, 80%, 55%, .5), 0 0 50px hsl(200, 80%, 55%, .15);
  animation: none;
}
.tg-float:active { transform: scale(.88); animation: none; }

/* ═══ CONTEXT MENU ═══ */
.context-menu {
  position: fixed; z-index: 400;
  background: linear-gradient(135deg, hsl(228, 20%, 9%) 0%, hsl(228, 18%, 7%) 100%);
  border: 1px solid hsl(228, 16%, 16%, .6);
  border-radius: var(--r);
  padding: 6px; min-width: 210px;
  box-shadow: var(--shadow-xl), 0 0 60px hsl(228, 30%, 3%, .4);
  display: none;
  animation: ctxIn .18s cubic-bezier(0.22, 1, 0.36, 1) both;
  backdrop-filter: blur(32px) saturate(1.3); -webkit-backdrop-filter: blur(32px) saturate(1.3);
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(.92) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.ctx-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 13px; font-size: 13px;
  color: var(--text-secondary); cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.ctx-item:hover {
  background: linear-gradient(90deg, hsl(240, 50%, 50%, .06), var(--bg-hover));
  color: var(--text-primary);
  transform: translateX(2px);
}
.ctx-item .ph { font-size: 16px; color: var(--text-muted); transition: color var(--t-fast), transform 0.15s ease; line-height: 1; }
.ctx-item:hover .ph { color: var(--text-secondary); transform: scale(1.1); }
.ctx-danger { color: var(--red) !important; }
.ctx-danger .ph { color: var(--red) !important; }
.ctx-danger:hover { background: var(--red-bg) !important; }
.ctx-sep { height: 1px; background: linear-gradient(90deg, transparent, var(--border-soft), transparent); margin: 4px 8px; }

/* ═══ DRAG & DROP ═══ */
.email-item.dragging { opacity: .25; transform: scale(.95); }
.nav-item.drop-target {
  background: var(--accent-subtle) !important;
  box-shadow: inset 0 0 0 1.5px var(--accent);
  color: var(--text-primary) !important;
}
.nav-item.drop-target .nav-icon { color: var(--accent-text) !important; }
.nav-item.drop-reject {
  background: var(--red-bg) !important;
  box-shadow: inset 0 0 0 1.5px var(--red);
}
.drag-ghost {
  position: fixed; z-index: 999; pointer-events: none;
  padding: 9px 16px;
  background: linear-gradient(135deg, hsl(228, 20%, 11%) 0%, hsl(228, 18%, 9%) 100%);
  border: 1px solid hsl(240, 60%, 55%, .3);
  border-radius: var(--r-sm);
  color: var(--text-primary); font-size: 12.5px; font-weight: 600;
  box-shadow: var(--shadow-lg), 0 0 30px hsl(240, 60%, 50%, .1);
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap; max-width: 280px;
  backdrop-filter: blur(20px) saturate(1.2); -webkit-backdrop-filter: blur(20px) saturate(1.2);
}
.drag-ghost .drag-count {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
  min-width: 18px; text-align: center;
}

/* ═══ DESKTOP ≥1024px ═══ */
@media (min-width: 1024px) {
  .list-column { width: var(--list-w); }
  .reading-pane {
    position: relative; inset: auto; z-index: auto;
    transform: none; transition: none;
    width: auto; height: 100%; max-width: none;
    overflow: hidden; flex: 1;
    border-left: 1px solid var(--border);
  }
  .reading-pane:not(.open) .reading-empty { display: flex; }
  .reading-content { overflow-x: hidden; }
  .back-btn { display: none !important; }
  .tool-label { display: inline; }
  .topbar { padding: 0 20px; }
  .search-wrap { padding: 0 20px 10px; }
  .filter-tabs { padding: 0 20px 10px; }
  .email-item { padding: 13px 20px; }
  .msg-header { padding: 40px 44px 28px; }
  .msg-subject { font-size: 23px; }
  .msg-divider { margin: 0 44px; }
  .msg-body-html { margin: 20px 44px 48px; }
  .msg-body-text { padding: 28px 44px 48px; }
  .msg-attachments { padding: 18px 44px; }
}

/* ═══ 4K ≥1920px ═══ */
@media (min-width: 1920px) {
  :root { --sidebar-w: 296px; --list-w: 450px; }
  .email-item { padding: 15px 24px; gap: 14px; }
  .em-avatar { width: 40px; height: 40px; font-size: 14px; }
  .msg-header { padding: 48px 64px 32px; max-width: 920px; }
  .msg-subject { font-size: 27px; }
  .msg-divider { margin: 0 64px; }
  .msg-body-html { margin: 22px 64px 52px; max-width: 920px; }
  .msg-body-text { padding: 32px 64px 52px; max-width: 920px; }
  .msg-attachments { padding: 20px 64px; }
  .reading-toolbar { height: 56px; padding: 0 22px; }
  .tool-btn { height: 38px; padding: 0 14px; font-size: 13px; }
  .tool-btn .ph { font-size: 17px; }
  .toast { font-size: 14px; padding: 12px 22px; }
}

/* ═══ TABLET 769-1023px ═══ */
@media (min-width: 769px) and (max-width: 1023px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 280px; transform: translateX(-100%);
    box-shadow: 16px 0 48px hsl(228, 24%, 1%, .75);
    z-index: 55;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .menu-btn { display: flex; }
  .list-column { flex: 1; }
  .tg-float { width: 42px; height: 42px; bottom: 20px; right: 20px; }
}

/* ═══ MOBILE ≤768px ═══ */
@media (max-width: 768px) {
  .app { overflow: hidden; max-width: 100vw; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(280px, 84vw);
    transform: translateX(-100%);
    box-shadow: 16px 0 48px hsl(228, 24%, 1%, .75);
    z-index: 55;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .menu-btn { display: flex; }
  .main-content { width: 100vw; max-width: 100vw; overflow: hidden; }
  .list-column { flex: 1; border-right: none; width: 100%; max-width: 100vw; min-width: 0; }
  .topbar { height: 52px; padding: 0 14px; }
  .search-wrap { padding: 0 14px 8px; }
  .filter-tabs { padding: 0 14px 8px; }
  .email-list { overflow-x: hidden; }
  .em-quick-actions { display: none !important; }
  .reading-pane { max-width: 100vw; }
  .tool-label { display: none; }
  .tool-btn { height: 36px; padding: 0 11px; }
  .toolbar-divider { height: 18px; margin: 0 3px; }
  .reading-content { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; max-width: 100vw; }
  .msg-body-html { margin: 12px; border-radius: var(--r-sm); overflow-x: hidden; max-width: calc(100vw - 24px); word-break: break-word; }
  .msg-body-text { padding: 18px; font-size: 13.5px; }
  .msg-attachments { padding: 12px; gap: 8px; }
  .att-file { padding: 9px 12px; gap: 9px; max-width: 100%; min-width: 0; }
  .att-icon { width: 32px; height: 32px; font-size: 15px; }
  .pagination { padding: 10px; gap: 3px; }
  .pg-btn { height: 28px; min-width: 28px; padding: 0 5px; font-size: 11.5px; }
  .pg-info { font-size: 10.5px; }
  .toast { bottom: 16px; font-size: 12.5px; padding: 10px 16px; max-width: calc(100vw - 32px); white-space: normal; }
  .tg-float { width: 40px; height: 40px; bottom: 16px; right: 16px; }
  .tg-float svg { width: 17px; height: 17px; }
  .context-menu { min-width: 180px; padding: 5px; max-width: calc(100vw - 24px); }
}

/* ═══ SMALL MOBILE ≤420px ═══ */
@media (max-width: 420px) {
  .topbar { height: 48px; padding: 0 12px; }
  .folder-title { font-size: 14px; }
  .icon-btn { width: 34px; height: 34px; }
  .search-box { height: 34px; padding: 0 12px; }
  .filter-tab { padding: 4px 11px; font-size: 11px; }
  .email-item { padding: 10px 12px; gap: 10px; }
  .em-avatar { width: 34px; height: 34px; font-size: 11px; }
  .tool-btn { height: 32px; padding: 0 9px; }
  .msg-header { padding: 16px 14px 14px; }
  .msg-subject { font-size: 17px; }
  .msg-meta { gap: 10px; flex-wrap: wrap; }
  .msg-date-wrap { width: 100%; text-align: left; margin-top: 6px; padding-left: 56px; }
  .msg-body-html { margin: 10px; max-width: calc(100vw - 20px); }
  .msg-body-text { padding: 14px; font-size: 13px; }
  .bulk-bar { padding: 7px 12px; }
  .action-btn { height: 26px; padding: 0 10px; font-size: 11px; }
}

/* ═══ TINY MOBILE ≤340px ═══ */
@media (max-width: 340px) {
  .checkbox-wrap { display: none; }
  .email-item { padding: 9px 10px; gap: 8px; }
  .em-avatar { width: 32px; height: 32px; font-size: 10.5px; }
  .filter-tab { padding: 3px 9px; font-size: 10px; }
  .msg-subject { font-size: 15.5px; }
  .bulk-bar { flex-direction: column; gap: 6px; align-items: stretch; }
  .bulk-count { text-align: center; }
  .bulk-actions { justify-content: center; }
}

/* ═══ LANDSCAPE ═══ */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { height: 44px; }
  .search-box { height: 30px; }
  .filter-tab { padding: 3px 11px; }
  .email-item { padding: 8px 14px; }
  .reading-toolbar { min-height: 38px; padding: 4px 10px; flex-wrap: nowrap; }
  .msg-header { padding: 12px 18px 10px; }
  .msg-subject { font-size: 17px; margin-bottom: 10px; }
  .nav-item { height: 34px; }
  .sidebar-footer { padding: 10px 14px; }
}

/* ═══ REDUCED MOTION ═══ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ═══ NEW MESSAGE BANNER ═══ */
.new-msg-banner {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 700;
  display: flex; align-items: center; gap: 13px;
  background: linear-gradient(135deg, hsl(228, 22%, 9%) 0%, hsl(228, 20%, 7%) 100%);
  border: 1px solid hsl(240, 70%, 60%, .2);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  padding: 13px 16px;
  min-width: 290px; max-width: 380px;
  box-shadow: var(--shadow-xl), 0 0 50px hsl(240, 60%, 50%, .06);
  backdrop-filter: blur(32px) saturate(1.3); -webkit-backdrop-filter: blur(32px) saturate(1.3);
  cursor: pointer;
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .35s ease, border-color .2s ease, box-shadow .2s ease;
  user-select: none;
  overflow: hidden;
}
.new-msg-banner::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, hsl(240, 70%, 60%, .2), hsl(270, 60%, 55%, .1), transparent 60%);
  pointer-events: none;
}
.new-msg-banner.visible {
  transform: translateX(0);
  opacity: 1;
}
.new-msg-banner:hover {
  border-color: hsl(240, 70%, 60%, .4);
  box-shadow: var(--shadow-xl), 0 0 60px hsl(240, 60%, 50%, .1);
}

.nmb-icon {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, hsl(240, 90%, 66%, .12), hsl(200, 90%, 56%, .06));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  animation: nmb-pulse 2.5s ease-in-out infinite;
}
@keyframes nmb-pulse {
  0%, 100% { box-shadow: 0 0 0 0 hsl(240, 90%, 66%, .2); }
  50% { box-shadow: 0 0 0 8px hsl(240, 90%, 66%, 0); }
}
.nmb-icon .ph { font-size: 18px; color: var(--accent-light); line-height: 1; }

.nmb-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
}
.nmb-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nmb-sub {
  font-size: 12px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.nmb-close {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs); color: var(--text-disabled);
  flex-shrink: 0; transition: all var(--t-base);
}
.nmb-close:hover { color: var(--text-muted); background: var(--bg-hover); }
.nmb-close .ph { font-size: 11px; line-height: 1; }

@media (max-width: 768px) {
  .new-msg-banner {
    top: auto; bottom: 72px;
    right: 12px; left: 12px;
    max-width: none; min-width: 0;
    transform: translateY(20px);
  }
  .new-msg-banner.visible { transform: translateY(0); }
}

/* ═══ INBOX RULES PANEL ═══ */
.rules-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.rules-panel {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); width: 560px; max-width: 92vw;
  max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 48px rgba(0,0,0,.4);
}
.rules-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.rules-header h2 {
  font-size: 15px; font-weight: 600; color: var(--text-primary); margin: 0;
}
.rules-close {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs); color: var(--text-muted); font-size: 18px;
  background: none; border: none; cursor: pointer; transition: all .15s;
}
.rules-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.rules-body {
  padding: 16px 20px; overflow-y: auto; flex: 1;
}
.rules-loading {
  text-align: center; color: var(--text-disabled); padding: 40px 0; font-size: 13px;
}
.rules-empty {
  text-align: center; color: var(--text-disabled); padding: 40px 0; font-size: 13px;
}
.rule-card {
  background: var(--bg-card, var(--bg-hover)); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 10px;
  transition: border-color .15s;
}
.rule-card:hover { border-color: var(--accent); }
.rule-card:last-child { margin-bottom: 0; }
.rule-top {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.rule-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%;
}
.rule-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: .5px;
}
.rule-badge.on { background: rgba(34,197,94,.15); color: #22c55e; }
.rule-badge.off { background: rgba(239,68,68,.1); color: #ef4444; }
.rule-desc {
  font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-bottom: 8px;
}
.rule-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.rule-tag {
  font-size: 10px; padding: 3px 8px; border-radius: 6px;
  background: rgba(99,102,241,.12); color: var(--accent); font-weight: 500;
}
.rule-tag.redirect { background: rgba(245,158,11,.12); color: #f59e0b; }
.rule-tag.forward { background: rgba(59,130,246,.12); color: #3b82f6; }
.rule-tag.delete { background: rgba(239,68,68,.1); color: #ef4444; }
.rule-tag.move { background: rgba(34,197,94,.1); color: #22c55e; }

.rule-top-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.rule-del-btn {
  width: 24px; height: 24px; border-radius: 6px; border: none;
  background: rgba(239,68,68,.1); color: #ef4444; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .15s; line-height: 1;
}
.rule-del-btn:hover { background: rgba(239,68,68,.25); }
.rule-add-btn {
  width: 100%; padding: 10px; margin-bottom: 12px; border-radius: var(--r-md);
  border: 1px dashed var(--border); background: none; color: var(--accent);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.rule-add-btn:hover { background: rgba(99,102,241,.08); border-color: var(--accent); }
.rule-add-form { display: flex; flex-direction: column; gap: 12px; }
.rule-form-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.rule-add-form label {
  display: flex; flex-direction: column; gap: 4px; font-size: 12px;
  color: var(--text-muted); font-weight: 500;
}
.rule-add-form input[type="text"],
.rule-add-form input[type="email"],
.rule-add-form select {
  padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg-base); color: var(--text-primary); font-size: 13px;
  outline: none; transition: border-color .15s;
}
.rule-add-form input:focus, .rule-add-form select:focus { border-color: var(--accent); }
.rule-add-form label:has(input[type="checkbox"]) {
  flex-direction: row; align-items: center; gap: 8px; cursor: pointer;
}
.rule-form-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.rule-form-cancel {
  padding: 7px 16px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: none; color: var(--text-muted); font-size: 12px; cursor: pointer;
}
.rule-form-cancel:hover { background: var(--bg-hover); }
.rule-form-save {
  padding: 7px 16px; border-radius: var(--r-sm); border: none;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
}
.rule-form-save:hover { opacity: .9; }
.rule-form-save:disabled { opacity: .5; cursor: not-allowed; }
