/* Webmail — premium UI, light + dark */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --accent: #2557d6;
    --accent-dark: #1e46b0;
    --accent-grad: var(--accent);
    --accent-soft: color-mix(in srgb, var(--accent) 9%, transparent);

    --bg: #f4f5f8;
    --bg-grad: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #f7f8fd;
    --border: #e5e8f2;
    --text: #171a21;
    --text-dim: #5d6472;
    --text-muted: #9aa1b1;
    --read-bg: #f2f4f8;
    --unread-bg: #ffffff;
    --hover-row: color-mix(in srgb, var(--accent) 5%, transparent);
    --selected-row: color-mix(in srgb, var(--accent) 10%, transparent);
    --shadow-1: 0 1px 3px rgba(23,26,33,.09);
    --shadow-2: 0 6px 24px rgba(23,26,33,.12);
    --shadow-3: 0 16px 60px rgba(23,26,33,.22);
    --glass: rgba(255,255,255,.86);
    --danger: #dc2626;
    --danger-dim: #fdecea;
    --star: #f59e0b;
    --radius: 14px;
    --radius-sm: 9px;
}

:root[data-theme="dark"] {
    --accent: #6b9fff;
    --accent-dark: #4d86f0;
    --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
    --bg: #101216;
    --bg-grad: #101216;
    --surface: #181b21;
    --surface-2: #1e222a;
    --border: #272c35;
    --text: #e7e9ee;
    --text-dim: #9ba2b0;
    --text-muted: #636a78;
    --read-bg: #15181e;
    --unread-bg: #1a1e26;
    --hover-row: color-mix(in srgb, var(--accent) 6%, transparent);
    --selected-row: color-mix(in srgb, var(--accent) 13%, transparent);
    --shadow-1: 0 1px 3px rgba(0,0,0,.5);
    --shadow-2: 0 6px 24px rgba(0,0,0,.5);
    --shadow-3: 0 16px 60px rgba(0,0,0,.65);
    --glass: rgba(23,26,35,.9);
    --danger: #f87171;
    --danger-dim: rgba(220,38,38,.15);
}

/* Accent palettes — each defines light + dark variants; tints derive via color-mix */
:root[data-accent="teal"]     { --accent: #0d9488; --accent-dark: #0b7a70; }
:root[data-accent="green"]    { --accent: #15803d; --accent-dark: #116632; }
:root[data-accent="purple"]   { --accent: #7c3aed; --accent-dark: #6527d0; }
:root[data-accent="rose"]     { --accent: #be185d; --accent-dark: #9a1249; }
:root[data-accent="orange"]   { --accent: #c2410c; --accent-dark: #9a3410; }
:root[data-accent="red"]      { --accent: #dc2626; --accent-dark: #b91c1c; }
:root[data-accent="graphite"] { --accent: #4b5563; --accent-dark: #374151; }

:root[data-theme="dark"][data-accent="teal"]     { --accent: #31b8a9; --accent-dark: #219e90; }
:root[data-theme="dark"][data-accent="green"]    { --accent: #4bc879; --accent-dark: #2ea85c; }
:root[data-theme="dark"][data-accent="purple"]   { --accent: #a78bfa; --accent-dark: #8b6cf2; }
:root[data-theme="dark"][data-accent="rose"]     { --accent: #f472b6; --accent-dark: #ec4899; }
:root[data-theme="dark"][data-accent="orange"]   { --accent: #fb923c; --accent-dark: #f97316; }
:root[data-theme="dark"][data-accent="red"]      { --accent: #f87171; --accent-dark: #ef4444; }
:root[data-theme="dark"][data-accent="graphite"] { --accent: #9ca3af; --accent-dark: #7b8494; }

html, body { height: 100%; }

body {
    font-family: 'Segoe UI Variable Text', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    background: var(--bg-grad);
    color: var(--text);
    font-size: 14px;
    overflow: hidden;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
svg { fill: currentColor; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: content-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

.glass { background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.glass-strong { background: var(--surface); }

/* ---------------------------------------------------------------- Login */

.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: var(--bg-grad);
    position: relative;
    overflow: hidden;
}

.login-card {
    position: relative;
    background: var(--glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 48px 44px 36px;
    width: 100%;
    max-width: 430px;
    box-shadow: var(--shadow-3);
    text-align: center;
    animation: rise .45s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }

.login-logo {
    width: 60px; height: 60px;
    margin: 0 auto 18px;
    border-radius: 16px;
    background: var(--accent-soft);
    display: flex; align-items: center; justify-content: center;
}
.login-logo svg { width: 30px; height: 30px; fill: var(--accent); }

.login-card h1 { font-size: 23px; font-weight: 650; margin-bottom: 6px; }
.login-sub { color: var(--text-dim); margin-bottom: 28px; font-size: 13.5px; }
.login-foot { color: var(--text-muted); margin-top: 22px; font-size: 12px; line-height: 1.5; }

.field { position: relative; margin-bottom: 16px; text-align: left; }
.field input {
    width: 100%;
    padding: 15px 14px 13px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    outline: none;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field label {
    position: absolute; left: 12px; top: 14px;
    color: var(--text-dim);
    background: var(--surface);
    padding: 0 5px;
    border-radius: 4px;
    pointer-events: none;
    transition: all .12s ease;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label { top: -8px; font-size: 11.5px; color: var(--accent); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    padding: 12px 28px;
    border-radius: 10px;
    font-weight: 600;
    width: 100%;
    transition: transform .12s, background .15s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: default; transform: none; }

.login-error {
    background: var(--danger-dim);
    color: var(--danger);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
    text-align: left;
}

/* ---------------------------------------------------------------- Topbar */

#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
    display: flex; align-items: center; gap: 20px;
    padding: 10px 18px;
}

.topbar-left { width: 226px; flex-shrink: 0; }

.brand { display: flex; align-items: center; gap: 11px; white-space: nowrap; }
.brand-mark {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: var(--accent-soft);
    display: flex; align-items: center; justify-content: center;
}
.brand-mark svg { width: 19px; height: 19px; fill: var(--accent); }
.brand-name { font-size: 18px; font-weight: 650; letter-spacing: -.2px; }

.topbar-search {
    flex: 1; max-width: 720px;
    display: flex; align-items: center; gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0 16px;
    height: 46px;
    transition: box-shadow .15s, border-color .15s;
}
.topbar-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar-search > svg { width: 19px; height: 19px; fill: var(--text-dim); flex-shrink: 0; }
.topbar-search input {
    flex: 1; border: none; outline: none; background: transparent; font-size: 14.5px; color: var(--text);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.search-clear { font-size: 18px; }

.topbar-right { margin-left: auto; position: relative; display: flex; align-items: center; gap: 4px; }

.ico-sun { display: none; }
:root[data-theme="dark"] .ico-sun { display: block; }
:root[data-theme="dark"] .ico-moon { display: none; }

.avatar-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 650;
    font-size: 15px;
    text-transform: uppercase;
    margin-left: 6px;
    transition: transform .12s;
}
.avatar-btn:hover { transform: scale(1.06); }

.account-menu {
    position: absolute;
    right: 0; top: 48px;
    width: 330px;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-3);
    z-index: 60;
    overflow: hidden;
    animation: pop .16s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }

.account-menu-list { padding: 8px 0; max-height: 300px; overflow-y: auto; }

.account-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 10px 16px; text-align: left;
}
.account-item:hover { background: var(--hover-row); }
.mini-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    color: #fff; font-weight: 650; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    text-transform: uppercase;
    flex-shrink: 0;
}
.account-item .acct-info { flex: 1; min-width: 0; }
.account-item .acct-email { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-item .acct-domain { font-size: 11.5px; color: var(--text-dim); }
.account-item .acct-active { color: var(--accent); flex-shrink: 0; }
.account-item .acct-active svg { width: 18px; height: 18px; }
.account-item .acct-unlink { color: var(--text-dim); flex-shrink: 0; visibility: hidden; padding: 4px; border-radius: 50%; }
.account-item:hover .acct-unlink { visibility: visible; }
.account-item .acct-unlink:hover { background: var(--danger-dim); color: var(--danger); }
.account-item .acct-unlink svg { width: 16px; height: 16px; }

.account-menu-actions { border-top: 1px solid var(--border); padding: 8px 0; }
.account-menu-actions button {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 10px 18px; text-align: left;
}
.account-menu-actions button:hover { background: var(--hover-row); }
.account-menu-actions svg { width: 20px; height: 20px; fill: var(--text-dim); }

/* ---------------------------------------------------------------- Layout */

.layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
    width: 226px; flex-shrink: 0;
    padding: 6px 10px 14px 14px;
    display: flex; flex-direction: column;
    overflow-y: auto;
}

.compose-btn {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 13px 24px;
    border-radius: 14px;
    font-weight: 650;
    font-size: 14px;
    box-shadow: var(--shadow-1);
    margin: 6px 0 16px;
    transition: box-shadow .15s, transform .12s;
}
.compose-btn:hover { box-shadow: var(--shadow-2); }
.compose-btn:active { transform: translateY(1px); }
.compose-btn svg { width: 19px; height: 19px; fill: var(--accent); }

.folder-list { list-style: none; }
.folder-list li button {
    display: flex; align-items: center; gap: 13px;
    width: 100%; padding: 8px 14px;
    border-radius: 12px;
    color: var(--text);
    text-align: left;
    font-size: 13.5px;
    transition: background .12s;
    position: relative;
}
.folder-list li button:hover { background: var(--hover-row); }
.folder-list li button.active {
    background: var(--accent-soft);
    font-weight: 700;
    color: var(--accent);
}
.folder-list li button.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.folder-list svg { width: 18px; height: 18px; fill: var(--text-dim); flex-shrink: 0; }
.folder-list li button.active svg { fill: var(--accent); }
.folder-list .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-list .fcount {
    font-size: 11px; color: var(--text-dim); font-weight: 700;
    background: var(--surface-2); border: 1px solid var(--border);
    padding: 1px 7px; border-radius: 9px;
}
.folder-list li button.active .fcount { color: var(--accent); background: transparent; border-color: transparent; }

.new-folder-btn {
    display: flex; align-items: center; gap: 13px;
    padding: 8px 14px; border-radius: 12px;
    color: var(--text-muted); font-size: 13px;
    margin-top: 2px;
}
.new-folder-btn:hover { background: var(--hover-row); color: var(--text-dim); }
.new-folder-btn svg { width: 18px; height: 18px; }

.storage-widget {
    margin-top: auto;
    padding: 13px 14px 11px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
}
.storage-widget:hover { box-shadow: var(--shadow-1); border-color: var(--accent); }
.storage-head { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-dim); }
.storage-head svg { width: 15px; height: 15px; fill: var(--text-dim); }
.storage-head span { font-weight: 600; }
.storage-bar { height: 6px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); margin: 9px 0 7px; overflow: hidden; }
.storage-bar-fill { height: 100%; width: 0%; background: var(--accent-grad); border-radius: 4px; transition: width .6s cubic-bezier(.2,.9,.3,1); }
.storage-manage { font-size: 11.5px; color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- Content */

.content {
    flex: 1; min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    margin: 0 14px 14px 2px;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-1);
}

#list-view, #message-view, #storage-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#list-view[hidden], #message-view[hidden], #storage-view[hidden] { display: none; }

.list-toolbar, .msg-toolbar {
    display: flex; align-items: center; gap: 4px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    min-height: 50px;
}

.cb-wrap { padding: 8px; display: flex; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.icon-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-dim);
    flex-shrink: 0;
    transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover-row); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn:disabled:hover { background: none; }

.sel-actions { display: inline-flex; gap: 2px; }
.list-status { color: var(--text-dim); font-size: 13px; margin-left: 10px; }

.empty-folder-btn {
    margin-left: 12px;
    color: var(--danger);
    font-size: 12.5px; font-weight: 600;
    padding: 6px 12px; border-radius: 8px;
    border: 1px solid transparent;
}
.empty-folder-btn:hover { background: var(--danger-dim); }

.pager { margin-left: auto; display: flex; align-items: center; gap: 2px; color: var(--text-dim); font-size: 12.5px; }
#pager-label { margin-right: 6px; }

.msg-list { flex: 1; overflow-y: auto; }

.msg-row {
    display: flex; align-items: center; gap: 2px;
    padding: 0 12px 0 6px;
    height: 44px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    background: var(--read-bg);
    position: relative;
    transition: background .1s;
}
.msg-row:hover { background: var(--hover-row); z-index: 1; }
.msg-row.unread { background: var(--unread-bg); }
.msg-row.unread::before {
    content: '';
    position: absolute; left: 0; top: 10px; bottom: 10px;
    width: 3px; border-radius: 0 3px 3px 0;
    background: var(--accent-grad);
}
.msg-row.selected { background: var(--selected-row); }
.msg-row.dragging { opacity: .45; }

.msg-row .star-btn {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    border-radius: 50%;
    flex-shrink: 0;
    transition: color .12s, transform .12s;
}
.msg-row .star-btn:hover { color: var(--text); transform: scale(1.15); }
.msg-row .star-btn.starred { color: var(--star); }
.msg-row .star-btn svg { width: 18px; height: 18px; }

.row-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    color: #fff; font-weight: 650; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    text-transform: uppercase;
    flex-shrink: 0;
    margin: 0 8px 0 4px;
}

.msg-from {
    width: 178px; flex-shrink: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 13.5px;
    padding-right: 10px;
}
.msg-row.unread .msg-from, .msg-row.unread .msg-subject { font-weight: 700; }

.msg-subject {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 13.5px;
    color: var(--text);
}
.msg-subject .snooze-tag {
    color: var(--accent); font-size: 11.5px; font-weight: 700; margin-left: 8px;
}

.msg-size { flex-shrink: 0; font-size: 12px; color: var(--text-muted); width: 64px; text-align: right; }

.msg-date {
    flex-shrink: 0;
    font-size: 12px; color: var(--text-dim);
    width: 80px; text-align: right;
}
.msg-row.unread .msg-date { color: var(--text); font-weight: 700; }

.row-actions {
    display: none;
    position: absolute; right: 8px; top: 0; bottom: 0;
    align-items: center; gap: 2px;
    background: inherit;
    padding-left: 8px;
}
.msg-row:hover .row-actions { display: flex; }
.row-actions .icon-btn { width: 32px; height: 32px; }
.row-actions .icon-btn svg { width: 17px; height: 17px; }

.msg-empty {
    text-align: center; color: var(--text-dim);
    padding: 80px 20px; font-size: 14px;
}
.msg-empty svg { width: 52px; height: 52px; fill: var(--text-muted); opacity: .5; margin-bottom: 14px; }

.loading-bar {
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 30%, var(--accent-soft) 60%);
    background-size: 200% 100%;
    animation: slide 1s linear infinite;
}
@keyframes slide { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- Message view */

.msg-detail { flex: 1; overflow-y: auto; padding: 12px 42px 44px; }
.msg-detail h1 { font-size: 21px; font-weight: 600; margin: 16px 0 18px; letter-spacing: -.2px; }

.msg-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; }
.msg-head .mini-avatar { width: 42px; height: 42px; font-size: 16px; }
.msg-head-info { flex: 1; min-width: 0; }
.msg-head-from { font-size: 14px; }
.msg-head-from b { font-weight: 700; }
.msg-head-from span { color: var(--text-dim); font-size: 12.5px; }
.msg-head-to { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }
.msg-head-date { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; }
.msg-star { color: var(--text-muted); }
.msg-star.starred { color: var(--star); }

.msg-body-frame { width: 100%; border: none; min-height: 200px; background: #fff; border-radius: 10px; }
:root[data-theme="dark"] .msg-body-frame { background: #fff; }
.msg-body-text { white-space: pre-wrap; font-size: 14px; line-height: 1.65; }

.msg-attachments {
    display: flex; flex-wrap: wrap; gap: 10px;
    border-top: 1px solid var(--border);
    margin-top: 26px; padding-top: 18px;
}
.att-chip {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 9px 13px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    max-width: 280px;
    background: var(--surface-2);
    transition: border-color .12s, box-shadow .12s;
}
.att-chip:hover { border-color: var(--accent); box-shadow: var(--shadow-1); }
.att-chip svg { width: 18px; height: 18px; fill: var(--accent); flex-shrink: 0; }
.att-chip img.att-thumb {
    width: 38px; height: 38px; object-fit: cover; border-radius: 8px; flex-shrink: 0;
}
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip .att-size { color: var(--text-dim); font-size: 11.5px; flex-shrink: 0; }

.msg-actions { margin-top: 28px; display: flex; gap: 10px; }
.msg-actions button {
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 8px 20px;
    font-weight: 600; font-size: 13px;
    color: var(--text-dim);
    display: inline-flex; align-items: center; gap: 8px;
    transition: border-color .12s, color .12s, background .12s;
}
.msg-actions button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.msg-actions button svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- Threads */

.acct-dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0; margin-right: 6px;
}
.thread-count { color: var(--text-dim); font-weight: 400; margin-left: 5px; font-size: 12.5px; }
.msg-row.unread .thread-count { font-weight: 700; }

.thread-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    background: var(--surface);
    overflow: hidden;
}
.thread-card.open { box-shadow: var(--shadow-1); }
.thread-card-head {
    display: flex; gap: 12px; align-items: center;
    padding: 11px 16px;
    cursor: pointer;
}
.thread-card-head:hover { background: var(--hover-row); }
.thread-card-head .mini-avatar { width: 34px; height: 34px; font-size: 13px; }
.thread-head-info { flex: 1; min-width: 0; }
.thread-head-from { font-size: 13.5px; font-weight: 600; }
.thread-head-from .th-folder {
    font-size: 10.5px; font-weight: 700; color: var(--accent);
    background: var(--accent-soft); border-radius: 6px; padding: 1px 7px; margin-left: 8px;
    vertical-align: 1px;
}
.thread-head-snippet {
    color: var(--text-dim); font-size: 12.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-head-date { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.thread-card-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- Scheduled */

.sched-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}
.sched-when {
    width: 170px; flex-shrink: 0;
    color: var(--accent); font-weight: 700; font-size: 12.5px;
}
.sched-when.failed { color: var(--danger); }
.sched-to { width: 200px; flex-shrink: 0; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- Storage view */

.storage-title { font-weight: 650; font-size: 15px; margin-left: 6px; flex: 1; }
.storage-detail { flex: 1; overflow-y: auto; padding: 22px 34px 40px; }

.storage-hero {
    display: flex; align-items: center; gap: 26px;
    padding: 24px 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent-soft), transparent 60%);
    margin-bottom: 22px;
}
.storage-ring { width: 92px; height: 92px; flex-shrink: 0; transform: rotate(-90deg); }
.storage-ring .ring-bg { stroke: var(--border); }
.storage-ring .ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2,.9,.3,1); }
.storage-hero-info h2 { font-size: 26px; font-weight: 700; letter-spacing: -.4px; }
.storage-hero-info p { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.storage-hero-actions { margin-left: auto; display: flex; flex-direction: column; gap: 8px; }
.storage-hero-actions button {
    border: 1.5px solid var(--border); border-radius: 10px;
    padding: 8px 16px; font-size: 12.5px; font-weight: 600; color: var(--text-dim);
    white-space: nowrap;
}
.storage-hero-actions button:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-dim); }

.storage-section-title { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .6px; margin: 20px 0 12px; }

.folder-bars { display: flex; flex-direction: column; gap: 9px; }
.folder-bar-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.folder-bar-row .fb-name { width: 130px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-bar-row .fb-track { flex: 1; height: 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.folder-bar-row .fb-fill { height: 100%; border-radius: 6px; transition: width .7s cubic-bezier(.2,.9,.3,1); }
.folder-bar-row .fb-size { width: 84px; text-align: right; color: var(--text-dim); font-size: 12.5px; flex-shrink: 0; }
.folder-bar-row .fb-count { width: 76px; text-align: right; color: var(--text-muted); font-size: 12px; flex-shrink: 0; }

.storage-table { width: 100%; border-collapse: collapse; }
.storage-table th {
    text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .5px;
    padding: 8px 10px; border-bottom: 1px solid var(--border);
    cursor: pointer; user-select: none;
    white-space: nowrap;
}
.storage-table th:hover { color: var(--text); }
.storage-table th .sort-arrow { font-size: 10px; }
.storage-table td {
    padding: 9px 10px; border-bottom: 1px solid var(--border);
    font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.storage-table tr:hover td { background: var(--hover-row); }
.storage-table .st-size { font-weight: 700; white-space: nowrap; }
.storage-table .st-folder {
    font-size: 11px; font-weight: 700; color: var(--accent);
    background: var(--accent-soft); border-radius: 7px; padding: 2px 8px;
}
.storage-table .st-subject { max-width: 0; width: 45%; cursor: pointer; }
.storage-table .st-subject:hover { color: var(--accent); }
.storage-bulkbar {
    display: flex; align-items: center; gap: 10px;
    margin: 10px 0;
    min-height: 36px;
}
.storage-bulkbar .btn-danger {
    background: var(--danger); color: #fff; border-radius: 9px;
    padding: 7px 16px; font-size: 12.5px; font-weight: 600;
}
.storage-bulkbar .btn-danger:disabled { opacity: .4; }
.storage-bulkbar select {
    border: 1px solid var(--border); background: var(--surface); border-radius: 9px;
    padding: 7px 10px; font-size: 12.5px; outline: none;
}

/* ---------------------------------------------------------------- Compose */

.compose {
    position: fixed;
    right: 26px; bottom: 0;
    width: 560px;
    max-width: calc(100vw - 40px);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow-3);
    display: flex; flex-direction: column;
    z-index: 80;
    max-height: min(680px, calc(100vh - 40px));
    animation: rise .25s cubic-bezier(.2,.9,.3,1.1);
    transition: right .18s ease;
}
.compose[hidden] { display: none; }
.compose.drag-float {
    transition: none;
    z-index: 95 !important;
    box-shadow: 0 14px 60px rgba(0,0,0,.5);
    opacity: .95;
}
@media (max-width: 1300px) {
    .compose { width: 480px; }
}

.compose-header {
    background: #23262e;
    color: #eceef4;
    padding: 11px 16px;
    border-radius: 15px 15px 0 0;
    display: flex; align-items: center; justify-content: space-between;
    font-size: 14px; font-weight: 650;
    cursor: pointer;
    user-select: none;
}
.compose-header #compose-title {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0; margin-right: 10px;
}
.compose-header-btns { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.compose-min, .compose-close { color: #eceef4; opacity: .85; padding: 2px 6px; border-radius: 6px; }
.compose-min:hover, .compose-close:hover { opacity: 1; background: rgba(255,255,255,.12); }
.compose-min svg { width: 16px; height: 16px; display: block; }
.compose-close { font-size: 20px; line-height: 1; }

/* Minimized: just the header bar, docked bottom-right */
.compose.minimized { width: 300px; max-height: none; }
.compose.minimized .compose-fields,
.compose.minimized .compose-toolbar,
.compose.minimized .compose-body,
.compose.minimized .compose-attachments,
.compose.minimized .compose-footer,
.compose.minimized .compose-drop { display: none; }

.compose-fields { padding: 0 16px; }
.compose-row {
    display: flex; align-items: center; gap: 8px;
    border-bottom: 1px solid var(--border);
    min-height: 41px;
}
.compose-label { color: var(--text-dim); font-size: 13px; width: 38px; flex-shrink: 0; }
.compose-row input, .compose-row select {
    flex: 1; border: none; outline: none; background: transparent; padding: 8px 0; min-width: 0;
}
.compose-subject { font-weight: 600; }
.cc-toggle { color: var(--text-dim); font-size: 12.5px; }
.cc-toggle:hover { color: var(--accent); }

.autocomplete-anchor { position: relative; }
.autocomplete {
    position: absolute;
    left: 38px; right: 0; top: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-2);
    z-index: 90;
    overflow: hidden;
    max-height: 220px; overflow-y: auto;
}
.ac-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
}
.ac-item:hover, .ac-item.active { background: var(--hover-row); }
.ac-item .mini-avatar { width: 26px; height: 26px; font-size: 11px; }
.ac-item .ac-name { font-weight: 600; }
.ac-item .ac-email { color: var(--text-dim); font-size: 12px; }

.compose-toolbar {
    display: flex; align-items: center; gap: 2px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
}
.fmt-btn {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-dim);
    font-size: 13px;
}
.fmt-btn:hover { background: var(--hover-row); color: var(--text); }
.fmt-btn svg { width: 16px; height: 16px; }
.fmt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }

.compose-body {
    flex: 1;
    min-height: 170px;
    overflow-y: auto;
    padding: 14px 16px;
    outline: none;
    font-size: 14px;
    line-height: 1.6;
}
.compose-body blockquote {
    border-left: 2.5px solid var(--accent);
    margin: 8px 0 8px 6px;
    padding-left: 12px;
    color: var(--text-dim);
}
.compose-body a { color: var(--accent); }

.compose-attachments { padding: 0 16px; display: flex; flex-direction: column; gap: 6px; }
.c-att {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 7px 11px;
    font-size: 12.5px;
}
.c-att .att-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-att button { color: var(--text-dim); font-size: 16px; line-height: 1; }
.c-att button:hover { color: var(--danger); }

.compose-drop {
    position: absolute; inset: 0;
    border: 2.5px dashed var(--accent);
    border-radius: 16px 16px 0 0;
    background: var(--accent-soft);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--accent); font-size: 15px;
    z-index: 5;
    pointer-events: none;
}
.compose-drop[hidden] { display: none; }

.compose-footer { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.btn-send { width: auto; padding: 10px 24px; border-radius: 22px; display: inline-flex; align-items: center; gap: 9px; }
.btn-send svg { width: 15px; height: 15px; fill: #fff; }
.attach-label { cursor: pointer; }
.compose-status { color: var(--text-dim); font-size: 12.5px; flex: 1; }
.compose-trash { margin-left: auto; }
.compose-trash:hover { color: var(--danger); background: var(--danger-dim); }

/* ---------------------------------------------------------------- Popovers */

.popover {
    position: fixed;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-3);
    z-index: 110;
    min-width: 220px;
    overflow: hidden;
    animation: pop .14s cubic-bezier(.2,.9,.3,1.2);
    padding: 6px 0;
    max-height: 340px; overflow-y: auto;
}
.popover .pop-title {
    padding: 8px 16px 6px;
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .6px;
}
.popover button.pop-item {
    display: flex; align-items: center; gap: 11px;
    width: 100%; padding: 9px 16px; text-align: left; font-size: 13px;
}
.popover button.pop-item:hover { background: var(--hover-row); }
.popover .pop-item svg { width: 16px; height: 16px; fill: var(--text-dim); }
.popover .pop-item .pop-hint { margin-left: auto; color: var(--text-muted); font-size: 11.5px; }

/* ---------------------------------------------------------------- Context menu / lightbox */

#context-menu { min-width: 240px; }
#context-menu .pop-item.danger { color: var(--danger); }
#context-menu .pop-item.danger svg { fill: var(--danger); }
#context-menu .pop-sep { height: 1px; background: var(--border); margin: 5px 0; }

.lightbox {
    position: fixed; inset: 0;
    background: rgba(8, 10, 15, .88);
    display: flex; align-items: center; justify-content: center;
    z-index: 140;
    backdrop-filter: blur(6px);
}
.lightbox[hidden] { display: none; }
.lightbox img {
    max-width: 88vw; max-height: 86vh;
    border-radius: 10px;
    box-shadow: 0 20px 80px rgba(0,0,0,.6);
}
.lightbox-close {
    position: absolute; top: 18px; right: 24px;
    color: #fff; font-size: 32px; line-height: 1;
    opacity: .8;
}
.lightbox-close:hover { opacity: 1; }
.lightbox-download {
    position: absolute; bottom: 24px; left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,.14);
    color: #fff; text-decoration: none;
    padding: 9px 22px; border-radius: 20px;
    font-size: 13px; font-weight: 600;
}
.lightbox-download:hover { background: rgba(255,255,255,.24); }

/* ---------------------------------------------------------------- Modal */

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(10,12,18,.55);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal-backdrop[hidden] { display: none; }

.modal {
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-3);
    animation: rise .22s cubic-bezier(.2,.9,.3,1.15);
}
.modal h2 { font-size: 18px; font-weight: 650; margin-bottom: 8px; }
.modal p { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal-actions .btn-primary { width: auto; padding: 9px 22px; }
.btn-ghost { color: var(--accent); font-weight: 600; padding: 9px 16px; border-radius: 10px; }
.btn-ghost:hover { background: var(--accent-soft); }

.modal-lg { max-width: 540px; max-height: calc(100vh - 60px); overflow-y: auto; }

.settings-grid { display: flex; flex-direction: column; gap: 4px; }
.setting-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.setting-row select {
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12.5px;
    outline: none;
    max-width: 240px;
}
.setting-row select:focus { border-color: var(--accent); }

.accent-swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.swatch {
    width: 26px; height: 26px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border);
    transition: transform .1s, box-shadow .12s;
    display: flex; align-items: center; justify-content: center;
}
.swatch:hover { transform: scale(1.12); }
.swatch.selected { box-shadow: 0 0 0 2px var(--accent); }
.swatch svg { width: 14px; height: 14px; fill: #fff; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }

/* Compact density */
body.compact .msg-row { height: 34px; }
body.compact .row-avatar { display: none; }
body.compact .msg-row .star-btn { width: 26px; height: 26px; }
body.compact .folder-list li button { padding: 5px 14px; }
body.compact .list-toolbar, body.compact .msg-toolbar { min-height: 42px; padding-top: 4px; padding-bottom: 4px; }
body.compact .compose-btn { padding: 10px 24px; }

.settings-tabs {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.settings-tab {
    padding: 8px 14px;
    font-size: 13px; font-weight: 600;
    color: var(--text-dim);
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1px;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.pane-note { color: var(--text-muted); font-size: 12px; line-height: 1.5; margin-top: 12px; }

.labels-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.label-row {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
}
.label-row input[type="color"], .label-add input[type="color"] {
    width: 26px; height: 26px;
    border: none; border-radius: 7px;
    padding: 0; cursor: pointer; background: none;
}
.label-row .lr-name { flex: 1; font-weight: 600; }
.label-row button { color: var(--text-dim); font-size: 12px; padding: 4px 8px; border-radius: 7px; }
.label-row button:hover { background: var(--hover-row); color: var(--text); }
.label-row button.lr-del:hover { background: var(--danger-dim); color: var(--danger); }
.label-add { display: flex; align-items: center; gap: 8px; }
.label-add input[type="text"] {
    flex: 1; border: 1.5px solid var(--border); border-radius: 9px;
    padding: 8px 10px; background: var(--surface-2); outline: none;
}
.label-add input[type="text"]:focus { border-color: var(--accent); }

.label-chip {
    display: inline-block;
    font-size: 10.5px; font-weight: 700;
    padding: 1px 8px; border-radius: 8px;
    margin-right: 6px;
    vertical-align: 1px;
    white-space: nowrap;
}

.filters-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.filter-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 12.5px;
}
.filter-row .fr-desc { flex: 1; line-height: 1.45; }
.filter-row .fr-desc b { color: var(--accent); }
.filter-row button { color: var(--text-dim); font-size: 12px; padding: 4px 8px; border-radius: 7px; white-space: nowrap; }
.filter-row button:hover { background: var(--hover-row); color: var(--text); }
.filter-row button.fr-del:hover { background: var(--danger-dim); color: var(--danger); }

.filter-form { border: 1px dashed var(--border); border-radius: 12px; padding: 12px; }
.filter-form-row {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 8px; font-size: 12.5px; color: var(--text-dim);
    flex-wrap: wrap;
}
.filter-form-row:last-child { margin-bottom: 0; }
.filter-form select, .filter-form input[type="text"] {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 6px 8px; font-size: 12.5px;
    background: var(--surface-2); outline: none;
}
.filter-form input[type="text"] { flex: 1; min-width: 120px; }
.filter-form label { display: flex; align-items: center; gap: 5px; cursor: pointer; }

.sidebar-section-title {
    font-size: 10.5px; font-weight: 700; letter-spacing: .8px;
    color: var(--text-muted); text-transform: uppercase;
    padding: 14px 14px 5px;
    list-style: none;
}
.label-dot {
    width: 11px; height: 11px;
    border-radius: 4px;
    flex-shrink: 0;
    margin: 0 3.5px;
}
.label-dot-btn { cursor: pointer; transition: transform .1s, box-shadow .12s; }
.label-dot-btn:hover {
    transform: scale(1.35);
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--accent);
}

.pw-grid { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pw-grid input {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 9px 11px;
    background: var(--surface-2);
    outline: none;
    font-size: 13px;
}
.pw-grid input:focus { border-color: var(--accent); }

.signature-box {
    border: 1.5px solid var(--border);
    border-radius: 10px;
    min-height: 110px; max-height: 220px;
    overflow-y: auto;
    padding: 12px;
    font-size: 13.5px;
    outline: none;
    background: var(--surface-2);
}
.signature-box:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------------------------------------------------------------- Toast */

.toast {
    position: fixed;
    left: 26px; bottom: 26px;
    background: #22252e;
    color: #eceef4;
    padding: 13px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-3);
    font-size: 13.5px;
    z-index: 130;
    display: flex; align-items: center; gap: 16px;
    animation: rise .2s ease;
}
.toast[hidden] { display: none; }
.toast button {
    color: #a5b4fc; font-weight: 700; font-size: 13px;
    padding: 4px 10px; border-radius: 8px;
}
.toast button:hover { background: rgba(165,180,252,.12); }

/* ---------------------------------------------------------------- Print */

@media print {
    .topbar, .sidebar, .msg-toolbar, .compose, .toast, .popover { display: none !important; }
    .content { border: none; box-shadow: none; margin: 0; }
    body { overflow: visible; background: #fff; }
    .msg-detail { overflow: visible; padding: 0; }
}

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 900px) {
    .topbar-left { width: auto; }
    .brand-name { display: none; }
    .sidebar { width: 72px; padding-left: 8px; }
    .compose-btn span, .folder-list .fname, .folder-list .fcount,
    .new-folder-btn span, .storage-widget { display: none; }
    .msg-from { width: 110px; }
    .row-avatar { display: none; }
    .msg-size { display: none; }
    .msg-detail { padding: 10px 16px 30px; }
    .compose { right: 0; width: 100vw; max-width: 100vw; }
}
