/* ===== میل‌یو — رابط کاربری شبیه جیمیل (راست‌به‌چپ) ===== */
:root {
  --bg: #f6f8fc; --surface: #fff; --surface-2: #f2f6fc; --hover: #f2f6fc; --row-read: #f2f6fc; --row-unread: #fff;
  --text: #1f1f1f; --text-2: #444746; --text-3: #5f6368; --border: #e0e2e6; --divider: #eceff1;
  --primary: #0b57d0; --primary-soft: #d3e3fd; --compose: #c2e7ff; --compose-hover: #b3dcf7;
  --selected-row: #c2dbff; --danger: #b3261e; --star: #f4b400; --important: #e8a700; --success: #188038;
  --shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2: 0 4px 8px 3px rgba(60,64,67,.15), 0 1px 3px rgba(60,64,67,.3);
  --radius: 16px; --row-h: 40px;
  --font: 'Vazirmatn', 'Segoe UI', Tahoma, system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111418; --surface: #1b1e23; --surface-2: #23272e; --hover: #262a31; --row-read: #1b1e23; --row-unread: #23272e;
  --text: #e3e3e3; --text-2: #c4c7c5; --text-3: #9aa0a6; --border: #3c4043; --divider: #2c3036;
  --primary: #a8c7fa; --primary-soft: #004a77; --compose: #004a77; --compose-hover: #0b5c8f;
  --selected-row: #2c4a73; --danger: #f2b8b5; --shadow: 0 1px 3px rgba(0,0,0,.6); --shadow-2: 0 6px 16px rgba(0,0,0,.6);
  color-scheme: dark;
}
:root[data-density="compact"] { --row-h: 32px; }
:root[data-density="comfortable"] { --row-h: 48px; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--primary); }
.hidden { display: none !important; }
.ltr { direction: ltr; unicode-bidi: plaintext; }
.muted { color: var(--text-3); }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
svg.i { width: 20px; height: 20px; fill: currentColor; flex: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* boot */
#app.booting { display: grid; place-items: center; height: 100%; }
.boot-logo img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; transform: scale(.92); } }

/* ===== buttons ===== */
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--text-2); flex: none; position: relative; }
.icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm svg.i { width: 18px; height: 18px; }
.icon-btn[disabled] { opacity: .38; pointer-events: none; }
.btn { height: 36px; padding: 0 20px; border-radius: 18px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.btn.primary { background: var(--primary); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #062e6f; }
.btn.primary:hover { box-shadow: var(--shadow); filter: brightness(1.05); }
.btn.tonal { background: var(--primary-soft); color: var(--text); }
.btn.outline { border: 1px solid var(--border); color: var(--primary); }
.btn.outline:hover, .btn.text:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.btn.text { color: var(--primary); padding: 0 12px; }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ===== layout ===== */
.shell { display: grid; grid-template-columns: var(--nav-w, 256px) minmax(0, 1fr); grid-template-rows: 64px 1fr; height: 100vh; height: 100dvh; }
.shell.nav-collapsed { --nav-w: 72px; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; }
.brand { display: flex; align-items: center; gap: 4px; min-width: calc(var(--nav-w) - 16px); }
.brand img { width: 36px; height: 36px; }
.brand b { font-size: 22px; color: var(--text-2); font-weight: 500; margin-inline-start: 4px; }
.nav-collapsed .brand b { display: none; }
.search { flex: 1; max-width: 720px; height: 48px; background: color-mix(in srgb, var(--primary) 7%, var(--bg)); border-radius: 24px; display: flex; align-items: center; padding: 0 4px; position: relative; }
:root[data-theme="dark"] .search { background: var(--surface-2); }
.search:focus-within { background: var(--surface); box-shadow: var(--shadow-2); }
.search input { flex: 1; border: 0; background: none; outline: 0; font-size: 16px; padding: 0 8px; min-width: 0; }
.adv-search { position: absolute; top: 52px; inset-inline: 0; background: var(--surface); box-shadow: var(--shadow-2); border-radius: 8px; padding: 20px 24px; z-index: 30; display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; align-items: center; }
.adv-search input[type=text], .adv-search select { border: 0; border-bottom: 1px solid var(--border); padding: 6px 2px; background: none; outline: 0; }
.adv-search input:focus { border-color: var(--primary); }
.adv-search .actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.top-actions { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; flex: none; text-transform: uppercase; user-select: none; }
.avatar.lg { width: 40px; height: 40px; font-size: 18px; }
.avatar.xl { width: 80px; height: 80px; font-size: 36px; }

/* ===== sidebar ===== */
.sidebar { overflow-y: auto; padding: 8px 8px 16px 0; scrollbar-width: thin; }
.compose-btn { display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 20px 0 24px; margin: 0 8px 16px; border-radius: 16px; background: var(--compose); font-weight: 500; font-size: 14px; transition: box-shadow .15s; }
.compose-btn:hover { box-shadow: var(--shadow); background: var(--compose-hover); }
.compose-btn svg { width: 24px; height: 24px; }
.nav-collapsed .compose-btn { width: 56px; padding: 0; justify-content: center; }
.nav-collapsed .compose-btn span, .nav-collapsed .nav-item .label, .nav-collapsed .nav-item .count, .nav-collapsed .nav-section { display: none; }
.nav-item { display: flex; align-items: center; gap: 16px; height: 32px; padding: 0 26px 0 12px; border-radius: 0 16px 16px 0; color: var(--text-2); text-decoration: none; cursor: pointer; font-size: 14px; position: relative; }
.nav-item:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.nav-item.active { background: var(--primary-soft); color: var(--text); font-weight: 700; }
.nav-item.unread { font-weight: 700; color: var(--text); }
.nav-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count { font-size: 12px; font-weight: 700; }
.nav-item .dot { width: 12px; height: 12px; border-radius: 3px; flex: none; margin: 0 4px; }
.nav-item .more { position: absolute; inset-inline-end: 4px; opacity: 0; }
.nav-item:hover .more { opacity: 1; }
.nav-item.indent { padding-inline-start: calc(26px + var(--depth, 0) * 16px); }
.nav-section { display: flex; align-items: center; justify-content: space-between; padding: 16px 26px 4px 8px; font-size: 16px; font-weight: 500; }
.storage { margin: 16px 26px 0 12px; font-size: 12px; color: var(--text-3); }
.storage .bar { height: 4px; border-radius: 2px; background: var(--divider); margin-bottom: 6px; overflow: hidden; }
.storage .bar i { display: block; height: 100%; background: var(--primary); }

/* ===== main ===== */
.main { background: var(--surface); border-radius: var(--radius); margin: 0 0 16px 16px; display: flex; flex-direction: column; min-width: 0; overflow: hidden; position: relative; }
.toolbar { display: flex; align-items: center; gap: 2px; padding: 8px 16px; min-height: 48px; border-bottom: 1px solid transparent; flex-wrap: nowrap; }
.toolbar.scrolled { border-color: var(--divider); }
.toolbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.toolbar .pager { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.checkbox { width: 18px; height: 18px; border: 2px solid var(--text-3); border-radius: 2px; display: inline-grid; place-items: center; cursor: pointer; flex: none; background: transparent; }
.checkbox.on { background: var(--text-2); border-color: var(--text-2); }
.checkbox.on::after { content: ''; width: 5px; height: 10px; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.checkbox.some { background: var(--text-2); border-color: var(--text-2); }
.checkbox.some::after { content: ''; width: 8px; height: 2px; background: var(--surface); }
.sel-wrap { display: flex; align-items: center; padding: 0 4px 0 0; border-radius: 4px; }
.sel-wrap:hover { background: var(--hover); }

.tabs { display: flex; border-bottom: 1px solid var(--divider); overflow-x: auto; scrollbar-width: none; flex: none; }
.tab { text-decoration: none; flex: 0 1 252px; min-width: 120px; height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 16px; color: var(--text-2); position: relative; font-weight: 500; }
.tab:hover { background: var(--hover); }
.tab.active { color: var(--primary); }
.tab.active::after { content: ''; position: absolute; bottom: 0; inset-inline: 8px; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }
.tab .badge { font-size: 11px; padding: 0 8px; border-radius: 10px; color: #fff; background: var(--tab-c, var(--primary)); }
.tab .sub { font-size: 12px; color: var(--text-3); font-weight: 400; }

.list { flex: 1; overflow-y: auto; overflow-x: hidden; }
.row { display: flex; align-items: center; height: var(--row-h); padding: 0 16px 0 8px; gap: 4px; border-bottom: 1px solid var(--divider); background: var(--row-read); cursor: pointer; position: relative; }
.row.unread { background: var(--row-unread); font-weight: 700; }
.row.unread .snippet { font-weight: 400; }
.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: 1; }
:root[data-theme="dark"] .row:hover { box-shadow: 0 2px 6px rgba(0,0,0,.6); }
.row.selected { background: var(--selected-row); }
.row.focused::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.row .lead { display: flex; align-items: center; gap: 0; flex: none; }
.row .star.on svg { fill: var(--star); }
.row .imp.on svg { fill: var(--important); }
.row .from { width: 200px; flex: none; padding-inline-end: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .from .cnt { color: var(--text-3); font-weight: 400; font-size: 12px; margin-inline-start: 4px; }
.row .from .draft { color: var(--danger); font-weight: 400; }
.row .content { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.row .line { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
.row .subject { flex: none; max-width: 70%; overflow: hidden; text-overflow: ellipsis; }
.row .snippet { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.row .atts { display: flex; gap: 8px; margin-top: 2px; }
.chip-att { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: 13px; font-size: 12px; font-weight: 400; max-width: 180px; background: var(--surface); }
.chip-att svg { width: 16px; height: 16px; fill: var(--danger); }
.row .date { width: 92px; text-align: end; font-size: 12px; flex: none; white-space: nowrap; }
.row.unread .date { color: var(--text); }
.row .hover-actions { display: none; position: absolute; inset-inline-end: 8px; background: inherit; align-items: center; }
.row:hover .hover-actions { display: flex; }
.row:hover .date { visibility: hidden; }
.row.has-atts { height: calc(var(--row-h) + 30px); }
.lbl { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 500; background: var(--lc, #ddd); color: var(--ltc, #222); flex: none; white-space: nowrap; }
.lbl.cat { background: transparent; border: 1px solid var(--border); color: var(--text-3); }
.empty { padding: 64px 24px; text-align: center; color: var(--text-3); }
.empty svg { width: 96px; height: 96px; fill: var(--border); }

/* ===== thread view ===== */
.thread { flex: 1; overflow-y: auto; padding: 0 0 48px; }
.thread-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 72px 8px 24px; }
.thread-head h1 { font-size: 22px; font-weight: 400; margin: 0; flex: 1; line-height: 1.5; word-break: break-word; }
.thread-head .lbl { font-size: 12px; height: 20px; margin-inline-start: 6px; vertical-align: middle; }
.msg { padding: 0 24px 0 24px; }
.msg + .msg { border-top: 1px solid var(--divider); }
.msg-head { display: flex; gap: 12px; padding: 16px 0 8px; cursor: pointer; align-items: flex-start; }
.msg-head .who { flex: 1; min-width: 0; }
.msg-head .name { font-weight: 700; }
.msg-head .addr { color: var(--text-3); font-size: 12px; }
.msg-head .to { color: var(--text-3); font-size: 12px; display: flex; align-items: center; gap: 2px; }
.msg-head .meta { display: flex; align-items: center; gap: 2px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.msg.collapsed .msg-head { padding: 12px 0; }
.msg.collapsed .snippet { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.msg-body { padding: 0 0 16px 52px; padding-inline-start: 52px; padding-inline-end: 0; }
.msg-body iframe { width: 100%; border: 0; min-height: 40px; display: block; background: #fff; border-radius: 4px; }
.msg-body .plain { white-space: pre-wrap; word-break: break-word; font-family: var(--font); }
.details-pop { background: var(--surface); box-shadow: var(--shadow-2); border-radius: 8px; padding: 12px 16px; font-size: 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.details-pop dt { color: var(--text-3); text-align: end; }
.details-pop dd { margin: 0; }
.img-banner { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; flex-wrap: wrap; }
.warn-banner { display: flex; align-items: center; gap: 12px; background: #fce8e6; color: #5f2120; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }
:root[data-theme="dark"] .warn-banner { background: #5c2b29; color: #f6aea9; }
.att-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--divider); }
.att-card { width: 180px; height: 120px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; position: relative; display: flex; flex-direction: column; background: var(--surface-2); text-decoration: none; color: inherit; }
.att-card .thumb { flex: 1; display: grid; place-items: center; overflow: hidden; }
.att-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-card .thumb svg { width: 40px; height: 40px; fill: var(--text-3); }
.att-card .info { height: 40px; padding: 4px 10px; font-size: 12px; background: var(--surface); display: flex; align-items: center; gap: 6px; }
.att-card .ov { position: absolute; inset: 0; background: rgba(0,0,0,.55); color: #fff; display: none; align-items: center; justify-content: center; gap: 8px; }
.att-card:hover .ov { display: flex; }
.att-card .ov .icon-btn { color: #fff; background: rgba(255,255,255,.15); }
.reply-bar { display: flex; gap: 12px; padding: 16px 24px 0 76px; padding-inline-start: 76px; flex-wrap: wrap; }
.inline-compose { margin: 16px 24px 0 24px; margin-inline-start: 76px; border-radius: 8px; box-shadow: var(--shadow-2); background: var(--surface); }

/* ===== compose ===== */
#compose-dock { position: fixed; bottom: 0; inset-inline-end: 16px; display: flex; align-items: flex-end; gap: 16px; z-index: 50; flex-direction: row; pointer-events: none; }
.compose { width: 540px; height: 580px; max-height: calc(100vh - 80px); background: var(--surface); border-radius: 12px 12px 0 0; box-shadow: var(--shadow-2), 0 8px 10px 1px rgba(0,0,0,.14); display: flex; flex-direction: column; pointer-events: auto; overflow: hidden; }
.compose.minimized { height: 40px; width: 280px; }
.compose.minimized .c-body { display: none; }
.compose.full { position: fixed; inset: 5vh 10vw; width: auto; height: auto; max-height: none; border-radius: 12px; z-index: 60; }
.compose-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; pointer-events: auto; }
.c-head { height: 40px; background: var(--surface-2); display: flex; align-items: center; padding: 0 12px 0 4px; font-weight: 500; cursor: pointer; flex: none; }
.c-head .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.c-head .icon-btn { width: 28px; height: 28px; }
.c-head .icon-btn svg { width: 16px; height: 16px; }
.c-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.inline-compose .c-body { min-height: 260px; }
.c-field { display: flex; align-items: center; min-height: 40px; margin: 0 16px; border-bottom: 1px solid var(--divider); gap: 4px; flex-wrap: wrap; position: relative; padding: 4px 0; }
.c-field > .lab { color: var(--text-3); min-width: 40px; }
.c-field input.bare { flex: 1; border: 0; outline: 0; background: none; min-width: 120px; height: 30px; }
.c-field .cc-toggles { display: flex; gap: 8px; color: var(--text-3); margin-inline-start: auto; }
.c-field .cc-toggles button:hover { text-decoration: underline; }
.rchip { display: inline-flex; align-items: center; gap: 4px; height: 26px; border-radius: 13px; padding: 0 4px 0 10px; padding-inline-start: 4px; padding-inline-end: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; max-width: 100%; }
.rchip.invalid { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.rchip .avatar { width: 20px; height: 20px; font-size: 10px; }
.rchip button { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; }
.rchip button:hover { background: var(--hover); }
.rchip button svg { width: 14px; height: 14px; }
.suggest { position: absolute; top: 100%; inset-inline-start: 30px; min-width: 320px; background: var(--surface); box-shadow: var(--shadow-2); border-radius: 8px; z-index: 5; padding: 6px 0; max-height: 280px; overflow-y: auto; }
.suggest .it { display: flex; align-items: center; gap: 12px; padding: 6px 16px; cursor: pointer; }
.suggest .it.on, .suggest .it:hover { background: var(--hover); }
.suggest .it small { color: var(--text-3); display: block; font-size: 12px; }
.c-editor { flex: 1; overflow-y: auto; padding: 12px 16px; outline: 0; min-height: 120px; word-break: break-word; }
.c-editor:empty::before { content: attr(data-ph); color: var(--text-3); }
.c-editor blockquote { margin: 0 0 0 .8ex; margin-inline-start: .8ex; border-inline-start: 1px solid #ccc; padding-inline-start: 1ex; }
.c-editor .quote-toggle, .msg-body .quote-toggle { display: inline-block; background: var(--surface-2); border-radius: 6px; padding: 0 6px; cursor: pointer; letter-spacing: 2px; margin: 4px 0; }
.c-atts { display: flex; flex-direction: column; gap: 4px; padding: 0 16px 8px; }
.c-att { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 4px; padding: 4px 8px; font-size: 13px; }
.c-att .progress { height: 3px; background: var(--primary); border-radius: 2px; }
.fmt-bar { display: flex; flex-wrap: wrap; gap: 0; padding: 2px 12px; margin: 0 16px 4px; border-radius: 8px; background: var(--surface-2); }
.fmt-bar .icon-btn { width: 30px; height: 30px; border-radius: 4px; }
.fmt-bar .icon-btn svg { width: 18px; height: 18px; }
.fmt-bar select { border: 0; background: none; padding: 0 4px; }
.c-foot { display: flex; align-items: center; gap: 4px; padding: 10px 16px 14px; flex: none; }
.send-group { display: inline-flex; border-radius: 18px; overflow: hidden; }
.send-group .btn { border-radius: 0; }
.send-group .btn:first-child { border-radius: 0 18px 18px 0; padding-inline: 24px 16px; }
.send-group .btn.caret { padding: 0 8px; border-inline-start: 1px solid rgba(255,255,255,.35); border-radius: 18px 0 0 18px; }
.drop-zone { position: absolute; inset: 0; background: color-mix(in srgb, var(--primary) 18%, var(--surface)); border: 3px dashed var(--primary); border-radius: 8px; display: grid; place-items: center; font-size: 20px; color: var(--primary); z-index: 3; }

/* ===== menus, modals, toasts ===== */
.menu { position: fixed; z-index: 200; background: var(--surface); box-shadow: var(--shadow-2); border-radius: 6px; padding: 6px 0; min-width: 200px; max-height: 70vh; overflow-y: auto; }
.menu .mi { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 34px; cursor: pointer; white-space: nowrap; width: 100%; text-align: start; }
.menu .mi:hover, .menu .mi.on { background: var(--hover); }
.menu .mi svg { width: 18px; height: 18px; fill: var(--text-3); }
.menu .mi small { margin-inline-start: auto; color: var(--text-3); }
.menu hr { border: 0; border-top: 1px solid var(--divider); margin: 6px 0; }
.menu .mh { padding: 4px 16px; font-size: 12px; color: var(--text-3); }
.menu input.menu-search { margin: 4px 12px 6px; width: calc(100% - 24px); border: 0; border-bottom: 1px solid var(--border); outline: 0; padding: 4px; background: none; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 150; display: grid; place-items: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-2); width: min(480px, 100%); max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal.wide { width: min(720px, 100%); }
.modal h2 { margin: 0 0 16px; font-size: 22px; font-weight: 400; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-2); }
.input, .field input, .field select, .field textarea { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface); outline: 0; width: 100%; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.swatches { display: grid; grid-template-columns: repeat(8, 28px); gap: 6px; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; }
.swatches button.on { border-color: var(--text); }
#toasts { position: fixed; bottom: 24px; inset-inline-start: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #303030; color: #f2f2f2; border-radius: 4px; padding: 0 8px 0 16px; min-height: 48px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-2); animation: slide .2s; font-size: 14px; max-width: 560px; }
:root[data-theme="dark"] .toast { background: #e3e3e3; color: #1f1f1f; }
.toast button { color: #a8c7fa; font-weight: 600; padding: 8px; border-radius: 4px; }
:root[data-theme="dark"] .toast button { color: #0b57d0; }
.toast button:hover { background: rgba(255,255,255,.08); }
.toast .x { color: inherit; display: grid; place-items: center; }
@keyframes slide { from { transform: translateY(16px); opacity: 0; } }

/* ===== settings / pages ===== */
.page { flex: 1; overflow-y: auto; }
.page-head { padding: 20px 24px 0; font-size: 22px; }
.stabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--divider); overflow-x: auto; scrollbar-width: none; }
.stabs a { padding: 14px 16px; color: var(--text-2); text-decoration: none; white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 500; }
.stabs a.on { color: var(--primary); border-color: var(--primary); }
.srow { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding: 18px 24px; border-bottom: 1px solid var(--divider); }
.srow > .k { font-weight: 600; color: var(--text-2); }
.srow > .k small { display: block; font-weight: 400; color: var(--text-3); margin-top: 4px; }
.srow .v { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.srow .v .input { max-width: 420px; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.save-bar { position: sticky; bottom: 0; background: var(--surface); padding: 16px 24px; border-top: 1px solid var(--divider); display: flex; gap: 8px; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--divider); font-size: 13px; vertical-align: middle; }
table.tbl th { color: var(--text-3); font-weight: 500; }
.sig-editor { border: 1px solid var(--border); border-radius: 8px; min-height: 120px; padding: 10px; width: 100%; max-width: 560px; outline: 0; }
.kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; font-family: monospace; text-align: center; font-size: 12px; direction: ltr; }
.contact-card { display: flex; align-items: center; gap: 16px; padding: 10px 24px; border-bottom: 1px solid var(--divider); }
.contact-card:hover { background: var(--hover); }

/* ===== auth ===== */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
body:has(.auth-wrap) { overflow: auto; }
.auth-card { background: var(--surface); border-radius: 28px; padding: 36px 40px; width: min(1040px, 100%); display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.auth-card .side img { width: 48px; height: 48px; }
.auth-card h1 { font-size: 36px; font-weight: 400; margin: 16px 0 12px; line-height: 1.3; }
.auth-card .side p { font-size: 16px; color: var(--text-2); margin: 0; }
.auth-card form { display: flex; flex-direction: column; gap: 4px; padding-top: 48px; }
.auth-card .email-field { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.auth-card .email-field input { border: 0; box-shadow: none !important; flex: 1; text-align: left; direction: ltr; }
.auth-card .email-field span { padding: 0 12px; color: var(--text-3); direction: ltr; }
.auth-card .email-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.auth-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }
.err { color: var(--danger); font-size: 13px; min-height: 20px; }
.hint { font-size: 12px; color: var(--text-3); }
.hint.ok { color: var(--success); }
.hint.bad { color: var(--danger); }

/* ===== responsive ===== */
.mobile-only { display: none !important; }
@media (max-width: 900px) {
  .row .from { width: 140px; }
  .srow { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 720px) {
  .mobile-only { display: inline-grid !important; }
  .desktop-only { display: none !important; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar .search { min-width: 0; }
  .top-actions .help-btn, .top-actions a.icon-btn { display: none; }
  .sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: 280px; background: var(--surface); z-index: 100; transform: translateX(100%); transition: transform .2s; padding-top: 16px; box-shadow: var(--shadow-2); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
  .brand { min-width: 0; } .brand b { display: none; }
  .main { margin: 0; border-radius: 16px 16px 0 0; }
  .topbar { padding: 8px; }
  .row { height: auto !important; padding: 10px 12px; align-items: flex-start; flex-wrap: wrap; }
  .row .lead .checkbox-wrap, .row .lead .imp { display: none; }
  .row .from { width: auto; flex: 1; padding: 0; }
  .row .date { width: auto; }
  .row .content { flex-basis: 100%; padding-inline-start: 40px; }
  .row .line { white-space: normal; flex-wrap: wrap; }
  .row .subject { max-width: 100%; }
  .row .hover-actions { display: none !important; }
  .row:hover .date { visibility: visible; }
  .row .mob-av { display: inline-grid !important; margin-inline-end: 8px; }
  .compose, .compose.full { position: fixed; inset: 0; width: 100%; height: 100%; max-height: none; border-radius: 0; }
  #compose-dock { inset-inline-end: 0; }
  .msg { padding: 0 12px; }
  .msg-body { padding-inline-start: 0; }
  .thread-head { padding: 16px 12px 8px; }
  .reply-bar, .inline-compose { margin-inline-start: 12px; padding-inline-start: 12px; margin-inline-end: 12px; }
  .auth-card { grid-template-columns: 1fr; padding: 24px; gap: 8px; }
  .auth-card form { padding-top: 8px; }
  .toolbar { padding: 4px 8px; overflow-x: auto; }
  .tab { min-width: 64px; padding: 0 12px; } .tab .sub, .tab .tlabel { display: none; }
  #toasts { inset-inline: 12px; bottom: 12px; }
}
.mob-av { display: none !important; }
@media print {
  .sidebar, .topbar, .toolbar, .reply-bar, #compose-dock, #toasts { display: none !important; }
  .shell { display: block; } .main { margin: 0; } .thread { overflow: visible; } body { overflow: visible; }
}
.compose.inline-compose { width: auto; height: auto; max-height: none; border-radius: 8px; overflow: visible; }
.compose.inline-compose .c-editor { min-height: 160px; }
a.btn { text-decoration: none; }
