/* Mills Mail */
:root {
  --bg: #f4f5f7;
  --pane: #ffffff;
  --list: #ffffff;
  --side: #f3f4f6;
  --line: #e3e5ea;
  --line2: #eef0f3;
  --text: #14171c;
  --muted: #6a717d;
  --faint: #9aa0aa;
  --accent: #3358d4;
  --accent-ink: #ffffff;
  --accent-soft: #e9eefc;
  --hover: #f1f3f6;
  --sel: #e9eefc;
  --ok: #15803d;
  --ok-soft: #e6f5ea;
  --warn: #a75a06;
  --warn-soft: #fcf1df;
  --idle: #646b77;
  --idle-soft: #eff1f4;
  --danger: #c0262d;
  --star: #e0a100;
  --shadow: 0 12px 32px rgba(15, 20, 30, 0.16), 0 2px 6px rgba(15, 20, 30, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b212c;
    --pane: #1f2531;
    --list: #222935;
    --side: #262d3a;
    --line: #333b4a;
    --line2: #2b3240;
    --text: #e9edf3;
    --muted: #98a2b3;
    --faint: #6f7a8c;
    --accent: #5b9cf5;
    --accent-ink: #0f141c;
    --accent-soft: #24344f;
    --hover: #2c3442;
    --sel: #2a3a55;
    --ok: #4ade80;
    --ok-soft: #15301f;
    --warn: #fbbf24;
    --warn-soft: #33290f;
    --idle: #a3acbb;
    --idle-soft: #2a313d;
    --danger: #f87171;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
    --bg: #1b212c;
    --pane: #1f2531;
    --list: #222935;
    --side: #262d3a;
    --line: #333b4a;
    --line2: #2b3240;
    --text: #e9edf3;
    --muted: #98a2b3;
    --faint: #6f7a8c;
    --accent: #5b9cf5;
    --accent-ink: #0f141c;
    --accent-soft: #24344f;
    --hover: #2c3442;
    --sel: #2a3a55;
    --ok: #4ade80;
    --ok-soft: #15301f;
    --warn: #fbbf24;
    --warn-soft: #33290f;
    --idle: #a3acbb;
    --idle-soft: #2a313d;
    --danger: #f87171;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body { overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.ic { flex: none; display: block; }
.ic.filled { fill: currentColor; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fine { font-size: 12px; color: var(--faint); line-height: 1.5; padding: 0 16px; }
.warn-text { color: var(--warn); }
.danger-text { color: var(--danger) !important; font-weight: 600; }
.mobile-only { display: none !important; }
.boot { height: 100vh; display: grid; place-items: center; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 236px 384px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.scrim, .fab { display: none; }

/* ---------------------------------------------------------------- sidebar */
.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; padding: calc(14px + var(--st)) 10px calc(12px + var(--sb)) calc(10px + var(--sl)); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.compose-btn { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 10px 14px; font-weight: 600; margin: 0 4px 14px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.compose-btn:hover { filter: brightness(1.06); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 8px; text-align: left; color: var(--text); min-height: 34px; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--sel); color: var(--accent); font-weight: 600; }
.nav-item .count { margin-left: auto; font-size: 12px; font-weight: 650; color: var(--muted); }
.nav-item.active .count { color: var(--accent); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-email { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.side-section { margin-top: 18px; padding: 0 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.warn-ic { color: var(--warn); margin-left: auto; }
.side-spacer { flex: 1; min-height: 16px; }
.demo-pill { margin: 0 6px 8px; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; text-align: center; }

/* ---------------------------------------------------------------- list */
.list-pane { background: var(--list); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.list-head { padding: calc(10px + var(--st)) 12px 10px; border-bottom: 1px solid var(--line2); display: flex; flex-direction: column; gap: 8px; }
.list-title-row { display: flex; align-items: center; gap: 4px; min-height: 38px; }
.list-title-wrap { flex: 1; min-width: 0; padding-left: 4px; }
.list-title { font-size: 19px; font-weight: 750; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--star); }
.icon-btn.tiny { width: 26px; height: 26px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--hover); border-radius: 10px; padding: 0 4px 0 10px; height: 36px; color: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; min-width: 0; height: 100%; font-size: 14px; color: var(--text); -webkit-appearance: none; appearance: none; }
.search input::-webkit-search-cancel-button { display: none; }
.list-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.list-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line2); font-size: 12.5px; color: var(--muted); background: var(--side); }
.link-btn { color: var(--muted); font-size: 13px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.link-btn:hover { color: var(--text); background: var(--hover); }

.row { position: relative; display: flex; gap: 10px; padding: 11px 14px 11px 14px; border-bottom: 1px solid var(--line2); cursor: pointer; outline: none; }
.row:hover { background: var(--hover); }
.row.selected { background: var(--sel); }
.row:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.row > .dot { margin-top: 6px; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: center; gap: 6px; }
.row-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.row-date { font-size: 12px; color: var(--muted); flex: none; }
.row-subject { font-size: 13.5px; margin-top: 1px; display: flex; align-items: center; gap: 5px; min-width: 0; }
.row-snippet { font-size: 13px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 1px; word-break: break-word; }
.row.unread .row-from, .row.unread .row-subject { font-weight: 700; }
.row.unread::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.thread-count { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 5px; }
.star-on { color: var(--star); display: inline-flex; }
.star-on .ic { fill: currentColor; }
.row.skel { cursor: default; }
.row.skel i { display: block; height: 10px; border-radius: 5px; background: var(--hover); margin: 5px 0 9px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

.badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 7px; font-size: 11.5px; font-weight: 650; padding: 2px 9px 2px 7px; border-radius: 999px; max-width: 100%; }
.badge span { font-weight: 500; opacity: 0.85; white-space: nowrap; }
.badge.mini { margin-top: 0; font-size: 11px; padding: 1px 8px 1px 6px; flex: none; }
.badge.opened { background: var(--ok-soft); color: var(--ok); }
.badge.maybe { background: var(--warn-soft); color: var(--warn); }
.badge.unopened { background: var(--idle-soft); color: var(--idle); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line2); }
.stats div { background: var(--side); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.stats b { font-size: 20px; letter-spacing: -0.02em; }
.stats span { font-size: 12px; color: var(--muted); }

.empty { padding: 56px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; }
.empty h3 { color: var(--text); margin: 12px 0 4px; font-size: 15px; }
.empty p { margin: 0; font-size: 13px; max-width: 280px; }
.load-more { display: block; width: calc(100% - 28px); margin: 14px; padding: 9px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); }
.load-more:hover { background: var(--hover); color: var(--text); }
.error-banner { margin: 10px 12px; padding: 10px 12px; border-radius: 9px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; white-space: pre-wrap; text-align: left; }

/* ---------------------------------------------------------------- reader */
.read-pane { background: var(--pane); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.reader-bar { display: flex; align-items: center; gap: 2px; padding: calc(8px + var(--st)) 14px 8px; border-bottom: 1px solid var(--line2); min-height: 54px; }
.reader-actions { display: flex; gap: 2px; }
.reader-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px 28px 48px; min-height: 0; }
.reader-subject { font-size: 22px; line-height: 1.25; font-weight: 750; letter-spacing: -0.02em; margin: 0 0 8px; word-break: break-word; }
.reader-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--hover); padding: 3px 10px; border-radius: 999px; }
.reader-empty { flex: 1; display: grid; place-items: center; color: var(--faint); text-align: center; padding: 20px; }
.reader-empty .logo { margin: 0 auto 10px; opacity: 0.9; }
.reader-empty p { margin: 4px 0; }

.msg { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; background: var(--pane); overflow: hidden; }
.msg.collapsed { display: flex; gap: 10px; padding: 10px 14px; cursor: pointer; align-items: center; }
.msg.collapsed:hover { background: var(--hover); }
.msg-head { display: flex; gap: 10px; padding: 14px 16px 8px; cursor: pointer; align-items: flex-start; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 13px; flex: none; letter-spacing: 0.02em; }
.msg-who { flex: 1; min-width: 0; }
.msg-sum { flex: 1; min-width: 0; }
.msg-line { display: flex; gap: 8px; align-items: baseline; min-width: 0; white-space: nowrap; overflow: hidden; }
.msg-line b { overflow: hidden; text-overflow: ellipsis; }
.msg-line .email { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.msg-to { font-size: 12.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.msg-date { font-size: 12px; color: var(--muted); flex: none; white-space: nowrap; }
.msg-snip { color: var(--muted); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.msg-body { padding: 4px 18px 8px 60px; }
.mail-frame { width: 100%; border: 0; display: block; min-height: 40px; height: 120px; background: #fff; border-radius: 6px; color-scheme: light; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mail-frame { padding: 10px 12px; } }
:root[data-theme="dark"] .mail-frame { padding: 10px 12px; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 18px 10px 60px; }
.att { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; font-size: 12.5px; max-width: 100%; }
.att:hover { background: var(--hover); }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 18px 14px 60px; align-items: center; }
.chip-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 9px; padding: 7px 12px; font-size: 13px; color: var(--text); background: var(--pane); }
.chip-btn:hover { background: var(--hover); }
.chip-btn.small { padding: 5px 10px; font-size: 12.5px; }
.blocked { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; margin-left: auto; }
.reply-bar { display: flex; gap: 8px; margin-top: 4px; }
.reply-bar .chip-btn { flex: 1; padding: 10px; }

.receipt { margin: 0 18px 8px 60px; border-radius: 10px; font-size: 13px; }
.receipt > summary, .receipt.flat { display: flex; align-items: center; gap: 7px; padding: 8px 12px; list-style: none; }
.receipt > summary { cursor: pointer; }
.receipt > summary::-webkit-details-marker { display: none; }
.receipt .sub { font-weight: 400; opacity: 0.85; }
.receipt.opened { background: var(--ok-soft); color: var(--ok); }
.receipt.maybe { background: var(--warn-soft); color: var(--warn); }
.receipt.unopened { background: var(--idle-soft); color: var(--idle); }
.receipt ul { margin: 0; padding: 0 12px 10px 34px; color: var(--text); font-size: 12.5px; }
.receipt li { margin: 3px 0; }
.receipt-slot:empty { display: none; }

.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 48px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- compose */
.compose { position: fixed; right: 24px; bottom: 0; width: 620px; max-width: calc(100vw - 32px); height: min(660px, calc(100vh - 48px)); background: var(--pane); border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 40; }
.compose.min { height: auto; width: 340px; }
.compose.min > :not(.compose-head) { display: none; }
.compose-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line2); font-weight: 650; }
.compose-head .title { flex: 1; cursor: pointer; }
.field { position: relative; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line2); padding: 0 12px 0 16px; min-height: 42px; }
.field > span { color: var(--muted); width: 56px; flex: none; font-size: 13px; }
.field input, .field select { flex: 1; border: 0; outline: 0; background: transparent; height: 40px; min-width: 0; font-size: 14px; color: var(--text); }
.field select { -webkit-appearance: none; appearance: none; cursor: pointer; }
.suggest { position: absolute; left: 72px; right: 12px; top: calc(100% - 2px); background: var(--pane); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 5; overflow: hidden; }
.suggest button { display: block; width: 100%; text-align: left; padding: 9px 12px; }
.suggest button:hover, .suggest button.hi { background: var(--hover); }
.suggest small { color: var(--muted); margin-left: 8px; }
.toolbar { display: flex; gap: 2px; padding: 4px 10px; border-bottom: 1px solid var(--line2); align-items: center; position: relative; }
.toolbar .icon-btn { width: 32px; height: 32px; }
.toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.compose-body { flex: 1; overflow-y: auto; padding: 14px 16px; outline: 0; font-size: 14.5px; line-height: 1.55; min-height: 120px; word-break: break-word; }
.compose-body:empty::before { content: attr(data-placeholder); color: var(--faint); }
.compose-body ul { padding-left: 22px; }
.mm-sig { color: var(--muted); }
.compose-extras { padding: 0 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.compose-extras:not(:empty) { padding-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; background: var(--hover); border-radius: 999px; padding: 4px 6px 4px 10px; max-width: 100%; }
.chip button { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: var(--muted); }
.chip button:hover { background: var(--line); color: var(--text); }
.compose-foot { display: flex; align-items: center; gap: 14px; padding: 10px 12px calc(10px + var(--sb)); border-top: 1px solid var(--line2); }
.foot-spacer { flex: 1; }
.link-pop { position: absolute; top: calc(100% + 4px); left: 10px; z-index: 6; display: flex; gap: 6px; background: var(--pane); border: 1px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: var(--shadow); }
.link-pop input { border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; width: 240px; max-width: 60vw; background: var(--pane); outline: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 9px; padding: 9px 16px; font-weight: 600; border: 1px solid var(--line); background: var(--pane); color: var(--text); text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.big { padding: 13px 22px; font-size: 15px; }
.btn.wide { width: 100%; }

.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; -webkit-user-select: none; }
.toggle input { appearance: none; -webkit-appearance: none; width: 36px; height: 21px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.15s; cursor: pointer; margin: 0; flex: none; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.toggle input:checked { background: var(--ok); }
.toggle input:checked::after { transform: translateX(15px); }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; left: 50%; bottom: calc(22px + var(--sb)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 70; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; background: #1d2129; color: #f1f3f6; padding: 10px 10px 10px 16px; border-radius: 11px; box-shadow: var(--shadow); font-size: 13.5px; animation: toastIn 0.18s ease-out; max-width: 100%; }
.toast-text { min-width: 0; }
.toast.error { background: #8a1c1c; }
.toast.open-alert { background: #14532d; }
.toast button { color: #a9bdff; font-weight: 700; padding: 5px 8px; border-radius: 6px; white-space: nowrap; }
.toast.open-alert button { color: #bbf7d0; }
.toast button:hover { background: rgba(255, 255, 255, 0.08); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ---------------------------------------------------------------- modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(10, 12, 16, 0.45); z-index: 60; display: grid; place-items: center; padding: 16px; animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--pane); border-radius: 16px; box-shadow: var(--shadow); width: 540px; max-width: 100%; max-height: calc(100dvh - 32px); overflow-y: auto; }
.modal-head { display: flex; align-items: center; padding: 14px 12px 12px 20px; font-weight: 750; font-size: 16px; position: sticky; top: 0; background: var(--pane); border-bottom: 1px solid var(--line2); z-index: 1; }
.modal-head .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px 20px 20px; }
.modal-body > p { margin: 0 0 12px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.set-group { margin-bottom: 22px; }
.set-group h4 { margin: 0 0 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.set-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line2); }
.set-row .desc { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.set-row select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--pane); }
.textarea { width: 100%; min-height: 130px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--pane); outline: 0; resize: vertical; }
.code { font: 700 28px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.14em; text-align: center; padding: 20px; background: var(--hover); border-radius: 12px; margin: 10px 0; }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: calc(24px + var(--st)) 24px calc(24px + var(--sb)); }
.login-card { width: 380px; max-width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.login-card h1 { margin: 4px 0 0; font-size: 26px; letter-spacing: -0.02em; }
.login-card > p { margin: 0 0 8px; }
.login-or { width: 100%; display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin-top: 8px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pair-form { display: flex; gap: 8px; width: 100%; }
.pair-form input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--pane); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; outline: 0; }
.login-help { font-size: 12.5px; margin: 0; }
.small-link { font-size: 13px; margin-top: 8px; }

/* ---------------------------------------------------------------- tablet */
@media (min-width: 900px) and (max-width: 1220px) {
  .app { grid-template-columns: 208px 330px minmax(0, 1fr); }
  .reader-scroll { padding: 18px 20px 40px; }
  .msg-body, .atts, .msg-actions { padding-left: 16px; }
  .receipt { margin-left: 16px; }
}

/* ---------------------------------------------------------------- phone */
@media (max-width: 899px) {
  .mobile-only { display: grid !important; }
  .btn.mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .app { display: block; position: relative; height: 100vh; height: 100dvh; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 300px; max-width: 86vw; z-index: 30; transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--shadow); }
  body.drawer-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 12, 16, 0.4); z-index: 25; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .list-pane { position: absolute; inset: 0; border: 0; }
  .list-head { padding-left: calc(8px + var(--sl)); }
  .read-pane { position: fixed; inset: 0; z-index: 20; transform: translateX(100%); transition: transform 0.25s ease; box-shadow: var(--shadow); }
  body.reading .read-pane { transform: none; }
  .reader-bar { padding-left: 6px; }
  .reader-scroll { padding: 16px 14px calc(28px + var(--sb)); }
  .reader-subject { font-size: 20px; }
  .msg-head { padding: 12px 14px 6px; }
  .msg-body, .atts, .msg-actions { padding-left: 14px; padding-right: 14px; }
  .receipt { margin-left: 14px; margin-right: 14px; }
  .msg-line .email { display: none; }
  .fab { display: grid; position: fixed; right: 18px; bottom: calc(22px + var(--sb)); width: 58px; height: 58px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); place-items: center; box-shadow: 0 8px 22px rgba(30, 50, 120, 0.35); z-index: 15; }
  body.reading .fab, body.composing .fab { display: none; }
  .row { padding-top: 12px; padding-bottom: 12px; }
  .list-scroll { padding-bottom: calc(96px + var(--sb)); }
  .compose { inset: 0; width: auto; max-width: none; height: auto; border-radius: 0; border: 0; }
  .compose-head { padding-top: calc(8px + var(--st)); padding-left: 6px; }
  .compose-head .title { text-align: center; cursor: default; }
  .toasts { bottom: calc(92px + var(--sb)); }
  body.reading .toasts, body.composing .toasts { bottom: calc(20px + var(--sb)); }
  .field input, .field select, .search input { font-size: 16px; } /* stops iOS zooming into inputs */
  .compose-body { font-size: 16px; }
  .modal-scrim { place-items: end center; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92dvh; padding-bottom: var(--sb); }
}

/* ---------------------------------------------------------------- menus, chips, banners */
.menu { position: fixed; z-index: 80; min-width: 240px; max-width: calc(100vw - 16px); background: var(--pane); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; animation: fade 0.12s; }
.menu-title { font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--faint); padding: 6px 10px 4px; }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; }
.menu-item > span:first-child { display: inline-flex; align-items: center; gap: 9px; }
.menu-item:hover { background: var(--hover); }
.menu-item .muted { font-size: 12.5px; white-space: nowrap; }
.menu-sep { height: 1px; background: var(--line2); margin: 6px 4px; }
.menu-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }
.menu-custom { display: flex; gap: 6px; padding: 4px; }
.menu-custom input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--pane); color: var(--text); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.chips .badge { margin-top: 0; }
.badge.sched { background: var(--accent-soft); color: var(--accent); }
.lbl { flex: none; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--hover); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; line-height: 17px; }
.lbl-tag { cursor: pointer; }
.row.draft .row-from { color: var(--danger); }
.row.job { cursor: default; }
.row.job[data-action] { cursor: pointer; }
.job-actions { display: flex; gap: 6px; margin-top: 6px; margin-left: -8px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; margin-bottom: 12px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.banner.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.scope-pill { display: flex; align-items: center; gap: 8px; margin: 10px 6px 0; padding: 6px 6px 6px 10px; border-radius: 9px; background: var(--hover); font-size: 12.5px; color: var(--muted); }
.scope-pill button { margin-left: auto; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.scope-pill button:hover { background: var(--line); }
.nav.folders { margin-top: 14px; }
.nav-item.subtle { color: var(--muted); }
.send-group { display: inline-flex; }
.send-group .btn:first-child { border-radius: 9px 0 0 9px; }
.send-group .btn.icon-only { border-radius: 0 9px 9px 0; padding: 9px 10px; border-left: 1px solid rgba(255, 255, 255, 0.25); }
.follow-sel { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.follow-sel select { border: 0; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; -webkit-appearance: none; appearance: none; padding: 4px 2px; }
.save-state { font-weight: 400; color: var(--faint); font-size: 12.5px; }
.label-list { max-height: 50vh; overflow-y: auto; }
.label-list input { width: 17px; height: 17px; accent-color: var(--accent); }
@media (max-width: 899px) {
  .compose-foot { flex-wrap: wrap; gap: 10px 14px; }
  .reader-actions .icon-btn { width: 38px; }
  .menu { left: 8px !important; right: 8px; width: auto; }
}

/* ---------------------------------------------------------------- Polymail-style layout */
.side-top { display: flex; align-items: center; gap: 10px; padding: 0 6px 14px; }
.compose-round { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--muted); color: var(--text); flex: none; }
.compose-round:hover { background: var(--hover); border-color: var(--text); }
.side-top .brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.sec-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 14px; padding: 4px 10px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-radius: 6px; }
.sec-toggle:hover { color: var(--text); }
.sec-toggle .ic { transition: transform 0.15s; }
.sec-toggle.closed .ic { transform: rotate(-90deg); }
.side-top + .sec-toggle { margin-top: 0; }
.nav-item.acct-email .nav-label { color: var(--muted); }
.nav-item.acct-email.active .nav-label { color: var(--accent); }
.nav-item.acct-email { padding-left: 28px; }
.f-archive { color: #34d399; } .f-trash { color: #f87171; } .f-sent { color: #60a5fa; } .f-drafts { color: #fb923c; }
.f-snoozed { color: #c084fc; } .f-scheduled { color: #2dd4bf; } .f-receipts { color: #5b9cf5; } .f-starred { color: #fbbf24; } .f-spam { color: #94a3b8; }
.nav-item.active .ic { color: inherit; }
.sync-line { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line2); margin-top: 8px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.sync-dot.syncing { background: var(--accent); animation: pulse 1s infinite; }
.sync-dot.error { background: var(--warn); }
.user-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; font-weight: 600; }
.user-row:hover { background: var(--hover); }
.user-row .avatar { width: 26px; height: 26px; font-size: 11px; }
.list-head { gap: 10px; }
.list-title-row .filter-btn { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; font-weight: 600; padding: 4px 8px; border-radius: 7px; }
.list-title-row .filter-btn:hover { background: var(--hover); color: var(--text); }
.row-top .row-from { font-size: 12.5px; color: var(--muted); }
.row.unread .row-top .row-from { color: var(--text); }
.row-subject { font-size: 14px; color: var(--text); }
.rcpt { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; flex: none; font-size: 12px; font-weight: 700; padding-left: 6px; }
.rcpt.opened { color: var(--accent); } .rcpt.maybe { color: var(--warn); } .rcpt.unopened { color: var(--faint); }
.rcpt .ic { fill: currentColor; }
.row > .dot { width: 7px; height: 7px; margin-top: 7px; }
.reader-participants { color: var(--muted); font-size: 13.5px; margin: -2px 0 14px; }
.reply-pill { position: sticky; bottom: 14px; display: flex; justify-content: center; pointer-events: none; margin-top: 6px; z-index: 2; }
.reply-pill > div { pointer-events: auto; display: inline-flex; background: var(--side); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.reply-pill button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; font-size: 13.5px; color: var(--text); }
.reply-pill button + button { border-left: 1px solid var(--line); }
.reply-pill button:hover { background: var(--hover); }
.msg-head .shield { color: var(--muted); display: inline-flex; margin-left: 8px; }
/* right-hand panel */
.side-panel { display: none; background: var(--pane); border-left: 1px solid var(--line); min-width: 0; min-height: 0; flex-direction: column; }
.panel-tabs { display: flex; align-items: center; gap: 2px; padding: calc(8px + var(--st)) 10px 8px; border-bottom: 1px solid var(--line2); min-height: 54px; }
.panel-tabs .icon-btn.active { color: var(--accent); background: var(--accent-soft); }
.panel-body { flex: 1; overflow-y: auto; padding: 16px; }
.panel-body h3 { margin: 0 0 4px; font-size: 16px; }
.panel-contact { text-align: center; padding: 6px 0 14px; border-bottom: 1px solid var(--line2); margin-bottom: 14px; }
.panel-contact .avatar { width: 56px; height: 56px; font-size: 20px; margin: 0 auto 10px; }
.panel-contact .email { color: var(--muted); font-size: 13px; word-break: break-all; }
.panel-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.panel-stats div { background: var(--side); border-radius: 10px; padding: 10px; }
.panel-stats b { display: block; font-size: 18px; } .panel-stats span { font-size: 12px; color: var(--muted); }
.panel-h { font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); margin: 4px 0 8px; }
.panel-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.panel-item:hover { background: var(--hover); }
.panel-item .t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-item .s { display: block; color: var(--muted); font-size: 12px; }
.ev { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line2); font-size: 13px; }
.ev .ic { margin-top: 2px; }
.ev .s { color: var(--muted); font-size: 12px; }
@media (min-width: 1280px) {
  .app.with-panel { grid-template-columns: 236px 380px minmax(0, 1fr) 300px; }
  .app.with-panel .side-panel { display: flex; }
}
.desktop-only.inline, .reader-actions .desktop-only { display: inline-flex; }
.panel-toggle-wrap { display: inline-flex; margin-left: 6px; padding-left: 6px; border-left: 1px solid var(--line2); }
@media (max-width: 1279px) { .panel-toggle-wrap { display: none; } }
@media (max-width: 899px) { .reader-actions .desktop-only { display: none !important; } }

/* compose body looks like the email recipients will see */
.compose-body { background: #ffffff; color: #1f2329; }
.compose-body a { color: #2c4fc4; }
.compose-body .mm-sig { color: inherit; }
.sig-preview { background: #fff; color: #1f2329; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; overflow-x: auto; }
.textarea.mono { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 160px; }
