:root {
  --bg: #fff; --fg: #1d1d1f; --muted: #6b6b70; --line: #e4e4e7; --accent: #2b5fab;
  --hover: #f3f4f6; --current: #e8eefa; color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #18181b; --fg: #ececee; --muted: #a1a1aa; --line: #2e2e33; --accent: #8ab4f8;
          --hover: #232327; --current: #1f2a3d; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
       background: var(--bg); color: var(--fg); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.3rem; margin: .4rem 0 .8rem; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .5rem; }
button { font: inherit; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--accent);
         background: var(--accent); color: var(--bg); cursor: pointer; }
button.link { background: none; border: none; color: var(--accent); padding: .3rem; }
button:disabled { opacity: .5; }
code { font-size: .9em; }
.note { color: var(--muted); }
.small { font-size: .85rem; }
.muted { color: var(--muted); font-size: .9em; }
form.inline { display: inline; }

.top { display: flex; gap: .8rem; align-items: center; padding: .5rem .8rem;
       border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 1; }
.brand { font-weight: 650; color: var(--fg); }
.search { flex: 1; }
.search input { width: 100%; font: inherit; padding: .45rem .7rem; border-radius: 8px;
                border: 1px solid var(--line); background: var(--hover); color: var(--fg); }
.layout { display: flex; }
.sidebar { width: 240px; flex: none; border-right: 1px solid var(--line); min-height: calc(100vh - 50px);
           padding: .5rem 0; }
main { flex: 1; min-width: 0; padding: .5rem 1rem 2rem; }
main.narrow { max-width: 30rem; margin: 3rem auto; }
.menu { display: none; }

.folders { list-style: none; margin: 0; padding: 0; }
.folders a { display: flex; justify-content: space-between; padding: .3rem .9rem; color: var(--fg); }
.folders a:hover { background: var(--hover); }
.folders .current a { background: var(--current); font-weight: 600; }
.folders .count { color: var(--accent); font-size: .85em; font-weight: 600; }
.folders .depth-1 a { padding-left: 1.8rem; } .folders .depth-2 a { padding-left: 2.7rem; }
.folders .depth-3 a, .folders .depth-4 a { padding-left: 3.6rem; }
.folders .sep { border-top: 1px solid var(--line); margin-top: .5rem; padding-top: .5rem; }

.messages { list-style: none; margin: 0; padding: 0; }
.messages li { border-bottom: 1px solid var(--line); }
.messages a { display: grid; grid-template-columns: 1fr auto; gap: 0 .8rem; padding: .55rem .3rem;
              color: var(--fg); }
.messages a:hover { background: var(--hover); }
.messages .from, .messages .subject, .messages .snippet { overflow: hidden; text-overflow: ellipsis;
                                                          white-space: nowrap; }
.messages .date { color: var(--muted); font-size: .85em; }
.messages .subject, .messages .snippet { grid-column: 1 / 3; }
.messages .snippet { color: var(--muted); font-size: .9em; }
.messages .in { background: var(--hover); border-radius: 4px; padding: 0 .3rem; margin-right: .2rem; }
.messages .unread .from, .messages .unread .subject { font-weight: 650; }
.messages .flag { color: #d33; }
.messages.compact .current a { background: var(--current); }
.more { text-align: center; }

.mail .headers { display: grid; grid-template-columns: auto 1fr; gap: .1rem .8rem; margin: 0 0 .6rem;
                 font-size: .92em; }
.mail .headers dt { color: var(--muted); }
.mail .headers dd { margin: 0; overflow-wrap: anywhere; }
.attachments { list-style: none; padding: 0; margin: .4rem 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.attachments li { border: 1px solid var(--line); border-radius: 6px; padding: .25rem .6rem; }
.attachments .size { color: var(--muted); font-size: .85em; }
.actions { font-size: .9em; margin: .3rem 0; }
iframe.body { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.plain { padding-left: 1.2rem; }
.events li { margin: .2rem 0; }

@media (max-width: 760px) {
  .sidebar { display: none; }
  .menu { display: inline; }
  main { padding: .4rem .7rem 2rem; }
  body.folders-page .folders a { padding: .6rem .3rem; }
  iframe.body { height: 75vh; }
}
