/* EmeraldsMC Mail. Colours follow the emeraldsmc.com palette (obsidian + emerald + diamond). */
:root {
  --bg: #f5f3fa; --panel: #ffffff; --panel-2: #f1eef7; --raise: #ffffff; --line: #e7e2f0; --line-soft: #f0ecf6;
  --ink: #1a1524; --ink-soft: #3d3552; --mute: #736a88;
  --accent: #0b8a4c; --accent-ink: #ffffff; --accent-soft: #e2f6ea; --accent-line: #b9e8cd; --glow: #2ae58a;
  --diamond: #0d8fb0; --star: #e0a400;
  --danger: #c0362f; --danger-soft: #fdecea;
  --shadow-sm: 0 1px 2px rgba(26, 21, 36, .06);
  --shadow-md: 0 8px 24px -10px rgba(26, 21, 36, .22);
  --shadow-lg: 0 24px 60px -20px rgba(26, 21, 36, .35);
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --top: 60px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
/* Dark tokens: follow the device unless a light theme is forced, or when dark is forced (theme.js sets data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0710; --panel: #120e19; --panel-2: #1a1526; --raise: #1d1729; --line: #2a2238; --line-soft: #1f1a2b;
    --ink: #efebf7; --ink-soft: #bdb5d0; --mute: #8a809f;
    --accent: #2ae58a; --accent-ink: #052012; --accent-soft: rgba(42, 229, 138, .11); --accent-line: rgba(42, 229, 138, .32);
    --glow: #2ae58a; --diamond: #7fe9ff; --star: #ffc23a;
    --danger: #ff6a5e; --danger-soft: rgba(255, 106, 94, .12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, .7);
    --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, .85);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0710; --panel: #120e19; --panel-2: #1a1526; --raise: #1d1729; --line: #2a2238; --line-soft: #1f1a2b;
  --ink: #efebf7; --ink-soft: #bdb5d0; --mute: #8a809f;
  --accent: #2ae58a; --accent-ink: #052012; --accent-soft: rgba(42, 229, 138, .11); --accent-line: rgba(42, 229, 138, .32);
  --glow: #2ae58a; --diamond: #7fe9ff; --star: #ffc23a;
  --danger: #ff6a5e; --danger-soft: rgba(255, 106, 94, .12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, .7);
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, .85);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }
.muted { color: var(--mute); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.grow { flex: 1; }
:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; }
::selection { background: rgba(42, 229, 138, .3); }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--line); background: var(--raise); color: var(--ink);
  border-radius: 999px; padding: 8px 16px; min-height: 40px; cursor: pointer; text-decoration: none;
  font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .1s, filter .15s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
  border-color: transparent; color: var(--accent-ink);
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--accent) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { width: 100%; min-height: 52px; font-size: 16px; margin-top: 22px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.danger-fill { background: var(--danger); color: #fff; border-color: transparent; box-shadow: none; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px;
  border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; flex: none;
  transition: background .15s, color .15s, transform .1s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn[aria-pressed="true"] { color: var(--star); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px 0; font-weight: 600; }

/* Selects get a custom chevron; data: images are allowed by the CSP. */
select#acct, select.chip, .row select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23887f9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 16px; background-position: right 10px center;
}
select#acct {
  border: 1px solid var(--line); background-color: var(--panel-2); border-radius: 999px;
  padding: 0 32px 0 14px; min-height: 38px; max-width: 240px; font-size: 14px; font-weight: 600; color: var(--ink-soft);
  text-overflow: ellipsis;
}
.chip {
  display: inline-flex; align-items: center; border: 1px solid var(--line); background-color: var(--raise); color: var(--ink-soft);
  border-radius: 999px; padding: 0 12px; min-height: 32px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
select.chip { padding-right: 30px; background-position: right 8px center; }
.chip:hover { border-color: var(--accent-line); color: var(--ink); }
.chip.danger { color: var(--danger); }
.chip.danger:hover { border-color: var(--danger); background-color: var(--danger-soft); }

/* ---------------------------------------------------------------- sign-in / setup gate */
.gate {
  min-height: 100%; display: grid; place-items: center; padding: max(24px, var(--sat)) 16px max(24px, var(--sab));
  background:
    radial-gradient(600px 400px at 50% -10%, rgba(42, 229, 138, .18), transparent 70%),
    radial-gradient(500px 360px at 100% 110%, rgba(127, 233, 255, .12), transparent 70%),
    var(--bg);
}
.gate-card {
  width: 100%; max-width: 390px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 24px; padding: 36px 26px 28px; text-align: center;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(42, 229, 138, .05);
  animation: rise .5s var(--ease) both;
}
.gate-logo { display: block; margin: 0 auto 16px; filter: drop-shadow(0 8px 20px rgba(42, 229, 138, .35)); }
.gate-card h1 { font-size: 24px; margin-bottom: 6px; font-weight: 800; }
.gate-card p { margin: 8px 0; }
.field { display: block; text-align: left; margin-top: 20px; }
.field span { display: block; font-size: 13px; color: var(--mute); margin-bottom: 6px; font-weight: 600; }
.field input { width: 100%; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: var(--bg); min-height: 46px; }
.field input:focus { border-color: var(--accent-line); outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---------------------------------------------------------------- top bar */
#app { height: 100%; display: flex; flex-direction: column; }
.top {
  height: var(--top); flex: none; display: flex; align-items: center; gap: 10px;
  padding: var(--sat) max(14px, var(--sar)) 0 max(14px, var(--sal));
  background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 25;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; padding-right: 4px; }
.brand img { filter: drop-shadow(0 3px 8px rgba(42, 229, 138, .3)); }
.search {
  flex: 1; min-width: 0; max-width: 560px; position: relative; display: flex; align-items: center;
}
.search svg { position: absolute; left: 13px; width: 18px; height: 18px; color: var(--mute); pointer-events: none; }
.search input {
  width: 100%; border: 1px solid transparent; background: var(--panel-2);
  border-radius: 999px; padding: 8px 16px 8px 40px; min-height: 40px; transition: background .15s, border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--mute); }
.search input:focus { outline: none; background: var(--raise); border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.top .compose { margin-left: auto; }

/* ---------------------------------------------------------------- panes */
.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 232px minmax(320px, 420px) 1fr; }

.folders { padding: 12px 10px; overflow-y: auto; background: var(--bg); }
.folders-head { display: none; }
.folders ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.folder {
  width: 100%; display: flex; align-items: center; gap: 12px; border: 0; background: none; cursor: pointer;
  padding: 0 12px; min-height: 42px; border-radius: 999px; text-align: left; color: var(--ink-soft); font-weight: 500;
  transition: background .15s, color .15s;
}
.folder:hover { background: var(--panel-2); color: var(--ink); }
.folder .ico { width: 22px; text-align: center; font-size: 17px; line-height: 1; flex: none; }
.folder.on { background: var(--accent-soft); color: var(--ink); font-weight: 700; }
.folder .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count {
  font-size: 12px; font-weight: 700; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: inline-grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}
.new-folder svg { width: 22px; }
.new-folder { display: flex; align-items: center; gap: 12px; margin: 10px 0 0; padding: 8px 12px; color: var(--mute); }
.new-folder:hover { color: var(--accent); }

.list {
  display: flex; flex-direction: column; min-height: 0; background: var(--panel);
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}
.list-head {
  display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 8px; border-bottom: 1px solid var(--line-soft);
  min-height: 58px; flex-wrap: wrap;
}
.list-head h2 { font-size: 20px; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk {
  display: flex; gap: 6px; flex-wrap: wrap; width: 100%; padding: 4px 0 2px 6px;
  animation: drop .18s var(--ease) both;
}
.chk { display: grid; place-items: center; width: 40px; height: 40px; flex: none; cursor: pointer; }
.chk input, .pick input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.search-note { padding: 8px 16px; font-size: 13px; color: var(--mute); border-bottom: 1px solid var(--line-soft); background: var(--panel-2); }

.msgs { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.msg {
  position: relative; display: flex; align-items: center; gap: 4px; margin: 0 6px; padding: 0 6px 0 4px;
  border-radius: var(--r); transition: background .12s;
}
.msg + .msg::before { content: ""; position: absolute; top: 0; left: 60px; right: 12px; border-top: 1px solid var(--line-soft); }
.msg:hover { background: var(--panel-2); }
.msg.on { background: var(--accent-soft); }
.msg.on::before, .msg.on + .msg::before, .msg:hover::before, .msg:hover + .msg::before { border-color: transparent; }
.msg.picked { background: var(--accent-soft); }

/* Avatar doubles as the row's checkbox: tap it to select. */
.pick { position: relative; display: grid; place-items: center; width: 48px; height: 64px; flex: none; cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick:focus-within .avatar { outline: 2px solid var(--glow); outline-offset: 2px; }
.pick .tick { display: none; }
.pick input:checked ~ .avatar { background: var(--accent); color: var(--accent-ink); }
.pick input:checked ~ .avatar .ini { display: none; }
.pick input:checked ~ .avatar .tick { display: block; }

.avatar {
  width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; flex: none;
  font-size: 15px; font-weight: 700; letter-spacing: .01em; color: #fff;
  background: var(--av, #6b5b95); transition: background .15s, transform .15s;
  text-transform: uppercase;
}
.pick:hover .avatar { transform: scale(1.05); }
.avatar .tick { width: 20px; height: 20px; stroke-width: 2.6; }
.av-0 { --av: linear-gradient(135deg, #12b76a, #0b7f46); }
.av-1 { --av: linear-gradient(135deg, #22b8cf, #0d7f9a); }
.av-2 { --av: linear-gradient(135deg, #8b6cf0, #5b3fc4); }
.av-3 { --av: linear-gradient(135deg, #f0789a, #c43d64); }
.av-4 { --av: linear-gradient(135deg, #f5a524, #c46b05); }
.av-5 { --av: linear-gradient(135deg, #5b8def, #2f5fc4); }
.av-6 { --av: linear-gradient(135deg, #8a7fa6, #5c5275); }
.av-7 { --av: linear-gradient(135deg, #2fbf9b, #138069); }

.msg-main { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 11px 4px 11px 2px; cursor: pointer; }
.msg-top { display: flex; gap: 6px; align-items: center; }
.msg-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-weight: 500; }
.msg-date { font-size: 12px; color: var(--mute); flex: none; font-variant-numeric: tabular-nums; }
.msg-subj { display: flex; align-items: center; gap: 5px; color: var(--mute); margin-top: 2px; font-size: 14px; min-width: 0; }
.msg-subj .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.msg-subj svg, .msg-top svg { width: 15px; height: 15px; }
.msg .flag { color: var(--star); }
.msg .flag svg { fill: currentColor; }
.msg .clip, .msg .replied { color: var(--mute); }
.msg.unread .msg-from { color: var(--ink); font-weight: 750; }
.msg.unread .msg-subj { color: var(--ink); font-weight: 600; }
.msg.unread .msg-date { color: var(--accent); font-weight: 700; }
.msg.unread .msg-from::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 99px; background: var(--accent);
  margin-right: 7px; vertical-align: 1px; box-shadow: 0 0 0 3px var(--accent-soft);
}
.empty { padding: 56px 16px; text-align: center; list-style: none; }
.empty svg { width: 40px; height: 40px; color: var(--line); stroke-width: 1.4; display: block; margin: 0 auto 10px; }
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px calc(8px + var(--sab)); border-top: 1px solid var(--line-soft);
}
.pager:empty { display: none; }
.pager .btn { min-height: 34px; padding: 4px 14px; font-size: 14px; }

/* ---------------------------------------------------------------- reader */
.reader { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.reader-empty { flex: 1; display: grid; place-items: center; text-align: center; }
.reader-empty svg { width: 56px; height: 56px; color: var(--line); stroke-width: 1.2; }
#msg { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; animation: fade .2s ease both; }
.reader-bar {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 2px;
  padding: 8px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.move-wrap { overflow: hidden; }
.move-wrap select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; font-size: 16px; }
.move-wrap:focus-within { outline: 2px solid var(--glow); outline-offset: 2px; }

.subject { font-size: 24px; font-weight: 800; padding: 22px 28px 14px; overflow-wrap: anywhere; letter-spacing: -.02em; }
.meta { display: flex; align-items: flex-start; gap: 12px; padding: 0 28px 16px; }
.meta .avatar { width: 42px; height: 42px; }
.meta .who { flex: 1; min-width: 0; }
.meta .who-line { overflow-wrap: anywhere; line-height: 1.35; }
.meta .from { font-weight: 700; }
.meta .addr { font-size: 13px; }
.meta .to { margin-top: 2px; overflow-wrap: anywhere; }
.meta .when { flex: none; padding-top: 2px; text-align: right; }
.images-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 28px 12px; padding: 10px 14px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; color: var(--ink-soft);
}
.images-bar svg { color: var(--mute); width: 18px; height: 18px; }
.images-bar span { flex: 1; min-width: 180px; }
.atts { list-style: none; margin: 0 28px 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.atts:empty { display: none; }
.atts li {
  display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 8px 12px; font-size: 14px; max-width: 100%;
}
.atts li svg { width: 16px; height: 16px; color: var(--mute); }
.att { color: var(--ink); text-decoration: none; font-weight: 600; overflow-wrap: anywhere; }
.att:hover { color: var(--accent); }
#m-body {
  flex: none; height: 200px; min-height: 200px; width: calc(100% - 40px); margin: 0 20px 12px;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; box-shadow: var(--shadow-sm);
}

/* Floating reply dock, pinned to the bottom of the reader. */
.reader-foot {
  position: sticky; bottom: 0; z-index: 3; margin-top: auto; display: flex; justify-content: center;
  padding: 10px 12px calc(14px + var(--sab)); pointer-events: none;
}
.reply-dock {
  pointer-events: auto; display: flex; gap: 4px; padding: 5px; border-radius: 999px;
  background: color-mix(in srgb, var(--raise) 90%, transparent); border: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.4) blur(16px); backdrop-filter: saturate(1.4) blur(16px);
  box-shadow: var(--shadow-md);
}
.dock-btn {
  display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--ink);
  border-radius: 999px; padding: 0 16px; min-height: 40px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.dock-btn svg { width: 18px; height: 18px; color: var(--accent); }
.dock-btn:hover { background: var(--panel-2); }
.dock-btn:active { transform: scale(.96); }
#reply-btn { background: var(--accent-soft); }

/* ---------------------------------------------------------------- sheets */
.sheet {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; background: var(--panel); color: var(--ink);
  width: min(720px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-shadow: var(--shadow-lg);
}
.sheet[open] { animation: pop .22s var(--ease) both; }
.sheet.narrow { width: min(460px, calc(100vw - 32px)); padding-bottom: 6px; }
.sheet::backdrop { background: rgba(5, 3, 8, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet form { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--line-soft); }
.sheet-head h2 { font-size: 17px; font-weight: 750; flex: 1; }
#compose .sheet-head { padding-left: 8px; }
.sheet h3 { font-size: 12px; padding: 18px 20px 0; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); }
.sheet .plain { list-style: none; padding: 6px 20px; margin: 0; }
.sheet .plain li { padding: 10px 12px; margin: 6px 0; border-radius: var(--r); background: var(--panel-2); }
.sheet .plain li strong { display: block; }
.sheet > p { padding: 0 20px; }
.send { min-height: 38px; padding: 6px 20px; }

.row { display: flex; align-items: center; gap: 10px; padding: 2px 20px; border-bottom: 1px solid var(--line-soft); min-height: 48px; }
.row > span, .row > label { width: 64px; flex: none; color: var(--mute); font-size: 14px; }
.row input, .row select { flex: 1; min-width: 0; border: 0; background-color: transparent; padding: 10px 0; outline-offset: 0; }
.row select { padding-right: 30px; background-position: right 2px center; }
.row input:focus, .row select:focus { outline: none; }
.row:focus-within { box-shadow: inset 2px 0 0 var(--accent); }
#c-body { flex: 1; min-height: 260px; border: 0; resize: vertical; padding: 16px 20px; background: transparent; line-height: 1.55; }
#c-body:focus { outline: none; }
#c-atts { margin: 0 20px 10px; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px calc(10px + var(--sab)); border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.sheet-foot .err { margin: 0; }
.attach { cursor: pointer; }

/* in-app confirm / prompt */
.sheet.ask { width: min(380px, calc(100vw - 32px)); padding: 22px 20px 16px; }
.ask p { margin: 0 0 14px; font-size: 16px; font-weight: 600; line-height: 1.4; padding: 0; }
.ask input { width: 100%; border: 1px solid var(--line); border-radius: var(--r); padding: 11px 14px; background: var(--bg); min-height: 46px; margin-bottom: 14px; }
.ask input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.ask-btns { display: flex; gap: 10px; justify-content: flex-end; }
.ask-btns .btn { min-width: 96px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); z-index: 60; max-width: calc(100vw - 32px); animation: toast .25s var(--ease) both;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 99px; background: var(--glow); flex: none; }
.toast.bad { background: var(--danger); color: #fff; }
.toast.bad::before { background: #fff; }

.only-narrow { display: none; }

@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes up { from { transform: translateY(100%); } }

/* ---------------------------------------------------------------- tablet: folders become a drawer */
@media (max-width: 1100px) {
  .panes { grid-template-columns: minmax(310px, 380px) 1fr; }
  .list { border-left: 0; }
  .folders {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(290px, 84vw); z-index: 40;
    padding: calc(14px + var(--sat)) 12px calc(14px + var(--sab)) max(12px, var(--sal));
    background: var(--panel); border-radius: 0 22px 22px 0;
    transform: translateX(-105%); visibility: hidden; box-shadow: var(--shadow-lg);
    transition: transform .28s var(--ease), visibility 0s linear .28s;
  }
  .folders-head { display: flex; align-items: center; gap: 10px; padding: 6px 12px 14px; font-weight: 800; font-size: 18px; }
  body.drawer .folders { transform: none; visibility: visible; transition: transform .28s var(--ease); }
  .only-narrow { display: inline-grid; }
  .scrim {
    position: fixed; inset: 0; background: rgba(5, 3, 8, .45); z-index: 35; display: block;
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  body.drawer .scrim { opacity: 1; pointer-events: auto; }
  .subject { padding: 18px 22px 12px; }
  .meta { padding: 0 22px 14px; }
  .images-bar, .atts { margin-left: 22px; margin-right: 22px; }
}

/* ---------------------------------------------------------------- phone: one pane at a time */
@media (max-width: 760px) {
  :root { --top: 112px; }
  body { font-size: 16px; }
  .top {
    flex-wrap: wrap; height: auto; min-height: var(--top); row-gap: 8px; column-gap: 4px;
    padding: calc(8px + var(--sat)) max(8px, var(--sar)) 10px max(8px, var(--sal));
    border-bottom: 0;
  }
  .brand span { display: none; }
  .brand { padding: 0 2px; }
  select#acct { flex: 1; min-width: 0; max-width: none; font-size: 15px; min-height: 40px; background-color: transparent; border-color: transparent; padding-left: 6px; }
  .search { order: 10; flex: 1 0 100%; max-width: none; padding: 0 4px; }
  .search svg { left: 17px; }
  .search input { min-height: 44px; font-size: 16px; }

  /* Compose becomes a floating button on the list screen. */
  .top .compose {
    position: fixed; right: max(18px, var(--sar)); bottom: calc(20px + var(--sab)); z-index: 20;
    width: auto; min-height: 56px; padding: 0 22px 0 18px; font-size: 16px; border-radius: 18px;
    box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--accent) 70%, transparent), var(--shadow-md);
  }
  .top .compose svg { width: 22px; height: 22px; }
  body[data-view="reader"] .top .compose, body.drawer .top .compose { display: none; }
  .toast { bottom: calc(92px + var(--sab)); }
  body[data-view="reader"] .toast { bottom: calc(84px + var(--sab)); }

  .panes { display: block; position: relative; }
  .list, .reader { position: absolute; inset: 0; border: 0; }
  .list { border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; }
  body[data-view="list"] .reader { display: none; }
  body[data-view="reader"] .list { display: none; }
  body[data-view="reader"] .reader { animation: slide .24s var(--ease) both; }
  body[data-view="reader"] .top { display: none; }
  body[data-view="reader"] .panes { position: fixed; inset: 0; }
  .reader-bar { padding: calc(6px + var(--sat)) max(6px, var(--sar)) 6px max(6px, var(--sal)); }
  .list-head { padding: 10px 8px 6px 4px; min-height: 56px; }
  .list-head h2 { font-size: 22px; }
  .msgs { padding-bottom: calc(90px + var(--sab)); }
  .msg { margin: 0 4px; }
  .pick { width: 52px; height: 70px; }
  .avatar { width: 42px; height: 42px; }
  .msg + .msg::before { left: 62px; }
  .pager { padding-bottom: calc(86px + var(--sab)); }

  .subject { font-size: 21px; padding: 14px 16px 12px; }
  .meta { padding: 0 16px 12px; }
  .meta { flex-wrap: wrap; row-gap: 2px; }
  .meta .when { order: 3; width: 100%; padding: 0 0 0 54px; text-align: left; }
  .atts, .images-bar { margin-left: 16px; margin-right: 16px; }
  #m-body { width: 100%; margin: 0; border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .reply-dock { width: 100%; max-width: 420px; justify-content: space-between; }
  .dock-btn { flex: 1; justify-content: center; padding: 0 10px; min-height: 46px; }

  .sheet { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .sheet[open] { animation: up .28s var(--ease) both; }
  .sheet form { max-height: 100dvh; height: 100%; }
  .sheet-head { padding-top: calc(10px + var(--sat)); }
  .sheet.narrow {
    width: 100vw; height: fit-content; margin: auto 0 0; border-radius: 22px 22px 0 0; padding-bottom: var(--sab);
  }
  .sheet.narrow .sheet-head { padding-top: 14px; }
  .sheet.narrow::before {
    content: ""; display: block; width: 38px; height: 5px; border-radius: 99px; background: var(--line); margin: 8px auto 0;
  }
  .sheet.ask { width: 100vw; padding: 0 18px calc(18px + var(--sab)); }
  .sheet.ask p { margin-top: 18px; }
  .ask-btns .btn { flex: 1; min-height: 48px; }
  .row { padding: 2px 16px; min-height: 52px; }
  .row > span, .row > label { width: 58px; }
  #c-body { padding: 14px 16px; }
}
@keyframes slide { from { opacity: .4; transform: translateX(24px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* appearance picker (Account sheet) */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 8px 20px 4px; padding: 4px; border-radius: 999px; background: var(--panel-2); }
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent;
  color: var(--ink-soft); border-radius: 999px; min-height: 38px; padding: 0 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button svg { width: 17px; height: 17px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--raise); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.seg button[aria-checked="true"] svg { color: var(--accent); }
.seg-note { padding: 0 20px; margin: 4px 0 0; }
