/* NEX Messenger: Telegram-inspired liquid glass, RTL */
:root {
  --font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --ink: oklch(0.25 0.02 245);
  --ink-2: oklch(0.47 0.02 245);
  --ink-3: oklch(0.62 0.015 245);
  --accent: oklch(0.62 0.15 246);
  --accent-hi: oklch(0.56 0.16 250);
  --accent-ink: oklch(0.985 0.006 246);
  --accent-soft: oklch(0.62 0.15 246 / 0.12);
  --online: oklch(0.66 0.16 150);
  --danger: oklch(0.58 0.19 25);
  --danger-soft: oklch(0.58 0.19 25 / 0.1);
  --paper: oklch(0.985 0.004 245);
  --glass: oklch(0.985 0.006 200 / 0.58);
  --glass-strong: oklch(0.985 0.005 220 / 0.84);
  --edge: oklch(0.99 0.01 200 / 0.7);
  --line: oklch(0.3 0.02 245 / 0.09);
  --shadow: 0 1px 1px oklch(0.3 0.04 200 / 0.06), 0 10px 32px -8px oklch(0.3 0.05 200 / 0.18);
  --in: oklch(0.992 0.004 110);
  --out: oklch(0.955 0.065 132);
  --out-meta: oklch(0.55 0.11 145);
  --r: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.55 var(--font); color: var(--ink); background: oklch(0.86 0.06 130);
  -webkit-font-smoothing: antialiased; overflow: hidden; -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: 0.6; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
bdi, .item-prev, .text, .sender, .head-txt b { unicode-bidi: plaintext; }
a { color: var(--accent-hi); }

/* ---------- wallpaper: Telegram's mint/lemon gradient + doodle grain ---------- */
#bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(55% 45% at 12% 18%, oklch(0.9 0.1 108) 0%, transparent 62%),
    radial-gradient(48% 55% at 88% 12%, oklch(0.78 0.1 158) 0%, transparent 60%),
    radial-gradient(60% 55% at 78% 88%, oklch(0.9 0.09 98) 0%, transparent 60%),
    radial-gradient(52% 55% at 8% 92%, oklch(0.74 0.1 152) 0%, transparent 62%),
    oklch(0.86 0.07 130);
}
#bg::after {
  content: ''; position: absolute; inset: 0; opacity: 0.14; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%23305a3a' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M20 30l14-6-5 14-3-5z'/%3E%3Ccircle cx='110' cy='28' r='7'/%3E%3Cpath d='M70 70c6-8 16-8 22 0M78 62h.1M86 62h.1'/%3E%3Cpath d='M130 100l6 6m0-6l-6 6'/%3E%3Cpath d='M24 110c8 0 8 12 16 12s8-12 16-12'/%3E%3Crect x='96' y='128' width='16' height='12' rx='3'/%3E%3Cpath d='M100 128v-3a4 4 0 018 0v3'/%3E%3Cpath d='M58 20l3 6 6 1-4.5 4 1 6-5.5-3-5.5 3 1-6-4.5-4 6-1z'/%3E%3C/svg%3E");
  background-size: 160px;
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.7); backdrop-filter: blur(22px) saturate(1.7);
  border: 1px solid var(--edge); box-shadow: var(--shadow);
}
.glass-strong {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(28px) saturate(1.8); backdrop-filter: blur(28px) saturate(1.8);
  border: 1px solid var(--edge); box-shadow: var(--shadow);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: oklch(0.975 0.008 200 / 0.94); }
  .glass-strong { background: oklch(0.985 0.005 220 / 0.97); }
}

.ic { display: inline-grid; place-items: center; flex: none; }
.ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.tiny svg { width: 15px; height: 15px; stroke-width: 2; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; line-height: 1.6; }
.on { color: var(--accent) !important; }
.pad-x { padding-inline: 16px; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 18px; border-radius: 12px; font-weight: 600;
  background: oklch(0.3 0.02 245 / 0.06); transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn:hover { background: oklch(0.3 0.02 245 / 0.1); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hi); }
.btn.ghost { background: transparent; color: var(--accent-hi); }
.btn.danger-ghost { background: var(--danger-soft); color: var(--danger); }
.btn.armed, .chip.armed { background: var(--danger); color: var(--accent-ink); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn.busy { position: relative; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); flex: none;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.icon-btn:hover { background: oklch(0.3 0.02 245 / 0.07); color: var(--ink); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent-hi); white-space: nowrap;
}
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.inp {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; outline: none;
  background: oklch(0.995 0.003 245 / 0.75); border: 1px solid var(--line);
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea.inp { height: auto; padding: 11px 14px; resize: vertical; min-height: 46px; line-height: 1.6; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp.sm { height: 38px; font-size: 14px; }
.inp::placeholder, textarea::placeholder { color: var(--ink-3); }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding-inline: 4px; }
.form { display: flex; flex-direction: column; gap: 14px; padding: 4px 16px 8px; }
.form-err { margin: 0; min-height: 1.4em; color: var(--danger); font-size: 13px; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; overflow-y: auto; height: 100dvh; }
.auth-card { width: min(400px, 100%); border-radius: 28px; padding: 30px 26px 22px; display: flex; flex-direction: column; gap: 20px; animation: rise 0.6s var(--ease); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 26px; line-height: 1.1; font-weight: 800; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--ink-2); font-size: 13.5px; }
.brand-mark {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.35), 0 8px 20px -6px oklch(0.55 0.16 246 / 0.6);
}
.brand-mark .ic svg { width: 28px; height: 28px; transform: scaleX(-1); }
.splash { height: 100dvh; display: grid; place-items: center; }
.splash .brand-mark { animation: pulse 1.4s var(--ease) infinite; }
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 14px; background: oklch(0.3 0.02 245 / 0.06); }
.seg-b { height: 36px; border-radius: 10px; font-weight: 600; color: var(--ink-2); transition: background 0.25s var(--ease), color 0.25s; }
.seg-b.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px oklch(0.3 0.03 245 / 0.12); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .btn.primary { height: 48px; margin-top: 2px; }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: -4px; }
.meter i { height: 4px; border-radius: 4px; background: var(--line); transition: background 0.3s; }
.meter[data-s="1"] i:nth-child(-n+1) { background: var(--danger); }
.meter[data-s="2"] i:nth-child(-n+2) { background: oklch(0.72 0.15 70); }
.meter[data-s="3"] i:nth-child(-n+3) { background: oklch(0.7 0.14 140); }
.meter[data-s="4"] i { background: var(--online); }
.auth-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: oklch(0.38 0.08 246); }
.auth-note p { margin: 0; font-size: 12.5px; line-height: 1.7; }
.unlock-who { display: flex; gap: 14px; align-items: center; }
.unlock-who h2 { margin: 0; font-size: 19px; }
.unlock-who p { margin: 0; }
.lead { margin: 0; color: var(--ink-2); }
.fatal { max-width: 440px; margin: 15vh auto; padding: 28px; border-radius: 24px; text-align: center; }
.fatal h1 { margin: 0 0 8px; font-size: 22px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: minmax(310px, 390px) 1fr; height: 100dvh; position: relative; overflow: hidden; }
.side {
  position: relative; display: flex; flex-direction: column; min-height: 0; border-radius: 0; border-block: 0; border-inline-start: 0;
  box-shadow: none; z-index: 5;
}
.side-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px; flex: none; }
.side-title { margin: 0; font-size: 17px; font-weight: 700; }
.side-body { overflow-y: auto; flex: 1; padding-bottom: 24px; display: flex; flex-direction: column; gap: 6px; }
.search-wrap {
  flex: 1; display: flex; align-items: center; gap: 6px; height: 42px; padding-inline: 12px; border-radius: 99px;
  background: oklch(0.3 0.02 245 / 0.06); color: var(--ink-3); transition: background 0.2s, box-shadow 0.2s;
}
.search-wrap:focus-within { background: var(--paper); box-shadow: 0 0 0 2px var(--accent); color: var(--accent); }
.search { flex: 1; min-width: 0; border: 0; outline: none; background: none; height: 100%; color: var(--ink); }
.search::-webkit-search-cancel-button { display: none; }

.menu {
  position: absolute; top: 56px; inset-inline-start: 10px; width: 260px; z-index: 20; border-radius: 16px; padding: 6px;
  transform-origin: top right; animation: pop 0.22s var(--ease);
}
.menu-me { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-me div { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.menu-me span { color: var(--ink-2); font-size: 12.5px; text-align: end; }
.menu-i { display: flex; align-items: center; gap: 14px; width: 100%; height: 42px; padding-inline: 10px; border-radius: 10px; font-weight: 500; text-align: start; }
.menu-i:hover { background: oklch(0.3 0.02 245 / 0.06); }
.menu-i .ic { color: var(--ink-2); }
.menu-i.danger, .menu-i.danger .ic { color: var(--danger); }

.list { flex: 1; overflow-y: auto; padding: 2px 8px 90px; display: flex; flex-direction: column; gap: 1px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border-radius: 14px; text-align: start;
  transition: background 0.18s var(--ease);
}
.item:hover { background: oklch(0.99 0.005 200 / 0.55); }
.item.active { background: var(--accent); color: var(--accent-ink); }
.item.active .item-prev, .item.active .item-time, .item.active .who, .item.active .muted-i { color: oklch(0.95 0.03 246); }
.item.active .badge { background: var(--accent-ink); color: var(--accent-hi); }
.item.active .tick { color: var(--accent-ink) !important; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.item-top, .item-bot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.item-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.item-title bdi { overflow: hidden; text-overflow: ellipsis; }
.item-time { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 2px; flex: none; }
.item-prev { flex: 1; min-width: 0; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-prev.typing, .typing { color: var(--accent); }
.who { color: var(--ink); font-weight: 500; }
.muted-i { color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none;
}
.tick { color: var(--online); }
.list-empty { padding: 28px 16px; color: var(--ink-2); text-align: center; font-size: 14px; }
.list-empty.first { text-align: start; padding: 36px 14px; }
.list-empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 17px; }
.list-empty p { margin: 0 0 12px; line-height: 1.8; }
.my-id {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent-hi); font-weight: 600; direction: ltr;
}
.fab {
  position: absolute; bottom: 20px; inset-inline-end: 20px; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 10px 24px -8px oklch(0.5 0.16 246 / 0.7); transition: transform 0.25s var(--ease);
}
.fab:hover { transform: translateY(-2px) scale(1.03); }
.lookup { margin: 4px 2px 10px; padding: 10px 12px 12px; border-radius: 16px; background: var(--paper); box-shadow: 0 1px 3px oklch(0.3 0.03 245 / 0.1); }
.lookup-label { font-size: 12px; color: var(--accent-hi); font-weight: 600; }
.lookup-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.lookup-row .muted { font-size: 13px; text-align: end; }

/* avatars */
.av {
  --s: 48px; width: var(--s); height: var(--s); border-radius: 50%; flex: none; position: relative; display: grid; place-items: center;
  background: linear-gradient(160deg, oklch(0.76 0.12 var(--h)), oklch(0.62 0.14 var(--h)));
  color: oklch(0.99 0.01 var(--h)); font-weight: 700; font-size: calc(var(--s) * 0.36); letter-spacing: 0.02em; user-select: none;
}
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.av.saved { background: linear-gradient(160deg, oklch(0.72 0.13 235), oklch(0.6 0.15 250)); color: var(--accent-ink); }
.av.saved .ic svg { width: calc(var(--s) * 0.42); height: calc(var(--s) * 0.42); }
.av.online::after {
  content: ''; position: absolute; bottom: 1px; inset-inline-start: 1px; width: calc(var(--s) * 0.26); height: calc(var(--s) * 0.26);
  border-radius: 50%; background: var(--online); border: 2.5px solid var(--paper); max-width: 16px; max-height: 16px;
}

/* ---------- chat pane ---------- */
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.chat.drop::after { content: 'رها کن تا رمزنگاری و ارسال بشه'; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 24px; display: grid; place-items: center; background: oklch(0.97 0.02 246 / 0.7); font-weight: 700; color: var(--accent-hi); z-index: 30; }
.chat-head {
  position: absolute; top: 10px; inset-inline: 12px; z-index: 6; height: 58px; border-radius: 18px;
  display: flex; align-items: center; gap: 4px; padding-inline: 6px 8px;
}
.chat-head .back { display: none; }
.head-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 14px; text-align: start; }
.head-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.head-txt b { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.e2e { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--online); padding: 3px 8px; border-radius: 99px; background: oklch(0.66 0.16 150 / 0.12); direction: ltr; }

.msgs { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; }
.msgs-inner { max-width: 780px; margin: 0 auto; padding: 80px 16px 98px; display: flex; flex-direction: column; min-height: 100%; justify-content: flex-end; }
.day { align-self: center; margin: 12px 0 8px; position: sticky; top: 76px; z-index: 2; }
.day span { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600; color: oklch(0.98 0.01 140); background: oklch(0.42 0.06 150 / 0.36); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.intro { align-self: center; margin: auto 0 24px; max-width: 320px; padding: 18px 20px; border-radius: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink-2); }
.intro .ic { color: var(--accent); }
.intro p { margin: 0; font-size: 14px; }

.row { display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; position: relative; }
.row.start { margin-top: 8px; }
.row.mine { flex-direction: row-reverse; }
.row.post { justify-content: flex-start; }
.av-gap { width: 34px; flex: none; }
.bubble {
  position: relative; max-width: min(540px, 82%); padding: 6px 11px 6px; border-radius: 18px; background: var(--in);
  box-shadow: 0 1px 1.5px oklch(0.3 0.04 150 / 0.14);
  overflow-wrap: anywhere;
}
.row.post .bubble { max-width: min(560px, 100%); width: fit-content; }
.row.mine .bubble { background: var(--out); }
.row.end:not(.mine) .bubble { border-end-start-radius: 6px; }
.row.end.mine .bubble { border-end-end-radius: 6px; }
.row.post.end .bubble { border-end-start-radius: 18px; }
.sender { font-size: 13.5px; font-weight: 700; color: oklch(0.55 0.15 var(--h)); margin-bottom: 1px; }
.sender.ch { color: var(--accent-hi); }
.text { white-space: pre-wrap; display: inline; }
.text.jumbo { font-size: 44px; line-height: 1.15; }
.bubble.bare { background: none !important; box-shadow: none; padding-inline: 2px; }
.bubble.bare .meta { background: oklch(0.3 0.04 150 / 0.3); color: oklch(0.98 0.01 140); padding: 0 6px; border-radius: 99px; }
.meta {
  float: left; float: inline-end; display: inline-flex; align-items: center; gap: 2px; margin-inline-start: 10px; margin-top: 6px;
  font-size: 11.5px; line-height: 1; color: var(--ink-3); position: relative; top: 4px; direction: ltr; user-select: none;
}
.row.mine .meta { color: var(--out-meta); }
.meta .tick { color: var(--out-meta); }
.meta .tick.read { color: var(--accent); }
.bubble.media { padding: 3px; background: var(--in); }
.row.mine .bubble.media { background: var(--out); }
.bubble.media > img, .img-box { display: block; border-radius: 15px; max-width: 100%; min-width: 120px; min-height: 90px; background: oklch(0.3 0.03 150 / 0.08); object-fit: cover; }
.img-box { overflow: hidden; cursor: zoom-in; padding: 0; }
.img-box img { width: 100%; height: 100%; object-fit: cover; display: block; animation: fade 0.3s var(--ease); }
.gif { max-height: 320px; }
.bubble.media .meta { position: absolute; bottom: 9px; inset-inline-end: 9px; top: auto; margin: 0; padding: 2px 7px; border-radius: 99px; background: oklch(0.2 0.02 245 / 0.5); color: oklch(0.98 0.005 245); }
.bubble.media .meta .tick { color: oklch(0.98 0.005 245); }
.bubble.media .sender { padding: 4px 8px 2px; }
.file { display: flex; align-items: center; gap: 12px; padding: 4px 2px 2px; min-width: 200px; }
.file-dl { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.row.mine .file-dl { background: var(--online); }
.file-dl.spin .ic { animation: pulse 0.9s var(--ease) infinite; }
.file-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.file-txt b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.file-txt span { font-size: 12.5px; color: var(--ink-2); }
.locked, .deleted-t { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-3); font-size: 14px; font-style: italic; }
.bubble.deleted { background: oklch(0.99 0.004 110 / 0.7) !important; }
.msg-del {
  align-self: center; opacity: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink-2); background: oklch(0.99 0.005 200 / 0.7); transition: opacity 0.2s, background 0.2s; font-size: 12px; font-weight: 700;
}
.msg-del.armed { opacity: 1; width: auto; padding: 0 10px; border-radius: 99px; }
.msg-acts { align-self: center; display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.row:hover .msg-acts, .msg-acts:focus-within, .msg-acts:has(.armed) { opacity: 1; }
.msg-acts .msg-del { opacity: 1; }
.msg-act { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); background: oklch(0.99 0.005 200 / 0.7); transition: background 0.2s, color 0.2s; }
.msg-act:hover, .msg-del:hover { background: var(--paper); color: var(--accent-hi); }
@media (hover: none) { .msg-acts { opacity: 0.6; } }

/* composer */
.composer {
  position: absolute; bottom: 12px; inset-inline: 12px; z-index: 6; max-width: 800px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
}
.field { flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 2px; border-radius: 24px; padding: 4px; }
.field textarea {
  flex: 1; min-width: 0; border: 0; outline: none; background: none; resize: none; padding: 9px 4px; max-height: 180px;
  line-height: 1.5; font-size: 15.5px;
}
.gif-btn { height: 40px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 800; letter-spacing: 0.05em; color: var(--ink-2); direction: ltr; }
.gif-btn:hover { background: oklch(0.3 0.02 245 / 0.07); color: var(--ink); }
.send {
  width: 50px; height: 50px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 22px -8px oklch(0.5 0.16 246 / 0.75);
  transition: transform 0.25s var(--ease), background 0.2s;
}
.send .ic svg { transform: scaleX(-1); width: 24px; height: 24px; }
.send:hover { background: var(--accent-hi); }
.send:active { transform: scale(0.94); }
.send:not(.ready) { background: oklch(0.62 0.15 246 / 0.85); }
.ro-pill { margin: 0 auto; padding: 12px 20px; border-radius: 99px; font-size: 14px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; text-align: center; }
.composer[data-mode="ro"], .composer[data-mode="wait"] { justify-content: center; }

.gif-panel {
  position: absolute; bottom: 62px; inset-inline-end: 0; width: min(400px, calc(100vw - 24px)); height: 380px; border-radius: 20px;
  display: flex; flex-direction: column; padding: 10px; gap: 8px; animation: pop 0.24s var(--ease); transform-origin: bottom left;
}
.gif-top { display: flex; gap: 8px; align-items: center; }
.gif-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; align-content: start; }
.gif-cell { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: oklch(0.3 0.03 150 / 0.08); position: relative; }
.gif-pick { width: 100%; height: 100%; display: block; }
.gif-x { position: absolute; top: 4px; inset-inline-start: 4px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: oklch(0.2 0.02 245 / 0.55); color: #fff; opacity: 0; transition: opacity 0.2s; }
.gif-cell:hover .gif-x { opacity: 1; }
@media (hover: none) { .gif-x { opacity: 0.85; } }
.gif-tab { height: 32px; padding: 0 12px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.gif-tab.on { background: var(--accent-soft); color: var(--accent-hi); }
.gif-top .grow { flex: 1; }
.gif-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-msg { grid-column: 1 / -1; padding: 30px; text-align: center; color: var(--ink-2); }
.gif-off { padding: 16px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; color: var(--ink-2); line-height: 1.8; }
.gif-by { font-size: 10.5px; color: var(--ink-3); text-align: center; direction: ltr; }

.empty { flex: 1; display: grid; place-items: center; padding: 24px; }
.empty-card { max-width: 380px; padding: 30px 28px; border-radius: 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-card h2 { margin: 4px 0 0; font-size: 21px; }
.empty-card p { margin: 0 0 8px; color: var(--ink-2); line-height: 1.85; }
.empty-ic { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty-ic .ic svg { width: 30px; height: 30px; }

/* ---------- info drawer & side views ---------- */
.info {
  position: absolute; inset-block: 10px; inset-inline-end: 10px; width: 360px; z-index: 10; border-radius: 22px;
  display: flex; flex-direction: column; transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none;
  transition: transform 0.45s var(--ease), opacity 0.3s var(--ease);
}
.info.open { transform: none; opacity: 1; pointer-events: auto; }
.info-body { overflow-y: auto; flex: 1; padding-bottom: 20px; display: flex; flex-direction: column; gap: 6px; }
.profile-hero { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 16px 14px; text-align: center; }
.profile-hero h3 { margin: 10px 0 0; font-size: 20px; line-height: 1.3; }
.profile-hero .muted { font-size: 13.5px; }
.profile-hero .my-id { margin-top: 6px; }
.desc { margin: 8px 0 0; color: var(--ink-2); line-height: 1.8; white-space: pre-wrap; }
.av-edit { position: relative; border-radius: 50%; }
.av-cam { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; background: oklch(0.2 0.02 245 / 0.35); color: var(--accent-ink); opacity: 0; transition: opacity 0.25s; }
.av-edit:hover .av-cam, .av-edit:focus-visible .av-cam { opacity: 1; }
@media (hover: none) { .av-cam { opacity: 0.8; background: none; align-items: end; justify-items: end; } .av-cam .ic { background: var(--accent); border-radius: 50%; padding: 6px; } }
.sec { margin: 6px 12px 0; padding: 14px; border-radius: 16px; background: oklch(0.99 0.004 245 / 0.6); display: flex; flex-direction: column; gap: 10px; }
.sec.tight { background: none; padding: 6px 4px 0; }
.sec h4 { margin: 0; font-size: 13px; font-weight: 700; color: var(--accent-hi); display: flex; align-items: center; gap: 6px; }
.sec p { margin: 0; }
.sec-h { display: flex; align-items: center; justify-content: space-between; }
.fp { font: 600 14.5px/1.7 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; letter-spacing: 0.06em; color: var(--ink); background: oklch(0.3 0.02 245 / 0.05); padding: 8px 12px; border-radius: 10px; word-spacing: 0.3em; text-align: center; }
.invite { font: 12.5px/1.6 ui-monospace, Menlo, Consolas, monospace; word-break: break-all; background: oklch(0.3 0.02 245 / 0.05); padding: 8px 10px; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
details.edit summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); list-style: none; }
details.edit summary::before { content: '✎  '; }
details.edit .form { padding: 12px 0 0; }
.rows { display: flex; flex-direction: column; margin: 0 12px; }
.info-row { display: flex; gap: 16px; align-items: center; padding: 10px 8px; border-radius: 12px; text-align: start; width: 100%; }
button.info-row:hover { background: oklch(0.3 0.02 245 / 0.05); }
.info-row .ic { color: var(--ink-3); }
.info-row div { display: flex; flex-direction: column; min-width: 0; line-height: 1.45; }
.info-row b { font-weight: 500; overflow-wrap: anywhere; }
.info-row span { font-size: 12.5px; color: var(--ink-3); }
.members { gap: 2px; }
.member { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.member-main { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 12px; text-align: start; }
.member-main:hover { background: oklch(0.3 0.02 245 / 0.05); }
.role { font-size: 11.5px; font-weight: 700; color: var(--accent-hi); }
.add-row { display: flex; gap: 8px; }
.add-row .btn { height: 46px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px 12px 6px; }
.quick-i { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 16px; font-size: 13px; font-weight: 600; background: oklch(0.99 0.004 245 / 0.55); transition: background 0.2s; }
.quick-i:hover { background: var(--paper); }
.q-ic { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-hi); }
.contact { padding: 0; }
.contact-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px 10px; text-align: start; }
.contact .chip { margin-inline-end: 10px; opacity: 0; transition: opacity 0.2s; }
.contact:hover .chip, .contact .chip.armed { opacity: 1; }
@media (hover: none) { .contact .chip { opacity: 1; } }
.picker { display: flex; flex-direction: column; padding: 0 8px 90px; gap: 1px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 14px; cursor: pointer; }
.pick:hover { background: oklch(0.99 0.005 200 / 0.55); }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.tickbox { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ink-3); display: grid; place-items: center; color: transparent; flex: none; transition: all 0.2s var(--ease); }
.tickbox .ic svg { width: 14px; height: 14px; stroke-width: 3; }
.pick input:checked ~ .tickbox { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pick input:focus-visible ~ .tickbox { outline: 2px solid var(--accent); outline-offset: 2px; }
.sticky-btn { position: sticky; bottom: 14px; margin: auto 16px 0; width: calc(100% - 32px); height: 48px; box-shadow: 0 10px 24px -10px oklch(0.5 0.16 246 / 0.7); }

.viewer { position: fixed; inset: 0; z-index: 100; background: oklch(0.15 0.02 245 / 0.88); display: grid; place-items: center; padding: 24px; animation: fade 0.25s var(--ease); cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 12px; animation: rise 0.35s var(--ease); }
.viewer-x { position: absolute; top: 16px; inset-inline-end: 16px; color: oklch(0.95 0.01 245); background: oklch(1 0 0 / 0.12); }

#toast {
  position: fixed; bottom: 90px; left: 50%; z-index: 200; max-width: min(440px, calc(100vw - 32px)); padding: 11px 18px; border-radius: 99px;
  background: oklch(0.26 0.02 245 / 0.9); color: oklch(0.97 0.005 245); font-size: 14px; text-align: center;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.err { background: oklch(0.5 0.17 25 / 0.95); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: oklch(0.3 0.03 200 / 0.2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { transform: scale(0.9); opacity: 0.7; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .info { inset: 0; width: auto; inset-inline-start: auto; width: min(380px, 100%); border-radius: 0; inset-block: 0; inset-inline-end: 0; }
}
@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .side, .chat { grid-area: 1 / 1; }
  .chat { visibility: hidden; transform: translateX(-30%); opacity: 0; transition: transform 0.4s var(--ease), opacity 0.3s var(--ease), visibility 0s 0.4s; }
  .shell.in-chat .chat { visibility: visible; transform: none; opacity: 1; transition: transform 0.4s var(--ease), opacity 0.3s var(--ease); }
  .shell.in-chat .side { visibility: hidden; transition: visibility 0s 0.4s; }
  .side { background: oklch(0.985 0.006 200 / 0.78); }
  .chat-head { top: max(8px, env(safe-area-inset-top)); inset-inline: 8px; }
  .chat-head .back { display: grid; }
  .e2e { display: none; }
  .composer { bottom: max(8px, env(safe-area-inset-bottom)); inset-inline: 8px; }
  .msgs-inner { padding-inline: 8px; }
  .bubble { max-width: 86%; }
  .info { width: 100%; }
  .gif-panel { inset-inline-end: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- notifications ---------- */
.nag { display: flex; align-items: center; gap: 10px; margin: 2px 2px 8px; padding: 10px 10px 10px 6px; border-radius: 16px; background: var(--paper); box-shadow: 0 1px 3px oklch(0.3 0.03 245 / 0.1); animation: rise 0.4s var(--ease); }
.nag-ic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-hi); }
.nag .grow { line-height: 1.45; }
.nag b { font-size: 14px; }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ic svg { width: 18px; height: 18px; }
.mute-i { color: var(--ink-3); display: inline-flex; }
.item.active .mute-i { color: oklch(0.95 0.03 246); }
.badge.mute { background: oklch(0.3 0.02 245 / 0.28); }
.item.active .badge.mute { background: oklch(0.99 0 0 / 0.35); color: var(--accent-ink); }
.sw-row { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 2px 0; position: relative; }
.sw-row .grow { line-height: 1.45; }
.sw-row b { font-weight: 500; font-size: 14.5px; }
.sw-row.off { cursor: default; opacity: 0.55; }
.sw-row input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.sw { width: 42px; height: 24px; border-radius: 99px; background: oklch(0.3 0.02 245 / 0.18); position: relative; flex: none; transition: background 0.2s var(--ease); }
.sw::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 3px oklch(0.2 0.02 245 / 0.3); transition: transform 0.25s var(--ease); }
.sw-row input:checked + .sw { background: var(--accent); }
.sw-row input:checked + .sw::after { transform: translateX(-18px); }
[dir="ltr"] .sw-row input:checked + .sw::after { transform: translateX(18px); }
.sw-row input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.sec.notif .btn.ghost { align-self: flex-start; padding-inline: 4px; }
.warn { color: var(--danger) !important; }

/* ---------- NEX additions ---------- */
.row.anim .bubble { animation: msgIn 0.32s var(--ease); }
.row.flash .bubble { animation: flash 1.2s var(--ease); }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent), 0 1px 1.5px oklch(0.3 0.04 150 / 0.14); } 100% { box-shadow: 0 1px 1.5px oklch(0.3 0.04 150 / 0.14); } }
.brand-mark .logo-img { width: 70%; height: 70%; object-fit: contain; display: block; }
.brand-mark .logo-txt, .av.sys .logo-txt { color: var(--accent-ink); font-size: 15px; letter-spacing: 0.04em; }
.logo-img { user-select: none; -webkit-user-drag: none; }
.av.sys { background: linear-gradient(160deg, oklch(0.66 0.15 246), oklch(0.5 0.16 256)); }
.av.sys .logo-img { width: 62%; height: 62%; object-fit: contain; border-radius: 0; }
.av.sup { background: linear-gradient(160deg, oklch(0.74 0.13 160), oklch(0.6 0.14 170)); }
.verified { color: var(--accent); display: inline-flex; }
.item.active .verified { color: var(--accent-ink); }
.e2e.off { color: var(--accent-hi); background: var(--accent-soft); letter-spacing: 0; direction: rtl; }
.quote {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-width: 140px; text-align: start; margin: 2px 0 4px;
  padding: 3px 9px 4px; border-radius: 8px; border-inline-start: 3px solid oklch(0.58 0.15 var(--h, 246));
  background: oklch(0.58 0.15 var(--h, 246) / 0.1); line-height: 1.45; font-size: 13.5px;
}
.quote b { color: oklch(0.5 0.15 var(--h, 246)); font-size: 13px; }
.quote span { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; unicode-bidi: plaintext; }
.bubble.media .quote { margin: 4px 4px 3px; width: calc(100% - 8px); }
.reply-bar, .plain-note {
  position: absolute; bottom: calc(100% + 6px); inset-inline: 0; display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 12px; border-radius: 16px; animation: pop 0.2s var(--ease);
}
.reply-bar > .ic { color: var(--accent); }
.reply-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: start; line-height: 1.4; border-inline-start: 3px solid var(--accent); padding-inline-start: 8px; }
.reply-txt b { color: var(--accent-hi); font-size: 13px; }
.reply-txt span { font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plain-note { position: absolute; background: oklch(0.99 0.005 200 / 0.8); font-size: 12.5px; color: var(--ink-2); padding: 8px 12px; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.img-box.gone { cursor: default; display: grid; place-items: center; padding: 12px; min-height: 70px; }
.auth-note.danger { background: var(--danger-soft); color: var(--danger); }
.center { text-align: center; }
