/* Nook — self-contained styles. No external fonts or assets.
   2026 refresh: indigo→violet gradient accent, layered surfaces, soft depth,
   rounder shapes, presence rings, glassy header, floating composer. */
:root {
  --bg: #edeff6;
  --panel: #ffffff;
  --panel-2: #f1f2f8;
  --text: #14151c;
  --muted: #6a7084;
  --border: #e3e5ef;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --accent-ink: #ffffff;
  --accent-soft: #ecedfe;
  --bubble-me: #6366f1;
  --bubble-me-grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --bubble-me-ink: #ffffff;
  --bubble-other: #eef0f7;
  --bubble-other-ink: #14151c;
  --danger: #e04343;
  --ok: #10b981;
  --ring: rgba(99, 102, 241, 0.32);
  --radius: 18px;
  --shadow: 0 14px 40px rgba(28, 28, 60, 0.12);
  --shadow-sm: 0 4px 14px rgba(28, 28, 60, 0.08);
  --header-bg: rgba(255, 255, 255, 0.72);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0d12;
    --panel: #15161e;
    --panel-2: #1c1e28;
    --text: #e9eaf1;
    --muted: #969bb1;
    --border: #272a37;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --accent-grad: linear-gradient(135deg, #818cf8, #a78bfa);
    --accent-ink: #ffffff;
    --accent-soft: #211f3a;
    --bubble-me: #6d64f2;
    --bubble-me-grad: linear-gradient(135deg, #6d64f2, #9168f0);
    --bubble-me-ink: #ffffff;
    --bubble-other: #20222d;
    --bubble-other-ink: #e9eaf1;
    --danger: #f06a6a;
    --ok: #34d399;
    --ring: rgba(129, 140, 248, 0.4);
    --shadow: 0 16px 44px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.4);
    --header-bg: rgba(21, 22, 30, 0.68);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: var(--accent); }
button { font-family: inherit; }

/* ---------- Centered card layout (join / login) ---------- */
.center {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.join-wrap { width: 100%; max-width: 420px; }
.card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

/* "Why Nook" advantages under the join card */
.perks { width: fit-content; max-width: 100%; margin: 20px auto 0; padding: 0 6px; display: grid; gap: 11px; }
.perks-title {
  text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.perk { display: flex; align-items: center; justify-content: flex-start; gap: 11px; font-size: 13.5px; color: var(--text); }
.perk-ic {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.brand .logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 18px;
  flex: none;
}
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.tagline { font-size: 16.5px; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; text-align: center; margin: 6px 0 0; text-wrap: balance; }
.tagline-name { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 750; }
.subtitle { color: var(--muted); font-size: 14px; margin: 4px 0 22px; text-align: center; text-wrap: balance; }
.room-badge {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: fit-content; margin: 0 auto 18px;
  background: var(--accent-soft); color: var(--accent);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}

/* ---------- Avatar picker (join page) ---------- */
.avatar-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 4px 0 6px; }
.avatar-preview {
  width: 78px; height: 78px; border-radius: 50%;
  border: 2px dashed var(--border); background: var(--panel-2);
  display: grid; place-items: center; cursor: pointer; overflow: hidden;
  padding: 0; position: relative;
}
.avatar-preview:hover { border-color: var(--accent); }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: none; }
.avatar-preview.has-img { border-style: solid; }
.avatar-preview.has-img img { display: block; }
.avatar-preview.has-img .avatar-plus { display: none; }
.avatar-plus { font-size: 30px; color: var(--muted); line-height: 1; }
.avatar-cap { background: none; border: none; color: var(--muted); font-size: 12.5px; cursor: pointer; padding: 2px 6px; }
.avatar-cap:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Recent rooms (landing) ---------- */
.recent { margin-bottom: 8px; }
.recent-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.recent-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.recent-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  text-align: left; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; color: var(--text); font-family: inherit;
}
.recent-main:hover { border-color: var(--accent); }
.recent-text { display: flex; flex-direction: column; min-width: 0; }
.recent-room { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-sub { font-size: 12px; color: var(--muted); }
.recent-x {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
  display: grid; place-items: center; transition: color .15s, border-color .15s, background .15s;
}
.recent-x:hover { border-color: var(--danger); color: var(--danger); background: var(--panel-2); }
.recent-or { display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 4px; }
.recent-or::before, .recent-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.recent-or span { padding: 0 10px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
/* Centre the field labels on the join screen */
#joinView label { text-align: center; }
input[type=text], input[type=password], input[type=email] {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 12px 16px;
  margin-top: 18px;
  border: none;
  border-radius: 12px;
  background: var(--accent-grad);
  color: var(--accent-ink);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: filter .15s, transform .02s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--border); width: auto; margin: 0; padding: 7px 12px; font-size: 13px; }
.btn.small { width: auto; margin: 0; padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.note { font-size: 12.5px; color: var(--muted); margin-top: 16px; text-align: center; }
.error { color: var(--danger); font-size: 13.5px; margin-top: 12px; min-height: 18px; }
.hidden { display: none !important; }

/* ---------- Chat layout ---------- */
.chat {
  display: flex; flex-direction: column;
  height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  position: relative;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: saturate(1.5) blur(16px);
  -webkit-backdrop-filter: saturate(1.5) blur(16px);
  position: sticky; top: 0; z-index: 5;
}
.chat-header .logo {
  width: 32px; height: 32px; border-radius: 11px;
  background: var(--accent-grad);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; flex: none;
  box-shadow: var(--shadow-sm);
}
.chat-title { flex: 1; min-width: 0; }
.chat-title .name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title .name.editable { cursor: pointer; border-radius: 8px; padding: 1px 6px; margin: -1px -6px; display: inline-block; max-width: calc(100% + 12px); vertical-align: top; transition: background .15s; }
.chat-title .name.editable::after { content: '✎'; font-weight: 500; font-size: 13px; color: var(--muted); margin-left: 6px; opacity: .55; transition: opacity .15s; }
.chat-title .name.editable:hover, .chat-title .name.editable:focus-visible { background: var(--accent-soft); outline: none; }
.chat-title .name.editable:hover::after, .chat-title .name.editable:focus-visible::after { opacity: 1; color: var(--accent); }
.chat-title .name-input { display: block; width: 100%; max-width: 320px; font: inherit; font-weight: 700; font-size: 16px; color: inherit; background: var(--panel); border: 1.5px solid var(--accent); border-radius: 8px; padding: 2px 7px; margin: -3px 0 0 -8px; outline: none; box-shadow: 0 0 0 3px var(--ring); }
.chat-title .name-input.err { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(224,67,67,.18); }
.chat-title .status { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 24%, transparent); }
.dot.off { background: var(--muted); box-shadow: none; }

.iconbtn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  border-radius: 11px; padding: 7px 11px; font-size: 13px; cursor: pointer; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.iconbtn:hover { border-color: var(--accent); }
.iconbtn .btn-ic { display: none; } /* label text by default; icon-only on mobile */

.me-btn {
  border: 1px solid var(--border); background: var(--panel-2);
  border-radius: 50%; padding: 2px; cursor: pointer; flex: none;
  width: 38px; height: 38px; display: grid; place-items: center;
}
.me-btn:hover { border-color: var(--accent); }
.me-btn .avatar { width: 30px; height: 30px; font-size: 13px; }

/* ---------- Modal (profile editor) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(0,0,0,.5);
  display: grid; place-items: center; padding: 24px;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; width: 100%; max-width: 340px; text-align: center;
}
.modal-title { margin: 0 0 16px; font-size: 17px; }
.profile-av { width: 96px; height: 96px; margin: 0 auto 12px; }
.profile-av .avatar { width: 96px; height: 96px; font-size: 34px; }
.profile-name { font-weight: 600; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.modal-actions .btn { width: auto; margin: 0; }
.modal-card .btn.secondary { margin-top: 14px; }
.modal .error { text-align: center; }
.modal-card input[type="text"], .modal-card input[type="password"] { margin: 8px 0 0; text-align: center; }
.modal-card .modal-actions .btn.secondary { margin-top: 0; }

.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 2px;
  overscroll-behavior: contain;
}
.day-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 8px; }

.msg-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.msg-row.me { flex-direction: row-reverse; }
.msg-row.grouped { margin-top: 2px; }
.av-slot { width: 30px; flex: none; }
.av-slot .avatar { width: 30px; height: 30px; font-size: 13px; box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--ring); }
.msg { display: flex; flex-direction: column; max-width: 76%; min-width: 0; }
.msg .who { font-size: 12px; color: var(--muted); margin: 0 0 3px 4px; font-weight: 600; }
.bubble {
  padding: 10px 14px; border-radius: 18px;
  background: var(--bubble-other); color: var(--bubble-other-ink);
  box-shadow: var(--shadow-sm);
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
  font-size: 14.5px;
}
.msg .time { font-size: 11px; color: var(--muted); margin: 3px 0 0 4px; }

.msg.me { align-items: flex-end; }
.msg.me .bubble { background: var(--bubble-me-grad); color: var(--bubble-me-ink); }
.msg.me .time, .msg.me .who { margin-left: 0; margin-right: 4px; }

.sys { text-align: center; color: var(--muted); font-size: 12.5px; margin: 10px 0; }

.typing { min-height: 18px; padding: 0 20px 2px; font-size: 12.5px; color: var(--muted); font-style: italic; }

.composer {
  display: flex; gap: 8px; align-items: flex-end;
  margin: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  padding: 7px 7px 7px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.composer textarea {
  flex: 1; resize: none;
  border: none; border-radius: 16px;
  background: transparent; color: var(--text);
  padding: 10px 6px; font-size: 15px; font-family: inherit;
  max-height: 140px; outline: none; line-height: 1.4;
}
.composer textarea:focus { border-color: transparent; box-shadow: none; }
.send {
  border: none; background: var(--accent-grad); color: var(--accent-ink);
  border-radius: 50%; width: 44px; height: 44px; padding: 0; font-weight: 600; font-size: 16px; cursor: pointer;
  flex: none; display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
  transition: filter .15s, transform .05s;
}
.send:hover { filter: brightness(1.08); }
.send:active { transform: scale(.94); }
.send:disabled { opacity: .5; cursor: not-allowed; }

.attach {
  flex: none;
  width: 40px; height: 40px;
  border: none; background: transparent; color: var(--muted);
  border-radius: 50%; font-size: 21px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.attach:hover { background: var(--panel-2); color: var(--accent); }

/* ---------- Upload bar (staged file) ---------- */
.upload-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-top: 1px solid var(--border);
  background: var(--panel-2);
}
.up-thumb {
  width: 42px; height: 42px; border-radius: 8px; flex: none;
  background: var(--border) center/cover no-repeat;
  display: grid; place-items: center; font-size: 20px;
  overflow: hidden;
}
.up-info { flex: 1; min-width: 0; }
.up-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.progress { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width .15s; }

/* ---------- Media in messages ---------- */
.att-media { margin-bottom: 3px; }
.att-img {
  max-width: min(340px, 72vw); max-height: 380px;
  border-radius: 18px; display: block; cursor: zoom-in;
  background: var(--bubble-other); object-fit: cover;
  box-shadow: var(--shadow-sm);
}
.msg.me .att-img, .msg.me .att-video { margin-left: auto; }
.att-video {
  max-width: min(360px, 78vw); max-height: 420px;
  border-radius: 18px; display: block; background: #000;
  box-shadow: var(--shadow-sm);
}
.att-file {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--bubble-other); color: var(--bubble-other-ink);
  padding: 10px 14px; border-radius: 16px; text-decoration: none; font-size: 14px;
}
.msg.me .att-file { background: var(--bubble-me-grad); color: var(--bubble-me-ink); }
.att-file-ic { font-size: 18px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.85);
  display: grid; place-items: center; padding: 24px; cursor: zoom-out;
}
.lightbox img { max-width: 96vw; max-height: 94vh; border-radius: 10px; box-shadow: 0 10px 50px rgba(0,0,0,.5); }

/* ---------- Presence bar (invite · you · others) ---------- */
.presence-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--panel); min-height: 58px; gap: 8px;
}
.presence-left { justify-self: start; display: flex; align-items: center; }
.presence-center { justify-self: center; display: flex; align-items: center; }
.presence-right { justify-self: end; display: flex; align-items: center; padding-left: 8px; overflow: hidden; }

/* Your own avatar, centred and slightly larger with a ring */
.me-av { border: none; background: none; padding: 0; cursor: pointer; line-height: 0; border-radius: 50%; }
.me-av .avatar { width: 42px; height: 42px; font-size: 16px; box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.me-av:hover .avatar { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); filter: brightness(1.03); }

/* Other people, overlapping cluster on the right */
.presence-right .p-av { border: none; background: none; padding: 0; cursor: pointer; line-height: 0; margin-left: -6px; transition: transform .12s; }
.presence-right .p-av:first-child { margin-left: 0; }
.presence-right .p-av:hover { transform: translateY(-2px); z-index: 2; }
.presence-right .avatar { width: 32px; height: 32px; font-size: 13px; box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--ring); }
.presence-more { flex: none; font-size: 12.5px; color: var(--muted); font-weight: 600; padding-left: 8px; }

/* Nicer invite pill */
.invite-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid transparent; border-radius: 999px;
  padding: 7px 14px 7px 11px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s;
}
.invite-pill:hover { box-shadow: 0 0 0 3px var(--accent-soft); }
.invite-pill .ip-plus { font-size: 15px; line-height: 1; }
#presenceLeft { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.invite-pill.app-pill { background: var(--panel-2); color: var(--text); }
/* ---------- Chat tabs (one pill per open chat) ---------- */
.tabs-bar {
  display: flex; align-items: center; gap: 6px; flex: none;
  padding: 7px 12px; border-bottom: 1px solid var(--border); background: var(--panel);
  overflow-x: auto; scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; flex: none; max-width: 200px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
}
.tab:hover { border-color: var(--accent); }
.tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tab-main {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0;
  border: none; background: none; color: inherit; cursor: pointer;
  font: 600 13px var(--font); padding: 4px 11px 4px 4px; border-radius: 999px;
}
.tab.active .tab-main { padding-right: 4px; }
.tab-main:focus-visible, .tab-x:focus-visible, .tab-add:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab-ini {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800;
}
.tab-lock { font-size: 11px; opacity: .8; }
.tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; flex: none;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
  animation: tabpop .25s cubic-bezier(.34,1.7,.5,1);
}
.tab-x {
  width: 22px; height: 22px; margin-right: 4px; padding: 0; flex: none;
  border: none; background: none; color: inherit; opacity: .6; cursor: pointer;
  border-radius: 50%; font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.tab-x:hover { opacity: 1; background: var(--panel); }
.tab-add {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  border: 1px dashed var(--border); background: none; color: var(--muted);
  font-size: 16px; cursor: pointer; display: grid; place-items: center;
}
.tab-add:hover { border-color: var(--accent); color: var(--accent); }
@keyframes tabpop { from { transform: scale(0); } to { transform: scale(1); } }
@media (max-width: 600px) { .tabs-bar { padding: 6px 10px; } .tab { max-width: 150px; } }
@media (prefers-reduced-motion: reduce) { .tab-badge { animation: none; } }

/* ---------- Your devices (profile) + continue on another device ---------- */
.devices { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 8px; text-align: center; }
.devices-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.devices .btn.small { width: 100%; margin: 0; }
.signout-confirm { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.signout-confirm p { margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.btn.danger-fill { background: var(--danger); color: #fff; }
.devices-msg { font-size: 13px; color: var(--ok); min-height: 0; }
.devices-msg:empty { display: none; }
.handoff-card { max-width: 340px; }
.qr-box {
  width: 220px; height: 220px; margin: 4px auto 10px; padding: 10px;
  background: #fff; border-radius: 16px; border: 1px solid var(--border);
  display: grid; place-items: center; box-shadow: var(--shadow-sm); position: relative;
}
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-wait { font-size: 13px; color: #6a7084; }
.qr-box.expired svg, .qr-box.done svg { opacity: .12; }
.qr-box.done::after {
  content: "✓"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 72px; font-weight: 800; color: var(--ok);
}
.handoff-status { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 12px; font-variant-numeric: tabular-nums; min-height: 18px; }
.handoff-fine { font-size: 12px; color: var(--muted); margin: 12px 0 0; line-height: 1.45; }
@media (max-width: 600px) { .desk-only { display: none !important; } }

/* Private-chat badge (shown instead of the invite pill in a DM room) */
.dm-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 13px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}

/* Avatar tap menu (nudge) */
.avatar-menu {
  position: fixed; z-index: 60; width: 160px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 10px;
  text-align: center;
}
.avatar-menu .am-name { font-weight: 600; font-size: 14px; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar-menu .btn { width: 100%; margin: 0; }

/* ---------- Invite button in people panel ---------- */
.invite-btn { width: 100%; margin: 2px 0 10px; }
.people-nudge {
  margin-left: auto; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); border-radius: 8px; padding: 3px 9px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.people-nudge:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Media-safe note + voice recorder ---------- */
.up-safe { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.attach.mic { font-size: 18px; }
.attach.mic.armed { background: var(--danger); color: #fff; border-color: var(--danger); }
.rec-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-top: 1px solid var(--border); background: var(--panel-2);
}
.rec-bar .rec-label { color: var(--muted); font-size: 13px; flex: 1; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; flex: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- Audio message ---------- */
.att-audio { display: block; margin-bottom: 3px; }
.att-audio audio { width: min(280px, 70vw); height: 40px; }
.msg.me .att-audio audio { margin-left: auto; }

/* ---------- Terms checkbox ---------- */
.tos-row { display: flex; align-items: center; justify-content: center; gap: 9px; font-weight: 400; font-size: 13px; color: var(--muted); margin: 16px 0 0; cursor: pointer; text-align: center; }
.tos-row input { width: 16px; height: 16px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }

/* ---------- Modal extras ---------- */
.modal-note { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; text-align: center; }
.modal-card .linkbox code { font-size: 12.5px; }
.invite-count { font-size: 13px; color: var(--muted); text-align: center; margin: 12px 0 4px; }

/* ---------- Nudge shake + flash (gentle) ---------- */
/* A soft, brief glow rather than a full-screen violet wash. */
.nudge-flash { position: fixed; inset: 0; z-index: 200; background: radial-gradient(130% 90% at 50% 50%, transparent 55%, var(--accent) 100%); opacity: 0; pointer-events: none; animation: nudgeflash .6s ease; }
@keyframes nudgeflash { 0% { opacity: 0; } 25% { opacity: .14; } 100% { opacity: 0; } }

/* Gentle wobble — a nudge, not an earthquake. */
.shake { animation: shake .5s ease; }
@keyframes shake {
  0%   { transform: translate(0, 0) rotate(0); }
  20%  { transform: translate(-4px, 2px) rotate(-.5deg); }
  40%  { transform: translate(4px, -2px) rotate(.5deg); }
  60%  { transform: translate(-3px, 1px) rotate(-.3deg); }
  80%  { transform: translate(2px, -1px) rotate(.2deg); }
  100% { transform: translate(0, 0) rotate(0); }
}
@media (prefers-reduced-motion: reduce) { .shake { animation: none; } }
.iconbtn.muted { color: var(--muted); }

/* ---------- Presence popover ---------- */
.people {
  position: absolute; right: 12px; top: 58px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  min-width: 200px; max-width: 260px; padding: 10px; z-index: 20; border-radius: 16px;
}
.people h4 { margin: 4px 6px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.people ul { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.people li { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 8px; font-size: 14px; }
.people li:hover { background: var(--panel-2); }
/* ---------- Alerts settings panel ---------- */
.alerts-panel {
  position: absolute; right: 12px; top: 58px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  min-width: 240px; max-width: 280px; padding: 12px; z-index: 20; border-radius: 16px;
}
.alerts-panel h4 { margin: 4px 6px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.al-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 6px; font-size: 14px; cursor: pointer; border-radius: 8px; }
.al-row:hover { background: var(--panel-2); }
.al-row input { width: 17px; height: 17px; flex: none; accent-color: var(--accent); cursor: pointer; }

/* Nudge picker list */
#nudgeList { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.nudge-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.nudge-item:hover { background: var(--panel-2); }
.nudge-nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nudge-go { font-size: 16px; }
.nudge-empty { color: var(--muted); font-size: 13px; padding: 8px 6px; text-align: center; }

.avatar { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ---------- Admin ---------- */
.admin-wrap { max-width: 820px; margin: 0 auto; padding: 24px 18px 60px; }
.admin-top { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.admin-top .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-grad);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; flex: none;
}
.admin-top h1 { font-size: 20px; margin: 0; flex: 1; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 12px; text-align: center; box-shadow: var(--shadow); }
.stat-num { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-lbl { font-size: 12px; color: var(--muted); margin-top: 5px; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.instant-btn { margin-bottom: 12px; }

.newroom { display: flex; gap: 10px; margin-bottom: 22px; }
.newroom input { margin: 0; }
.newroom .btn { margin: 0; width: auto; padding: 12px 18px; white-space: nowrap; }

.room {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.room .row1 { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.room .rname { font-weight: 700; font-size: 16px; flex: 1; display: flex; align-items: center; gap: 8px; }
.lock-badge {
  font-size: 11px; font-weight: 600; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px;
}
.room .meta { font-size: 12.5px; color: var(--muted); }
.linkbox {
  display: flex; gap: 8px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; margin: 8px 0;
}
.linkbox code { flex: 1; font-size: 13px; overflow-x: auto; white-space: nowrap; color: var(--text); }
.room .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

@media (max-width: 600px) {
  .chat { border-left: none; border-right: none; }
  .msg { max-width: 86%; }
  .newroom { flex-direction: column; }
  .newroom .btn { width: 100%; }
  /* Compact header: icon-only People/Leave so the room name keeps its space. */
  .chat-header { gap: 7px; padding: 10px 12px; }
  .chat-header .iconbtn { padding: 7px 9px; font-size: 15px; line-height: 1; }
  .iconbtn .btn-lbl { display: none; }
  .iconbtn .btn-ic { display: inline; }
}

/* ============================================================
   Reactions, replies, emoji, calls, missed-call bubble
   ============================================================ */

/* Composer emoji button */
.attach.emoji { font-size: 20px; }

/* ---------- Message hover actions (react / reply) ---------- */
.msg { position: relative; }
.msg-actions {
  position: absolute; top: -12px; z-index: 3;
  display: flex; gap: 4px; opacity: 0; pointer-events: none;
  transition: opacity .12s;
}
.msg:not(.me) .msg-actions { right: 0; }
.msg.me .msg-actions { left: 0; }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; pointer-events: auto; }
.ma-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-size: 14px; cursor: pointer; line-height: 1;
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.ma-btn:hover { border-color: var(--accent); color: var(--accent); }
/* On touch screens there's no hover — always show the actions faintly */
@media (hover: none) {
  .msg-actions { opacity: .6; pointer-events: auto; }
}

/* ---------- Reaction chips ---------- */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reactions:not(.has) { display: none; }
.msg.me .reactions { justify-content: flex-end; }
.react-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border); background: var(--panel-2);
  border-radius: 999px; padding: 2px 8px; font-size: 12.5px; cursor: pointer;
  color: var(--text); line-height: 1.4;
}
.react-chip:hover { border-color: var(--accent); }
.react-chip.mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.rc-em { font-size: 13px; }
.rc-ct { font-weight: 600; }

/* ---------- Reaction picker popover ---------- */
.react-pop {
  position: fixed; z-index: 140;
  display: flex; gap: 2px; flex-wrap: wrap; max-width: 260px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow); padding: 6px 8px;
}
.rp-em {
  border: none; background: none; cursor: pointer; font-size: 20px;
  line-height: 1; padding: 4px; border-radius: 8px; transition: transform .1s, background .1s;
}
.rp-em:hover { transform: scale(1.25); background: var(--panel-2); }

/* ---------- Emoji picker (composer) ---------- */
.emoji-pop {
  position: absolute; bottom: 70px; right: 14px; z-index: 130;
  width: min(320px, 90vw); max-height: 240px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.ep-em {
  border: none; background: none; cursor: pointer; font-size: 20px;
  line-height: 1; padding: 6px; border-radius: 8px;
}
.ep-em:hover { background: var(--panel-2); }

/* ---------- Reply bar (composer) + quote in messages ---------- */
.reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-top: 1px solid var(--border);
  background: var(--panel-2);
}
.reply-bar .reply-ic { font-size: 16px; color: var(--accent); flex: none; }
.reply-info { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 10px; }
.reply-to { font-size: 12px; font-weight: 700; color: var(--accent); }
.reply-text { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-quote {
  border-left: 3px solid var(--accent); padding: 4px 10px; margin-bottom: 5px;
  background: var(--accent-soft);
  border-radius: 8px; cursor: pointer; max-width: 100%; min-width: 0;
}
.reply-quote .rq-name { display: block; font-size: 11.5px; font-weight: 700; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-quote .rq-text { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Flash highlight when jumping to a quoted message */
.flash-hl .bubble, .flash-hl .att-media, .flash-hl .att-file, .flash-hl .att-audio { animation: flashHl 1.3s ease; }
@keyframes flashHl { 0%,100% { box-shadow: none; } 20% { box-shadow: 0 0 0 3px var(--accent); } }

/* People-panel call button */
.people-call {
  border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); border-radius: 8px; padding: 3px 8px; font-size: 13px; cursor: pointer;
}
.people-call:hover { border-color: var(--accent); }

/* ---------- Call UI ---------- */
.call-card { max-width: 320px; }
.call-av { width: 92px; height: 92px; margin: 0 auto 14px; }
.call-av .avatar { width: 92px; height: 92px; font-size: 34px; animation: ringpulse 1.4s ease-in-out infinite; }
@keyframes ringpulse { 0%,100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 12px transparent; } }
.call-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.call-actions .btn { width: auto; margin: 0; padding: 12px 22px; }
.call-accept { background: var(--ok); }
.call-decline { background: var(--danger); }

.call-overlay {
  position: fixed; inset: 0; z-index: 180; background: #0a0b0f;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.remote-video { width: 100%; height: 100%; object-fit: contain; background: #0a0b0f; }
.local-video {
  position: absolute; right: 16px; top: 16px;
  width: 128px; height: 170px; object-fit: cover;
  border-radius: 12px; border: 2px solid rgba(255,255,255,.3);
  background: #15161c; box-shadow: 0 6px 24px rgba(0,0,0,.5); transform: scaleX(-1);
}
.call-top {
  position: absolute; top: 16px; left: 16px; z-index: 2;
  color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.call-peer { font-size: 18px; font-weight: 700; }
.call-status { font-size: 13px; opacity: .85; margin-top: 2px; }
.call-secure { font-size: 12px; opacity: .8; margin-top: 6px; background: rgba(0,0,0,.35); padding: 3px 9px; border-radius: 999px; display: inline-block; }
.call-controls {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 2;
  display: flex; gap: 16px;
}
.call-ctrl {
  width: 58px; height: 58px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.18); color: #fff;
  font-size: 22px; cursor: pointer; display: grid; place-items: center;
  backdrop-filter: blur(6px); transition: background .12s;
}
.call-ctrl:hover { background: rgba(255,255,255,.3); }
.call-ctrl.off { background: #fff; color: #111; }
.call-ctrl.hangup { background: var(--danger); transform: rotate(135deg); }
.call-ctrl.hangup:hover { background: #ef4444; }
@media (max-width: 600px) {
  .local-video { width: 96px; height: 128px; right: 12px; top: 12px; }
  .call-ctrl { width: 52px; height: 52px; font-size: 20px; }
}

/* ---------- Missed-call → leave a voice message bubble ---------- */
.missed-bubble {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  z-index: 90; display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px;
  width: min(360px, calc(100vw - 28px));
  animation: mbIn .25s ease;
}
@keyframes mbIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.missed-bubble .mb-ic {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 18px;
}
.missed-bubble .mb-body { flex: 1; min-width: 0; }
.missed-bubble .mb-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.missed-bubble .mb-sub { font-size: 12.5px; color: var(--muted); }
.missed-bubble .btn.small { flex: none; }

/* ---------- Admin contact inbox ---------- */
.inbox-head { margin: 34px 0 14px; display: flex; align-items: center; gap: 10px; }
.inbox-head h2 { font-size: 18px; margin: 0; display: flex; align-items: center; gap: 10px; }
.inbox-badge {
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 999px; padding: 0 6px;
  display: inline-grid; place-items: center;
}
.contact-msg.unread { border-color: var(--accent); }
.new-badge { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.contact-body {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin: 8px 0; font-size: 14px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}

/* ---- Installable app ---- */
.app-cta { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: -10px auto 20px; }
.app-cta-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 15px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.app-cta-btn:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 6px 18px rgba(99, 102, 241, .18); }
.app-cta-ic { font-size: 15px; line-height: 1; }
.app-cta-alt { font-size: 12px; color: var(--muted); }
.app-cta-alt:hover { color: var(--accent); }
.al-hint { font-size: 11.5px; color: var(--muted); padding: 0 6px 6px; line-height: 1.35; max-width: 240px; }
.al-push { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.push-ask {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin: 10px 14px 0; padding: 10px 12px; border-radius: 14px;
  background: var(--accent-soft); border: 1px solid var(--border); font-size: 13.5px;
}
.push-ask.hidden { display: none; }
.push-ask-btns { display: flex; gap: 6px; margin-left: auto; }
.android-box { display: grid; gap: 10px; }
.android-status { font-size: 14px; display: grid; gap: 3px; }
.android-fine { font-size: 12.5px; color: var(--muted); }
.android-box code, .android-fine code { font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.ios-card h3 { margin: 0 0 14px; text-align: center; }
.ios-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; text-align: left; }
.ios-steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.4; }
.ios-steps small { display: block; color: var(--muted); font-size: 12.5px; }
.ios-n { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.ios-share { width: 20px; height: 20px; vertical-align: -4px; color: #0a84ff; margin: 0 2px; }
.ios-plus { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1.6px solid currentColor; border-radius: 5px; font-size: 13px; line-height: 1; vertical-align: -3px; }
.ios-fine { font-size: 12.5px; color: var(--muted); text-align: center; margin: 16px 0 4px; }
.al-test { margin: 0 6px 8px; }
.admin-warn { background: #fff7e6; border: 1px solid #f5c26b; color: #6b4a00; border-radius: 14px; padding: 4px 16px; margin: 0 0 18px; font-size: 14px; line-height: 1.5; }
.admin-warn code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
@media (prefers-color-scheme: dark) { .admin-warn { background: #2b2210; border-color: #7a5a14; color: #f3d9a0; } }
.topic-help { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 6px 0 10px; }
.topic-help a { color: var(--accent); }
.opt { color: var(--muted); font-weight: 400; }
.sent-title { margin: 8px 0 4px; }
.sent-text { color: var(--muted); font-size: 14px; margin: 0; }
.profile-legal { text-align: center; font-size: 12.5px; color: var(--muted); margin: 14px 0 10px; } .profile-legal a { color: var(--muted); }
.push-ask-text a { color: var(--accent); }

/* ---- End-to-end encryption ---- */
.e2e-badge { display: inline-flex; align-items: center; gap: 3px; margin-left: 4px; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: #0f7a4f; background: rgba(16,185,129,.12); white-space: nowrap; cursor: help; }
@media (prefers-color-scheme: dark) { .e2e-badge { color: #5ee0a8; background: rgba(16,185,129,.16); } }
.e2e-badge.hidden { display: none; }
.bubble.locked { font-style: italic; color: var(--muted); background: var(--panel-2); }
.att-locked { padding: 14px 16px; border-radius: 14px; background: var(--panel-2); color: var(--muted); font-size: 13.5px; font-style: italic; }
.att-media.decrypting, .att-audio.decrypting { min-height: 60px; min-width: 160px; border-radius: 14px; background: linear-gradient(90deg, var(--panel-2), var(--border), var(--panel-2)); background-size: 200% 100%; animation: encShimmer 1.2s linear infinite; }
@keyframes encShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.messages.decrypting::before { content: '🔒 Decrypting…'; display: block; text-align: center; color: var(--muted); font-size: 13px; margin: 24px 0; }
.room-badge.enc { color: #0f7a4f; background: rgba(16,185,129,.12); border-color: transparent; }
.e2e-opt { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); line-height: 1.45; margin: 4px 2px 10px; cursor: pointer; }
.e2e-opt input { margin-top: 2px; accent-color: var(--accent); flex: none; }
.lock-badge.enc { background: rgba(16,185,129,.14); color: #0f7a4f; }
.key-note { font-size: 12.5px; color: var(--muted); margin: -4px 0 10px; line-height: 1.45; }
@media (max-width: 600px) { .e2e-word { display: none; } .e2e-badge { padding: 1px 5px; } }
.chat-title .status { white-space: nowrap; overflow: hidden; } .chat-title .status #connText { overflow: hidden; text-overflow: ellipsis; }
.enc-pill-wrap { text-align: center; margin: -12px 0 18px; }
.enc-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: #0f7a4f; background: rgba(16,185,129,.12); cursor: help; }
@media (prefers-color-scheme: dark) { .enc-pill { color: #5ee0a8; background: rgba(16,185,129,.16); } }
.request-access { text-align: center; font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.request-access a { color: var(--accent); font-weight: 600; text-decoration: none; }
.request-access a:hover { text-decoration: underline; }

/* ---------- Links + link preview cards ---------- */
.bubble a.msg-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bubble a.msg-link:hover { text-decoration-thickness: 2px; }
.link-card {
  display: flex; flex-direction: column; margin-top: 5px;
  width: min(320px, 100%); max-width: 100%;
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  background: var(--panel); color: var(--text); text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.link-card:hover { border-color: var(--accent); }
.link-card .lc-img { display: block; width: 100%; max-height: 220px; object-fit: cover; background: var(--panel-2); }
.link-card .lc-body { padding: 9px 12px 11px; min-width: 0; }
.link-card .lc-site { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-card .lc-title { font-size: 14px; font-weight: 700; line-height: 1.3; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-card .lc-desc { font-size: 12.5px; color: var(--muted); line-height: 1.4; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.link-card.lc-small { flex-direction: row; align-items: center; }
.link-card.lc-small .lc-img { width: 56px; height: 56px; max-height: none; flex: none; margin: 10px 0 10px 10px; border-radius: 10px; }
/* Composer: the preview that will go out with your message */
.lp-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-top: 1px solid var(--border); background: var(--panel-2);
}
.lp-slot { flex: 1; min-width: 0; }
.lp-loading { font-size: 12.5px; color: var(--muted); }
.link-card.lc-compose { flex-direction: row; align-items: center; width: 100%; margin: 0; cursor: default; box-shadow: none; }
.link-card.lc-compose .lc-img { width: 64px; height: 48px; max-height: none; flex: none; margin: 6px 0 6px 6px; border-radius: 8px; aspect-ratio: auto !important; }
.link-card.lc-compose .lc-body { padding: 6px 10px; }
.link-card.lc-compose .lc-desc { -webkit-line-clamp: 1; }

/* ---------- Editing a message ---------- */
.reply-bar.editing .reply-ic { color: var(--accent); }
.reply-bar.editing ~ .composer .attach:not(.emoji) { display: none; }
.msg.editing-now .bubble { box-shadow: 0 0 0 2px var(--accent); }

/* Admin: link preview test */
.lp-test-row { display: flex; gap: 8px; }
.lp-test-row input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); color: var(--text); padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none; }
.lp-test-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lp-test-card { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--panel); max-width: 520px; }
.lp-test-card img { width: 120px; height: auto; border-radius: 8px; flex: none; }
.lp-test-site { font-size: 12px; color: var(--muted); }
.lp-test-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* In-chat "get the app" offer + alerts-panel button */
.app-ask { background: var(--accent-soft); }
.alerts-panel .al-app { width: 100%; margin-top: 10px; }

/* Invite: send the link with WhatsApp, Telegram, text, email or the phone's share sheet */
.share-row { margin: 12px 0 4px; }
.share-label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.share-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.share-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.share-btn:hover { border-color: var(--accent); }
.share-btn.sb-wa { background: #25d366; border-color: #25d366; color: #fff; }
.share-btn.sb-tg { background: #2aabee; border-color: #2aabee; color: #fff; }
.modal-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
