:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1b1f24;
    --muted: #667085;
    --border: #d9dde3;
    --accent: #1f6feb;
    --accent-text: #ffffff;
    --danger: #c62828;
    --radius: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1216;
        --surface: #181c22;
        --text: #e8eaed;
        --muted: #9aa3af;
        --border: #2a3039;
        --accent: #4c8dff;
        --accent-text: #0b0e12;
        --danger: #ff6b6b;
    }
}

* { box-sizing: border-box; }

/* Text scales with the screen: 16px on a desktop, about 14px on a phone, smoothly in between. Sizes elsewhere are in rem, so they follow. */
html { font-size: clamp(13.5px, 12px + 0.5vw, 16px); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    padding-bottom: env(safe-area-inset-bottom);
}

main { max-width: 720px; margin: 0 auto; padding: 16px; }
main.narrow { max-width: 400px; margin-top: 8vh; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

h1 { margin: 0 0 12px; font-size: 1.5rem; }
h2 { margin: 0 0 8px; font-size: 1.15rem; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); }
.center { text-align: center; }
code { word-break: break-all; }

form { display: flex; flex-direction: column; gap: 12px; }

input[type="text"], input[type="password"] {
    width: 100%;
    font: inherit;
    padding: 12px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

button {
    font: inherit;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    min-height: 44px;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; color: var(--accent); padding: 8px; min-height: 44px; }

input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 16px;
    padding-top: calc(4px + env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar form { display: block; }

.phases { padding-left: 1.2rem; margin: 0 0 8px; }
.phases li { margin-bottom: 4px; color: var(--muted); }
.phases li.done { color: var(--text); font-weight: 600; }

a { color: var(--accent); }

/* --- Phase 1 --- */
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 12px; text-decoration: none; color: var(--muted); min-height: 44px; }
.topbar nav a[aria-current="page"] { color: var(--text); font-weight: 600; }

a.button { display: inline-block; padding: 12px 16px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); text-decoration: none; min-height: 44px; }
a.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions form { display: block; }
.chip { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); vertical-align: middle; }
.notice { background: var(--surface); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; }
.bigcode { font-size: 1.6rem; letter-spacing: .15em; user-select: all; }

.searchbar { flex-direction: row; gap: 8px; margin-bottom: 12px; }
.searchbar input[type="search"] { flex: 1 1 14rem; min-width: 0; font: inherit; padding: 12px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
select { font: inherit; padding: 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; max-width: 40%; }

label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
label input { color: var(--text); }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 8px 12px; border: 1px solid var(--border); border-radius: 99px; text-decoration: none; color: var(--text); background: var(--surface); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

a.account-card { display: block; text-decoration: none; color: var(--text); }

ul.messages, ul.folders { list-style: none; margin: 0; padding: 0; }
ul.messages li { border-bottom: 1px solid var(--border); }
ul.messages a { display: flex; flex-direction: column; gap: 2px; padding: 12px 4px; text-decoration: none; color: var(--text); }
.row1 { display: flex; justify-content: space-between; gap: 8px; }
.from, .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread { font-weight: 700; }
.snippet, .meta { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }

ul.folders li { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); gap: 8px; }
ul.folders form { display: block; }

dl.headers { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: .9rem; }
dl.headers dt { color: var(--muted); }
dl.headers dd { margin: 0; overflow-wrap: anywhere; }
pre.body { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; border-top: 1px solid var(--border); padding-top: 12px; }
ul.attachments { padding-left: 1rem; }

/* --- Folder tree --- */
.layout { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.layout main { max-width: none; margin: 0; min-width: 0; padding: 16px 0; }  /* margin:0 so the grid item fills its column */
.tree { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 16px; padding: 4px 8px 8px; }
.tree > summary { cursor: pointer; padding: 10px 4px; font-weight: 600; min-height: 44px; list-style-position: inside; }
.tree-tools { display: flex; gap: 4px; justify-content: flex-end; }
.tree-tools button.link { padding: 4px 8px; min-height: 32px; font-size: .85rem; color: var(--muted); }

/* collapsible rows: <summary> holds a chevron (toggle target) and the folder link */
.tree details.acct, .tree details.branch { margin: 0; }
.tree details > summary { display: flex; align-items: center; list-style: none; cursor: pointer; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree .chev { flex: none; width: 32px; height: 40px; display: grid; place-items: center; color: var(--muted); border-radius: 8px; }
.tree .chev::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(-45deg); transition: transform .12s ease; }
.tree details[open] > summary > .chev::before { transform: rotate(45deg); }
.tree .chev:hover { background: var(--bg); }
.tree .children { margin-left: 15px; padding-left: 4px; border-left: 1px solid var(--border); }
.tree .children.root { margin-left: 0; border-left: 0; padding-left: 0; }
.tree details.acct { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 4px; }

.tree .node { display: flex; flex: 1; min-width: 0; justify-content: space-between; align-items: center; gap: 8px; text-decoration: none;
    color: var(--text); padding: 8px; border-radius: 8px; min-height: 40px; }
.tree .node.leaf { margin-left: 32px; }          /* line up with branch labels, which sit after the chevron */
.tree .node.all { margin-left: 0; }
.tree .node:hover { background: var(--bg); }
.tree .node[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.tree .node[aria-current="page"] .count { color: inherit; }
.tree .node.account { font-weight: 600; }
.tree .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .count { color: var(--muted); font-size: .85rem; flex: none; }
.tree .pad { padding: 4px 8px; margin: 0; }
.tree [hidden] { display: none !important; }   /* filtered-out rows (details/a set their own display) */
.tree-filter { width: 100%; font: inherit; padding: 10px 12px; margin: 4px 0; color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px; }
.tree-status { margin: 0 4px 4px; font-size: .85rem; }
p.scope { margin: 0 0 8px; }

@media (min-width: 900px) {
    .layout { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
    .tree { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
    .tree > summary { display: none; }
}

ol.steps { padding-left: 1.2rem; margin: 8px 0; }
ol.steps li { margin-bottom: 6px; }

/* --- Filters and message toolbar --- */
.searchbar { flex-wrap: wrap; align-items: stretch; }
.searchbar select { flex: none; max-width: 11rem; }
details.filters { flex: 1 0 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; }
details.filters > summary { cursor: pointer; padding: 10px 0; font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: 8px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.filter-grid input { width: 100%; font: inherit; padding: 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); min-height: 32px; font-size: 1rem; }
label.check input { width: 18px; height: 18px; }
details.filters .actions { padding-bottom: 12px; }
.star { color: #d89b00; }

.msgbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.nav-pair { display: flex; gap: 6px; }
a.button.disabled, span.button.disabled { opacity: .45; pointer-events: none; display: inline-block; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; }
.replybar { margin-bottom: 4px; }
.small { font-size: .8rem; margin: 4px 0 12px; }

/* --- Settings, tags, classification --- */
.settings .card { margin-bottom: 16px; scroll-margin-top: 12px; }
.settings textarea, textarea { width: 100%; font: .9rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; padding: 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
ul.plain { list-style: none; padding: 0; margin: 8px 0 12px; }
ul.plain li { padding: 3px 0; }
.inline-form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.inline-form label { flex: 1 1 14rem; }
.inline-form input[type="text"], .inline-form select, .age-grid input, .tag-row input[type="text"] { font: inherit; padding: 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; width: 100%; min-width: 0; }
.age-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.age-grid .actions { grid-column: 1 / -1; }
.tag-row { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tag-row input[type="text"] { flex: 1 1 10rem; width: auto; }
.tag-row input[type="color"] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.tag-row .count { min-width: 2rem; text-align: right; }
.notice.error { border-color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0; }
.chip.dest { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.chip.dest.review { border-color: #d89b00; }
.chip.important { background: var(--danger); color: #fff; }
.chip.tag { background: var(--tag, var(--accent)); color: #fff; border: 0; }
button.chip { min-height: 0; font: inherit; font-size: .8rem; padding: 4px 10px; cursor: pointer; }
.chip-form { display: inline-block; margin-right: 4px; }
.classbox, .tagbox { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 12px; }
.classbox p, .tagbox p { margin: 4px 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

ul.dest-tree, ul.dest-tree ul { list-style: none; margin: 0; padding: 0; }
ul.dest-tree ul { margin-left: 16px; border-left: 1px solid var(--border); padding-left: 6px; }
ul.dest-tree a { display: flex; justify-content: space-between; gap: 8px; padding: 10px 6px; min-height: 44px; align-items: center; text-decoration: none; color: var(--text); border-radius: 8px; }
ul.dest-tree a:hover { background: var(--bg); }
ul.dest-tree .count { color: var(--muted); font-size: .85rem; }

/* --- Settings tables --- */
.edit-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; }
.edit-table th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.edit-table td { padding: 4px 6px; vertical-align: middle; }
.edit-table input[type="text"] { width: 100%; font: inherit; padding: 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.edit-table tbody tr, .edit-table tfoot tr { border-top: 1px solid var(--border); }
.edit-table .narrow { width: 1%; white-space: nowrap; }
.edit-table .nowrap button { margin-left: 4px; }
.edit-table input[type="color"] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.edit-table button.link.danger { color: var(--danger); border: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
    .edit-table thead { display: none; }
    .edit-table tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 8px 0; }
    .edit-table td { display: block; padding: 0; }
    .edit-table td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); margin-bottom: 2px; }
    .edit-table td.narrow { width: auto; }
    .edit-table td:not(.narrow) { grid-column: 1 / -1; }
}


.review-tabs { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 12px; }
.review-tabs a { padding: 10px 4px; min-height: 44px; text-decoration: none; color: var(--muted); }
.review-tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }
.review-sender { margin-bottom: 12px; }
.review-warnings { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 8px 0; }
.review-warnings li { font-size: .8rem; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--danger); color: var(--danger); }
.review-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 8px; }
.review-keep { display: flex; flex-direction: row; flex: 1 1 18rem; flex-wrap: wrap; align-items: stretch; gap: 8px; min-width: 0; }
.review-keep button { flex: 0 0 auto; width: auto; }
.review-keep input[type="text"] { flex: 1 1 10rem; min-width: 0; font: inherit; padding: 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.wrap-anywhere { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }

.classify-bar { padding: 10px 12px; margin-bottom: 12px; }
.classify-bar .inline-form { align-items: center; }
.classify-bar .inline-form label.grow { flex: 1 1 18rem; min-width: 16rem; }
.classify-bar select { width: 100%; font: inherit; padding: 10px; }
.classify-bar .notice { margin: 0 0 8px; }
.sugg-form { gap: 10px; }
.sugg-form input[type="text"] { font: inherit; padding: 10px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; width: 100%; }
.inline-form .grow { flex: 1 1 14rem; }

/* Reply page */
#reply-text { width: 100%; box-sizing: border-box; font: inherit; }
#reply-form label { display: block; margin-top: 12px; }
#reply-form input[type=text] { width: 100%; box-sizing: border-box; }
.preline { white-space: pre-line; }

/* Jarvis */
.jarvis-turn { margin-bottom: 12px; }
.jarvis-turn.user { border-top: 1px solid var(--border, #ddd); padding-top: 10px; }
.full-width { width: 100%; box-sizing: border-box; }
/* HTML email: a sandboxed frame, always on white because senders design for white, sized to its content by message.js */
iframe.mailframe { display: block; width: 100%; min-height: 160px; border: 0; border-top: 1px solid var(--border); margin-top: 8px; background: #fff; color-scheme: light; }
.viewbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 12px; }
.viewbar .small-button, .viewbar a.button.small-button { padding: 2px 12px; min-height: 0; font-size: inherit; border-radius: 99px; }
.viewbar { margin: 6px 0 0; }


/* ===================================================================== app layout (11/2026)
   Top bar: menu button + name + links (a side panel on phones) + mailbox picker on the right.
   Mail list: round initial, sender, date, subject, one line of text. Message: icons on top, sender folded, replies at the bottom. */
.icon { display: block; flex: none; }
.iconbtn { display: inline-grid; place-items: center; width: 44px; height: 44px; min-height: 0; padding: 0; border: 0; border-radius: 50%;
    background: none; color: var(--text); text-decoration: none; cursor: pointer; }
.iconbtn:hover { background: var(--bg); }
.iconbtn.on { color: var(--accent); }
.iconbtn.disabled { opacity: .3; pointer-events: none; }
.iconform { display: contents; }
.spacer { flex: 1; }

.topbar { gap: 4px; justify-content: flex-start; position: sticky; top: 0; z-index: 30; }
.topbar .brand { font-weight: 700; color: var(--text); text-decoration: none; margin-right: 8px; white-space: nowrap; }
.topbar nav { flex: 1; flex-wrap: wrap; align-items: center; }
.topbar nav .logout { margin-left: auto; }
.menu-btn, .drawer-head, .drawer-backdrop { display: none; }
.drawer-tree:empty { display: none; }

.acct-pick { position: relative; margin-left: auto; }
.acct-pick > summary { list-style: none; display: flex; align-items: center; gap: 4px; cursor: pointer; padding: 6px 10px; border: 1px solid var(--border);
    border-radius: 99px; max-width: 46vw; min-height: 36px; font-size: .9rem; }
.acct-pick > summary::-webkit-details-marker { display: none; }
.acct-pick > summary .icon { width: 16px; height: 16px; }
.acct-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; max-width: 90vw; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 6px; z-index: 40; }
.acct-menu a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--text); text-decoration: none; }
.acct-menu a:hover, .acct-menu a[aria-current] { background: var(--bg); }
.acct-menu a[aria-current] .acct-name { font-weight: 700; }
.acct-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 1.05rem;
    color: #fff; background: hsl(var(--hue, 210) 45% 48%); }
.acct-menu .avatar { width: 30px; height: 30px; font-size: .85rem; }

/* list */
ul.messages a { flex-direction: row; align-items: flex-start; gap: 12px; padding: 10px 4px; }
.rowtext { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.row1 time { flex: none; font-size: .8rem; }
.row1 time.unread { color: var(--text); }
.listinfo { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; margin: 4px 0; }
.check-mail { display: block; }
button.small-link { display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; min-height: 32px; font-size: .85rem; }
button.small-link .icon { width: 16px; height: 16px; }
.classify-bar { margin-bottom: 0; }
.classify-more > summary { cursor: pointer; padding: 4px 0; margin: 0; }
.classify-more form { margin-top: 8px; }
details.filters > summary { list-style: none; }
details.filters > summary::-webkit-details-marker { display: none; }
details.filters .filter-grid select { max-width: none; width: 100%; padding: 10px; }

/* message */
.msgbar { gap: 2px; flex-wrap: nowrap; margin-bottom: 8px; }
.card.msg h1 { font-size: 1.35rem; line-height: 1.3; margin-bottom: 6px; overflow-wrap: anywhere; }
.card.msg > .chips { margin: 0 0 10px; }
details.sender > summary { list-style: none; display: flex; gap: 12px; align-items: center; cursor: pointer; padding: 6px 0; }
details.sender > summary::-webkit-details-marker { display: none; }
.who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.who .row1 { align-items: baseline; }
.to-line { display: flex; align-items: center; gap: 2px; font-size: .85rem; min-width: 0; overflow: hidden; white-space: nowrap; }
.to-line .icon { width: 16px; height: 16px; transition: transform .12s ease; }
details.sender[open] .to-line .icon { transform: rotate(180deg); }
details.sender dl.headers { background: var(--bg); border-radius: 8px; padding: 8px 10px; margin: 4px 0 8px; }
ul.attachments { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
ul.attachments li { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.replybar { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.replybar .button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 99px; min-height: 40px; }
.replybar .icon { width: 18px; height: 18px; }
details.more { border-top: 1px solid var(--border); margin-top: 12px; }
details.more > summary { cursor: pointer; padding: 10px 0; color: var(--muted); }

/* ------------------------------------------------------------- phones */
@media (max-width: 640px) {
    main, .layout main { padding: 8px 12px; }
    .layout { padding: 0; }
    .card { padding: 12px; border-radius: 10px; margin-bottom: 12px; }
    button, a.button { padding: 8px 12px; min-height: 40px; }
    input[type="text"], input[type="password"], select, .searchbar input[type="search"] { padding: 9px 10px; }
    h1 { font-size: 1.3rem; }

    .topbar { padding: 2px 6px; padding-top: calc(2px + env(safe-area-inset-top)); }
    .menu-btn { display: inline-grid; }
    body.drawer-open .topbar { z-index: 70; }
    .topbar nav.drawer { position: fixed; inset: 0 auto 0 0; width: min(84vw, 330px); z-index: 60; background: var(--surface); flex-direction: column; flex-wrap: nowrap;
        align-items: stretch; gap: 0; padding: env(safe-area-inset-top) 0 16px; overflow-y: auto; transform: translateX(-102%); transition: transform .2s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,.25); visibility: hidden; }
    body.drawer-open .topbar nav.drawer { transform: none; visibility: visible; }
    .topbar nav.drawer > * { flex-shrink: 0; }
    body.drawer-open { overflow: hidden; }
    .drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 20px; border-bottom: 1px solid var(--border); }
    .topbar nav.drawer a { padding: 11px 20px; color: var(--text); border-radius: 0 99px 99px 0; margin-right: 10px; min-height: 0; }
    .topbar nav.drawer a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 700; }
    .topbar nav .logout { margin: 4px 0 0; padding: 0 10px; border-bottom: 1px solid var(--border); }
    .drawer-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
    .drawer-backdrop[hidden] { display: none; }
    .drawer-tree .tree { border: 0; margin: 0; padding: 4px 6px; background: none; }
    .drawer-tree .tree > summary { padding: 8px 12px; }
    .drawer-tree .tree .node { color: var(--text); }

    /* list: just the mail */
    .searchbar { gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }
    .searchbar input[type="search"] { border-radius: 99px; padding-left: 16px; }
    .search-go { display: none; }
    details.filters { flex: none; border: 0; padding: 0; background: none; }
    details.filters[open] { flex: 1 0 100%; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 10px; background: var(--surface); }
    details.filters > summary { min-height: 40px; padding: 0 8px; }
    details.filters:not([open]) .filters-label { display: none; }
    ul.messages .chips, ul.messages .meta { display: none; }
    ul.messages a { padding: 9px 2px; gap: 10px; }
    .from, .subject { font-size: .95rem; }
    .avatar { width: 36px; height: 36px; font-size: .95rem; }
    p.scope { font-size: .85rem; }

    /* message: full width, email edge to edge */
    .card.msg { border: 0; border-radius: 0; margin: 0 -12px; padding: 4px 12px 12px; }
    .card.msg h1 { font-size: 1.2rem; }
    iframe.mailframe { width: calc(100% + 24px); margin-left: -12px; margin-right: -12px; }
    .replybar .button { flex: 1 1 auto; justify-content: center; }
}

/* ===================================================================== compact phone view (from the user's Gmail comparison, 8/11) */
.card.msg h1 { font-weight: 500; }
.to-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
ul.attachments li.att { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; }
.att-open { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-decoration: none; color: var(--text); }
.att-open .icon { color: var(--muted); }
.att-text { display: flex; flex-direction: column; min-width: 0; }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); }
.att-meta { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
    /* One bar on top, like a phone mail app: the message's own back/Done/Delete/arrows bar replaces the app bar. */
    .page-message .topbar { display: none; }
    .page-message .msgbar { position: sticky; top: 0; z-index: 30; background: var(--surface); margin: -8px -12px 4px; padding: 2px 4px;
        padding-top: calc(2px + env(safe-area-inset-top)); border-bottom: 1px solid var(--border); }
    .page-message .card.msg h1 { font-size: 1.25rem; }
    .viewbar { font-size: .78rem; margin-top: 2px; }
    .att-type { display: none; }
    /* Replies stay on screen at the bottom while you read. */
    .replybar { position: sticky; bottom: 0; z-index: 20; flex-wrap: nowrap; gap: 6px; margin: 12px -12px 0; padding: 8px 12px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
    .replybar .button { flex: 1 1 auto; padding: 6px 10px; min-height: 38px; font-size: .9rem; white-space: nowrap; justify-content: center; }
    .replybar .button.reply-only { flex: 0 0 auto; font-size: 0; gap: 0; padding: 6px 14px; }
    .replybar .button.reply-only .icon { width: 20px; height: 20px; }
    .reply-note { display: none; }
}

/* ===================================================================== Move bar (8/11) */
.movebar { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 0; margin: 6px 0 4px; }
.move-line { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0; }
.move-line .chip.dest { font-size: .85rem; padding: 3px 10px; }
button.pill { min-height: 32px; padding: 4px 14px; border-radius: 99px; font-size: .9rem; }
.small-inline { font-size: .8rem; }
details.move-other > summary { cursor: pointer; color: var(--accent); font-size: .85rem; padding: 6px 0 2px; }
.move-form { gap: 8px; margin: 6px 0 4px; }
.move-form input[type="text"] { font: inherit; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }

/* Reply: editable To / Cc / Subject, and Send */
.compose-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.compose-fields .compose-from { margin: 0; }
.compose-fields input[type="text"] { padding: 9px 10px; }
.sendbar { align-items: center; margin: 8px 0 4px; }
.sendbar #reply-send { min-width: 120px; }

/* ===================================================================== Jarvis as a chat (8/11) */
.jarvis-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px 0 10px; position: sticky; top: 48px; background: var(--bg); z-index: 20; }
.jarvis-tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 6px; }
.jarvis-tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.count-pill { font-size: .75rem; min-width: 1.4em; padding: 0 6px; border-radius: 99px; background: var(--border); color: var(--text); text-align: center; }
.count-pill.due { background: var(--danger); color: #fff; }
.jarvis-panel[hidden] { display: none !important; }
.chat-log { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.bubble { max-width: 88%; padding: 9px 12px; border-radius: 16px; line-height: 1.45; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.bubble.jarvis-said { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.thinking { color: var(--muted); font-style: italic; }
a.cite { display: inline-grid; place-items: center; min-width: 1.35em; height: 1.35em; padding: 0 4px; margin: 0 1px; border-radius: 99px; font-size: .75rem;
    background: color-mix(in srgb, var(--accent) 15%, transparent); text-decoration: none; vertical-align: 1px; }
span.cite { display: inline-grid; place-items: center; min-width: 1.35em; height: 1.35em; border-radius: 99px; font-size: .72rem; background: var(--bg); border: 1px solid var(--border); }
.sources { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.source { font-size: .8rem; text-decoration: none; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-empty { padding: 12px 0; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest .pill { font-size: .85rem; text-align: left; }
.composer { flex-direction: row; gap: 8px; align-items: center; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); z-index: 15; }
.composer input[type="text"] { flex: 1; min-width: 0; font: inherit; padding: 11px 16px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.composer button { border-radius: 99px; padding: 0 18px; min-height: 42px; }
.clear-chat { justify-content: flex-end; }
.due-note { display: block; margin-bottom: 8px; text-decoration: none; border-color: var(--danger); }
.panel-h { font-size: 1rem; margin: 12px 0 6px; }
ul.brief-list { list-style: none; margin: 0; padding: 0; }
ul.brief-list li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
ul.brief-list .chip { flex: none; margin-top: 2px; }
.brief-item { display: flex; flex-direction: column; min-width: 0; text-decoration: none; color: var(--text); }
.brief-subject { overflow: hidden; text-overflow: ellipsis; }
.brief-meta { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reminder { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.reminder-actions { display: flex; gap: 4px; align-items: center; flex: none; }
@media (max-width: 640px) {
    .jarvis-tabs { top: 44px; margin: -8px -12px 8px; padding: 0 6px; }
    .composer { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
}

.source-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.source-row .source { flex: 1; min-width: 0; }
.reply-link { flex: none; font-size: .78rem; padding: 2px 10px; border: 1px solid var(--border); border-radius: 99px; text-decoration: none; }

details.trail { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; margin: 4px 0 8px; }
details.trail > summary { cursor: pointer; color: var(--muted); }
.trail-text { font-size: .85rem; color: var(--muted); max-height: 50vh; overflow: auto; margin-top: 6px; }

.danger-link { color: var(--danger) !important; }
.draft-chip { border-color: var(--accent); color: var(--accent); }

/* ===================================================================== selecting several emails (8/11) */
ul.messages li { position: relative; }
ul.messages input.pick { display: none; }
body.selecting ul.messages input.pick { display: block; position: absolute; left: 14px; top: 20px; width: 20px; height: 20px; margin: 0; z-index: 2; pointer-events: none; }
body.selecting ul.messages .avatar { visibility: hidden; }
ul.messages li.picked { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.avatar[data-select] { cursor: pointer; }
.listinfo-right { display: inline-flex; align-items: center; gap: 12px; }
.bulkbar { position: sticky; bottom: 0; z-index: 25; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,.12); padding: 6px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
.bulkbar[hidden] { display: none; }
.bulk-top { display: flex; align-items: center; gap: 8px; }
.bulk-top #bulk-count { flex: 1; font-weight: 600; }
.bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bulk-actions .pill { display: inline-flex; align-items: center; gap: 6px; }
.bulk-actions .icon { width: 18px; height: 18px; }
.bulk-move { display: flex; gap: 6px; }
.bulk-move[hidden] { display: none; }
.bulk-move input { flex: 1; min-width: 0; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.bulk-form { display: block; }
.undo-bulk { margin: 0 0 6px; }
@media (max-width: 640px) {
    .bulkbar { margin: 0 -12px; border-radius: 0; border-left: 0; border-right: 0; }
}

/* After Delete: one small line with Undo and Always delete (8/11) */
.deleted-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .85rem; padding: 4px 2px; margin-bottom: 6px; }
.deleted-bar[hidden] { display: none; }
button.small-pill { min-height: 28px; padding: 2px 12px; font-size: .82rem; border-radius: 99px; }

/* ===================================================================== Jarvis panel (8/11) */
.jarvis-btn { color: var(--accent); }
.topbar .jarvis-btn { margin-left: auto; }
.topbar .jarvis-btn + .acct-pick { margin-left: 4px; }
.jarvis-sheet { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: 0; width: min(640px, 100%); max-height: 82vh; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.25);
    padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
.jarvis-sheet[hidden], .sheet-backdrop[hidden] { display: none; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 75; }
.sheet-head { position: sticky; top: 0; background: var(--surface); display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.sheet-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--accent); }
.sheet-body { padding-top: 8px; }
.j-loading { padding: 18px 0; }
.j-summary { margin: 4px 0 8px; }
.j-asks, .j-deadline { margin: 4px 0; font-size: .92rem; }
.j-label { margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; }
.j-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.j-step { text-align: left; }
.j-refresh { display: block; margin-top: 8px; }
ul.j-list { list-style: none; padding: 0; margin: 0; }
ul.j-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.j-offers { display: flex; flex-direction: column; gap: 8px; }
.j-offer { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.j-offer span { flex: 1 1 14rem; font-size: .9rem; }
@media (max-width: 640px) {
    .jarvis-sheet { width: 100%; border-radius: 16px 16px 0 0; }
}

/* Jarvis suggestions on the Review page (8/11) */
.jarvis-review { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.jarvis-verdict { margin: 6px 0; font-size: .9rem; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); }
.jarvis-verdict.junk { border-color: var(--danger); }
.jarvis-verdict.keep { border-color: #2e7d32; }
