:root {
  color-scheme: dark;
  --back: #141516;
  --side: #1b1c1d;
  --surface: #202122;
  --line: #373737;
  --ink: #f4eee8;
  --muted: #b6afa9;
  --accent: #ff7881;
  font: 16px/1.5 Inter, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--back);
}
* { box-sizing: border-box; }
body { margin: 0; }
.masthead, main { width: min(100% - 64px, 1240px); margin: auto; }
.masthead { height: 86px; display: flex; align-items: center; justify-content: space-between; }
.wordmark { display: flex; gap: 15px; align-items: center; font-size: 25px; font-weight: 650; letter-spacing: -1.4px; }
.brand-ring { position: relative; width: 31px; height: 25px; transform: rotate(-27deg); }
.brand-ring::before, .brand-ring::after { content: ""; position: absolute; inset: 0 0 6px; border: 2px solid var(--accent); border-radius: 50%; }
.brand-ring::after { transform: translateY(6px); }
.network, small, code { font: 12px/1.5 ui-monospace, Consolas, monospace; }
.network { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.network i { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; }
[data-network="mainnet"] .network i { background: #96999b; }
[data-network="mainnet"] .network[data-status="online"] i { background: #59cd88; }
main { display: grid; grid-template-columns: clamp(232px, 25vw, 315px) minmax(0, 1fr); margin-bottom: 20px; }
aside, .thread { border: 1px solid var(--line); min-width: 0; }
aside { background: var(--side); border-radius: 18px 0 0 18px; padding: 24px 18px 12px; display: flex; flex-direction: column; }
.thread { background: #191a1b; border-left: 0; border-radius: 0 18px 18px 0; display: flex; flex-direction: column; min-height: clamp(590px, 78dvh, 850px); }
h1, h2, p { margin: 0; }
h1, h2 { font-weight: 600; letter-spacing: -.045em; }
h1 { font-size: 19px; overflow-wrap: anywhere; }
h2 { font-size: 24px; }
.sidebar-head, .thread-head, .editor-foot, .buttons { display: flex; align-items: center; gap: 10px; }
.sidebar-head, .editor-foot { justify-content: space-between; }
button, summary { min-height: 44px; cursor: pointer; }
button, input, textarea { font: inherit; color: inherit; }
button { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-size: 14px; font-weight: 550; }
button:hover { background: #323130; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#refresh { font-size: 23px; width: 44px; padding: 0; background: transparent; border: 0; color: var(--muted); }
#new { margin: 15px 0 16px; text-align: left; color: var(--accent); background: #382328; border-color: #67343e; }
#new:hover { background: #4c2b32; }
#new span { margin-right: 6px; }
nav { display: grid; gap: 4px; max-height: 54dvh; overflow: auto; }
nav button { display: grid; grid-template-columns: 35px minmax(0,1fr); column-gap: 12px; text-align: left; align-items: center; background: transparent; border-color: transparent; padding: 10px 8px; }
nav button[aria-current=true] { background: #303030; border-color: var(--line); }
nav button.unread { position: relative; border-color: var(--accent); padding-right: 26px; }
nav button.unread::after { content: ""; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.has-unread::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; vertical-align: middle; border-radius: 50%; background: var(--accent); }
.avatar { display: inline-block; width: 35px; height: 35px; border-radius: 50%; background: repeating-radial-gradient(ellipse at 25% 85%, #282525 0 5px, #c06b78 6px 7px, #35252b 8px 10px); border: 1px solid #68414a; }
nav .avatar { grid-row: span 2; }
nav small { font-family: inherit; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#empty-inbox { color: var(--muted); font-size: 14px; padding: 8px 4px 20px; }
#inbox-search { margin-bottom:12px; }
#search-input, .private-dialog input, .private-dialog textarea { width:100%; padding:9px; border:1px solid var(--line); border-radius:8px; background:var(--surface); }
#search-results { max-height:30vh; overflow:auto; }
#search-results button { display:block; width:100%; text-align:left; margin-top:4px; overflow-wrap:anywhere; }
.private-dialog { width:min(410px,calc(100% - 28px)); border:1px solid var(--line); border-radius:16px; padding:20px; background:var(--side); color:var(--ink); }
.private-dialog label { display:grid; gap:4px; }
.private-dialog::backdrop { background:#080909ba; }
#history article .buttons { margin-top:8px; }
#name-contact { margin-left:auto; }
.thread-head:has(#name-contact:not([hidden])) { flex-wrap:wrap; }
.wallet { border-top: 1px solid var(--line); margin-top: auto; padding-top: 8px; }
.wallet summary { align-content: center; font-size: 14px; }
.wallet strong { margin-left: 6px; font-weight: 450; color: var(--muted); }
code { overflow-wrap: anywhere; display: block; margin: 10px 0; }
.buttons { flex-wrap: wrap; }
.thread-head { min-height: 78px; padding: 12px 28px; border-bottom: 1px solid var(--line); }
#back { display: none; }
.stage { flex: 1; display: grid; min-width: 0; }
#welcome { align-self: center; text-align: center; padding: 22px 16px; }
#welcome h2 { font-size: clamp(24px, 3vw, 33px); }
#welcome p { margin: 5px auto 0; color: var(--muted); font-size: 14px; }
.orbit-art { position: relative; width: min(100%, 340px); height: 155px; margin: 0 auto 12px; display: grid; place-items: center; background: radial-gradient(ellipse, #722a3680 0, transparent 67%); }
.orbit-stack { position: relative; width: 180px; height: 115px; transform: rotate(-22deg); }
.orbit-stack i { position: absolute; inset: 0 0 auto; height: 65px; border: 1px solid #ffadb4; border-radius: 50%; box-shadow: inset 0 2px 1px #ff748555, 0 2px 3px #321b23; }
.orbit-stack i:nth-child(2) { top: 10px; border-color: #ff929e; }
.orbit-stack i:nth-child(3) { top: 20px; border-color: #f67b8a; }
.orbit-stack i:nth-child(4) { top: 30px; border-color: #dc6275; }
.orbit-stack i:nth-child(5) { top: 40px; border-color: #b74c61; }
.orbit-stack i:nth-child(6) { top: 50px; border-color: #963b50; }
#history:empty { display: none; }
#history { align-self: end; display: grid; gap: 12px; padding: 24px clamp(15px, 3vw, 38px); max-height: 52dvh; overflow-y: auto; }
article, blockquote { max-width: 85%; margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; background: #2b2c2e; padding: 10px 15px; border-radius: 16px 16px 16px 4px; justify-self: start; }
article small { display: block; color: var(--muted); margin-bottom: 3px; }
article small a { color: inherit; }
article.sent { justify-self: end; background: #4b2933; border-radius: 16px 16px 4px 16px; }
.compose-area { padding: 12px clamp(15px, 3vw, 38px) 24px; }
form, #review { display: grid; gap: 10px; }
.recipient, .editor, #review { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.recipient { display: flex; align-items: center; padding: 0 14px; gap: 14px; color: var(--muted); font-size: 14px; }
input, textarea { background: transparent; border: 0; min-width: 0; font-size: 16px; color: var(--ink); }
input { width: 100%; min-height: 45px; }
textarea { width: 100%; min-height: 60px; padding: 13px 14px 0; resize: vertical; }
input::placeholder, textarea::placeholder { color: #aaa5a0; }
.editor-foot { padding: 6px 10px 10px 14px; }
#count { color: var(--muted); }
.primary { color: #2a1016; background: var(--accent); border-color: transparent; }
.primary:hover { background: #ff9ca4; }
.primary span { margin-left: 4px; }
#review { padding: 16px; }
#terms, #feedback { overflow-wrap: anywhere; }
#terms { color: var(--muted); font-size: 14px; }
footer { grid-column: 1/-1; color: var(--muted); padding: 10px 4px; font-size: 13px; }
#feedback { white-space: pre-wrap; }
[hidden] { display: none !important; }
#invite,#requests { margin:0 0 12px; }
#invite { text-align:left; }
#welcome-invite { margin-top:14px; }
#request-count { color:var(--accent); }
#requests summary,#blocked-section summary { cursor:pointer; padding:8px 0; }
#request-prompt { padding:12px; border:1px solid var(--line); border-radius:12px; }
#request-prompt button { margin-top:8px; }
#peer-actions { margin-left:auto; }
#peer-actions button { font-size:12px; color:var(--muted); background:transparent; }
#blocked-list button { width:100%; overflow-wrap:anywhere; margin:4px 0; }
#wallet-balances { display:grid; gap:8px; margin:12px 0; }
#wallet-balances p { display:grid; grid-template-columns:auto 1fr; align-items:baseline; column-gap:8px; }
#wallet-balances span { justify-self:end; overflow-wrap:anywhere; font-variant-numeric:tabular-nums; }
#wallet-balances small { grid-column:1/-1; color:var(--muted); font-family:inherit; }
#invite-dialog { width:min(350px,calc(100% - 28px)); border:1px solid var(--line); border-radius:16px; padding:20px; background:var(--side); color:var(--ink); }
#invite-dialog::backdrop { background:#080909ba; }
#invite-qr { display:block; margin:14px auto; max-width:100%; height:auto!important; }
#invite-url { margin-bottom:10px; }
.phantom-link { display:inline-flex; align-items:center; min-height:44px; padding-inline:14px; color:#291017; background:var(--accent); border-radius:10px; text-decoration:none; }
#history article button { display:block; margin-top:6px; }
#chat-setup { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin-bottom:12px; padding:12px 14px; border:1px solid var(--line); border-radius:12px; background:var(--surface); }
#setup-hint { flex:1 1 170px; margin:0; font-size:14px; }
#settings-dialog { width:min(380px,calc(100% - 32px)); border:1px solid var(--line); border-radius:16px; padding:20px; background:var(--side); color:var(--ink); }
#settings-dialog p { color:var(--muted); font-size:14px; }
.setting { display:flex; align-items:center; gap:10px; }
.setting input { width:18px; min-height:18px; accent-color:var(--accent); }
@media(max-width:700px){html[data-mode="hosted"] .masthead{flex-wrap:wrap;height:auto;gap:6px;padding-block:8px}.masthead .buttons{flex-wrap:wrap}html[data-mode="hosted"] .wordmark{font-size:20px}}
#profile-dialog { width: min(440px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: 18px; background: var(--side); padding: 24px; color: var(--ink); }
#profile-dialog::backdrop { background: #080909ba; }
#profile-dialog p, #profile-dialog code { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; margin: 8px 0 14px; }
#profile-dialog label { display: grid; min-width: 0; gap: 4px; }
#profile-dialog input { border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
#profile-dialog input[type=file] { max-width: 100%; font-size: 13px; }
.profile-picture { width: 62px; height: 62px; }
.avatar { overflow: hidden; flex-shrink: 0; }
.avatar canvas { width: 100%; height: 100%; display: block; }
#profile-open { max-width: 155px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#profile-open:has(.avatar) { display:inline-flex; align-items:center; gap:8px; }
#profile-open .avatar { width:26px; height:26px; }
#profile-open span { overflow:hidden; text-overflow:ellipsis; }
#balance-open { display:grid; grid-template-columns:auto auto; column-gap:10px; align-items:center; text-align:left; padding:5px 12px; line-height:1.2; }
#balance-open span { font-size:11px; color:var(--muted); }
#balance-amount { grid-column:1; font-size:14px; font-variant-numeric:tabular-nums; }
#balance-open i { grid-column:2; grid-row:1 / 3; color:var(--accent); font-style:normal; font-size:20px; }
@media (max-width: 700px) {
  .masthead, main { width: 100%; }
  .masthead { height: 58px; padding: 0 16px; }
  main { display: block; margin-bottom: 0; }
  aside, .thread { border: 0; border-top: 1px solid var(--line); border-radius: 0; min-height: calc(100dvh - 105px); }
  [data-pane=thread] aside, [data-pane=inbox] .thread { display: none; }
  #back { display: block; color: var(--accent); background: transparent; border: 0; padding: 6px; }
  .thread-head { padding: 6px 12px; min-height: 57px; }
  .head-avatar { width: 26px; height: 26px; }
  .compose-area { padding-bottom: 12px; }
  aside { padding: 16px; }
  footer { padding: 8px 16px max(8px, env(safe-area-inset-bottom)); }
}

.app-brand{display:flex;align-items:center;gap:7px;color:inherit;text-decoration:none}.app-brand img{width:38px;height:38px}
#inbox-keys { width:min(440px,calc(100% - 28px)); max-height:85dvh; overflow:auto; border:1px solid var(--line); border-radius:18px; background:var(--side); color:var(--ink); padding:22px; }
#inbox-keys::backdrop { background:#080909ba; }
#backup-feedback { border-left: 3px solid var(--accent); padding: 6px 10px; }
#inbox-keys p, #inbox-keys label { display:block; margin:12px 0; }
#inbox-keys input, #inbox-keys textarea { display:block; width:100%; border:1px solid var(--line); border-radius:8px; padding:8px; }
