/* mailbrain — editorial × brutalist
   --------------------------------------------------------------- */
:root {
  --ink: #0e0d0b;
  --ink-2: #14120f;
  --surface: #181612;
  --surface-warm: #1d1a14;
  --rule: #2a2620;
  --rule-soft: #211e19;
  --paper: #f3eee5;
  --paper-2: #d7d0c3;
  --muted: #b0a89c;
  --muted-2: #7a7268;

  --urgent: #ff3b30;
  --urgent-ink: #2a0a08;
  --respond: #e7a86b;
  --respond-ink: #2a1a08;
  --read: #7ec7a4;
  --read-ink: #0c2218;
  --digest: #8b8478;

  --display: "Fraunces", "Times New Roman", serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --pad: 18px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  background:
    radial-gradient(1200px 600px at 0% -10%, rgba(231,168,107,0.06), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(126,199,164,0.04), transparent 60%),
    var(--ink);
  min-height: 100vh;
}
.hidden { display: none !important; }
.italic { font-style: italic; }

/* Masthead --------------------------------------------------------------- */
.masthead {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink) 85%, rgba(14,13,11,0.92));
  backdrop-filter: blur(8px);
}
.masthead-inner {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px var(--pad) 6px;
  max-width: 760px; margin: 0 auto;
}
.brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: -0.02em;
  font-variation-settings: "SOFT" 30, "WONK" 1, "opsz" 144;
  line-height: 1;
}
.brand-mark { display: inline; }
.brand-mark.italic {
  font-style: italic;
  font-weight: 500;
  color: var(--paper-2);
}
.brand-large { font-size: 48px; }
.masthead-meta { display: flex; align-items: center; gap: 12px; }
.dateline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ghostbtn {
  background: transparent;
  color: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 0;
  width: 32px; height: 32px;
  font-size: 16px;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}
.ghostbtn:hover { color: var(--paper); border-color: var(--paper-2); }

.tabs {
  display: flex; gap: 0;
  overflow-x: auto;
  padding: 6px var(--pad) 10px;
  max-width: 760px; margin: 0 auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 12px 6px 0;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.tab + .tab { padding-left: 12px; border-left: 1px solid var(--rule); }
.tab.active { color: var(--paper); }
.tab.active::after {
  content: "";
  position: absolute; left: 0; right: 12px; bottom: -1px;
  height: 2px; background: var(--paper);
}
.tab.active + .tab { /* the bordering line stays */ }
.tab .tab-label { display: block; line-height: 1.1; }
.tab .tab-sub {
  display: block;
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--muted-2);
  text-transform: none;
  font-weight: 400;
  margin-top: 1px;
}
.tab.active .tab-sub { color: var(--muted); }
.token-warn {
  display: inline-block;
  color: #f87171;
  font-size: 10px;
  font-weight: 700;
  margin-left: 3px;
  vertical-align: middle;
  line-height: 1;
}
.reconnect-btn {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #f87171;
  border: 1px solid #f87171;
  background: transparent;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.reconnect-btn:hover { background: rgba(248,113,113,0.1); }

.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; max-width: 760px; margin: 0 auto; }
.rule-thick {
  border-top: 2px solid var(--paper);
  max-width: calc(760px);
  margin: 0 auto;
}
@media (max-width: 760px) {
  .rule, .rule-thick { margin: 0; max-width: 100%; }
}

/* Feed ------------------------------------------------------------------- */
main {
  padding: 24px var(--pad) 120px;
  max-width: 760px;
  margin: 0 auto;
}

.section {
  margin-bottom: 40px;
}
.section-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.section-title {
  font-family: var(--display);
  font-variation-settings: "SOFT" 50, "opsz" 144, "WONK" 1;
  font-weight: 700;
  font-size: 34px;
  line-height: 0.95;
  letter-spacing: -0.025em;
  margin: 0;
}
.section-count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
  padding-bottom: 6px;
}
.section.urgent .section-title { color: var(--urgent); font-style: italic; }
.section.respond .section-title { color: var(--respond); }
.section.read .section-title { color: var(--read); font-weight: 500; }
.section.digest .section-title,
.section.payment .section-title,
.section.parcel .section-title { color: var(--paper-2); font-weight: 500; }

.empty {
  font-family: var(--display);
  font-style: italic;
  color: var(--muted);
  padding: 14px 0 4px;
  font-size: 16px;
}

/* Cards: each section has its own visual register ------------------------ */
.card { display: block; cursor: default; }
.card.swipeable {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  transition: transform 180ms ease, opacity 180ms ease;
  will-change: transform;
  touch-action: pan-y;
  overflow: hidden;
}
.card.swipeable.swiping { transition: none; }
.card-inner {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.cluster-count {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  background: var(--surface-warm);
  border: 1px solid var(--rule);
  padding: 1px 6px;
  margin-left: auto;
  color: var(--paper-2);
}
/* Refreshing indicator — top progress bar */
#refresh-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  height: 2px;
  background: var(--paper);
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
  pointer-events: none;
}
#refresh-bar.active {
  opacity: 1;
  animation: refresh-sweep 1.6s ease-in-out infinite;
}
@keyframes refresh-sweep {
  0%   { transform: scaleX(0);   opacity: 1; }
  70%  { transform: scaleX(0.8); opacity: 1; }
  100% { transform: scaleX(1);   opacity: 0; }
}

.card .meta-row {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.account-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted-2);
}
.account-chip .dot {
  width: 7px; height: 7px; display: inline-block; border-radius: 50%;
}

/* URGENT — alarm, oversized, monospaced detail */
.section.urgent .card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,59,48,0.07), rgba(255,59,48,0));
  border-left: 3px solid var(--urgent);
  padding: 0;
  margin-bottom: 12px;
}
.section.urgent .card-inner { padding: 16px 8px 18px 18px; }
.section.urgent .card::before {
  content: "URGENT";
  position: absolute;
  top: -8px; left: -3px;
  background: var(--urgent); color: var(--ink);
  font-family: var(--mono); font-weight: 600;
  font-size: 10px; letter-spacing: 0.18em;
  padding: 3px 8px 2px;
}
.section.urgent .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--urgent);
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(255,59,48,0.6);
  animation: pulse 1.8s infinite cubic-bezier(0.4, 0, 0.6, 1);
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,59,48,0.55); }
  70% { box-shadow: 0 0 0 14px rgba(255,59,48,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); }
}
.section.urgent .summary {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 8px 0 6px;
}
.section.urgent .submeta {
  font-family: var(--mono); font-size: 11px; color: var(--paper-2);
}

/* RESPOND — warm, italic display sender, conversational */
.section.respond .card {
  padding: 0;
  border-bottom: 1px solid var(--rule-soft);
}
.section.respond .card-inner { padding: 14px 8px 14px 0; }
.section.respond .summary {
  font-family: var(--body);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
  margin: 6px 0 4px;
}
.section.respond .from {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  color: var(--respond);
  font-size: 14px;
}
.section.respond .subject {
  font-family: var(--body);
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* READ — narrow column, generous leading, serif body */
.section.read .card {
  padding: 0;
  border-bottom: 1px dashed var(--rule);
}
.section.read .card-inner { padding: 14px 8px 14px 0; }
.section.read .summary {
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "opsz" 24, "WONK" 0;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.45;
  max-width: 52ch;
  margin: 4px 0 6px;
}
.section.read .submeta {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}

/* DIGEST — dense ledger, no card chrome */
.section .ledger {
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.section .row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule-soft);
  will-change: transform;
  touch-action: pan-y;
}
.section .row:last-child { border-bottom: none; }
.clear-section-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 8px 0;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.clear-section-btn:hover { color: var(--paper); border-color: var(--paper-2); }

/* Digest cleanup ----------------------------------------------------------- */
.section.digest .section-head { grid-template-columns: 1fr auto auto; }
.cleanup-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 10px;
  margin-bottom: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 120ms ease, border-color 120ms ease;
}
.cleanup-btn:hover { color: var(--paper); border-color: var(--paper-2); }
.cleanup-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 10px;
}
.cleanup-empty { padding: 14px 0; }
.cleanup-row .who { flex: 1; min-width: 0; }
.cleanup-unsub-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 120ms ease, border-color 120ms ease;
}
.cleanup-unsub-btn:hover:not(:disabled) { color: var(--urgent); border-color: var(--urgent); }
.cleanup-unsub-btn:disabled { cursor: default; opacity: 0.7; }
.cleanup-unsub-btn.done { color: var(--read); border-color: var(--rule-soft); }

/* Backfill indicator */
.backfill-indicator {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 0 4px;
}
.backfill-dots::after {
  content: "";
  animation: backfill-ellipsis 1.4s steps(4, end) infinite;
}
@keyframes backfill-ellipsis {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
  100% { content: ""; }
}
.unsub-pill {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 100, 90, 0.7);
}
.skel-row {
  height: 46px;
  background: linear-gradient(90deg, var(--surface-warm) 0%, var(--rule) 40%, var(--surface-warm) 80%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: 0;
}
@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.section .row .row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  cursor: pointer;
}
.section .row .what {
  color: var(--paper);
  font-family: var(--body);
  font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.section .row .sender {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.section .row .row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}
.section .row .count-pill {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}
.section .row .amount-pill {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}
.row-dismiss-btn {
  background: transparent;
  border: none;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  cursor: pointer;
  padding: 0;
  transition: color 120ms ease;
}
.row-dismiss-btn:hover { color: var(--paper); }
.payment-monthly-total {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  padding: 10px 0 4px;
  margin-top: 4px;
}
.empty + .payment-monthly-total { border-top: none; margin-top: 0; }

/* Generic "Mark read" affordance for non-digest sections */
.actions {
  display: flex; gap: 10px;
  margin-top: 8px;
  font-family: var(--mono);
}
.actions .linkbtn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}
.actions .linkbtn:hover { color: var(--paper); border-bottom-color: var(--paper); }

/* Parcels section -------------------------------------------------------- */
.parcel-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}
.tracking-status {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-ordered        { background: rgba(255,255,255,0.07); color: var(--paper-2); }
.status-in_transit     { background: rgba(59,130,246,0.18);  color: #7eb8f7; }
.status-out_for_delivery { background: rgba(245,158,11,0.2); color: #f8c76a; }
.status-delivered      { background: rgba(16,185,129,0.18);  color: #5fdfb0; }
.delivered-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
  white-space: nowrap;
}
.delivered-btn:hover { color: var(--muted-2); border-color: var(--muted-2); }

/* Login scrim ------------------------------------------------------------ */
.scrim {
  position: fixed; inset: 0;
  background: radial-gradient(1000px 600px at 50% 40%, rgba(231,168,107,0.08), rgba(14,13,11,0.96));
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 20;
}
.scrim-inner { max-width: 360px; text-align: left; }
.lede {
  font-family: var(--display);
  font-style: italic;
  font-size: 18px;
  color: var(--paper-2);
  margin: 14px 0 22px;
}
.btn {
  display: inline-block;
  background: var(--paper);
  color: var(--ink);
  padding: 12px 18px;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: 1px solid var(--paper);
  transition: background 120ms ease, transform 120ms ease;
}
.btn:hover { background: var(--paper-2); transform: translateY(-1px); }

/* Notification prompt --------------------------------------------------- */
.notifprompt {
  position: fixed; left: 12px; right: 12px; bottom: 12px;
  max-width: 560px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--urgent);
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  font-family: var(--body);
  font-size: 13px;
  z-index: 10;
}
.notifprompt-actions { display: flex; gap: 6px; }
.btn-mini {
  background: transparent;
  color: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn-mini-primary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}

/* Toast ------------------------------------------------------------------ */
.toast {
  position: fixed; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 6px 12px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.toast.show { opacity: 1; }
/* Inline section flash (replaces global toast for clear/dismiss actions) */
.section-flash {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 0 2px;
  opacity: 0;
  transition: opacity 200ms ease;
}
.section-flash.show { opacity: 1; }

@media (max-width: 480px) {
  .brand { font-size: 26px; }
  .brand-large { font-size: 38px; }
  .section-title { font-size: 28px; }
  .section.urgent .summary { font-size: 20px; }
}

/* Desktop quadrants for Action view ≥ 1100px */
@media (min-width: 1100px) {
  .view-action {
    max-width: 1280px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "urgent   respond"
      "read     digest"
      "payment  payment";
    gap: 32px;
    padding: 28px 28px 120px;
  }
  .view-action .section { margin-bottom: 0; }
  .view-action .section.urgent  { grid-area: urgent; }
  .view-action .section.respond { grid-area: respond; }
  .view-action .section.read    { grid-area: read; }
  .view-action .section.digest  { grid-area: digest; }
  .view-action .section.payment { grid-area: payment; }
  /* slightly smaller titles to fit quadrant width */
  .view-action .section-title { font-size: 28px; }
}

/* View toggle (Action / All mail) --------------------------------------- */
.viewtabs {
  display: flex;
  gap: 0;
  padding: 12px var(--pad) 6px;
  max-width: 760px; margin: 0 auto;
}
.viewtab {
  font-family: var(--display);
  font-size: 24px;
  font-style: italic;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0 0 4px 0;
  margin-right: 22px;
  cursor: pointer;
  letter-spacing: -0.01em;
  position: relative;
  transition: color 120ms ease;
}
.viewtab.active { color: var(--paper); }
.viewtab.active::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--paper);
}
.view.hidden { display: none; }

/* All-mail view --------------------------------------------------------- */
.allmail-controls {
  position: sticky;
  top: 0;
  background: var(--ink);
  z-index: 2;
  padding: 8px var(--pad) 14px;
  max-width: 760px; margin: 0 auto;
}
.search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--paper);
  font-family: var(--body);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 120ms ease;
}
.search:focus { border-color: var(--paper-2); }
.catfilters {
  display: flex; flex-wrap: wrap; gap: 0;
  margin-top: 10px;
}
.catfilter {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-right: none;
  padding: 6px 10px;
  cursor: pointer;
}
.catfilter:last-child { border-right: 1px solid var(--rule); }
.catfilter.active {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}
.catfilter[data-cat="urgent"].active { background: var(--urgent); color: var(--ink); border-color: var(--urgent); }
.catfilter[data-cat="respond"].active { background: var(--respond); color: var(--ink); border-color: var(--respond); }
.catfilter[data-cat="read"].active { background: var(--read); color: var(--ink); border-color: var(--read); }

.allmail-list {
  max-width: 760px; margin: 0 auto;
  padding: 0 var(--pad);
}
.mailrow {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  transition: background 120ms ease;
}
.mailrow:hover { background: rgba(243,238,229,0.025); }
.mailrow .accdot {
  width: 8px; height: 8px; border-radius: 50%;
}
.mailrow .body { min-width: 0; }
.mailrow .from-line {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: flex; gap: 8px; align-items: baseline;
  text-transform: uppercase;
}
.mailrow .from-line .pill {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 1px 5px;
  color: var(--ink-2);
  background: var(--paper-2);
}
.mailrow .from-line .pill.urgent { background: var(--urgent); color: var(--ink); }
.mailrow .from-line .pill.respond { background: var(--respond); color: var(--ink); }
.mailrow .from-line .pill.read { background: var(--read); color: var(--ink); }
.mailrow .from-line .pill.digest { background: var(--rule); color: var(--paper-2); }
.mailrow .summary {
  font-family: var(--body);
  font-size: 15px;
  font-weight: 600;
  color: var(--paper);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mailrow .subject {
  font-family: var(--body);
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mailrow .when {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  align-self: start;
  text-transform: uppercase;
  padding-top: 2px;
  white-space: nowrap;
}
.mailrow.read .summary { font-weight: 500; color: var(--paper-2); }
.mailrow.read .subject { color: var(--muted-2); }
.mailrow-child {
  padding-left: 24px;
  background: rgba(243,238,229,0.015);
  border-bottom: 1px solid var(--rule-soft);
}
.mailrow-child::before {
  content: "↳";
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 12px;
  margin-right: 6px;
}
.thread-toggle {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--paper-2);
  background: var(--surface-warm);
  padding: 1px 6px;
  cursor: pointer;
  border: 1px solid var(--rule);
}
.thread-toggle:hover { color: var(--paper); border-color: var(--paper-2); }
.thread-toggle.expanded { background: var(--paper-2); color: var(--ink); border-color: var(--paper-2); }
.loadmore {
  display: block;
  margin: 18px auto 0;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--paper-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 10px 18px;
  cursor: pointer;
}
.loadmore.hidden { display: none; }

/* Detail overlay -------------------------------------------------------- */
.detail {
  position: fixed; inset: 0;
  background: var(--ink);
  z-index: 30;
  overflow-y: auto;
}
.detail.hidden { display: none; }
.detail-bar {
  position: sticky; top: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 12px var(--pad);
  background: var(--ink);
  border-bottom: 1px solid var(--rule);
}
.detail-account {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.detail-body {
  max-width: 720px; margin: 0 auto;
  padding: 22px var(--pad) 80px;
}
.detail-body h1 {
  font-family: var(--display);
  font-variation-settings: "SOFT" 80, "opsz" 144, "WONK" 1;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 6px 0 4px;
  line-height: 1.1;
}
.detail-body .summary-line {
  font-family: var(--display);
  font-style: italic;
  font-size: 16px;
  color: var(--paper-2);
  margin: 0 0 16px;
}
.detail-body .meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.detail-body .meta .label { color: var(--muted-2); margin-right: 6px; }
.detail-body .content {
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--paper);
}
.detail-body .content iframe {
  width: 100%; border: none; background: var(--paper);
  min-height: 60vh;
}
.detail-body pre.plain {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--body);
  font-size: 15px;
}
.detail-body .unsub {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.detail-body .unsub a { color: var(--paper-2); }
.detail-actions {
  margin: 6px 0 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.urgent-sender-btn {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--urgent, #ef4444);
  border: 1px solid var(--urgent, #ef4444);
  background: transparent;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 120ms ease;
}
.urgent-sender-btn:hover:not(:disabled) { background: rgba(239,68,68,0.1); }
.urgent-sender-btn:disabled { cursor: default; opacity: 0.7; }
.urgent-sender-btn.done { color: var(--muted); border-color: var(--rule); }
.muted-sender-btn {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--rule);
  background: transparent;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 120ms ease;
}
.muted-sender-btn:hover:not(:disabled) { background: rgba(176,168,156,0.08); color: var(--muted-2); border-color: var(--muted-2); }
.muted-sender-btn:disabled { cursor: default; opacity: 0.7; }
.muted-sender-btn.done { color: var(--muted-2); border-color: var(--rule-soft); }

/* Thread analysis card */
.analysis {
  margin: 8px 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--muted);
  background: var(--surface);
}
.analysis.needs-reply { border-left-color: var(--respond); background: linear-gradient(180deg, rgba(231,168,107,0.08), transparent); }
.analysis.ok { border-left-color: var(--read); }
.analysis-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 6px;
}
.analysis.needs-reply .analysis-tag { color: var(--respond); }
.analysis.ok .analysis-tag { color: var(--read); }
.analysis-summary {
  font-family: var(--display);
  font-size: 17px;
  line-height: 1.4;
  margin: 4px 0 8px;
}
.analysis-q, .analysis-action {
  font-family: var(--body);
  font-size: 14px;
  margin: 4px 0;
  color: var(--paper);
}
.analysis-q .lbl, .analysis-action .lbl {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  background: var(--surface-warm);
  padding: 1px 6px;
  margin-right: 8px;
}

/* Thread messages within detail */
.thread-msg {
  border-top: 1px solid var(--rule);
  padding: 10px 0;
}
.thread-msg > summary {
  list-style: none;
  cursor: pointer;
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0;
}
.thread-msg > summary::-webkit-details-marker { display: none; }
.thread-msg .tm-from { font-family: var(--display); font-style: italic; font-weight: 500; font-size: 15px; }
.thread-msg .tm-date { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.thread-msg[open] > summary { border-bottom: 1px solid var(--rule-soft); }
.thread-msg .content { padding-top: 8px; }

/* Account drawer -------------------------------------------------------- */
.drawer {
  position: fixed; inset: 0;
  z-index: 25;
}
.drawer.hidden { display: none; }
.drawer-scrim {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1;
}
.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 86%; max-width: 360px;
  background: var(--ink-2);
  border-left: 1px solid var(--rule);
  padding: 18px;
  display: flex; flex-direction: column;
  gap: 14px;
  box-shadow: -8px 0 24px rgba(0,0,0,0.4);
  z-index: 2;
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
}
.drawer-title {
  font-family: var(--display);
  font-variation-settings: "SOFT" 60, "WONK" 1, "opsz" 100;
  font-size: 22px;
  font-style: italic;
  font-weight: 600;
}
.drawer-list {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--rule);
}
.drawer-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.drawer-row .accdot {
  width: 9px; height: 9px; border-radius: 50%;
}
.drawer-row .who {
  flex: 1; min-width: 0;
  font-family: var(--body);
  font-size: 14px;
  color: var(--paper);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.drawer-row .who small { display: block; font-size: 10px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }
.drawer-row .disconnect {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 8px;
  cursor: pointer;
}
.drawer-row .disconnect:hover { color: var(--urgent); border-color: var(--urgent); }
.drawer-row .row-actions { display: flex; gap: 6px; align-items: center; }
.drawer-row .rename {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.drawer-row .rename:hover { color: var(--paper); border-color: var(--paper-2); }
.drawer-row .who-name { font-weight: 500; color: var(--paper); }
.btn-block { display: block; text-align: center; width: 100%; }
.drawer-foot { margin-top: auto; }
.linkbtn-quiet {
  color: var(--muted);
  font-size: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
}
.hint {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  margin: 6px 0 0;
}
.inline-quote {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-warm);
  color: var(--paper);
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}
.section.urgent .inline-quote { border-color: rgba(255,59,48,0.4); }
.section.respond .inline-quote { border-color: rgba(231,168,107,0.4); }
.linkbtn-quiet:hover { color: var(--urgent); }

/* Money view ------------------------------------------------------------- */
.view-money {
  padding: 24px var(--pad) 120px;
  max-width: 760px;
  margin: 0 auto;
}
.money-month {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.money-month-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper);
}
.money-month .ghostbtn:disabled { opacity: 0.3; cursor: default; }
.money-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  border-top: 2px solid var(--paper);
  padding-top: 12px;
}
.money-stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.money-stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.money-stat-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.money-pos { color: var(--read); }
.money-neg { color: var(--urgent); }
.money-int { color: var(--muted); }
.money-internal {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-top: 8px;
}
.money-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 16px 0 34px;
}
.money-bar-col {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.money-bar-track {
  width: 100%; height: 36px;
  display: flex; align-items: flex-end;
  border-bottom: 1px solid var(--rule);
}
.money-bar {
  width: 100%;
  min-height: 1px;
  background: var(--paper-2);
}
.money-bar-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted-2);
  text-transform: uppercase;
}
.view-money .section-title { font-size: 24px; color: var(--paper-2); font-weight: 500; }
.money-row .money-amount {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper-2);
  white-space: nowrap;
}
.price-up   { font-family: var(--mono); font-size: 11px; color: var(--respond); }
.price-down { font-family: var(--mono); font-size: 11px; color: var(--read); }
.sub-failed { font-family: var(--mono); font-size: 11px; color: var(--urgent); }
.merchant-bar {
  height: 2px;
  background: var(--rule);
  margin-top: 5px;
}
.transfer-arrow { font-family: var(--mono); }
.transfer-arrow.flow-in { color: var(--read); }
.transfer-arrow.flow-out { color: var(--muted); }
.transfer-arrow.flow-internal { color: var(--muted-2); }

@media (max-width: 480px) {
  .viewtab { font-size: 20px; margin-right: 16px; }
  .money-stat-value { font-size: 13px; }
}
