:root {
  --bg: #f5f6fb;
  --panel: #ffffff;
  --panel-2: #fafbfd;
  --rail-bg: #f0f1f7;
  --line: #ebecf3;
  --line-2: #e3e5ef;
  --text: #14161d;
  --text-2: #2b2f3a;
  --muted: #888fa3;
  --muted-2: #aab0c0;
  --hover: #eef0f6;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --unread: #f4f6ff;
  --on-accent: #ffffff;
  --danger: #e5484d;
  --danger-soft: #fde7e8;
  --badge-bg: #eceefb;
  --badge-text: #5b62c9;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --grad-accent: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --shadow-sm: 0 1px 2px rgba(20,22,40,.06), 0 1px 3px rgba(20,22,40,.05);
  --shadow-md: 0 4px 16px rgba(28,30,60,.10), 0 1px 4px rgba(28,30,60,.06);
  --shadow-lg: 0 18px 50px rgba(28,28,70,.22);
  --shadow-glow: 0 8px 22px rgba(99,102,241,.38);
  --glass: rgba(255,255,255,.82);
  --scroll: #d2d6e0;
  --scroll-hover: #b4bac8;
}
:root[data-theme="dark"] {
  --bg: #0e1016;
  --panel: #161a23;
  --panel-2: #1a1f2a;
  --rail-bg: #11141c;
  --line: #242a36;
  --line-2: #2d3340;
  --text: #e8eaf1;
  --text-2: #c4c8d4;
  --muted: #8a92a6;
  --muted-2: #5f6779;
  --hover: #20262f;
  --accent: #7c83ff;
  --accent-2: #a78bfa;
  --accent-soft: #20233a;
  --unread: #181d2e;
  --on-accent: #ffffff;
  --danger: #ff6b6b;
  --danger-soft: #2a1a1e;
  --badge-bg: #262a44;
  --badge-text: #aab1ff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 20px rgba(0,0,0,.45);
  --shadow-lg: 0 22px 60px rgba(0,0,0,.6);
  --shadow-glow: 0 8px 24px rgba(99,102,241,.35);
  --glass: rgba(22,26,35,.8);
  --scroll: #2e3543;
  --scroll-hover: #3d4555;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Minimalist scrollbars — Chrome/Edge/Safari via pseudo-elements */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll); border-radius: 999px;
  border: 3.5px solid transparent; background-clip: content-box;
  transition: background .15s;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }
/* Firefox (no ::-webkit-scrollbar support) */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
}

html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14.5px; overflow: hidden;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; letter-spacing: -0.01em;
  transition: background-color .25s ease, color .25s ease;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
.ico-svg { display: block; flex: none; }
[data-icon] { display: inline-flex; align-items: center; }

/* ---------- Auth screens ---------- */
.auth {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(124,58,237,.55), transparent 60%),
    radial-gradient(1000px 700px at 110% 110%, rgba(56,189,248,.40), transparent 55%),
    linear-gradient(135deg, #4f46e5, #312e81);
}
.auth.hidden, .app.hidden { display: none; }
.theme-fab { position: fixed; top: 18px; right: 18px; width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.16); color: #fff; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); transition: background .15s; }
.theme-fab:hover { background: rgba(255,255,255,.28); }
.card {
  position: relative; background: var(--glass); backdrop-filter: blur(20px);
  width: 100%; max-width: 410px; border-radius: 22px; padding: 34px 30px 30px;
  box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,.16); text-align: center;
}
.logo-badge { width: 60px; height: 60px; border-radius: 18px; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; box-shadow: var(--shadow-glow); }
.card h1 { margin: 0 0 6px; font-size: 23px; font-weight: 800; letter-spacing: -0.03em; }
.card .sub { color: var(--muted); margin: 0 0 22px; font-size: 13.5px; }
.field { margin-bottom: 13px; text-align: left; }
.field label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line-2); border-radius: 11px;
  background: var(--panel-2); outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus, .field select:focus { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 4px var(--accent-soft); }
.btn {
  width: 100%; padding: 13px; border-radius: 12px; background: var(--grad-accent);
  color: #fff; font-weight: 600; font-size: 14.5px; margin-top: 8px; box-shadow: var(--shadow-glow);
  transition: transform .12s, box-shadow .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(99,102,241,.45); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .6; cursor: default; transform: none; box-shadow: none; }
.linkbtn { color: var(--accent); font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; padding: 7px 0; }
.linkbtn:hover { color: var(--accent-2); }
.back-link { position: absolute; top: 18px; left: 18px; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 500; }
.back-link:hover { color: var(--text); }
.err { color: var(--danger); font-size: 12.5px; min-height: 17px; margin: 6px 0 0; text-align: left; }
.detect { font-size: 12px; min-height: 16px; margin: 2px 0 6px; color: var(--muted); text-align: left; line-height: 1.5; }
.detect.ok { color: #0c8a5b; }
.detect.busy { color: var(--accent); }
.oauth-box { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.oauth-box.hidden, .oauth-sep.hidden { display: none; }
.oauth-btn { display: flex; align-items: center; justify-content: center; gap: 11px; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--panel); font-weight: 600; font-size: 14px; color: var(--text); transition: border-color .15s, background .15s; }
.oauth-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.oauth-btn svg { flex: none; }
.oauth-sep { display: flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: 12px; margin: 16px 0 14px; }
.oauth-sep::before, .oauth-sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.prov-help { background: var(--accent-soft); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; margin: 4px 0 10px; font-size: 12.5px; line-height: 1.55; color: var(--text-2); text-align: left; }
.prov-help.hidden { display: none; }
.prov-help b { color: var(--text); }
.prov-help a { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--accent); font-weight: 600; text-decoration: none; padding: 7px 12px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line-2); }
.prov-help a:hover { border-color: var(--accent); }
.advanced { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 14px; }
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1; }
.row2 .field:last-child { max-width: 92px; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 300px 360px 1fr; height: 100%; }
.sidebar { display: flex; min-width: 0; border-right: 1px solid var(--line); }
.list { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.reader { background: var(--panel); overflow: hidden; display: flex; flex-direction: column; }

/* Account rail */
.rail { width: 70px; flex: none; background: var(--rail-bg); display: flex; flex-direction: column; align-items: center; padding: 14px 0 12px; gap: 8px; border-right: 1px solid var(--line); }
.rail-logo { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-glow); margin-bottom: 6px; }
.rail-accounts { display: flex; flex-direction: column; align-items: center; gap: 9px; flex: 1; overflow-y: auto; width: 100%; padding: 2px 0; }
.rail-accounts::-webkit-scrollbar { width: 0; }
.rail-acct { position: relative; width: 44px; height: 44px; border-radius: 14px; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; transition: transform .12s, border-radius .15s; box-shadow: var(--shadow-sm); }
.rail-acct:hover { transform: translateY(-1px); border-radius: 12px; }
.rail-acct.active { border-radius: 13px; box-shadow: 0 0 0 2px var(--rail-bg), 0 0 0 4px var(--accent); }
.rail-acct.active::before { content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%); width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--accent); }
.rail-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--rail-bg); }
.rail-add { width: 44px; height: 44px; border-radius: 14px; flex: none; display: flex; align-items: center; justify-content: center; color: var(--muted); border: 1.5px dashed var(--line-2); transition: color .12s, border-color .12s, background .12s; }
.rail-add:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.rail-bottom { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.rail-btn { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--muted); transition: background .12s, color .12s; }
.rail-btn:hover { background: var(--hover); color: var(--text); }

/* Folder column */
.folders { flex: 1; min-width: 0; background: var(--panel-2); display: flex; flex-direction: column; overflow-y: auto; }
.acct-head { display: flex; align-items: center; gap: 11px; padding: 16px 16px 12px; min-width: 0; }
.acct-head .avatar { width: 38px; height: 38px; border-radius: 11px; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; box-shadow: var(--shadow-sm); }
.acct-head-main { min-width: 0; }
.acct-head-label { font-size: 11px; font-weight: 600; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; }
.acct-head-email { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.02em; }
.acct-head-remove { flex: none; width: 32px; height: 32px; opacity: 0; transition: opacity .12s, color .12s, background .12s; }
.acct-head:hover .acct-head-remove { opacity: 1; }
.acct-head-remove:hover { background: var(--danger-soft); color: var(--danger); }

.compose-btn {
  margin: 2px 14px 12px; padding: 12px; border-radius: 13px; background: var(--grad-accent);
  color: #fff; font-weight: 600; box-shadow: var(--shadow-glow); display: flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .12s, box-shadow .15s;
}
.compose-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(99,102,241,.42); }

#folderNav { padding: 4px 10px 14px; flex: 1; }
.folder {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; border-radius: 11px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500; margin-bottom: 1px; transition: background .12s, color .12s;
}
.folder:hover { background: var(--hover); color: var(--text); }
.folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.folder .ico { width: 19px; height: 19px; display: flex; align-items: center; justify-content: center; color: inherit; opacity: .9; }
.folder .count { margin-left: auto; font-size: 11px; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 9px; background: var(--badge-bg); color: var(--badge-text); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.folder.active .count { background: var(--accent); color: #fff; }

/* List */
.list-head { position: sticky; top: 0; background: var(--glass); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); padding: 13px 14px; display: flex; align-items: center; gap: 8px; z-index: 5; }
.list-head .title { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.list-count { font-size: 12px; color: var(--muted-2); font-weight: 600; }
.iconbtn { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--muted); transition: background .12s, color .12s; flex: none; }
.iconbtn:hover { background: var(--hover); color: var(--text); }
.list-head .sort-wrap { margin-left: auto; position: relative; }
.iconbtn.on { background: var(--accent-soft); color: var(--accent); }
.back { display: none; }

.sort-menu { position: absolute; top: 44px; right: 0; z-index: 30; background: var(--panel); border: 1px solid var(--line-2); border-radius: 13px; box-shadow: var(--shadow-md); padding: 6px; min-width: 220px; animation: fade .12s; }
.sort-menu.hidden { display: none; }
.sort-menu .sort-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); padding: 7px 10px 5px; }
.sort-opt { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text-2); width: 100%; text-align: left; }
.sort-opt:hover { background: var(--hover); color: var(--text); }
.sort-opt .ck { width: 17px; flex: none; color: var(--accent); display: inline-flex; opacity: 0; }
.sort-opt.active { color: var(--accent); font-weight: 600; }
.sort-opt.active .ck { opacity: 1; }

.msg { display: flex; gap: 12px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--line); position: relative; transition: background .1s; }
.msg:hover { background: var(--panel-2); }
.msg.active { background: var(--accent-soft); }
.msg.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.msg.unread { background: var(--unread); }
.msg.unread .msg-from, .msg.unread .msg-subj { font-weight: 700; color: var(--text); }
.msg-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; box-shadow: var(--shadow-sm); }
.msg-main { flex: 1; min-width: 0; }
.msg-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-from { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 14px; color: var(--text-2); }
.msg-date { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; font-weight: 500; }
.msg-subj { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.msg-subj .badge { color: var(--muted-2); display: inline-flex; flex: none; }
.msg-subj .badge.star { color: #f5a623; }
.msg-dot { position: absolute; right: 14px; bottom: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--unread); }
.empty { padding: 50px 24px; text-align: center; color: var(--muted-2); font-size: 13.5px; }

/* Reader */
#readerContent { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.reader-head { display: flex; align-items: center; gap: 6px; padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(12px); z-index: 5; flex: none; }
.reader-head .grow { flex: 1; }
.reader-inner { padding: 24px 40px 22px; max-width: 1180px; width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.r-subject { font-size: 23px; font-weight: 700; margin: 0 0 18px; letter-spacing: -0.025em; line-height: 1.25; flex: none; }
.r-from { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex: none; }
.r-from .msg-avatar { width: 44px; height: 44px; font-size: 16px; }
.r-from-main { min-width: 0; }
.r-from-name { font-weight: 600; font-size: 14.5px; }
.r-from-to { color: var(--muted); font-size: 12.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-date { margin-left: auto; color: var(--muted-2); font-size: 12.5px; white-space: nowrap; flex: none; }
.r-cc { color: var(--muted); font-size: 12.5px; margin: -8px 0 14px 56px; flex: none; }
.r-body { flex: 1; min-height: 0; overflow-y: auto; margin-top: 12px; line-height: 1.65; color: var(--text-2); }
.r-body iframe { display: block; width: 100%; height: 100%; border: none; background: #fff; }
:root[data-theme="dark"] .r-body iframe { border-radius: 10px; }
.r-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.7; color: var(--text); }
.attachments { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-wrap: wrap; gap: 9px; flex: none; }
.att { display: inline-flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1.5px solid var(--line-2); border-radius: 11px; text-decoration: none; color: var(--text); font-size: 13px; font-weight: 500; transition: border-color .12s, background .12s; }
.att:hover { background: var(--accent-soft); border-color: var(--accent); }
.att .att-ico { color: var(--accent); display: inline-flex; }
.placeholder { display: flex; height: 100%; align-items: center; justify-content: center; color: var(--muted-2); flex-direction: column; gap: 14px; font-size: 14px; }
.ph-icon { width: 76px; height: 76px; border-radius: 22px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }

/* Compose modal */
.modal { position: fixed; inset: 0; background: rgba(8,9,16,.5); backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .15s; }
.modal.hidden { display: none; }
@keyframes fade { from { opacity: 0; } }
.composer { background: var(--panel); width: 100%; max-width: 660px; border-radius: 20px 20px 0 0; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slideup .22s cubic-bezier(.2,.8,.2,1); }
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } }
.composer .chead { padding: 15px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px; display: flex; align-items: center; }
.composer .chead .iconbtn { margin-left: auto; }
.composer .cbody { padding: 4px 20px; overflow-y: auto; }
.composer .cfield { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.composer .cfield span { color: var(--muted); width: 64px; font-size: 13px; font-weight: 500; }
.composer .cfield input { flex: 1; border: none; outline: none; padding: 13px 4px; background: none; }
.composer #composeFrom { color: var(--muted); }
.composer textarea { width: 100%; border: none; outline: none; padding: 16px 4px; min-height: 230px; resize: vertical; background: none; line-height: 1.6; color: var(--text); }
.composer .cfoot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.composer .cfoot .send { background: var(--grad-accent); color: #fff; padding: 11px 24px; border-radius: 12px; font-weight: 600; display: flex; gap: 8px; align-items: center; box-shadow: var(--shadow-glow); transition: transform .12s; }
.composer .cfoot .send:hover { transform: translateY(-1px); }
.composer .cfoot .send:disabled { opacity: .6; transform: none; }
.composer .cfoot .save { color: var(--muted); font-weight: 500; font-size: 13.5px; }
.composer .cfoot .save:hover { color: var(--text); }

/* Blacklist manager */
.bl-hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 10px 0 14px; }
.bl-hint code { background: var(--hover); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.bl-add { display: flex; gap: 8px; margin-bottom: 14px; }
.bl-add input { flex: 1; padding: 11px 13px; border: 1.5px solid var(--line-2); border-radius: 11px; background: var(--panel-2); outline: none; transition: border-color .15s, box-shadow .15s; }
.bl-add input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.bl-add button { display: flex; align-items: center; gap: 6px; padding: 0 16px; border-radius: 11px; background: var(--grad-accent); color: #fff; font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.bl-list { display: flex; flex-direction: column; gap: 6px; max-height: 26vh; overflow-y: auto; }
.bl-section { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 6px; }
.bl-section-title { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 700; margin-top: 10px; letter-spacing: -0.01em; }
.bl-section-title [data-icon] { color: var(--accent); }
.bl-item .bl-ico.kw { color: var(--accent); }
.bl-empty { color: var(--muted-2); font-size: 13px; text-align: center; padding: 26px 0; }
.bl-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); }
.bl-item .bl-ico { color: var(--danger); display: inline-flex; flex: none; }
.bl-item .bl-val { flex: 1; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-item .bl-del { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); transition: background .12s, color .12s; }
.bl-item .bl-del:hover { background: var(--danger-soft); color: var(--danger); }
.composer .cfoot .apply { color: var(--accent); font-weight: 600; font-size: 13.5px; }
.composer .cfoot .apply:hover { color: var(--accent-2); }
.kw-pick { display: flex; align-items: center; gap: 8px; margin-bottom: 11px; flex-wrap: wrap; }
.kw-pick-label { font-size: 12.5px; color: var(--muted); font-weight: 600; flex: none; }
.kw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-chip { display: flex; align-items: center; gap: 7px; padding: 4px 11px 4px 4px; border-radius: 999px; border: 1.5px solid var(--line-2); cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--muted); transition: border-color .12s, background .12s, color .12s; }
.kw-chip .av { width: 22px; height: 22px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 11px; }
.kw-chip.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.kw-mb { display: flex; align-items: center; gap: 3px; flex: none; margin-right: 2px; }
.kw-mb .av { width: 19px; height: 19px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 9.5px; box-shadow: 0 0 0 1.5px var(--panel); }
.kw-mb .all { font-size: 11px; color: var(--muted-2); font-weight: 600; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px); background: #1b1d29; color: #fff; padding: 12px 20px; border-radius: 13px; font-size: 13.5px; font-weight: 500; z-index: 100; box-shadow: var(--shadow-md); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
:root[data-theme="dark"] .toast { background: #2a2f3d; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

.spinner { width: 22px; height: 22px; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .65s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  body { font-size: 15px; }
  .app { grid-template-columns: 1fr; grid-template-rows: 100%; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 300px; z-index: 40; transform: translateX(-105%); transition: transform .24s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow-lg); background: var(--panel-2); }
  body.drawer .sidebar { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; background: rgba(8,9,16,.45); z-index: 35; display: none; }
  body.drawer .scrim { display: block; animation: fade .15s; }
  .list, .reader { grid-row: 1; grid-column: 1; }
  .reader { transform: translateX(100%); transition: transform .24s cubic-bezier(.2,.8,.2,1); z-index: 20; }
  body[data-view="reader"] .reader { transform: translateX(0); }
  .back { display: flex; }
  .reader-inner { padding: 18px 18px 50px; }
  .r-subject { font-size: 21px; }
  .composer { max-width: 100%; border-radius: 18px 18px 0 0; max-height: 100%; }
  .modal { align-items: stretch; }
}
@media (min-width: 901px) {
  .menu-btn { display: none; }
  .scrim { display: none !important; }
}
