/* Aurix Mail — styles */
:root {
    --bg: #f6f8fc;
    --surface: #ffffff;
    --surface-2: #eef2fa;
    --hover: #e8edf7;
    --selected: #dfe6fb;
    --text: #1f2430;
    --muted: #5f6675;
    --faint: #8a91a1;
    --border: #e3e7ef;
    --accent: #5b5bf0;
    --accent-2: #4646d8;
    --accent-soft: #e6e6ff;
    --danger: #d93838;
    --star: #f4b400;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .08);
    --shadow-lg: 0 12px 40px rgba(16, 24, 40, .22);
    --radius: 14px;
    --sidebar: 248px;
    --header: 64px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1117;
        --surface: #171a22;
        --surface-2: #1e222c;
        --hover: #232835;
        --selected: #2a2f45;
        --text: #e7e9ee;
        --muted: #a3a9b7;
        --faint: #7b8191;
        --border: #2a2f3a;
        --accent: #8b8bff;
        --accent-2: #a3a3ff;
        --accent-soft: #2b2c55;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
        color-scheme: dark;
    }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font: 14px/1.45 "Inter", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); }
.hidden { display: none !important; }
svg.i { width: 20px; height: 20px; fill: currentColor; flex: none; }

.boot { height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px;
    border-radius: 999px; font-weight: 600; transition: background .15s, box-shadow .15s, opacity .15s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); box-shadow: var(--shadow); }
.btn.ghost { background: var(--surface-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center;
    color: var(--muted); flex: none; transition: background .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg.i { width: 18px; height: 18px; }
.icon-btn.active { color: var(--accent); }

/* ---------- avatar ---------- */
.avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
    font-weight: 700; font-size: 15px; color: #fff; overflow: hidden; user-select: none; text-transform: uppercase;
}
.avatar { position: relative; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 76px; height: 76px; font-size: 30px; }
.avatar.xl { width: 112px; height: 112px; font-size: 44px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
    width: 100%; max-width: 420px; background: var(--surface); border-radius: 24px; padding: 40px 36px 32px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
}
.login-card .logo { width: 52px; height: 52px; }
.login-card h1 { font-size: 26px; margin: 18px 0 6px; letter-spacing: -.02em; }
.login-card p.sub { color: var(--muted); margin: 0 0 26px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, .field input, .field textarea {
    width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface-2); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.login-card .btn { width: 100%; justify-content: center; height: 46px; margin-top: 6px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 6px; }
.login-foot { margin-top: 18px; text-align: center; }
.login-foot button { color: var(--accent); font-weight: 600; }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; right: 4px; top: 3px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-rows: var(--header) 1fr; height: 100vh; height: 100dvh; }
header.top {
    grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -.02em; width: calc(var(--sidebar) - 64px); white-space: nowrap; }
.brand img { width: 32px; height: 32px; }
.search {
    flex: 1; min-width: 0; max-width: 720px; display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 6px 0 4px;
    background: var(--surface-2); border-radius: 24px; transition: background .15s, box-shadow .15s;
}
.search:focus-within { background: var(--surface); box-shadow: var(--shadow); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; height: 100%; font-size: 15px; min-width: 0; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.acct-btn { border-radius: 50%; padding: 4px; }
.acct-btn:hover { background: var(--hover); }

aside.side { padding: 4px 12px 12px 8px; overflow-y: auto; display: flex; flex-direction: column; }
.compose-btn {
    display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px 0 18px; border-radius: 18px;
    background: var(--accent-soft); color: var(--text); font-weight: 600; font-size: 15px; margin: 4px 0 14px 0; align-self: flex-start;
    transition: box-shadow .15s;
}
.compose-btn:hover { box-shadow: var(--shadow); }
.compose-btn svg { color: var(--accent); }
.nav-item {
    display: flex; align-items: center; gap: 16px; height: 34px; padding: 0 12px 0 22px; border-radius: 0 17px 17px 0;
    color: var(--text); text-decoration: none; cursor: pointer; margin-left: -8px; white-space: nowrap;
}
.nav-item svg { color: var(--muted); }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--selected); font-weight: 700; }
.nav-item.active svg { color: var(--accent); }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count { font-size: 12px; font-weight: 700; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 0 10px 14px; }
.side-foot { margin-top: auto; padding: 16px 0 0 14px; color: var(--faint); font-size: 12px; }

main.content {
    background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; margin-right: 12px;
    overflow: hidden; display: flex; flex-direction: column; min-width: 0; box-shadow: var(--shadow);
}

/* ---------- list ---------- */
.toolbar {
    display: flex; align-items: center; gap: 2px; height: 52px; padding: 0 10px; border-bottom: 1px solid var(--border); flex: none;
}
.toolbar .spacer { flex: 1; }
.toolbar .pager { color: var(--muted); font-size: 12.5px; margin-right: 4px; white-space: nowrap; }
.check { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0 11px; flex: none; }
.list { overflow-y: auto; flex: 1; }
.row {
    display: flex; align-items: center; gap: 4px; height: 44px; padding: 0 12px 0 0; border-bottom: 1px solid var(--border);
    cursor: pointer; position: relative; background: var(--surface);
}
.row:hover { box-shadow: inset 1px 0 0 var(--border), inset -1px 0 0 var(--border), 0 1px 3px rgba(0,0,0,.12); z-index: 1; }
.row.selected { background: var(--selected); }
.row:not(.unread) { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.row.unread .from, .row.unread .subj, .row.unread .date { font-weight: 700; color: var(--text); }
.row .star { color: var(--faint); }
.row .star.on { color: var(--star); }
.row .from { min-width: 0; width: 200px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; color: var(--muted); }
.row .subj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.row .subj b { color: var(--text); font-weight: inherit; }
.row .meta { display: flex; align-items: center; gap: 6px; color: var(--faint); }
.row .date { font-size: 12.5px; width: 64px; text-align: right; color: var(--muted); }
.row .avatar { display: none; }
.row .draft-tag { color: var(--danger); }
.empty { padding: 80px 24px; text-align: center; color: var(--muted); }
.empty svg { width: 64px; height: 64px; opacity: .35; }
.loading-bar { height: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 200% 100%; animation: load 1s linear infinite; }
@keyframes load { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- reader ---------- */
.reader { overflow-y: auto; flex: 1; padding: 8px 0 40px; }
.reader-subj { display: flex; align-items: flex-start; gap: 12px; padding: 14px 24px 8px 72px; }
.reader-subj h1 { font-size: 22px; font-weight: 500; margin: 0; flex: 1; word-break: break-word; letter-spacing: -.01em; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); vertical-align: middle; margin-left: 8px; font-weight: 500; }
.msg-head { display: flex; gap: 14px; padding: 12px 24px 4px 16px; }
.msg-head .avatar { width: 42px; height: 42px; }
.msg-head .who { flex: 1; min-width: 0; }
.msg-head .who .n { font-weight: 700; }
.msg-head .who .e { color: var(--muted); font-size: 12.5px; }
.msg-head .who .to { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-head .acts { display: flex; align-items: center; gap: 2px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.msg-body { padding: 8px 24px 0 72px; }
.img-banner {
    display: flex; align-items: center; gap: 10px; margin: 6px 24px 8px 72px; padding: 8px 12px; border-radius: 10px;
    background: var(--surface-2); color: var(--muted); font-size: 13px;
}
.img-banner button { color: var(--accent); font-weight: 600; }
iframe.mail-frame { width: 100%; border: 0; display: block; min-height: 80px; background: #fff; border-radius: 8px; }
.atts { display: flex; flex-wrap: wrap; gap: 10px; padding: 18px 24px 0 72px; }
.att {
    display: flex; align-items: center; gap: 10px; width: 220px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
    text-decoration: none; color: var(--text); background: var(--surface);
}
.att:hover { background: var(--hover); }
.att .ic { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800; flex: none; }
.att .nm { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .sz { font-size: 12px; color: var(--muted); }
.reply-bar { display: flex; gap: 10px; padding: 24px 24px 0 72px; flex-wrap: wrap; }
.reply-bar .btn { border: 1px solid var(--border); background: var(--surface); height: 38px; }
.reply-bar .btn:hover { background: var(--hover); }

/* ---------- menus / popovers ---------- */
.menu {
    position: fixed; z-index: 60; min-width: 200px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
    border: 1px solid var(--border); padding: 6px; max-height: 70vh; overflow-y: auto;
}
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; }
.menu button:hover { background: var(--hover); }
.menu .sep { height: 1px; background: var(--border); margin: 6px 0; }
.scrim { position: fixed; inset: 0; z-index: 55; }

.acct-pop {
    position: fixed; z-index: 60; top: 62px; right: 12px; width: 380px; max-width: calc(100vw - 24px); background: var(--surface-2);
    border-radius: 28px; box-shadow: var(--shadow-lg); padding: 14px; max-height: calc(100vh - 80px); overflow-y: auto;
}
.acct-pop .cur { text-align: center; padding: 10px 10px 18px; }
.acct-pop .cur .email { color: var(--muted); font-size: 13px; }
.acct-pop .cur .avatar { margin: 12px auto 8px; }
.acct-pop .cur .hi { font-size: 21px; margin-bottom: 14px; }
.acct-pop .cur .btn { border: 1px solid var(--faint); background: transparent; color: var(--accent); }
.acct-pop .group { background: var(--surface); border-radius: 20px; overflow: hidden; margin-top: 6px; }
.acct-pop .item { display: flex; align-items: center; gap: 14px; padding: 12px 18px; width: 100%; text-align: left; }
.acct-pop .item:hover { background: var(--hover); }
.acct-pop .item .t { flex: 1; min-width: 0; }
.acct-pop .item .t div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-pop .item .t .e { color: var(--muted); font-size: 12.5px; }
.acct-pop .item .ic { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); }
.acct-pop .foot { text-align: center; color: var(--faint); font-size: 12px; padding: 12px 0 2px; }

/* ---------- compose ---------- */
.compose {
    position: fixed; z-index: 50; right: 24px; bottom: 0; width: 560px; max-width: 100vw; height: min(640px, calc(100vh - 80px));
    background: var(--surface); border-radius: 14px 14px 0 0; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
    border: 1px solid var(--border);
}
.compose.max { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(1000px, calc(100vw - 48px)); height: min(820px, calc(100vh - 48px)); border-radius: 14px; }
.compose.min { height: 46px; }
.compose .bar { display: flex; align-items: center; height: 46px; padding: 0 6px 0 16px; background: var(--surface-2); font-weight: 600; cursor: pointer; flex: none; }
.compose .bar .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose .fld { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 0 12px 0 16px; min-height: 42px; flex: none; }
.compose .fld label { color: var(--muted); width: 52px; flex: none; }
.compose .fld input { flex: 1; border: 0; outline: 0; background: transparent; height: 40px; min-width: 0; }
.compose .fld .lnk { color: var(--muted); font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.compose .fld .lnk:hover { background: var(--hover); color: var(--text); }
.compose .from-sel { flex: 1; border: 0; background: transparent; outline: 0; height: 40px; }
.editor { flex: 1; overflow-y: auto; padding: 14px 16px; outline: none; line-height: 1.55; word-break: break-word; }
.editor:empty::before { content: attr(data-placeholder); color: var(--faint); }
.editor blockquote, .msg-quote { margin: 8px 0 0 4px; padding-left: 12px; border-left: 2px solid var(--border); color: var(--muted); }
.editor .awm-sig { color: var(--muted); }
.compose .atts-c { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 8px; flex: none; }
.compose .atts-c .a { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 8px; padding: 4px 4px 4px 10px; font-size: 12.5px; max-width: 260px; }
.compose .atts-c .a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose .foot { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-top: 1px solid var(--border); flex: none; }
.compose .foot .spacer { flex: 1; }
.fmt { display: flex; gap: 0; flex-wrap: wrap; }
.status-txt { color: var(--muted); font-size: 12.5px; margin-left: 6px; }

/* ---------- settings ---------- */
.settings { overflow-y: auto; flex: 1; padding: 28px 32px 60px; }
.settings h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.settings .sub { color: var(--muted); margin: 0 0 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px; margin-bottom: 18px; max-width: 760px; }
.card h3 { margin: 0 0 16px; font-size: 16px; }
.avatar-edit { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.avatar-edit .avatar { cursor: pointer; position: relative; }
.sig-editor { min-height: 120px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; outline: none; background: var(--surface-2); }
.sig-editor:focus { border-color: var(--accent); background: var(--surface); }
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.acct-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.acct-row:last-child { border-bottom: 0; }
.acct-row .t { flex: 1; min-width: 0; }
.acct-row .t .e { color: var(--muted); font-size: 12.5px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 24px; bottom: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: #2b2f3a; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 14px;
    animation: up .2s ease-out; max-width: calc(100vw - 48px);
}
.toast.err { background: #b3261e; }
.toast button { color: #a8b0ff; font-weight: 700; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }


/* ---------- mobile ---------- */
@media (max-width: 860px) {
    :root { --header: 60px; }
    .shell { grid-template-columns: minmax(0, 1fr); }
    .desktop-only { display: none !important; }
    .brand { width: auto; }
    .brand span { display: none; }
    header.top { padding: 0 8px; gap: 4px; }
    .search { height: 46px; }
    aside.side {
        position: fixed; z-index: 45; top: 0; bottom: 0; left: 0; width: 290px; background: var(--surface);
        transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); padding-top: 14px;
    }
    aside.side.open { transform: none; }
    .side-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 44; }
    .compose-btn.fab {
        position: fixed; right: 16px; bottom: 20px; z-index: 40; box-shadow: var(--shadow-lg); margin: 0; height: 56px;
        background: var(--accent-soft);
    }
    main.content { margin: 0; border-radius: 0; box-shadow: none; }
    .row { height: auto; padding: 10px 12px 10px 10px; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
    .row .check { display: none; }
    .row.selecting .check, .selecting-mode .row .check { display: block; margin: 9px 0 0 4px; }
    .row .avatar { display: grid; width: 40px; height: 40px; }
    .row .mob { flex: 1; min-width: 0; }
    .row .from { width: auto; padding: 0; flex: 1; font-size: 15px; }
    .row .subj { display: block; font-size: 14px; }
    .row .line1 { display: flex; align-items: baseline; gap: 8px; }
    .row .line2 { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
    .row .date { width: auto; }
    .row:not(.unread) { background: var(--surface); }
    .row:hover { box-shadow: none; }
    .reader-subj { padding: 12px 16px 6px; }
    .reader-subj h1 { font-size: 20px; }
    .msg-head { padding: 10px 12px 4px; }
    .msg-body, .atts, .reply-bar { padding-left: 12px; padding-right: 12px; }
    .img-banner { margin-left: 12px; margin-right: 12px; }
    .att { width: 100%; }
    .compose, .compose.max { inset: 0; width: 100%; height: 100%; max-width: none; border-radius: 0; transform: none; right: 0; bottom: 0; }
    .compose.min { inset: auto 0 0 0; height: 46px; }
    .compose .foot .fmt { flex-wrap: nowrap; overflow-x: auto; min-width: 0; flex: 1; scrollbar-width: none; }
    .compose .foot .spacer { display: none; }
    .settings { padding: 18px 14px 80px; }
    .card { padding: 18px; }
    .toolbar .pager { display: none; }
    #toasts { left: 12px; right: 12px; bottom: 88px; }
}
@media (min-width: 861px) {
    .mobile-only { display: none !important; }
    .row .mob { display: contents; }
    .row .line1, .row .line2 { display: contents; }
    .row .check { order: 0; } .row .star { order: 1; } .row .from { order: 2; }
    .row .subj { order: 3; } .row .meta { order: 4; } .row .date { order: 5; }
}
