:root{
  --bg0:#0b0d11; --bg1:#0f1115; --bg2:#12141a; --bg3:#1a1d24; --bg4:#1d212a;
  --line:#1f232c; --line2:#262b36;
  --tx:#e7e9ee; --tx2:#c3c8d2; --tx3:#9aa3b2; --tx4:#8d95a3;
  --accent:#8b9dff; --ai-bg:#151925; --ai-line:#2a3150;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--bg0);color:var(--tx);font-family:'Geist',system-ui,sans-serif;-webkit-font-smoothing:antialiased}
button{font:inherit;color:inherit;cursor:pointer}
button:disabled{cursor:default;opacity:.45}
svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}
.grow{flex:1;min-width:0}

.app{display:flex;height:100vh;height:100dvh;overflow:hidden;background:var(--bg1)}

/* rail */
.rail{width:68px;flex-shrink:0;display:flex;flex-direction:column;align-items:center;gap:8px;padding:18px 0;background:var(--bg0);border-right:1px solid var(--line)}
.logo{width:36px;height:36px;border-radius:10px;display:grid;place-items:center;background:var(--accent);color:var(--bg0);font:600 20px 'Fraunces',serif;margin-bottom:14px}
.rail-btn{width:44px;height:44px;border:0;border-radius:12px;background:transparent;color:var(--tx4);display:grid;place-items:center}
.rail-btn.active{background:var(--bg4);color:var(--tx)}
.rail-btn.accent{color:var(--accent)}
.me{width:34px;height:34px;border-radius:50%;background:#262b36;display:grid;place-items:center;font-size:13px;font-weight:600}

/* sidebar */
.sidebar{width:236px;flex-shrink:0;display:flex;flex-direction:column;gap:4px;padding:20px 14px;background:var(--bg2);border-right:1px solid var(--line);overflow-y:auto}
.brand{font:500 22px 'Fraunces',serif;padding:0 8px 14px}
.compose{height:44px;border:0;border-radius:12px;background:var(--accent);color:var(--bg0);font-size:14px;font-weight:600;display:flex;align-items:center;justify-content:center;gap:8px;margin-bottom:14px}
.compose svg{width:18px;height:18px;stroke-width:1.8}
.nav{height:38px;border:0;border-radius:10px;background:transparent;display:flex;align-items:center;gap:10px;padding:0 10px;font-size:14px;color:var(--tx2);width:100%;text-align:left}
.nav svg{width:18px;height:18px}
.nav.on{background:var(--bg4);color:var(--tx);font-weight:500}
.nav .n{font-size:12px;color:var(--tx3)}
.dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}
.section-label{font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--tx4);padding:18px 10px 6px}
.alias-count{display:flex;align-items:center;gap:10px;padding:6px 10px;font-size:13px;color:var(--tx2)}
.alias-count svg{width:16px;height:16px}
.leak{margin:4px 4px 0;padding:10px;border-radius:10px;background:#2a1a1c;border:1px solid #4a2a2e;display:flex;flex-direction:column;gap:6px}
.leak .t{font-size:12px;color:#ffb4b4;font-weight:600}
.leak .s{font-size:12px;color:#e3c6c6;line-height:1.4}
.leak button{align-self:flex-start;height:30px;border:0;border-radius:8px;background:#5a2d33;color:#ffd6d6;font-size:12px;font-weight:600;padding:0 12px}
.leak.dead{background:var(--bg3);border-color:var(--line2)}
.leak.dead .t{color:var(--tx3)}

/* list */
.list{width:424px;flex-shrink:0;display:flex;flex-direction:column;border-right:1px solid var(--line);background:var(--bg2);min-height:0}
.list-head{display:flex;align-items:center;gap:10px;padding:18px 18px 12px}
.list-head h1{margin:0;font-size:20px;font-weight:600}
.icon-btn{width:38px;height:38px;border:0;border-radius:10px;background:transparent;color:#aeb5c2;display:grid;place-items:center}
.icon-btn.on{background:var(--bg4);color:var(--accent)}
.menu-btn{display:none}
.search{display:flex;align-items:center;gap:8px;height:40px;margin:0 18px;padding:0 12px;border-radius:10px;background:var(--bg3);border:1px solid var(--line2);color:var(--tx4)}
.search svg{width:16px;height:16px}
.search input{flex:1;background:transparent;border:0;outline:none;color:var(--tx);font:inherit;font-size:14px;min-width:0}
.chips{display:flex;gap:6px;padding:12px 18px}
.chip{height:30px;border:1px solid #2a2f3a;border-radius:15px;background:transparent;color:var(--tx2);font-size:13px;padding:0 12px}
.chip.on{background:var(--tx);color:var(--bg1);border-color:var(--tx);font-weight:600}
.gate{margin:0 14px 10px;padding:12px;border-radius:12px;background:#161a22;border:1px solid var(--line2);display:flex;align-items:center;gap:12px}
.gate-icon{width:34px;height:34px;border-radius:10px;background:#20263a;color:var(--accent);display:grid;place-items:center}
.gate-icon svg{width:18px;height:18px}
.gate .t{font-size:13px;font-weight:600}
.gate .s{font-size:12px;color:var(--tx3)}
.small{height:30px;border:0;border-radius:8px;background:var(--line2);font-size:12px;font-weight:600;padding:0 12px}
.rows{flex:1;overflow-y:auto;padding:0 8px 16px;display:flex;flex-direction:column;gap:2px}
.group{font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--tx4);padding:12px 10px 4px}
.row{border:0;border-radius:12px;background:transparent;display:flex;gap:12px;padding:12px;text-align:left;width:100%}
.row:hover{background:#171a21}
.row.sel{background:var(--bg4);box-shadow:inset 3px 0 0 var(--accent)}
.av{width:38px;height:38px;border-radius:50%;flex-shrink:0;display:grid;place-items:center;font-weight:600;font-size:14px}
.row .top{display:flex;align-items:center;gap:8px}
.row .who{font-size:14px;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row .when{font-size:12px;color:var(--tx3)}
.row .subj{font-size:13px}
.row .prev{font-size:12px;color:var(--tx3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row.unread .who,.row.unread .subj{font-weight:600;color:var(--tx)}
.row:not(.unread) .who,.row:not(.unread) .subj{color:var(--tx2)}
.row .mid{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.bundle-ic{width:38px;height:38px;border-radius:10px;background:var(--bg3);color:#aeb5c2;display:grid;place-items:center;flex-shrink:0}
.bundle-ic svg{width:18px;height:18px}
.empty{padding:40px 20px;text-align:center;color:var(--tx3);font-size:14px}

/* reader */
.reader{flex:1;display:flex;flex-direction:column;min-width:0;background:var(--bg1)}
.bar{height:64px;flex-shrink:0;display:flex;align-items:center;gap:6px;padding:0 24px;border-bottom:1px solid var(--line)}
.back-btn{display:none}
.via{display:flex;align-items:center;gap:8px;height:32px;padding:0 12px;border-radius:16px;background:#161a22;border:1px solid var(--line2);font-size:12px;color:#aeb5c2;white-space:nowrap}
.via .dot{width:7px;height:7px}
.body{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:20px;padding:26px 40px 20px}
.body h2{margin:0;font-size:26px;font-weight:600;letter-spacing:-.01em}
.meta{font-size:13px;color:var(--tx3);margin-top:6px}
.ai{border-radius:16px;background:var(--ai-bg);border:1px solid var(--ai-line);padding:18px 20px;display:flex;flex-direction:column;gap:12px}
.ai-h{display:flex;align-items:center;gap:8px;color:var(--accent);font-size:13px;font-weight:600}
.ai-h svg{width:16px;height:16px}
.ai ul{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:6px;font-size:14px;line-height:1.5;color:#dde1e8}
.acts{display:flex;gap:8px;flex-wrap:wrap}
.act{height:32px;border:1px solid #343b52;border-radius:16px;background:transparent;font-size:13px;padding:0 14px}
.act.primary{border:0;background:var(--accent);color:var(--bg0);font-weight:600}
.act.done{border-color:#2e5c4f;color:#9ff0da}
.msg{display:flex;flex-direction:column;gap:14px}
.msg-h{display:flex;align-items:center;gap:12px}
.msg-h .av{width:40px;height:40px}
.msg-h .from{font-size:14px;font-weight:600}
.msg-h .to{font-size:12px;color:var(--tx3)}
.msg-h .when{font-size:12px;color:var(--tx3)}
.msg-text{font-size:15px;line-height:1.65;color:#d4d8e0;max-width:680px}
.msg-text p{margin:0 0 12px}
.att{display:flex;align-items:center;gap:10px;width:300px;max-width:100%;padding:10px 12px;border-radius:12px;background:#161a22;border:1px solid var(--line2)}
.att .n{font-size:13px;font-weight:500}.att .s{font-size:12px;color:var(--tx3)}
.reply{margin:0 40px 24px;border-radius:16px;background:#161a22;border:1px solid var(--line2);padding:14px 16px;display:flex;flex-direction:column;gap:10px}
.reply textarea{background:transparent;border:0;outline:none;resize:none;color:var(--tx);font:inherit;font-size:14px;min-height:22px}
.reply-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.pill{height:30px;border:1px solid #2a2f3a;border-radius:15px;background:transparent;font-size:12px;color:var(--tx2);padding:0 12px}
.pill.ai-pill{border:0;background:#20263a;color:var(--accent);font-weight:600}
.send{height:36px;border:0;border-radius:10px;background:var(--accent);color:var(--bg0);font-size:13px;font-weight:600;padding:0 16px;display:flex;align-items:center;gap:6px}
.send svg{width:15px;height:15px}
.nothing{flex:1;display:grid;place-items:center;color:var(--tx3);font-size:14px}

.demo-badge{position:fixed;right:12px;bottom:12px;font-size:11px;color:var(--tx3);background:var(--bg3);border:1px solid var(--line2);border-radius:999px;padding:4px 10px;pointer-events:none}
.scrim{display:none}

/* tablet portrait / narrow: list + reader as one pane, sidebar as drawer */
@media (max-width:1100px){
  .sidebar{position:fixed;left:0;top:0;bottom:0;z-index:20;transform:translateX(-100%);transition:transform .2s ease;width:260px}
  .app.drawer .sidebar{transform:none}
  .app.drawer ~ .scrim{display:block;position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:10}
  .menu-btn{display:grid}
}
@media (max-width:860px){
  .rail{display:none}
  .list{width:100%;border-right:0}
  .reader{display:none}
  .app[data-view="read"] .list{display:none}
  .app[data-view="read"] .reader{display:flex}
  .back-btn{display:grid}
  .body{padding:20px}
  .reply{margin:0 16px 16px}
  .bar{padding:0 12px}
}
