/* ==========================================================================
   Webmail — Gmail-inspired layout
   ========================================================================== */
body.mail { overflow: hidden; }
.mail-layout { display: flex; height: calc(100vh - var(--topbar-h)); }

/* ---------- Sidebar ---------- */
.mail-side { width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column; padding: 0 16px 0 0; overflow-y: auto; overflow-x: hidden; transition: width .2s var(--ease); }
.compose-btn {
  display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 20px 0 16px; margin: 8px 0 16px 8px;
  border-radius: 16px; border: 0; background: var(--compose); color: var(--on-compose); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: box-shadow .15s; align-self: flex-start; white-space: nowrap;
}
.compose-btn:hover { box-shadow: var(--shadow-2); }
.compose-btn .ms { font-size: 24px; }
.mail-side .nav-item { height: 32px; }
.mail-side .nav-item.unread { font-weight: 700; }
.storage { padding: 16px 12px 16px 22px; margin-top: auto; font-size: 12px; color: var(--text-2); }
.storage .progress { margin: 8px 0 6px; }
body.side-collapsed .mail-side { width: 80px; padding-right: 0; }
body.side-collapsed .mail-side .nav-item { padding: 0; width: 32px; height: 32px; border-radius: 50%; margin-left: 24px; justify-content: center; gap: 0; }
body.side-collapsed .mail-side .nav-item > :not(.ms) { display: none; }
body.side-collapsed .mail-side .nav-item .label-dot { display: inline-block; margin: 0; }
body.side-collapsed .compose-btn { padding: 0; width: 56px; justify-content: center; margin-left: 12px; }
body.side-collapsed .compose-btn span:not(.ms), body.side-collapsed .nav-section, body.side-collapsed .storage { display: none; }

/* ---------- Main surface ---------- */
.mail-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); margin: 0 16px 16px 0; overflow: hidden; }
.mail-toolbar { display: flex; align-items: center; gap: 2px; padding: 4px 8px 4px 12px; min-height: 48px; border-bottom: 1px solid transparent; flex-shrink: 0; }
.mail-toolbar .sel-wrap { display: inline-flex; align-items: center; border-radius: 4px; }
.mail-toolbar .sel-wrap:hover { background: var(--hover); }
.mail-toolbar .sel-wrap input { margin: 0 0 0 8px; }
.mail-toolbar .sel-wrap .icon-btn { width: 20px; height: 32px; border-radius: 4px; }
.mail-toolbar .sel-wrap .icon-btn .ms { font-size: 18px; }
.mail-toolbar .divider { width: 1px; height: 20px; background: var(--border); margin: 0 8px; }
.mail-toolbar .pager { margin-left: auto; display: flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.mail-toolbar .pager span { padding: 0 8px; }

.cat-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; scrollbar-width: none; }
.cat-tab { flex: 0 1 252px; min-width: 140px; height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 16px; border: 0; background: transparent; cursor: pointer; position: relative; color: var(--text-2); font-weight: 500; font-size: 14px; text-align: left; }
.cat-tab:hover { background: var(--hover); }
.cat-tab .ms { font-size: 20px; }
.cat-tab.active { color: var(--primary); }
.cat-tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }
.cat-tab .new { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 10px; color: #fff; margin-left: auto; }
.cat-tab .cat-text { display: flex; flex-direction: column; min-width: 0; }
.cat-tab .cat-text small { font-size: 12px; font-weight: 400; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Message list ---------- */
.mail-body { flex: 1; min-height: 0; display: flex; }
.list-pane { flex: 1; min-width: 0; overflow-y: auto; }
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-row {
  display: grid; grid-template-columns: auto auto auto 200px 1fr auto; align-items: center; gap: 0;
  height: 40px; padding: 0 16px 0 8px; cursor: pointer; position: relative;
  background: var(--read-bg); border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-2);
}
.msg-row.unread { background: var(--unread-bg); color: var(--text); }
.msg-row.unread .sender, .msg-row.unread .subj, .msg-row.unread .date { font-weight: 700; color: var(--text); }
.msg-row:hover { box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15); z-index: 2; }
:root[data-theme="dark"] .msg-row:hover { box-shadow: inset 0 0 0 1px var(--border-strong), 0 2px 6px rgba(0,0,0,.5); }
.msg-row.selected { background: var(--row-selected) !important; }
.msg-row.focused::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.msg-row .cb { width: 40px; height: 40px; display: grid; place-items: center; }
.msg-row .cb input { width: 16px; height: 16px; }
.msg-row .icon-btn { width: 32px; height: 32px; }
.msg-row .icon-btn .ms { font-size: 18px; }
.msg-row .star-btn .ms { color: var(--text-3); }
.msg-row .star-btn.on .ms { color: #f4b400; font-variation-settings: 'FILL' 1; }
.msg-row .imp-btn .ms { color: var(--text-3); font-size: 18px; }
.msg-row .imp-btn.on .ms { color: #f4b400; font-variation-settings: 'FILL' 1; }
.msg-row .sender { padding: 0 24px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.msg-row .sender .cnt { color: var(--text-3); font-weight: 400; font-size: 12px; margin-left: 4px; }
.msg-row .content { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.msg-row .content .labels { display: inline-flex; gap: 4px; flex-shrink: 0; }
.lbl { font-size: 12px; padding: 0 6px; border-radius: 4px; line-height: 18px; font-weight: 500; white-space: nowrap; }
.msg-row .subj { flex-shrink: 0; max-width: 70%; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.msg-row .snip { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.msg-row .att-ic { color: var(--text-3); font-size: 16px; margin-left: 4px; }
.msg-row .date { font-size: 12px; text-align: right; padding-left: 16px; min-width: 76px; white-space: nowrap; color: var(--text-2); }
.msg-row .hover-actions { display: none; align-items: center; padding-left: 8px; grid-column: 6; grid-row: 1; }
.msg-row .date { grid-column: 6; grid-row: 1; }
.msg-row:hover .hover-actions { display: flex; }
.msg-row:hover .date { display: none; }
.msg-row .avatar-col { display: none; }
.msg-row .att-chips { display: none; }

/* density */
body.density-compact .msg-row { height: 32px; }
body.density-comfortable .msg-row { height: auto; min-height: 40px; padding-top: 6px; padding-bottom: 6px; grid-template-columns: auto auto auto 200px 1fr auto; grid-template-rows: auto auto; }
body.density-comfortable .msg-row .att-chips { display: flex; gap: 8px; grid-column: 5 / 6; grid-row: 2; padding-top: 4px; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 14px; font-size: 12.5px; color: var(--text-2); max-width: 200px; background: var(--surface); }
.att-chip .ms { font-size: 16px; color: #d93025; }

.list-empty { padding: 72px 24px; text-align: center; color: var(--text-2); }
.list-footer { padding: 16px; text-align: center; font-size: 12px; color: var(--text-3); }

/* ---------- Thread / reading view ---------- */
.read-pane { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; }
.thread { padding: 8px 0 32px; }
.thread-head { display: flex; align-items: flex-start; gap: 12px; padding: 12px 24px 8px 72px; }
.thread-head h2 { font-family: var(--font); font-weight: 400; font-size: 22px; line-height: 1.35; flex: 1; word-break: break-word; }
.thread-head .labels { display: inline-flex; gap: 6px; vertical-align: middle; margin-left: 8px; }
.thread-head .lbl { display: inline-flex; align-items: center; gap: 2px; }
.thread-head .lbl button { border: 0; background: transparent; padding: 0; cursor: pointer; color: inherit; display: inline-flex; }
.msg { padding: 0 24px 0 16px; border-bottom: 1px solid var(--border); }
.msg:last-of-type { border-bottom: 0; }
.msg-head { display: flex; gap: 16px; padding: 16px 0 8px; align-items: flex-start; cursor: pointer; }
.msg-head .avatar { width: 40px; height: 40px; font-size: 16px; }
.msg-meta { flex: 1; min-width: 0; }
.msg-meta .from { font-weight: 700; font-size: 14px; color: var(--text); }
.msg-meta .from .addr { font-weight: 400; font-size: 12px; color: var(--text-2); margin-left: 4px; }
.msg-meta .to { font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; cursor: pointer; }
.msg-meta .snippet { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.when-sm { display: none; font-size: 12px; font-weight: 400; color: var(--text-2); float: right; }
.msg-head .when { font-size: 12px; color: var(--text-2); white-space: nowrap; padding-top: 2px; }
.msg-head .msg-actions { display: flex; align-items: center; gap: 0; margin-top: -8px; }
.msg-body { padding: 4px 0 20px 56px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; color: var(--text); }
.msg.collapsed .msg-body, .msg.collapsed .msg-atts, .msg.collapsed .to, .msg.collapsed .msg-actions .hide-collapsed, .msg.collapsed .details { display: none; }
.msg:not(.collapsed) .snippet { display: none; }
.details { margin: 6px 0 0; font-size: 12px; color: var(--text-2); display: none; grid-template-columns: auto 1fr; gap: 2px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; box-shadow: var(--shadow-1); max-width: 520px; }
.details.show { display: grid; }
.details span:nth-child(odd) { text-align: right; color: var(--text-3); }
.msg-atts { padding: 0 0 20px 56px; }
.msg-atts .att-title { font-size: 14px; font-weight: 500; padding-top: 12px; border-top: 1px solid var(--border); margin-bottom: 12px; color: var(--text-2); }
.att-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.att-card { width: 180px; height: 120px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; position: relative; cursor: pointer; background: var(--surface-2); }
.att-card .att-prev { flex: 1; display: grid; place-items: center; }
.att-card .att-prev .ms { font-size: 44px; }
.att-card .att-foot { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface); border-top: 1px solid var(--border); font-size: 12px; }
.att-card .att-foot .ms { font-size: 18px; }
.att-card .att-hover { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; gap: 8px; color: #fff; }
.att-card:hover .att-hover { display: flex; }
.att-card .att-hover .icon-btn { color: #fff; background: rgba(255,255,255,.15); }
.reply-bar { display: flex; gap: 12px; padding: 16px 24px 16px 72px; flex-wrap: wrap; }
.reply-bar .btn { border: 1px solid var(--border-strong); color: var(--text-2); height: 36px; padding: 0 20px 0 16px; }
.reply-bar .btn:hover { background: var(--hover); }
.inline-reply { margin: 8px 24px 24px 72px; border-radius: 8px; box-shadow: var(--shadow-2); background: var(--surface); }
.inline-reply .ir-to { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.inline-reply .ir-body { min-height: 140px; padding: 16px; outline: none; font-size: 14px; line-height: 1.6; }
.inline-reply .ir-foot { display: flex; align-items: center; gap: 4px; padding: 8px 12px 12px; }
.quote-toggle { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 14px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); border: 0; cursor: pointer; margin-left: 56px; margin-bottom: 12px; font-size: 14px; line-height: 0; }

/* Split pane */
body.split .mail-body .list-pane { flex: 0 0 44%; border-right: 1px solid var(--border); }
body.split .msg-row { grid-template-columns: auto auto 1fr auto; grid-template-rows: auto auto; height: auto; padding: 8px 16px 8px 4px; }
body.split .msg-row .imp-btn { display: none; }
body.split .msg-row .sender { grid-column: 3; grid-row: 1; padding-left: 4px; }
body.split .msg-row .content { grid-column: 3 / 5; grid-row: 2; padding-left: 4px; }
body.split .msg-row .date { grid-column: 4; grid-row: 1; }
body.split .msg-row .cb, body.split .msg-row .star-btn { grid-row: 1 / 3; }
body.split .msg-row:hover .date { display: block; }
body.split .msg-row .hover-actions { display: none !important; }
body.split .msg-row.open { background: var(--primary-soft) !important; }
body.split .msg-row .subj { max-width: 60%; }
.split-empty { flex: 1; display: grid; place-items: center; color: var(--text-3); text-align: center; }

/* ---------- Compose window ---------- */
.compose-dock { position: fixed; right: 16px; bottom: 0; display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 16px; z-index: 800; pointer-events: none; }
.compose {
  width: 560px; height: min(600px, calc(100vh - 80px)); background: var(--surface); border-radius: 12px 12px 0 0;
  box-shadow: var(--shadow-3); display: flex; flex-direction: column; pointer-events: auto; overflow: hidden; animation: composeIn .22s var(--ease);
}
@keyframes composeIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.compose.min { width: 280px; height: 40px; }
.compose.min .c-fields, .compose.min .c-body, .compose.min .c-foot, .compose.min .c-fmt, .compose.min .c-atts { display: none; }
.compose.full { position: fixed; inset: 5vh 8vw; width: auto; height: auto; border-radius: 12px; z-index: 960; }
.compose-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 955; }
.c-head { display: flex; align-items: center; height: 40px; padding: 0 6px 0 16px; background: var(--surface-2); cursor: pointer; flex-shrink: 0; }
.c-head .title { flex: 1; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-head .saved { font-size: 12px; color: var(--text-3); margin-right: 8px; }
.c-head .icon-btn { width: 28px; height: 28px; border-radius: 4px; }
.c-head .icon-btn .ms { font-size: 18px; }
.c-fields { padding: 0 16px; flex-shrink: 0; }
.c-row { display: flex; align-items: center; gap: 4px; min-height: 40px; border-bottom: 1px solid var(--border); position: relative; flex-wrap: wrap; padding: 4px 0; }
.c-row .c-label { color: var(--text-2); font-size: 14px; margin-right: 4px; }
.c-row input { flex: 1; min-width: 120px; border: 0; outline: none; background: transparent; height: 30px; font-size: 14px; }
.c-row .c-toggles { margin-left: auto; display: flex; gap: 4px; }
.c-row .c-toggles button { border: 0; background: none; color: var(--text-2); cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px; }
.c-row .c-toggles button:hover { text-decoration: underline; }
.rchip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 2px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; max-width: 260px; }
.rchip .avatar { width: 22px; height: 22px; font-size: 11px; }
.rchip.invalid { background: var(--danger-soft); border-color: var(--danger); }
.rchip span.n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rchip button { border: 0; background: none; cursor: pointer; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: var(--text-2); padding: 0; }
.rchip button:hover { background: var(--hover); }
.rchip button .ms { font-size: 14px; }
.ac-list { position: absolute; left: 0; top: 100%; z-index: 20; background: var(--surface); box-shadow: var(--shadow-2); border-radius: 8px; padding: 6px 0; min-width: 320px; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); }
.ac-item { display: flex; align-items: center; gap: 12px; padding: 6px 16px; cursor: pointer; }
.ac-item:hover, .ac-item.focus { background: var(--hover); }
.ac-item .n { font-size: 14px; } .ac-item .e { font-size: 12px; color: var(--text-2); }
.c-body { flex: 1; min-height: 80px; overflow-y: auto; padding: 12px 16px; outline: none; font-size: 14px; line-height: 1.6; }
.c-body:empty::before { content: attr(data-ph); color: var(--text-3); }
.c-body blockquote, .ir-body blockquote { margin: 0 0 0 8px; padding-left: 12px; border-left: 2px solid var(--border-strong); color: var(--text-2); }
.c-body .sig, .ir-body .sig { color: var(--text-2); }
.c-atts { padding: 0 16px 8px; display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; max-height: 120px; overflow-y: auto; }
.c-att { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 4px; padding: 4px 4px 4px 10px; font-size: 13px; }
.c-att .n { color: var(--primary); font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-att .s { color: var(--text-3); }
.c-att .progress { width: 60px; }
.c-fmt { display: none; align-items: center; gap: 2px; margin: 0 16px 6px; padding: 2px 4px; border-radius: 8px; box-shadow: var(--shadow-1); flex-wrap: wrap; flex-shrink: 0; }
.compose.show-fmt .c-fmt { display: flex; }
.c-fmt .icon-btn { width: 30px; height: 30px; border-radius: 4px; }
.c-fmt .icon-btn .ms { font-size: 18px; }
.c-fmt .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.c-fmt .select { height: 30px; width: auto; border: 0; font-size: 13px; padding: 0 28px 0 8px; background-color: transparent; }
.c-foot { display: flex; align-items: center; gap: 2px; padding: 8px 12px 12px 16px; flex-shrink: 0; }
.send-split { display: inline-flex; margin-right: 8px; }
.send-split .btn { border-radius: 18px 0 0 18px; height: 36px; padding: 0 16px 0 20px; }
.send-split .btn + .btn { border-radius: 0 18px 18px 0; padding: 0 8px; border-left: 1px solid rgba(255,255,255,.35); }
:root[data-theme="dark"] .send-split .btn + .btn { border-left-color: rgba(0,0,0,.25); }
.c-foot .icon-btn { width: 36px; height: 36px; }
.c-foot .grow { flex: 1; }
.drop-overlay { position: absolute; inset: 40px 0 0; background: color-mix(in srgb, var(--primary-soft) 85%, transparent); border: 2px dashed var(--primary); display: none; place-items: center; font-weight: 600; color: var(--on-primary-soft); z-index: 5; border-radius: 0 0 12px 12px; }
.compose.dragging .drop-overlay { display: grid; }
.compose { position: relative; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; }
.emoji-grid button { border: 0; background: none; font-size: 22px; padding: 4px; border-radius: 6px; cursor: pointer; }
.emoji-grid button:hover { background: var(--hover); }

/* ---------- Search filters popover ---------- */
.search-adv { position: absolute; top: 0; left: 0; right: 0; background: var(--surface); border-radius: var(--r-sm); box-shadow: var(--shadow-3); padding: 20px 24px; z-index: 60; }
.search-adv .row-f { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: center; margin-bottom: 8px; }
.search-adv .row-f label { font-size: 14px; color: var(--text-2); }
.search-adv .row-f input, .search-adv .row-f select { border: 0; border-bottom: 1px solid var(--border-strong); outline: none; background: transparent; height: 32px; width: 100%; font-size: 14px; color: var(--text); }
.search-adv .row-f input:focus { border-bottom: 2px solid var(--primary); }
.search-sugg { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border-radius: 0 0 var(--r-sm) var(--r-sm); box-shadow: var(--shadow-2); padding: 8px 0; z-index: 60; }
.search-chips { display: flex; gap: 8px; padding: 8px 16px; flex-wrap: wrap; flex-shrink: 0; border-bottom: 1px solid var(--border); }

/* ---------- Quick settings drawer ---------- */
.qs-panel { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: 320px; background: var(--surface); box-shadow: var(--shadow-2); z-index: 70; padding: 16px 24px 24px; overflow-y: auto; transform: translateX(105%); transition: transform .25s var(--ease); border-radius: 16px 0 0 16px; }
.qs-panel.open { transform: none; }
.qs-panel h4 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 20px 0 10px; }
.qs-opt { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; }
.qs-opt .demo { margin-left: auto; width: 56px; height: 36px; border: 1px solid var(--border-strong); border-radius: 6px; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 4px; }
.qs-opt .demo i { display: block; height: 3px; background: var(--border-strong); border-radius: 2px; }

/* ---------- Settings page ---------- */
.settings-page { flex: 1; overflow-y: auto; }
.settings-page .tabs { padding: 0 16px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.settings-content { padding: 8px 32px 48px; max-width: 980px; }
.set-row { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.set-row > .set-label { font-weight: 500; }
.set-row > .set-label small { display: block; font-weight: 400; color: var(--text-3); font-size: 12px; margin-top: 4px; }
.set-row .radios { display: flex; flex-direction: column; gap: 10px; }
.sig-editor { border: 1px solid var(--border-strong); border-radius: 8px; min-height: 120px; padding: 12px; outline: none; }
.sig-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.settings-actions { position: sticky; bottom: 0; background: var(--surface); padding: 16px 0; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ---------- Shortcuts dialog ---------- */
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 32px; }
.kbd-grid h4 { grid-column: 1 / -1; margin: 12px 0 4px; color: var(--primary); }
.kbd-grid div { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; gap: 12px; }

/* ---------- Mobile ---------- */
.fab { display: none; }
.side-scrim { display: none; }
@media (max-width: 1100px) {
  .msg-row { grid-template-columns: auto auto auto 150px 1fr auto; }
}
@media (max-width: 900px) {
  :root { --topbar-h: 60px; }
  .topbar { gap: 4px; padding: 8px; }
  .topbar .brand, .topbar .hide-sm, #q-adv { display: none; }
  .search { height: 44px; min-width: 0; }
  .topbar .top-actions { padding-left: 0; }
  .msg-row .att-ic { display: none; }
  .mail-toolbar { overflow-x: auto; scrollbar-width: none; }
  .mail-toolbar .divider, .mail-toolbar .pager { display: none; }
  body.in-thread .fab { display: none; }
  .msg-head { gap: 12px; }
  .msg-head .when { display: none; }
  .msg-meta .from .addr { display: block; margin-left: 0; }
  .when-sm { display: inline !important; }
  .mail-side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 900; background: var(--surface); width: 280px; padding-top: 12px; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-3); border-radius: 0 16px 16px 0; }
  body.side-open .mail-side { transform: none; }
  body.side-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 899; }
  body.side-collapsed .mail-side { width: 280px; }
  .mail-side .compose-btn { display: none; }
  .mail-main { margin: 0; border-radius: 0; }
  .fab { display: inline-flex; position: fixed; right: 16px; bottom: 16px; z-index: 700; margin: 0; box-shadow: var(--shadow-2); }
  .cat-tabs { display: none; }
  .msg-row { grid-template-columns: 48px 1fr auto; grid-template-rows: auto auto auto; height: auto !important; padding: 10px 12px 10px 8px; gap: 0 8px; background: var(--surface) !important; border-bottom: 0; align-items: start; }
  .msg-row.selected { background: var(--row-selected) !important; }
  .msg-row .cb, .msg-row .imp-btn, .msg-row .hover-actions { display: none !important; }
  .msg-row .avatar-col { display: block; grid-row: 1 / 4; padding-top: 2px; }
  .msg-row .avatar-col .avatar { width: 40px; height: 40px; font-size: 17px; }
  .msg-row .sender { grid-column: 2; grid-row: 1; padding: 0; font-size: 15px; }
  .msg-row .date { grid-column: 3; grid-row: 1; display: block !important; padding: 2px 0 0; min-width: 0; }
  .msg-row .content { grid-column: 2 / 4; grid-row: 2; flex-direction: column; align-items: flex-start; gap: 0; white-space: normal; }
  .msg-row .content .sep { display: none; }
  .msg-row .subj { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
  .msg-row .snip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: calc(100% - 36px); }
  .msg-row .star-btn { grid-column: 3; grid-row: 2; align-self: end; justify-self: end; }
  .msg-row .att-chips { display: flex !important; grid-column: 2 / 4; grid-row: 3; gap: 6px; padding-top: 6px; }
  body.split .mail-body .list-pane { flex: 1; border: 0; }
  body.split .read-pane { display: none; }
  .thread-head { padding: 12px 16px 8px; }
  .msg { padding: 0 12px; }
  .msg-body, .msg-atts { padding-left: 0; }
  .reply-bar { padding: 16px; }
  .inline-reply { margin: 8px 12px 16px; }
  .quote-toggle { margin-left: 0; }
  .compose-dock { right: 0; left: 0; }
  .compose, .compose.full { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; z-index: 960; }
  .compose.min { inset: auto 0 0 auto; width: 100%; height: 40px; }
  .qs-panel { width: 100%; border-radius: 0; }
  .settings-content { padding: 8px 16px 48px; }
  .set-row { grid-template-columns: 1fr; gap: 8px; }
  .mail-toolbar .pager span { display: none; }
}

/* ---- Domino Mail additions ---- */
.msg-body.msg-html { white-space: normal; padding-right: 0; }
.msg-frame { width: 100%; border: 0; display: block; background: #fff; border-radius: 8px; min-height: 60px; color-scheme: light; }
.ext-banner { display: flex; gap: 8px; align-items: center; margin: 0 0 12px 56px; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft, #fef7e0); color: var(--text); font-size: 13px; }
.ext-banner .ms { color: var(--warn, #e37400); }
.qr-box { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qr-box img { width: 180px; height: 180px; border-radius: 12px; background: #fff; padding: 8px; }
@media (max-width: 600px) { .ext-banner { margin-left: 0; } }
