/* BlurMailer — one stylesheet, mobile first. Loaded by the frame and the sign-in
   screen from /apps/blurmailer/public/mail.css (BlurPager D336's public/ folder).
   It sits on top of BlurPager's public/styles.css, so every rule that changes
   a button states background, colour, border AND radius together
   (BlurPager SKILLS.md, D143/D147). */

/* The brand is BlurPaper's teal, #00c6cf (docs/BRAND.md). White text on it
   is too faint to read (2:1), so a FILLED teal surface carries dark ink
   (--bm-on-brand, 7:1), and teal TEXT on the page uses a deeper teal of the
   same hue (--bm-accent, 4.6:1 on white). */
:root {
  --bm-bg: #ffffff;
  --bm-fg: #111827;
  --bm-muted: #6b7280;
  --bm-line: #e5e7eb;
  --bm-soft: #f3f4f6;
  --bm-brand: #00c6cf;
  --bm-on-brand: #00363a;
  --bm-accent: #00818a;
  --bm-danger: #b91c1c;
  --bm-unseen: #e6fafb;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bm-bg: #0b1214;
    --bm-fg: #e5e7eb;
    --bm-muted: #9ca3af;
    --bm-line: #1f2a2d;
    --bm-soft: #121c1f;
    --bm-accent: #3fd9e0;
    --bm-danger: #f87171;
    --bm-unseen: #0a2a2d;
  }
}

html, body { background: var(--bm-bg); color: var(--bm-fg); }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

.bm-app { min-height: 100dvh; display: flex; flex-direction: column; }
.bm-main { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding: 0 0 48px; box-sizing: border-box; }

/* The bar is the page's own colour with the teal logo on it, as BlurPaper's
   logo sits on white, and a teal rule under it. */
.bm-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--bm-bg); color: var(--bm-fg); border-bottom: 3px solid var(--bm-brand);
}
.bm-bar a { color: inherit; text-decoration: none; }
.bm-brand { display: flex; align-items: center; gap: 5px; height: 30px; min-width: 0; }
.bm-logo-mark { height: 30px; width: 30px; flex: none; }
.bm-logo-word { height: 30px; width: auto; aspect-ratio: 596 / 116; }
.bm-nav { display: flex; align-items: center; gap: 4px; flex: none; }
.bm-nav-write {
  padding: 6px 14px; border-radius: 999px; font-weight: 700;
  background: var(--bm-brand); color: var(--bm-on-brand) !important;
}
.bm-icon { display: flex; padding: 8px; border-radius: 999px; color: var(--bm-accent) !important; }
.bm-icon svg { width: 22px; height: 22px; }
.bm-icon:hover, .bm-icon:focus-visible { background: var(--bm-soft); }
/* A folded phone's outer screen is under 300 px wide: the mark stays, the word goes. */
@media (max-width: 340px) { .bm-logo-word { display: none; } }

h1 { font-size: 22px; margin: 16px 16px 4px; }
.bm-h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--bm-muted); margin: 24px 16px 8px; }
.bm-sub, .bm-meta { margin: 0 16px 4px; color: var(--bm-muted); font-size: 14px; overflow-wrap: anywhere; }
.bm-sync { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.bm-note { margin: 8px 16px; padding: 8px 12px; background: var(--bm-soft); border-radius: 8px; font-size: 14px; color: var(--bm-muted); }
.bm-empty, .bm-loading { padding: 24px 16px; color: var(--bm-muted); list-style: none; }

/* Accounts */
.bm-accounts { list-style: none; margin: 0; padding: 0; }
.bm-accounts a, .bm-account-row {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px;
  border-bottom: 1px solid var(--bm-line); color: inherit; text-decoration: none;
}
.bm-account-row { justify-content: space-between; }
.bm-acc-label { font-weight: 600; }
.bm-acc-email { color: var(--bm-muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.bm-badge {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center;
  background: var(--bm-brand); color: var(--bm-on-brand); font-size: 13px; font-weight: 700;
}

/* Folder tabs */
.bm-folders { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 12px; scrollbar-width: none; }
.bm-folders a {
  flex: none; padding: 6px 12px; border-radius: 999px; background: var(--bm-soft);
  color: inherit; text-decoration: none; font-size: 14px; white-space: nowrap;
}
.bm-folders a[aria-current="page"] { background: var(--bm-brand); color: var(--bm-on-brand); font-weight: 600; }

/* Message list */
.bm-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--bm-line); }
.bm-item a { display: block; padding: 10px 16px; border-bottom: 1px solid var(--bm-line); color: inherit; text-decoration: none; }
.bm-item.bm-unseen a { background: var(--bm-unseen); box-shadow: inset 3px 0 0 var(--bm-brand); }
.bm-item.bm-unseen .bm-from, .bm-item.bm-unseen .bm-subject { font-weight: 700; }
.bm-item-top, .bm-item-bottom { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.bm-from, .bm-subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-item time { flex: none; color: var(--bm-muted); font-size: 13px; }
.bm-subject { color: var(--bm-muted); font-size: 15px; }
.bm-tag { flex: none; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bm-soft); color: var(--bm-muted); }
.bm-star { color: #f59e0b; }

/* One message */
.bm-back { margin: 12px 16px 0; font-size: 14px; }
.bm-back a { color: var(--bm-accent); text-decoration: none; }
.bm-message h1 { overflow-wrap: anywhere; }
.bm-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--bm-line); }
.bm-inline { display: inline; margin: 0; }
.bm-body { display: block; width: 100%; height: calc(100dvh - 120px); min-height: 360px; border: 0; background: #ffffff; }
.bm-text { margin: 0; padding: 12px 16px; white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.5 system-ui, sans-serif; }
.bm-attachments { list-style: none; margin: 0; padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 8px; }

/* Buttons and forms */
.bm-button, .bm-attachment, form button {
  display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--bm-line);
  background: var(--bm-soft); color: var(--bm-fg); font: inherit; font-size: 15px; text-decoration: none; cursor: pointer;
}
.bm-primary, form button.bm-primary { background: var(--bm-brand); color: var(--bm-on-brand); border: 1px solid var(--bm-brand); border-radius: 8px; font-weight: 700; }
.bm-small, form button.bm-small { padding: 3px 10px; font-size: 13px; background: transparent; color: var(--bm-muted); border: 1px solid var(--bm-line); border-radius: 8px; }
.bm-danger, form button.bm-danger { background: transparent; color: var(--bm-danger); border: 1px solid var(--bm-danger); border-radius: 8px; }
.bm-compose form, .bm-settings form:not(.bm-inline), .bm-login form { display: flex; flex-direction: column; gap: 12px; padding: 8px 16px; }
.bm-compose label, .bm-settings label, .bm-login label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--bm-muted); }
.bm-compose input, .bm-compose select, .bm-compose textarea,
.bm-settings input, .bm-login input {
  font: inherit; font-size: 16px; color: var(--bm-fg); background: var(--bm-bg);
  padding: 10px 12px; border: 1px solid var(--bm-line); border-radius: 8px;
}
.bm-compose textarea { min-height: 40dvh; resize: vertical; }
.bm-login { max-width: 420px; padding-top: 12vh; }
.bm-login-logo { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 0 16px 24px; }
.bm-login-logo .bm-logo-mark, .bm-login-logo .bm-logo-word { height: 44px; }
.bm-login-logo .bm-logo-mark { width: 44px; }
.bm-login-logo .bm-logo-word { display: block; }
.bm-welcome { padding: 32px 16px; text-align: center; }
.bm-settings p { margin: 8px 16px; }

/* Move to another folder */
.bm-move { display: inline-flex; gap: 6px; align-items: center; }
.bm-move select {
  font: inherit; font-size: 15px; color: var(--bm-fg); background: var(--bm-bg);
  padding: 7px 8px; border: 1px solid var(--bm-line); border-radius: 8px; max-width: 150px;
}

/* Attachments while writing */
.bm-files { display: flex; flex-direction: column; gap: 6px; }
.bm-file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bm-file-list:empty { display: none; }
.bm-file-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--bm-line); border-radius: 8px; overflow-wrap: anywhere; font-size: 14px;
}
.bm-file-list label { flex-direction: row !important; align-items: center; gap: 6px !important; color: var(--bm-fg) !important; }
.bm-file-list small, .bm-attachments small { color: var(--bm-muted); }
.bm-compose .bm-attach { align-self: flex-start; flex-direction: row; color: var(--bm-fg); font-size: 15px; }
.bm-compose output:empty { display: none; }
.bm-compose-actions { display: flex; gap: 8px; margin: 4px 0 0; }
.bm-compose .bm-meta { margin: 0; }

/* Search */
.bm-search-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
.bm-search-form input {
  flex: 1 1 180px; min-width: 0; font: inherit; font-size: 16px; color: var(--bm-fg); background: var(--bm-bg);
  padding: 10px 12px; border: 1px solid var(--bm-line); border-radius: 8px;
}
.bm-search-form select {
  font: inherit; font-size: 15px; color: var(--bm-fg); background: var(--bm-bg);
  padding: 9px 8px; border: 1px solid var(--bm-line); border-radius: 8px;
}
.bm-search .bm-sub { margin-bottom: 10px; }
