/* Pulse — self-hosted messenger UI */

:root,
[data-theme="dark"] {
  --bg: #0f0a14;
  --bg-2: #150e1c;
  --panel: #1a1122;
  --panel-2: #24172d;
  --panel-3: #2e1d39;
  --line: #3a2745;
  --line-soft: #2a1b34;
  --text: #f6eef5;
  --muted: #b3a0b5;
  --muted-2: #8a7690;
  --accent: #f27a9e;
  --accent-2: #ffb08a;
  --accent-soft: rgba(242, 122, 158, 0.16);
  --bubble-in: rgba(35, 23, 42, 0.92);
  --bubble-out-1: #b83f70;
  --bubble-out-2: #d9568a;
  --danger: #ff6b81;
  --ok: #4ade9b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --scroll-thumb: #432c4e;
  --glass: rgba(26, 17, 34, 0.76);
  --glass-2: rgba(36, 23, 45, 0.62);
  --glass-line: rgba(242, 190, 210, 0.13);
  --glow-1: rgba(242, 122, 158, 0.22);
  --glow-2: rgba(255, 176, 138, 0.14);
  --glow-3: rgba(168, 92, 255, 0.13);
  --brand-text: linear-gradient(100deg, #ffffff 0%, #ffd3df 46%, #ffc4a3 100%);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fbf0f3;
  --bg-2: #fff7f8;
  --panel: #ffffff;
  --panel-2: #f9edf1;
  --panel-3: #f3e1e8;
  --line: #ecd3dc;
  --line-soft: #f6e5eb;
  --text: #2a1622;
  --muted: #7a5c6b;
  --muted-2: #a08494;
  --accent: #c23a6b;
  --accent-2: #d9714e;
  --accent-soft: rgba(194, 58, 107, 0.12);
  --bubble-in: #ffffff;
  --bubble-in-2: #fff7f9;
  --bubble-out-1: #b93a68;
  --bubble-out-2: #d55483;
  --danger: #d92d4b;
  --ok: #0f9d70;
  --shadow: 0 24px 70px rgba(80, 31, 52, 0.16);
  --shadow-sm: 0 6px 20px rgba(80, 31, 52, 0.1);
  --scroll-thumb: #e2c3d0;
  --glass: rgba(255, 255, 255, 0.8);
  --glass-2: rgba(255, 255, 255, 0.66);
  --glass-line: rgba(120, 60, 88, 0.12);
  --glow-1: rgba(194, 58, 107, 0.13);
  --glow-2: rgba(217, 113, 78, 0.11);
  --glow-3: rgba(168, 92, 255, 0.09);
  --brand-text: linear-gradient(100deg, #40172b 0%, #b23a66 52%, #c26a45 100%);
  color-scheme: light;
}

/* Accent presets. The default is Rose (the values above). */

[data-theme="dark"][data-accent="violet"] {
  --accent: #a78bfa;
  --accent-2: #f0abfc;
  --accent-soft: rgba(167, 139, 250, 0.17);
  --bubble-out-1: #7c3aed;
  --bubble-out-2: #a855f7;
}
[data-theme="light"][data-accent="violet"] {
  --accent: #7c3aed;
  --accent-2: #c026d3;
  --accent-soft: rgba(124, 58, 237, 0.12);
  --bubble-out-1: #7c3aed;
  --bubble-out-2: #9333ea;
}
[data-theme="dark"][data-accent="sunset"] {
  --accent: #ffa46b;
  --accent-2: #ffd166;
  --accent-soft: rgba(255, 164, 107, 0.17);
  --bubble-out-1: #e07a35;
  --bubble-out-2: #f59e42;
}
[data-theme="light"][data-accent="sunset"] {
  --accent: #c2620c;
  --accent-2: #b77900;
  --accent-soft: rgba(194, 98, 12, 0.12);
  --bubble-out-1: #c2620c;
  --bubble-out-2: #d9822b;
}
[data-theme="dark"][data-accent="ocean"] {
  --accent: #67d4e8;
  --accent-2: #7dd3fc;
  --accent-soft: rgba(103, 212, 232, 0.16);
  --bubble-out-1: #0e7490;
  --bubble-out-2: #0891b2;
}
[data-theme="light"][data-accent="ocean"] {
  --accent: #0e7490;
  --accent-2: #1670e0;
  --accent-soft: rgba(14, 116, 144, 0.12);
  --bubble-out-1: #0e7490;
  --bubble-out-2: #1670e0;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Inter", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

body.modal-open { overflow: hidden; }

button, input, textarea { font: inherit; color: inherit; }

button { cursor: pointer; border: 0; background: none; }

a { color: var(--accent); }

h1, h2, h3, p { margin: 0; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ scrollbars */

* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------- elements */

.logo {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 800;
  font-size: 24px;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 42%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  position: relative;
  overflow: hidden;
}
.logo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.55) 48%, transparent 62%);
  transform: translateX(-130%);
  animation: logo-sheen 7s ease-in-out infinite;
}
@keyframes logo-sheen {
  0%, 62% { transform: translateX(-130%); }
  78%, 100% { transform: translateX(130%); }
}

.logo.sm { width: 32px; height: 32px; border-radius: 10px; font-size: 16px; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 11px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--line);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}
.btn.primary:hover { filter: brightness(1.07); box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 48%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.28); }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.wide { width: 100%; padding: 12px; }
.btn[aria-busy="true"] { opacity: 0.7; pointer-events: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 11px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.icon-btn:hover {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--glass-line);
}
.icon-btn:active { transform: scale(0.94); }

.text-input,
.field input,
.search-wrap input,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-2);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.text-input::placeholder,
.field input::placeholder,
.search-wrap input::placeholder,
.composer textarea::placeholder { color: var(--muted-2); }

.text-input:focus,
.field input:focus,
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.muted { color: var(--muted); }
.small { font-size: 12.5px; line-height: 1.5; }
.error { color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: 0.01em; }
.field.slim { margin-bottom: 12px; }

.form-error {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 13px;
}

/* ------------------------------------------------------------------ auth */

.auth {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(76, 141, 255, 0.16), transparent 60%),
    radial-gradient(800px 500px at 95% 105%, rgba(139, 108, 255, 0.14), transparent 60%),
    var(--bg);
}

.auth-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.45;
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
.auth-glow.g1 { width: 420px; height: 420px; background: var(--glow-1); top: -160px; left: -120px; }
.auth-glow.g2 { width: 460px; height: 460px; background: var(--glow-3); bottom: -200px; right: -140px; animation-duration: 18s; animation-direction: alternate-reverse; }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(28px, 20px, 0) scale(1.09); }
}

.auth-card {
  position: relative;
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow), 0 0 100px -46px color-mix(in srgb, var(--accent) 70%, transparent);
  backdrop-filter: blur(18px) saturate(1.15);
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
}

.brand-lg { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand-lg h1 { font-size: 24px; letter-spacing: -0.02em; }
.brand-lg p { color: var(--muted); font-size: 13px; margin-top: 2px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  margin-bottom: 20px;
}
.tab {
  padding: 9px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.tab.active { background: var(--panel-3); color: var(--text); box-shadow: var(--shadow-sm); }

.auth-form { margin-bottom: 6px; }
.reset-copy { color: var(--muted); font-size: 13px; line-height: 1.45; margin-bottom: 14px; }
.link-btn {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.link-btn:hover { color: var(--text); }

.demo {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.demo p { color: var(--muted); font-size: 12.5px; margin-bottom: 9px; }
.demo code {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 12px;
}
.demo-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }

.fineprint { margin-top: 20px; color: var(--muted-2); font-size: 11.5px; text-align: center; line-height: 1.5; }

/* ------------------------------------------------------------------- app */

.app {
  display: grid;
  grid-template-columns: 348px 1fr;
  height: 100dvh;
  background:
    radial-gradient(900px 620px at 4% -10%, var(--glow-1), transparent 62%),
    radial-gradient(820px 560px at 98% 0%, var(--glow-2), transparent 58%),
    radial-gradient(760px 520px at 74% 112%, var(--glow-3), transparent 62%),
    var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, var(--glass), color-mix(in srgb, var(--panel) 88%, transparent));
  backdrop-filter: blur(18px) saturate(1.15);
  border-right: 1px solid var(--glass-line);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 12px 10px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  background: var(--brand-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand .logo.sm { color: #fff; }
.head-actions { display: flex; gap: 2px; }

.search-wrap { padding: 4px 14px 10px; }

.chat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 13px;
  text-align: left;
  color: var(--text);
  transition: background 0.14s, transform 0.14s, box-shadow 0.14s;
}
.chat-item:hover { background: var(--panel-2); transform: translateX(1px); }
.chat-item.active {
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent-2) 10%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
}
.chat-item.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  transform: translateY(-50%);
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 70%, transparent);
}
.chat-item-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chat-item-top { display: flex; align-items: baseline; gap: 8px; }
.chat-item-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-time { margin-left: auto; flex: 0 0 auto; color: var(--muted-2); font-size: 11.5px; }
.chat-item-bottom { display: flex; align-items: center; gap: 8px; min-height: 17px; }
.chat-item-preview {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 12.8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item-preview.typing { color: var(--accent); }
.chat-item-preview.muted { color: var(--muted-2); }
.chat-item.active .chat-item-preview { color: color-mix(in srgb, var(--text) 72%, var(--muted)); }

.badge {
  flex: 0 0 auto;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 45%, transparent);
}

.chat-list-empty { padding: 30px 18px; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.6; }

.me-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--glass-line);
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  backdrop-filter: blur(12px);
}
.me-btn { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; padding: 5px 7px; border-radius: 11px; text-align: left; transition: background 0.15s; }
.me-btn:hover { background: var(--panel-2); }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--muted-2); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------- avatars */

.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  user-select: none;
  background: #3f6fd1;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 46px; height: 46px; font-size: 16px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.xl { width: 84px; height: 84px; font-size: 28px; }
.avatar.has-photo {
  background-size: cover;
  background-position: center;
  color: transparent;
}
button.avatar { border: 0; padding: 0; }
button.avatar.clickable { cursor: pointer; }
button.avatar.clickable:hover { filter: brightness(1.08); }
#chat-avatar:not(.clickable) { cursor: default; }
.avatar.online::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ok);
  border: 2.5px solid var(--panel);
}
.avatar-spacer { width: 32px; flex: 0 0 32px; }

/* -------------------------------------------------------------- chat pane */

.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(720px 420px at 82% -12%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 62%),
    radial-gradient(600px 420px at 6% 106%, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 64%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg-2) 92%, transparent), color-mix(in srgb, var(--bg) 96%, transparent));
}

.empty {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 30px;
  text-align: center;
}
.empty-art {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--accent) 24%, var(--panel-2)), var(--panel-2) 62%);
  border: 1px solid var(--glass-line);
  font-size: 40px;
  box-shadow: 0 18px 50px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow-sm);
  margin-bottom: 4px;
  animation: bob 5s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.empty h2 { font-size: 21px; letter-spacing: -0.01em; }
.empty p { color: var(--muted); font-size: 13.5px; max-width: 320px; margin-bottom: 8px; }

.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--glass-line);
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  backdrop-filter: blur(16px) saturate(1.12);
  z-index: 2;
}
.chat-id { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-id h2 { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-id p { color: var(--muted); font-size: 12.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-id p.typing { color: var(--accent); }
.back { display: none; font-size: 26px; line-height: 1; padding-bottom: 4px; }

.message-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 22px 10px;
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 920px;
  margin: 0 auto;
  min-height: 100%;
  justify-content: flex-end;
}
.messages-empty {
  margin: auto;
  padding: 24px;
  color: var(--muted-2);
  font-size: 13.5px;
  text-align: center;
}

.day-sep {
  align-self: center;
  margin: 16px 0 10px;
  padding: 4px 11px;
  border-radius: 99px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.highlight .bubble { animation: flash 1.6s ease; }
@keyframes flash {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  20%, 60% { box-shadow: 0 0 0 3px var(--accent-soft); }
}

/* --------------------------------------------------------------- messages */

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 3px;
  position: relative;
}
.msg:not(.compact) { margin-top: 11px; }
.msg.in { justify-content: flex-start; }
.msg.out { justify-content: flex-end; }

.msg-main { position: relative; display: flex; flex-direction: column; max-width: min(74%, 640px); min-width: 0; }

.msg-sender { display: flex; align-items: baseline; gap: 7px; margin: 0 0 3px 3px; }
.sender-name { color: var(--accent); font-size: 12.5px; font-weight: 650; }
.sender-time { color: var(--muted-2); font-size: 10.5px; }

.bubble {
  position: relative;
  padding: 8px 12px 6px;
  border-radius: 16px;
  background: var(--bubble-in);
  border: 1px solid var(--glass-line);
  min-width: 64px;
  max-width: 100%;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08), 0 6px 18px rgba(0, 0, 0, 0.08);
}
.msg.in .bubble { border-bottom-left-radius: 5px; }
.msg.out .bubble {
  border: 0;
  border-bottom-right-radius: 5px;
  background: linear-gradient(135deg, var(--bubble-out-1), var(--bubble-out-2));
  color: #fff;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--bubble-out-1) 32%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.msg.out .msg-main { align-items: flex-end; }

.msg-text { font-size: 14.3px; line-height: 1.42; white-space: pre-wrap; }
.msg-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg.out .msg-text a { color: #eaf2ff; }
.detail-link {
  border-radius: 4px;
  padding: 0 2px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.detail-email { cursor: pointer; }
.detail-phone { cursor: pointer; font-variant-numeric: tabular-nums; }
.detail-mention {
  color: var(--accent, #4c8dff);
  font-weight: 600;
  border-radius: 4px;
  padding: 0 2px;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.deleted-text { font-style: italic; color: var(--muted-2); }
.msg.out .deleted-text { color: rgba(255, 255, 255, 0.72); }

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1;
  user-select: none;
}
.msg.out .meta { color: rgba(255, 255, 255, 0.72); }
.meta .edited { opacity: 0.85; }
.meta .ticks { font-weight: 700; letter-spacing: -2px; padding-left: 1px; }
.meta .ticks.read { color: #a9d4ff; }
[data-theme="light"] .msg.out .meta .ticks.read { color: #ffffff; }

.reply-quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  text-align: left;
  margin: 0 0 6px;
  padding: 5px 9px;
  border-radius: 9px;
  border-left: 3px solid var(--accent);
  background: rgba(0, 0, 0, 0.16);
  color: inherit;
  font-size: 12px;
}
.msg.in .reply-quote { background: var(--panel-2); }
.reply-quote strong { color: var(--accent); font-size: 11.5px; font-weight: 650; }
.msg.out .reply-quote strong { color: #eaf2ff; }
.reply-quote span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.msg.out .reply-quote span { color: rgba(255, 255, 255, 0.78); }

.attachment { margin: 1px 0 5px; }
.msg-image {
  display: block;
  max-width: 320px;
  max-height: 320px;
  width: auto;
  height: auto;
  border-radius: 10px;
  background: var(--panel-2);
  object-fit: cover;
}
.image-link { display: block; line-height: 0; position: relative; }
.msg-image { transition: filter 0.18s ease, transform 0.18s ease; }
.msg-audio { display: block; width: min(280px, 72vw); height: 40px; margin: 2px 0 4px; }
.story-ref {
  min-width: 190px;
  max-width: 288px;
  margin-bottom: 5px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.16);
}
.msg.in .story-ref { background: var(--panel-2); }
.story-ref-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0.85;
}
.story-ref-icon { font-size: 13px; }
.story-ref-image { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.story-ref-text {
  padding: 12px;
  font-size: 13px;
  line-height: 1.35;
  color: #fff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.story-ref-text:empty { display: none; }
.story-ref-caption {
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.story-ref-hint { display: block; padding: 6px 10px; font-size: 10.5px; opacity: 0.65; }

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.14);
  color: inherit;
  text-decoration: none;
  min-width: 200px;
}
.msg.in .file-card { background: var(--panel-2); }
.file-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 18px;
}
.msg.in .file-icon { background: var(--panel-3); }
.file-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-info strong { font-size: 12.8px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info small { color: var(--muted); font-size: 11px; }
.msg.out .file-info small { color: rgba(255, 255, 255, 0.7); }
.file-dl { flex: 0 0 auto; opacity: 0.7; font-weight: 700; }
.file-card:hover .file-dl { opacity: 1; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.14);
  color: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  transition: background 0.12s, border-color 0.12s;
}
.msg.in .reaction { background: var(--panel-2); }
.reaction:hover { border-color: var(--accent); }
.reaction.mine { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.msg.out .reaction.mine { background: rgba(255, 255, 255, 0.22); color: #fff; }
.reaction .count { font-size: 11px; font-weight: 700; }

/* message action toolbar */
.msg-tools {
  position: absolute;
  top: -20px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 0.12s, transform 0.12s;
  white-space: nowrap;
}
.msg.out .msg-tools { right: 0; }
.msg.in .msg-tools { left: 0; }
.msg:hover .msg-tools,
.msg:focus-within .msg-tools,
.msg.show-tools .msg-tools {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.tool {
  display: grid;
  place-items: center;
  min-width: 27px;
  height: 27px;
  padding: 0 4px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}
.tool:hover { background: var(--panel-2); color: var(--text); }
.tool.emoji { font-size: 15px; }
.tool[data-action="delete"]:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.picker { display: flex; align-items: center; gap: 0; }

/* -------------------------------------------------------- jump / composer */

.jump-latest {
  position: absolute;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  z-index: 3;
  padding: 7px 14px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}
.jump-latest:hover { border-color: var(--accent); }

.composer {
  position: relative;
  padding: 10px 18px 12px;
  border-top: 1px solid var(--glass-line);
  background: color-mix(in srgb, var(--panel) 66%, transparent);
  backdrop-filter: blur(16px) saturate(1.12);
  transition: box-shadow 0.2s;
}
.composer:focus-within {
  box-shadow: 0 -1px 0 color-mix(in srgb, var(--accent) 30%, transparent), 0 -18px 40px -24px color-mix(in srgb, var(--accent) 55%, transparent);
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; max-width: 920px; margin: 0 auto; }
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 160px;
  padding: 11px 13px;
  border-radius: 14px;
  line-height: 1.4;
  background: color-mix(in srgb, var(--panel-2) 88%, transparent);
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn.send {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  flex: 0 0 auto;
}

.composer-context {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 920px;
  margin: 0 auto 7px;
  padding: 6px 8px 6px 11px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent);
  font-size: 12.3px;
}
.ctx-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.ctx-text strong { font-size: 11.8px; color: var(--accent); font-weight: 650; }
.ctx-text span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-cancel {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
}
.ctx-cancel:hover { background: var(--panel-3); color: var(--text); }

.attach-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 920px;
  margin: 0 auto 7px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.attach-chip img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; }

.attach-menu {
  position: absolute;
  left: 18px;
  bottom: 66px;
  z-index: 8;
  width: min(330px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: pop 0.14s ease;
}
.attach-menu[hidden] { display: none; }
.attach-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 10px;
  text-align: left;
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
}
.attach-item:hover { background: var(--panel-2); }
.attach-item:disabled { opacity: 0.42; cursor: not-allowed; }
.attach-emoji {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 15px;
}
.attach-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--panel-3);
  font-size: 17px;
}
.attach-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.attach-meta strong { font-size: 12.6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-meta small { color: var(--muted); font-size: 11px; }

.composer-hint {
  max-width: 920px;
  margin: 6px auto 0;
  color: var(--muted-2);
  font-size: 10.8px;
  text-align: right;
  user-select: none;
}

.spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ search */

.search-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 10px 12px;
}
.result-section { margin-bottom: 14px; }
.result-heading {
  padding: 8px 8px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.result-empty { padding: 6px 10px 12px; color: var(--muted-2); font-size: 12.5px; }
.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border-radius: 10px;
  text-align: left;
  color: var(--text);
}
.result-item:hover { background: var(--panel-2); }
.result-item.selected { background: var(--accent-soft); }
.result-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.result-text strong { font-size: 13.3px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-text small { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-action { color: var(--accent); font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.result-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 14px;
}

/* ------------------------------------------------------------------ modals */

.modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 7, 12, 0.62); backdrop-filter: blur(3px); }

.modal {
  position: relative;
  width: min(460px, 100%);
  max-height: min(640px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
  animation: pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  opacity: 0.9;
  z-index: 1;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 16px 12px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 { font-size: 16.5px; letter-spacing: -0.01em; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 12px 20px 16px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; }

.result-list { margin-top: 11px; display: flex; flex-direction: column; gap: 2px; min-height: 60px; }

.selected-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.selected-chips:empty { display: none; }
.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 5px 3px 9px;
  border-radius: 99px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  font-size: 12px;
  font-weight: 600;
}
.person-chip button {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
}
.person-chip button:hover { background: var(--panel-3); color: var(--text); }

/* -------------------------------------------------------------- settings */

.modal-settings {
  width: min(720px, 100%);
  max-height: min(780px, calc(100dvh - 40px));
}
.settings-head { padding: 16px 16px 14px 20px; align-items: center; }
.settings-head-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.settings-head-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--accent-soft), color-mix(in srgb, var(--accent-2) 12%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  font-size: 18px;
}
.settings-head-id h2 { font-size: 17px; }
.settings-head-id p { margin-top: 2px; color: var(--muted); font-size: 12px; }

.settings-nav {
  display: flex;
  gap: 4px;
  padding: 9px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--panel-2) 45%, transparent);
  scrollbar-width: none;
}
.settings-nav::-webkit-scrollbar { display: none; }
.settings-nav-btn {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 99px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 650;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.settings-nav-btn:hover { background: var(--panel-2); color: var(--text); }
.settings-nav-btn.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  box-shadow: 0 0 18px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 22px;
  scroll-behavior: smooth;
}
.settings-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line-soft);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-2) 62%, transparent), color-mix(in srgb, var(--panel) 42%, transparent));
  scroll-margin-top: 10px;
}
.settings-card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.settings-card-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  font-size: 16px;
}
.settings-card-head h3 { font-size: 14.5px; letter-spacing: -0.01em; }
.settings-card-head p { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.settings-form { margin-bottom: 0; }
.settings-profile {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.settings-profile-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.settings-profile-actions .small { flex-basis: 100%; margin: 0; }
.bio-input { resize: vertical; min-height: 76px; font-family: inherit; line-height: 1.5; }
.settings-field { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.settings-field:first-of-type { margin-top: 0; }
.settings-label {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.accent-row { display: flex; flex-wrap: wrap; gap: 8px; }
.accent-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.1s;
}
.accent-btn:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-1px); }
.accent-btn[aria-pressed="true"] {
  color: var(--text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 58%, transparent);
  box-shadow: 0 0 18px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.accent-dot {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.accent-rose { background: linear-gradient(135deg, #f27a9e, #ffb08a); }
.accent-violet { background: linear-gradient(135deg, #a78bfa, #f0abfc); }
.accent-sunset { background: linear-gradient(135deg, #ffa46b, #ffd166); }
.accent-ocean { background: linear-gradient(135deg, #67d4e8, #7dd3fc); }

.privacy-note {
  padding: 12px 13px;
  border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--panel-2)), color-mix(in srgb, var(--accent-2) 6%, var(--panel-2)));
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
}
.privacy-note strong { display: block; margin-bottom: 4px; font-size: 12.8px; }
.privacy-note p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.privacy-note b { color: var(--text); font-weight: 650; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  padding: 12px 2px 2px;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
}
.switch-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-text strong { font-size: 13.3px; font-weight: 600; }
.switch-text small { color: var(--muted); font-size: 11.8px; line-height: 1.45; }
.switch-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.18s;
}
.switch-input:checked + .switch {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 0 16px -5px color-mix(in srgb, var(--accent) 85%, transparent);
}
.switch-input:checked + .switch::after { transform: translateX(18px); background: #fff; }
.switch-input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.invite-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  margin-bottom: 14px;
  border-radius: 14px;
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--accent) 20%, var(--panel-2)), color-mix(in srgb, var(--accent-2) 12%, var(--panel-2)));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.invite-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.invite-card-text strong { font-size: 14px; }
.invite-card-text span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-row { display: flex; gap: 8px; }
.copy-row .text-input { flex: 1 1 auto; min-width: 0; }
.copy-row .btn { flex: 0 0 auto; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

#btn-logout { margin-top: 4px; }

.profile-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding-top: 26px;
  padding-bottom: 30px;
}
.profile-body h3 { font-size: 19px; }
.profile-body #profile-username { margin-bottom: 10px; }
.profile-bio {
  max-width: 360px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.seg {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  width: fit-content;
}
.seg-btn {
  padding: 6px 14px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}
.seg-btn.active { background: var(--panel-3); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  max-width: 100%;
  padding: 9px 15px;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12.8px;
  box-shadow: var(--shadow);
  animation: toast-in 0.16s ease;
  pointer-events: auto;
}
.toast.error { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.toast.error::before { content: "⚠ "; color: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.noscript { padding: 24px; text-align: center; color: var(--muted); }

/* ----------------------------------------------------------------- stories */

.story-tray {
  display: flex;
  gap: 9px;
  padding: 0 14px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--line-soft);
  scrollbar-width: none;
}
.story-tray::-webkit-scrollbar { display: none; }
.story-tray:empty { display: none; }

.story-tile {
  width: 62px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.2;
  text-align: center;
}
.story-tile-label {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-ring {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 2.5px;
  border-radius: 50%;
  background: var(--line);
}
.story-ring.has-story { background: conic-gradient(from 180deg, var(--accent), var(--accent-2), var(--accent)); }
.story-ring.unseen { background: conic-gradient(from 180deg, #ffb347, #ff5f6d, #8b6cff, #4c8dff, #ffb347); }
.story-ring .avatar { width: 100%; height: 100%; font-size: 16px; border: 2px solid var(--panel); }
.story-add-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--panel);
}
.story-tile:hover .story-ring { filter: brightness(1.08); }

.modal-story { width: min(520px, 100%); }
.story-preview {
  position: relative;
  min-height: 190px;
  display: grid;
  place-items: center;
  padding: 18px;
  margin: 13px 0 11px;
  border-radius: 14px;
  overflow: hidden;
  color: #fff;
  text-align: center;
  font-size: 20px;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
  background: linear-gradient(135deg, #4c8dff, #8b6cff);
}
.story-preview img { max-width: 100%; max-height: 260px; border-radius: 10px; object-fit: contain; }
.story-text {
  width: 100%;
  resize: vertical;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-2);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.story-text:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.story-bg-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.story-bg-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.story-bg-swatch.active { border-color: var(--text); }

.story-viewer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 5, 10, 0.9);
  backdrop-filter: blur(12px);
}
.story-shell {
  position: relative;
  width: min(420px, 100%);
  height: min(740px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  overflow: hidden;
  background: #111;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.story-progress {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  z-index: 5;
}
.story-progress span { flex: 1; height: 3px; border-radius: 99px; background: rgba(255, 255, 255, 0.28); overflow: hidden; }
.story-progress i { display: block; height: 100%; width: 0; background: #fff; }
.story-progress i.done { width: 100%; }
.story-progress i.active { animation: storyFill 6s linear forwards; }
@keyframes storyFill { from { width: 0; } to { width: 100%; } }

.story-viewer-head {
  position: absolute;
  top: 18px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  z-index: 5;
  color: #fff;
}
.story-author-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.story-author-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-author-text small { color: rgba(255, 255, 255, 0.66); font-size: 11px; }
.story-viewer-head .icon-btn { color: rgba(255, 255, 255, 0.82); }
.story-viewer-head .icon-btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.story-content {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 56px 18px 44px;
  color: #fff;
}
.story-content .story-body {
  max-width: 100%;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 650;
  text-align: center;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  white-space: pre-wrap;
}
.story-content .story-image { max-width: 100%; max-height: 100%; border-radius: 14px; object-fit: contain; }
.story-content .story-caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 40px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.38);
  font-size: 13px;
  text-align: center;
}
.story-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  color: #fff;
  font-size: 26px;
  line-height: 1;
}
.story-nav.prev { left: 8px; }
.story-nav.next { right: 8px; }
.story-nav:disabled { opacity: 0.2; pointer-events: none; }
.story-views {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 10px 14px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  color: rgba(255, 255, 255, 0.82);
  font-size: 11.5px;
  line-height: 1.45;
}
.story-reply-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.58) 38%);
}
.story-shell.has-reply .story-content { padding-bottom: 132px; }
.story-reactions { display: flex; justify-content: center; gap: 6px; }
.story-reaction {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.story-reaction:hover { transform: scale(1.12); background: rgba(255, 255, 255, 0.26); }
.story-reaction:active { transform: scale(0.96); }
.story-reply-form { display: flex; align-items: center; gap: 8px; }
.story-reply-form .text-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.story-reply-form .text-input::placeholder { color: rgba(255, 255, 255, 0.66); }
.story-reply-form .text-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.2);
}
.story-reply-form .btn { flex: 0 0 auto; border-radius: 99px; }

/* ------------------------------------------------------------- voice notes */

.modal-voice { width: min(420px, 100%); }
.voice-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 0 6px;
}
.voice-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e35d6a;
  animation: voicePulse 1.2s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.82); }
}
.voice-timer { font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: 0.5px; }
.voice-preview { width: 100%; }
.voice-foot { justify-content: space-between; gap: 8px; }

/* ------------------------------------------------------------------- gifts */

.chat-actions { margin-left: auto; display: flex; align-items: center; gap: 1px; flex: 0 0 auto; }
.chat-actions .icon-btn { width: 36px; height: 36px; font-size: 16px; }

.modal-gift { width: min(520px, 100%); }
.gift-balance { font-size: 13px; color: var(--muted); }
.gift-balance strong { color: #e8b83d; }
.gift-recipient-wrap { display: flex; align-items: center; gap: 7px; margin-top: 4px; min-height: 30px; }
.gift-recipient-wrap #gift-recipient { font-size: 13px; font-weight: 600; }
.gift-recipient-select {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  padding: 5px 8px;
  font-size: 12.5px;
  max-width: 230px;
}
.gift-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 13px 0 12px;
}
.gift-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 5px 8px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 10.5px;
  line-height: 1.2;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.gift-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.gift-card:active { transform: translateY(1px); }
.gift-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.gift-card:disabled { opacity: 0.42; cursor: not-allowed; }
.gift-emoji {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 22px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.gift-name { font-weight: 600; }
.gift-price { color: #e8b83d; font-weight: 700; font-size: 11px; }
.gift-note { margin-top: 6px; }

.gift-card-msg {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 218px;
  margin: 1px 0 5px;
  padding: 9px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
}
.msg.in .gift-card-msg { background: var(--panel-2); }
.gift-art {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 24px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.gift-lines { display: flex; flex-direction: column; min-width: 0; }
.gift-lines strong { font-size: 13px; }
.gift-lines small { color: var(--muted); font-size: 11px; }
.msg.out .gift-lines small { color: rgba(255, 255, 255, 0.72); }
.gift-note-text { margin-top: 2px; font-size: 12.5px; overflow-wrap: anywhere; }

.mini-gifts { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-gift {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 11.5px;
}

/* ------------------------------------------------------------------- calls */

.call-card-msg { display: flex; align-items: center; gap: 10px; min-width: 196px; }
.call-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
  font-size: 17px;
}
.msg.in .call-icon { background: var(--panel-2); }
.call-lines { display: flex; flex-direction: column; min-width: 0; }
.call-lines strong { font-size: 12.8px; font-weight: 600; }
.call-lines small { color: var(--muted); font-size: 11px; }
.msg.out .call-lines small { color: rgba(255, 255, 255, 0.72); }
.call-lines .missed { color: var(--danger); }
.msg.out .call-lines .missed { color: #ffd0d5; }

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 6, 11, 0.88);
  backdrop-filter: blur(16px);
}
.call-card {
  position: relative;
  width: min(880px, 100%);
  height: min(620px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: radial-gradient(700px 500px at 50% 0%, #1b2b40, #0a0e13);
  box-shadow: var(--shadow);
}
.call-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; transition: opacity 0.2s; }
.call-remote.audio-mode { opacity: 0; }
.call-remote.off { display: none; }
.call-avatar {
  position: relative;
  z-index: 1;
  width: 120px;
  height: 120px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 40px;
  font-weight: 800;
  background: var(--accent);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.call-local-wrap {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  width: 132px;
  height: 98px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.call-local { width: 100%; height: 100%; object-fit: cover; }
.call-info {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  z-index: 1;
  padding: 0 70px;
  text-align: center;
  color: #fff;
  pointer-events: none;
}
.call-info h2 { font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-kind { margin-top: 2px; color: rgba(255, 255, 255, 0.68); font-size: 12px; }
.call-status { margin-top: 7px; color: rgba(255, 255, 255, 0.82); font-size: 13px; }
.call-timer { margin-top: 2px; color: rgba(255, 255, 255, 0.92); font-size: 14px; font-variant-numeric: tabular-nums; }
.call-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 14px;
}
.call-btn {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 21px;
  backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.08s;
}
.call-btn:hover { background: rgba(255, 255, 255, 0.24); }
.call-btn:active { transform: scale(0.95); }
.call-btn.danger { background: #e34b5c; }
.call-btn.danger:hover { background: #f05a6b; }
.call-btn.ok { background: #18a06e; }
.call-btn.ok:hover { background: #1fb97f; }
.call-btn.off { background: rgba(255, 255, 255, 0.3); }

/* --------------------------------------------------- attach-card messages */

.card-msg {
  display: flex;
  gap: 10px;
  min-width: 220px;
  max-width: 330px;
  margin: 1px 0 5px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
}
.msg.in .card-msg { background: var(--panel-2); }
.card-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 18px;
}
.msg.in .card-icon { background: var(--panel-3); }
.card-lines { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.card-lines strong { font-size: 13.4px; font-weight: 650; overflow-wrap: anywhere; }
.card-lines small,
.card-lines p { color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.msg.out .card-lines small,
.msg.out .card-lines p { color: rgba(255, 255, 255, 0.78); }
.card-desc { white-space: pre-wrap; }
.card-link {
  margin-top: 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  width: fit-content;
}
.card-link:hover { text-decoration: underline; }
.msg.out .card-link { color: #eaf2ff; }

.contact-card .avatar { flex: 0 0 auto; }

.poll-card,
.event-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 240px;
  max-width: 350px;
  margin: 1px 0 5px;
  padding: 11px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
}
.msg.in .poll-card,
.msg.in .event-card { background: var(--panel-2); }
.poll-q { font-size: 13.5px; font-weight: 650; overflow-wrap: anywhere; }
.poll-opt {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  color: inherit;
  text-align: left;
  font-size: 12.5px;
  overflow: hidden;
}
.poll-opt:hover { border-color: var(--accent); }
.poll-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent-soft);
  transition: width 0.2s ease;
}
.poll-opt > span { position: relative; z-index: 1; }
.poll-opt.mine { border-color: var(--accent); }
.poll-opt.mine .poll-fill { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.poll-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.msg.out .poll-count { color: rgba(255, 255, 255, 0.78); }
.poll-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}
.msg.out .poll-foot { color: rgba(255, 255, 255, 0.75); }

.event-when { color: var(--muted); font-size: 12px; font-weight: 600; }
.msg.out .event-when { color: rgba(255, 255, 255, 0.82); }
.rsvp-row { display: flex; gap: 6px; margin-top: 2px; }
.rsvp-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}
.rsvp-btn:hover { border-color: var(--accent); color: var(--text); }
.rsvp-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.msg.out .rsvp-btn.active { background: rgba(255, 255, 255, 0.2); color: #fff; }

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.msg.out .ai-badge { background: rgba(255, 255, 255, 0.18); color: #fff; }
.ai-caption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11.5px;
  font-style: italic;
  overflow-wrap: anywhere;
}
.msg.out .ai-caption { color: rgba(255, 255, 255, 0.78); }

/* ---------------------------------------------------- attach-modal bodies */

.camera-body { align-items: center; }
.camera-video {
  width: 100%;
  max-height: 52dvh;
  border-radius: 12px;
  background: #0b0f14;
  object-fit: cover;
}
.contact-results { max-height: 180px; overflow-y: auto; margin-bottom: 12px; }
.contact-results:empty { display: none; }
.poll-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.poll-option-row { display: flex; align-items: center; gap: 8px; }
.poll-option-row .text-input { flex: 1; }
.poll-option-remove {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--muted);
}
.poll-option-remove:hover { background: var(--panel-2); color: var(--text); }
.poll-option-remove:disabled { opacity: 0.35; cursor: not-allowed; }
.poll-option-remove:disabled:hover { background: none; color: var(--muted); }
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 14px 0 2px;
  color: var(--muted);
  font-size: 13px;
}
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.ai-preview {
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel-2);
}
.ai-preview img { display: block; width: 100%; max-height: 300px; object-fit: contain; }

/* -------------------------------------------------------------- responsive */

/* ------------------------------------------------ density and privacy blur */

[data-density="compact"] .msg:not(.compact) { margin-top: 5px; }
[data-density="compact"] .bubble { padding: 5px 10px 4px; border-radius: 13px; }
[data-density="compact"] .msg-text { font-size: 13.8px; line-height: 1.36; }
[data-density="compact"] .msg-sender { margin-bottom: 1px; }
[data-density="compact"] .day-sep { margin: 9px 0 6px; }
[data-density="compact"] .chat-item { padding: 6px 9px; }
[data-density="compact"] .story-tile { width: 58px; }

.privacy-blur .image-link .msg-image { filter: blur(18px); transform: scale(1.02); }
.privacy-blur .image-link.revealed .msg-image { filter: none; transform: none; }
.privacy-blur .image-link:not(.revealed)::after {
  content: "👁  Tap to reveal";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(5, 9, 16, 0.32);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

@media (hover: none) {
  .msg-tools { opacity: 0; pointer-events: none; }
  .msg.show-tools .msg-tools { opacity: 1; pointer-events: auto; transform: translateY(0); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { width: 100%; }

  .chat-pane {
    position: fixed;
    inset: 0;
    z-index: 20;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
  }
  .app.chat-open .chat-pane { transform: translateX(0); }
  .back { display: inline-grid; }

  .message-scroll { padding: 14px 12px 8px; }
  .msg-main { max-width: 84%; }
  .msg-image { max-width: min(260px, 64vw); }

  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .attach-menu { left: 10px; right: 10px; width: auto; bottom: 62px; }
  .chat-head { padding: 9px 10px; }
  .jump-latest { bottom: 96px; }

  .modal-root { padding: 12px; align-items: end; }
  .modal { max-height: calc(100dvh - 24px); }

  .story-tray { padding: 0 10px 9px; }
  .chat-actions .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  .story-viewer { padding: 0; }
  .story-shell { width: 100%; height: 100dvh; border-radius: 0; border: 0; }
  .call-overlay { padding: 0; }
  .call-card { width: 100%; height: 100dvh; border-radius: 0; border: 0; }
  .call-local-wrap { width: 104px; height: 78px; }
}

@media (max-width: 380px) {
  .msg-tools .tool { min-width: 25px; height: 25px; padding: 0 2px; }
  .msg-tools .tool.emoji { font-size: 14px; }
}

@media (max-width: 860px) {
  .modal-settings { max-height: calc(100dvh - 24px); }
  .settings-head { padding: 13px 12px 11px 16px; }
  .settings-nav { padding: 8px 12px; }
  .settings-body { padding: 12px; gap: 12px; }
  .settings-card { padding: 14px; }
  .settings-profile { gap: 12px; }
  .settings-profile .avatar.xl { width: 68px; height: 68px; font-size: 22px; }
  .copy-row { flex-direction: column; }
  .copy-row .btn { width: 100%; }
  .invite-actions .btn { flex: 1 1 100%; }
}

@media (max-width: 420px) {
  .settings-nav-btn { padding: 6px 11px; font-size: 12px; }
  .settings-card-head p { font-size: 11.5px; }
  .settings-head-id h2 { font-size: 16px; }
  .settings-head-icon { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .logo::after,
  .empty-art,
  .auth-glow { animation: none; }
  .chat-item,
  .accent-btn,
  .icon-btn,
  .msg-image { transition: none; }
  .settings-body { scroll-behavior: auto; }
  .modal { animation: none; }
}

