/* chudmail — self-hosted Inter, charcoal + white, layered dark surfaces.
   Class names are the contract with the templates; everything here is visual.
   Spacing follows an 8px scale (4/8/12/16/24/32) via the --s* tokens. */
@font-face {
  font-family: "Inter";
  src: url("../fonts/InterVariable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  /* 8px spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f3f6;
  --surface-3: #eaecf0;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #11131a;
  --text-2: #3d4351;
  --muted: #6b7280;
  --faint: #9ca3af;

  /* Primary: charcoal. White-on-charcoal for actions, off-white for tints. */
  --accent: #1c1e24;
  --accent-hover: #2e313a;
  --accent-text: #ffffff;
  --accent-soft: rgba(28, 30, 36, .055);
  --accent-soft-2: rgba(28, 30, 36, .09);
  --accent-line: rgba(28, 30, 36, .30);

  --danger: #c0262d;
  --danger-line: #f3b4b6;
  --danger-bg: #fdf1f1;
  --ok-bg: #eefaf1;
  --ok-line: #b7e4c3;
  --ok-text: #166534;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-xs: none;
  --shadow: none;
  --shadow-lg: none;

  /* The message body is always light: it is someone else's document. */
  --doc-bg: #ffffff;
  --doc-text: #1a1d24;
  --header-h: 56px;
}

/* Dark palette: deep neutral (not pure black), each layer a step lighter. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0c10;
    --surface: #12141a;
    --surface-2: #171a21;
    --surface-3: #1f232c;
    --line: #22262f;
    --line-strong: #313742;
    --text: #eef0f4;
    --text-2: #c3c8d2;
    --muted: #8b93a1;
    --faint: #666e7c;

    --accent: #e9eaee;
    --accent-hover: #ffffff;
    --accent-text: #0b0c10;
    --accent-soft: rgba(255, 255, 255, .055);
    --accent-soft-2: rgba(255, 255, 255, .095);
    --accent-line: rgba(237, 238, 242, .55);

    --danger: #f2727c;
    --danger-line: #4a1d22;
    --danger-bg: #241417;
    --ok-bg: #0f2017;
    --ok-line: #1d3d2a;
    --ok-text: #7ee2a0;

    --shadow-xs: none;
    --shadow: none;
    --shadow-lg: none;
  }
}
/* Explicit dark choice from the toggle. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c10;
  --surface: #12141a;
  --surface-2: #171a21;
  --surface-3: #1f232c;
  --line: #22262f;
  --line-strong: #313742;
  --text: #eef0f4;
  --text-2: #c3c8d2;
  --muted: #8b93a1;
  --faint: #666e7c;
  --accent: #e9eaee;
  --accent-hover: #ffffff;
  --accent-text: #0b0c10;
  --accent-soft: rgba(255, 255, 255, .055);
  --accent-soft-2: rgba(255, 255, 255, .095);
  --accent-line: rgba(237, 238, 242, .55);
  --danger: #f2727c;
  --danger-line: #4a1d22;
  --danger-bg: #241417;
  --ok-bg: #0f2017;
  --ok-line: #1d3d2a;
  --ok-text: #7ee2a0;
  --shadow-xs: none;
  --shadow: none;
  --shadow-lg: none;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01";   /* single-storey a, open digits */
  letter-spacing: -.006em;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1 { font-size: 1.25rem; font-weight: 650; letter-spacing: -.02em; margin: 0 0 var(--s3); }
h2 { font-size: .95rem; font-weight: 650; letter-spacing: -.01em; margin: var(--s6) 0 var(--s3); }
small, .small { font-size: .8125rem; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.warn { color: var(--muted); font-style: italic; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .875em; background: var(--surface-2); padding: .1em .35em;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
}
:where(a, button, input, select, textarea, tr, .folders li a):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: nowrap;
  padding: 0 var(--s5);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  height: var(--header-h);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-weight: 650; font-size: .95rem; letter-spacing: -.015em;
  margin-right: var(--s4); padding: var(--s1); border-radius: var(--radius-sm);
}
.brand:hover { color: var(--text); }
/* The logo is used exactly as supplied: no background chip, no recolouring. */
.brand-logo { display: block; flex: none; line-height: 0; }
.brand-logo img { width: 28px; height: 29px; object-fit: contain; display: block; }
.brand-name { white-space: nowrap; }

.main-nav { display: flex; align-items: center; gap: 2px; }
.main-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px;
  color: var(--muted); font-size: .875rem; font-weight: 500; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.main-nav a:hover { background: var(--surface-2); color: var(--text); }
.main-nav a.active {
  background: var(--accent-soft); color: var(--accent);
}
.main-nav a.active:hover { background: var(--accent-soft-2); }
.badge {
  display: inline-block; min-width: 20px; text-align: center;
  background: var(--accent); color: var(--accent-text);
  border-radius: 999px; padding: 0 6px;
  font-size: .6875rem; font-weight: 650; line-height: 18px;
  font-variant-numeric: tabular-nums;
}
.user-box {
  margin-left: auto; display: flex; align-items: center; gap: var(--s3);
  font-size: .875rem;
}
.user-box::before { content: ""; width: 1px; height: 20px; background: var(--line); order: -1; }
.user-menu { display: flex; align-items: center; gap: var(--s3); color: var(--muted); }
.user-menu a { color: var(--muted); transition: color .15s ease; }
.user-menu a:hover { color: var(--text); }
.user-menu .link-button { color: var(--muted); }
.user-menu .link-button:hover { color: var(--text); }
.user-menu .user-email {
  max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 4px 8px; border-radius: 6px; font-weight: 500;
}
.user-menu .user-email:hover { background: var(--surface-2); }
.compose-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: .85rem; font-weight: 600;
  border-radius: 8px;
}
.user-email { color: var(--muted); }

/* ---------- icons ---------- */
.icon { flex: none; vertical-align: -.18em; }
button .icon, .button .icon { margin-right: 0; }
button, .button, .main-nav a, .folders li a, .compose-link { line-height: 1.2; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: var(--s4); padding: var(--s4) var(--s5) var(--s5);
  align-items: start; width: 100%;
}
/* Only pages that render a sidebar block get a second column. */
.layout:has(> .folders) { grid-template-columns: 232px minmax(0, 1fr); }
.folders { position: sticky; top: calc(var(--header-h) + var(--s4)); padding: var(--s2) 0; }
.folders ul { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: 2px; }
.folders li a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--text-2);
  font-size: .875rem; font-weight: 500;
  transition: background .15s ease, color .15s ease;
  position: relative;
}
.folders li a .icon { color: var(--muted); transition: color .15s ease; }
.folders li a .label { flex: 1; }
.folders li a:hover { background: var(--surface-2); color: var(--text); }
.folders li a:hover .icon { color: var(--text-2); }
.folders li.active a {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.folders li.active a .icon { color: var(--accent); }
/* Accent bar on the active folder. */
.folders li.active a::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 3px; background: var(--accent);
}
.folders .count {
  color: var(--muted); font-size: .75rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 20px; text-align: right;
}
.folders li.active .count { color: var(--accent); }
/* Sidebar compose: the primary action, so it carries the accent. */
.compose-link {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  font-weight: 600; font-size: .875rem;
  padding: 10px var(--s4); border-radius: 9px;
  color: var(--accent-text); background: var(--accent);
  transition: background .15s ease, transform .1s ease;
}
.compose-link:hover {
  background: var(--accent-hover); color: var(--accent-text);
}
.compose-link:active { transform: translateY(1px); }
.content {
  min-width: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--s5);
  min-height: calc(100vh - var(--header-h) - 3rem);
}
.content.narrow { max-width: 460px; margin: var(--s6) auto; }

/* ---------- auth pages ---------- */
.auth { max-width: 380px; margin: 8vh auto 2rem; padding: 0 1rem; }
.auth-brand {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  text-decoration: none; font-weight: 650; font-size: 1.05rem; letter-spacing: -.01em;
}
.auth-brand img { width: 76px; height: 79px; object-fit: contain; }
.auth h1 { text-align: center; }
.auth-foot { text-align: center; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.4rem;
}

/* ---------- forms ---------- */
.form label { display: block; margin-bottom: var(--s4); font-size: .8125rem; font-weight: 600; color: var(--text-2); }
.form label > label, .form label > span.label { display: block; margin-bottom: .3rem; }
.form input[type=text], .form input[type=password], .form input[type=email],
.form input[type=search], .form textarea, .form select,
.search-form input[type=search] {
  display: block; width: 100%; padding: 8px 11px; font: inherit; font-size: .875rem;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px;
  transition: border-color .15s ease, background .15s ease;
}
.form input:hover, .form textarea:hover, .search-form input:hover { border-color: var(--line-strong); }
.form input:focus, .form textarea:focus, .search-form input:focus {
  outline: none; background: var(--surface);
  border-color: var(--accent);
}
input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.form textarea { resize: vertical; min-height: 16rem; line-height: 1.6; }
.form details { margin-bottom: var(--s4); }
.form details > summary { font-size: .8125rem; font-weight: 600; color: var(--muted); cursor: pointer; padding: 4px 0; }
.form details > summary:hover { color: var(--text); }
.form .muted.small { margin: -.4rem 0 .85rem; }
.input-suffix { display: flex; align-items: center; gap: 0; }
.input-suffix input { border-radius: 8px 0 0 8px !important; }
.input-suffix span {
  padding: .5rem .65rem; border: 1px solid var(--line-strong); border-left: 0;
  border-radius: 0 8px 8px 0; background: var(--bg); color: var(--muted); white-space: nowrap;
}
input[aria-label=Username] { min-width: 0; }
.checkbox { display: inline-flex !important; align-items: center; gap: .45rem; font-weight: 400; }
.inline { display: inline; }
.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }

/* ---------- buttons ---------- */
button, .button {
  font: inherit; font-size: .875rem; font-weight: 550; cursor: pointer;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  line-height: 1.35; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease,
              transform .1s ease;
}
button:hover, .button:hover {
  background: var(--surface-3); border-color: var(--line-strong); color: var(--text);
}
button:active, .button:active { transform: translateY(1px); }
.primary, button.primary {
  background: var(--accent); border-color: transparent; color: var(--accent-text);
}
.primary:hover, button.primary:hover { background: var(--accent-hover); color: var(--accent-text); }
.form > button[type=submit], .form .form-actions > button:first-child {
  background: var(--accent); border-color: transparent; color: var(--accent-text);
}
.form > button[type=submit]:hover, .form .form-actions > button:first-child:hover { background: var(--accent-hover); }
/* full-width submit only inside the auth cards */
.auth-card .form button[type=submit] { width: 100%; }
.danger, button.danger { color: var(--danger); border-color: var(--line); background: transparent; }
.danger:hover, button.danger:hover { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
.link-button {
  border: 0; background: none; padding: var(--s1); font-weight: 400; color: var(--muted);
  cursor: pointer; border-radius: 6px;
}
.link-button:hover { color: var(--text); background: var(--surface-2); }

/* ---------- flash ---------- */
.flash { list-style: none; margin: 0 0 1rem; padding: 0; }
.flash li {
  padding: .6rem .8rem; margin-bottom: .5rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); font-size: .875rem;
}
.flash-error { border-color: var(--danger-line) !important; background: var(--danger-bg) !important; color: var(--danger); }
.flash-success { border-color: var(--ok-line) !important; background: var(--ok-bg) !important; color: var(--ok-text); }
.flash-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; background: #fefce8 !important; }

/* ---------- list ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: .9rem; }
.toolbar .button { display: inline-flex; align-items: center; gap: .45rem; }
.search-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .9rem; }
.search-form input[type=search] { flex: 1 1 16rem; min-width: 10rem; width: auto; }
.search-form button { flex: none; }
.search-form .checkbox { flex: none; white-space: nowrap; }
.search-form input[type=search] { flex: 1; min-width: 12rem; width: auto; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .9rem; }
.bulk-bar button, .bulk-bar .button { padding: .38rem .75rem; font-size: .82rem; }
.bulk-bar label { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--muted); }
.bulk-bar select { padding: .34rem .5rem; font: inherit; font-size: .82rem; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); }

table.message-list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.message-list th {
  text-align: left; font-size: .75rem; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--muted); padding: .5rem .5rem;
  border-bottom: 1px solid var(--line);
}
table.message-list td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.message-list .subject { width: 32%; }
table.message-list .sender { width: 22%; }
table.message-list tbody tr:hover { background: var(--surface-2); }
table.message-list tr.unread .sender, table.message-list tr.unread .subject { font-weight: 650; }
table.message-list .subject a { text-decoration: none; }
table.message-list .subject a:hover { text-decoration: underline; }
table.message-list .preview { max-width: 0; width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
table.message-list .date { white-space: nowrap; color: var(--muted); font-size: .8125rem; }
.pager { display: flex; gap: 1rem; justify-content: space-between; margin-top: 1rem; font-size: .875rem; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

/* ---------- message ---------- */
.crumbs { margin: 0 0 .75rem; font-size: .875rem; }
.message h1 { font-size: 1.2rem; }
.headers { display: grid; grid-template-columns: 4.5rem 1fr; gap: .2rem .75rem; margin: 0 0 1rem; font-size: .875rem; }
.headers dt { color: var(--muted); }
.headers dd { margin: 0; word-break: break-word; }
.auth-results {
  font-size: .8125rem; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: .45rem .7rem; margin-bottom: 1rem;
}
iframe#message-frame { width: 100%; min-height: 240px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
pre.plain {
  white-space: pre-wrap; word-wrap: break-word; font: inherit;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: .85rem 1rem; margin: 0;
}
.attachments ul { list-style: none; padding: 0; margin: 0; }
.attachments li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.thread { margin-top: 1.5rem; }
.thread ul { list-style: none; padding: 0; }
.thread li { padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: .875rem; }
.thread li.current { font-weight: 650; }

/* ---------- settings / tables ---------- */
.kv { display: grid; grid-template-columns: 8rem 1fr; gap: .3rem .75rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
section + section { border-top: 1px solid var(--line); margin-top: 1.75rem; }
.status-accepted { color: var(--ok-text); font-weight: 600; }
.status-failed { color: var(--danger); font-weight: 600; }
.status-pending { color: #92400e; }
.blocked-content { font-style: italic; color: var(--muted); border: 1px dashed var(--line-strong); padding: 0 .3rem; border-radius: 4px; }
.draft-attachments { list-style: none; padding: 0; margin: 0 0 .6rem; }
fieldset.attach { border: 1px solid var(--line); border-radius: 8px; margin: 1rem 0; padding: .75rem 1rem; }
fieldset.attach legend { padding: 0 .4rem; font-size: .875rem; font-weight: 600; }
.form-actions { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; }

@media (max-width: 1200px) {
  .main-nav a span:not(.badge) { display: none; }      /* icon-only nav */
  .main-nav a { padding: 8px; }
  .user-menu .user-email { display: none; }
}
@media (max-width: 940px) {
  .layout { grid-template-columns: 1fr; }
  .folders { position: static; padding: 0; }
  .folders ul { display: flex; flex-wrap: wrap; gap: var(--s1); margin-bottom: var(--s2); }
  .folders li.active a::before { display: none; }
  .folders li a .label { display: inline; }
  .folders li a { padding: 6px 10px; }
  .compose-link { display: none; }
}
@media (max-width: 760px) {
  .site-header { padding: 0 var(--s4); }
  .layout { padding: var(--s2) var(--s3); }
  .content { padding: var(--s4); border-radius: var(--radius); }
  table.message-list .preview, table.message-list .col-date { display: none; }
  .brand-name { display: none; }
  .reader-head { padding: var(--s4); }
  .message-body { padding: var(--s3); }
  .reader-body .actions { padding: var(--s2) var(--s3); }
  .reader-subject { font-size: 1.2rem; }
}

/* ---------- landing ---------- */
.landing-header { border-bottom: 1px solid var(--line); }
.landing { max-width: 900px; margin: 0 auto; padding: 4rem 1.25rem 2rem; }
.hero { text-align: center; }
.hero-logo { width: 150px; height: 156px; object-fit: contain; }
.hero h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.4rem); line-height: 1.15; letter-spacing: -.02em;
  margin: 1.25rem auto .75rem; max-width: 22ch;
}
.hero h1 .accent { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 6px; }
.hero-lede { color: var(--muted); font-size: 1.05rem; max-width: 46ch; margin: 0 auto 1.75rem; }
.hero-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; align-items: center; }
.hero-actions .button { padding: .6rem 1.3rem; width: auto; }
.features {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem; margin: 3.5rem 0 0;
}
.feature {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem;
}
.feature h2 { margin: 0 0 .4rem; }
.feature p { margin: 0; color: var(--muted); font-size: .9rem; }
.landing-foot { display: flex; gap: .5rem; justify-content: center; margin-top: 3rem; }

/* ---------- theme toggle ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 0; background: none; padding: .4rem .5rem;
  font-size: .85rem; color: var(--muted); border-radius: 8px;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }

/* ---------- wide screens ---------- */
@media (min-width: 1600px) {
  /* Wide screens: only widen the gaps; the column count belongs to the
     sidebar rule above, or the list overflows on a single-column layout. */
  .layout { gap: var(--s5); }
}
/* Message reading: keep lines readable without shrinking the card. */
.message-body, .message .headers, .message h1 { max-width: 78ch; }

/* ---------- two-pane mail ---------- */
.content.split-content { padding: 0; overflow: hidden; min-height: 0; }
.mail-split {
  display: grid;
  grid-template-columns: var(--list-width, 420px) 9px minmax(0, 1fr);
  height: calc(100vh - var(--header-h) - 2.5rem);
  min-height: 480px;
}
.mail-split.is-stacked {
  grid-template-columns: minmax(0, 1fr);
  height: auto;
}
.mail-split.is-stacked .pane-resizer { display: none; }
.mail-split.is-stacked .pane-list { max-height: 45vh; }
.mail-split:not(.is-stacked) .pane-list { min-width: 0; }
.mail-split.is-stacked .pane-reader { min-height: 50vh; }

.pane { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.pane-list { padding: var(--s4) var(--s4) 0; background: var(--surface); }
.pane-reader { background: var(--bg); }
.pane-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); padding: 0 2px; }
.pane-title {
  margin: 0; flex: 1; font-size: 1.0625rem; font-weight: 650; letter-spacing: -.02em;
  display: flex; align-items: center; gap: var(--s2);
}
.pane-title .count-n {
  font-size: .75rem; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border-radius: 999px; padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.button.icon-only { padding: 7px; width: 32px; height: 32px; border-radius: 8px; }

/* drag handle: invisible until hovered, then a soft line */
.pane-resizer {
  cursor: col-resize; position: relative; background: transparent;
  border-left: 1px solid var(--line);
}
.pane-resizer::before {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 32px; border-radius: 2px; background: transparent;
  transition: background .15s ease;
}
.pane-resizer:hover::before, .pane-resizer:focus-visible::before,
.mail-split.is-resizing .pane-resizer::before { background: var(--line-strong); }
.pane-resizer:hover { border-left-color: transparent; }
.pane-resizer:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

/* list */
#message-rows {
  flex: 1; overflow-y: auto; overflow-x: hidden; margin: 0 -.2rem;
  scrollbar-gutter: stable; scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
#bulk-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
table.message-list { font-size: .875rem; }
table.message-list th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface);
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
}
table.message-list td { padding: 0; height: 66px; border: 0; }
table.message-list { table-layout: fixed; width: 100%; border-collapse: separate; border-spacing: 0; }
table.message-list .col-check, table.message-list .col-flags {
  width: 26px; white-space: nowrap; padding-left: 6px; padding-right: 0;
}
table.message-list .col-flags { width: 18px; }
table.message-list .col-date {
  width: 92px; white-space: nowrap; text-align: right;
  font-size: .75rem; font-variant-numeric: tabular-nums; color: var(--muted);
  padding-right: 8px;
}
/* Hidden entirely (not just display:none) so table-layout: fixed does not
   reserve a column for it. */
table.message-list .col-sender, table.message-list .sender {
  display: none; width: 0; padding: 0; border: 0;
}
table.message-list .subject { width: auto; padding: 10px 8px 10px 2px; }

/* Row = card-ish hover surface; the selected row carries a soft accent tint
   plus a left accent bar, the unread row a dot. */
table.message-list tbody tr { cursor: pointer; position: relative; }
table.message-list tbody tr td { transition: background .12s ease; }
table.message-list tbody tr:hover td { background: var(--surface-2); }
table.message-list tbody tr.selected td { background: var(--accent-soft); }
table.message-list tbody tr.selected:hover td { background: var(--accent-soft-2); }
table.message-list tbody tr.selected .subject a { color: var(--text); }
/* Selected-row marker: a real border (an inset shadow would read as a glow). */
table.message-list tbody tr.selected td.col-check {
  border-left: 2px solid var(--text); padding-left: 4px;
}

table.message-list .subject a {
  display: flex; align-items: center; gap: 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .875rem; font-weight: 500; color: var(--text);
  line-height: 1.35; margin-bottom: 2px;
}
table.message-list .subject a::before {
  content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%;
  background: transparent;
}
table.message-list tr.unread .subject a { font-weight: 650; }
table.message-list tr.unread .subject a::before { background: var(--accent); }
table.message-list .preview {
  display: block; color: var(--muted); font-size: .8125rem; font-weight: 400;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%; padding-left: 13px; letter-spacing: 0;
}
table.message-list .preview .who { color: var(--text-2); font-weight: 500; }
table.message-list tr.unread .preview .who { color: var(--text); }
.flag-star { color: #e8b13a; }
/* The empty message is hidden when rows exist. */
#message-rows .empty { display: none; }
#message-rows:has(.message-list) .empty { display: none; }
#message-rows:not(:has(.message-list)) .empty { display: block; }

.search-wrap {
  position: relative; flex: 1 1 12rem; display: flex; align-items: center; min-width: 0;
}
.search-wrap .icon { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search-wrap input[type=search] { padding-left: 32px; height: 34px; }
.search-form { margin-bottom: var(--s2); gap: var(--s2); }
.search-form .checkbox { font-size: .8125rem; color: var(--muted); }
/* Bulk actions: quiet icon buttons that gain an accent tint on hover. */
.bulk-bar { gap: 2px; margin-bottom: var(--s1); padding: 2px 0 var(--s2); }
.bulk-bar button {
  padding: 6px; width: 30px; height: 30px; border-radius: 7px;
  border-color: transparent; background: transparent; color: var(--muted);
}
.bulk-bar button:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.bulk-bar button.danger { color: var(--muted); }
.bulk-bar button.danger:hover { background: var(--danger-bg); color: var(--danger); }
.bulk-spacer { flex: 1; }

/* reader */
.pane-reader { overflow-y: auto; scroll-padding-top: var(--s4); }
.reader-empty[hidden] { display: none !important; }
.reader-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--faint); gap: var(--s3); padding: var(--s6) var(--s4); font-size: .875rem;
}
.reader-empty .icon { color: var(--faint); opacity: .7; }
.reader-empty p { margin: 0; }
.reader-body { padding: var(--s4); }
/* The message is one floating card: header, body, actions. */
.reader-body > .message {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.reader-head {
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--line);
}
.reader-subject {
  margin: 0 0 var(--s3); font-size: 1.375rem; font-weight: 650;
  letter-spacing: -.025em; line-height: 1.25; color: var(--text);
}
.reader-meta {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: var(--s2); font-size: .875rem;
}
.reader-meta strong { font-weight: 600; }
.reader-to { margin-top: var(--s1); }
.reader-body .message h1 { display: none; }
.message-body { padding: var(--s4) var(--s5); }
/* The body frame never scrolls on its own: it is always as tall as the reading
   pane, and the pane (plus the page header) is the scroll container. The body
   page's height reporter shrinks it for short messages when it can.
   The document itself is always light (see message_html): a sender's email is
   their document, and many hard-code dark text on white. */
.reader-body iframe#message-frame {
  display: block; width: 100%; min-height: 240px;
  height: max(240px, calc(100dvh - var(--header-h) - 18rem));
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--doc-bg);
}
.reader-body .actions {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  position: sticky; bottom: 0; z-index: 2;
  margin: 0; padding: var(--s3) var(--s5);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.reader-body .actions .button, .reader-body .actions button {
  display: inline-flex; align-items: center; gap: 6px; flex: none; white-space: nowrap;
  padding: 6px 10px; font-size: .8125rem;
  background: transparent; border-color: var(--line);
}
.reader-body .actions .button:hover, .reader-body .actions button:hover {
  background: var(--surface-2); border-color: var(--line-strong);
}
.reader-body .actions .button:first-child {
  background: var(--text); border-color: transparent; color: var(--bg);
  font-weight: 600;
}
.reader-body .actions .button:first-child:hover { background: var(--text); opacity: .88; color: var(--bg); }
.reader-body .actions button.danger:hover { background: var(--danger-bg); color: var(--danger); }
.plain-toggle { margin-top: var(--s2); font-size: .8125rem; color: var(--muted); }
.plain-toggle summary { cursor: pointer; width: fit-content; }
.plain-toggle summary:hover { color: var(--text); }
.attachments { padding: var(--s3) var(--s5) 0; }
.attachments h3 { margin: 0 0 var(--s2); font-weight: 600; }
.attachments li {
  display: flex; align-items: center; gap: var(--s2);
  padding: 6px 0; font-size: .875rem;
}

@media (max-width: 700px) {
  .mail-split { height: auto; }
  .mail-split .pane-list { max-height: 45vh; }
}

.pane-reader.has-message .reader-empty { display: none !important; }
/* With nothing open there is no reading pane to size against: let the list
   fill the window instead of leaving a large empty area beside it. */
.mail-split:not(.has-message):not(.is-stacked) { grid-template-columns: minmax(0, 1fr); }
.mail-split:not(.has-message) .pane-list { width: 100%; }
/* Rows stay readable when the list is wide rather than stretching text. */
.mail-split:not(.has-message) table.message-list { max-width: 760px; }
.mail-split:not(.has-message):not(.is-stacked) .pane-resizer,
.mail-split:not(.has-message):not(.is-stacked) .pane-reader { display: none; }
.mail-split:not(.has-message) #message-rows { margin: 0; }
