/* ═══════════════════════════════════════════════════════════════════
   Mesh — design tokens
   Base is a deep indigo rather than neutral black: it reads as night sky
   over a network map. Brass marks anything that is key material (phrases,
   seals, locks). Teal marks live signal (online, delivered, peers up).
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --ink-900:  #070A14;
  --ink-850:  #0A0E1D;
  --ink-800:  #0E1326;
  --ink-750:  #131931;
  --ink-700:  #18203D;
  --ink-600:  #202949;
  --line:     #232C4E;
  --line-soft:#1A2140;

  --text:     #E8EBF7;
  --text-dim: #A7AFCC;
  --muted:    #7982A6;

  --brass:    #E3A857;
  --brass-lo: #8A6526;
  --brass-glow: rgba(227,168,87,.16);

  --signal:   #55D6C2;
  --signal-lo:#1E5B54;
  --alert:    #FF6B81;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 12px 40px rgba(0,0,0,.55);
  --shadow-3: 0 24px 80px rgba(0,0,0,.7);

  --sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', var(--sans);
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;

  --sidebar-w: 336px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--ink-900);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: var(--brass-glow); color: #fff; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--ink-600) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--ink-600);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: #2C3860; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 4px;
}

.screen { height: 100dvh; }
[hidden] { display: none !important; }

/* ═══════════════════════════ primitives ═══════════════════════════ */

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  padding: 10px 18px;
  cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              transform .1s var(--ease), color .16s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }

.btn--primary {
  background: linear-gradient(180deg, #F0BA6C, var(--brass));
  color: #221704;
  box-shadow: 0 6px 20px rgba(227,168,87,.22);
}
.btn--primary:hover:not(:disabled) { filter: brightness(1.07); }

.btn--ghost {
  background: var(--ink-750);
  border-color: var(--line);
  color: var(--text-dim);
}
.btn--ghost:hover:not(:disabled) { background: var(--ink-700); color: var(--text); }
.btn--danger:hover:not(:disabled) { color: var(--alert); border-color: #5B2733; }

.btn--block { width: 100%; }

.btn--icon {
  width: 40px; height: 40px;
  padding: 0;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  color: var(--text-dim);
  font-size: 17px;
  flex: none;
}
.btn--icon:hover { background: var(--ink-700); color: var(--text); }

.btn--send {
  width: 44px; height: 44px;
  padding: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #F0BA6C, var(--brass));
  color: #221704;
  font-size: 16px;
  flex: none;
  box-shadow: 0 4px 16px rgba(227,168,87,.28);
}
.btn--send:hover { filter: brightness(1.08); }

.field { display: block; margin-bottom: 16px; position: relative; }
.field__label {
  display: block;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 7px;
}
.field input,
.modal input[type="text"],
.modal input[type="search"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.field input:focus, .modal input:focus {
  outline: none;
  border-color: var(--brass-lo);
  background: var(--ink-800);
}
.field input::placeholder { color: #4E5679; }

.hint { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.meter { display: block; height: 3px; background: var(--ink-700); border-radius: 2px; margin-top: 8px; }
.meter i {
  display: block; height: 100%; width: 0;
  background: var(--alert); border-radius: 2px;
  transition: width .3s var(--ease), background .3s var(--ease);
}
.meter[data-level="2"] i { background: #E0A64B; }
.meter[data-level="3"] i { background: var(--signal); }

.ava {
  display: grid; place-items: center;
  background: var(--ink-700);
  border-radius: 30%;
  font-family: var(--emoji);
  flex: none;
  border: 1px solid var(--line);
  user-select: none;
}
.ava--lg { width: 46px; height: 46px; font-size: 24px; }
.ava--md { width: 40px; height: 40px; font-size: 21px; }
.ava--sm { width: 34px; height: 34px; font-size: 18px; border-radius: 32%; }

.avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.avatar-pick {
  width: 64px; height: 64px;
  font-size: 34px;
  font-family: var(--emoji);
  background: var(--ink-750);
  border: 1px dashed var(--line);
  border-radius: 22px;
  cursor: pointer;
  transition: border-color .16s, transform .12s var(--ease);
  display: grid; place-items: center;
}
.avatar-pick:hover { border-color: var(--brass-lo); transform: scale(1.04); }

.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.check input { accent-color: var(--brass); width: 15px; height: 15px; }

/* ═══════════════════════════ auth screen ═══════════════════════════ */

.screen--auth { display: grid; grid-template-columns: 1.15fr 1fr; }

.auth-art {
  position: relative;
  background:
    radial-gradient(120% 90% at 12% 8%, #14204A 0%, transparent 55%),
    radial-gradient(90% 80% at 90% 100%, #1A1330 0%, transparent 60%),
    var(--ink-900);
  overflow: hidden;
  display: flex;
  align-items: center;
}
#mesh-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.auth-art__copy { position: relative; padding: 0 clamp(36px, 7vw, 96px); max-width: 640px; }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 42px; }
.brand__mark { font-size: 26px; font-family: var(--emoji); }
.brand__name {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: .34em;
  font-size: 15px;
  color: var(--brass);
}

.auth-art__head {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(30px, 3.9vw, 52px);
  line-height: 1.07;
  letter-spacing: -.025em;
  margin: 0 0 40px;
}

.auth-art__facts { list-style: none; padding: 0; margin: 0 0 48px; display: grid; gap: 1px; }
.auth-art__facts li {
  display: grid; gap: 2px;
  padding: 15px 0;
  border-top: 1px solid var(--line-soft);
}
.auth-art__facts li:last-child { border-bottom: 1px solid var(--line-soft); }
.auth-art__facts b { font-size: 14px; font-weight: 700; }
.auth-art__facts span { font-size: 13px; color: var(--muted); }

.auth-art__node {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .04em;
}

.auth-panel { display: grid; place-items: center; padding: 32px; background: var(--ink-850); }
.auth-card { width: 100%; max-width: 380px; }

.tabs { display: flex; gap: 4px; background: var(--ink-800); padding: 4px; border-radius: var(--r-md); margin-bottom: 28px; }
.tab {
  flex: 1; font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.tab.is-active { background: var(--ink-700); color: var(--text); }

.auth-note {
  margin: 18px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.5;
  padding-left: 12px; border-left: 2px solid var(--line);
}
.auth-note--warn { border-left-color: var(--brass-lo); }

.auth-error {
  margin-top: 18px; padding: 11px 14px;
  background: rgba(255,107,129,.09);
  border: 1px solid rgba(255,107,129,.28);
  border-radius: var(--r-md);
  color: #FFA3B1; font-size: 13.5px;
}

/* ═══════════════════════════ app shell ═══════════════════════════ */

.screen--app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

.sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 0;
  background: var(--ink-850);
  border-right: 1px solid var(--line-soft);
}

.me {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
  transition: background .16s var(--ease);
}
.me:hover { background: var(--ink-800); }
.me__text { display: grid; min-width: 0; flex: 1; }
.me__text b { font-size: 14.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me__text i {
  font-style: normal; font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.node-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); flex: none;
  box-shadow: 0 0 0 0 rgba(85,214,194,.5);
}
.node-dot.is-live { background: var(--signal); animation: pulse 2.4s infinite; }
.node-dot.is-down { background: var(--alert); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(85,214,194,.45); }
  70%  { box-shadow: 0 0 0 7px rgba(85,214,194,0); }
  100% { box-shadow: 0 0 0 0 rgba(85,214,194,0); }
}

.search { display: flex; gap: 8px; padding: 14px 14px 10px; }
.search input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 14px;
  background: var(--ink-800);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 10px 14px;
  color: var(--text);
}
.search input:focus { outline: none; border-color: var(--brass-lo); }
.search input::placeholder { color: #4E5679; }
.search input::-webkit-search-cancel-button { filter: invert(.6); }

.list { overflow-y: auto; padding: 4px 8px 12px; min-height: 0; }
.list--results { border-top: 1px solid var(--line-soft); }
.list--flat { max-height: 230px; padding: 0; }

.list__label {
  font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
  padding: 14px 12px 8px;
}
.list__empty { padding: 22px 14px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .14s var(--ease);
  position: relative;
}
.row:hover { background: var(--ink-800); }
.row.is-active { background: var(--ink-700); }
.row.is-active::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 2px; border-radius: 2px; background: var(--brass);
}
.row__body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row__top { display: flex; align-items: baseline; gap: 8px; }
.row__name {
  font-weight: 600; font-size: 14.5px; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row__time { font-size: 11px; color: var(--muted); font-family: var(--mono); flex: none; }
.row__prev {
  font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
}
.row__badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--brass); color: #221704;
  font-size: 11px; font-weight: 800;
  display: grid; place-items: center; flex: none;
}
.row__lock { color: var(--brass); font-size: 11px; }

.presence {
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--ink-850);
  background: var(--muted);
  position: absolute; left: 32px; bottom: 9px;
}
.presence.is-on { background: var(--signal); }
.row { }
.row .ava { position: relative; }

.mesh-bar {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 18px;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .16s var(--ease);
}
.mesh-bar:hover { background: var(--ink-800); }
.mesh-bar__pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--signal);
  animation: pulse 2.4s infinite; flex: none;
}
.mesh-bar__text { display: grid; flex: 1; min-width: 0; }
.mesh-bar__text b { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.mesh-bar__text i { font-style: normal; font-size: 11.5px; color: var(--muted); }
.mesh-bar__chev { color: var(--muted); font-size: 18px; }

/* ═══════════════════════════ chat pane ═══════════════════════════ */

.chat { display: grid; min-height: 0; background: var(--ink-900); }

.chat__empty {
  display: grid; place-content: center; justify-items: center;
  text-align: center; gap: 6px; padding: 40px;
}
.chat__empty-mark { font-size: 44px; font-family: var(--emoji); opacity: .5; margin-bottom: 10px; }
.chat__empty h2 { font-family: var(--display); font-weight: 700; font-size: 20px; margin: 0; }
.chat__empty p { color: var(--muted); margin: 0; max-width: 320px; font-size: 13.5px; }

.chat__inner { display: grid; grid-template-rows: auto 1fr auto auto; min-height: 0; }

.chat__head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--ink-850);
}
.chat__back { display: none; }
.chat__title { display: grid; flex: 1; min-width: 0; }
.chat__title b { font-family: var(--display); font-weight: 700; font-size: 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__title i { font-style: normal; font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.seal-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--ink-750);
  color: var(--text-dim);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; flex: none;
  transition: all .18s var(--ease);
}
.seal-chip:hover { border-color: var(--brass-lo); color: var(--text); }
.seal-chip__icon { font-family: var(--emoji); font-size: 13px; }
.seal-chip.is-sealed {
  border-color: var(--brass-lo);
  background: var(--brass-glow);
  color: var(--brass);
}
.seal-chip.is-locked {
  border-color: var(--alert);
  background: rgba(255,107,129,.1);
  color: var(--alert);
}

/* ── messages ─────────────────────────────────────────────────────── */

.messages {
  overflow-y: auto;
  padding: 22px 22px 8px;
  display: flex; flex-direction: column; gap: 3px;
  min-height: 0;
  scroll-behavior: smooth;
}

.daymark {
  align-self: center;
  margin: 16px 0 12px;
  padding: 4px 13px;
  font-size: 11px; letter-spacing: .06em;
  color: var(--muted);
  background: var(--ink-800);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-pill);
}

.msg {
  max-width: min(66%, 620px);
  align-self: flex-start;
  display: grid;
  animation: msg-in .26s var(--ease) both;
}
.msg--out { align-self: flex-end; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .msg { animation: none; }
  .messages { scroll-behavior: auto; }
  .node-dot.is-live, .mesh-bar__pulse { animation: none; }
}

.msg__author {
  font-size: 11.5px; font-weight: 700; color: var(--brass);
  margin: 8px 0 3px 14px;
}
.msg__bubble {
  background: var(--ink-750);
  border: 1px solid var(--line-soft);
  border-radius: 16px 16px 16px 5px;
  padding: 9px 14px 7px;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.msg--out .msg__bubble {
  background: linear-gradient(180deg, #23305A, #1C2748);
  border-color: #2C3963;
  border-radius: 16px 16px 5px 16px;
}
.msg--grouped .msg__bubble { border-radius: 16px; }
.msg--out.msg--grouped .msg__bubble { border-radius: 16px; }

.msg__text { white-space: pre-wrap; font-size: 14.5px; line-height: 1.48; }
.msg__text.is-jumbo { font-size: 40px; line-height: 1.2; font-family: var(--emoji); }

.msg__sticker { font-size: 78px; line-height: 1.05; font-family: var(--emoji); }
.msg--sticker .msg__bubble { background: none; border: 0; padding: 2px 6px; }

.msg__meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  font-size: 10.5px; color: var(--muted); margin-top: 2px;
  font-family: var(--mono);
}
.msg__tick { color: var(--signal); font-size: 11px; }
.msg__seal { color: var(--brass); }
.msg__origin { opacity: .55; }

/* the signature: content that cannot be opened is shown as live noise,
   not as a grey placeholder — the encryption is meant to be visible */
.msg--locked .msg__bubble {
  background: repeating-linear-gradient(
    -45deg, var(--ink-800) 0 8px, var(--ink-750) 8px 16px);
  border-color: var(--brass-lo);
}
.msg__noise {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--brass);
  opacity: .62;
  letter-spacing: .06em;
  user-select: none;
  word-break: break-all;
}
.msg__locked-note {
  display: flex; align-items: center; gap: 6px;
  margin-top: 7px; padding-top: 7px;
  border-top: 1px dashed var(--brass-lo);
  font-size: 11.5px; color: var(--brass);
  cursor: pointer;
}
.msg__locked-note:hover { text-decoration: underline; }

.typing {
  display: flex; align-items: center; gap: 4px;
  padding: 0 26px 10px;
  color: var(--muted); font-size: 12px;
}
.typing i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--muted);
  animation: blink 1.3s infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
.typing span { margin-left: 6px; }
@keyframes blink { 0%,60%,100% { opacity: .25; } 30% { opacity: 1; } }

/* ── composer ─────────────────────────────────────────────────────── */

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--ink-850);
}
.composer__field {
  flex: 1;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 9px 14px;
  transition: border-color .16s var(--ease);
}
.composer__field:focus-within { border-color: var(--brass-lo); }
.composer__field textarea {
  width: 100%;
  font: inherit; font-size: 14.5px;
  color: var(--text);
  background: none; border: 0; resize: none;
  max-height: 168px; line-height: 1.45;
  display: block;
}
.composer__field textarea:focus { outline: none; }
.composer__field textarea::placeholder { color: #4E5679; }

.is-sealed-chat .composer__field { border-color: var(--brass-lo); }

.composer__seal {
  padding: 0 18px 12px;
  font-size: 11.5px; color: var(--brass);
  background: var(--ink-850);
  letter-spacing: .02em;
}

/* ═══════════════════════════ pickers ═══════════════════════════ */

.picker {
  position: fixed; z-index: 60;
  width: 352px; max-width: calc(100vw - 24px);
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: pop .16s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.picker__tabs {
  display: flex; gap: 2px; padding: 8px;
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
}
.picker__tab {
  font-family: var(--emoji); font-size: 17px;
  width: 34px; height: 34px; flex: none;
  border: 0; border-radius: 9px; background: transparent;
  cursor: pointer; display: grid; place-items: center;
  opacity: .5; transition: opacity .14s, background .14s;
}
.picker__tab:hover { background: var(--ink-700); opacity: .85; }
.picker__tab.is-active { background: var(--ink-700); opacity: 1; }

.picker__grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 8px;
  max-height: 292px; overflow-y: auto;
}
.picker__grid button {
  aspect-ratio: 1;
  font-family: var(--emoji); font-size: 22px;
  border: 0; border-radius: 9px; background: transparent;
  cursor: pointer; transition: background .12s, transform .12s var(--ease);
  display: grid; place-items: center;
}
.picker__grid button:hover { background: var(--ink-700); transform: scale(1.14); }

.picker__grid--stickers { grid-template-columns: repeat(4, 1fr); }
.picker__grid--stickers button { font-size: 44px; border-radius: var(--r-md); }

/* ═══════════════════════════ modals ═══════════════════════════ */

.scrim {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(4,6,14,.72);
  backdrop-filter: blur(3px);
  animation: fade .18s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  position: fixed; z-index: 80;
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(460px, calc(100vw - 32px));
  max-height: min(88dvh, 780px);
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: rise .2s var(--ease) both;
}
.modal--wide { width: min(620px, calc(100vw - 32px)); }
@keyframes rise { from { opacity: 0; transform: translate(-50%,-46%) scale(.985); } }

.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.modal__head h2 {
  font-family: var(--display); font-weight: 700; font-size: 17px;
  margin: 0; letter-spacing: -.01em;
}
.modal__body { padding: 20px 18px; overflow-y: auto; min-height: 0; }
.modal__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line-soft);
}
.modal__foot-actions { display: flex; gap: 8px; }

.fingerprint { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.fingerprint code {
  display: block;
  font-family: var(--mono); font-size: 13px;
  color: var(--signal);
  background: var(--ink-850);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 10px 12px; margin: 6px 0 8px;
  word-break: break-all; letter-spacing: .08em;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px 5px 6px;
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600;
}
.chip button {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px;
}
.chip button:hover { color: var(--alert); }

.stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 18px; }
.stat {
  background: var(--ink-850); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: 13px; text-align: center;
}
.stat b { display: block; font-family: var(--mono); font-size: 16px; color: var(--signal); }
.stat span { font-size: 11px; color: var(--muted); }

.peer {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--line-soft); border-radius: var(--r-md);
  margin-bottom: 7px;
  background: var(--ink-850);
}
.peer__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--alert); flex: none; }
.peer__dot.is-on { background: var(--signal); }
.peer__body { flex: 1; min-width: 0; display: grid; }
.peer__body b { font-family: var(--mono); font-size: 12.5px; }
.peer__body i { font-style: normal; font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══════════════ the key card — signature element ═══════════════ */

.phrase-lede { margin: 0 0 20px; font-size: 13.5px; color: var(--text-dim); line-height: 1.6; }

.keycard {
  border: 1px solid var(--brass-lo);
  border-radius: var(--r-md);
  background:
    linear-gradient(180deg, rgba(227,168,87,.05), transparent 40%),
    var(--ink-850);
  overflow: hidden;
}
.keycard__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px dashed var(--brass-lo);
}
.keycard__title {
  font-family: var(--display); font-weight: 700;
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--brass);
}
.keycard__count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.keycard__count b { color: var(--text); }

.keycard__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border-bottom: 1px dashed var(--brass-lo);
}
.wordcell {
  display: flex; align-items: center; gap: 7px;
  background: var(--ink-850);
  padding: 8px 9px;
  transition: background .14s var(--ease);
}
.wordcell:focus-within { background: var(--ink-750); }
.wordcell__n {
  font-family: var(--mono); font-size: 10px;
  color: var(--brass-lo); font-weight: 700;
  min-width: 15px; text-align: right; flex: none;
}
.wordcell input {
  width: 100%; min-width: 0;
  font-family: var(--mono); font-size: 12.5px;
  background: none; border: 0; color: var(--text);
  padding: 0;
}
.wordcell input:focus { outline: none; }
.wordcell input::placeholder { color: #3B4368; }
.wordcell.is-bad { background: rgba(255,107,129,.09); }
.wordcell.is-bad input { color: var(--alert); }
.wordcell.is-ok .wordcell__n { color: var(--brass); }

.keycard__foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; font-size: 11.5px;
}
.keycard__hint { color: var(--muted); }
.keycard__strength { font-family: var(--mono); color: var(--brass); font-size: 11px; }

.phrase-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.phrase-actions .btn { padding: 8px 13px; font-size: 12.5px; }

.qr-box {
  margin-top: 18px; padding: 18px;
  background: var(--ink-850);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  text-align: center;
}
.qr-box__code { display: inline-block; background: #fff; padding: 12px; border-radius: 10px; line-height: 0; }
.qr-box__code img, .qr-box__code canvas { display: block; }
.qr-box video {
  width: 100%; max-width: 340px; border-radius: var(--r-md);
  background: #000; aspect-ratio: 4/3; object-fit: cover;
}

/* ═══════════════════════════ toasts ═══════════════════════════ */

.toasts {
  position: fixed; z-index: 200; bottom: 22px; left: 50%;
  transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 10px 20px;
  font-size: 13.5px;
  box-shadow: var(--shadow-2);
  animation: toast-in .22s var(--ease) both;
  max-width: 90vw;
}
.toast--bad { border-color: rgba(255,107,129,.4); color: #FFA3B1; }
.toast--good { border-color: var(--signal-lo); color: var(--signal); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ═══════════════════════════ responsive ═══════════════════════════ */

@media (max-width: 1020px) {
  .screen--auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-panel { align-items: center; }
}

@media (max-width: 760px) {
  .screen--app { grid-template-columns: 1fr; }
  .sidebar { grid-column: 1; }
  .chat {
    position: fixed; inset: 0; z-index: 40;
    transform: translateX(100%);
    transition: transform .26s var(--ease);
  }
  body.is-chat-open .chat { transform: none; }
  .chat__back { display: grid; }
  .msg { max-width: 84%; }
  .keycard__grid { grid-template-columns: repeat(2, 1fr); }
  .picker { width: calc(100vw - 20px); }
  .modal { width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ═════════════════════════════════════════════════════════════════════
   DELIVERY STATE, REACTIONS, PRESENCE, OUTBOX
   ═════════════════════════════════════════════════════════════════════ */

/* Ticks. Colour carries the meaning, so each state also differs in shape
   or opacity — roughly 1 in 12 men cannot separate these hues. */
.msg__tick { font-size: 11px; letter-spacing: -2px; transition: color .2s; }
.msg__tick.is-sent      { color: var(--muted); }
.msg__tick.is-delivered { color: var(--text); opacity: .75; }
.msg__tick.is-read      { color: var(--signal); opacity: 1; }
.msg__tick.is-pending   { color: var(--muted); letter-spacing: 0; opacity: .8; }
.msg__tick.is-failed    { color: var(--alert); letter-spacing: 0; font-weight: 700; }

/* A message still sitting in the outbox reads as provisional, not broken. */
.msg--pending .msg__bubble { opacity: .62; border-style: dashed; }
.msg--failed  .msg__bubble { border-color: var(--alert); }

/* ── reactions ─────────────────────────────────────────────────────── */

.msg { position: relative; }

.msg__react {
  position: absolute; top: 2px;
  width: 26px; height: 26px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--ink-750);
  color: var(--muted);
  font-size: 13px; line-height: 1;
  cursor: pointer;
  opacity: 0; transform: scale(.85);
  transition: opacity .14s, transform .14s, color .14s, border-color .14s;
}
.msg:not(.msg--out) .msg__react { right: -32px; }
.msg--out .msg__react           { left: -32px; }
.msg:hover .msg__react,
.msg__react:focus-visible { opacity: 1; transform: scale(1); }
.msg__react:hover { color: var(--brass); border-color: var(--brass-lo); }

.msg__reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin: 5px 0 0;
}
.msg--out .msg__reactions { justify-content: flex-end; }

.rx {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink-750);
  color: var(--text);
  font: inherit; font-size: 12px; line-height: 1.5;
  cursor: pointer;
  transition: border-color .14s, background .14s, transform .1s;
}
.rx:hover  { border-color: var(--brass-lo); }
.rx:active { transform: scale(.94); }
/* Your own reaction is outlined, not just tinted, so it survives a
   colour-blind reading and a dimmed screen. */
.rx.is-mine {
  border-color: var(--brass);
  background: var(--brass-glow);
  box-shadow: inset 0 0 0 1px var(--brass-glow);
}
.rx__e { font-size: 13px; }
.rx__n { color: var(--muted); font-variant-numeric: tabular-nums; }
.rx.is-mine .rx__n { color: var(--brass); }

/* the quick bar that opens over a message */
.rxbar {
  position: absolute; z-index: 40; top: -40px; left: 0;
  display: flex; gap: 2px; padding: 4px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  animation: rxbar-in .13s ease-out;
}
.msg--out .rxbar { left: auto; right: 0; }
@keyframes rxbar-in {
  from { opacity: 0; transform: translateY(4px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
.rxbar__b {
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent;
  font-size: 17px; line-height: 1;
  cursor: pointer;
  transition: background .12s, transform .12s;
}
.rxbar__b:hover { background: var(--ink-700); transform: scale(1.16); }
.rxbar__b.is-mine { background: var(--brass-glow); }
.rxbar__more { font-size: 15px; color: var(--muted); }

/* ── presence in the chat header ───────────────────────────────────── */

#chat-avatar { position: relative; }
#chat-presence {
  position: absolute; right: -1px; bottom: -1px;
  opacity: 0; transition: opacity .2s;
}
#chat-presence.is-online { opacity: 1; background: var(--signal); }

/* ── connectivity ──────────────────────────────────────────────────── */

.linkbar {
  padding: 7px 16px;
  background: rgba(255,107,129,.10);
  border-bottom: 1px solid rgba(255,107,129,.28);
  color: var(--alert);
  font-size: 12.5px; text-align: center;
}

.outbox {
  margin: 0 14px 6px;
  padding: 5px 10px;
  align-self: flex-start;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--ink-800);
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}

@media (prefers-reduced-motion: reduce) {
  .rxbar { animation: none; }
  .rxbar__b:hover { transform: none; }
  .msg__react { transition: opacity .01s; }
}

/* On a touch screen there is no hover, so the reaction button is always
   visible rather than unreachable. */
@media (hover: none) {
  .msg__react { opacity: .55; transform: none; }
  .msg:not(.msg--out) .msg__react { right: -30px; }
  .msg--out .msg__react           { left: -30px; }
}

/* Offline: the composer still works — anything typed is encrypted and queued —
   so the cue is a muted send button, not a disabled form. Blocking input
   would lose the message the person was in the middle of writing. */
body.is-offline .btn--send {
  background: var(--ink-700);
  border-color: var(--line);
  color: var(--muted);
}
body.is-offline #me-node-dot { background: var(--alert); }

/* ═════════════════════════════════════════════════════════════════════
   ATTACHMENTS
   ═════════════════════════════════════════════════════════════════════ */

.msg--media .msg__bubble--media { padding: 4px; overflow: hidden; }

.photo {
  position: relative; display: block;
  width: min(320px, 62vw); height: 0;
  border-radius: 10px; overflow: hidden;
  background: var(--ink-750);
  cursor: zoom-in;
}
.photo img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  /* The thumbnail rides inside the envelope, so it is already sharp enough
     to read; the blur only covers the moment before it paints. */
  transition: transform .3s, filter .3s;
}
.photo:hover img { transform: scale(1.03); }
.photo__open {
  position: absolute; left: 8px; bottom: 8px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(7,10,20,.72);
  color: var(--text); font-size: 11.5px;
  opacity: 0; transition: opacity .16s;
}
.photo:hover .photo__open { opacity: 1; }
.photo.is-loading::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(7,10,20,.55) url("data:image/svg+xml;charset=utf8,\
%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'\
%3E%3Ccircle cx='14' cy='14' r='11' fill='none' stroke='%23E3A857' stroke-width='2.5'\
 stroke-dasharray='40 30'%3E%3CanimateTransform attributeName='transform' type='rotate'\
 from='0 14 14' to='360 14 14' dur='.9s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E")
    center/28px no-repeat;
}

/* ── file card ── */

.file {
  display: flex; align-items: center; gap: 10px;
  min-width: 190px; max-width: 320px;
  padding: 4px 2px;
  cursor: pointer;
}
.file__icon {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border-radius: 9px;
  background: var(--ink-750);
  border: 1px solid var(--line);
  font-size: 17px;
}
.file__body { min-width: 0; flex: 1; }
.file__name {
  display: block; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file__meta { display: block; color: var(--muted); font-size: 11.5px; }
.file__go {
  flex: none; width: 30px; text-align: right;
  color: var(--brass); font-family: var(--mono); font-size: 12px;
}
.file:hover .file__icon { border-color: var(--brass-lo); }
.file.is-loading { opacity: .7; cursor: progress; }

/* ── voice note ── */

.voice { display: flex; align-items: center; gap: 9px; min-width: 200px; }
.voice__play {
  width: 34px; height: 34px; flex: none; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--brass-lo); border-radius: 50%;
  background: var(--brass-glow); color: var(--brass);
  font-size: 12px; cursor: pointer;
  transition: background .15s;
}
.voice__play:hover { background: rgba(227,168,87,.26); }
.voice__wave {
  display: flex; align-items: center; gap: 2px;
  height: 26px; flex: 1;
}
/* Peaks are computed once at record time, so the waveform draws without
   the audio ever being downloaded. */
.voice__wave i {
  flex: 1; min-width: 2px;
  background: var(--line);
  border-radius: 1px;
  transition: background .12s;
}
.voice__wave i.is-past { background: var(--brass); }
.voice__time {
  flex: none; color: var(--muted);
  font-family: var(--mono); font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.voice.is-loading .voice__play { opacity: .5; }
.msg--out .voice__wave i.is-past { background: var(--signal); }

/* ── upload progress ── */

.uploads { display: flex; flex-direction: column; gap: 5px; margin: 0 14px 6px; }
.up {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--ink-800);
  font-size: 12px;
}
.up__name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.up__size { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.up__bar {
  flex: none; width: 90px; height: 4px;
  border-radius: 999px; background: var(--ink-700); overflow: hidden;
}
.up__bar i {
  display: block; height: 100%; width: 0;
  background: var(--brass); transition: width .18s;
}
.up__pct {
  flex: none; width: 34px; text-align: right;
  color: var(--brass); font-family: var(--mono); font-size: 11px;
}
.up__x {
  flex: none; border: 0; background: none;
  color: var(--muted); cursor: pointer; font-size: 13px;
}
.up__x:hover { color: var(--alert); }

/* ── drop target ── */

.dropzone {
  position: absolute; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgba(7,10,20,.82);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.dropzone__inner {
  padding: 22px 30px;
  border: 2px dashed var(--brass-lo); border-radius: 14px;
  color: var(--brass); font-size: 14px;
}

/* ── recorder ── */

.recorder {
  display: flex; align-items: center; gap: 10px;
  margin: 0 14px 6px; padding: 8px 12px;
  border: 1px solid rgba(255,107,129,.32); border-radius: 10px;
  background: rgba(255,107,129,.07);
}
.recorder__dot {
  width: 9px; height: 9px; flex: none;
  border-radius: 50%; background: var(--alert);
  animation: rec-pulse 1.1s ease-in-out infinite;
}
@keyframes rec-pulse { 50% { opacity: .25; } }
.recorder__time {
  font-family: var(--mono); font-size: 13px; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.recorder__wave { flex: 1; }

/* ── lightbox ── */

.lightbox {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: rgba(4,6,14,.93);
  padding: 40px;
}
.lightbox img {
  max-width: 100%; max-height: calc(100vh - 120px);
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.lightbox__close, .lightbox__save {
  position: absolute; top: 18px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--ink-800); color: var(--text);
  padding: 7px 13px; font-size: 13px;
  cursor: pointer; text-decoration: none;
}
.lightbox__close { right: 18px; }
.lightbox__save { left: 18px; color: var(--brass); }
.lightbox__save:hover, .lightbox__close:hover { border-color: var(--brass-lo); }

.chat__inner { position: relative; }

@media (prefers-reduced-motion: reduce) {
  .recorder__dot { animation: none; }
  .photo:hover img { transform: none; }
}

/* A voice note that is currently playing keeps its button lit, so a long
   recording is still identifiable after scrolling away and back. */
.voice.is-playing .voice__play {
  background: var(--brass); color: var(--ink-900); border-color: var(--brass);
}

/* ═════════════════════════════════════════════════════════════════════
   NODES
   ═════════════════════════════════════════════════════════════════════ */

.peer { display: flex; align-items: center; gap: 10px; padding: 9px 2px; }
.peer.is-dead { opacity: .62; }
.peer__dot {
  width: 8px; height: 8px; flex: none; border-radius: 50%;
  background: var(--muted);
}
.peer__dot.is-on  { background: var(--signal); box-shadow: 0 0 0 3px rgba(85,214,194,.14); }
.peer__dot.is-bad { background: var(--alert); }
.peer__dot.is-off { background: var(--line); }
.peer__body { flex: 1; min-width: 0; }
.peer__body b { display: block; font-size: 13.5px; }
.peer__body i {
  display: block; color: var(--muted); font-style: normal;
  font-size: 11.5px; font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.peer__tag {
  margin-left: 7px; padding: 1px 6px;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 10px; font-weight: 400;
  font-family: var(--text-font, inherit);
}
.peer__acts { display: flex; gap: 3px; flex: none; }
.peer__btn {
  width: 26px; height: 26px; padding: 0;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--ink-750); color: var(--muted);
  font-size: 11px; cursor: pointer;
  transition: color .14s, border-color .14s;
}
.peer__btn:hover { color: var(--text); border-color: var(--brass-lo); }
.peer__btn--x:hover { color: var(--alert); border-color: #5B2733; }

.peer-add { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.peer-add__row { display: flex; gap: 7px; }
.peer-add__row input { flex: 1; }
.peer-add__note {
  margin-top: 8px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--ink-800); color: var(--muted); font-size: 12px;
}
.peer-add__note.is-bad { border-color: #5B2733; color: var(--alert); }
.btn--wide { width: 100%; margin-top: 9px; }

/* ── node picker on the sign-in card ── */

.nodepick { position: relative; margin-bottom: 14px; }
.nodepick__current {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--ink-800); color: var(--text);
  cursor: pointer; text-align: left;
  transition: border-color .14s;
}
.nodepick__current:hover { border-color: var(--brass-lo); }
.nodepick__dot {
  width: 7px; height: 7px; flex: none; border-radius: 50%;
  background: var(--signal);
}
.nodepick__label { flex: 1; min-width: 0; }
.nodepick__label b { display: block; font-size: 13px; }
.nodepick__label i {
  display: block; color: var(--muted); font-style: normal;
  font-size: 11px; font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nodepick__chev { color: var(--muted); font-size: 11px; }

.nodepick__menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  padding: 7px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--ink-800);
  box-shadow: 0 18px 42px rgba(0,0,0,.5);
}
.nodepick__list { max-height: 190px; overflow: auto; }
.nodepick__item {
  display: block; width: 100%; padding: 7px 9px;
  border: 0; border-radius: 8px; background: none;
  color: var(--text); text-align: left; cursor: pointer;
}
.nodepick__item:hover { background: var(--ink-750); }
.nodepick__item b { display: block; font-size: 12.5px; }
.nodepick__item i {
  display: block; color: var(--muted); font-style: normal;
  font-size: 11px; font-family: var(--mono);
}
.nodepick__item.is-current { background: var(--ink-750); cursor: default; }
.nodepick__here { color: var(--brass); font-size: 10.5px; }
.nodepick__add { display: flex; gap: 6px; margin-top: 7px; }
.nodepick__add input { flex: 1; }
.nodepick__note {
  margin: 8px 2px 2px; color: var(--muted); font-size: 11px; line-height: 1.45;
}

/* ═════════════════════════════════════════════════════════════════════
   PROFILES
   ═════════════════════════════════════════════════════════════════════ */

.modal--profile .modal__body { padding-top: 4px; }

.prof { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.prof__ava {
  width: 68px; height: 68px; flex: none;
  display: grid; place-items: center;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--ink-750) center/cover no-repeat;
  font-size: 32px;
}
/* A decrypted photo replaces the emoji entirely; the brass ring marks it as
   key material rather than decoration. */
.prof__ava.has-photo { border-color: var(--brass-lo); font-size: 0; }
.prof__id { min-width: 0; }
.prof__id b { display: block; font-size: 19px; font-family: var(--display); }
.prof__id i {
  display: block; color: var(--muted); font-style: normal;
  font-family: var(--mono); font-size: 12.5px;
}
.prof__seen { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.prof__seen.is-online { color: var(--signal); }

.prof__status {
  margin: 0 0 8px; padding: 8px 11px;
  border-left: 2px solid var(--brass-lo); border-radius: 0 8px 8px 0;
  background: var(--ink-800); font-size: 13.5px;
}
.prof__bio {
  margin: 0 0 12px; color: var(--text);
  font-size: 13.5px; line-height: 1.55; white-space: pre-wrap;
}

.prof__facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px; margin-bottom: 14px;
}
.fact {
  padding: 8px 10px;
  border: 1px solid var(--line-soft); border-radius: 9px;
  background: var(--ink-800);
}
.fact span { display: block; color: var(--muted); font-size: 11px; }
.fact b {
  display: block; margin-top: 2px;
  font-family: var(--mono); font-size: 12.5px; font-weight: 500;
}

.prof__note {
  margin-bottom: 12px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--ink-800); color: var(--muted); font-size: 12.5px;
}
.prof__acts { display: flex; flex-direction: column; gap: 8px; }
.prof__row { display: flex; gap: 8px; }
.prof__row .btn { flex: 1; }
.btn.is-quiet { background: var(--ink-750); border-color: var(--line); color: var(--muted); }

.prof__sub {
  margin: 18px 0 8px; font-size: 12px; font-weight: 500;
  color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
}

/* ── group editing ── */

.gp-edit {
  margin: 4px 0 12px; padding: 12px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--ink-800);
}
.gp-edit__row { display: flex; gap: 8px; margin-top: 4px; }
.gp-edit__row .btn { flex: 1; }

/* ── member rows ── */

.gmem { display: flex; align-items: center; gap: 10px; padding: 7px 2px; }
.gmem__body { flex: 1; min-width: 0; cursor: pointer; }
.gmem__body b { display: block; font-size: 13.5px; font-weight: 500; }
.gmem__body i {
  display: block; color: var(--muted); font-style: normal;
  font-size: 11.5px; font-family: var(--mono);
}
.gmem__you { color: var(--brass); font-family: inherit; font-size: 11px; }
.gmem__acts { display: flex; gap: 3px; flex: none; }
.gmem .ava { cursor: pointer; }

/* The header is a doorway to the profile, so it should look like one. */
#chat-head { cursor: pointer; }
#chat-head:hover .chat__title b { color: var(--brass); }
.msg__author { cursor: pointer; }
.msg__author:hover { color: var(--brass); }

/* ═════════════════════════════════════════════════════════════════════
   EDIT & DELETE
   ═════════════════════════════════════════════════════════════════════ */

.msg__more {
  position: absolute; top: 2px;
  width: 26px; height: 26px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--ink-750); color: var(--muted);
  font-size: 13px; line-height: 1; cursor: pointer;
  opacity: 0; transform: scale(.85);
  transition: opacity .14s, transform .14s, color .14s, border-color .14s;
}
.msg:not(.msg--out) .msg__more { right: -62px; }
.msg--out .msg__more           { left: -62px; }
.msg:hover .msg__more,
.msg__more:focus-visible { opacity: 1; transform: scale(1); }
.msg__more:hover { color: var(--brass); border-color: var(--brass-lo); }

.msgmenu {
  position: absolute; z-index: 45; top: 100%; left: 0;
  min-width: 178px; padding: 5px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--ink-800);
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.msg--out .msgmenu { left: auto; right: 0; }
.msgmenu__i {
  display: block; width: 100%; padding: 7px 10px;
  border: 0; border-radius: 7px; background: none;
  color: var(--text); font: inherit; font-size: 13px;
  text-align: left; cursor: pointer;
}
.msgmenu__i:hover { background: var(--ink-750); }
.msgmenu__i.is-danger { color: var(--alert); }
.msgmenu__i.is-danger:hover { background: rgba(255,107,129,.10); }

/* "изм." rather than a full timestamp: the fact of an edit is what matters
   to a reader, and the exact second is noise in a busy thread. */
.msg__edited { color: var(--muted); font-size: 10.5px; }

/* A message being edited stays visible and marked, so it is obvious which
   line the composer is about to overwrite. */
.msg.is-editing .msg__bubble {
  outline: 1px solid var(--brass-lo);
  outline-offset: 2px;
}

/* A deletion keeps the message's place in the thread. Collapsing the row
   would quietly reshuffle everything around it. */
.msg--gone .msg__bubble {
  background: transparent;
  border: 1px dashed var(--line);
}
.gone {
  display: flex; align-items: center; gap: 7px;
  color: var(--muted); font-size: 13px; font-style: italic;
}
.gone__icon { font-style: normal; opacity: .7; }

.editbar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 14px 6px; padding: 7px 11px;
  border: 1px solid var(--brass-lo); border-radius: 10px;
  background: var(--brass-glow);
}
.editbar__icon { color: var(--brass); font-size: 14px; }
.editbar__body { flex: 1; min-width: 0; }
.editbar__body b { display: block; color: var(--brass); font-size: 11.5px; }
.editbar__body i {
  display: block; color: var(--muted); font-style: normal; font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (hover: none) {
  .msg__more { opacity: .55; transform: none; }
  .msg:not(.msg--out) .msg__more { right: -58px; }
  .msg--out .msg__more           { left: -58px; }
}

/* ═════════════════════════════════════════════════════════════════════
   PHOTO AVATARS, REPLIES, FORWARDS
   ═════════════════════════════════════════════════════════════════════ */

/* An .ava is either an emoji glyph or a photo painted as a background. The
   glyph lives in its own span so a photo can replace it without disturbing
   anything else nested inside — the presence dot, for one. */
.ava { background-position: center; background-size: cover; overflow: hidden; }
.ava.has-photo { background-color: var(--ink-750); }
.ava.has-photo .ava__glyph { display: none; }
.prof__ava.has-photo { border-color: var(--brass-lo); }
#chat-avatar.has-photo, #me-avatar.has-photo { font-size: 0; }
/* The presence dot has to stay legible on top of a photograph. */
.ava.has-photo .presence { box-shadow: 0 0 0 2px var(--ink-850); }

/* ── quoted reply ── */

.quote {
  display: block; width: 100%; margin: 0 0 6px; padding: 5px 9px;
  border: 0; border-left: 2px solid var(--brass);
  border-radius: 0 7px 7px 0;
  background: rgba(227,168,87,.09);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: background .14s;
}
.quote:hover { background: rgba(227,168,87,.16); }
.quote__who {
  display: block; color: var(--brass);
  font-size: 11.5px; font-weight: 500;
}
.quote__text {
  display: block; color: var(--muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg--out .quote { border-left-color: var(--signal); background: rgba(85,214,194,.08); }
.msg--out .quote:hover { background: rgba(85,214,194,.15); }
.msg--out .quote__who { color: var(--signal); }

/* Jumping to a quoted message: a brief highlight, because scrolling alone
   leaves you hunting for which line you landed on. */
.msg.is-flash .msg__bubble {
  animation: flash 1.2s ease-out;
}
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 2px var(--brass); }
  100%    { box-shadow: 0 0 0 2px transparent; }
}

.fwd-mark {
  margin-bottom: 5px;
  color: var(--muted); font-size: 11.5px; font-style: italic;
}

.replybar { border-color: var(--signal-lo); background: rgba(85,214,194,.07); }
.replybar .editbar__icon,
.replybar .editbar__body b { color: var(--signal); }

/* ── forward picker ── */

.fwd__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 6px;
  border: 0; border-radius: 9px; background: none;
  color: var(--text); font: inherit; font-size: 13.5px;
  text-align: left; cursor: pointer;
}
.fwd__item:hover { background: var(--ink-750); }

@media (prefers-reduced-motion: reduce) {
  .msg.is-flash .msg__bubble { animation: none; box-shadow: 0 0 0 2px var(--brass); }
}

/* ═════════════════════════════════════════════════════════════════════
   PICTURE AVATARS & SVG EMOJI
   ═════════════════════════════════════════════════════════════════════ */

/* Every avatar is now an image — an uploaded photo or a pattern derived from
   the public key. No glyph, so no font metrics to fight and no baseline
   drift between platforms. */
.ava {
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-color: var(--ink-750);
  overflow: hidden;
  flex: none;
  font-size: 0;
  /* A squircle rather than a circle: it keeps more of the picture and reads
     as deliberate next to the square message bubbles. */
  border-radius: 30%;
}
.ava--sm { width: 32px; height: 32px; }
.ava--md { width: 40px; height: 40px; }
.ava--lg { width: 46px; height: 46px; }
/* A hairline ring separates a dark photo from a dark background without
   drawing attention to itself. */
.ava::after {
  content: ''; position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
  pointer-events: none;
}
.ava { position: relative; }
.prof__ava { border-radius: 26%; font-size: 0; }

.emo {
  width: 1.25em; height: 1.25em;
  vertical-align: -0.25em;
  object-fit: contain;
}
.is-jumbo .emo { width: 1.15em; height: 1.15em; vertical-align: -0.15em; }
.emo--tab { width: 20px; height: 20px; vertical-align: middle; }
.emo--sticker { width: 100%; height: 100%; }
.rx__e .emo { width: 15px; height: 15px; vertical-align: -3px; }
.picker__grid button .emo { width: 24px; height: 24px; }
.rxbar__b .emo { width: 21px; height: 21px; vertical-align: -4px; }

.picker__empty {
  grid-column: 1 / -1;
  padding: 28px 16px;
  color: var(--muted); font-size: 12.5px; text-align: center; line-height: 1.6;
}
.picker__empty code {
  color: var(--brass); font-family: var(--mono); font-size: 11.5px;
}

/* ── date separators ── */

.daysep {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 4px 10px;
  color: var(--muted); font-size: 11.5px;
}
.daysep::before, .daysep::after {
  content: ''; flex: 1; height: 1px; background: var(--line-soft);
}
.daysep span {
  padding: 3px 11px;
  border: 1px solid var(--line-soft); border-radius: 999px;
  background: var(--ink-800);
  white-space: nowrap;
}

/* ── jump to latest ── */

.jump {
  position: absolute; right: 20px; bottom: 92px; z-index: 12;
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px; height: 38px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--ink-800); color: var(--text);
  box-shadow: 0 10px 26px rgba(0,0,0,.45);
  cursor: pointer;
  animation: jump-in .16s ease-out;
}
.jump:hover { border-color: var(--brass-lo); }
.jump__arrow { font-size: 15px; line-height: 1; }
.jump__n {
  min-width: 19px; padding: 0 5px;
  border-radius: 999px; background: var(--brass); color: var(--ink-900);
  font-size: 11px; font-weight: 600; line-height: 19px; text-align: center;
}
@keyframes jump-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .jump { animation: none; } }

/* ═════════════════════════════════════════════════════════════════════
   FRIEND REQUESTS
   ═════════════════════════════════════════════════════════════════════ */

/* Above the chat list rather than inside it: a request is not a
   conversation, and burying it among chats is how it gets ignored. */
.reqbar {
  display: flex; align-items: center; gap: 9px; width: 100%;
  margin: 0 0 4px; padding: 9px 14px;
  border: 0; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(90deg, var(--brass-glow), transparent 70%);
  color: var(--text); font: inherit; font-size: 13px;
  text-align: left; cursor: pointer;
  transition: background .15s;
}
.reqbar:hover { background: linear-gradient(90deg, rgba(227,168,87,.22), transparent 70%); }
.reqbar__icon {
  display: grid; place-items: center;
  width: 24px; height: 24px; flex: none;
  border-radius: 50%; background: var(--brass); color: var(--ink-900);
  font-size: 13px; font-weight: 700;
}
.reqbar__text { flex: 1; }
.reqbar__count {
  min-width: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--brass); color: var(--ink-900);
  font-size: 11px; font-weight: 600; line-height: 20px; text-align: center;
}

.reqrow { display: flex; align-items: center; gap: 11px; padding: 9px 2px; }
.reqrow__body { flex: 1; min-width: 0; cursor: pointer; }
.reqrow__body b { display: block; font-size: 13.5px; font-weight: 500; }
.reqrow__body i {
  display: block; color: var(--muted); font-style: normal; font-size: 11.5px;
}
.reqrow__acts { display: flex; gap: 6px; flex: none; }
.btn--tiny { padding: 5px 11px; font-size: 12px; }

/* A chat that exists only for you until you speak. Marked, because an unsent
   chat and a quiet one look identical otherwise. */
.row__draft {
  margin-right: 5px; padding: 1px 6px;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 10px;
}
.list__hint {
  display: block; margin-top: 7px;
  color: var(--brass); font-size: 12px;
}

/* ═════════════════════════════════════════════════════════════════════
   TEXT FORMATTING
   ═════════════════════════════════════════════════════════════════════ */

.msg__text strong { font-weight: 650; }
.msg__text em { font-style: italic; }
.msg__text u { text-decoration: underline; text-underline-offset: 2px; }
.msg__text del { opacity: .62; text-decoration-thickness: 1.5px; }

.fmt-code {
  padding: 1px 5px;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--ink-850);
  font-family: var(--mono); font-size: .88em;
  /* A long token must wrap rather than stretch the bubble off-screen. */
  overflow-wrap: anywhere;
}
.fmt-pre {
  margin: 6px 0 2px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--ink-850);
  overflow-x: auto;
}
.fmt-pre code {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  white-space: pre;
}
.msg--out .fmt-code, .msg--out .fmt-pre { background: rgba(0,0,0,.24); }

.fmt-quote {
  display: block; margin: 3px 0; padding: 2px 0 2px 10px;
  border-left: 2px solid var(--brass-lo);
  color: var(--muted);
}
.msg--out .fmt-quote { border-left-color: var(--signal-lo); }

.fmt-link { color: var(--signal); text-decoration: none; overflow-wrap: anywhere; }
.fmt-link:hover { text-decoration: underline; }
.msg--out .fmt-link { color: var(--brass); }

/* A spoiler hides the text under a grain of static rather than a flat block:
   a solid rectangle reads as a redaction, which is a different message from
   "there is something here you can look at". */
.fmt-spoiler {
  position: relative;
  border-radius: 4px;
  color: transparent;
  background-color: var(--ink-700);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.22) 0.6px, transparent 0.7px),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,.18) 0.6px, transparent 0.7px),
    radial-gradient(circle at 45% 85%, rgba(255,255,255,.14) 0.6px, transparent 0.7px);
  background-size: 7px 7px, 11px 11px, 9px 9px;
  cursor: pointer;
  transition: color .18s, background-color .18s;
  user-select: none;
}
.fmt-spoiler * { visibility: hidden; }
.fmt-spoiler .emo { opacity: 0; }
.fmt-spoiler:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
.fmt-spoiler.is-open {
  color: inherit;
  background: rgba(227,168,87,.10);
  cursor: text;
  user-select: text;
}
.fmt-spoiler.is-open * { visibility: visible; }
.fmt-spoiler.is-open .emo { opacity: 1; }

/* Jumbo lone-emoji messages should not inherit code or quote framing. */
.msg__text.is-jumbo .fmt-code, .msg__text.is-jumbo .fmt-pre { font-size: 13px; }
