/* Yave Mail — design tokens follow the Yave design system (primary #6D4AFF) */
:root {
  --primary: #6d4aff;
  --primary-hover: #5b3de6;
  --primary-soft: rgba(109, 74, 255, 0.1);
  --secondary: #8b5cf6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f2f7;
  --surface-3: #e7e9f1;
  --border: #e3e5ee;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --row-hover: #f4f4fb;
  --row-active: #ece8ff;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.12), 0 2px 6px rgba(17, 24, 39, 0.06);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 248px;
  --font: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1020;
    --surface: #111827;
    --surface-2: #172033;
    --surface-3: #1f2a40;
    --border: #253049;
    --text: #f8fafc;
    --text-2: #cbd5e1;
    --muted: #94a3b8;
    --row-hover: #162036;
    --row-active: #241f4d;
    --primary-soft: rgba(139, 92, 246, 0.16);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0b1020;
  --surface: #111827;
  --surface-2: #172033;
  --surface-3: #1f2a40;
  --border: #253049;
  --text: #f8fafc;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --row-hover: #162036;
  --row-active: #241f4d;
  --primary-soft: rgba(139, 92, 246, 0.16);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
kbd { font-family: ui-monospace, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
.selectable { user-select: all; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; display: flex; justify-content: center; align-items: center; }
.pad { padding: 28px; }
.ml-auto { margin-left: auto; }
.icon { flex-shrink: 0; }
.boot { height: 100%; display: grid; place-items: center; }

/* ─── Buttons & inputs ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-danger-ghost { color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 44px; font-size: 15px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0 4px; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; flex-shrink: 0; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.sm { width: 28px; height: 28px; }
.input { width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input-sm { height: 32px; width: auto; min-width: 140px; }
.input-lg { height: 44px; font-size: 15px; }
.code-input { text-align: center; letter-spacing: .3em; font-size: 20px; font-family: ui-monospace, monospace; }
.input-group { display: flex; gap: 6px; align-items: center; }
.input-addon { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.row-gap { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.inline-form.wrap { flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 180px; }
.checkbox { display: inline-grid; place-items: center; width: 28px; height: 28px; cursor: pointer; flex-shrink: 0; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.color-input { width: 26px; height: 26px; border: 0; padding: 0; background: none; vertical-align: middle; cursor: pointer; }

.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; }
.alert-error { background: rgba(239, 68, 68, .1); color: #b91c1c; border: 1px solid rgba(239, 68, 68, .25); }
.alert-success { background: rgba(16, 185, 129, .1); color: #047857; border: 1px solid rgba(16, 185, 129, .25); }
:root[data-theme='dark'] .alert-error, :root:not([data-theme='light']) .alert-error { color: #fca5a5; }
@media (prefers-color-scheme: light) { :root:not([data-theme='dark']) .alert-error { color: #b91c1c; } }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.pill-ok { background: rgba(16, 185, 129, .14); color: var(--success); }
.pill-bad { background: rgba(239, 68, 68, .14); color: var(--danger); }
.pill-primary { background: var(--primary-soft); color: var(--primary); }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 0 7px; height: 19px; border-radius: 5px; border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.tag-x { border: 0; background: none; cursor: pointer; padding: 0 0 0 2px; color: inherit; font-size: 13px; line-height: 1; }
.label-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; display: inline-block; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot-sent { background: var(--success); } .dot-failed { background: var(--danger); } .dot-pending { background: var(--warning); }
.err-text { word-break: break-word; max-width: 420px; }

.spinner { display: inline-block; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); position: relative; transition: background .2s; flex-shrink: 0; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px var(--primary-soft); }
.toggle.disabled { opacity: .5; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; margin-bottom: 8px; }
.segmented button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 500; }

/* ─── Auth screens ─── */
.auth-page { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(109,74,255,.18), transparent), radial-gradient(900px 500px at 110% 110%, rgba(139,92,246,.14), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; margin: 24px 0 6px; }
.auth-card > p { margin: 0 0 20px; }
.auth-brand { display: flex; gap: 12px; align-items: center; }
.auth-footer { margin-top: 18px; text-align: center; font-size: 13.5px; }
.auth-note { margin-top: 18px; display: flex; gap: 6px; align-items: center; }
.logo-mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--secondary), var(--primary)); box-shadow: 0 6px 16px rgba(109,74,255,.35); }
.logo-mark.sm { width: 30px; height: 30px; border-radius: 8px; }
.logo-text { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.logo-text span { color: var(--primary); }

/* ─── Shell ─── */
.shell { display: flex; height: 100%; overflow: hidden; }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); height: 100%; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 18px; }
.btn-compose { margin: 4px 14px 10px; height: 42px; border-radius: 12px; font-size: 14.5px; box-shadow: 0 4px 12px rgba(109,74,255,.25); }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.nav-item { display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: 8px; color: var(--text-2); cursor: pointer; text-decoration: none !important; font-weight: 500; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; font-weight: 600; color: var(--text-2); }
.nav-count.strong { background: var(--primary); color: #fff; padding: 0 7px; border-radius: 99px; line-height: 19px; }
.nav-section { display: flex; align-items: center; justify-content: space-between; margin: 16px 4px 4px 10px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav-hint { padding: 2px 10px 6px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px; }
.usage { padding: 4px 10px 10px; }
.usage-bar { height: 5px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.usage-bar > div { height: 100%; background: var(--primary); border-radius: 99px; }
.usage-bar > div.danger { background: var(--danger); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.content { flex: 1; min-height: 0; overflow: hidden; }
.drawer-scrim { display: none; }

.topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.search { flex: 1; max-width: 720px; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); border: 1px solid transparent; }
.search:focus-within { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); font: inherit; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; display: flex; }
.avatar { border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; flex-shrink: 0; letter-spacing: .02em; }
.mobile-only { display: none; }

/* ─── Menus, modals, toasts ─── */
.menu-wrap { position: relative; display: inline-flex; }
.menu { position: absolute; top: calc(100% + 6px); z-index: 60; min-width: 220px; max-height: 60vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.menu-left { left: 0; } .menu-right { right: 0; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; color: var(--text); text-decoration: none !important; font-size: 13.5px; white-space: nowrap; }
.menu-item:hover { background: var(--surface-2); }
.menu-header { padding: 6px 10px; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(8, 10, 20, .5); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow-y: auto; animation: fade .15s; }
.modal { width: 100%; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--border); animation: pop .18s ease-out; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px 22px; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 8px 22px 18px; }
.modal-body p { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 10px; background: #1f2937; color: #f9fafb; box-shadow: var(--shadow); font-size: 13.5px; animation: pop .2s; }
.toast-error { background: #b91c1c; }
.toast-success { background: #047857; }
.toast-action { border: 0; background: none; color: #c4b5fd; font-weight: 700; cursor: pointer; text-transform: uppercase; font-size: 12.5px; letter-spacing: .04em; }
.toast-close { border: 0; background: none; color: inherit; opacity: .7; cursor: pointer; display: grid; place-items: center; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; }
.empty-icon { width: 72px; height: 72px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; margin-bottom: 14px; }
.empty h3 { font-size: 16px; margin-bottom: 4px; }
.empty p { margin: 0; max-width: 320px; }

/* ─── Mail view ─── */
.mail-view { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; height: 100%; }
.list-pane { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); min-height: 0; min-width: 0; }
.list-head { padding: 14px 12px 6px 16px; border-bottom: 1px solid var(--border); }
.list-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.list-title h1 { font-size: 19px; }
.toolbar { display: flex; align-items: center; gap: 2px; min-height: 36px; flex-wrap: wrap; }
.list-body { flex: 1; overflow-y: auto; }
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-row { display: flex; align-items: flex-start; gap: 2px; padding: 10px 14px 10px 8px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; outline: none; }
.msg-row:hover { background: var(--row-hover); }
.msg-row.active { background: var(--row-active); }
.msg-row.selected { background: var(--primary-soft); }
.msg-row.focused { box-shadow: inset 3px 0 0 var(--primary); }
.msg-row.unread::before { content: ''; position: absolute; left: 2px; top: 50%; width: 5px; height: 5px; margin-top: -2px; border-radius: 50%; background: var(--primary); }
.msg-row .checkbox, .msg-row .star-btn { margin-top: 1px; }
.msg-main { flex: 1; min-width: 0; padding-left: 4px; }
.msg-top { display: flex; align-items: baseline; gap: 8px; }
.msg-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.msg-date { font-size: 12px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; }
.msg-subject-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.msg-subject { color: var(--text-2); }
.msg-snippet { color: var(--muted); }
.msg-row.unread .msg-from, .msg-row.unread .msg-subject { color: var(--text); font-weight: 650; }
.msg-row.unread .msg-date { color: var(--primary); font-weight: 600; }
.msg-tags { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.msg-list.compact .msg-row { padding-top: 6px; padding-bottom: 6px; }
.msg-list.compact .msg-tags { display: none; }
.thread-count { font-size: 11px; color: var(--muted); margin-left: 4px; font-weight: 500; }
.draft-tag { color: var(--danger); font-weight: 600; }
.star-btn { border: 0; background: none; cursor: pointer; color: var(--muted); opacity: .55; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; }
.star-btn:hover { opacity: 1; background: var(--surface-2); }
.star-btn.on { color: #f59e0b; opacity: 1; }
.star-btn.on svg { fill: #f59e0b; }

.reader-pane { min-width: 0; min-height: 0; background: var(--bg); }
.reader-empty { height: 100%; display: grid; place-items: center; }
.reader { height: 100%; display: flex; flex-direction: column; }
.reader-toolbar { display: flex; align-items: center; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.toolbar-nav { display: flex; align-items: center; gap: 2px; }
.reader-scroll { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }
.reader-subject { margin: 0 0 14px; }
.reader-subject h2 { font-size: 21px; font-weight: 650; word-break: break-word; }
.reader-labels { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.thread-msg { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.thread-msg.collapsed { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; }
.thread-msg.collapsed:hover { background: var(--row-hover); }
.tm-head { display: flex; gap: 12px; padding: 14px 16px 10px; cursor: pointer; align-items: flex-start; }
.tm-head-text { flex: 1; min-width: 0; }
.tm-snippet { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.thread-msg.collapsed .tm-head-text { display: flex; gap: 10px; align-items: baseline; }
.thread-msg.collapsed .tm-head-text strong { white-space: nowrap; }
.tm-from { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tm-to { cursor: pointer; display: inline-flex; align-items: center; gap: 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-meta { display: flex; align-items: center; gap: 2px; }
.tm-details { margin: 0 16px 10px 68px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; display: flex; flex-direction: column; gap: 3px; word-break: break-word; }
.auth-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.auth-badge.ok { background: rgba(16,185,129,.12); color: var(--success); }
.auth-badge.bad { background: rgba(239,68,68,.12); color: var(--danger); }
.email-frame { display: block; width: calc(100% - 32px); margin: 0 16px 14px; border: 0; min-height: 60px; border-radius: 6px; background: #fff; }
.banner { display: flex; align-items: center; gap: 10px; margin: 0 16px 12px; padding: 9px 12px; border-radius: 9px; font-size: 13px; flex-wrap: wrap; }
.banner > span { flex: 1; min-width: 200px; }
.reader-scroll > .banner { margin: 0 0 12px; }
.banner-info { background: var(--primary-soft); color: var(--text); }
.banner-warn { background: rgba(245,158,11,.14); }
.banner-danger { background: rgba(239,68,68,.12); color: var(--danger); font-weight: 500; }
.attachments { padding: 0 16px 16px; }
.att-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att-chip { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); width: 240px; max-width: 100%; }
.att-icon { width: 36px; height: 36px; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--primary); flex-shrink: 0; }
.att-icon img { width: 100%; height: 100%; object-fit: cover; }
.att-info { flex: 1; min-width: 0; }
.att-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ─── Compose ─── */
.compose { position: fixed; right: 24px; bottom: 0; z-index: 80; width: 600px; max-width: calc(100vw - 32px); height: min(640px, calc(100vh - 80px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: 14px 14px 0 0; box-shadow: var(--shadow); }
.compose-max { right: 50%; transform: translateX(50%); bottom: 4vh; width: min(1000px, calc(100vw - 48px)); height: 90vh; border-radius: 14px; border-bottom: 1px solid var(--border); }
.compose-min { height: 44px; width: 320px; flex-direction: row; align-items: center; justify-content: space-between; padding: 0 8px 0 16px; cursor: pointer; font-weight: 600; }
.compose-min span { display: flex; gap: 8px; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.compose-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; background: var(--surface-2); border-radius: 14px 14px 0 0; }
.compose-head > div { display: flex; }
.save-state { font-weight: 400; }
.compose-fields { border-bottom: 1px solid var(--border); }
.rcpt-row { display: flex; align-items: center; gap: 8px; padding: 0 14px; min-height: 42px; border-bottom: 1px solid var(--border); position: relative; }
.rcpt-row:last-child { border-bottom: 0; }
.rcpt-label { color: var(--muted); font-size: 13px; width: 34px; flex-shrink: 0; }
.rcpt-box { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 6px 0; position: relative; min-width: 0; }
.rcpt-input { flex: 1; min-width: 120px; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; height: 26px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 99px; background: var(--primary-soft); color: var(--text); font-size: 13px; max-width: 100%; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; }
.chip-bad { background: rgba(239,68,68,.15); color: var(--danger); }
.suggest { position: absolute; top: 100%; left: 0; z-index: 90; list-style: none; margin: 2px 0 0; padding: 4px; min-width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); }
.suggest li { padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.suggest li.active, .suggest li:hover { background: var(--surface-2); }
.subject-input { flex: 1; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-weight: 500; height: 40px; }
.from-select { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; outline: none; height: 40px; }
.editor-toolbar { display: flex; align-items: center; gap: 1px; padding: 4px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.tb-select { height: 28px; border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer; border-radius: 6px; }
.tb-color { position: relative; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--text-2); cursor: pointer; }
.tb-color:hover { background: var(--surface-2); }
.tb-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.editor { flex: 1; overflow-y: auto; padding: 14px 16px; outline: none; font-size: 14.5px; line-height: 1.6; word-wrap: break-word; }
.editor blockquote, .editor .yave-quote blockquote { margin: 6px 0 6px 4px; padding-left: 12px; border-left: 3px solid var(--border); color: var(--text-2); }
.editor .yave-quote { color: var(--text-2); }
.editor img { max-width: 100%; }
.editor-box { min-height: 160px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.compose-atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--border); max-height: 130px; overflow-y: auto; }
.compose-foot { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border); }
.send-group { display: flex; }
.send-group > .btn { border-radius: var(--radius-sm) 0 0 var(--radius-sm); padding: 0 18px; }
.send-group .send-more { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 0 8px; border-left: 1px solid rgba(255,255,255,.3); }
.send-group .menu { bottom: calc(100% + 6px); top: auto; min-width: 320px; }
.drag-over { outline: 3px dashed var(--primary); outline-offset: -6px; }
.drop-hint { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 8px; background: rgba(109,74,255,.08); color: var(--primary); font-weight: 600; pointer-events: none; border-radius: 14px; }

/* ─── Settings / admin pages ─── */
.page { height: 100%; overflow-y: auto; padding: 20px 24px 60px; }
.page-head { display: flex; align-items: center; gap: 8px; max-width: 1100px; margin: 0 auto 16px; }
.page-head h1 { font-size: 22px; }
.page-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; max-width: 1100px; margin: 0 auto; align-items: start; }
.tabs-vertical { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.tab { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; text-decoration: none !important; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--primary-soft); color: var(--primary); }
.page-content { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 0; }
.card-head h2 { font-size: 16px; }
.card-head p { margin: 4px 0 0; }
.card-body { padding: 14px 20px 18px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.kv th { width: 180px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--border); }
.row-warn td { background: rgba(239,68,68,.05); }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.codes code { font-size: 15px; padding: 8px; text-align: center; }
.secret-box { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 14px; background: var(--surface-2); border-radius: 10px; margin-top: 10px; }
.secret-box code { font-size: 20px; letter-spacing: .08em; background: none; }
.qr { border-radius: 10px; background: #fff; padding: 8px; margin: 6px 0; }
.steps { padding-left: 20px; margin: 6px 0; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.checklist { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat-value { font-size: 20px; font-weight: 700; }
.dns-records { margin: 6px 0 14px; display: flex; flex-direction: column; gap: 8px; }
.dns-record { display: flex; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.dns-type { font-weight: 700; font-size: 12px; min-width: 46px; color: var(--primary); padding-top: 2px; }
.dns-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dns-value { display: flex; align-items: flex-start; gap: 4px; }
.dns-value code { flex: 1; }
.dns-results { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.dns-check { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; flex-wrap: wrap; }
.dns-check.ok { background: rgba(16,185,129,.1); color: var(--success); }
.dns-check.bad { background: rgba(239,68,68,.08); color: var(--danger); }
.dns-check .muted { word-break: break-all; }

/* ─── Responsive ─── */
@media (max-width: 1180px) {
  .mail-view { grid-template-columns: 1fr; }
  .mail-view .reader-pane { display: none; }
  .mail-view.has-reader .list-pane { display: none; }
  .mail-view.has-reader .reader-pane { display: block; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 70; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .drawer-open .sidebar { transform: none; }
  .drawer-open .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.4); }
  .mobile-only { display: inline-grid; }
  .desktop-only { display: none; }
  .page-layout { grid-template-columns: 1fr; }
  .tabs-vertical { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 4px; }
  .tab { white-space: nowrap; }
  .compose, .compose-max { right: 0; left: 0; bottom: 0; top: 0; width: 100%; max-width: 100%; height: 100%; transform: none; border-radius: 0; }
  .compose-head { border-radius: 0; }
  .compose-min { top: auto; height: 48px; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 8px; gap: 6px; }
  .search input::placeholder { color: transparent; }
  .reader-scroll { padding: 14px 10px 30px; }
  .page { padding: 14px 12px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .tm-meta .nowrap { display: none; }
  .tm-details { margin-left: 16px; }
  .email-frame { width: calc(100% - 16px); margin: 0 8px 12px; }
  .setting-row { flex-direction: column; align-items: flex-start; }
  .card-head { flex-direction: column; }
  .auth-card { padding: 24px 20px; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .send-group .menu { min-width: 260px; }
}
@media print {
  .sidebar, .topbar, .list-pane, .reader-toolbar, .reply-bar { display: none !important; }
}

/* ─── v2: security & compliance UI ─── */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
textarea.input { width: 100%; resize: vertical; line-height: 1.45; }
.filter-rule { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.filter-rule .input { width: auto; min-width: 120px; flex: 1 1 140px; }
.mailbox-switch { margin: 0 12px 10px; width: calc(100% - 24px); }
.bimi-logo { width: 18px; height: 18px; border-radius: 4px; vertical-align: middle; margin-left: 4px; }
.icon-btn.active-lock { color: var(--success, #10B981); background: color-mix(in srgb, var(--success, #10B981) 14%, transparent); }
.shared-box { padding: 12px 0; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.checkbox { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.45; }
.checkbox input { margin-top: 3px; }
