/* light is the default; dark only when chosen, or when "Auto" is chosen on a dark device */
:root {
  --bg: #F3F3F5;
  --panel: #FFFFFF;
  --panel-2: #F7F7F9;
  --hover: #F2F2F5;
  --ink: #1A1A1F;
  --ink-2: #4A4A55;
  --ink-3: #85858F;
  --line: #E5E5EA;
  --accent: #D71920;
  --accent-ink: #FFFFFF;
  --accent-soft: #FDEEEE;
  --gold: #FF5A5F;
  --danger: #B3362B;
  --side: #16161A;
  --side-2: #232329;
  --side-ink: #BDBDC6;
  --paper: #FFFFFF;
  --shadow: 0 1px 2px rgba(20, 20, 26, .06), 0 8px 24px -12px rgba(20, 20, 26, .18);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E0E11; --panel: #17171B; --panel-2: #1E1E23; --hover: #212127; --ink: #ECECF0; --ink-2: #B6B6C0; --ink-3: #85858F;
  --line: #2A2A31; --accent: #FF6B70; --accent-ink: #160A0B; --accent-soft: #3A1518; --side: #0B0B0E; --side-2: #18181D; --side-ink: #AFAFB9;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0E0E11; --panel: #17171B; --panel-2: #1E1E23; --hover: #212127; --ink: #ECECF0; --ink-2: #B6B6C0; --ink-3: #85858F;
    --line: #2A2A31; --accent: #FF6B70; --accent-ink: #160A0B; --accent-soft: #3A1518; --side: #0B0B0E; --side-2: #18181D; --side-ink: #AFAFB9;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.5 "Figtree", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--panel); font: 600 11.5px/1.5 "Figtree", sans-serif; color: var(--ink-2); text-align: center; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: inherit; }

.app { display: grid; grid-template-columns: 252px minmax(340px, 420px) 1fr; height: 100dvh; }

/* ---------- sidebar ---------- */
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px 14px; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 16px; padding: 4px 10px 16px; letter-spacing: -.005em; }
.brand b { color: var(--gold); font-weight: 600; }
.mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #FFFFFF; }
.mark img { width: 26px; height: 26px; object-fit: contain; }
.compose-btn { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 4px 14px; padding: 11px 14px; border: 0; border-radius: 11px;
  background: #D71920; color: #FFFFFF; font-weight: 600; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.compose-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px -10px rgba(215, 25, 32, .6); }
.folders a, .boxes a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: inherit; text-decoration: none; transition: background .12s, color .12s; }
.folders a:hover, .boxes a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.folders a.on, .boxes a.on { background: var(--side-2); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center; color: #FFFFFF; background: #D71920; }
.count:empty { display: none; }
.boxes-head { margin: 18px 10px 6px; font-size: 12px; color: #737C98; }
.boxes { display: flex; flex-direction: column; gap: 1px; }
.boxes a { font-size: 13.5px; padding: 6px 10px; }
.boxes a.domain { font-weight: 600; color: #E3E7F2; margin-top: 6px; }
.boxes a.addr { padding-left: 30px; color: #A3AAC2; }
.boxes a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boxes .count { background: rgba(255, 90, 95, .18); color: var(--gold); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--dc, #8EA2FF); }
.me { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.me .who { color: #E3E7F2; overflow-wrap: anywhere; padding: 0 2px; }
.me-links { display: flex; flex-direction: column; gap: 6px; padding: 0 2px; }
.me a, .me .link { color: var(--side-ink); text-decoration: none; text-align: left; }
.me a:hover, .me .link:hover { color: #fff; }
.theme { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.theme button { border: 0; border-radius: 8px; padding: 5px 0; background: none; color: var(--side-ink); cursor: pointer; font-size: 12.5px; }
.theme button[aria-checked="true"] { background: var(--side-2); color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.scrim { display: none; }

/* ---------- message list ---------- */
.list { position: relative; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.list-head { display: flex; align-items: center; gap: 8px; padding: 18px 16px 6px 20px; }
.list-head .title { flex: 1; min-width: 0; }
.list-head h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.015em; }
.list-head .sub { margin: 0; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); cursor: pointer; transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
.menu { display: none; }
.tools { padding: 6px 16px 10px; min-height: 54px; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-2); color: var(--ink-3); transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--ink-2); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; padding: 10px 0; min-width: 0; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search:focus-within kbd { display: none; }
.select-bar { display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 6px 0 4px; border-radius: 11px; background: var(--accent-soft); }
.select-bar .n-sel { font-size: 13.5px; margin-right: auto; color: var(--ink); }
.select-bar .bulk { display: flex; gap: 2px; }
.select-bar .icon-btn { width: 34px; height: 34px; }
.select-bar .icon-btn:hover { background: var(--panel); }
.select-bar .link { padding: 0 8px; font-size: 13.5px; }

.items { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.group { padding: 14px 12px 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.item { display: grid; grid-template-columns: 38px 1fr auto; column-gap: 12px; padding: 11px 12px; border-radius: 12px; cursor: pointer; position: relative; transition: background .12s; }
.item + .item { margin-top: 1px; }
.item:hover { background: var(--hover); }
.item.on { background: var(--accent-soft); }
.item.sel { background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.item .pick { grid-row: 1 / span 3; position: relative; width: 38px; height: 38px; }
.item .pick .av { position: absolute; inset: 0; }
.item .pick input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.item .pick .box { position: absolute; inset: 7px; border-radius: 7px; border: 1.8px solid var(--ink-3); background: var(--panel); display: none; place-items: center; }
.item .pick .box svg { width: 15px; height: 15px; stroke: var(--accent-ink); stroke-width: 2.6; opacity: 0; }
.item:hover .pick .box, .selecting .item .pick .box { display: grid; }
.item:hover .pick .av, .selecting .item .pick .av { opacity: 0; }
.item.sel .pick .box { background: var(--accent); border-color: var(--accent); }
.item.sel .pick .box svg { opacity: 1; }
.av { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; font-weight: 650; font-size: 14.5px; color: #fff; background: hsl(var(--h, 230) 45% 52%); letter-spacing: .01em; }
.item .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; align-self: end; }
.item time { font-size: 12px; color: var(--ink-3); white-space: nowrap; align-self: end; }
.item.unread time { color: var(--accent); font-weight: 600; }
.item .subj { grid-column: 2 / -1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .snip { grid-column: 2 / -1; font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.unread .who, .item.unread .subj { font-weight: 700; color: var(--ink); }
.item.unread::after { content: ""; position: absolute; left: 3px; top: 50%; width: 4px; height: 22px; translate: 0 -50%; border-radius: 4px; background: var(--accent); }
.item .tags { grid-column: 2 / -1; display: flex; gap: 8px; align-items: center; margin-top: 3px; font-size: 11.5px; color: var(--ink-3); min-width: 0; }
.item .tags svg { width: 14px; height: 14px; }
.item .tags .star { color: #D9A21B; }
.item .tags .star svg { fill: #F2C86B; }
.item .tags .box-tag { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .tags .dot { width: 7px; height: 7px; }
.skel { padding: 13px 12px; display: grid; grid-template-columns: 38px 1fr; gap: 12px; }
.skel i { display: block; height: 10px; margin: 5px 0; border-radius: 6px; background: linear-gradient(90deg, var(--panel-2) 25%, var(--hover) 50%, var(--panel-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skel i.c { width: 38px; height: 38px; border-radius: 50%; margin: 0; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { padding: 56px 24px; text-align: center; color: var(--ink-3); }
.empty svg { width: 72px; height: 72px; stroke-width: 1.1; color: var(--line); margin-bottom: 10px; }
.empty b { display: block; color: var(--ink-2); font-weight: 600; margin-bottom: 2px; }
.more { margin: 0 16px 16px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: transparent; cursor: pointer; color: var(--ink-2); }
.more:hover { background: var(--hover); }
.fab { display: none; }

/* ---------- reader ---------- */
.reader { background: var(--bg); display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }
.empty-reader { margin: auto; text-align: center; color: var(--ink-3); padding: 24px; }
.empty-reader svg { width: 88px; height: 88px; stroke-width: 1; color: var(--ink-3); opacity: .55; }
.empty-reader b { display: block; margin-top: 8px; font-weight: 600; color: var(--ink-2); }
.empty-reader p { margin: 2px 0 0; font-size: 13.5px; }
.read-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 2px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.read-bar .back { display: none; }
.read-bar .spacer { flex: 1; }
.read-bar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.read-bar .pos { font-size: 12.5px; color: var(--ink-3); padding: 0 6px; white-space: nowrap; }
.read-bar .icon-btn.star-on { color: #D9A21B; }
.read-bar .icon-btn.star-on svg { fill: #F2C86B; }
.sheet { margin: 4px 20px 28px; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.read-head { padding: 24px 28px 14px; }
.read-head h2 { margin: 0 0 16px; font-size: 22px; line-height: 1.3; font-weight: 650; letter-spacing: -.015em; overflow-wrap: anywhere; }
.via { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--panel-2); font-size: 12px; color: var(--ink-2); }
.sender { display: flex; gap: 12px; align-items: flex-start; }
.sender .av { width: 42px; height: 42px; }
.sender .lines { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.sender .lines b { color: var(--ink); font-size: 15px; font-weight: 600; }
.sender .lines .addr { color: var(--ink-3); }
.sender time { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.notice { margin: 0 28px 4px; padding: 9px 12px; border-radius: 10px; background: var(--panel-2); font-size: 13px; color: var(--ink-2); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice svg { width: 17px; height: 17px; color: var(--ink-3); }
.notice button { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; }
.body { padding: 14px 28px 24px; }
.body iframe { width: 100%; border: 0; min-height: 80px; display: block; background: var(--paper); border-radius: 10px; }
:root[data-theme="dark"] .body iframe { padding: 8px; }
.body .plain { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.6; }
.body .plain a, .atts a { color: var(--accent); }
.atts { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 28px 24px; list-style: none; margin: 0; }
.atts a, .atts span.gone { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; font-size: 13px; color: var(--ink); max-width: 260px; transition: border-color .12s, background .12s; }
.atts a:hover { border-color: var(--accent); background: var(--accent-soft); }
.atts .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--panel-2); display: grid; place-items: center; flex: none; color: var(--ink-3); }
.atts .meta { min-width: 0; display: grid; }
.atts .meta b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atts small { color: var(--ink-3); }
.read-actions { display: flex; gap: 8px; padding: 0 28px 26px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); cursor: pointer; font-weight: 500; transition: border-color .12s, background .12s; }
.pill:hover { border-color: var(--ink-3); background: var(--hover); }
.pill svg { width: 17px; height: 17px; }

/* ---------- compose ---------- */
.compose { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end; padding: 20px; background: rgba(10, 14, 26, .32); animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.compose-card { width: min(680px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; background: var(--panel); border-radius: 18px; box-shadow: 0 30px 80px -20px rgba(10, 14, 26, .5); display: flex; flex-direction: column; animation: rise .2s cubic-bezier(.2, .8, .3, 1); }
@keyframes rise { from { translate: 0 16px; opacity: 0; } }
.compose-card header { display: flex; align-items: center; gap: 10px; padding: 14px 12px 6px 22px; }
.compose-card h2 { margin: 0; font-size: 16px; font-weight: 650; }
.compose-card .saved { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.field { display: flex; align-items: center; gap: 12px; margin: 0 22px; border-bottom: 1px solid var(--line); }
.field:focus-within { border-bottom-color: var(--accent); }
.field > span { width: 58px; flex: none; font-size: 13.5px; color: var(--ink-3); }
.field input, .field select { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 12px 0; }
.from-wrap { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.from-wrap select { flex: 1 1 220px; padding: 12px 0; border: 0; background: transparent; outline: 0; font-weight: 500; }
.new-from { display: flex; align-items: center; gap: 4px; flex: 1 1 260px; padding-bottom: 6px; }
.new-from input, .new-from select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); min-width: 0; }
.new-from input { flex: 1; }
.link-btn { align-self: flex-start; margin: 6px 22px 0 92px; border: 0; background: none; color: var(--accent); font-size: 13px; cursor: pointer; padding: 2px 0; }
.compose textarea { margin: 12px 22px 0; border: 0; outline: 0; resize: vertical; min-height: 220px; background: transparent; line-height: 1.6; font-size: 15px; }
.quote { margin: 0 22px; font-size: 13px; color: var(--ink-3); }
.quote summary { cursor: pointer; color: var(--ink-2); padding: 4px 0; }
.quote div { padding: 8px 12px; border-left: 2px solid var(--line); max-height: 180px; overflow: auto; white-space: pre-wrap; }
.files { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 22px 0; padding: 0; }
.files:empty { display: none; }
.files li { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 11px; border-radius: 999px; background: var(--panel-2); font-size: 12.5px; }
.files small { color: var(--ink-3); }
.files button { border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 0 4px; font-size: 16px; line-height: 1; }
.form-error { margin: 10px 22px 0; color: var(--danger); font-size: 13.5px; }
.form-error:empty { display: none; }
.compose footer { display: flex; align-items: center; gap: 16px; padding: 16px 22px 18px; flex-wrap: wrap; }
.send-btn { padding: 10px 28px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 650; cursor: pointer; transition: filter .12s, transform .12s; }
.send-btn:hover { filter: brightness(1.08); }
.send-btn:active { transform: scale(.98); }
.send-btn:disabled { opacity: .6; cursor: progress; }
.attach { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14px; cursor: pointer; }
.attach:hover { color: var(--ink); }
.hint { font-size: 12px; color: var(--ink-3); }
.compose .discard { margin-left: auto; font-size: 13px; color: var(--ink-3); }
.compose .discard:hover { color: var(--danger); }

/* ---------- shortcuts ---------- */
.keys { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 20px; background: rgba(10, 14, 26, .4); animation: fade .15s ease; }
.keys-card { width: min(420px, 100%); background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 10px 22px 22px; }
.keys-card header { display: flex; align-items: center; justify-content: space-between; }
.keys-card h2 { margin: 0; font-size: 16px; font-weight: 650; }
.keys-card dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 10px 0 0; align-items: center; }
.keys-card dt { text-align: right; white-space: nowrap; }
.keys-card dd { margin: 0; color: var(--ink-2); font-size: 14px; }

/* ---------- people ---------- */
.people { grid-column: 2 / -1; background: var(--bg); overflow-y: auto; padding: 28px clamp(16px, 4vw, 48px); }
.people h1 { margin: 0 0 4px; font-size: 22px; font-weight: 650; letter-spacing: -.015em; }
.people > p { margin: 0 0 22px; color: var(--ink-2); max-width: 62ch; }
.people .table { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 28px; }
.people table { width: 100%; border-collapse: collapse; font-size: 14px; }
.people th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12.5px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.people td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.people tr:last-child td { border-bottom: 0; }
.people td small { color: var(--ink-3); }
.people td .chip { display: inline-flex; align-items: center; gap: 6px; margin: 0 4px 4px 0; padding: 3px 10px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); font-size: 12.5px; }
.people .row-actions { text-align: right; white-space: nowrap; }
.people .row-actions button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0 6px; font: inherit; }
.people .row-actions button.danger { color: var(--danger); }
.person-form { display: grid; gap: 16px; max-width: 580px; padding: 22px; border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.person-form h2 { margin: 0; font-size: 16px; font-weight: 650; }
.person-form label { display: grid; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.person-form .label { display: block; font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; }
.person-form input[type=text], .person-form input[type=email] { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.person-form input[type=text]:focus, .person-form input[type=email]:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.person-form .doms { display: flex; flex-wrap: wrap; gap: 8px; }
.person-form .doms label, .person-form .check { display: flex; align-items: center; gap: 8px; color: var(--ink); padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); cursor: pointer; width: fit-content; }
.person-form .doms label:has(input:checked), .person-form .check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.person-form small { color: var(--ink-3); }

.toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 20px; opacity: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 11px 18px; border-radius: 999px; background: var(--ink); color: var(--panel); font-size: 14px; transition: opacity .2s, translate .2s; pointer-events: none; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5); }
.toast.on { opacity: 1; translate: -50% 0; pointer-events: auto; }
.toast .link { color: var(--gold); font-weight: 650; }

/* ---------- tablet: list and reader share the space ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 228px 1fr; }
  .app[data-view="list"] .reader { display: none; }
  .app[data-view="read"] .list { display: none; }
  .read-bar .back { display: grid; }
}
/* ---------- phone: one pane at a time, the sidebar slides in ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 284px; z-index: 16; translate: -100% 0; transition: translate .25s ease; padding-top: max(18px, env(safe-area-inset-top)); }
  .app.menu-open .side { translate: 0 0; box-shadow: 0 0 60px rgba(0, 0, 0, .35); }
  .app.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(10, 14, 26, .4); }
  .menu { display: grid; }
  .list-head { padding-top: max(14px, env(safe-area-inset-top)); padding-left: 10px; }
  .people { grid-column: 1; }
  .sheet { margin: 0 0 20px; border-radius: 0; box-shadow: none; }
  .reader { background: var(--panel); }
  .read-bar { background: color-mix(in srgb, var(--panel) 90%, transparent); padding-top: max(10px, env(safe-area-inset-top)); }
  .read-bar .pos { display: none; }
  .read-head, .body, .atts, .read-actions { padding-left: 16px; padding-right: 16px; }
  .notice { margin-left: 16px; margin-right: 16px; }
  .fab { display: grid; place-items: center; position: absolute; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border: 0; border-radius: 18px; background: #D71920; color: #FFFFFF; box-shadow: 0 10px 24px -8px rgba(215, 25, 32, .45); cursor: pointer; z-index: 3; }
  .fab svg { width: 24px; height: 24px; }
  .selecting .fab { display: none; }
  .compose { padding: 0; }
  .compose-card { max-height: 100dvh; height: 100dvh; border-radius: 0; padding-top: env(safe-area-inset-top); }
  .link-btn { margin-left: 22px; }
  .hint { display: none; }
  .search kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, 1fr); background: var(--panel); }
.login-art { position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 36px 44px; background: var(--side); color: var(--side-ink);
  background-image: radial-gradient(60% 50% at 70% 40%, rgba(215, 25, 32, .24), transparent 70%), radial-gradient(50% 40% at 20% 85%, rgba(255, 255, 255, .06), transparent 70%); }
.login-art .brand { padding: 0; }
.art-line { margin: 0; max-width: 18ch; font-size: clamp(26px, 3vw, 38px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; color: #fff; }
.stack { position: relative; flex: 1; min-height: 260px; }
.env { position: absolute; width: min(340px, 70%); padding: 18px 20px 20px; border-radius: 16px; background: #fff; box-shadow: 0 30px 60px -25px rgba(0, 0, 0, .55); display: grid; grid-template-columns: 34px 1fr; gap: 8px 12px; }
.env i { grid-row: 1 / span 3; width: 34px; height: 34px; border-radius: 50%; background: var(--dc); }
.env b { height: 10px; width: 55%; border-radius: 6px; background: #18203A; opacity: .85; margin-top: 4px; }
.env s { height: 8px; border-radius: 6px; background: #E3E6EE; }
.env s:last-child { width: 70%; }
.e1 { left: 6%; top: 18%; rotate: -6deg; }
.e2 { left: 26%; top: 36%; rotate: 3deg; }
.e3 { left: 12%; top: 56%; rotate: -2deg; animation: drop .9s cubic-bezier(.2, .8, .3, 1) both .15s; }
@keyframes drop { from { translate: 0 -40px; opacity: 0; } }
.login-panel { display: grid; place-items: center; padding: 32px 24px; }
.login-form { width: min(380px, 100%); display: grid; gap: 16px; }
.login-form .brand.small { display: none; color: var(--ink); padding: 0 0 8px; }
.login-form .brand.small b { color: var(--accent); }
.login-form .brand.small .mark { background: var(--accent-soft); }
.login-form h1 { margin: 0; font-size: 30px; font-weight: 650; letter-spacing: -.02em; }
.lede { margin: -8px 0 6px; color: var(--ink-2); }
.in { display: grid; gap: 6px; font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.in input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-2); font-size: 15px; font-weight: 400; transition: border-color .15s, box-shadow .15s; }
.in input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--panel); }
.in small { color: var(--ink-3); font-weight: 400; }
.pw { position: relative; display: block; }
.pw input { padding-right: 64px; }
.pw .link { position: absolute; right: 12px; top: 50%; translate: 0 -50%; font-size: 13px; font-weight: 600; }
.send-btn.wide { width: 100%; padding: 13px; font-size: 15px; }
.fine { margin: 0; font-size: 13px; color: var(--ink-3); text-align: center; }
.login .form-error, .pass-form .form-error { margin: 0; }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-form .brand.small { display: flex; }
  .login-panel { place-items: start center; padding-top: max(12vh, env(safe-area-inset-top)); }
}

/* ---------- sidebar: who and how much they sent ---------- */
.me .who { display: flex; align-items: center; gap: 10px; padding: 0 2px; }
.me .who .av { width: 34px; height: 34px; font-size: 13px; flex: none; }
.who-text { display: grid; min-width: 0; }
.who-text b { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { color: #8C94AE; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quota { display: grid; gap: 6px; padding: 0 2px; font-size: 12px; color: #8C94AE; }
.quota .bar { height: 5px; border-radius: 5px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.quota .bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--gold); transition: width .4s; }
.quota.high .bar i { background: #E5735F; }

/* ---------- password dialog and logins screen extras ---------- */
.pass-form { display: grid; gap: 16px; padding-bottom: 22px; }
.people .usage { font-size: 12.5px; color: var(--ink-3); }
.people .state { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; background: var(--panel-2); color: var(--ink-3); }
.people .state.admin { background: var(--accent-soft); color: var(--accent); }
.people .state.off { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.people .cap { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin: -8px 0 20px; font-size: 13.5px; color: var(--ink-2); }
.people .cap .bar { width: 160px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.people .cap .bar i { display: block; height: 100%; background: var(--accent); }
.person-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.person-form .roles { display: grid; gap: 8px; }
.person-form .roles label { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--ink); }
.person-form .roles label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.person-form .roles input { grid-row: 1 / span 2; margin-top: 3px; accent-color: var(--accent); }
.person-form .roles small { grid-column: 2; }
.person-form .pw-row { display: flex; gap: 8px; }
.person-form .pw-row input { flex: 1; min-width: 0; }
.person-form .pw-row button { flex: none; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; }
.person-form input[type=number], .person-form input[type=password] { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.person-form .actions { display: flex; gap: 14px; align-items: center; }
@media (max-width: 760px) {
  .person-form .two { grid-template-columns: 1fr; }
  .people table thead { display: none; }
  .people table, .people tbody, .people tr, .people td { display: block; }
  .people tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .people td { border: 0; padding: 4px 16px; }
  .people .row-actions { text-align: left; }
}

/* ---------- editor ---------- */
.tools-bar { display: flex; align-items: center; gap: 2px; margin: 10px 22px 0; padding: 4px; border-radius: 10px; background: var(--panel-2); width: fit-content; }
.tools-bar button { display: grid; place-items: center; width: 32px; height: 30px; border: 0; border-radius: 7px; background: none; color: var(--ink-2); cursor: pointer; }
.tools-bar button:hover { background: var(--hover); color: var(--ink); }
.tools-bar button.on { background: var(--accent-soft); color: var(--accent); }
.tools-bar svg { width: 17px; height: 17px; }
.tools-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.editor { margin: 10px 22px 0; min-height: 220px; max-height: 50dvh; overflow-y: auto; outline: 0; line-height: 1.6; font-size: 15px; overflow-wrap: anywhere; }
.editor:empty::before { content: attr(data-placeholder); color: var(--ink-3); }
.editor a { color: var(--accent); }
.editor ul, .editor ol { padding-left: 1.4em; margin: .3em 0; }
.editor .sig { color: var(--ink-2); }
.suggest { position: absolute; z-index: 5; list-style: none; margin: 0; padding: 6px; min-width: 300px; max-width: calc(100% - 44px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.suggest li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--accent-soft); }
.suggest .av { width: 30px; height: 30px; font-size: 12px; }
.suggest span { display: grid; min-width: 0; font-size: 13.5px; }
.suggest small { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.compose-card { position: relative; }

/* ---------- conversation ---------- */
.thread-count { display: inline-grid; place-items: center; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--panel-2); color: var(--ink-2); font-size: 11.5px; font-weight: 600; line-height: 18px; vertical-align: 1px; }
.item.unread .thread-count { background: var(--accent-soft); color: var(--accent); }
.conv { display: flex; flex-direction: column; }
.msg + .msg { border-top: 1px solid var(--line); }
.msg-head { display: flex; gap: 12px; align-items: flex-start; padding: 16px 28px; cursor: pointer; }
.msg.open .msg-head { cursor: default; padding-bottom: 6px; }
.msg-head .av { width: 38px; height: 38px; }
.msg-head .lines { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink-2); }
.msg-head .lines b { color: var(--ink); font-size: 14.5px; font-weight: 600; }
.msg-head .lines .addr { color: var(--ink-3); }
.msg-head .peek { display: block; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.open .peek { display: none; }
.msg:not(.open) .to-line { display: none; }
.msg-head time { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.msg-head .mini { display: flex; gap: 0; margin: -6px -8px 0 0; }
.msg:not(.open) .mini { display: none; }
.msg-head .mini .icon-btn { width: 32px; height: 32px; }
.msg-head .mini svg { width: 17px; height: 17px; }
.msg:not(.open) .msg-body { display: none; }
.msg.unread-dot .lines b::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--accent); vertical-align: 2px; }
.collapsed-more { margin: 0 28px; padding: 8px 0; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: none; color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer; text-align: left; }
.read-head.conv-head { padding-bottom: 6px; }
.read-head.conv-head h2 { margin-bottom: 4px; }

/* ---------- settings ---------- */
.settings-block { max-width: 640px; margin-bottom: 18px; padding: 22px; border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); display: grid; gap: 14px; }
.settings-block h2 { margin: 0; font-size: 16px; font-weight: 650; }
.settings-block > p { margin: -6px 0 0; color: var(--ink-2); font-size: 14px; }
.settings-block textarea, .settings-block input[type=text], .settings-block input[type=date] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); line-height: 1.5; }
.settings-block textarea { min-height: 110px; resize: vertical; }
.settings-block textarea:focus, .settings-block input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.settings-block label { display: grid; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.settings-block .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.switch { display: inline-flex !important; grid-auto-flow: column; align-items: center; gap: 10px !important; cursor: pointer; color: var(--ink) !important; font-size: 14.5px !important; }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: translate .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { translate: 16px 0; }
.settings-block .status { font-size: 13px; color: var(--ink-3); }
.settings-block .status.good { color: #2F8F5B; }
.pill.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill.primary:hover { filter: brightness(1.08); background: var(--accent); }

/* ---------- each pane scrolls on its own; the page itself never scrolls ---------- */
html, body { overflow: hidden; overscroll-behavior: none; }
.login { height: 100dvh; overflow-y: auto; }
.app { grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.side, .list, .reader, .people { min-height: 0; }
.list { overflow: hidden; }
.items, .reader, .people, .side { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.items { min-height: 0; scroll-padding-top: 40px; }
.reader { scroll-padding-top: 64px; }
.list .more { flex: none; }
.compose-card { overscroll-behavior: contain; }
@media (max-width: 760px) {
  .app { height: 100dvh; }
  .side { overflow-y: auto; }
}
/* the reader scrolls; the sheet inside must keep its full height, never squeeze to fit */
.reader > * { flex-shrink: 0; }
.reader > .empty-reader { flex-shrink: 1; }
@media (max-width: 760px) {

  .items { padding-bottom: 88px; }
  .msg-head { padding: 14px 16px; }
  .msg-head .mini { display: none; }
  .msg-head time { font-size: 12px; }
  .collapsed-more { margin: 0 16px; }
  .read-bar { gap: 0; padding-left: 8px; padding-right: 8px; }
  .read-bar .icon-btn { width: 34px; }
}

/* ---------- app feel on every screen ---------- */
* { -webkit-tap-highlight-color: transparent; }
.side, .tabbar, .list-head, .read-bar, .item, .select-bar, .compose-card header, .fab { -webkit-user-select: none; user-select: none; }
button, a, .item { touch-action: manipulation; }
.tabbar, .ptr, .send-top { display: none; }
.ptr { position: absolute; left: 50%; top: 8px; z-index: 4; width: 40px; height: 40px; place-items: center; border-radius: 50%; background: var(--panel); color: var(--accent); box-shadow: var(--shadow); translate: -50% 0; opacity: 0; pointer-events: none; }
.ptr.spin svg { animation: spin .8s linear infinite; }
@media (display-mode: standalone) { .install { display: none !important; } }

/* ---------- phone: a real app shell ---------- */
@media (max-width: 760px) {
  input, select, textarea, .editor { font-size: 16px !important; } /* stops iPhone zooming in on tap */
  .ptr { display: grid; }

  /* tab bar at the bottom, like a native mail app */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 2px; padding: 4px 0; border: 0; background: none; color: var(--ink-3); font: 500 11px/1.2 "Figtree", sans-serif; text-decoration: none; cursor: pointer; }
  .tabbar .ic { position: relative; display: grid; place-items: center; width: 52px; height: 30px; border-radius: 999px; transition: background .15s; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--accent); font-weight: 650; }
  .tabbar a.on .ic { background: var(--accent-soft); }
  .tabbar a.on svg { stroke-width: 2.1; }
  .tabbar .count { position: absolute; top: -3px; right: 2px; min-width: 18px; padding: 0 5px; font-size: 10.5px; line-height: 17px; color: #fff; background: #E5484D; }
  .app[data-view="read"] .tabbar { display: none; }

  /* list: edge to edge rows, a compact top bar */
  .list { background: var(--panel); }
  .list-head { padding: max(10px, env(safe-area-inset-top)) 8px 2px 4px; }
  .list-head h1 { font-size: 26px; }
  .tools { padding: 4px 14px 8px; min-height: 52px; }
  .search { border-radius: 12px; background: var(--hover); border-color: transparent; }
  .items { padding: 0 0 calc(150px + env(safe-area-inset-bottom)); background: var(--panel); }
  .group { padding: 12px 16px 6px; }
  .item { border-radius: 0; padding: 12px 16px; background: var(--panel); }
  .item + .item { margin-top: 0; box-shadow: 0 -1px 0 var(--line); }
  .item:hover { background: var(--panel); }
  .item:active { background: var(--hover); }
  .item.on { background: var(--panel); }
  .item.unread::after { left: 4px; }
  .item:hover .pick .box { display: none; }
  .item:hover .pick .av { opacity: 1; }
  .selecting .item .pick .box { display: grid; }
  .selecting .item .pick .av { opacity: 0; }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: 16px; border-radius: 16px; }

  /* reader slides in, with Reply buttons in thumb reach */
  .app[data-view="read"] .reader { animation: slide-in .22s cubic-bezier(.2, .8, .3, 1); }
  @keyframes slide-in { from { translate: 24% 0; opacity: .4; } }
  .read-bar { border-bottom: 1px solid var(--line); }
  .read-bar .back svg { width: 24px; height: 24px; }
  .read-bar > .icon-btn[data-act="reply"], .read-bar > .icon-btn[data-act="reply-all"], .read-bar > .icon-btn[data-act="forward"], .read-bar > .sep { display: none; }
  .read-bar .spacer { order: 1; }
  .read-bar > .icon-btn[data-act="star"], .read-bar > .icon-btn[data-act="unread"], .read-bar > .icon-btn[data-act="restore"], .read-bar > .icon-btn[data-act="delete"] { order: 2; }
  .read-bar > [data-act="prev"], .read-bar > [data-act="next"] { order: 3; }
  .read-head { padding-top: 16px; }
  .read-head h2 { font-size: 21px; }
  .body { padding: 10px 12px 18px; }
  .read-actions { position: sticky; bottom: 0; z-index: 2; display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--panel) 94%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
  .read-actions .pill { justify-content: center; padding: 11px 6px; }
  .sheet { min-height: calc(100% - 57px); display: flex; flex-direction: column; }
  .sheet .conv { flex: 1; }

  /* compose: full screen, close on the left, send on the right */
  .compose { animation: none; background: var(--panel); }
  .compose-card { animation: slide-up .25s cubic-bezier(.2, .8, .3, 1); box-shadow: none; }
  @keyframes slide-up { from { translate: 0 30%; opacity: .5; } }
  .compose-card header { position: sticky; top: 0; z-index: 3; background: var(--panel); padding: max(8px, env(safe-area-inset-top)) 8px 8px; border-bottom: 1px solid var(--line); gap: 4px; }
  .compose-card header h2 { flex: 1; font-size: 17px; }
  .compose-card .close-top { order: -1; }
  .compose-card .saved { margin: 0 4px; }
  .send-top { display: grid; color: var(--accent); }
  .send-top svg { width: 23px; height: 23px; }
  .compose footer .send-btn { display: none; }
  .field { margin: 0 16px; }
  .tools-bar, .editor, .quote, .files, .form-error { margin-left: 16px; margin-right: 16px; }
  .compose footer { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
  .compose .discard { margin-left: auto; }

  /* pages (settings, logins) leave room for the tab bar */
  .people { padding-bottom: calc(110px + env(safe-area-inset-bottom)); padding-top: max(20px, env(safe-area-inset-top)); }
  .side { padding-bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 16; }
}

.more-row { list-style: none; padding: 8px 0 0; }
.more-row .more { width: calc(100% - 32px); margin: 0 16px 8px; display: block; }
@media (max-width: 760px) { .items { padding-bottom: calc(160px + env(safe-area-inset-bottom)); } }

/* swiping an email shows a colored strip with what will happen, only behind that email */
.items { overflow-x: hidden; }
.item[data-swipe]::before { position: absolute; top: 0; bottom: 0; width: 100vw; display: flex; align-items: center; padding: 0 24px; color: #fff; font-weight: 650; font-size: 14px; }
.item[data-swipe="trash"]::before { content: "Trash"; left: 100%; background: #E5484D; }
.item[data-swipe="read"]::before, .item[data-swipe="unread"]::before { right: 100%; justify-content: flex-end; background: var(--accent); color: var(--accent-ink); }
.item[data-swipe="read"]::before { content: "Mark as read"; }
.item[data-swipe="unread"]::before { content: "Mark as unread"; }
