:root {
  --bg-app: #0b1120;
  --bg-panel: #111827;
  --bg-card: #1e293b;
  --bg-hover: #263349;
  --border: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --green: #10b981;
  --amber: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 54px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
}

.brand img { width: 26px; height: 26px; border-radius: 6px; }

.tag-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(2, 132, 199, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.tag-pill.vault-armed {
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.45);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mode-switch {
  display: inline-flex;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 600;
}

.status-pill {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  cursor: pointer;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--accent-hover); }
.btn.secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn.secondary:hover { background: var(--bg-hover); }
.btn.green { background: #059669; }
.btn.green:hover { background: #047857; }
.btn.purple { background: #7c3aed; }
.btn.purple:hover { background: #6d28d9; }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }

.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.compose-cta {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-main); }
.nav-item.active { background: rgba(2, 132, 199, 0.18); color: #38bdf8; font-weight: 600; }

.count-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}
.count-badge.muted { background: #334155; color: #cbd5e1; }

.sidebar-section-label {
  margin-top: 16px;
  margin-bottom: 4px;
  padding: 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.quick-contacts {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quick-contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: #cbd5e1;
}
.quick-contact-row:hover { background: var(--bg-card); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.p2p { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.relay { background: var(--amber); }
.dot.gossip { background: #a78bfa; box-shadow: 0 0 5px #a78bfa; }
.dot.offline { background: #64748b; }
.dot.ext { background: #38bdf8; box-shadow: 0 0 5px rgba(56, 189, 248, 0.7); }

.route-badge-ext {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.upgrade-e2ee-banner {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: #a7f3d0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-main);
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.main-pane {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.mail-list-col {
  width: 340px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #0f172a;
  flex-shrink: 0;
}

.col-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mail-list {
  flex: 1;
  overflow-y: auto;
}

.mail-row {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
  cursor: pointer;
  transition: background 0.12s;
}
.mail-row:hover { background: var(--bg-card); }
.mail-row.selected { background: rgba(2, 132, 199, 0.16); border-left: 3px solid #38bdf8; }
.mail-row.unread .mail-subject { font-weight: 700; color: #fff; }
.mail-row.unread .mail-peer { font-weight: 700; color: #38bdf8; }

.mail-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.mail-subject { font-size: 13px; color: #e2e8f0; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-snippet { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mail-reader-col {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.5;
}

.crypto-banner {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 12px;
  margin: 12px 0 18px 0;
}

.reader-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  font-size: 14px;
  color: #f1f5f9;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  flex: 1;
}

.page-scroll {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.card h3 { margin: 0 0 8px 0; font-size: 15px; color: #38bdf8; }
.card p { margin: 0 0 12px 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }

input, textarea, select {
  width: 100%;
  background: var(--bg-app);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13px;
  margin-top: 4px;
}
label { display: block; font-size: 12px; color: var(--text-muted); margin-top: 10px; }

.mono-box {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  word-break: break-all;
  white-space: pre-wrap;
}

.lane-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-radius: 7px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  font-size: 12.5px;
}

.chain-drawer {
  width: 310px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.chain-drawer.hidden { display: none; }

.block-item {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  color: #cbd5e1;
}
.block-item strong { color: #38bdf8; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.86);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.hidden { display: none; }

.modal-card {
  width: 540px;
  max-width: 94vw;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}
.modal-card h2 { margin: 0 0 8px 0; font-size: 18px; }

.vault-lock-card {
  border: 1px solid rgba(139, 92, 246, 0.55);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.18);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  border: 1px solid #38bdf8;
  color: #f8fafc;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 80;
}
.toast.hidden { display: none; }
.hidden { display: none !important; }

/* --- v0.8 Live Encrypted Chat Messenger Layout --- */
.chat-peers-col {
  width: 295px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #0f172a;
  flex-shrink: 0;
}

.chat-peer-row {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
  cursor: pointer;
  transition: background 0.12s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-peer-row:hover { background: var(--bg-card); }
.chat-peer-row.selected { background: rgba(2, 132, 199, 0.18); border-left: 3px solid #38bdf8; }

.chat-thread-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  overflow: hidden;
}

.chat-thread-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 74%;
}
.chat-bubble-row.outgoing { align-self: flex-end; align-items: flex-end; }
.chat-bubble-row.incoming { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.8px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
}
.chat-bubble.outgoing {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #f8fafc;
  border-bottom-right-radius: 3px;
}
.chat-bubble.incoming {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-bottom-left-radius: 3px;
}

.chat-subj-tag {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.chat-bubble-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 3px;
}

.chat-composer {
  padding: 12px 18px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chat-composer textarea {
  flex: 1;
  margin-top: 0;
  resize: none;
  font-size: 13.5px;
  line-height: 1.45;
  max-height: 130px;
}
.chat-send-btn {
  padding: 11px 18px;
  flex-shrink: 0;
  height: 44px;
}

/* OpenMail v1.0 Attachments, RAM Browser Viewer & Notistry Ledger */
.att-pending-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 18px 0 18px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}
.att-pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11.5px;
}
.att-pill-card {
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.35);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.att-pill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}
.att-pill-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.8px;
  color: var(--text-muted);
}
.att-pill-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.att-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  cursor: pointer;
}
.att-btn:hover { border-color: #38bdf8; }
.att-btn.primary {
  background: #0284c7;
  border-color: #38bdf8;
  color: #fff;
}

.viewer-modal-card {
  width: min(980px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.viewer-stage {
  margin-top: 10px;
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 320px;
  max-height: 64vh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}
.viewer-stage img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 6px;
}
.viewer-stage video, .viewer-stage audio {
  max-width: 100%;
  width: 100%;
}
.viewer-stage embed, .viewer-stage iframe {
  width: 100%;
  height: 60vh;
  border: none;
  border-radius: 6px;
  background: #fff;
}
.viewer-stage pre {
  width: 100%;
  margin: 0;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.notistry-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.proof-verdict-box {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
  line-height: 1.5;
}

.om-body-link {
  color: #38bdf8;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  cursor: pointer;
}
.om-body-link:hover {
  color: #7dd3fc;
}
.chat-bubble.outgoing .om-body-link {
  color: #e0f2fe;
  font-weight: 600;
}
.chat-bubble.outgoing .om-body-link:hover {
  color: #ffffff;
}
.om-att-inline-link {
  color: #6ee7b7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}
.chat-bubble.outgoing .om-att-inline-link {
  color: #d1fae5;
}
.om-tiny-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  margin: 1px 2px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.4);
  font-size: 0.92em;
  text-decoration: none;
  word-break: break-word;
}
.om-tiny-link-pill:hover {
  background: rgba(56, 189, 248, 0.25);
  text-decoration: underline;
}
.chat-bubble.outgoing .om-tiny-link-pill {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.42);
  color: #ffffff;
}
.chat-bubble.outgoing .om-tiny-link-pill:hover {
  background: rgba(255, 255, 255, 0.28);
}
.om-stream-inline-link {
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
}


