/* SecureMail — calm, readable, large touch targets. */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --surface-3: #e6ebf3;
  --line: #dde3ec;
  --text: #1b2330;
  --text-2: #4a5568;
  --muted: #6b7686;
  --primary: #1f5fbf;
  --primary-hover: #194f9f;
  --primary-soft: #e3edfc;
  --on-primary: #ffffff;
  --danger: #c0262d;
  --danger-soft: #fdecec;
  --danger-line: #f4b8bb;
  --warn: #9a5b00;
  --warn-soft: #fff4dd;
  --warn-line: #f3d08b;
  --ok: #157f3b;
  --ok-soft: #e5f6ec;
  --focus: #1f5fbf;
  --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: 12px;
  --radius-sm: 8px;
  --row-pad: .8rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c; --surface: #181d26; --surface-2: #1f2530; --surface-3: #283040; --line: #2c3442;
    --text: #e8edf4; --text-2: #c2cad6; --muted: #8e99aa;
    --primary: #6aa0ff; --primary-hover: #8ab4ff; --primary-soft: #1d2b45; --on-primary: #0b1220;
    --danger: #ff7b80; --danger-soft: #3a1c20; --danger-line: #6d2c31;
    --warn: #f5c062; --warn-soft: #3a2e14; --warn-line: #6b5420;
    --ok: #5fd28b; --ok-soft: #173326; --focus: #8ab4ff;
    --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;
  }
}
:root[data-theme="dark"] {
  --bg: #11151c; --surface: #181d26; --surface-2: #1f2530; --surface-3: #283040; --line: #2c3442;
  --text: #e8edf4; --text-2: #c2cad6; --muted: #8e99aa;
  --primary: #6aa0ff; --primary-hover: #8ab4ff; --primary-soft: #1d2b45; --on-primary: #0b1220;
  --danger: #ff7b80; --danger-soft: #3a1c20; --danger-line: #6d2c31;
  --warn: #f5c062; --warn-soft: #3a2e14; --warn-line: #6b5420;
  --ok: #5fd28b; --ok-soft: #173326; --focus: #8ab4ff;
  --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;
}
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html[data-size="large"] { font-size: 18px; }
html[data-size="xlarge"] { font-size: 20.5px; }
html[data-density="compact"] { --row-pad: .45rem; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.5 var(--font); overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.noscript { padding: 2rem; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.grow { flex: 1 1 auto; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: .75rem 0; }

.ic { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.big { width: 3.5rem; height: 3.5rem; stroke-width: 1.4; opacity: .45; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.75rem; padding: .5rem 1rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-text { color: var(--danger); }
.btn.big { min-height: 3.1rem; padding: .6rem 1.4rem; font-size: 1.05rem; }
.btn.sm { min-height: 2.25rem; padding: .3rem .75rem; font-size: .9rem; }
.btn.block { width: 100%; }
.btn.icon-only { padding: 0; width: 2.75rem; }
.btn.sm.icon-only { width: 2.25rem; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 1.2rem; height: 1.2rem; border: 3px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.linkish { background: none; border: 0; color: var(--primary); cursor: pointer; padding: .5rem 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .3rem .85rem; min-height: 2.25rem; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--text-2); }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---------- forms ---------- */
input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input:not([type]), textarea, select {
  width: 100%; min-height: 2.9rem; padding: .6rem .85rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none;
}
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; line-height: 1.45; }
label { font-weight: 600; display: block; margin: .9rem 0 .35rem; }
label small, .help { display: block; font-weight: 400; color: var(--muted); font-size: .9rem; margin: 0 0 .4rem; }
.form > label:first-child { margin-top: 0; }
.field-wrap { position: relative; }
.field-wrap input { padding-right: 3rem; }
.field-btn { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); background: none; border: 0; width: 2.6rem; height: 2.6rem; cursor: pointer; color: var(--muted); display: grid; place-items: center; border-radius: 50%; }
.hint { font-size: .9rem; margin-top: .4rem; display: flex; align-items: center; gap: .3rem; }
.hint.warn { color: var(--warn); }
.check { display: flex; gap: .6rem; align-items: center; font-weight: 600; margin: 1rem 0; cursor: pointer; }
.check input { width: 1.3rem; height: 1.3rem; }
.code-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); margin: 1rem 0; border: 1px solid; display: flex; gap: .5rem; align-items: flex-start; }
.alert.error, .alert.caution { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.alert.caution { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.alert.info { background: var(--primary-soft); border-color: transparent; color: var(--text); }
.alert.success { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

.spinner { width: 2.4rem; height: 2.4rem; border: 4px solid var(--surface-3); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 3rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { display: grid; place-items: center; height: 100vh; }

/* ---------- login ---------- */
.login { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem 1rem; overflow-y: auto; height: 100vh;
  background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 27rem; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 2rem 1.75rem; border: 1px solid var(--line); }
.login-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.login-brand h1 { font-size: 1.5rem; }
.logo { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 14px; background: var(--primary); color: var(--on-primary); }
.logo .ic { width: 1.6rem; height: 1.6rem; }
.logo.sm { width: 2.2rem; height: 2.2rem; border-radius: 10px; }
.logo.sm .ic { width: 1.2rem; height: 1.2rem; }
.login-form .btn.big { margin-top: 1.25rem; }
.login-form .linkish { display: block; margin: .9rem auto 0; }
.login-safe { display: flex; gap: .6rem; align-items: flex-start; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.login-safe .ic { color: var(--ok); margin-top: .1rem; }
.login-foot { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 1.25rem; max-width: 27rem; }
.lead { font-size: 1.05rem; }
.steps { padding-left: 1.3rem; margin: 0 0 1rem; }
.steps li { margin-bottom: 1.2rem; }
.steps li strong { display: block; margin-bottom: .35rem; }
.qr { display: block; width: 13rem; max-width: 100%; height: auto; image-rendering: pixelated; margin: .6rem 0; border-radius: 8px; background: #fff; padding: .4rem; }
.secret { display: inline-block; font-size: 1.05rem; letter-spacing: .08em; background: var(--surface-2); padding: .4rem .6rem; border-radius: 6px; margin-top: .4rem; user-select: all; word-break: break-all; }
details summary { cursor: pointer; color: var(--primary); font-weight: 600; padding: .3rem 0; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin: 1rem 0; }
.codes code { background: var(--surface-2); padding: .55rem; border-radius: 6px; text-align: center; font-size: 1.1rem; letter-spacing: .06em; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 16.5rem 1fr; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.15rem; width: 15rem; flex: none; min-width: 0; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.searchbox { flex: 1; max-width: 44rem; display: flex; align-items: center; gap: .5rem; background: var(--surface-2); border-radius: 999px; padding: 0 1rem; border: 1.5px solid transparent; }
.searchbox:focus-within { border-color: var(--primary); background: var(--surface); }
.searchbox .ic { color: var(--muted); }
.searchbox input { border: 0; background: transparent; box-shadow: none !important; padding-left: 0; }
.top-actions { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.secure-pill { display: inline-flex; align-items: center; gap: .35rem; color: var(--ok); background: var(--ok-soft); border-radius: 999px; padding: .3rem .75rem; font-size: .85rem; font-weight: 700; margin-right: .4rem; }
.secure-pill .ic { width: 1.05em; height: 1.05em; }

.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1rem .75rem; overflow-y: auto; min-height: 0; }
.compose-btn { width: 100%; margin-bottom: 1rem; box-shadow: var(--shadow); }
.folders { display: flex; flex-direction: column; gap: 2px; }
.folder { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 500; min-height: 2.75rem; border: 0; background: none; cursor: pointer; text-align: left; width: 100%; }
.folder:hover { background: var(--surface-2); }
.folder.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.folder.disabled { opacity: .55; cursor: default; }
.folder.add { color: var(--muted); margin-top: .3rem; }
.folder .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { font-weight: 700; font-size: .85rem; background: var(--primary); color: var(--on-primary); border-radius: 999px; padding: .05rem .5rem; min-width: 1.6rem; text-align: center; }
.folder .count.muted { background: var(--surface-3); color: var(--text-2); }
.indent[data-d="1"] { width: .9rem; } .indent[data-d="2"] { width: 1.8rem; } .indent[data-d="3"] { width: 2.7rem; } .indent[data-d="4"] { width: 3.6rem; }
.side-foot { margin-top: auto; padding-top: 1rem; display: flex; flex-direction: column; gap: 2px; }
.side-foot .btn { justify-content: flex-start; font-weight: 500; }
.whoami { color: var(--muted); font-size: .85rem; padding: .6rem .8rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panes { display: grid; grid-template-columns: minmax(20rem, 28rem) 1fr; min-height: 0; min-width: 0; }
.app.no-pane .panes { grid-template-columns: 1fr; }
.app.no-pane .readpane { display: none; }
.app.no-pane.show-msg .listpane { display: none; }
.app.no-pane.show-msg .readpane { display: block; }

/* ---------- list ---------- */
.listpane { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; position: relative; }
.listpane.loading::after { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--primary), transparent); animation: bar 1s linear infinite; }
@keyframes bar { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.list-head { position: sticky; top: 0; background: var(--surface); z-index: 2; border-bottom: 1px solid var(--line); padding: .6rem .9rem .5rem; }
.list-title { display: flex; align-items: center; gap: .6rem; }
.list-title h2 { font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-tools { display: flex; align-items: center; gap: .7rem; margin-top: .5rem; min-height: 2.4rem; }
.cb { width: 1.25rem; height: 1.25rem; flex: none; cursor: pointer; accent-color: var(--primary); }
.bulk { display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; }
.bulk-count { font-weight: 700; margin-right: .4rem; font-size: .9rem; }
.msglist { display: flex; flex-direction: column; }
.msg { display: flex; align-items: center; gap: .75rem; padding: var(--row-pad) .9rem; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; outline-offset: -3px; }
.msg:hover { background: var(--surface-2); }
.msg.selected { background: var(--primary-soft); }
.msg.active { background: var(--primary-soft); box-shadow: inset 4px 0 0 var(--primary); }
.msg.unread .from, .msg.unread .subject { font-weight: 800; color: var(--text); }
.msg.unread::before { content: ""; position: absolute; left: 3px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--primary); }
.msg .meta { flex: 1; min-width: 0; }
.msg .r1, .msg .r2 { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.msg .from { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.msg .date { color: var(--muted); font-size: .85rem; flex: none; }
.msg.unread .date { color: var(--primary); font-weight: 700; }
.msg .subject { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: .95rem; }
.msg .clip, .msg .replied { color: var(--muted); display: inline-flex; }
.msg .clip .ic, .msg .replied .ic { width: 1em; height: 1em; }
.tag.imp { background: var(--warn-soft); color: var(--warn); border-radius: 4px; padding: 0 .35rem; font-size: .72rem; font-weight: 700; }
.star { border: 0; background: none; cursor: pointer; color: var(--muted); width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border-radius: 50%; flex: none; opacity: .55; }
.star:hover { background: var(--surface-3); opacity: 1; }
.star.on { color: #e8a500; opacity: 1; }
.star.on .ic { fill: currentColor; }
.avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .95rem; flex: none; color: #fff; letter-spacing: .02em; }
.av0 { background: #3b6fd4; } .av1 { background: #0f8a7e; } .av2 { background: #b4521e; } .av3 { background: #7a4fc9; }
.av4 { background: #c23b6b; } .av5 { background: #3f7d2c; } .av6 { background: #8a6d12; } .av7 { background: #4a5a73; }
.pager { display: flex; justify-content: center; align-items: center; gap: .75rem; padding: 1rem; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 4rem 1.5rem; }
.empty p { font-size: 1.05rem; margin-top: 1rem; }

/* ---------- reader ---------- */
.readpane { overflow-y: auto; min-height: 0; background: var(--bg); }
.reader { max-width: 60rem; margin: 0 auto; min-height: 100%; }
.read-tools { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: .35rem; padding: .55rem 1rem; background: var(--bg); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.back-btn { display: none; }
.read-scroll { padding: 1.25rem 1.25rem 3rem; }
.read-head .subject { font-size: 1.55rem; margin-bottom: 1rem; word-break: break-word; }
.sender { display: flex; gap: .85rem; align-items: flex-start; }
.sender .avatar { width: 2.9rem; height: 2.9rem; }
.sender-meta { flex: 1; min-width: 0; }
.sender-line { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.addr { color: var(--muted); word-break: break-all; }
.verified { display: inline-flex; align-items: center; gap: .25rem; color: var(--ok); background: var(--ok-soft); border-radius: 999px; padding: .05rem .55rem; font-size: .8rem; font-weight: 700; }
.verified .ic { width: 1em; height: 1em; }
.recip { color: var(--text-2); font-size: .92rem; word-break: break-word; }
.when { color: var(--muted); font-size: .88rem; text-align: right; flex: none; max-width: 12rem; }
.shield { border-radius: var(--radius); padding: 1rem 1.15rem; margin: 1.15rem 0 0; border: 1.5px solid; }
.shield.danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.shield.caution { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.shield.ok { background: var(--primary-soft); border-color: transparent; }
.shield-head { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; }
.shield ul { margin: .5rem 0 0; padding-left: 1.6rem; color: var(--text); }
.shield li { margin: .25rem 0; }
.shield .row { margin-bottom: 0; }
.notice { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); padding: .7rem 1rem; border-radius: var(--radius); margin-top: 1rem; font-size: .95rem; }
.notice > .ic { color: var(--muted); }
.notice > span:not(.notice-actions) { flex: 1 1 16rem; }
.notice.subtle { background: transparent; }
.notice-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.mailbody { margin-top: 1.2rem; background: #fff; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.mailbody.text { background: var(--surface); padding: 1.15rem 1.25rem; }
.mailframe { display: block; width: 100%; border: 0; min-height: 8rem; background: #fff; }
.plain { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1rem; line-height: 1.6; }
.attachments { margin-top: 1.2rem; }
.attachments h3 { font-size: 1rem; display: flex; align-items: center; gap: .35rem; margin-bottom: .6rem; }
.att-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: .6rem; }
.att { display: flex; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--line); padding: .5rem .5rem .5rem .8rem; border-radius: var(--radius-sm); min-width: 0; }
.att.danger { border-color: var(--danger-line); background: var(--danger-soft); }
.att.danger .att-icon { color: var(--danger); }
.att.caution { border-color: var(--warn-line); }
.att-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.att-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta .muted { font-size: .82rem; }
.read-foot { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
.details dt { font-weight: 700; color: var(--text-2); }
.details dd { margin: 0; word-break: break-word; }
kbd { background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: .05rem .45rem; font-family: inherit; font-size: .9rem; }

/* ---------- composer ---------- */
.composer { position: fixed; right: 1.25rem; bottom: 0; width: min(46rem, calc(100vw - 2.5rem)); height: min(44rem, calc(100vh - 4rem)); background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; z-index: 40; border: 1px solid var(--line); }
.composer.max { inset: 2vh 4vw; width: auto; height: auto; border-radius: 16px; }
.composer.drop { outline: 3px dashed var(--primary); outline-offset: -8px; }
.chead { display: flex; align-items: center; padding: .4rem .5rem .4rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: 16px 16px 0 0; }
.chead h2 { font-size: 1.05rem; }
.cfields { padding: 0 1.1rem; }
.crow { display: flex; align-items: center; gap: .6rem; border-bottom: 1px solid var(--line); min-height: 3rem; }
.crow > label, .from-label { width: 4.2rem; margin: 0; color: var(--muted); font-weight: 600; flex: none; }
.from-val { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow input[type="text"]#c-subj { border: 0; box-shadow: none; padding-left: 0; font-weight: 600; }
.to-line { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--line); }
.to-line .crow { border: 0; flex: 1; }
.rcpt-wrap { position: relative; flex: 1; min-width: 0; }
.rcpt { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; padding: .35rem 0; cursor: text; }
.rcpt input { flex: 1; min-width: 9rem; border: 0 !important; box-shadow: none !important; padding: .3rem 0; min-height: 2.2rem; background: transparent; }
.pill { display: inline-flex; align-items: center; gap: .2rem; background: var(--primary-soft); color: var(--text); border-radius: 999px; padding: .15rem .25rem .15rem .7rem; font-size: .92rem; font-weight: 600; max-width: 100%; }
.pill.bad { background: var(--danger-soft); color: var(--danger); text-decoration: wavy underline; }
.pill button { border: 0; background: none; cursor: pointer; width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center; color: inherit; }
.pill button:hover { background: var(--surface-3); }
.pill .ic { width: .95em; height: .95em; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 5; overflow: hidden; }
.sugg { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem; cursor: pointer; }
.sugg .avatar { width: 2rem; height: 2rem; font-size: .8rem; }
.sugg.on, .sugg:hover { background: var(--primary-soft); }
.etools { display: flex; gap: .15rem; padding: .35rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.tb { min-width: 2.4rem; height: 2.4rem; border: 0; background: none; border-radius: 6px; cursor: pointer; font-size: 1.05rem; display: grid; place-items: center; color: var(--text-2); }
.tb:hover { background: var(--surface-2); color: var(--text); }
.tb.b { font-weight: 800; } .tb.i { font-style: italic; font-family: Georgia, serif; } .tb.u { text-decoration: underline; }
.etools .sep { width: 1px; height: 1.4rem; background: var(--line); margin: 0 .3rem; }
.cbody { flex: 1; min-height: 0; overflow-y: auto; display: flex; }
.editor { flex: 1; padding: 1rem 1.1rem; outline: none; min-height: 10rem; line-height: 1.55; overflow-wrap: anywhere; }
.editor.plain { border: 0; border-radius: 0; resize: none; box-shadow: none !important; height: 100%; }
.editor blockquote, .editor .sig { color: var(--text-2); }
.editor blockquote { border-left: 3px solid var(--line); margin: .5rem 0; padding-left: .9rem; }
.editor a { color: var(--primary); }
.catts { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1.1rem; }
.catts:not(:empty) { padding-top: .5rem; padding-bottom: .5rem; border-top: 1px solid var(--line); }
.catt { display: inline-flex; align-items: center; gap: .35rem; background: var(--surface-2); border-radius: 8px; padding: .25rem .25rem .25rem .6rem; font-size: .88rem; max-width: 100%; }
.catt.pending { opacity: .65; }
.catt.danger { background: var(--danger-soft); color: var(--danger); }
.catt .att-name { max-width: 14rem; }
.catt button { border: 0; background: none; cursor: pointer; width: 1.9rem; height: 1.9rem; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.cfoot { display: flex; align-items: center; gap: .5rem; padding: .7rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.cstatus { font-size: .85rem; }

/* ---------- popovers, modals, toasts ---------- */
.popover { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 60vh; overflow-y: auto; min-width: 14rem; }
.menu { padding: .35rem; display: flex; flex-direction: column; }
.menu-title { font-size: .8rem; color: var(--muted); font-weight: 700; padding: .35rem .7rem; text-transform: uppercase; letter-spacing: .04em; }
.menu-item { display: flex; align-items: center; gap: .65rem; border: 0; background: none; padding: .6rem .75rem; border-radius: 8px; cursor: pointer; text-align: left; min-height: 2.6rem; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.modal-back { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); z-index: 80; display: grid; place-items: center; padding: 1rem; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: min(32rem, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.modal.wide { width: min(54rem, 100%); height: min(46rem, calc(100vh - 2rem)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem .6rem .8rem 1.4rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.2rem; }
.modal-body { padding: 1.2rem 1.4rem; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.4rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.toasts { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: center; width: min(36rem, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: .6rem; background: #1f2633; color: #fff; padding: .55rem .5rem .55rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: up .2s ease-out; max-width: 100%; }
.toast.error { background: #a2222a; }
.toast.success { background: #146c35; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes up { from { opacity: 0; transform: translateY(10px); } }
.toast-text { flex: 1; }
.toast-action { background: none; border: 0; color: #9cc3ff; font-weight: 800; cursor: pointer; padding: .4rem .7rem; border-radius: 8px; text-transform: uppercase; letter-spacing: .03em; }
.toast.success .toast-action, .toast.error .toast-action { color: #fff; text-decoration: underline; }
.toast-action:hover { background: rgba(255,255,255,.12); }
.toast-close { background: none; border: 0; color: #fff; opacity: .7; cursor: pointer; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; }

/* ---------- settings ---------- */
.modal.wide .modal-body { padding: 0; display: flex; }
.settings { display: flex; flex: 1; min-height: 0; width: 100%; }
.settings-tabs { width: 13rem; flex: none; border-right: 1px solid var(--line); padding: .75rem .5rem; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.stab { display: flex; align-items: center; gap: .6rem; border: 0; background: none; padding: .65rem .8rem; border-radius: 999px; cursor: pointer; text-align: left; font-weight: 500; min-height: 2.75rem; }
.stab:hover { background: var(--surface-2); }
.stab.on { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.settings-body { flex: 1; overflow-y: auto; padding: 1.25rem 1.5rem 2rem; min-width: 0; }
.settings-body h3 { margin: 1.75rem 0 .3rem; font-size: 1.1rem; }
.choice { border: 0; padding: 0; margin: 1.5rem 0 0; }
.choice legend { font-weight: 700; padding: 0; margin-bottom: .3rem; font-size: 1.02rem; }
.options { display: flex; flex-wrap: wrap; gap: .5rem; }
.opt { display: flex; align-items: center; gap: .6rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .9rem; cursor: pointer; margin: 0; font-weight: 400; min-height: 2.9rem; }
.opt input { width: 1.15rem; height: 1.15rem; accent-color: var(--primary); }
.opt.on { border-color: var(--primary); background: var(--primary-soft); }
.opt small { display: block; color: var(--muted); font-size: .82rem; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); margin: 0; cursor: pointer; }
.switch-row small { display: block; color: var(--muted); font-weight: 400; font-size: .88rem; }
.switch { appearance: none; width: 3.1rem; height: 1.8rem; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; flex: none; transition: background .15s; border: 0; }
.switch::after { content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(1.3rem); }
.card { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; }
.card-head { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; }
.card-head.ok { color: var(--ok); }
.card-head.warn { color: var(--warn); }
.history { display: flex; flex-direction: column; }
.hrow { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.hrow > span:nth-child(2) { flex: 1; }
.hrow small { display: block; color: var(--muted); }
.hrow > .ic { color: var(--ok); }
.hrow.fail > .ic, .hrow.fail strong { color: var(--danger); }
.hrow .muted { font-size: .85rem; text-align: right; }
.contacts { display: flex; flex-direction: column; margin-top: .5rem; }
.contact { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.cmeta { flex: 1; min-width: 0; }
.cmeta strong, .cmeta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmeta small { color: var(--muted); }
.settings-body .row input[type="search"] { flex: 1; min-width: 12rem; width: auto; }
.tip { padding: .9rem 0; border-bottom: 1px solid var(--line); }
.tip p { margin: .3rem 0 0; color: var(--text-2); }

.only-mobile { display: none !important; }
.fab { position: fixed; right: 1.1rem; bottom: 1.1rem; width: 3.75rem; height: 3.75rem; border-radius: 18px; border: 0; background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-lg); z-index: 30; cursor: pointer; }
.fab .ic { width: 1.6rem; height: 1.6rem; }
.scrim { display: none; }

/* ---------- tablet & phone ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 14.5rem 1fr; }
  .brand { width: auto; }
  .panes { grid-template-columns: minmax(17rem, 22rem) 1fr; }
  .secure-pill span { display: none; }
  .top-actions .btn .btn-label { display: none; }
  .top-actions .btn { width: 2.75rem; padding: 0; }
}
@media (max-width: 860px) {
  .only-mobile { display: inline-flex !important; }
  .only-desktop { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .topbar { padding: .45rem .6rem; gap: .4rem; }
  .brand-name, .brand .logo { display: none; }
  .secure-pill { display: none; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(19rem, 86vw); z-index: 50; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; }
  .sidebar .compose-btn { display: none; }
  .panes { grid-template-columns: 1fr; }
  .readpane { display: none; }
  body.reading .listpane { display: none; }
  body.reading .readpane { display: block; }
  body.reading .fab { display: none !important; }
  body.composing .fab { display: none !important; }
  .listpane { border-right: 0; padding-bottom: 6rem; }
  .back-btn { display: inline-flex; }
  .read-tools .btn:not(.primary):not(.icon-only):not(.back-btn) .btn-label { display: none; }
  .read-tools .btn:not(.primary):not(.icon-only):not(.back-btn) { width: 2.75rem; padding: 0; }
  .read-scroll { padding: 1rem .8rem 3rem; }
  .read-head .subject { font-size: 1.3rem; }
  .sender { flex-wrap: wrap; }
  .when { text-align: left; width: 100%; padding-left: 3.75rem; max-width: none; margin-top: -.3rem; }
  .composer, .composer.max { inset: 0; width: auto; height: auto; border-radius: 0; }
  .chead { border-radius: 0; }
  .modal { border-radius: 16px; }
  .modal.wide { height: calc(100vh - 2rem); }
  .settings { flex-direction: column; }
  .settings-tabs { width: auto; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; padding: .5rem; }
  .stab { flex: none; }
  .stab span { white-space: nowrap; }
  .settings-body { padding: 1rem; }
  .list-tools .bulk .btn .btn-label { display: none; }
  .list-tools .bulk .btn { width: 2.4rem; padding: 0; }
  .att-list { grid-template-columns: 1fr; }
  .toasts { bottom: 5.5rem; }
}

/* ---------- print: only the open email ---------- */
@media print {
  body { overflow: visible; background: #fff; }
  .topbar, .sidebar, .listpane, .read-tools, .read-foot, .fab, .toasts, .notice, .composer, .modal-back .modal-head, .modal-back .modal-foot { display: none !important; }
  .app, .panes { display: block; height: auto; }
  .readpane { display: block !important; overflow: visible; }
  .mailframe { height: auto !important; }
  .modal-back { position: static; background: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (min-width: 861px) {
  body.composing .toasts { left: 1.25rem; transform: none; align-items: flex-start; width: min(30rem, calc(100vw - 52rem)); min-width: 18rem; }
}

/* ---------- address book & outbox ---------- */
.panes.view-contacts, .panes.view-outbox { grid-template-columns: 1fr; }
.ab { display: grid; grid-template-columns: 16rem minmax(18rem, 26rem) 1fr; min-height: 0; height: 100%; }
.ab-side { background: var(--surface); border-right: 1px solid var(--line); padding: .75rem .6rem; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.side-title { font-size: .78rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 1rem .8rem .35rem; }
.side-title:first-child { padding-top: .25rem; }
.folder .sub { display: block; font-size: .78rem; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.folder.active .sub { color: inherit; opacity: .8; }
.side-foot .btn.active { background: var(--primary-soft); color: var(--primary); }
.ab-list { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; }
.ab-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0 .5rem; }
.ab-search { margin: .25rem 0 .25rem; max-width: none; }
.ab-note { display: flex; align-items: center; gap: .3rem; margin: .4rem 0 0; }
.ab-note .ic { width: 1em; height: 1em; }
.contact-row .meta .from { font-weight: 600; }
.ab-detail { overflow-y: auto; min-height: 0; background: var(--bg); }
.contact-card { max-width: 46rem; margin: 0 auto; padding-bottom: 3rem; }
.contact-card > .form, .contact-card > .card-top, .contact-card > .clines, .contact-card > .row { padding-left: 1.5rem; padding-right: 1.5rem; }
.contact-card .read-tools h2 { font-size: 1.15rem; }
.card-top { display: flex; gap: 1rem; align-items: center; padding-top: 1.5rem; }
.card-top .avatar { width: 4.5rem; height: 4.5rem; font-size: 1.5rem; }
.card-top h1 { font-size: 1.6rem; }
.card-top p { margin: .2rem 0; }
.card-top .chips { margin-top: .4rem; }
.clines { display: flex; flex-direction: column; gap: .2rem; margin-top: 1rem; }
.cline { display: flex; gap: .9rem; align-items: flex-start; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.cline > .ic { color: var(--muted); margin-top: .9rem; }
.cline small { display: block; }
.cline div div, .cline a { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.02rem; }
.contact-form { padding-top: .5rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.two label { margin-top: .9rem; }
.multi { display: flex; flex-direction: column; gap: .45rem; }
.multi-row { display: grid; grid-template-columns: 7.5rem 1fr auto; gap: .45rem; align-items: center; }
.multi .linkish { align-self: flex-start; padding: .2rem 0; }
select { min-height: 2.9rem; padding: .4rem .6rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.addr { display: flex; flex-direction: column; gap: .45rem; }
.addr .two { gap: .45rem; }
.group-checks { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.group-checks .check { margin: .3rem 0; font-weight: 500; }
.share-add { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; align-items: center; }
.menu-item .sub { display: block; font-size: .8rem; color: var(--muted); }
.row.center, p.center { justify-content: center; text-align: center; }
.sep-row { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--line); margin: 0; cursor: pointer; font-weight: 400; }
.sep-row input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; accent-color: var(--primary); flex: none; }
.sep-row small { display: block; color: var(--muted); }
.sendplan { background: var(--primary-soft); border-radius: var(--radius-sm); padding: .65rem .85rem; margin: .5rem 0; font-size: .92rem; }
.sendplan .warn-line { color: var(--warn); margin-top: .35rem; display: flex; gap: .3rem; align-items: center; }
.danger-text { color: var(--danger); }
.pill.group { background: var(--ok-soft); }
.pill.group .ic { width: 1em; height: 1em; margin-right: .2rem; }
.outbox { overflow-y: auto; height: 100%; background: var(--bg); }
.outbox .list-head { background: var(--surface); }
.outbox-body { max-width: 52rem; margin: 0 auto; padding: 1rem 1.25rem 3rem; display: flex; flex-direction: column; gap: .9rem; }
.job { background: var(--surface); }
.job-head { display: flex; align-items: center; gap: .75rem; }
.job p { margin: .5rem 0 0; }
.chip.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.bar { height: .6rem; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: .75rem; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s; }

@media (max-width: 1100px) {
  .ab { grid-template-columns: 14rem minmax(16rem, 22rem) 1fr; }
}
@media (max-width: 860px) {
  .ab { grid-template-columns: 1fr; }
  .ab-side { position: fixed; left: 0; top: 0; bottom: 0; width: min(19rem, 86vw); z-index: 55; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.drawer-open .ab-side { transform: none; }
  body.drawer-open:has(.ab-side) .sidebar { transform: translateX(-105%); }
  .ab-detail { display: none; }
  body.ab-open .ab-list { display: none; }
  body.ab-open .ab-detail { display: block; }
  .two { grid-template-columns: 1fr; gap: 0; }
  .contact-card > .form, .contact-card > .card-top, .contact-card > .clines, .contact-card > .row { padding-left: 1rem; padding-right: 1rem; }
  .share-add { grid-template-columns: 1fr; }
  .multi-row { grid-template-columns: 6.5rem 1fr auto; }
}

/* ---------- administration ---------- */
.admin-section { margin-top: 1.5rem; }
.admin-section .form > div > label:first-child { margin-top: .9rem; }
.admin-actions { position: sticky; bottom: -2rem; background: var(--surface); padding: .75rem 0; border-top: 1px solid var(--line); }
.wide-code { letter-spacing: .15em; font-size: 1.3rem !important; max-width: 20rem; display: block; margin-top: .5rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem !important; }
.test-results { margin-top: .5rem; }
.shield .steps { margin: .6rem 0 0; color: var(--text); }
.shield .steps li { margin-bottom: .4rem; }
.shield .steps li strong { display: inline; margin: 0; }

.version-line { font-weight: 700; color: var(--muted); margin: 0 0 1rem; }
