:root{--accent:#3a6d96;--accent-hover:color-mix(in srgb,var(--accent) 80%,#000);--accent-dark:var(--accent);--accent-text:color-mix(in srgb,var(--accent) 85%,#000);--accent-soft:color-mix(in srgb,var(--accent) 16%,#fff);--sel:color-mix(in srgb,var(--accent) 12%,#fff);--side:#1f2328;--side-hover:#2b3036}
*{box-sizing:border-box}
:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
input:focus,select:focus,textarea:focus{outline:2px solid var(--accent);outline-offset:0;border-color:var(--accent)}
a{color:var(--accent-text)}
button[type=submit]:hover,#composebtn:hover{background:var(--accent-hover)!important}
#side select{background:#2b3036;color:#e6e9ed;border-color:#3d434a}
.filters{color:#c4c9cf}.filters input{accent-color:var(--accent)}
input[type=checkbox]{accent-color:var(--accent)}
*{scrollbar-color:#9aa4ae transparent}#side{scrollbar-color:#4a525b transparent}
html,body{height:100%;margin:0}
body{font:14px/1.4 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;color:#1d2330;background:#f3f4f7}
.hidden{display:none!important}button,.btn{font:inherit;border:1px solid #c9ced8;background:#fff;border-radius:6px;padding:5px 10px;cursor:pointer;color:inherit;text-decoration:none;white-space:nowrap}
button:hover,.btn:hover{background:#eef1f6}button[type=submit],#composebtn{background:var(--accent);color:#fff;border-color:var(--accent)}
button.ghost,.btn.ghost{background:transparent}.icon{padding:4px 9px}
input,select,textarea{font:inherit;border:1px solid #c9ced8;border-radius:6px;padding:6px 8px;background:#fff;color:inherit}
#login{display:flex;align-items:center;justify-content:center;height:100%}
.card{background:#fff;border-radius:10px;box-shadow:0 4px 24px rgba(0,0,0,.12);padding:24px;display:flex;flex-direction:column;gap:12px;width:340px;max-width:94vw}
.card label{display:flex;flex-direction:column;gap:4px;font-size:12px;color:#556}.card h1{margin:0 0 6px;font-size:22px;color:var(--accent)}
.err{color:#c0392b;min-height:1em}
#app{display:flex;flex-direction:column;height:100%}
header{display:flex;gap:8px;align-items:center;padding:8px 12px;background:#fff;border-bottom:1px solid #dde1e8}
.brand{font-weight:700;color:var(--accent);margin-right:8px}#searchform{flex:1}#search{width:100%;max-width:520px}
#menubtn{display:none}
main{flex:1;display:flex;min-height:0}
#side{width:210px;background:var(--side);color:#e6e9ed;border-right:1px solid #15181c;padding:10px;overflow:auto;flex-shrink:0}
#acct{width:100%;margin-bottom:8px}#folders{list-style:none;margin:0;padding:0}
#folders li{padding:6px 8px;border-radius:6px;cursor:pointer;display:flex;justify-content:space-between}
#folders li:hover{background:var(--side-hover)}#folders li.on{background:var(--accent-dark);color:#fff;font-weight:600}
#folders .cnt{font-size:11px;background:var(--accent);color:#fff;border-radius:9px;padding:0 6px;font-weight:600}.filters{margin-top:12px;font-size:13px;display:flex;flex-direction:column;gap:4px}
#list{width:420px;border-right:1px solid #dde1e8;display:flex;flex-direction:column;background:#fff;min-width:0;flex-shrink:0}
.toolbar{display:flex;gap:4px;align-items:center;padding:6px;border-bottom:1px solid #eee;flex-wrap:wrap}
.toolbar button,.toolbar select{padding:3px 7px;font-size:12px}#pager{margin-left:auto;display:flex;align-items:center;gap:4px;font-size:12px}
#listtitle{padding:4px 10px;font-size:12px;color:#778}
#msgs{list-style:none;margin:0;padding:0;overflow:auto;flex:1}
#msgs li{display:grid;grid-template-columns:22px 1fr auto;gap:2px 8px;padding:8px 10px;border-bottom:1px solid #f0f1f4;cursor:pointer}
#msgs li:hover{background:#f7f8fb}#msgs li.on{background:var(--sel)}#msgs li.unread .from,#msgs li.unread .subj{font-weight:700}
#msgs li.unread{border-left:3px solid var(--accent)}
#msgs .from{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#msgs .date{font-size:12px;color:#778;white-space:nowrap}
#msgs .subj{grid-column:2/3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#334}
#msgs .acc{grid-column:2/3;font-size:11px;color:#99a}#msgs .flag{color:#e67e22}
#msgs input{grid-row:1/3;margin-top:3px}.empty-list{padding:20px;color:#889;text-align:center}
#reader{flex:1;display:flex;flex-direction:column;min-width:0;background:#fff}
#rempty{margin:auto;color:#99a}#rcontent{display:flex;flex-direction:column;height:100%;padding:12px 16px;gap:6px}
.rbar{display:flex;gap:4px;flex-wrap:wrap}.rbar button,.rbar .btn{font-size:12px;padding:3px 8px}
#rback{display:none}#rsubj{margin:6px 0 0;font-size:19px}#rmeta{font-size:13px;color:#556}
#ratts a{display:inline-block;margin:2px 6px 2px 0;padding:3px 8px;background:#f0f1f5;border-radius:12px;font-size:12px;color:#334;text-decoration:none}
.notice{background:#fff6dd;border:1px solid #f0dc9a;padding:5px 10px;border-radius:6px;font-size:13px}
.rtabs button{font-size:12px;padding:2px 8px}.rtabs .on{background:var(--accent-soft)}
#rframe{flex:1;border:1px solid #eee;border-radius:6px;width:100%;min-height:300px;background:#fff}
#rtext{flex:1;overflow:auto;white-space:pre-wrap;word-wrap:break-word;font:13px/1.5 ui-monospace,Menlo,Consolas,monospace;margin:0;border:1px solid #eee;border-radius:6px;padding:10px}
#compose{position:fixed;inset:0;background:rgba(20,24,28,.45);display:flex;align-items:center;justify-content:center;z-index:10}
.card.wide{width:760px;max-height:96vh;overflow:auto;gap:8px}.chead{display:flex;justify-content:space-between;align-items:center}
.card label{flex-direction:row;align-items:center}.card label>input,.card label>select{flex:1}.card label{gap:8px}
#loginform label{flex-direction:column;align-items:stretch}
.card.wide label{font-size:13px}.card.wide label>*:first-child{flex:1}
#cbody{width:100%;font:13px/1.5 ui-monospace,Menlo,Consolas,monospace;resize:vertical}
.crow{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.hint{font-size:12px;color:#99a;margin-left:auto}
#toast{position:fixed;bottom:18px;left:50%;transform:translateX(-50%);background:#222;color:#fff;padding:8px 16px;border-radius:8px;z-index:20}
@media (max-width:900px){
 #menubtn{display:inline-block}.brand{display:none}#logoutbtn{display:none}
 #side{position:fixed;top:49px;bottom:0;left:0;z-index:5;box-shadow:2px 0 12px rgba(0,0,0,.2);transform:translateX(-105%);transition:transform .15s}
 body.side-open #side{transform:none}
 #list{width:100%;border-right:0}#reader{display:none}
 body.reading #list{display:none}body.reading #reader{display:flex}#rback{display:inline-block}
 .card.wide{width:100vw;max-height:100vh;height:100vh;border-radius:0}
}

.themesw{display:inline-flex;border:1px solid #c9ced8;border-radius:6px;overflow:hidden;flex-shrink:0}
.themesw button{border:0;border-radius:0;padding:4px 8px;font-size:12px;background:transparent;line-height:1.2}
.themesw button+button{border-left:1px solid #c9ced8}
.themesw button[aria-pressed=true]{background:var(--accent);color:#fff}
#loginform .themesw{align-self:center}
/* ---------- dark theme ---------- */
html[data-theme=dark]{--accent-hover:color-mix(in srgb,var(--accent) 85%,#fff);--accent-text:color-mix(in srgb,var(--accent) 50%,#fff);--accent-soft:color-mix(in srgb,var(--accent) 30%,#22262b);--sel:color-mix(in srgb,var(--accent) 24%,#22262b)}
html[data-theme=dark] body{background:#181b1f;color:#e6e8eb}
html[data-theme=dark] a{color:var(--accent-text)}
html[data-theme=dark] header,html[data-theme=dark] #list,html[data-theme=dark] #reader,html[data-theme=dark] .card{background:#22262b;border-color:#30363d}
html[data-theme=dark] #list,html[data-theme=dark] header{border-color:#30363d}
html[data-theme=dark] .brand,html[data-theme=dark] .card h1{color:var(--accent-text)}
html[data-theme=dark] button,html[data-theme=dark] .btn{background:#2b3036;border-color:#3d444c;color:#e6e8eb}
html[data-theme=dark] button:hover,html[data-theme=dark] .btn:hover{background:#353b42}
html[data-theme=dark] button[type=submit],html[data-theme=dark] #composebtn{background:var(--accent);border-color:var(--accent);color:#fff}
html[data-theme=dark] button.ghost,html[data-theme=dark] .btn.ghost,html[data-theme=dark] .themesw button{background:transparent}
html[data-theme=dark] .themesw,html[data-theme=dark] .themesw button+button{border-color:#3d444c}
html[data-theme=dark] .themesw button[aria-pressed=true]{background:var(--accent);color:#fff}
html[data-theme=dark] input,html[data-theme=dark] select,html[data-theme=dark] textarea{background:#181b1f;border-color:#3d444c;color:#e6e8eb}
html[data-theme=dark] .card label,html[data-theme=dark] #rmeta,html[data-theme=dark] #listtitle,html[data-theme=dark] #msgs .date{color:#a9b1ba}
html[data-theme=dark] #msgs li{border-color:#2c3137}html[data-theme=dark] #msgs li:hover{background:#2a2f35}
html[data-theme=dark] #msgs li.on{background:var(--sel)}html[data-theme=dark] #msgs .subj{color:#d0d5db}
html[data-theme=dark] #msgs .acc,html[data-theme=dark] .empty-list,html[data-theme=dark] #rempty,html[data-theme=dark] .hint{color:#8b949e}
html[data-theme=dark] #msgs li.unread{border-left-color:var(--accent-text)}html[data-theme=dark] #msgs .flag{color:#f0a04b}
html[data-theme=dark] .toolbar{border-color:#30363d}
html[data-theme=dark] #ratts a{background:#2b3036;color:#e6e8eb}
html[data-theme=dark] .notice{background:#3a3220;border-color:#6b5a2a;color:#f1e3b8}
html[data-theme=dark] .rtabs .on{background:var(--accent);color:#fff}
html[data-theme=dark] #rframe{border-color:#30363d;background:#fff}
html[data-theme=dark] #rtext{background:#181b1f;color:#e6e8eb;border-color:#30363d}
html[data-theme=dark] .err{color:#ff7b72}
html[data-theme=dark] #toast{background:#e6e8eb;color:#181b1f}
html[data-theme=dark] *{scrollbar-color:#4a525b #181b1f}
html[data-theme=dark] :focus-visible,html[data-theme=dark] input:focus,html[data-theme=dark] select:focus,html[data-theme=dark] textarea:focus{outline-color:var(--accent-text);border-color:var(--accent-text)}
@media (max-width:900px){.themesw button{padding:4px 6px}}

/* ---------- per-account colours ---------- */
.adot{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:6px;vertical-align:1px;flex-shrink:0}
#msgs li[data-c]{box-shadow:inset 4px 0 0 var(--rowc)}
#msgs li.unread[data-c]{border-left-color:var(--rowc)}
#acct{border-left:6px solid var(--accent)}
#cfrom{border-left:6px solid var(--accent)}
#settings{position:fixed;inset:0;background:rgba(20,24,28,.45);display:flex;align-items:center;justify-content:center;z-index:12}
#settings .row{display:flex;align-items:center;gap:10px;font-size:14px}
#settings .row>span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#settings input[type=color]{width:44px;height:30px;padding:2px;cursor:pointer}
#settings .sw{display:flex;gap:4px;flex-wrap:wrap}
#settings .sw button{width:20px;height:20px;padding:0;border-radius:50%;border:2px solid transparent}
#folders .cnt:empty{display:none}
#settings .card{width:640px}
#settings .row>span{min-width:180px}
@media (max-width:700px){#settings .row{flex-wrap:wrap}#settings .row>span{min-width:100%}}

/* ---------- row quick actions ---------- */
#msgs .ract{grid-column:3;grid-row:2/4;justify-self:end;align-self:end;display:flex;gap:2px;margin:2px -4px -2px 0}
#msgs .ia{background:transparent;border:0;padding:0;width:26px;height:26px;display:inline-flex;align-items:center;justify-content:center;border-radius:6px;color:#8a929c;opacity:.75}
#msgs li:hover .ia,#msgs li:focus-within .ia{opacity:1}
#msgs .ia:hover,#msgs .ia:focus-visible{color:var(--accent-text);background:var(--accent-soft);opacity:1}
#msgs .ia[data-ra=trash]:hover{color:#c0392b}
html[data-theme=dark] #msgs .ia{background:transparent;color:#8b949e}
html[data-theme=dark] #msgs .ia:hover,html[data-theme=dark] #msgs .ia:focus-visible{color:var(--accent-text);background:var(--accent-soft)}
html[data-theme=dark] #msgs .ia[data-ra=trash]:hover{color:#ff7b72}
@media (pointer:coarse),(max-width:900px){#msgs .ia{width:34px;height:34px;opacity:1}#msgs .ia svg{width:18px;height:18px}#msgs .ract{gap:4px}}
.hasic{display:inline-flex;align-items:center;gap:5px}.hasic svg{flex-shrink:0}
@media (max-width:900px){.rbar .hasic .bl{display:none}.rbar .hasic{padding:5px 8px}}
#toast button{margin-left:10px;background:transparent;color:inherit;border-color:currentColor;padding:2px 10px}
/* folder icons */
#folders .fname{display:inline-flex;align-items:center;gap:8px;min-width:0}
#folders .fname svg{opacity:.85;flex-shrink:0}
#folders li{align-items:center}
#folders li:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
