:root {
  color-scheme: dark;
  --bg: #05070d;
  --panel: #0c1120;
  --panel-2: #0f1526;
  --line: #1c2740;
  --line-2: #263453;
  --txt: #e5eefb;
  --dim: #8494b4;
  --dimmer: #5a6788;
  --ember: #ff8a3c;
  --ember-2: #ffa860;
  --glow: rgba(255,138,60,.5);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--txt); overflow-x: hidden;
  font: 15px/1.5 "Outfit", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background:
    radial-gradient(1200px 700px at 88% -10%, rgba(255,138,60,.08), transparent 60%),
    radial-gradient(1000px 600px at -8% 108%, rgba(80,130,255,.08), transparent 60%),
    var(--bg);
}
/* subtle scanning line across the top for the sci-fi feel */
.scan {
  position: fixed; left: 0; right: 0; top: 0; height: 2px; z-index: 5; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
  opacity: .5; animation: scan 6s ease-in-out infinite;
}
@keyframes scan { 0%,100% { transform: translateY(0); opacity: .2; } 50% { transform: translateY(4px); opacity: .55; } }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 4;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10,14,26,.92), rgba(8,11,20,.82));
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px;
  color: #1a0d05; background: linear-gradient(135deg, #ff9a4d, #ff6a2b);
  box-shadow: 0 8px 22px -6px var(--glow);
}
.logo svg { width: 21px; height: 21px; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-txt b { font-size: 15px; }
.brand-txt span { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #2f9e6a;
  box-shadow: 0 0 0 0 rgba(57,192,122,.6);
}
.live-dot.beat { animation: beat 1s ease; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(57,192,122,.55); } 100% { box-shadow: 0 0 0 9px rgba(57,192,122,0); } }
.ghost-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--line); color: var(--dim); cursor: pointer;
  transition: .15s;
}
.ghost-btn:hover { color: var(--ember); border-color: var(--line-2); }
.ghost-btn svg { width: 18px; height: 18px; }

/* layout */
.wrap { max-width: 760px; margin: 0 auto; padding: 26px 20px 80px; }
.inbox-head { display: flex; align-items: baseline; gap: 12px; margin: 0 4px 16px; }
.inbox-head h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.count { font-size: 12.5px; color: var(--dim); }

/* message rows */
.mail-list { display: flex; flex-direction: column; gap: 10px; }
.mrow {
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  transition: border-color .18s, box-shadow .18s;
}
.mrow:hover { border-color: var(--line-2); }
.mrow.open { border-color: color-mix(in srgb, var(--ember) 50%, var(--line)); box-shadow: 0 18px 44px -26px rgba(0,0,0,.9); }
.mrow-head {
  width: 100%; display: flex; align-items: center; gap: 13px; padding: 14px 16px;
  background: none; border: 0; color: inherit; cursor: pointer; text-align: left; font: inherit;
}
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 11px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #1a0d05;
  background: linear-gradient(135deg, var(--ember-2), var(--ember));
}
.mrow.unread .avatar { box-shadow: 0 0 0 2px rgba(255,138,60,.35); }
.mrow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mrow-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mrow-from { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow.unread .mrow-from { color: var(--ember-2); }
.mrow-top time { font-size: 11.5px; color: var(--dimmer); flex: none; }
.mrow-subj { font-size: 13px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 18px; height: 18px; flex: none; color: var(--dimmer); transition: transform .2s; }
.mrow.open .chev { transform: rotate(180deg); color: var(--ember); }

/* expanded body */
.mrow-body { max-height: 0; overflow: hidden; transition: max-height .28s ease; }
.mrow.open .mrow-body { max-height: 2000px; }
.mrow-meta {
  padding: 4px 18px 12px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--dimmer); margin-top: 2px;
}
.mrow-meta span { color: var(--dim); }
.mail-text { padding: 4px 18px 18px; font-size: 14px; color: #cdd8ec; word-break: break-word; }
.mail-text a { color: var(--ember-2); }
.mail-frame {
  width: 100%; min-height: 320px; border: 0; background: #fff; border-radius: 0 0 14px 14px;
}

/* empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--dim); }
.empty-ico {
  width: 62px; height: 62px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 16px;
  color: var(--dimmer); background: var(--panel); border: 1px solid var(--line);
}
.empty-ico svg { width: 28px; height: 28px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: linear-gradient(135deg, #ff9a4d, #ff6a2b); color: #1a0d05; font-weight: 600;
  padding: 11px 20px; border-radius: 12px; font-size: 13.5px; opacity: 0; pointer-events: none;
  box-shadow: 0 16px 40px -12px var(--glow); transition: .25s; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .wrap { padding: 20px 14px 70px; }
  .mrow-subj { white-space: normal; }
}

/* ===== LOGIN VIEW (shown before auth; session lives only in memory) ===== */
#app[hidden] { display: none; }
.lv {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(1100px 700px at 50% -12%, rgba(255,150,60,.10), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(90,140,255,.10), transparent 60%),
    var(--bg);
  overflow: hidden;
}
.lv::before {
  content: ""; position: absolute; inset: -50%; z-index: 0; opacity: .4;
  background-image:
    linear-gradient(rgba(120,160,220,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,160,220,.06) 1px, transparent 1px);
  background-size: 44px 44px; animation: drift 26s linear infinite;
}
@keyframes drift { to { transform: translate(44px, 44px); } }
.lv-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px; text-align: center;
  background: linear-gradient(180deg, rgba(16,22,36,.9), rgba(9,12,22,.92));
  border: 1px solid rgba(255,150,80,.18); border-radius: 18px; padding: 34px 30px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.04);
  backdrop-filter: blur(14px);
}
.lv-badge {
  width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 15px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(135deg, #ff8a3c, #ff6a2b); box-shadow: 0 10px 30px -6px var(--glow);
}
.lv-badge svg { width: 26px; height: 26px; }
.lv-card h1 { font-size: 20px; margin: 0 0 6px; font-weight: 700; letter-spacing: -.01em; }
.lv-sub { margin: 0 0 22px; color: var(--dim); font-size: 13px; }
.lv-form { display: grid; gap: 12px; text-align: left; }
.lv-form label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7d8cad; }
.lv-form input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; background: #0a0e18;
  border: 1px solid rgba(140,170,220,.16); color: var(--txt); font: 400 14.5px "Outfit", sans-serif;
  outline: 0; transition: border-color .15s, box-shadow .15s;
}
.lv-form input:focus { border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255,138,60,.15); }
.lv-btn {
  margin-top: 4px; width: 100%; border: 0; border-radius: 12px; padding: 13px 16px; cursor: pointer;
  font: 700 14.5px "Outfit", sans-serif; color: #1a0d05;
  background: linear-gradient(135deg, #ff9a4d, #ff6a2b);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: filter .15s, opacity .15s;
}
.lv-btn:hover:not(:disabled) { filter: brightness(1.07); }
.lv-btn:disabled { opacity: .6; cursor: default; }
.lv-btn svg { width: 16px; height: 16px; }
.lv-err { color: #ff8f8f; font-size: 12.5px; min-height: 16px; margin: 2px 0 -4px; }
.lv-foot { margin-top: 16px; font-size: 11px; color: var(--dimmer); }
.lv .spin { animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
