*{box-sizing:border-box;}
html,body{height:100%;margin:0;}
a{color:var(--accent);}
a:hover{color:var(--accent-strong);}

:root,.app{
  --canvas:#e9edf4;
  --surface:#ffffff;
  --surface-2:#f3f6fa;
  --surface-3:#e9eef5;
  --border:#e2e7ef;
  --border-strong:#cfd7e3;
  --text:#141821;
  --muted:#586173;
  --dim:#8b95a6;
  --accent:#2f6bed;
  --accent-strong:#1f57d6;
  --accent-2:#7c5cff;
  --accent-soft:rgba(47,107,237,0.09);
  --accent-line:rgba(47,107,237,0.30);
  --grad:linear-gradient(135deg,#2f6bed,#5b8bff 55%,#7c5cff);
  --ok:#12a150;
  --ok-soft:rgba(18,161,80,0.12);
  --err:#e5484d;
  --err-soft:rgba(229,72,77,0.10);
  --heart:#ff4d6d;
  --shadow-xs:0 1px 2px rgba(20,28,45,0.06);
  --shadow-sm:0 2px 6px rgba(20,28,45,0.07),0 1px 2px rgba(20,28,45,0.06);
  --shadow-md:0 10px 26px rgba(20,28,45,0.10),0 3px 8px rgba(20,28,45,0.06);
  --shadow-lg:0 30px 70px rgba(15,22,40,0.28);
  --r-sm:10px;
  --r-md:14px;
  --r-lg:18px;
  --r-xl:22px;
}
.app[data-theme="dark"]{
  --canvas:#080b11;
  --surface:#12171f;
  --surface-2:#1a212b;
  --surface-3:#222b37;
  --border:#252f3d;
  --border-strong:#354150;
  --text:#eef2f8;
  --muted:#9aa6b6;
  --dim:#616d7e;
  --accent:#5b8dff;
  --accent-strong:#82a8ff;
  --accent-2:#9b7bff;
  --accent-soft:rgba(91,141,255,0.14);
  --accent-line:rgba(91,141,255,0.42);
  --grad:linear-gradient(135deg,#4d82ff,#6f97ff 55%,#9b7bff);
  --ok:#33c26e;
  --ok-soft:rgba(51,194,110,0.15);
  --err:#ff6b61;
  --err-soft:rgba(255,107,97,0.13);
  --heart:#ff5c7a;
  --shadow-xs:0 1px 2px rgba(0,0,0,0.35);
  --shadow-sm:0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:0 12px 30px rgba(0,0,0,0.5);
  --shadow-lg:0 30px 70px rgba(0,0,0,0.62);
}

body{
  font-family:'Plus Jakarta Sans',ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  background:var(--canvas);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  font-size:15px;
  line-height:1.55;
}
.app{
  height:100dvh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  background:var(--canvas);
  color:var(--text);
  position:relative;
}

::-webkit-scrollbar{width:10px;height:10px;}
::-webkit-scrollbar-thumb{background:var(--border-strong);border-radius:8px;border:2px solid transparent;background-clip:padding-box;}
::-webkit-scrollbar-thumb:hover{background:var(--dim);background-clip:padding-box;}
::-webkit-scrollbar-track{background:transparent;}
*{scrollbar-width:thin;scrollbar-color:var(--border-strong) transparent;}

/* ---------- top bar ---------- */
.topbar{
  height:66px;
  flex:0 0 66px;
  display:flex;
  align-items:center;
  gap:14px;
  padding:0 20px;
  background:var(--surface);
  border-bottom:1px solid var(--border);
  z-index:30;
  min-width:0;
}
.brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}
button.brand{
  padding:0;
  border:0;
  background:transparent;
  color:inherit;
  text-align:left;
  cursor:pointer;
  font:inherit;
}
button.brand:hover .brand-name{color:var(--accent);}
button.brand:focus-visible{outline:2px solid var(--accent);outline-offset:4px;border-radius:8px;}
.logo{width:42px;height:42px;flex:0 0 42px;display:flex;align-items:center;justify-content:center;}
.logo svg{width:42px;height:42px;filter:drop-shadow(0 5px 14px rgba(47,107,237,.4));}
.brand-text{min-width:0;}
.brand-name{
  font-weight:800;
  font-size:18px;
  white-space:nowrap;
}
.brand-name .dot{background:var(--grad);-webkit-background-clip:text;background-clip:text;color:transparent;}
.brand-sub{font-size:12px;color:var(--dim);font-weight:600;margin-top:-2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.topbar-spacer{flex:1;}

.icon-btn{
  height:42px;
  min-width:42px;
  padding:0 12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  background:transparent;
  border:1px solid transparent;
  border-radius:12px;
  color:var(--muted);
  cursor:pointer;
  font:inherit;
  font-weight:700;
  font-size:13.5px;
  transition:background .14s,color .14s,transform .1s;
}
.icon-btn:hover{background:var(--surface-2);color:var(--text);}
.icon-btn:active{transform:scale(.95);}
.icon-btn svg{width:19px;height:19px;flex:0 0 19px;}
.mobile-menu-btn{display:none;}

.btn{
  height:44px;
  padding:0 18px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  border-radius:13px;
  cursor:pointer;
  font:inherit;
  font-weight:700;
  font-size:14px;
  border:1px solid var(--border-strong);
  background:var(--surface);
  color:var(--text);
  transition:background .14s,border-color .14s,transform .1s,box-shadow .14s;
  white-space:nowrap;
}
.btn:hover{background:var(--surface-2);}
.btn svg{width:17px;height:17px;}
.btn-primary{
  background:var(--grad);
  border:none;
  color:#fff;
  box-shadow:0 6px 18px rgba(47,107,237,.34);
}
.btn-primary:hover{background:var(--grad);filter:brightness(1.08);transform:translateY(-1px);box-shadow:0 10px 24px rgba(47,107,237,.42);}
.btn-primary:active{transform:scale(.98);}
.btn-primary:disabled{opacity:.6;cursor:not-allowed;transform:none;}
.btn.danger{color:var(--err);border-color:rgba(229,72,77,.35);}
.btn.danger:hover{background:var(--err-soft);border-color:var(--err);}

.acct-chip{
  position:relative;
  display:flex;
  align-items:center;
  gap:6px;
  height:44px;
  padding:0 6px 0 8px;
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:999px;
  max-width:320px;
  box-shadow:var(--shadow-xs);
}
.acct-chip .avatar{width:30px;height:30px;flex:0 0 30px;font-size:12px;}
.chip-main{
  flex:1;
  min-width:0;
  display:flex;
  align-items:center;
  gap:10px;
  background:none;
  border:none;
  padding:0 2px;
  font:inherit;
  color:inherit;
  cursor:pointer;
  border-radius:999px;
}
.acct-chip .ac-mail{flex:1;font-size:13.5px;font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;text-align:left;}
.chip-caret{width:15px;height:15px;flex:0 0 15px;color:var(--dim);transition:transform .18s;}
.acct-chip.open .chip-caret{transform:rotate(180deg);}
.acct-chip .ac-copy{
  width:32px;
  height:32px;
  flex:0 0 32px;
  border:none;
  border-radius:50%;
  background:transparent;
  color:var(--muted);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:background .14s,color .14s;
}
.acct-chip .ac-copy:hover{background:var(--accent-soft);color:var(--accent);}
.acct-chip .ac-copy svg{width:15px;height:15px;}
.chip-menu{
  position:absolute;
  top:calc(100% + 8px);
  left:0;
  min-width:260px;
  max-width:min(340px,calc(100vw - 24px));
  max-height:calc(100dvh - 90px);
  overflow-y:auto;
  overflow-x:hidden;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:var(--shadow-md);
  padding:6px;
  display:none;
  z-index:90;
}
.acct-chip.open .chip-menu{display:flex;flex-direction:column;gap:2px;animation:rise .16s ease-out;}
.chip-menu-head{
  font-size:10.5px;
  font-weight:800;
  letter-spacing:.09em;
  text-transform:uppercase;
  color:var(--dim);
  padding:6px 10px 4px;
}
.chip-acct{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  padding:8px 10px;
  border-radius:10px;
  border:none;
  background:transparent;
  cursor:pointer;
  text-align:left;
  font:inherit;
  transition:background .14s;
}
.chip-acct:hover{background:var(--surface-2);}
.chip-acct.active{background:var(--accent-soft);}
.chip-acct .avatar{width:32px;height:32px;flex:0 0 32px;font-size:13px;}
.chip-acct-meta{min-width:0;flex:1;}
.chip-acct-mail{font-size:13px;font-weight:700;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.chip-acct.active .chip-acct-mail{color:var(--accent);}
.chip-acct-sub{font-size:11px;color:var(--dim);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.chip-acct .count-pill{flex:0 0 auto;}
.chip-check{flex:0 0 16px;width:16px;height:16px;color:var(--accent);}
.chip-add-ico{
  width:32px;
  height:32px;
  flex:0 0 32px;
  border-radius:50%;
  background:var(--accent-soft);
  color:var(--accent);
  display:flex;
  align-items:center;
  justify-content:center;
}
.chip-add-ico svg{width:17px;height:17px;}
.chip-menu-div{height:1px;background:var(--border);margin:4px 6px;}

.language-picker{position:relative;}
.language-btn{min-width:42px;}
.language-btn .language-label{max-width:88px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.language-flag{
  width:20px;
  height:20px;
  flex:0 0 20px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  border-radius:50%;
  line-height:1;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.28),0 1px 2px rgba(20,28,45,.12);
}
.flag-en{background:conic-gradient(from 45deg,#cf2338 0 12.5%,#fff 12.5% 18%,#173f8e 18% 32%,#fff 32% 38%,#cf2338 38% 62.5%,#fff 62.5% 68%,#173f8e 68% 82%,#fff 82% 88%,#cf2338 88%);}
.flag-ru{background:linear-gradient(#fff 0 33%,#2366b5 33% 66%,#d52b1e 66%);}
.flag-uk{background:linear-gradient(#0057b7 0 50%,#ffd700 50%);}
.flag-zh{background:radial-gradient(circle at 33% 33%,#ffd447 0 13%,transparent 14%),#df252b;}
.flag-de{background:linear-gradient(#000 0 33%,#dd0000 33% 66%,#ffce00 66%);}
.flag-id{background:linear-gradient(#e70011 0 50%,#fff 50%);}
.flag-ms{background:radial-gradient(circle at 26% 30%,#fff 0 11%,#cc0001 12%),linear-gradient(#cc0001 0 7.1%,#fff 7.1% 14.3%,#cc0001 14.3% 21.4%,#fff 21.4% 28.6%,#cc0001 28.6% 35.7%,#fff 35.7% 42.9%,#010066 42.9% 50%,#cc0001 50% 57.1%,#fff 57.1% 64.3%,#cc0001 64.3% 71.4%,#fff 71.4% 78.6%,#cc0001 78.6% 85.7%,#fff 85.7% 92.9%,#cc0001 92.9%);}
.flag-fil{background:radial-gradient(circle at 24% 50%,#fdd116 0 7%,transparent 8%),linear-gradient(90deg,#fff 0 34%,transparent 34%),linear-gradient(#0038a8 0 50%,#ce1126 50%);}
.flag-tr{background:radial-gradient(circle at 47% 50%,#e30a17 0 9%,transparent 10%),radial-gradient(circle at 41% 50%,#fff 0 12%,transparent 13%),#e30a17;}
.flag-ar{background:linear-gradient(#147a3e 0 74%,#fff 74%);}
.flag-fr{background:linear-gradient(90deg,#2554a4 0 33%,#fff 33% 66%,#e9414d 66%);}
.flag-vi{background:radial-gradient(circle,#ffd44a 0 17%,transparent 18%),#d92c34;}
.flag-ko{background:radial-gradient(circle at 50% 42%,#e34c54 0 22%,#2878bb 23% 42%,transparent 43%),#fff;}
.flag-ja{background:radial-gradient(circle,#d73543 0 36%,transparent 37%),#fff;}
.flag-hi{background:radial-gradient(circle,#0b3577 0 9%,transparent 10%),linear-gradient(#ff9933 0 33%,#fff 33% 66%,#128807 66%);}
.flag-ur{background:radial-gradient(circle at 62% 50%,transparent 0 13%,#fff 13% 17%,transparent 17%),linear-gradient(90deg,#fff 0 22%,#01411c 22%);}
.language-menu{
  position:absolute;
  right:0;
  top:calc(100% + 9px);
  z-index:90;
  width:300px;
  max-width:calc(100vw - 20px);
  max-height:calc(100dvh - 84px);
  overflow-y:auto;
  overflow-x:hidden;
  padding:7px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:var(--shadow-md);
  display:none;
}
.language-menu.open{display:grid;grid-template-columns:1fr 1fr;gap:5px;animation:rise .16s ease-out;}
.language-option{
  height:40px;
  padding:0 9px;
  border:1px solid var(--border);
  border-radius:10px;
  color:var(--muted);
  text-align:left;
  cursor:pointer;
  font:inherit;
  font-size:12.5px;
  font-weight:700;
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  transition:background .14s,color .14s,border-color .14s;
}
.language-option>span:last-child{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.language-option:hover,.language-option.active{background:var(--accent-soft);color:var(--accent);}

/* ---------- main grid ---------- */
.app-main{
  flex:1;
  min-height:0;
  display:grid;
  grid-template-columns:288px minmax(340px,410px) 1fr;
  position:relative;
  background:var(--canvas);
  overflow:hidden;
}
.app-main.no-accounts{grid-template-columns:288px 1fr;}

/* ---------- sidebar ---------- */
.pane-sidebar{
  background:var(--surface);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow-y:auto;
  padding:18px 14px;
}
.side-head{
  font-size:11.5px;
  font-weight:800;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--dim);
  padding:6px 10px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.side-count{margin-left:6px;color:var(--accent);background:var(--accent-soft);border-radius:999px;padding:1px 8px;font-size:11px;}
.side-head-actions{display:flex;align-items:center;gap:5px;}
.side-icon{
  width:30px;
  height:30px;
  border-radius:9px;
  border:none;
  cursor:pointer;
  background:var(--surface-2);
  color:var(--muted);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:background .14s,color .14s;
}
.side-icon:hover{background:var(--accent-soft);color:var(--accent);}
.side-icon svg{width:16px;height:16px;}
.side-accounts{display:flex;flex-direction:column;}
.account-row{
  display:flex;
  align-items:center;
  gap:12px;
  width:100%;
  padding:11px 12px;
  border-radius:14px;
  border:1px solid transparent;
  background:transparent;
  cursor:pointer;
  text-align:left;
  font:inherit;
  transition:background .14s,border-color .14s,transform .1s;
  margin-bottom:4px;
}
.account-row:hover{background:var(--surface-2);}
.account-row:active{transform:scale(.99);}
.account-row.active{background:var(--accent-soft);border-color:var(--accent-line);box-shadow:var(--shadow-xs);}
.avatar{
  flex:0 0 40px;
  width:40px;
  height:40px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  font-weight:800;
  font-size:15px;
  text-transform:uppercase;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.14);
}
.account-meta{min-width:0;flex:1;}
.account-email{font-size:14px;font-weight:700;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.account-sub{font-size:12px;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;}
.account-row.failed .account-email{color:var(--muted);}
.count-pill{
  flex:0 0 auto;
  min-width:22px;
  height:22px;
  padding:0 7px;
  border-radius:999px;
  background:var(--grad);
  color:#fff;
  font-size:11.5px;
  font-weight:800;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 2px 6px rgba(47,107,237,.3);
}
.fail-dot{flex:0 0 auto;width:9px;height:9px;border-radius:50%;background:var(--err);}
.side-empty{padding:14px 12px;font-size:13px;color:var(--dim);line-height:1.6;}
.side-divider{height:1px;background:var(--border);margin:16px 8px;}
.folder-list{display:flex;flex-direction:column;}
.folder-btn{
  display:flex;
  align-items:center;
  gap:13px;
  width:100%;
  padding:11px 14px;
  border-radius:12px;
  border:none;
  background:transparent;
  cursor:pointer;
  text-align:left;
  font:inherit;
  font-size:14.5px;
  font-weight:700;
  color:var(--muted);
  transition:background .14s,color .14s;
  margin-bottom:2px;
}
.folder-btn svg{width:19px;height:19px;flex:0 0 19px;opacity:.9;}
.folder-btn:hover{background:var(--surface-2);color:var(--text);}
.folder-btn.active{background:var(--accent-soft);color:var(--accent);}
.folder-btn .fcount{margin-left:auto;font-size:12px;font-weight:800;color:var(--dim);}
.folder-btn.active .fcount{color:var(--accent);}
.side-foot{margin-top:auto;padding-top:14px;display:flex;flex-direction:column;gap:10px;}
.credit{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  padding:9px 12px;
  border-radius:12px;
  background:linear-gradient(135deg,rgba(255,77,109,.08),rgba(124,92,255,.08));
  border:1px solid var(--border);
  font-size:12.5px;
  font-weight:700;
}
.credit .heart{color:var(--heart);display:inline-block;animation:beat 1.6s ease-in-out infinite;}
.credit .by{color:var(--dim);font-weight:600;}
.credit .who{background:var(--grad);-webkit-background-clip:text;background-clip:text;color:transparent;font-weight:800;}
@keyframes beat{0%,100%{transform:scale(1);}14%,42%{transform:scale(1.22);}28%{transform:scale(.95);}70%{transform:scale(1);}}
.theme-row{
  display:flex;
  align-items:center;
  gap:11px;
  padding:11px 14px;
  border-radius:12px;
  background:var(--surface-2);
  font-size:14px;
  font-weight:700;
  color:var(--muted);
}
.theme-row svg{width:18px;height:18px;}
.theme-switch{
  margin-left:auto;
  width:50px;
  height:28px;
  border-radius:999px;
  border:none;
  cursor:pointer;
  background:var(--border-strong);
  position:relative;
  transition:background .3s ease;
}
.app[data-theme="dark"] .theme-switch{background:var(--accent);}
.theme-knob{
  position:absolute;
  top:3px;
  left:3px;
  width:22px;
  height:22px;
  border-radius:50%;
  background:#fff;
  transition:transform .34s cubic-bezier(.34,1.56,.64,1),box-shadow .3s ease;
  box-shadow:0 1px 3px rgba(0,0,0,.3);
  display:flex;
  align-items:center;
  justify-content:center;
}
.theme-knob svg{width:12px;height:12px;transition:opacity .22s ease,transform .34s cubic-bezier(.34,1.56,.64,1);}
.theme-knob .k-sun{color:#f5a623;opacity:1;position:absolute;}
.theme-knob .k-moon{color:#5b6b86;opacity:0;position:absolute;transform:rotate(-40deg) scale(.6);}
.app[data-theme="dark"] .theme-knob{transform:translateX(22px);}
.app[data-theme="dark"] .theme-knob .k-sun{opacity:0;transform:rotate(40deg) scale(.6);}
.app[data-theme="dark"] .theme-knob .k-moon{opacity:1;transform:none;}
.app.theming,.app.theming *:not(.theme-knob):not(.theme-knob svg):not(.spinner):not(.sk):not(.heart){
  transition:background-color .32s ease,color .32s ease,border-color .32s ease,fill .32s ease,box-shadow .32s ease !important;
}

/* ---------- message list ---------- */
.pane-list{
  background:var(--surface);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  min-height:0;
  min-width:0;
}
.list-toolbar{
  flex:0 0 auto;
  padding:18px 18px 14px;
  border-bottom:1px solid var(--border);
  display:flex;
  flex-direction:column;
  gap:13px;
}
.list-title-row{display:flex;align-items:center;gap:11px;}
.list-title{font-size:21px;font-weight:800;}
.list-count{font-size:12.5px;font-weight:800;color:var(--accent);background:var(--accent-soft);padding:3px 11px;border-radius:999px;}
.list-actions{margin-left:auto;display:flex;align-items:center;gap:6px;}
.search{
  display:flex;
  align-items:center;
  gap:11px;
  padding:0 15px;
  height:46px;
  background:var(--surface-2);
  border:1.5px solid var(--border);
  border-radius:14px;
  transition:border-color .14s,box-shadow .14s,background .14s;
}
.search:focus-within{border-color:var(--accent);box-shadow:0 0 0 4px var(--accent-soft);background:var(--surface);}
.search svg{width:18px;height:18px;color:var(--dim);flex:0 0 18px;}
.search input{
  flex:1;
  border:none;
  background:transparent;
  outline:none;
  font:inherit;
  font-size:14.5px;
  font-weight:600;
  color:var(--text);
  min-width:0;
}
.search input::placeholder{color:var(--dim);font-weight:500;}
.search .spinner{flex:0 0 16px;}
.filter-row{display:flex;align-items:center;gap:9px;flex-wrap:wrap;min-height:34px;}
.pill{
  height:34px;
  padding:0 14px;
  border-radius:999px;
  border:1.5px solid var(--border);
  background:var(--surface);
  color:var(--muted);
  cursor:pointer;
  font:inherit;
  font-size:13px;
  font-weight:700;
  display:inline-flex;
  align-items:center;
  gap:7px;
  transition:background .14s,color .14s,border-color .14s;
}
.pill:hover{background:var(--surface-2);color:var(--text);}
.pill:disabled{opacity:.45;cursor:not-allowed;pointer-events:none;}
.pill.on{background:var(--accent-soft);color:var(--accent);border-color:var(--accent-line);}
.pill.danger{color:var(--err);}
.pill.danger:hover{background:var(--err-soft);border-color:var(--err);}
.pill svg{width:15px;height:15px;flex:0 0 15px;}
.pill .dot{width:8px;height:8px;border-radius:50%;background:currentColor;}
.selection-count{font-size:12.5px;font-weight:800;color:var(--accent);padding:0 4px;}
.filter-spacer{flex:1;}
.msg-list{flex:1;min-height:0;overflow-y:auto;padding:8px;}
.msg{
  display:flex;
  gap:13px;
  padding:14px 15px;
  cursor:pointer;
  position:relative;
  border-radius:14px;
  transition:background .12s,transform .1s;
  margin-bottom:3px;
}
.msg:hover{background:var(--surface-2);}
.msg:active{transform:scale(.995);}
.msg.active{background:var(--accent-soft);}
.msg.selected{background:var(--accent-soft);}
.msg.unread .msg-subject{font-weight:800;}
.msg.unread .msg-from{font-weight:800;color:var(--text);}
.msg-avatar{flex:0 0 40px;width:40px;height:40px;border-radius:50%;color:#fff;font-weight:800;font-size:15px;display:flex;align-items:center;justify-content:center;text-transform:uppercase;box-shadow:inset 0 0 0 1px rgba(255,255,255,.14);}
.msg-body{min-width:0;flex:1;}
.msg-top{display:flex;align-items:center;gap:8px;margin-bottom:3px;}
.msg-from{font-size:13.5px;font-weight:700;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;}
.msg-attach{flex:0 0 auto;width:15px;height:15px;color:var(--dim);display:inline-flex;}
.msg-attach svg{width:15px;height:15px;}
.msg-date{flex:0 0 auto;font-size:11.5px;font-weight:700;color:var(--dim);}
.msg-subject{font-size:14px;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-bottom:3px;font-weight:600;}
.msg-preview{font-size:12.5px;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.msg-check{
  flex:0 0 20px;
  width:20px;
  height:20px;
  margin-top:10px;
  border-radius:7px;
  border:1.5px solid var(--border-strong);
  background:var(--surface);
  color:#fff;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.msg-check.checked{background:var(--grad);border-color:transparent;}
.msg-check svg{width:13px;height:13px;opacity:0;}
.msg-check.checked svg{opacity:1;}

.sk-row{display:flex;gap:13px;padding:14px 15px;border-radius:14px;margin-bottom:3px;}
.sk{background:linear-gradient(90deg,var(--surface-2) 25%,var(--surface-3) 50%,var(--surface-2) 75%);background-size:200% 100%;animation:shimmer 1.1s infinite linear;border-radius:8px;}
.sk-av{width:40px;height:40px;flex:0 0 40px;border-radius:50%;}
.sk-lines{flex:1;display:flex;flex-direction:column;gap:8px;}
.sk-line{height:11px;}
@keyframes shimmer{from{background-position:200% 0;}to{background-position:-200% 0;}}

.empty{
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:36px 26px;
  text-align:center;
}
.empty-ico{
  width:58px;
  height:58px;
  border-radius:18px;
  background:var(--accent-soft);
  color:var(--accent);
  display:flex;
  align-items:center;
  justify-content:center;
  margin-bottom:16px;
}
.empty-ico svg{width:28px;height:28px;}
.empty-title{font-size:16px;font-weight:800;color:var(--text);}
.empty-sub{font-size:13px;color:var(--dim);font-weight:600;margin-top:4px;}
.fail-panel{width:100%;max-width:420px;}
.fail-box{
  display:flex;
  align-items:flex-start;
  gap:10px;
  padding:14px 16px;
  border-radius:14px;
  border:1px solid rgba(229,72,77,.35);
  background:var(--err-soft);
  color:var(--err);
  font-size:13px;
  font-weight:700;
  text-align:left;
}
.fail-box svg{width:17px;height:17px;flex:0 0 17px;margin-top:1px;}

/* ---------- reader ---------- */
.pane-reader{
  background:var(--surface-2);
  display:flex;
  flex-direction:column;
  min-height:0;
  min-width:0;
}
.reader-head{
  flex:0 0 auto;
  padding:22px 30px;
  background:var(--surface);
  border-bottom:1px solid var(--border);
}
.reader-top{display:flex;align-items:flex-start;gap:14px;}
.reader-back{display:none;}
.reader-subject{
  flex:1;
  min-width:0;
  font-size:23px;
  font-weight:800;
  line-height:1.3;
  word-break:break-word;
  display:-webkit-box;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:3;
  overflow:hidden;
}
.reader-actions{display:flex;gap:5px;flex:0 0 auto;}
.reader-actions .danger-action{color:var(--err);}
.reader-actions .danger-action:hover{background:var(--err-soft);}
.reader-meta{display:flex;align-items:center;gap:14px;margin-top:16px;}
.reader-meta .avatar{flex:0 0 46px;width:46px;height:46px;font-size:17px;}
.reader-fromline{min-width:0;}
.reader-fromname{font-size:15px;font-weight:800;}
.reader-fromaddr{font-size:13px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;}
.reader-date{margin-left:auto;font-size:13px;color:var(--dim);font-weight:700;text-align:right;flex:0 0 auto;}
.reader-to{margin-top:10px;font-size:13px;color:var(--muted);word-break:break-word;font-weight:600;}
.reader-to b{color:var(--dim);font-weight:700;}
.reader-body{
  flex:1;
  min-height:0;
  overflow-y:auto;
  padding:30px clamp(20px,4vw,48px);
  background:var(--surface-2);
}
.email-sheet{
  width:100%;
  max-width:860px;
  margin:0 auto;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--r-lg);
  box-shadow:var(--shadow-sm);
  overflow:hidden;
}
.email-sheet.text{padding:26px 30px;font-size:15px;line-height:1.75;color:var(--text);white-space:pre-wrap;word-break:break-word;}
.email-sheet.html{padding:24px 28px;font-size:15px;line-height:1.7;color:var(--text);word-break:break-word;overflow-wrap:anywhere;}
.email-sheet.html :where(h1,h2,h3,h4,h5,h6){line-height:1.3;margin:18px 0 8px;}
.email-sheet.html p{margin:0 0 12px;}
.email-sheet.html img{max-width:100%;height:auto;}
.email-sheet.html table{max-width:100%;border-collapse:collapse;}
.email-sheet.html a{color:var(--accent);}
.email-sheet.html blockquote{margin:12px 0;padding:4px 14px;border-left:3px solid var(--border-strong);color:var(--muted);}
.email-sheet.html pre{white-space:pre-wrap;word-break:break-word;background:var(--surface-2);padding:12px;border-radius:8px;}
.email-sheet.html ul,.email-sheet.html ol{padding-left:22px;margin:0 0 12px;}
.email-sheet.html > :first-child{margin-top:0;}
.email-sheet.html > :last-child{margin-bottom:0;}
.email-sheet iframe{display:block;border:0;width:100%;min-height:260px;}
.attach-strip{
  max-width:860px;
  margin:18px auto 0;
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}
.attach-card{
  display:flex;
  align-items:center;
  gap:11px;
  padding:11px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background:var(--surface);
  box-shadow:var(--shadow-xs);
  max-width:100%;
}
.attach-ico{
  width:36px;
  height:36px;
  flex:0 0 36px;
  border-radius:11px;
  background:var(--accent-soft);
  color:var(--accent);
  display:flex;
  align-items:center;
  justify-content:center;
}
.attach-ico svg{width:18px;height:18px;}
.attach-name{font-size:13px;font-weight:800;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:220px;}
.attach-size{font-size:11.5px;color:var(--dim);font-weight:600;}
.loading-pane{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:12px;
  color:var(--dim);
  font-weight:700;
  font-size:13.5px;
}

/* ---------- overlays ---------- */
.overlay{
  position:fixed;
  inset:0;
  z-index:100;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:rgba(15,20,30,.48);
  backdrop-filter:blur(3px);
  animation:fade .18s ease-out;
}
.overlay:not(.show){display:none;}
.overlay[hidden]{display:none!important;}
@keyframes fade{from{opacity:0;}to{opacity:1;}}
@keyframes rise{from{opacity:0;transform:translateY(8px) scale(.98);}to{opacity:1;transform:none;}}
.sheet{
  width:100%;
  max-height:calc(100dvh - 48px);
  overflow-y:auto;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--r-xl);
  box-shadow:var(--shadow-lg);
  animation:rise .2s ease-out;
}
.sheet-head{
  display:flex;
  align-items:flex-start;
  gap:14px;
  padding:22px 24px 14px;
  border-bottom:1px solid var(--border);
}
.sheet-title{flex:1;min-width:0;}
.sheet-title h2{margin:0;font-size:20px;font-weight:800;}
.sheet-title p{margin:5px 0 0;font-size:13px;color:var(--dim);font-weight:600;}
.sheet-body{padding:18px 24px 24px;}
.sheet-foot{
  display:flex;
  align-items:center;
  gap:10px;
  padding:14px 24px 22px;
  border-top:1px solid var(--border);
}
.sheet-foot .hint{flex:1;font-size:12.5px;color:var(--dim);font-weight:600;text-align:right;}
.label-row{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px;}
.field-label{font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);}
.text-actions{display:flex;align-items:center;gap:6px;}
.mini-btn{
  height:32px;
  padding:0 11px;
  display:inline-flex;
  align-items:center;
  gap:7px;
  border-radius:9px;
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--muted);
  cursor:pointer;
  font:inherit;
  font-size:12.5px;
  font-weight:700;
  transition:background .14s,color .14s,border-color .14s;
}
.mini-btn:hover{background:var(--surface-2);color:var(--text);}
.mini-btn svg{width:14px;height:14px;}
.creds-ta{
  width:100%;
  min-height:132px;
  resize:vertical;
  padding:13px 15px;
  border-radius:14px;
  border:1.5px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  font-family:'IBM Plex Mono',ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  font-size:12.5px;
  line-height:1.6;
  outline:none;
  transition:border-color .14s,box-shadow .14s,background .14s;
}
.creds-ta:focus{border-color:var(--accent);box-shadow:0 0 0 4px var(--accent-soft);background:var(--surface);}
.schema{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:10px 16px;
  margin-top:14px;
}
.schema-row{display:flex;align-items:center;gap:7px;flex-wrap:wrap;}
.chip{
  height:26px;
  padding:0 10px;
  display:inline-flex;
  align-items:center;
  gap:6px;
  border-radius:999px;
  font-size:11.5px;
  font-weight:800;
}
.chip svg{width:13px;height:13px;}
.chip.email{background:var(--accent-soft);color:var(--accent);}
.chip.pass{background:rgba(124,92,255,.10);color:var(--accent-2);}
.chip.token{background:rgba(201,130,10,.12);color:#c9820a;}
.chip.client{background:var(--ok-soft);color:var(--ok);}
.app[data-theme="dark"] .chip.email{color:#7aa4ff;}
.app[data-theme="dark"] .chip.pass{color:#b79bff;}
.app[data-theme="dark"] .chip.token{color:#e2a53a;}
.app[data-theme="dark"] .chip.client{color:#33c26e;}
.schema-sep{color:var(--dim);font-weight:800;}
.schema-toggle{display:flex;align-items:center;gap:10px;font-size:12.5px;font-weight:700;color:var(--muted);flex-wrap:wrap;}
.schema-toggle .lbl{color:var(--dim);font-size:11.5px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;}
.seg{display:inline-flex;border:1.5px solid var(--border);border-radius:10px;overflow:hidden;}
.seg-btn{
  height:30px;
  min-width:34px;
  border:none;
  background:var(--surface);
  color:var(--muted);
  cursor:pointer;
  font:inherit;
  font-weight:800;
  font-family:'IBM Plex Mono',monospace;
  transition:background .14s,color .14s;
}
.seg-btn + .seg-btn{border-left:1px solid var(--border);}
.seg-btn.active{background:var(--accent-soft);color:var(--accent);}
.creds-controls{display:flex;align-items:flex-end;gap:14px;margin-top:20px;flex-wrap:wrap;}
.ctrl{display:flex;flex-direction:column;gap:7px;}
.ctrl label{font-size:12px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:var(--dim);}
.ctrl select,.ctrl input{
  height:42px;
  min-width:150px;
  padding:0 13px;
  border-radius:12px;
  border:1.5px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  font:inherit;
  font-size:13.5px;
  font-weight:700;
  outline:none;
  transition:border-color .14s,box-shadow .14s,background .14s;
}
.ctrl select:focus,.ctrl input:focus{border-color:var(--accent);box-shadow:0 0 0 4px var(--accent-soft);background:var(--surface);}
.ctrl input[type="number"]{min-width:88px;width:88px;}

.manage-list{display:flex;flex-direction:column;gap:8px;}
.manage-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:11px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background:var(--surface-2);
  transition:box-shadow .14s,border-color .14s,transform .14s;
}
.manage-row.dragging{box-shadow:var(--shadow-md);border-color:var(--accent-line);transform:scale(1.01);}
.manage-row .avatar{flex:0 0 38px;width:38px;height:38px;font-size:14px;}
.manage-row .account-meta{flex:1;}
.drag-handle{
  width:30px;
  height:30px;
  border:none;
  background:transparent;
  color:var(--dim);
  cursor:grab;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:8px;
}
.drag-handle:hover{background:var(--surface-3);color:var(--text);}
.drag-handle svg{width:16px;height:16px;}
.manage-remove{
  width:32px;
  height:32px;
  border:none;
  border-radius:9px;
  background:transparent;
  color:var(--dim);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:background .14s,color .14s;
}
.manage-remove:hover{background:var(--err-soft);color:var(--err);}
.manage-remove svg{width:16px;height:16px;}

.cfield{display:grid;grid-template-columns:74px 1fr auto;align-items:center;gap:10px;margin-bottom:11px;}
.cfield label{font-size:12px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:var(--dim);}
.cfield select,.cfield input{
  height:42px;
  width:100%;
  padding:0 13px;
  border-radius:12px;
  border:1.5px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  font:inherit;
  font-size:13.5px;
  font-weight:600;
  outline:none;
  transition:border-color .14s,box-shadow .14s,background .14s;
}
.cfield select:focus,.cfield input:focus{border-color:var(--accent);box-shadow:0 0 0 4px var(--accent-soft);background:var(--surface);}
.cc-toggle{
  height:34px;
  padding:0 13px;
  border-radius:9px;
  border:1.5px solid var(--border);
  background:var(--surface);
  color:var(--muted);
  cursor:pointer;
  font:inherit;
  font-size:12.5px;
  font-weight:800;
  transition:background .14s,color .14s;
}
.cc-toggle:hover{background:var(--accent-soft);color:var(--accent);}
.cbody{
  width:100%;
  min-height:180px;
  resize:vertical;
  padding:13px 15px;
  border-radius:14px;
  border:1.5px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  font:inherit;
  font-size:14px;
  line-height:1.65;
  outline:none;
  transition:border-color .14s,box-shadow .14s,background .14s;
}
.cbody:focus{border-color:var(--accent);box-shadow:0 0 0 4px var(--accent-soft);background:var(--surface);}
.dropzone{
  margin-top:12px;
  height:74px;
  border:1.5px dashed var(--border-strong);
  border-radius:14px;
  background:var(--surface-2);
  color:var(--dim);
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  font-size:13px;
  font-weight:700;
  cursor:pointer;
  transition:border-color .14s,background .14s,color .14s;
}
.dropzone:hover,.dropzone.over{border-color:var(--accent);background:var(--accent-soft);color:var(--accent);}
.dropzone svg{width:19px;height:19px;}
.att-list{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px;}
.att-chip{
  display:flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--surface-2);
  font-size:12.5px;
  font-weight:700;
}
.att-chip .name{max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.att-chip button{border:none;background:transparent;color:var(--dim);cursor:pointer;padding:0;display:flex;}
.att-chip button:hover{color:var(--err);}
.att-chip svg{width:14px;height:14px;}

.confirm-sheet{max-width:460px;}
.confirm-symbol{
  width:44px;
  height:44px;
  flex:0 0 44px;
  border-radius:14px;
  background:var(--err-soft);
  color:var(--err);
  display:flex;
  align-items:center;
  justify-content:center;
}
.confirm-symbol svg{width:21px;height:21px;}
.confirm-message{color:var(--muted)!important;}
.confirm-foot{padding-top:16px;}
.btn.confirm{background:var(--err);border:none;color:#fff;box-shadow:0 6px 18px rgba(229,72,77,.32);}
.btn.confirm:hover{background:var(--err);filter:brightness(1.08);}

.toast{
  position:fixed;
  left:50%;
  bottom:24px;
  transform:translate(-50%,80px);
  z-index:200;
  display:flex;
  align-items:center;
  gap:10px;
  max-width:min(420px,calc(100vw - 32px));
  padding:12px 16px;
  border-radius:14px;
  background:var(--surface);
  border:1px solid var(--border);
  box-shadow:var(--shadow-lg);
  font-size:13.5px;
  font-weight:700;
  transition:transform .24s cubic-bezier(.34,1.4,.64,1),opacity .2s;
  opacity:0;
  pointer-events:none;
}
.toast.show{transform:translate(-50%,0);opacity:1;}
.toast svg{width:17px;height:17px;flex:0 0 17px;}
.toast.ok svg{color:var(--ok);}
.toast.err svg{color:var(--err);}
.backdrop{display:none;}
.spinner{
  width:16px;
  height:16px;
  border-radius:50%;
  border:2px solid var(--border-strong);
  border-top-color:var(--accent);
  animation:spin .7s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg);}}

/* ---------- responsive ---------- */
@media (max-width:1100px){
  .app-main{grid-template-columns:260px minmax(320px,380px) 1fr;}
  .app-main.no-accounts{grid-template-columns:260px 1fr;}
  .reader-head{padding:18px 22px;}
}
@media (max-width:900px){
  .brand-sub{display:none;}
  .app-main,.app-main.no-accounts{grid-template-columns:1fr;}
  .pane-sidebar{
    position:fixed;
    left:0;
    top:66px;
    bottom:0;
    width:288px;
    z-index:70;
    transform:translateX(-105%);
    transition:transform .22s ease;
    box-shadow:var(--shadow-lg);
  }
  .pane-sidebar.sidebar-open{transform:none;}
  .backdrop.show{
    display:block;
    position:fixed;
    inset:0;
    z-index:65;
    background:rgba(10,14,22,.45);
    animation:fade .18s;
  }
  .mobile-menu-btn{display:inline-flex;}
  .pane-list{grid-area:1/1;}
  .pane-reader{
    grid-area:1/1;
    position:absolute;
    inset:0;
    z-index:40;
    transform:translateX(105%);
    transition:transform .22s ease;
  }
  .pane-reader.reader-open{transform:none;}
  .reader-back{display:inline-flex;}
}
@media (max-width:720px){
  .topbar{padding:0 12px;gap:8px;}
  .add-label{display:none;}
  #addBtn{padding:0 13px;}
  .language-label{display:none;}
  .acct-chip{max-width:180px;}
  .reader-head{padding:16px 18px;}
  .reader-subject{font-size:19px;-webkit-line-clamp:2;}
  .reader-body{padding:20px 14px;}
  .email-sheet.text{padding:20px 18px;}
  .list-toolbar{padding:14px 14px 12px;}
  .list-title{font-size:18px;}
  .msg{padding:12px 13px;}
  .overlay{padding:14px;}
  .sheet-head{padding:18px 18px 12px;}
  .sheet-body{padding:14px 18px 18px;}
  .sheet-foot{padding:12px 18px 18px;}
  .creds-controls{align-items:stretch;flex-direction:column;}
  .creds-controls .btn{width:100%;}
  .cfield{grid-template-columns:64px 1fr;}
  .cfield .cc-toggle{grid-column:2;}
  .reader-actions .icon-btn{padding:0 9px;min-width:38px;}
}
@media (max-width:480px){
  .brand-name{font-size:16px;}
  .logo,.logo svg{width:36px;height:36px;}
  .acct-chip{max-width:150px;}
  .acct-chip .ac-copy{display:none;}
  .theme-row{font-size:13px;}
  .reader-subject{font-size:17px;}
  .reader-meta{gap:10px;}
  .reader-date{font-size:11.5px;}
  .sheet-foot{flex-wrap:wrap;}
  .sheet-foot .hint{flex:1 1 100%;text-align:center;}
  .msg-avatar{flex-basis:36px;width:36px;height:36px;}
}
