:root {
  --bg: #000;
  --surface: #121212;
  --surface-2: #1c1c1c;
  --surface-3: #262626;
  --border: #262626;
  --border-strong: #363636;
  --text: #f5f5f5;
  --text-2: #c7c7c7;
  --muted: #a8a8a8;
  --blue: #0095f6;
  --blue-hover: #1877f2;
  --green: #2ecc71;
  --danger: #ed4956;
  --ig: linear-gradient(45deg, #f9ce34 0%, #ee2a7b 45%, #6228d7 100%);
  --ig-dm: linear-gradient(180deg, #a033ff 0%, #d62e8a 45%, #ff6f3c 100%);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(238, 42, 123, 0.4); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; text-align: center; }

* { scrollbar-width: thin; scrollbar-color: #333 transparent; }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- Buttons & inputs ---------- */
.btn {
  border: 0;
  background: var(--surface-3);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.25;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.btn:hover { background: #363636; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-hover); }
.btn.big { width: 100%; padding: 13px 16px; font-size: 16px; border-radius: 12px; }
.btn.danger { color: var(--danger); background: var(--surface-3); }
.btn.danger:hover { background: #3a2226; }
.btn.primary.danger { background: var(--danger); color: #fff !important; }
.btn.primary.danger:hover { background: #d63443; }
.btn.small { padding: 7px 12px; font-size: 13.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.icon-btn {
  border: 0; background: transparent; width: 42px; height: 42px; border-radius: 50%;
  display: inline-grid; place-items: center; font-size: 22px; color: var(--text); flex: none;
  transition: background 0.15s, opacity 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }

input, textarea, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
input::placeholder, textarea::placeholder { color: #737373; }
input:focus, textarea:focus, select:focus { border-color: #737373; }
input:focus-visible, textarea:focus-visible { outline: none; }
label.field { display: block; margin: 0 0 16px; font-size: 13.5px; color: var(--muted); font-weight: 600; }
label.field input, label.field select { margin-top: 7px; color: var(--text); font-weight: 400; }

/* ---------- Logo & avatars ---------- */
.logo { font-family: "Pacifico", cursive; font-weight: 400; font-size: 26px; line-height: 1.2; letter-spacing: 0.2px; }
.logo.big { font-size: 46px; }

.avatar {
  --h: 330;
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 85% 62%), hsl(calc(var(--h) + 35) 80% 48%));
  user-select: none;
}
.avatar.emoji { font-size: 22px; line-height: 1; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.sm.emoji { font-size: 17px; }
.avatar.xl { width: 96px; height: 96px; font-size: 48px; }

/* ---------- Welcome ---------- */
.welcome { min-height: 100%; height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.welcome-card { margin: auto; max-width: 100%; }
.welcome-card {
  width: min(420px, 100%); padding: 40px 36px 32px; text-align: center;
  border: 1px solid var(--border-strong); border-radius: 4px;
  animation: rise 0.4s var(--ease) both;
}
.tagline { color: var(--muted); margin: 6px 0 26px; font-size: 16px; font-weight: 600; line-height: 1.35; }
.welcome-card form { display: grid; gap: 14px; }
.avatar-preview-wrap { display: grid; place-items: center; margin-bottom: 4px; }
#welcome-avatar { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px #ee2a7b, 0 0 0 7px transparent; }
#welcome-avatar.bump { animation: bump 0.35s var(--ease); }
#welcome-nick { text-align: center; font-size: 17px; font-weight: 600; padding: 14px; background: var(--surface); }
.picker-label { font-size: 13px; color: var(--muted); font-weight: 600; text-align: left; margin-bottom: -4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.emoji-grid button {
  aspect-ratio: 1; border: 0; background: var(--surface); border-radius: 12px;
  font-size: 22px; display: grid; place-items: center; transition: background 0.15s, transform 0.15s;
}
.emoji-grid button:hover { background: var(--surface-3); transform: scale(1.08); }
.emoji-grid button.on { background: var(--surface-3); box-shadow: inset 0 0 0 2px #ee2a7b; }
.hue-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 4px 0 8px; }
.hue-row button {
  width: 30px; height: 30px; border-radius: 50%; padding: 0; border: 0;
  background: linear-gradient(135deg, hsl(var(--h) 85% 62%), hsl(calc(var(--h) + 35) 80% 48%));
  transition: transform 0.15s;
}
.hue-row button:hover { transform: scale(1.1); }
.hue-row button.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px #fff; }
@keyframes bump { 40% { transform: scale(1.12); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 380px 1fr; height: 100%; height: var(--app-h, 100dvh); }
.sidebar {
  display: flex; flex-direction: column; min-height: 0; padding-top: var(--safe-t);
  background: var(--bg); border-right: 1px solid var(--border);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 20px 14px 24px; }
#profile-btn { width: 48px; height: 48px; }
#profile-btn .avatar { width: 38px; height: 38px; font-size: 19px; }
.sidebar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 20px 8px 24px; }
.room-list { overflow-y: auto; padding: 0 0 calc(16px + var(--safe-b)); flex: 1; }
.section-label { font-size: 16px; font-weight: 700; color: var(--text); padding: 18px 24px 8px; }
.room-list > p.muted { padding: 4px 24px !important; font-size: 14px !important; }
.room-item {
  display: flex; gap: 14px; align-items: center; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 9px 24px; transition: background 0.12s;
}
.room-item:hover { background: var(--surface); }
.room-item.active { background: var(--surface-2); }
.room-icon {
  --h: 330;
  width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative;
  font-size: 22px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 80% 58%), hsl(calc(var(--h) + 40) 80% 45%));
}
.room-icon.public { background: var(--ig); font-size: 24px; }
/* Story-style ring on rooms with unread messages */
.room-item.has-unread .room-icon { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px #ee2a7b; }
.room-meta { min-width: 0; flex: 1; display: grid; gap: 2px; }
.room-meta .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.room-meta strong { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item.has-unread strong { font-weight: 700; }
.room-meta .time { color: var(--muted); font-size: 12.5px; flex: none; }
.room-meta .preview { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item.has-unread .preview { color: var(--text); font-weight: 600; }
.unread {
  min-width: 20px; height: 20px; border-radius: 10px; background: var(--blue); color: #fff;
  font-size: 11.5px; font-weight: 700; display: grid; place-items: center; padding: 0 6px;
}

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.empty-chat { margin: auto; text-align: center; padding: 24px; max-width: 360px; animation: fade 0.3s; }
.empty-icon {
  width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--text); color: var(--text);
}
.empty-chat h2 { font-size: 22px; font-weight: 600; margin: 0 0 6px; }
.empty-chat p { font-size: 14.5px; margin: 0; }

.chat-head {
  display: flex; align-items: center; gap: 12px; padding: calc(12px + var(--safe-t)) 14px 12px 20px;
  border-bottom: 1px solid var(--border); min-height: 75px;
}
.chat-head .back { display: none; font-size: 34px; font-weight: 300; }
.chat-head .room-icon { width: 44px; height: 44px; font-size: 18px; }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-title h1 { font-size: 16px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-pill { border: 0; background: none; padding: 0; color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; align-self: flex-start; }
.online-pill:hover { color: var(--text); }
.online-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #555; }
.online-pill.active .dot { background: var(--green); }
.online-pill.offline { color: #f5a623; }
.online-pill.offline .dot { background: #f5a623; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
#room-info-btn { font-size: 22px; letter-spacing: 1px; }

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px 20px 10px; overscroll-behavior: contain; }
.messages.switching { animation: fade 0.2s; }
.load-more { display: block; margin: 0 auto 14px; }
.day-sep { text-align: center; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 22px 0 12px; }
.system-msg { text-align: center; font-size: 13px; color: var(--muted); margin: 10px 0; }

.msg { display: flex; gap: 8px; margin-top: 14px; align-items: flex-end; max-width: 100%; }
.msg.cont { margin-top: 3px; }
.msg.cont > .avatar { visibility: hidden; height: 0; }
.msg > .avatar { width: 30px; height: 30px; font-size: 15px; margin-bottom: 2px; }
.msg.mine { flex-direction: row-reverse; }
.msg.mine > .avatar { display: none; }
.msg.enter { animation: rise 0.22s var(--ease) both; }
.msg-body { max-width: min(65%, 560px); min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.msg.mine .msg-body { align-items: flex-end; }
.msg-author { font-size: 12.5px; color: var(--muted); margin: 0 0 4px 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.bubble {
  -webkit-touch-callout: none;
  position: relative; padding: 10px 15px; border-radius: 22px; white-space: pre-wrap; overflow-wrap: anywhere;
  user-select: text; -webkit-user-select: text; cursor: default; font-size: 15px; line-height: 1.38;
  background: var(--surface-3);
}
.msg.cont:not(.mine) .bubble { border-top-left-radius: 6px; }
.msg:not(.mine):has(+ .msg.cont:not(.mine)) .bubble { border-bottom-left-radius: 6px; }
/* Instagram-style: the gradient is fixed to the screen, so bubbles shift color as they scroll */
.msg.mine .bubble { background: var(--ig-dm); background-attachment: fixed; color: #fff; }
.msg.mine.cont .bubble { border-top-right-radius: 6px; }
.msg.mine:has(+ .msg.mine.cont) .bubble { border-bottom-right-radius: 6px; }
.bubble.flash { animation: flash 1.2s; }
@keyframes flash { 0%, 50% { box-shadow: 0 0 0 3px #ee2a7b; } }
.bubble img { display: block; max-width: 100%; max-height: 340px; border-radius: 16px; margin: -4px -9px 6px; max-width: calc(100% + 18px); cursor: zoom-in; }
.bubble:has(img):not(:has(.quote)) { padding-top: 4px; }
.bubble .time { display: none; font-size: 11px; color: var(--muted); margin-left: 10px; float: right; margin-top: 4px; }
.msg.mine .bubble .time { color: rgba(255, 255, 255, 0.75); }
.msg:hover .bubble .time { display: inline; }
.quote {
  background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 6px 10px; margin: 0 -6px 8px;
  font-size: 13.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% + 12px);
}
.quote strong { display: block; color: var(--text); font-size: 12.5px; font-weight: 700; }
.msg.mine .quote { background: rgba(255, 255, 255, 0.18); color: rgba(255, 255, 255, 0.9); }
.msg.mine .quote strong { color: #fff; }
.msg-tools { display: flex; align-self: center; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.msg:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
.msg.mine .msg-tools { flex-direction: row-reverse; }
.msg-more {
  display: grid; place-items: center; border: 0; background: transparent; border-radius: 50%; width: 32px; height: 32px;
  color: var(--muted); align-self: center; flex: none; font-size: 18px; transition: opacity 0.12s, background 0.12s;
}
.msg:hover .msg-more, .msg-more:focus-visible { opacity: 1; }
.msg-more:hover { background: var(--surface-2); color: var(--text); }
.reactions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: -6px; padding: 0 10px; position: relative; z-index: 1; }
.reaction {
  border: 2px solid var(--bg); background: var(--surface-3); border-radius: 999px; padding: 1px 7px 1px 5px; font-size: 13px;
  display: inline-flex; gap: 3px; align-items: center; transition: transform 0.12s;
}
.reaction:hover { transform: scale(1.08); }
.reaction.mine { background: #3a3a3a; }
.reaction .n { font-size: 12px; color: var(--text-2); font-weight: 600; }

.typing { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 0 20px 6px; min-height: 22px; }
.typing .dots { display: inline-flex; gap: 4px; background: var(--surface-3); padding: 9px 12px; border-radius: 18px; }
.typing .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typingDot 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: 0.15s; }
.typing .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }

/* ---------- Composer ---------- */
.composer { padding: 6px 18px calc(18px + var(--safe-b)); }
.composer-row {
  display: flex; align-items: flex-end; gap: 4px; padding: 5px 6px 5px 8px; border-radius: 26px;
  background: var(--bg); border: 1px solid var(--border-strong);
}
.composer textarea {
  resize: none; max-height: 140px; border: 0; background: transparent; padding: 10px 6px; line-height: 1.4;
  min-height: 42px; border-radius: 0; font-size: 15px;
}
.attach { cursor: pointer; width: 42px; height: 42px; }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--ig); color: #fff;
  display: grid; place-items: center; flex: none; transition: transform 0.12s, opacity 0.15s;
}
.send-btn:hover { transform: scale(1.06); }
.send-btn:active { transform: scale(0.92); }
.send-btn svg { width: 19px; height: 19px; }
.reply-preview, .image-preview {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 4px 8px;
  background: var(--surface); border-radius: 14px; padding: 8px 6px 8px 14px; font-size: 13.5px; color: var(--text-2);
  animation: rise 0.18s var(--ease);
}
.reply-preview div { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-preview strong { color: var(--text); margin-right: 8px; font-weight: 700; }
.image-preview img { max-height: 84px; border-radius: 10px; }

/* ---------- Action menu ---------- */
.actions {
  position: fixed; z-index: 50; border-radius: 16px; padding: 6px; min-width: 260px;
  background: var(--surface-3); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7); animation: pop 0.16s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(0.95); } }
.reaction-bar {
  display: flex; justify-content: space-between; gap: 2px; padding: 6px 8px; margin-bottom: 6px;
  background: #363636; border-radius: 30px;
}
.reaction-bar button { border: 0; background: none; font-size: 26px; border-radius: 50%; width: 40px; height: 40px; transition: transform 0.15s var(--ease); }
.reaction-bar button:hover { transform: scale(1.25); }
.reaction-bar button.mine { background: rgba(255, 255, 255, 0.15); }
.action-list { display: grid; }
.action-list button { border: 0; background: none; text-align: left; padding: 11px 14px; border-radius: 10px; font-size: 15px; font-weight: 500; }
.action-list button:hover { background: #363636; }
.danger { color: var(--danger) !important; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.65); animation: fade 0.15s; }
.modal-card {
  position: relative; width: min(480px, 100%); max-height: min(86dvh, 780px); overflow-y: auto;
  background: var(--surface-3); border-radius: 16px; padding: 20px 24px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7); animation: pop 0.18s var(--ease);
}
.modal-card header {
  display: flex; justify-content: center; align-items: center; position: relative;
  margin: -20px -24px 16px; padding: 14px 52px; border-bottom: 1px solid var(--border-strong);
  position: sticky; top: -20px; z-index: 2; background: var(--surface-3);
}
.modal-card header .icon-btn { position: absolute; right: 8px; }
.modal-card h2 { margin: 0; font-size: 16px; font-weight: 700; text-align: center; }
.modal-card h3 { font-size: 15px; font-weight: 700; color: var(--text); margin: 24px 0 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 14px 18px;
  background: var(--bg); border-radius: 14px; position: relative;
}
.code-box::before { content: ""; position: absolute; inset: 0; border-radius: 14px; padding: 2px; background: var(--ig); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.code-box code { font: 800 26px/1 var(--font); letter-spacing: 5px; color: var(--text); }
.member { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 0; }
.member .avatar.sm { width: 44px; height: 44px; font-size: 20px; }
.member .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; }
.member .online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; margin-left: 7px; vertical-align: middle; }
.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; flex: none; text-transform: capitalize; background: #363636; color: var(--text); }
.badge.owner { background: var(--ig); color: #fff; }
.badge.admin { background: var(--blue); color: #fff; }
.member-actions { display: flex; gap: 6px; flex-wrap: wrap; flex-basis: 100%; padding-left: 56px; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; margin: 8px 0 0; cursor: pointer; font-size: 15px; font-weight: 500; }
.toggle input {
  width: 46px; height: 28px; appearance: none; -webkit-appearance: none; background: #4a4a4a; border-radius: 999px;
  position: relative; padding: 0; border: 0; cursor: pointer; flex: none; transition: background 0.2s;
}
.toggle input::after { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform 0.2s var(--ease); }
.toggle input:checked { background: var(--blue); }
.toggle input:checked::after { transform: translateX(18px); }
.hint { font-size: 14px; color: var(--text-2); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.profile-avatar { display: grid; justify-items: center; margin: 4px 0 16px; }

/* ---------- Confirm dialog (Instagram-style) ---------- */
.confirm { z-index: 75; }
.confirm-card { width: min(400px, 100%); padding: 0; text-align: center; overflow: hidden; }
.confirm-icon { display: none; }
.confirm-card h2 { margin: 30px 24px 6px; font-size: 19px; font-weight: 700; }
.confirm-card p { margin: 0 24px 26px; font-size: 14.5px; }
.confirm-actions { display: flex; flex-direction: column-reverse; gap: 0; }
.confirm-actions .btn {
  width: 100%; border-radius: 0; background: transparent; border-top: 1px solid var(--border-strong);
  padding: 15px; font-size: 15px; font-weight: 400;
}
.confirm-actions .btn:hover { background: rgba(255, 255, 255, 0.04); }
.confirm-actions .btn.primary { color: var(--blue); font-weight: 700; }
.confirm-actions .btn.primary.danger { color: var(--danger) !important; background: transparent; }

.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.92); display: grid; place-items: center; cursor: zoom-out; padding: 16px; animation: fade 0.15s; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 10px); z-index: 80;
  background: #f5f5f5; color: #000; padding: 12px 18px; border-radius: 12px; font-size: 14.5px; font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s var(--ease); max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; }
  .sidebar-head { padding: 16px 12px 12px 18px; }
  .sidebar-actions { padding: 0 16px 6px 18px; }
  .section-label { padding: 16px 18px 6px; }
  .room-item { padding: 9px 18px; }
  .room-list > p.muted { padding: 4px 18px !important; }
  .chat { display: none; }
  .app.in-room .sidebar { display: none; }
  .app.in-room .chat { display: flex; animation: fade 0.2s; }
  .chat-head { padding-left: 4px; min-height: 64px; }
  .chat-head .back { display: inline-grid; }
  .chat-head .room-icon { width: 38px; height: 38px; }
  .msg-body { max-width: 78%; }
  .msg-more { display: none; }
  .messages { padding: 14px 12px 8px; }
  .composer { padding: 6px 10px calc(10px + var(--safe-b)); }
  .bubble { font-size: 16px; }
  .composer textarea { font-size: 16px; }
  .actions { left: 10px !important; right: 10px; bottom: calc(10px + var(--safe-b)); top: auto !important; border-radius: 20px; }
  .reaction-bar button { width: 46px; height: 46px; font-size: 28px; }
  .action-list button { padding: 14px 16px; font-size: 16px; }
  .modal { place-items: end center; padding: 0; }
  .modal-card { width: 100%; border-radius: 16px 16px 0 0; padding-bottom: calc(24px + var(--safe-b)); max-height: 92dvh; }
  .confirm { place-items: center; padding: 24px; }
  .confirm .modal-card { border-radius: 16px; padding-bottom: 0; }
  .welcome-card { border: 0; padding: 24px 8px; }
}

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

/* ---------- Conversation intro ---------- */
.room-intro { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 16px 18px; gap: 4px; }
.room-intro .room-icon.big { width: 96px; height: 96px; font-size: 40px; margin-bottom: 10px; }
.room-intro h2 { margin: 0; font-size: 20px; font-weight: 700; }
.room-intro p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }

@media (hover: none) {
  .bubble { user-select: none; -webkit-user-select: none; }
  .msg-tools { display: none; }
}
@media (max-width: 760px) {
  html, body { position: fixed; inset: 0; overscroll-behavior: none; }
}
