/* ==========================================================================
   Mailbox (/inbox) — sign in + three-pane reader
   ========================================================================== */

body { overflow: hidden; }
.spacer { flex: 1; }

/* --- Boot -------------------------------------------------------------- */
.boot {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity .5s var(--ease), visibility .5s;
}
.boot .wm3d { font-size: 24px; }
body:not(.is-booting) .boot { opacity: 0; visibility: hidden; }

/* ========================================================== Sign in === */
.login {
  position: fixed; inset: 0;
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(400px, 1fr);
  background: var(--bg);
  overflow: auto;
}
.login-art {
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: 34px 44px 32px;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.login-art-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 3; }
.login-stage { position: relative; z-index: 1; display: grid; gap: 56px; align-content: center; flex: 1; }
.login-hero {
  margin: 0;
  font-size: clamp(46px, 6.2vw, 96px);
  font-stretch: 112%;
  font-weight: 780;
  letter-spacing: -.045em;
  line-height: .95;
  max-width: 11ch;
}
.login-hero .w-mask:nth-last-child(-n+2) .w { color: var(--ink-3); }

/* The deck: example messages cycling like cards being dealt. */
.deck-wrap { perspective: 1100px; width: min(440px, 100%); }
.deck { position: relative; height: 150px; transform-style: preserve-3d; transition: transform .9s var(--ease); }
.deck-card {
  position: absolute; inset: 0 0 auto 0;
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 4px 14px; align-items: center;
  padding: 18px 18px 18px 16px;
  border-radius: 18px;
  background: var(--bg-3);
  box-shadow: 0 1px 0 rgba(255, 244, 230, .06) inset, 0 30px 60px -30px rgba(0, 0, 0, .8), 0 0 0 1px var(--line-2);
  transform-origin: 50% 0;
  transition: transform 1s var(--ease-spring), opacity .7s var(--ease), filter .7s var(--ease);
  will-change: transform;
}
.deck-card[data-pos='0'] { transform: translate3d(0, 0, 0); z-index: 3; }
.deck-card[data-pos='1'] { transform: translate3d(0, -16px, -40px) scale(.95); opacity: .62; z-index: 2; filter: saturate(.6); }
.deck-card[data-pos='2'] { transform: translate3d(0, -30px, -80px) scale(.9); opacity: .3; z-index: 1; filter: saturate(.3); }
.deck-card[data-pos='3'] { transform: translate3d(0, -40px, -120px) scale(.86); opacity: 0; z-index: 0; }
.deck-card.out { transform: translate3d(-36%, 30px, 60px) rotate(-9deg) !important; opacity: 0 !important; transition-duration: .8s, .5s, .5s; transition-timing-function: var(--ease-in-out); }
.deck-card .av { --_s: 40px; border-radius: 12px; grid-row: span 2; }
.deck-from { font-weight: 640; font-size: 14px; }
.deck-time { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); }
.deck-subject { grid-column: 2 / 4; font-size: 13.5px; color: var(--ink-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-code {
  grid-column: 2 / 4; justify-self: start; margin-top: 8px;
  display: inline-flex; gap: 5px;
}
.deck-code span {
  width: 26px; height: 32px; border-radius: 7px;
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 16px; color: var(--ink);
  background: var(--bg-4); box-shadow: 0 0 0 1px var(--line-2) inset;
}
.deck-code span:first-child { box-shadow: 0 0 0 1px var(--accent-line) inset; }

.login-facts { list-style: none; margin: 0; padding: 0; display: flex; gap: 28px; flex-wrap: wrap; position: relative; z-index: 3; }
.login-facts li { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.login-facts .ico { width: 15px; height: 15px; color: var(--ink-2); }

.login-pane { position: relative; display: grid; place-items: center; padding: 40px 28px; }
.login-theme { position: absolute; top: 22px; right: 22px; }
.login-card { width: min(360px, 100%); display: grid; gap: 16px; }
.login-card > .label { color: var(--accent-text); }
.login-card .display { font-size: 38px; margin: -8px 0 -6px; font-weight: 740; letter-spacing: -.035em; }
.login-card > .muted { margin: 0 0 8px; font-size: 14px; }
.login-card .input { height: 46px; font-size: 14.5px; border-radius: 11px; background: var(--bg-1); }
.login-card .input-group > .ico { left: 14px; }
.login-card .input-group > .input { padding-left: 40px; padding-right: 42px; }
.login-mark { display: none; margin-bottom: 22px; }
.login-mark .wm3d, .login-art-top .wm3d { font-size: 19px; }
.caps { margin: 0; font-size: 12px; color: var(--warn); }
.login-back { display: inline-flex; align-items: center; gap: 6px; justify-self: center; color: var(--ink-3); text-decoration: none; font-size: 13px; }
.login-back:hover { color: var(--ink); }
.login-card .btn-lg { height: 48px; margin-top: 6px; border-radius: 12px; font-size: 14.5px; }
.login-card .btn-lg .ico { transition: transform .5s var(--ease-spring); }
.login-card .btn-lg:hover .ico { transform: translateX(4px); }
.login-note { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); text-align: center; line-height: 1.5; }
.login-card.shake { animation: shake .5s var(--ease); }
.login-card.leaving { animation: leave .5s var(--ease-in-out) forwards; }
@keyframes shake { 15%, 55% { transform: translateX(-7px); } 35%, 75% { transform: translateX(7px); } }
@keyframes leave { to { opacity: 0; transform: translateY(-12px) scale(.98); filter: blur(6px); } }

@media (max-width: 960px) {
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-mark { display: inline-flex; }
}

/* ========================================================== App shell === */
.app {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  padding: 10px 10px 10px 0;
  background: var(--bg);
  transition: grid-template-columns .45s var(--ease);
}
.rail-mini { display: none; }
.rail-toggle { color: var(--ink-3); }
.rail-toggle .ico { width: 16px; height: 16px; }

/* --- Rail -------------------------------------------------------------- */
.rail { display: flex; flex-direction: column; gap: 16px; padding: 12px 14px 8px 18px; min-height: 0; }
.rail-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 34px; padding-left: 4px; }
.rail-top .wordmark { overflow: hidden; }
.rail-close { display: none; }

.account {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px 8px 8px;
  border-radius: 12px;
  background: var(--bg-1);
  box-shadow: 0 0 0 1px var(--line-2) inset;
  text-align: left;
  transition: background var(--t), box-shadow var(--t);
}
.account:hover { background: var(--bg-2); box-shadow: 0 0 0 1px var(--line-3) inset; }
.account > .ico { color: var(--ink-3); margin-left: auto; transition: transform .4s var(--ease-spring); }
.account:hover > .ico { transform: translateY(2px); }
.account-meta { display: grid; min-width: 0; flex: 1; }
.account-meta .label { font-size: 11px; }
.account-email { font-size: 13px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-email .f { display: none; }
.account:hover .account-email .m { display: none; }
.account:hover .account-email .f { display: inline; }

.rail-copy { height: 38px; width: 100%; border-radius: 11px; }

.folders { position: relative; display: grid; gap: 2px; isolation: isolate; }
.folders > .label { margin: 6px 0 6px 12px; }
.folders > .ind {
  position: absolute; left: 0; top: 0; z-index: -1;
  border-radius: 10px;
  background: var(--bg-3);
  box-shadow: 0 0 0 1px var(--line) inset;
  transition: transform .6s var(--ease-spring), height .3s var(--ease), width .3s var(--ease), opacity .2s;
}
.folder {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 36px; padding: 0 10px 0 12px;
  border-radius: 10px;
  color: var(--ink-3);
  font-weight: 560; font-size: 13.5px;
  text-align: left;
  transition: color var(--t);
}
.folder:hover { color: var(--ink); }
.folder.active { color: var(--ink); }
.folder .ico { width: 17px; height: 17px; transition: transform .5s var(--ease-spring), color var(--t); }
.folder:hover .ico { transform: scale(1.1) rotate(-4deg); }
.folder.active .ico { color: var(--accent); }
.folder .badge { margin-left: auto; }
.folder .badge:empty { display: none; }
.badge.bump { animation: bump .6s var(--ease-spring); }
@keyframes bump { 35% { transform: scale(1.35); } }

.pulse {
  margin-top: auto;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg-1);
  box-shadow: 0 0 0 1px var(--line-2) inset;
  display: grid; gap: 8px;
}
.pulse-head { display: flex; justify-content: space-between; align-items: center; }
.pulse-live { display: inline-flex; align-items: center; gap: 6px; }
.pulse-live .dot { background: var(--ink-4); }
.pulse-live.on { color: var(--ok); }
.pulse-live.on .dot { background: var(--ok); }
.pulse-num { display: flex; align-items: baseline; gap: 8px; }
.pulse-num b { font-size: 34px; font-weight: 740; letter-spacing: -.03em; }
.pulse-num span { color: var(--ink-3); font-size: 12.5px; }
.pulse-meta { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.pulse-meta b { color: var(--ink-2); font-weight: 600; }

.rail-foot { display: flex; align-items: center; gap: 2px; padding-top: 2px; }

/* --- Surface (list + reader) ------------------------------------------ */
.surface {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  min-height: 0;
  border-radius: 18px;
  background: var(--bg-1);
  box-shadow: 0 0 0 1px var(--line-2), 0 40px 80px -40px rgba(0, 0, 0, .5);
  overflow: hidden;
}

/* --- List -------------------------------------------------------------- */
.list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line-2); position: relative; }
.list-head { padding: 16px 16px 12px; display: grid; gap: 12px; border-bottom: 1px solid var(--line); position: relative; }
.list-title-row { display: flex; align-items: center; gap: 8px; height: 34px; }
.list-title-row h1 { margin: 0; font-size: 24px; font-weight: 760; letter-spacing: -.035em; }
.list-menu { display: none; margin-left: -6px; }
.search-field > .input { height: 36px; border-radius: 10px; }
.search-field kbd { pointer-events: none; }
.list-tools { display: flex; align-items: center; gap: 10px; padding-left: 11px; }
.bulkbar {
  position: absolute; left: 10px; right: 10px; bottom: 8px;
  display: flex; align-items: center; gap: 2px;
  height: 38px; padding: 0 4px 0 12px;
  border-radius: 11px;
  background: var(--bg-4);
  box-shadow: var(--shadow-pop);
  animation: bar-in .5s var(--ease-spring);
}
@keyframes bar-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.bulk-count { font-size: 12.5px; color: var(--ink-2); }
.bulk-count b { color: var(--ink); }

.items { flex: 1; overflow-y: auto; overflow-x: hidden; outline: none; position: relative; overscroll-behavior: contain; }
.items > .plate { left: 6px; right: 6px; border-radius: 12px; }

.item {
  --_pad: 11px;
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 11px;
  margin: 0 6px;
  padding: var(--_pad) 12px var(--_pad) 14px;
  border-radius: 12px;
  cursor: default;
  user-select: none;
  transition: background var(--t);
}
.item + .item::after {
  content: ''; position: absolute; left: 57px; right: 12px; top: 0; height: 1px; background: var(--line);
  transition: opacity var(--t);
}
.item.active::after, .item.active + .item::after { opacity: 0; }
.item:first-of-type { margin-top: 6px; }
/* Focus ring only while moving with J/K or arrows, never after a click. */
.items.kbd-nav .item.focus { box-shadow: 0 0 0 1px var(--line-2) inset; }
.item.active { background: var(--row-active); }
.item.checked { background: var(--accent-soft); }

.item-lead { position: relative; width: 32px; height: 32px; margin-top: 2px; }
.item-lead .av { --_s: 32px; border-radius: 10px; transition: opacity var(--t), transform .45s var(--ease-spring); }
.item-lead .check {
  position: absolute; inset: 0; width: 32px; height: 32px;
  display: grid; place-items: center;
  opacity: 0; transform: scale(.6);
  transition: opacity var(--t), transform .45s var(--ease-spring);
}
/* The checkbox appears when pointing at the avatar, not on every row hover. */
.item-lead:hover .check, .item.checked .item-lead .check, .items.selecting .item-lead .check { opacity: 1; transform: none; }
.item-lead:hover .av, .item.checked .item-lead .av, .items.selecting .item-lead .av { opacity: 0; transform: scale(.85); }

.item-main { min-width: 0; display: grid; gap: 1px; line-height: 1.35; }
.item-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.item-from { font-weight: 600; color: var(--ink-2); font-size: 13.5px; }
.item-time { margin-left: auto; font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; flex: none; transition: opacity var(--t); }
.item-subject { font-size: 13.5px; color: var(--ink-2); font-weight: 520; flex: 1 1 auto; }
.item-snippet { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.item-badges { display: flex; align-items: center; gap: 6px; flex: none; }
.item-badges .ico { width: 13px; height: 13px; color: var(--ink-3); }
.item-acct { font-size: 10.5px; color: var(--ink-3); border-radius: 99px; padding: 1px 7px; background: var(--bg-3); max-width: 120px; }

.item.unread .item-from { color: var(--ink); font-weight: 680; }
.item.unread .item-subject { color: var(--ink); font-weight: 600; }
.item.unread::before {
  content: ''; position: absolute; left: 4px; top: calc(var(--_pad) + 15px);
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.item-star { color: var(--ink-4); width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex: none; transition: color var(--t), transform .5s var(--ease-spring); }
.item-star .ico { width: 14px; height: 14px; }
.item-star:hover { color: var(--ink-2); }
.item.starred .item-star { color: var(--warn); }
.item.starred .item-star .ico { fill: currentColor; }
.item-star.pop { animation: star-pop .6s var(--ease-spring); }
@keyframes star-pop { 30% { transform: scale(1.5) rotate(-18deg); } }

/* Quick actions slide over the timestamp on hover */
.item-quick {
  position: absolute; right: 10px; top: 6px;
  display: flex; gap: 2px; padding: 2px;
  border-radius: 9px; background: var(--bg-2);
  box-shadow: 0 0 0 1px var(--line);
  opacity: 0; transform: translateX(4px);
  transition: opacity .25s, transform .45s var(--ease);
  pointer-events: none;
}
.item:hover .item-quick { opacity: 1; transform: none; pointer-events: auto; }
.item:hover .item-time { opacity: 0; }
.items.dragging .item-quick, .items.selecting .item-quick { display: none; }
.items.selecting .item:hover .item-time { opacity: 1; }
.item-quick .icon-btn { width: 26px; height: 26px; border-radius: 7px; }
.item-quick .icon-btn .ico { width: 14px; height: 14px; }

.item.new::after {
  content: ''; position: absolute; inset: 0; border-radius: 12px; opacity: 1 !important;
  background: linear-gradient(100deg, transparent 20%, var(--accent-soft) 50%, transparent 80%);
  background-size: 250% 100%;
  animation: sweep 1.6s var(--ease) forwards;
  pointer-events: none;
}
@keyframes sweep { from { background-position: 120% 0; } to { background-position: -40% 0; opacity: 0; } }

/* Compact density */
.density-compact .item { --_pad: 6px; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; }
.density-compact .item-lead, .density-compact .item-lead .check { width: 26px; height: 26px; }
.density-compact .item-lead .av { --_s: 26px; border-radius: 8px; }
.density-compact .item-lead { margin-top: 0; }
.density-compact .item-snippet { display: none; }
.density-compact .item.unread::before { top: calc(var(--_pad) + 10px); }
.density-compact .item-quick { top: 4px; }
.density-compact .item + .item::after { left: 48px; }

.list-foot { padding: 16px; display: grid; place-items: center; color: var(--ink-3); font-size: 12px; }
.list-foot .spinner { width: 16px; height: 16px; }

.sk-item { display: grid; grid-template-columns: 32px 1fr; gap: 11px; padding: 10px 20px; }
.sk-item .sk.av-sk { width: 32px; height: 32px; border-radius: 10px; }
.sk-item div { display: grid; gap: 7px; align-content: center; }

.drag-rect {
  position: absolute; z-index: 5; pointer-events: none;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: 6px;
}

/* --- Reader ------------------------------------------------------------ */
.reader { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg-1); }
.reader-empty { flex: 1; display: grid; place-items: center; }
.reader-empty kbd { margin: 0 1px; }

.msg { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.msg-bar {
  display: flex; align-items: center; gap: 2px;
  height: 56px; padding: 0 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.msg-bar-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 6px; }
.msg-back { display: none; }
.msg-pos { margin-right: 6px; font-family: var(--f-mono); font-size: 11px; }
.msg-bar [data-msg='star'].active .ico { fill: currentColor; color: var(--warn); }

.msg-scroll { flex: 1; overflow-y: auto; padding: 30px 36px 30px; display: flex; flex-direction: column; gap: 20px; min-height: 0; }
.msg-head { display: grid; gap: 18px; }
.msg-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.msg-tags:empty { display: none; }
.msg-subject { margin: 0; font-size: clamp(22px, 2.3vw, 31px); font-weight: 740; letter-spacing: -.03em; line-height: 1.12; word-break: break-word; }
.msg-from { display: flex; align-items: center; gap: 13px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.msg-from .av { --_s: 44px; border-radius: 13px; }
.msg-from-meta { min-width: 0; flex: 1; display: grid; gap: 2px; }
.msg-from-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
.msg-from-line strong { font-weight: 640; font-size: 15px; }
.msg-addr { color: var(--ink-3); font-size: 12px; border-radius: 5px; padding: 0 3px; transition: background var(--t), color var(--t); }
.msg-addr:hover { color: var(--ink); background: var(--bg-3); }
.msg-to { font-size: 13px; color: var(--ink-3); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-to b { color: var(--ink-2); font-weight: 540; }
.msg-date { display: grid; justify-items: end; gap: 2px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }

/* Verification code: digits in cells, dealt in one by one. */
.msg-code {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 18px 18px 18px 20px;
  border-radius: 16px;
  background: var(--bg-2);
  box-shadow: 0 0 0 1px var(--line-2) inset;
}
.msg-code .label { color: var(--accent-text); margin: 0 0 10px; }
.code-cells { display: flex; gap: 7px; }
.code-cells span {
  width: 40px; height: 50px; border-radius: 11px;
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 24px; color: var(--ink);
  background: var(--bg-3);
  box-shadow: 0 0 0 1px var(--line-2) inset, 0 1px 0 rgba(255, 244, 230, .04) inset;
}
.msg-code .btn { margin-left: auto; height: 40px; border-radius: 11px; padding: 0 16px; min-width: 128px; }
.btn.done { --_bg: var(--ok); --_fg: #0d1a12; }

#msg-body { min-height: 120px; }

/* --- Shortcuts sheet --------------------------------------------------- */
.sc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; }
.sc-grid .label { margin: 0 0 8px; color: var(--ink-2); }
.sc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.sc-row > span:last-child { display: flex; gap: 4px; flex: none; }
.sc-row em { font-style: normal; color: var(--ink-4); font-size: 11px; }
@media (max-width: 600px) { .sc-grid { grid-template-columns: 1fr; } }

.account-menu { min-width: 260px; }


/* --- Responsive -------------------------------------------------------- */
/* Collapsed rail: icon-only. Set by the toggle (remembered) or narrow screens. */
.app.rail-collapsed { grid-template-columns: 68px minmax(0, 1fr); }
.app.rail-collapsed .rail { padding: 12px 10px 8px; align-items: center; }
.app.rail-collapsed .rail .rail-hide { display: none !important; }
.app.rail-collapsed .rail-top { justify-content: center; padding: 0; }
.app.rail-collapsed .account { width: 46px; height: 46px; padding: 0; justify-content: center; }
.app.rail-collapsed .rail-copy { width: 46px; padding: 0; }
.app.rail-collapsed .folders { width: 100%; justify-items: center; }
.app.rail-collapsed .folder { width: 46px; justify-content: center; padding: 0; }
.app.rail-collapsed .folder .badge { position: absolute; top: 1px; right: -2px; min-width: 16px; height: 15px; font-size: 9.5px; padding: 0 4px; margin: 0; }
.app.rail-collapsed .folder .badge:not(.badge-accent) { display: none; }
.app.rail-collapsed .rail-foot { flex-direction: column; margin-top: auto; }
.app.rail-collapsed .rail-foot .spacer { display: none; }
.app.rail-collapsed .rail-top { flex-direction: column; height: auto; gap: 10px; }
.app.rail-collapsed .rail-full { display: none; }
.app.rail-collapsed .rail-mini { display: inline-flex; }
.app.rail-collapsed .folders > .label { display: none; }

/* ============================================================ Phones === */
/* The mailbox as an app: large title under a sticky bar, folders in a tab
   bar, the address on a floating button, the message pushed in from the
   right with its actions at the bottom, within reach of the thumb. */
.m-nav, .msg-top, .item-swipe { display: none; }

@media (max-width: 860px), (pointer: coarse) and (max-height: 520px) {
  :root { --dock: 56px; }
  html, body { overscroll-behavior: none; }
  body { overflow: hidden; }

  /* --- Sign in --- */
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-mark { display: inline-flex; margin-bottom: 18px; }
  .login-pane { padding: calc(32px + env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom)); }
  .login-theme { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
  .login-card { gap: 14px; }
  .login-card .display { font-size: 42px; }
  .login-card .input { height: 54px; border-radius: 15px; }
  .login-card .input-group > .ico { left: 16px; width: 18px; height: 18px; }
  .login-card .input-group > .input { padding-left: 46px; }
  .login-card .input-suffix { right: 6px; }
  .login-card .btn-lg { height: 56px; border-radius: 16px; font-size: 16.5px; margin-top: 8px; }
  .login-note { font-size: 13.5px; }

  /* --- Shell --- */
  .app { grid-template-columns: 1fr; padding: 0; }
  .rail, .rail-scrim { display: none !important; }
  .surface { display: block; position: relative; height: 100%; border-radius: 0; box-shadow: none; background: var(--bg); overflow: hidden; }
  .tabbar { display: flex; }
  .app.reading .tabbar, .app:has(.bulkbar:not([hidden])) .tabbar { transform: translateY(105%); }

  /* --- List: one scroller; the large title slides under a sticky bar --- */
  .list {
    display: block; height: 100%;
    overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain;
    border-right: 0;
    padding-bottom: calc(var(--dock) + 100px + env(safe-area-inset-bottom));
    transition: transform .5s var(--ease), opacity .5s var(--ease);
  }
  .app.reading .list { transform: translateX(-26%); opacity: .5; }

  .m-nav {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 4px;
    height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
    border-bottom: 1px solid transparent;
    transition: background .25s, border-color .25s;
  }
  .list.scrolled .m-nav, .list.picking .m-nav {
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-bottom-color: var(--line-2);
  }
  .m-nav-av { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
  .m-nav-av .av { --_s: 34px; border-radius: 50%; font-size: 14.5px; box-shadow: 0 0 0 1px var(--line-2); transition: transform .3s var(--ease-spring); }
  .m-nav-av:active .av { transform: scale(.9); }
  .m-nav-av .dot { position: absolute; margin: 26px 0 0 26px; width: 10px; height: 10px; box-shadow: 0 0 0 2px var(--bg); }
  .m-nav-title {
    position: absolute; left: 50%; bottom: 0; height: 52px;
    display: flex; align-items: center;
    max-width: calc(100% - 210px);
    transform: translateX(-50%);
    font-family: var(--f-display); font-stretch: 108%; font-weight: 700; font-size: 17px; letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    opacity: 0; transition: opacity .2s;
    pointer-events: none;
  }
  .list.scrolled .m-nav-title, .list.picking .m-nav-title { opacity: 1; }
  .m-nav-btn { height: 44px; padding: 0 12px; border-radius: 12px; color: var(--accent-text); font-size: 16px; font-weight: 600; white-space: nowrap; }
  .m-nav-btn:active { background: var(--bg-3); }
  .list.picking .m-nav-av { display: none; }
  .list.picking #m-select { font-weight: 700; }

  .list-head {
    padding: 0 max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    gap: 12px; border-bottom: 0;
    transition: opacity .25s;
  }
  .list-title-row { height: auto; gap: 10px; align-items: baseline; }
  .list-title-row h1 { font-size: 34px; letter-spacing: -.04em; line-height: 1.1; }
  #folder-total { font-size: 14px; }
  .list-menu, #refresh-btn, #list-more { display: none; }
  .search-field > .input { height: 42px; border-radius: 13px; background: var(--bg-2); border-color: transparent; padding-left: 40px; padding-right: 44px; }
  .search-field > .ico { left: 14px; width: 17px; height: 17px; }
  .search-field .search-clear { right: 3px; }
  .list-tools { padding-left: 0; gap: 8px; }
  .list-tools > .check, .list-tools > .spacer { display: none; }
  #filters { flex: 1; border-radius: 12px; }
  #filters button { flex: 1; justify-content: center; border-radius: 9px; }
  #filters > .ind { border-radius: 9px; }
  #empty-trash { height: 40px; }
  .list.picking .list-tools, .list.picking .search-field { opacity: .35; pointer-events: none; }

  /* --- Rows --- */
  .items { overflow: visible; flex: none; }
  .items > .plate { display: none; }
  .item {
    --_pad: 12px;
    grid-template-columns: 42px minmax(0, 1fr); gap: 13px;
    margin: 0; border-radius: 0;
    padding: var(--_pad) max(16px, env(safe-area-inset-right)) var(--_pad) max(22px, env(safe-area-inset-left));
    touch-action: pan-y;
  }
  .item:first-of-type { margin-top: 2px; }
  .item + .item::after { left: 77px; right: 0; }
  .item:active:not(.swiping) { background: var(--row-active); transition-duration: 0s; }
  .item-lead { width: 42px; height: 42px; margin-top: 1px; }
  .item-lead .av { --_s: 42px; border-radius: 13px; }
  .item-lead .check { width: 42px; height: 42px; opacity: 0; }
  .items.selecting .item-lead .check, .item.checked .item-lead .check { opacity: 1; transform: none; }
  .item:hover .item-lead .av { opacity: 1; transform: none; }
  .items.selecting .item-lead .av, .item.checked .item-lead .av { opacity: 0; transform: scale(.85); }
  .item.unread::before { left: 7px; top: calc(var(--_pad) + 18px); width: 8px; height: 8px; }
  .item-main { gap: 2px; }
  .item-from { font-size: 16px; }
  .item-time, .item:hover .item-time { font-size: 12.5px; opacity: 1; }
  .item-subject { font-size: 15px; }
  .item-snippet { font-size: 14px; }
  .item-star { width: 32px; height: 32px; margin: -6px -8px -6px -2px; }
  .item-star .ico { width: 16px; height: 16px; }
  .item-badges .otp { height: 28px; padding: 0 8px 0 10px; font-size: 13px; }
  .item-quick { display: none; }
  .list-foot { padding: 20px 16px; }
  .sk-item { grid-template-columns: 42px 1fr; padding: 12px 16px 12px 22px; gap: 13px; }
  .sk-item .sk.av-sk { width: 42px; height: 42px; border-radius: 13px; }

  .density-compact .item { --_pad: 8px; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; }
  .density-compact .item-lead, .density-compact .item-lead .check { width: 32px; height: 32px; }
  .density-compact .item-lead .av { --_s: 32px; border-radius: 10px; }
  .density-compact .item + .item::after { left: 66px; }
  .density-compact .item.unread::before { top: calc(var(--_pad) + 12px); }

  /* Swipe: right for the folder's main move, left to delete. */
  .item > .item-lead, .item > .item-main, .item.unread::before { transform: translateX(var(--sx, 0px)); }
  .item.settling > .item-lead, .item.settling > .item-main, .item.settling.unread::before, .item.settling > .item-swipe {
    transition: transform .4s var(--ease), width .4s var(--ease);
  }
  .item-swipe {
    display: block; position: absolute; top: 0; bottom: 0; z-index: -1;
    overflow: hidden; pointer-events: none;
    color: #fff; font-size: 13.5px; font-weight: 650;
  }
  .item-swipe > span { position: absolute; top: 50%; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; transform: translateY(-50%); }
  .item-swipe .ico { width: 22px; height: 22px; transition: transform .4s var(--ease-spring); }
  .item-swipe-r { left: 0; width: max(0px, var(--sx, 0px)); background: #2f7d55; }
  .item-swipe-r > span { left: 22px; }
  .item-swipe-l { right: 0; width: max(0px, calc(-1 * var(--sx, 0px))); background: #d23c41; }
  .item-swipe-l > span { right: 22px; }
  .item-swipe-r.restore { background: #3b6aa8; }
  .item.armed .item-swipe .ico { transform: scale(1.25); }
  .item:not(.armed) .item-swipe span span { opacity: .75; }

  /* --- Select mode: actions replace the tab bar --- */
  .bulkbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    height: auto; gap: 0;
    padding: 2px max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left));
    border-radius: 0;
    background: color-mix(in srgb, var(--bg-2) 90%, transparent);
    backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-top: 1px solid var(--line-2);
    box-shadow: none;
    overflow: visible;
    animation: dock-in .45s var(--ease);
  }
  @keyframes dock-in { from { transform: translateY(100%); } }
  .bulkbar > .bulk-count, .bulkbar > .spacer, .bulkbar > .icon-btn[data-bulk='clear'] { display: none; }
  .bulkbar .icon-btn, .msg-bar > .icon-btn {
    flex: 1 1 0; min-width: 0; width: auto; height: 56px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border-radius: 14px;
    font-size: 10.5px; font-weight: 600; color: var(--ink-2);
  }
  .bulkbar .icon-btn .ico, .msg-bar > .icon-btn .ico { width: 22px; height: 22px; transition: transform .4s var(--ease-spring); }
  .bulkbar .icon-btn:active .ico, .msg-bar > .icon-btn:active .ico { transform: scale(.85); }
  .bulkbar .icon-btn::after, .msg-bar > .icon-btn::after { content: attr(data-label); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bulkbar .icon-btn:disabled { opacity: .3; }

  /* --- Reader: pushed in from the right --- */
  .reader {
    position: fixed; inset: 0; z-index: 40;
    background: var(--bg);
    /* Parked past the edge by more than its shadow, so none of it shows. */
    transform: translateX(calc(100% + 80px));
    transition: transform .5s var(--ease);
    box-shadow: -24px 0 60px -24px rgba(0, 0, 0, .55);
  }
  .app.reading .reader { transform: none; }
  .reader.dragging, .list.dragging { transition: none; }
  .reader-empty { display: none; }
  .msg { position: relative; }
  .msg-top {
    display: flex; align-items: center; gap: 0; flex: none;
    height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(2px, env(safe-area-inset-left));
    border-bottom: 1px solid transparent;
    transition: border-color .25s;
  }
  .msg.scrolled .msg-top { border-bottom-color: var(--line-2); }
  .msg-top-back {
    display: inline-flex; align-items: center; gap: 0;
    height: 44px; padding: 0 12px 0 2px; max-width: 58%;
    border-radius: 12px;
    color: var(--accent-text); font-size: 16.5px; font-weight: 600;
  }
  .msg-top-back .ico { width: 28px; height: 28px; flex: none; stroke-width: 2; }
  .msg-top-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .msg-top-back:active { background: var(--bg-3); }
  #msg-top-pos { margin-right: 6px; font-family: var(--f-mono); font-size: 11.5px; }
  .msg-top .icon-btn .ico { width: 22px; height: 22px; }

  .msg-bar {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
    height: auto; gap: 0;
    padding: 2px max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-top: 1px solid var(--line-2); border-bottom: 0;
    overflow: visible;
  }
  .msg-bar > .msg-back, .msg-bar > .msg-close, .msg-bar > .msg-pos, .msg-bar > .msg-bar-sep, .msg-bar > .spacer,
  .msg-bar > [data-msg='prev'], .msg-bar > [data-msg='next'] { display: none; }
  .msg-bar > [data-msg='star'] { order: 1; }
  .msg-bar > [data-msg='unread'] { order: 2; }
  .msg-bar > [data-msg='archive'], .msg-bar > [data-msg='unarchive'], .msg-bar > [data-msg='notjunk'], .msg-bar > [data-msg='restore'] { order: 3; }
  .msg-bar > [data-msg='junk'] { order: 4; }
  .msg-bar > [data-msg='delete'] { order: 5; }
  .msg-bar > [data-msg='more'] { order: 6; }
  .msg-bar > [data-msg='star'].active { color: var(--warn); }

  .msg-scroll {
    padding: 4px max(18px, env(safe-area-inset-right)) calc(88px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    gap: 18px; overscroll-behavior-y: contain;
  }
  .msg-head { gap: 14px; }
  .msg-subject { font-size: 25px; line-height: 1.15; }
  .msg-from { flex-wrap: wrap; row-gap: 10px; padding-bottom: 16px; }
  .msg-from .av { --_s: 44px; }
  .msg-from-meta { flex-basis: calc(100% - 58px); }
  .msg-from-line strong { font-size: 16px; }
  .msg-from-meta { min-width: 0; }
  .msg-from-line { display: grid; gap: 1px; justify-items: start; }
  /* Long sender addresses truncate in the header; tap copies the full one. */
  .msg-addr { font-size: 12.5px; padding: 2px 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
  .msg-to { font-size: 13.5px; }
  .msg-date { order: 3; width: 100%; display: flex; justify-content: space-between; font-size: 13px; }
  .msg-code { padding: 16px; gap: 14px; border-radius: 18px; }
  .msg-code > div { flex: 1 1 100%; min-width: 0; }
  .code-cells { gap: 6px; }
  .code-cells span { flex: 1 1 0; width: auto; max-width: 46px; min-width: 0; height: 52px; font-size: 22px; }
  .msg-code .btn { margin-left: 0; width: 100%; height: 52px; border-radius: 15px; font-size: 16px; }
  .attachments { display: grid; }
  .attachment { max-width: none; padding: 10px 12px 10px 10px; border-radius: 14px; }
  .img-banner { border-radius: 14px; padding: 10px 10px 10px 14px; }
  .img-banner .btn { flex: 1; }
  .mail-frame-scroll, .mail-empty { border-radius: 16px; }
  .mail-text { font-size: 15.5px; }
}

/* Phones held sideways: the tab bar shrinks to icons. */
@media (pointer: coarse) and (max-height: 520px) {
  :root { --dock: 46px; }
  .tab { height: 46px; }
  .tab-label { display: none; }
  .list-title-row h1 { font-size: 28px; }
  /* Short screen: search and filters share one row; the address button stays compact. */
  .list-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 10px; }
  .list-head > .list-title-row { grid-column: 1 / -1; }
  .fab { padding: 0; width: 50px; height: 50px; justify-content: center; }
  .fab span { display: none; }
}

/* The rail never slides over the list any more; phones use the tab bar and account sheet. */
.rail-scrim { display: none; }

