/* ============================================================================
   CYNOSURE MAIL — bespoke UI styles
   OLED-true-black design system. Dense, sharp, well-grouped.
   Hard constraint: base background is pure #000 (OLED pixels off).
   Accent: family theme-store driven. Security/auth signal uses a restrained semantic triad.

   The :root token block below MIRRORS the canonical shared theme at
   e:/cynos-mail/shared/theme/tokens.css (one roof — keep values in sync). The
   mail Worker's ASSETS binding serves only ./ui/, so these tokens are inlined
   here for a self-contained bundle rather than <link>-ed across directories.
   ========================================================================== */

/* ----------------------------------------------------------------------------
   Inter — VENDORED locally (upgrade-1934 / RDEC-12, Wave 2.1). The Google-Fonts
   <link> was removed from index.html so NO remote font is fetched on the first-
   paint path (the bundled app's cold-start black-screen root cause, and a render-
   blocking request in the browser). The variable woff2 (weights 100-900, latin
   subset; @fontsource-variable/inter) ships IN the bundle and is served from the
   app's own origin — no remote fetch, no cache-busting. font-display:swap keeps
   text visible during the (local) load; the --font-ui token stack still falls back
   to system fonts if the face is ever absent.
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/inter-latin-wght-normal.woff2') format('woff2');
}

:root {
  /* --- OLED black surfaces --- */
  --black: #000000;          /* app base — true black */
  --raise-1: #07090b;        /* hover / selected (barely-there lift) */
  --raise-2: #0b0e11;        /* compose fields, body card */
  --raise-3: #101418;        /* inputs, chips */

  /* --- hairlines --- */
  --line: rgba(255,255,255,0.075);
  --line-strong: rgba(255,255,255,0.14);
  --line-faint: rgba(255,255,255,0.045);

  /* --- type --- */
  --fg: #e9eef2;
  --fg-dim: #9aa6b2;
  --fg-faint: #5d6873;
  --fg-ghost: #3a434c;

  /* --- family accent (runtime values are applied by theme-store.js) --- */
  --accent: #22d3ee;
  --accent-bright: #5eeaff;
  --accent-dim: #0e7490;
  --accent-glow: rgba(34,211,238,0.16);
  --accent-wash: rgba(34,211,238,0.03);
  --accent-wash-subtle: rgba(34,211,238,0.025);
  --accent-border: rgba(34,211,238,0.30);
  --accent-ink: #00171c;     /* text/glyph on an --accent fill (was a 9x literal) */

  /* --- semantic security triad --- */
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --ok-bg: rgba(52,211,153,0.12);
  --warn-bg: rgba(251,191,36,0.12);
  --bad-bg: rgba(251,113,133,0.12);

  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --rail-w: 216px;
  --list-w: 384px;

  /* density-tunable rhythm */
  --row-py: 11px;
  --row-gap: 3px;
  --show-preview: block;
}

/* density: compact — tighter rows, hide the preview line */
body.density-compact {
  --row-py: 7px;
  --row-gap: 1px;
  --show-preview: none;
}

/* surface: pure — collapse the near-black raises toward true #000 */
body.surface-pure {
  --raise-1: #000000;
  --raise-2: #030405;
  --raise-3: #060809;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--black);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

::selection { background: var(--accent-glow); color: var(--accent-bright); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.09); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }

/* ============================================================================
   APP SHELL — 3 pane grid
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--list-w) 1fr;
  height: 100vh;
  width: 100vw;
}
.app.compose-mode { grid-template-columns: var(--rail-w) 1fr; }
.app.compose-mode .list-pane,
.app.compose-mode .read-pane { display: none; }

/* ============================================================================
   NAV RAIL
   ========================================================================== */
.rail {
  background: var(--black);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  /* left clearance reserves the top-left corner for the fixed universal
     brand-mark (16px offset + 28px box) that overlays the rail head; the
     bespoke "C" glyph was retired in favour of the one shared lodestar. */
  padding: 16px 16px 14px 60px;
  border-bottom: 1px solid var(--line-faint);
}
.brand .wordmark { font-size: 11px; letter-spacing: 0.18em; font-weight: 700; color: var(--fg); text-transform: uppercase; }
.brand .wordmark b { color: var(--accent); font-weight: 700; }

/* App-shell (native super-fullscreen) accommodation for the UNIVERSAL LOGO
   PLACEMENT LAW: the corner star slides to the 39/39 inset, so push the rail-head
   content ASIDE (right) to clear the star's right edge (operator: surrounding UI
   shifts to accommodate the star; the star never moves). Tracks the same inset +
   corner-radius clamp the mark uses. Scoped to the family shell only — desktop
   keeps its 60px gutter. */
.bw-family-shell .brand,
.blackwall-app-shell .brand {
  padding-left: calc(max(var(--bw-brand-mark-app-inset, 39px), calc(var(--bw-corner-tl, 0px) * 0.3)) + 36px);
}

.compose-btn {
  margin: 14px 12px 6px; padding: 10px 14px;
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 8px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 8px; justify-content: center;
  transition: filter .12s ease, box-shadow .12s ease;
  box-shadow: 0 0 18px -6px var(--accent-glow);
}
.compose-btn:hover { filter: brightness(1.08); box-shadow: 0 0 22px -4px var(--accent-glow); }
.compose-btn svg { width: 15px; height: 15px; }

.nav { padding: 8px 8px 4px; display: flex; flex-direction: column; gap: 1px; flex: 1; min-height: 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  color: var(--fg-dim); user-select: none; border: 1px solid transparent; position: relative;
}
.nav-item:hover { background: var(--raise-1); color: var(--fg); }
.nav-item.active { background: var(--raise-2); color: var(--fg); border-color: var(--line); }
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.nav-item .ico { width: 16px; height: 16px; flex: none; color: currentColor; opacity: .85; }
.nav-item.active .ico { color: var(--accent); opacity: 1; }
.nav-item.custom { margin-top: 4px; }
.nav-item.custom-child { padding-left: 28px; }
.nav-item .label { flex: 1; font-size: 13px; font-weight: 500; }
.nav-item .count { font-family: var(--font-mono); font-size: 11px; color: var(--fg-faint); font-weight: 600; }
.nav-item .badge {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
}

.rail-foot { border-top: 1px solid var(--line-faint); padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.foot-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 8px; border-radius: 7px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--fg-dim);
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
}
.foot-btn:hover { background: var(--raise-1); color: var(--fg); }
.foot-btn svg { width: 15px; height: 15px; flex: none; }
.acct { display: flex; align-items: center; gap: 9px; margin-top: 2px; }
.acct .av {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--raise-3); border: 1px solid var(--line-strong);
  display: grid; place-items: center; font-weight: 700; font-size: 11px; color: var(--accent);
}
.acct .who { min-width: 0; }
.acct .who .nm { font-size: 12px; font-weight: 600; color: var(--fg); }
.acct .who .em { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-row { display: flex; gap: 6px; }
.sec-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 600; padding: 3px 7px; border-radius: 5px;
  background: var(--ok-bg); color: var(--ok); border: 1px solid rgba(52,211,153,0.2);
  font-family: var(--font-ui); cursor: pointer; line-height: 1.4;
}
.sec-chip:hover { filter: brightness(1.12); }
.sec-chip svg { width: 11px; height: 11px; }
.sec-chip.lock { background: var(--raise-2); color: var(--fg-dim); border-color: var(--line); }
.sec-chip.off { background: var(--warn-bg); color: var(--warn); border-color: rgba(251,191,36,0.22); }

/* ============================================================================
   LIST PANE
   ========================================================================== */
.list-pane { background: var(--black); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.list-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.list-head .title { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.list-head .sub { font-family: var(--font-mono); font-size: 11px; color: var(--fg-faint); }
.list-head .spacer { flex: 1; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line);
  background: transparent; color: var(--fg-dim); cursor: pointer; display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--raise-1); color: var(--fg); border-color: var(--line-strong); }
.icon-btn.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.icon-btn svg { width: 15px; height: 15px; }

.search { margin: 10px 12px 8px; display: flex; align-items: center; gap: 8px; background: var(--raise-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.search svg { width: 14px; height: 14px; color: var(--fg-faint); flex: none; }
.search input { background: transparent; border: none; outline: none; color: var(--fg); font-family: var(--font-ui); font-size: 12.5px; width: 100%; }
.search input::placeholder { color: var(--fg-faint); }
.search .qx { background: none; border: none; color: var(--fg-faint); cursor: pointer; display: grid; place-items: center; padding: 0; }
.search .qx:hover { color: var(--fg); }
.search .qx svg { width: 13px; height: 13px; }

.filters { display: flex; gap: 6px; padding: 0 12px 8px; flex-wrap: wrap; }
.chip {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--fg-dim); font-family: var(--font-ui);
}
.chip:hover { background: var(--raise-1); color: var(--fg); border-color: var(--line-strong); }
.chip.on { background: var(--accent-glow); color: var(--accent-bright); border-color: var(--accent-dim); }

.bulk-bar {
  display: flex; align-items: center; gap: 6px; margin: 0 12px 8px;
  padding: 7px 8px 7px 12px; border-radius: 8px;
  background: var(--accent-glow); border: 1px solid var(--accent-dim);
}
.bulk-bar .bcount { font-size: 11.5px; font-weight: 700; color: var(--accent-bright); }
.bulk-bar .spacer { flex: 1; }
.bulk-report { position: relative; margin: 0 12px 8px; padding: 9px 34px 9px 11px; border-radius: 7px; border: 1px solid var(--line); background: var(--raise-1); color: var(--fg-dim); font-size: 11px; }
.bulk-report b { color: var(--fg); }
.bulk-report ul { margin: 6px 0 0; padding-left: 18px; font-family: var(--font-mono); color: var(--bad); }
.bulk-report > .qx { position: absolute; right: 8px; top: 8px; }
.mini-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 5px 9px; border-radius: 6px; cursor: pointer;
  background: transparent; border: 1px solid var(--line-strong); color: var(--fg-dim); font-family: var(--font-ui);
}
.mini-btn:hover { background: var(--raise-2); color: var(--fg); }
.mini-btn.good { color: var(--ok); border-color: rgba(52,211,153,0.3); }
.mini-btn.good:hover { background: var(--ok-bg); }
.mini-btn.danger { color: var(--bad); border-color: rgba(251,113,133,0.3); }
.mini-btn.danger:hover { background: var(--bad-bg); }
.mini-btn svg { width: 13px; height: 13px; }

.msg-list { flex: 1; overflow-y: auto; min-height: 0; }

.group-head {
  position: sticky; top: 0; z-index: 2;
  padding: 7px 16px 5px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg-faint); background: var(--black); border-bottom: 1px solid var(--line-faint);
}

.row {
  display: grid; grid-template-columns: 16px 1fr; gap: 10px;
  padding: var(--row-py) 16px var(--row-py) 12px;
  border-bottom: 1px solid var(--line-faint); cursor: pointer; position: relative;
}
.row:hover { background: var(--raise-1); }
.row.selected { background: var(--raise-2); }
.row.checked { background: var(--accent-glow); }
.row.selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.row .gutter { display: flex; flex-direction: column; align-items: center; padding-top: 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 7px var(--accent-glow); }
.dot.read { background: transparent; }
.cbox { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; color: var(--accent-ink); }
.cbox.on { background: var(--accent); border-color: var(--accent); }
.cbox svg { width: 11px; height: 11px; stroke-width: 3; }

.row .main { min-width: 0; }
.row .l1 { display: flex; align-items: baseline; gap: 8px; }
.row .from { font-size: 13px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.row.unread .from { font-weight: 700; }
.row .time { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-faint); flex: none; }
.row-star { border: 0; background: transparent; color: var(--fg-ghost); cursor: pointer; padding: 0 3px; font-size: 15px; line-height: 1; }
.row-star:hover, .row-star.on { color: var(--warn); }
.row-star.danger:hover { color: var(--bad); }
.row .l2 { display: flex; align-items: baseline; gap: 8px; margin-top: 1px; }
.row .subj { font-size: 12.5px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row:not(.unread) .subj { color: var(--fg-dim); }
.row .l3 { display: flex; align-items: center; gap: 8px; margin-top: var(--row-gap); }
.row .preview { display: var(--show-preview); font-size: 11.5px; color: var(--fg-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.row .indi { display: flex; align-items: center; gap: 6px; flex: none; margin-left: auto; }

.mini { display: inline-flex; align-items: center; gap: 3px; font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--fg-faint); }
.mini svg { width: 11px; height: 11px; }
.mini.bad { color: var(--bad); }

.threat-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; letter-spacing: .02em; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; }
.threat-tag.spoof { background: var(--bad-bg); color: var(--bad); }
.threat-tag.spam { background: var(--warn-bg); color: var(--warn); }
.threat-tag svg { width: 10px; height: 10px; }

.list-empty { padding: 40px 24px; text-align: center; color: var(--fg-faint); }
.list-empty svg { width: 30px; height: 30px; opacity: .5; margin-bottom: 10px; }
.list-empty .mini-btn { margin-top: 12px; }

.list-sentinel { padding: 14px; text-align: center; color: var(--fg-faint); font-size: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.list-sentinel .spin { display: inline-grid; place-items: center; animation: spin 1s linear infinite; }
.list-sentinel .spin svg { width: 14px; height: 14px; }
.list-end { padding: 14px; text-align: center; color: var(--fg-ghost); font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
   READ PANE
   ========================================================================== */
.read-pane { background: var(--black); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.read-empty { flex: 1; display: grid; place-items: center; color: var(--fg-ghost); text-align: center; }
.read-empty .ill { width: 56px; height: 56px; opacity: .35; margin-bottom: 14px; color: var(--fg-faint); }
.read-empty p { margin: 0; font-size: 13px; color: var(--fg-faint); }
.read-empty .hint { font-size: 11.5px; color: var(--fg-ghost); margin-top: 4px; }

.read-toolbar { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tbtn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 7px;
  border: 1px solid var(--line); background: transparent; color: var(--fg-dim);
  font-family: var(--font-ui); font-size: 12px; font-weight: 600; cursor: pointer;
}
.tbtn:hover { background: var(--raise-1); color: var(--fg); border-color: var(--line-strong); }
.tbtn svg { width: 14px; height: 14px; }
.tbtn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tbtn.primary:hover { filter: brightness(1.08); }
.tbtn.danger:hover { color: var(--bad); border-color: rgba(251,113,133,0.4); background: var(--bad-bg); }
.tbtn.good { color: var(--ok); border-color: rgba(52,211,153,0.3); }
.tbtn.good:hover { background: var(--ok-bg); }
.tbtn.back-btn { padding: 7px 9px; }
.tbtn.back-btn svg { width: 16px; height: 16px; }
.read-toolbar .back-btn { display: none; }     /* desktop: 3-pane, no back needed */
.tb-spacer { flex: 1; }

.read-scroll { flex: 1; overflow-y: auto; min-height: 0; }

/* conversation strip */
.convo { display: flex; align-items: center; gap: 10px; padding: 10px 24px; border-bottom: 1px solid var(--line-faint); background: linear-gradient(180deg, var(--accent-wash), transparent); flex-wrap: wrap; }
.convo .ci { width: 14px; height: 14px; color: var(--accent); flex: none; }
.convo-label { font-size: 11px; font-weight: 700; color: var(--fg-dim); letter-spacing: .02em; }
.convo-items { display: flex; gap: 6px; flex-wrap: wrap; }
.convo-item { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 16px; cursor: pointer; background: var(--raise-2); border: 1px solid var(--line); color: var(--fg-dim); font-family: var(--font-ui); font-size: 11px; }
.convo-item:hover { color: var(--fg); border-color: var(--line-strong); }
.convo-item.cur { border-color: var(--accent-dim); color: var(--accent-bright); background: var(--accent-glow); }
.convo-item .cdot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-faint); }
.convo-item .cdot.me { background: var(--accent); }
.convo-item .ctime { font-family: var(--font-mono); font-size: 10px; color: var(--fg-faint); }

.read-head { padding: 18px 24px 16px; border-bottom: 1px solid var(--line-faint); }
.read-subject { font-size: 19px; font-weight: 700; line-height: 1.3; margin: 0 0 14px; letter-spacing: -.01em; }
.read-from { display: flex; align-items: center; gap: 12px; }
.read-from .av { width: 38px; height: 38px; border-radius: 50%; background: var(--raise-3); border: 1px solid var(--line-strong); display: grid; place-items: center; font-weight: 700; font-size: 15px; color: var(--accent); flex: none; }
.read-from .meta { min-width: 0; flex: 1; }
.read-from .nm { font-size: 13.5px; font-weight: 700; color: var(--fg); }
.read-from .nm .addr { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; color: var(--fg-faint); margin-left: 6px; }
.read-from .to { font-size: 11.5px; color: var(--fg-faint); margin-top: 2px; }
.read-from .to b { color: var(--fg-dim); font-weight: 600; }
.read-date { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-faint); flex: none; text-align: right; }

.sec-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 24px; border-bottom: 1px solid var(--line-faint); background: linear-gradient(180deg, var(--accent-wash-subtle), transparent); }
.auth-badges { display: flex; gap: 6px; }
.auth { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 5px; text-transform: uppercase; letter-spacing: .03em; }
.auth.pass { background: var(--ok-bg); color: var(--ok); }
.auth.fail { background: var(--bad-bg); color: var(--bad); }
.auth.none { background: var(--raise-2); color: var(--fg-faint); }
.strip-spacer { flex: 1; }
.shield { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600; padding: 5px 11px; border-radius: 6px; background: var(--raise-2); border: 1px solid var(--line); color: var(--fg-dim); }
.shield svg { width: 13px; height: 13px; color: var(--accent); }
.shield b { color: var(--fg); font-weight: 700; font-family: var(--font-mono); }

.body-card { margin: 18px 24px 28px; background: var(--raise-1); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.body-frame-bar { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line-faint); font-family: var(--font-mono); font-size: 10px; color: var(--fg-ghost); letter-spacing: .04em; text-transform: uppercase; }
.body-frame-bar .lockico { width: 11px; height: 11px; color: var(--fg-faint); }
.email-body { padding: 22px 26px; color: #d7dee4; font-size: 13.5px; line-height: 1.62; background: var(--raise-1); }
.email-body p { margin: 0 0 13px; }
.email-body h1, .email-body h2, .email-body h3 { color: var(--fg); margin: 18px 0 10px; line-height: 1.3; }
.email-body h2 { font-size: 17px; }
.email-body a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-border); }
.email-body a:hover { border-bottom-color: var(--accent); }
.email-body hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.email-body .btn-cta { display: inline-block; padding: 9px 18px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; border-bottom: none; }
.email-body blockquote { margin: 0 0 13px; padding: 4px 0 4px 14px; border-left: 2px solid var(--line-strong); color: var(--fg-faint); }
.email-body .muted { color: var(--fg-faint); font-size: 12px; }
.email-body ul { margin: 0 0 13px; padding-left: 20px; }
.email-body li { margin: 4px 0; }

.attach-row { margin: 0 24px 24px; display: flex; gap: 10px; flex-wrap: wrap; }
.attach { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 8px; background: var(--raise-2); border: 1px solid var(--line); min-width: 260px; }
.attach-meta { flex: 1; min-width: 0; }
.attach .fi { width: 30px; height: 30px; border-radius: 6px; background: var(--raise-3); display: grid; place-items: center; color: var(--accent); }
.attach .fi svg { width: 15px; height: 15px; }
.attach .fnm { font-size: 12px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach .fsz { font-family: var(--font-mono); font-size: 10px; color: var(--fg-faint); }

.q-banner { margin: 16px 24px 0; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px; background: var(--warn-bg); border: 1px solid rgba(251,191,36,0.28); }
.q-banner .qi { width: 20px; height: 20px; color: var(--warn); flex: none; }
.q-banner .qtxt { flex: 1; font-size: 12px; color: #f2d99a; }
.q-banner .qtxt b { color: var(--warn); }

/* ============================================================================
   COMPOSE
   ========================================================================== */
.compose { display: flex; flex-direction: column; height: 100vh; min-height: 0; background: var(--black); }
.compose-head { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.compose-head .back-btn { display: inline-flex; }
.compose-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.compose-head .draft-state { font-family: var(--font-mono); font-size: 11px; color: var(--fg-faint); display: flex; align-items: center; gap: 6px; margin-left: auto; }
.compose-head .draft-state .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.compose-error { display: flex; align-items: center; gap: 8px; padding: 9px 24px; background: var(--bad-bg); border-bottom: 1px solid rgba(251,113,133,0.3); color: var(--bad); font-size: 12px; }
.compose-error svg { width: 14px; height: 14px; flex: none; }
.compose-body { flex: 1; overflow-y: auto; min-height: 0; padding: 8px 24px 24px; }
.cfield { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; border-bottom: 1px solid var(--line-faint); }
.cfield label { font-size: 11.5px; font-weight: 600; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .04em; }
.cfield input, .cfield select { background: transparent; border: none; outline: none; color: var(--fg); font-family: var(--font-ui); font-size: 13px; padding: 13px 4px; width: 100%; }
.cfield input::placeholder { color: var(--fg-ghost); }
.cfield .from-pick { display: flex; align-items: center; gap: 8px; }
.cfield select { cursor: pointer; }
.cfield select option { background: var(--raise-3); color: var(--fg); }
.cc-add { background: none; border: none; cursor: pointer; font-size: 11px; font-weight: 700; color: var(--fg-faint); font-family: var(--font-mono); padding: 4px 6px; }
.cc-add:hover { color: var(--accent); }
.cbody-wrap { padding-top: 12px; }
.cbody { width: 100%; min-height: 300px; resize: vertical; background: var(--raise-1); border: 1px solid var(--line); border-radius: 10px; color: var(--fg); font-family: var(--font-ui); font-size: 13.5px; line-height: 1.6; padding: 16px 18px; outline: none; }
.cbody:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent-dim); }
.compose-foot { display: flex; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); }
.compose-foot .limits { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-faint); }
.compose-foot .spacer { flex: 1; }
.compose-attachments { display: flex; flex-direction: column; gap: 7px; padding-top: 12px; }
.compose-attachment { display: grid; grid-template-columns: 16px minmax(100px, 1fr) auto 28px; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--raise-1); }
.compose-attachment > svg { width: 14px; height: 14px; color: var(--accent); }
.compose-attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.compose-attachment small { color: var(--fg-faint); font-family: var(--font-mono); }
.draft-state.error, .draft-state.error .pulse { color: var(--bad); }
.draft-state.error .pulse { background: var(--bad); }
.attach-btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 8px; cursor: pointer; background: transparent; border: 1px solid var(--line); color: var(--fg-dim); font-size: 12px; font-weight: 600; font-family: var(--font-ui); }
.attach-btn:hover { background: var(--raise-1); color: var(--fg); }
.send-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; border-radius: 8px; cursor: pointer; background: var(--accent); color: var(--accent-ink); border: none; font-size: 13px; font-weight: 800; font-family: var(--font-ui); box-shadow: 0 0 20px -6px var(--accent-glow); }
.send-btn:hover { filter: brightness(1.08); }
.send-btn:disabled { opacity: .55; cursor: default; filter: none; }
.send-btn svg { width: 15px; height: 15px; }
.ghost-btn { display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 8px; cursor: pointer; background: transparent; border: 1px solid var(--line); color: var(--fg-dim); font-size: 12.5px; font-weight: 600; font-family: var(--font-ui); }
.ghost-btn:hover { background: var(--raise-1); color: var(--fg); }
.ghost-btn:disabled { opacity: .55; cursor: default; }
.ghost-btn.danger { color: var(--bad); border-color: rgba(251,113,133,0.3); }
.ghost-btn.danger:hover { background: var(--bad-bg); color: var(--bad); }
.ghost-btn svg { width: 14px; height: 14px; }

/* ============================================================================
   OVERLAYS — preferences + help + security
   ========================================================================== */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.62); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 80; padding: 20px; }
.panel { width: 100%; max-width: 460px; background: var(--raise-2); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 24px 80px -20px rgba(0,0,0,0.9); overflow: hidden; }
.settings-panel { max-width: 760px; }
.settings-scroll { display: grid; grid-template-columns: 1fr 1fr; max-height: 72vh; overflow: auto; }
.settings-section { padding: 15px 18px; border-right: 1px solid var(--line-faint); border-bottom: 1px solid var(--line-faint); }
.settings-section h4 { margin: 0 0 12px; color: var(--accent-bright); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.settings-section label { display: grid; gap: 5px; margin: 10px 0; color: var(--fg-faint); font-size: 11px; }
.settings-section input, .settings-section select, .settings-section textarea { width: 100%; box-sizing: border-box; padding: 9px 10px; border-radius: 7px; background: var(--black); border: 1px solid var(--line); color: var(--fg); font: 12px var(--font-ui); outline: none; }
.settings-section textarea { min-height: 70px; resize: vertical; font-family: var(--font-mono); }
.settings-section input:focus, .settings-section select:focus, .settings-section textarea:focus { border-color: var(--accent-dim); }
.settings-section .check-label { display: flex; align-items: center; gap: 8px; color: var(--fg-dim); }
.settings-section .check-label input { width: auto; accent-color: var(--accent); }
.theme-settings { display: grid; align-content: start; }
.theme-section-head { display: flex; align-items: center; gap: 12px; }
.theme-section-head h4 { flex: 1; margin-bottom: 0; }
.theme-mode { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--black); }
.theme-mode-btn { border: 0; border-radius: 5px; padding: 5px 8px; background: transparent; color: var(--fg-faint); font: 700 9px var(--font-mono); letter-spacing: .06em; cursor: pointer; }
.theme-mode-btn:hover { color: var(--fg); }
.theme-mode-btn.on { background: var(--accent); color: var(--accent-ink); }
.theme-mode-btn:disabled { cursor: wait; opacity: .65; }
.theme-scope { min-height: 32px; margin: 9px 0 5px; color: var(--fg-faint); font-size: 10.5px; line-height: 1.45; }
.settings-section .theme-control { gap: 7px; margin: 8px 0; }
.theme-control > span { display: flex; justify-content: space-between; gap: 10px; }
.theme-control output { color: var(--accent-bright); font-family: var(--font-mono); }
.settings-section .theme-control input[type="range"] { appearance: none; height: 4px; margin: 5px 0; padding: 0; border: 0; border-radius: 4px; background: var(--line-strong); cursor: pointer; }
.settings-section .theme-control input[type="range"]::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border: 2px solid var(--black); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }
.settings-section .theme-control input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid var(--black); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }
.settings-section .theme-control input[type="range"]:disabled { cursor: wait; opacity: .55; }
.theme-status { margin: 2px 0 0; color: var(--accent-bright); font: 700 9.5px var(--font-mono); letter-spacing: .05em; text-transform: uppercase; }
.settings-actions { display: flex; align-items: center; gap: 12px; }
.settings-actions .pf-note { flex: 1; }
.confirm-message { margin: 0; padding: 20px 18px; color: var(--fg-dim); font-size: 13px; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 12px 18px 16px; border-top: 1px solid var(--line-faint); }
.folder-choices { max-height: 55vh; overflow: auto; }
.folder-choice { width: 100%; margin: 0; border: 0; background: transparent; color: var(--fg); cursor: pointer; text-align: left; }
.folder-choice:hover { background: var(--raise-3); }
.folder-choice > svg { width: 16px; height: 16px; color: var(--accent); }
.folder-choice > span { flex: 1; }
.boot-error-mode { display: grid; grid-template-columns: 1fr; }
.boot-error { display: grid; place-items: center; align-content: center; gap: 10px; min-height: 100vh; padding: 30px; text-align: center; background: var(--black); }
.boot-error .ill { width: 52px; height: 52px; color: var(--warn); }
.boot-error h1 { margin: 0; font-size: 20px; }
.boot-error p { max-width: 520px; margin: 0 0 10px; color: var(--fg-faint); }
.panel-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 700; flex: 1; }
.panel-note { margin: 0; padding: 12px 18px 4px; font-size: 11.5px; color: var(--fg-faint); line-height: 1.5; }
.panel-note b { color: var(--fg-dim); }
.prow { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line-faint); }
.prow > div:first-child { flex: 1; min-width: 0; }
.prow .pl { font-size: 13px; font-weight: 600; color: var(--fg); }
.prow .ph { font-size: 11px; color: var(--fg-faint); margin-top: 2px; line-height: 1.4; }
.prow .ph b { color: var(--accent-bright); font-family: var(--font-mono); }
.seg { display: flex; gap: 4px; background: var(--black); border: 1px solid var(--line); border-radius: 8px; padding: 3px; flex: none; }
.seg-btn { padding: 6px 11px; border-radius: 6px; border: none; background: transparent; color: var(--fg-dim); font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.seg-btn:hover { color: var(--fg); }
.seg-btn.on { background: var(--accent); color: var(--accent-ink); }
.switch { width: 42px; height: 24px; border-radius: 13px; border: 1px solid var(--line-strong); background: var(--black); cursor: pointer; padding: 0; position: relative; flex: none; }
.switch span { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--fg-faint); transition: left .14s ease, background .14s ease; }
.switch.on { background: var(--accent-glow); border-color: var(--accent-dim); }
.switch.on span { left: 20px; background: var(--accent); }
.panel-foot { padding: 12px 18px; }
.pf-note { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-faint); }
.keys { padding: 8px 18px 16px; }
.krow { display: flex; align-items: center; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--line-faint); }
.krow:last-child { border-bottom: none; }
.krow kbd { font-family: var(--font-mono); font-size: 11px; min-width: 64px; padding: 4px 8px; border-radius: 6px; background: var(--black); border: 1px solid var(--line-strong); color: var(--accent-bright); text-align: center; }
.krow span { font-size: 12.5px; color: var(--fg-dim); }

/* ---- security / two-factor panel ---- */
.sec-panel-body { max-height: 72vh; overflow-y: auto; }
.sec-error { display: flex; align-items: center; gap: 8px; margin: 12px 18px 0; padding: 9px 12px; border-radius: 8px; background: var(--bad-bg); border: 1px solid rgba(251,113,133,0.3); color: var(--bad); font-size: 12px; font-weight: 600; }
.sec-error svg { width: 14px; height: 14px; flex: none; }
.sec-loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 32px; color: var(--fg-faint); font-size: 12.5px; }
.sec-loading .spin { display: inline-grid; place-items: center; animation: spin 1s linear infinite; }
.sec-loading .spin svg { width: 15px; height: 15px; }
.sec-state { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 6px; flex: none; }
.sec-state svg { width: 13px; height: 13px; }
.sec-state.on { background: var(--ok-bg); color: var(--ok); }
.sec-state.off { background: var(--warn-bg); color: var(--warn); }
.sec-actions { display: flex; gap: 10px; padding: 14px 18px; }
.sec-actions .send-btn, .sec-actions .ghost-btn { flex: 1; justify-content: center; }
.sec-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line-faint); }
.qr-wrap { display: grid; place-items: center; margin: 10px 18px; padding: 16px; background: #ffffff; border-radius: 12px; }
.qr-wrap svg, .qr-wrap img { width: 192px; height: 192px; display: block; }
.manual { padding: 0 18px 6px; }
.manual .ph { font-size: 11px; color: var(--fg-faint); margin-bottom: 6px; }
.manual-key { display: block; font-family: var(--font-mono); font-size: 13px; letter-spacing: .12em; word-break: break-all; padding: 10px 12px; border-radius: 8px; background: var(--black); border: 1px solid var(--line); color: var(--accent-bright); }
.code-row { display: flex; gap: 10px; padding: 12px 18px; align-items: center; }
.code-input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 18px; letter-spacing: .3em; text-align: center; padding: 12px 14px; border-radius: 8px; background: var(--raise-3); border: 1px solid var(--line); color: var(--fg); outline: none; }
.code-input.wide { font-size: 14px; letter-spacing: .08em; }
.code-input::placeholder { color: var(--fg-ghost); letter-spacing: .12em; }
.code-input:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent-dim); }
.code-row .send-btn, .code-row .ghost-btn { flex: none; }
.backup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 18px 6px; }
.backup-grid code { font-family: var(--font-mono); font-size: 12.5px; padding: 9px 10px; border-radius: 7px; background: var(--black); border: 1px solid var(--line); color: var(--fg); text-align: center; letter-spacing: .04em; word-break: break-all; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--raise-3); border: 1px solid var(--line-strong); border-radius: 9px; padding: 11px 18px; font-size: 12.5px; color: var(--fg); font-weight: 600; display: flex; align-items: center; gap: 9px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; box-shadow: 0 10px 40px -10px rgba(0,0,0,0.8); z-index: 90; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 15px; height: 15px; color: var(--accent); }
.toast.ok svg { color: var(--ok); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================================
   RESPONSIVE — collapse to 2 then 1 pane (back-nav becomes essential)
   ========================================================================== */
@media (max-width: 1180px) { :root { --list-w: 340px; } }
@media (max-width: 920px) {
  .app { grid-template-columns: 64px 1fr; }
  .rail { --rail-w: 64px; }
  /* Collapsed rail: the wordmark is hidden, so drop the wide left clearance
     (it would overflow 64px) and instead reserve the mark's height on the now-
     empty brand strip so the fixed corner mark never overlaps the compose btn. */
  .brand { padding: 16px 8px 14px; min-height: 44px; }
  .brand .wordmark, .nav-item .label, .nav-item .count, .acct .who, .compose-btn span, .sec-row, .foot-btn span { display: none; }
  .compose-btn { margin: 12px 10px; padding: 10px; }
  .foot-btn { justify-content: center; }
  .read-pane { display: none; }
  .app.reading .list-pane { display: none; }
  .app.reading .read-pane { display: flex; }
  .read-toolbar .back-btn { display: inline-flex; }   /* back appears on mobile */

  .read-from { flex-wrap: wrap; }
  .read-from .meta { flex-basis: calc(100% - 50px); }
  .read-from .nm .addr { display: block; margin-left: 0; margin-top: 2px; }
  .read-date { width: 100%; text-align: left; margin-top: 8px; order: 3; }
  .read-toolbar { gap: 5px; }
  .read-subject { font-size: 17px; }
}
@media (max-width: 680px) {
  .settings-scroll { grid-template-columns: 1fr; }
  .compose-foot { flex-wrap: wrap; }
  .compose-foot .limits { order: 3; width: 100%; }
  .confirm-actions { flex-wrap: wrap; }
}
