/* 13RT Mail — dark, quiet, sharp. */
:root {
  --bg: #0b0d10;
  --bg-raised: #12151a;
  --bg-hover: #1a1e25;
  --line: #23272f;
  --text: #e8eaed;
  --text-dim: #9aa0a6;
  --text-faint: #6b7280;
  --accent: #4f8ef7;
  --danger: #e5534b;
  --danger-bg: #2a1513;
  --ok: #3fb950;
  --chip: #223046;
  --chip-text: #8ab4f8;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.btn {
  border: 1px solid var(--line); background: var(--bg-raised); color: var(--text);
  border-radius: 8px; padding: 10px 18px; font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Gates */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-card { max-width: 420px; width: 100%; text-align: center; }
.wordmark {
  font-size: 64px; font-weight: 800; letter-spacing: 0.04em;
  background: linear-gradient(135deg, #e8eaed 30%, #6b7280 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.tagline { color: var(--text-dim); margin: 8px 0 20px; font-size: 17px; }
.gate-copy { color: var(--text-dim); margin-bottom: 24px; }
.gate-copy.small { font-size: 13px; color: var(--text-faint); margin-top: 16px; }
.claim-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.claim-row input { flex: 1; text-align: right; font-size: 18px; }
.claim-row.tight input { font-size: 15px; }
.claim-domain { color: var(--text-dim); font-size: 18px; white-space: nowrap; }
.claim-row.tight + .claim-domain, .claim-row.tight .claim-domain { font-size: 14px; }
.claim-status { min-height: 22px; font-size: 14px; color: var(--text-dim); margin-bottom: 12px; }
.claim-status.ok { color: var(--ok); }
.claim-status.bad { color: var(--danger); }

/* App layout */
.app { display: grid; grid-template-columns: 220px 360px 1fr; height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 16px; background: var(--bg-raised);
}
.brand { font-size: 26px; font-weight: 800; letter-spacing: 0.05em; padding-left: 6px; }
nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; justify-content: space-between; align-items: center;
  background: none; border: none; color: var(--text-dim);
  padding: 9px 12px; border-radius: 8px; text-align: left; font-weight: 600;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-hover); color: var(--text); }
.badge {
  background: var(--accent); color: #fff; border-radius: 10px;
  font-size: 12px; padding: 1px 8px; font-weight: 700;
}
.badge.danger { background: var(--danger); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.me-address { font-size: 13px; color: var(--text-dim); word-break: break-all; padding-left: 6px; }

.pane-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.pane-header {
  padding: 16px 18px; font-weight: 700; font-size: 17px;
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.msg-list { overflow-y: auto; flex: 1; }
.msg-row {
  padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
}
.msg-row:hover { background: var(--bg-hover); }
.msg-row.selected { background: var(--bg-hover); }
.msg-row .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.msg-from { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row.unread .msg-from::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 7px; vertical-align: middle;
}
.msg-time { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.msg-subject { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row:not(.unread) .msg-subject, .msg-row:not(.unread) .msg-from { font-weight: 400; color: var(--text-dim); }
.msg-snippet { font-size: 13px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.chip {
  background: var(--chip); color: var(--chip-text); font-size: 11.5px; font-weight: 700;
  border-radius: 6px; padding: 1px 8px;
}
.chip.leak { background: var(--danger-bg); color: var(--danger); }
.chip.spam { background: #2a2413; color: #d4a72c; }

.pane-read { overflow-y: auto; min-width: 0; }
.read-empty { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-faint); }
#read-content { padding: 24px 28px; }
.read-subject { font-size: 21px; font-weight: 700; margin-bottom: 10px; }
.read-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.read-from { font-weight: 600; }
.read-from small { color: var(--text-faint); font-weight: 400; }
.read-actions { display: flex; gap: 8px; flex-shrink: 0; }
.alias-banner {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; margin: 14px 0; font-size: 14px; color: var(--text-dim);
}
.alias-banner b { color: var(--text); }
.alias-banner.leak { background: var(--danger-bg); border-color: var(--danger); color: #f0b5b1; }
.alias-banner.leak b { color: #fff; }
.alias-banner .btn { margin-left: 10px; }
.read-body { margin-top: 16px; }
.read-body pre {
  white-space: pre-wrap; word-wrap: break-word; font: inherit; color: var(--text);
}
.read-body iframe {
  width: 100%; min-height: 400px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff;
}
.attachments { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.attachment {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  font-size: 13px; background: var(--bg-raised); cursor: pointer; color: var(--text-dim);
}
.attachment:hover { color: var(--text); border-color: var(--accent); }

/* Aliases view */
.alias-grid { padding: 18px; display: grid; gap: 12px; overflow-y: auto; }
.alias-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  background: var(--bg-raised); display: flex; flex-direction: column; gap: 6px;
}
.alias-card.leak { border-color: var(--danger); }
.alias-card .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.alias-addr { font-weight: 700; word-break: break-all; }
.alias-addr.dead { text-decoration: line-through; color: var(--text-faint); }
.alias-meta { font-size: 13px; color: var(--text-dim); }
.alias-meta b { color: var(--text); }
.alias-warn { font-size: 13px; color: var(--danger); font-weight: 600; }
.alias-actions { display: flex; gap: 8px; margin-top: 4px; }
.mint-cta { padding: 18px; }

/* Modals */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-card {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 12px;
  width: 640px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  padding: 18px 20px; display: flex; flex-direction: column; gap: 12px;
}
.modal-card.narrow { width: 440px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 17px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-dim); }
.field input, .field select { width: 100%; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.compose-status { font-size: 13px; color: var(--text-dim); }
.compose-status.bad { color: var(--danger); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 18px; z-index: 100; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}



.chip.opened { background: #13291a; color: #3fb950; }

.nav-row { display: flex; align-items: center; gap: 2px; }
.nav-row .nav-item { flex: 1; }
.refresh-btn {
  background: none; border: none; color: var(--text-dim); font-size: 17px;
  padding: 6px 9px; border-radius: 8px; line-height: 1;
}
.refresh-btn:hover { background: var(--bg-hover); color: var(--text); }
.refresh-btn.spinning { animation: spin 0.9s linear infinite; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.fwd-hint { color: #d4a72c; font-weight: 600; }

.row-side { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.row-actions { display: none; gap: 2px; }
.msg-row:hover .row-actions { display: inline-flex; }
.row-act {
  background: none; border: none; color: var(--text-dim); font-size: 14px;
  padding: 2px 5px; border-radius: 6px; line-height: 1;
}
.row-act:hover { background: var(--bg); color: var(--text); }

.alias-banner.confirm { background: #2a2413; border-color: #d4a72c; color: #e8d8a0; }
.alias-banner.confirm b { color: #fff; }
.confirm-actions { display: inline-flex; gap: 8px; margin-left: 10px; }

.plan-area { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.btn.upgrade { background: #6d4fc4; border-color: #6d4fc4; color: #fff; font-weight: 700; }
.btn.upgrade:hover { background: #7d5fd4; }
.plan-badge {
  text-align: center; font-weight: 800; letter-spacing: 0.1em; font-size: 12px;
  color: #b39ddb; border: 1px solid #6d4fc4; border-radius: 8px; padding: 6px;
}
.plan-note { font-size: 11.5px; color: var(--text-faint); text-align: center; }


/* Landing */
.landing { min-height: 100vh; overflow-y: auto; }
.land-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px; position: sticky; top: 0; background: rgba(11,13,16,0.85);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); z-index: 10;
}
.land-brand { font-size: 22px; font-weight: 800; letter-spacing: 0.05em; }
.hero { text-align: center; padding: 72px 24px 48px; max-width: 760px; margin: 0 auto; }
.hero-head { font-size: clamp(30px, 6vw, 48px); font-weight: 800; line-height: 1.15; margin: 8px 0 16px; }
.hero-sub { color: var(--text-dim); font-size: 17px; max-width: 560px; margin: 0 auto 28px; }
.btn.big { font-size: 17px; padding: 14px 26px; }
.hero-aliases { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 32px; }
.hero-aliases .chip { font-size: 13px; padding: 5px 12px; }
.land-section { max-width: 980px; margin: 0 auto; padding: 40px 24px; }
.land-section h2 { font-size: 26px; margin-bottom: 24px; text-align: center; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.step {
  border: 1px solid var(--line); border-radius: 12px; padding: 20px;
  background: var(--bg-raised);
}
.step-n {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; margin-bottom: 10px;
}
.step h3 { font-size: 16px; margin-bottom: 8px; }
.step p { color: var(--text-dim); font-size: 14.5px; }
.step p b, .step p i { color: var(--text); }
.price-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; max-width: 640px; margin: 0 auto; }
.price-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 24px; background: var(--bg-raised);
  display: flex; flex-direction: column; gap: 12px;
}
.price-card.featured { border-color: #6d4fc4; box-shadow: 0 0 40px rgba(109,79,196,0.25); }
.price-card .price { font-size: 38px; font-weight: 800; }
.price-card .price span { font-size: 16px; color: var(--text-dim); font-weight: 400; }
.price-card ul { list-style: none; display: flex; flex-direction: column; gap: 8px; color: var(--text-dim); font-size: 14.5px; flex: 1; }
.price-card li::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.land-foot { text-align: center; color: var(--text-faint); padding: 40px 24px; font-size: 13px; border-top: 1px solid var(--line); }

/* Auth modal */
.auth-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.auth-tab {
  flex: 1; background: none; border: none; color: var(--text-dim);
  font-weight: 700; padding: 8px; border-radius: 8px;
}
.auth-tab.active { background: var(--bg-hover); color: var(--text); }
#auth-signup, #auth-verify, #auth-signin { display: flex; flex-direction: column; gap: 12px; }
.field small { color: var(--text-faint); font-weight: 400; }
.auth-divider {
  display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: 12px;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Mobile app chrome (hidden on desktop) ---------- */
.mobile-top, .bottom-nav, .fab, .read-back { display: none; }

@media (max-width: 900px) {
  .app {
    display: flex; flex-direction: column;
    height: 100dvh; overflow: hidden; position: relative;
  }
  .sidebar { display: none; }

  .mobile-top {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: var(--bg-raised); border-bottom: 1px solid var(--line);
    flex-shrink: 0;
  }
  .mobile-top .land-brand { font-size: 19px; }
  .mt-title { font-weight: 700; font-size: 17px; flex: 1; text-align: center; }
  .mobile-top .icon-btn {
    background: none; border: none; color: var(--text-dim);
    padding: 8px; border-radius: 8px; line-height: 0;
  }
  .mobile-top .icon-btn svg { width: 22px; height: 22px; }
  .mobile-top .icon-btn.active, .mobile-top .icon-btn:active { color: var(--accent); }
  .mobile-top .icon-btn.spinning svg { animation: spin 0.9s linear infinite; color: var(--accent); }

  .pane-list { flex: 1; border-right: none; min-height: 0; }
  .pane-header { display: none; }
  .msg-list, .alias-grid { padding-bottom: 110px; }
  .msg-row { padding: 14px 16px; }
  .row-actions { display: inline-flex; } /* always visible on touch */
  .row-act { font-size: 16px; padding: 4px 7px; }

  /* In-flow bottom bar: part of the fixed-height app frame, so content
     scrolls past it inside the list — nothing can push it off screen. */
  .bottom-nav {
    display: flex; flex-direction: row; flex-shrink: 0;
    background: var(--bg-raised); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); z-index: 45;
  }
  /* Safari can't flex a <button> directly — flex lives on .bnav-inner. */
  .bnav-item {
    flex: 1; background: none; border: none; color: var(--text-faint);
    padding: 15px 0; position: relative;
  }
  .bnav-inner {
    display: flex; flex-direction: row; align-items: center;
    justify-content: center; gap: 8px; white-space: nowrap;
  }
  .bnav-item svg { width: 21px; height: 21px; flex-shrink: 0; display: block; }
  .bnav-label { font-size: 13.5px; font-weight: 700; letter-spacing: 0.01em; }
  .bnav-item.active { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
  .bnav-item .badge { position: static; transform: none; font-size: 11px; padding: 1px 7px; }

  #m-me { font-size: 20px; }
  #m-me.active { color: var(--accent); }

  .fab {
    display: flex; align-items: center; justify-content: center;
    position: absolute; right: 18px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--accent); color: #fff; border: none;
    box-shadow: 0 6px 20px rgba(0,0,0,0.45); z-index: 46;
  }
  .fab svg { width: 24px; height: 24px; }
  .fab:active { transform: scale(0.94); }

  .pane-read { display: none; }
  .pane-read.mobile-open {
    display: block; position: fixed; inset: 0; background: var(--bg);
    z-index: 50; overflow-y: auto;
    padding-top: env(safe-area-inset-top);
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  #read-content { padding: 14px 16px 24px; }
  .read-back {
    display: inline-flex; align-items: center;
    background: none; border: none; color: var(--accent);
    font-size: 16px; font-weight: 700; padding: 8px 0 14px;
  }
  .read-meta { flex-direction: column; }
  .read-actions { flex-wrap: wrap; }

  /* Full-screen modals */
  .modal { padding: 0; align-items: stretch; }
  .modal-card, .modal-card.narrow {
    width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh;
    border-radius: 0; border: none;
    padding-top: calc(18px + env(safe-area-inset-top));
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  #compose-body { flex: 1; min-height: 160px; }

  /* Me panel */
  .me-panel { padding: 18px; }
  .me-card {
    border: 1px solid var(--line); border-radius: 14px; background: var(--bg-raised);
    padding: 22px 18px; display: flex; flex-direction: column; gap: 14px; text-align: center;
  }
  .me-big { font-size: 19px; font-weight: 800; word-break: break-all; }

  /* Landing niceties on small screens */
  .hero { padding-top: 40px; }
  .land-nav { padding-top: calc(12px + env(safe-area-inset-top)); }
}

/* Me panel on desktop (if ever reached) */
.me-panel { padding: 18px; }

/* To-field combo dropdown */
.combo { position: relative; display: flex; }
.combo input { flex: 1; padding-right: 40px; }
.combo-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-dim);
  font-size: 15px; padding: 8px 10px; border-radius: 6px;
}
.combo-toggle:hover { color: var(--text); }
.combo-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px;
  max-height: 260px; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.combo-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; text-align: left; background: none; border: none;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover, .combo-item:active { background: var(--bg-hover); }
.combo-value { color: var(--text); font-weight: 600; word-break: break-all; }
.combo-kind { color: var(--text-faint); font-size: 12px; }
.combo-empty { padding: 12px 14px; color: var(--text-faint); font-size: 13.5px; }

.opens-disclaimer { margin-top: 8px; font-size: 12px; color: var(--text-faint); }
