/* ==========================================================================
   BrokenChat — Telegram Android–style UI.
   Colors use light-dark(): the theme only sets color-scheme and every token follows.
   Layout uses logical properties; --dir flips horizontal motion for RTL.
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: light dark;
  --dir: 1;
  --start: left;
  --end: right;

  --accent:     light-dark(#3a8fe0, #5ab1ef);
  --accent-2:   light-dark(#37a3e6, #4fb6e6);      /* teal-blue: ticks, send button */
  --on-accent:  light-dark(#ffffff, #0f1d29);
  --bg:         light-dark(#ffffff, #181818);
  --bg-2:       light-dark(#f0f1f4, #121212);      /* behind cards */
  --card:       light-dark(#ffffff, #212121);
  --field:      light-dark(#f1f2f4, #262626);      /* search pill, folder bar */
  --field-2:    light-dark(#e4e6ea, #333333);      /* active folder chip */
  --ink:        light-dark(#000000, #ffffff);
  --ink-2:      light-dark(#2b2b2b, #e6e6e6);
  --muted:      light-dark(#8a8a8f, #8d8d8d);
  --sep:        light-dark(#ececee, #2a2a2a);
  --hover:      light-dark(rgba(0, 0, 0, .045), rgba(255, 255, 255, .05));
  --ripple:     light-dark(rgba(0, 0, 0, .09), rgba(255, 255, 255, .09));
  --danger:     light-dark(#e53935, #ff5b5b);
  --online:     light-dark(#2fb94f, #4cd964);
  --badge:      light-dark(#3a8fe0, #4a9fe0);
  --badge-mute: light-dark(#b8bcc2, #5a5a5a);
  --tick:       light-dark(#4fae4e, #4fb6e6);
  --bar:        light-dark(rgba(255, 255, 255, .9), rgba(38, 38, 38, .9));
  --bar-line:   light-dark(rgba(0, 0, 0, .07), rgba(255, 255, 255, .06));
  --tab-on:     light-dark(rgba(58, 143, 224, .12), rgba(255, 255, 255, .07));
  --float:      light-dark(rgba(255, 255, 255, .92), rgba(33, 33, 33, .88));
  --switch-off: light-dark(#d3d6db, #4a4a4a);
  --tf-border:  light-dark(#d6d8dc, #3c3c3c);
  --sk-1:       light-dark(#eef0f2, #242424);
  --sk-2:       light-dark(#f8f9fa, #2e2e2e);
  --shadow:     light-dark(rgba(16, 35, 47, .14), rgba(0, 0, 0, .4));
  --shadow-lg:  light-dark(rgba(0, 0, 0, .16), rgba(0, 0, 0, .6));

  /* chat wallpaper: green doodles by day, night sky with clouds by night */
  --w1: light-dark(#dbddbb, #0b1226);
  --w2: light-dark(#6ba587, #121a33);
  --w3: light-dark(#d5d88d, #1a2747);
  --w4: light-dark(#88b884, #24375e);
  --wbase:  light-dark(#b9d1a0, #0a0f1f);
  --doodle: light-dark(rgba(35, 70, 30, .2), transparent);
  --stars:  light-dark(transparent, rgba(255, 255, 255, .75));
  --clouds: light-dark(transparent, #3c5f8f);
  --pill:   light-dark(rgba(64, 88, 52, .45), rgba(20, 20, 20, .62));

  /* bubbles */
  --in:        light-dark(#ffffff, #222222);
  --in-ink:    light-dark(#000000, #ffffff);
  --in-meta:   light-dark(#a1aab3, #8b8b8b);
  --out:       light-dark(#effdde, #26323e);
  --out-ink:   light-dark(#000000, #ffffff);
  --out-meta:  light-dark(#5aa956, #8ea4b8);
  --out-tick:  light-dark(#4fae4e, #4fb6e6);
  --out-quote: light-dark(#4fae4e, #4fb6e6);
  --link:      light-dark(#168acd, #62b8f2);
  --react:     light-dark(rgba(58, 143, 224, .12), rgba(255, 255, 255, .08));
  --react-on:  light-dark(#3a8fe0, #4fb6e6);
  --msg-font:  16px;

  --tail-s: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M9 0v17H0c3.2-.6 6-2.4 7.5-5.2C8.6 9.6 9 5.3 9 0z'/%3E%3C/svg%3E");
  --tail-e: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M0 0v17h9c-3.2-.6-6-2.4-7.5-5.2C.4 9.6 0 5.3 0 0z'/%3E%3C/svg%3E");

  --ease:   cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.45, .64, 1);
  --dur:    .36s;
  --col:    760px;
  --head-h: 76px;
}
:root[dir="rtl"] {
  --dir: -1;
  --start: right;
  --end: left;
  --tail-s: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M0 0v17h9c-3.2-.6-6-2.4-7.5-5.2C.4 9.6 0 5.3 0 0z'/%3E%3C/svg%3E");
  --tail-e: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M9 0v17H0c3.2-.6 6-2.4 7.5-5.2C8.6 9.6 9 5.3 9 0z'/%3E%3C/svg%3E");
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Vazirmatn', Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px; line-height: 1.4; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow: hidden; transition: opacity .25s var(--ease);
}
body.leaving { opacity: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--link); text-decoration: none; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 35%, transparent) transparent; }

svg.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; display: block; flex-shrink: 0; }
svg.fill { fill: currentColor; stroke: none; }
:root[dir="rtl"] svg.flip { transform: scaleX(-1); }

::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }
.theming, .theming * { transition: background-color .45s var(--ease), color .45s var(--ease), border-color .45s var(--ease) !important; }

/* ---------------------------------------------------------------- primitives */
.rp { position: relative; overflow: hidden; isolation: isolate; }
.ripple { position: absolute; border-radius: 50%; pointer-events: none; z-index: -1; background: var(--ripple); transform: scale(0); animation: ripple .6s cubic-bezier(.2, .6, .3, 1) forwards; }
.btn .ripple, .fab .ripple, .send .ripple { background: rgba(255, 255, 255, .3); }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: var(--muted); transition: background-color .2s, color .2s, transform .25s var(--spring); }
.icon-btn:hover { background: var(--hover); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.accent { color: var(--accent); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .75s linear infinite; flex-shrink: 0; }

.switch { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--switch-off); flex-shrink: 0; transition: background-color .25s; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 10px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); transition: inset-inline-start .32s var(--spring), width .2s var(--ease); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { inset-inline-start: 21px; }
:active > .switch::after { width: 26px; }
:active > .switch[aria-checked="true"]::after { inset-inline-start: 15px; }

.radio { position: relative; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); flex-shrink: 0; transition: border-color .2s; }
.radio::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); transform: scale(0); transition: transform .3s var(--spring); }
.on > .radio { border-color: var(--accent); }
.on > .radio::after { transform: scale(1); }

.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 52px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; transition: transform .2s var(--spring), filter .2s; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn .spinner { display: none; }
.btn.loading { pointer-events: none; }
.btn.loading .spinner { display: block; }
.btn.danger { background: var(--danger); }

/* Outlined field with a notched label (Telegram Android). */
.tf { position: relative; display: block; margin: 0 16px 20px; }
.tf input, .tf textarea {
  width: 100%; border: 1.5px solid var(--tf-border); border-radius: 14px; background: transparent;
  padding: 17px 16px; font-size: 17px; line-height: 1.35; outline: 0; resize: none; color: var(--ink);
  transition: border-color .2s, box-shadow .2s;
}
.tf textarea { min-height: 100px; }
.tf.has-eye input { padding-inline-end: 52px; }
.tf > span {
  position: absolute; top: 18px; inset-inline-start: 12px; padding: 0 6px; line-height: 1.3; font-size: 17px;
  color: var(--muted); background: var(--tf-bg, var(--bg)); pointer-events: none; transform-origin: var(--start) center;
  transition: transform .22s var(--ease), color .2s;
}
.tf input:focus, .tf textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2); }
.tf :is(input, textarea):is(:focus, :not(:placeholder-shown)) + span { transform: translateY(-29px) scale(.82); }
.tf :is(input, textarea):focus + span { color: var(--accent-2); }
.tf .count { position: absolute; inset-inline-end: 14px; bottom: 12px; font-size: 13px; font-style: normal; color: var(--muted); }
.tf .eye { position: absolute; inset-inline-end: 6px; top: 7px; }
.tf .eye.on { color: var(--accent); }
/* Fixed-LTR fields (email, password, username) stay aligned with the Persian interface. */
:root[dir="rtl"] .tf input[dir="ltr"]:not([data-bidi]) { text-align: right; }
button.info { display: block; width: 100%; text-align: start; }
.b a.mention { font-weight: 500; }

/* ---------------------------------------------------------------- auth pages */
.auth-page { overflow: auto; background: var(--bg); }
.auth-top { position: fixed; top: 0; inset-inline: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: max(env(safe-area-inset-top), 10px) 8px 6px; }
.auth-top .icon-btn { color: var(--ink); }
.lang-switch { font-size: 14px; font-weight: 600; color: var(--accent); background: var(--field); padding: 7px 16px; border-radius: 20px; margin-inline-end: 8px; transition: transform .2s var(--spring); }
.lang-switch:active { transform: scale(.95); }
.auth { width: min(420px, 100%); margin: 0 auto; padding: clamp(84px, 16vh, 150px) 16px 140px; text-align: center; }
.auth > * { animation: rise .55s var(--ease) both; }
.auth > :nth-child(2) { animation-delay: .05s; }
.auth > :nth-child(3) { animation-delay: .1s; }
.auth > :nth-child(4) { animation-delay: .15s; }
.auth > :nth-child(5) { animation-delay: .2s; }
.auth-logo { width: 96px; height: 96px; margin: 0 auto 26px; }
.auth-logo img { width: 100%; height: 100%; animation: float 4s ease-in-out infinite; }
.auth h1 { font-size: 24px; font-weight: 600; }
.auth-sub { color: var(--muted); margin: 10px 16px 34px; font-size: 16px; line-height: 1.5; }
.auth-form { text-align: start; }
/* Opacity only: a transform here would trap the fixed round button inside the form. */
.auth > .auth-form { animation-name: fadeIn; }
.auth-form .tf { margin: 0 8px 24px; }
.auth-form .hint { font-size: 13.5px; color: var(--muted); margin: -16px 12px 22px; }
.auth-note { margin: -18px 12px 24px; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-2); font-size: 14.5px; }
.auth-switch { margin-top: 6px; color: var(--muted); font-size: 15px; }
.auth-switch a { font-weight: 600; }
.auth-alert { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-radius: 12px; padding: 11px 16px; margin: 0 8px 22px; font-size: 14.5px; text-align: start; }
.auth-alert ~ .auth-form { animation: shake .45s var(--ease) .15s; }
.auth-fab {
  position: fixed; bottom: calc(28px + env(safe-area-inset-bottom)); inset-inline-end: max(24px, calc(50% - 210px + 16px)); z-index: 3;
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); transition: transform .3s var(--spring);
}
.auth-fab:hover { transform: scale(1.06); }
.auth-fab:active { transform: scale(.92); }
.auth-fab svg.i { width: 28px; height: 28px; stroke-width: 2.2; }
.auth-fab .spinner { display: none; width: 24px; height: 24px; }
.auth-fab.loading svg.i { display: none; }
.auth-fab.loading .spinner { display: block; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: minmax(320px, min(32vw, 420px)) 1fr; height: 100dvh; background: var(--bg); }
/* iOS keyboard: the app follows the visible area (see trackKeyboard in ui.js). */
.app { height: var(--app-h, 100dvh); }
.kb-open .app { transform: translateY(var(--app-top, 0px)); }
.side { position: relative; overflow: hidden; background: var(--bg); border-inline-end: 1px solid var(--sep); z-index: 2; }
.pages { position: absolute; inset: 0; }
.page { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.page.enter { animation: pageIn .32s var(--ease); }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.page-body { padding-bottom: 120px; }

.top { display: flex; align-items: center; gap: 6px; min-height: 64px; padding: max(env(safe-area-inset-top), 8px) 12px 4px 20px; padding-inline: 20px 8px; flex-shrink: 0; }
.brand { flex: 1; font-size: 25px; font-weight: 600; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- search & folders */
.search-row { padding: 4px 14px 10px; flex-shrink: 0; }
.search { display: flex; align-items: center; gap: 10px; height: 48px; padding-inline: 18px 8px; border-radius: 24px; background: var(--field); color: var(--muted); border: 1.5px solid transparent; transition: border-color .2s, background-color .2s; }
.search:focus-within { border-color: var(--accent); }
.search > svg.i { width: 22px; height: 22px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 17px; color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); opacity: 0; transform: scale(.4); pointer-events: none; transition: transform .25s var(--spring), opacity .2s; }
.search-clear svg.i { width: 18px; height: 18px; }
.search.has-text .search-clear { opacity: 1; transform: none; pointer-events: auto; }

.folders { position: relative; display: flex; gap: 2px; margin: 0 14px 8px; padding: 4px; border-radius: 24px; background: var(--field); flex-shrink: 0; overflow-x: auto; scrollbar-width: none; transition: opacity .25s, transform .3s var(--ease), max-height .3s var(--ease); max-height: 60px; }
.folders.gone { opacity: 0; max-height: 0; margin-bottom: 0; padding: 0; transform: translateY(-8px); pointer-events: none; }
.folder { position: relative; z-index: 1; display: flex; align-items: center; gap: 7px; height: 40px; padding: 0 16px; border-radius: 20px; font-size: 16px; font-weight: 500; color: var(--muted); white-space: nowrap; transition: color .25s; }
.folder.on { color: var(--ink); }
.folder b { min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; display: grid; place-items: center; background: var(--badge-mute); color: #fff; font-size: 13px; font-weight: 600; }
.folder b:empty { display: none; }
.folder-ind { position: absolute; top: 4px; bottom: 4px; z-index: 0; border-radius: 20px; background: var(--field-2); transition: inset-inline-start .38s var(--spring), width .38s var(--spring); }

.conn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 0; overflow: hidden; opacity: 0; color: var(--accent); font-size: 14px; font-weight: 500; transition: height .3s var(--ease), opacity .3s; flex-shrink: 0; }
.conn.on { height: 30px; opacity: 1; }
/* A server-side problem (database unreachable): the reason, wrapped, in the danger colour. */
.conn.problem.on { height: auto; min-height: 30px; padding: 8px 16px; color: var(--danger); text-align: center; line-height: 1.5; }
.conn.problem .spinner { display: none; }
.conn:not(.on) .spinner { animation-play-state: paused; } /* collapsed: don't spin in the background */

/* ---------------------------------------------------------------- chat list */
.list { padding: 0 0 120px; }
.row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 76px; padding: 8px 16px; text-align: start; transition: background-color .2s; }
.row:hover { background: var(--hover); }
.row.active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.row.enter { animation: rowIn .42s var(--ease) both; animation-delay: calc(var(--i, 0) * 26ms); }
.row-body { flex: 1; min-width: 0; }
.row-top, .row-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-name { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { display: flex; align-items: center; gap: 3px; flex-shrink: 0; font-size: 14px; color: var(--muted); }
.row-time .tick { width: 20px; height: 20px; color: var(--tick); stroke-width: 2; }
.row-text { margin-top: 3px; font-size: 16px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-text .me { color: var(--ink-2); }
.row-text.typing { color: var(--accent); }
.row-text i { font-style: italic; }
.draft { color: var(--danger); }
.badge { min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; background: var(--badge); color: #fff; font-size: 14px; font-weight: 600; }
.badge.bump { animation: bump .45s var(--spring); }
.list-label { padding: 14px 20px 6px; font-size: 15px; font-weight: 600; color: var(--accent); animation: rise .3s var(--ease); }
.sub-online { color: var(--accent); }

.empty { padding: 60px 28px; text-align: center; color: var(--muted); animation: rise .5s var(--ease); }
.empty .art { font-size: 64px; line-height: 1; margin-bottom: 16px; display: inline-block; animation: float 3.2s ease-in-out infinite; }
.empty b { display: block; color: var(--ink); font-size: 18px; font-weight: 600; margin-bottom: 6px; }

.sk-row { display: flex; align-items: center; gap: 14px; padding: 10px 16px; }
.sk-row .sk-av { width: 56px; height: 56px; border-radius: 50%; }
.sk-row .sk-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.sk-row .sk-line { height: 13px; border-radius: 7px; }
.sk { background: linear-gradient(90deg, var(--sk-1) 25%, var(--sk-2) 37%, var(--sk-1) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }

/* ---------------------------------------------------------------- floating tab bar */
.tabbar {
  position: absolute; z-index: 6; inset-inline: 14px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(4, 1fr); height: 68px; padding: 6px; border-radius: 34px;
  background: var(--bar); box-shadow: 0 0 0 1px var(--bar-line), 0 8px 24px var(--shadow);
  backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  transition: transform .35s var(--ease), opacity .25s;
}
.tabbar.hide { transform: translateY(140%); opacity: 0; }
.tab-ind { position: absolute; top: 6px; bottom: 6px; width: calc((100% - 12px) / 4); inset-inline-start: calc(6px + var(--tab-i, 0) * (100% - 12px) / 4); border-radius: 28px; background: var(--tab-on); transition: inset-inline-start .45s var(--spring); }
.tab { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 28px; color: var(--ink-2); font-size: 13.5px; font-weight: 500; transition: color .25s; }
.tab.on { color: var(--accent); }
.tab-ic { position: relative; display: grid; place-items: center; height: 28px; transition: transform .35s var(--spring); }
.tab.on .tab-ic { animation: tabPop .45s var(--spring); }
.tab-ic svg.i { width: 27px; height: 27px; }
.tab-ic .av { box-shadow: 0 0 0 2px transparent; transition: box-shadow .25s; }
.tab.on .tab-ic .av { box-shadow: 0 0 0 2px var(--accent); }
.tab-badge { position: absolute; top: -6px; inset-inline-start: 15px; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 11px; display: grid; place-items: center; background: var(--badge); color: #fff; font-size: 12px; font-weight: 600; box-shadow: 0 0 0 2px var(--bar); animation: pop .35s var(--spring); }

/* ---------------------------------------------------------------- avatars */
.av { position: relative; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 600; user-select: none; text-transform: uppercase; overflow: visible; }
.av img:not(.emj) { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; animation: fadeIn .3s; }
/* Name starting with an emoji: the Apple image is the avatar letter, centred like a glyph. */
.av > img.emj { position: static; width: 1.2em; height: 1.2em; margin: 0; border-radius: 0; object-fit: contain; vertical-align: 0; }
.av[data-c="0"] { background: linear-gradient(180deg, #ff885e, #ff516a); }
.av[data-c="1"] { background: linear-gradient(180deg, #ffcd6a, #ffa85c); }
.av[data-c="2"] { background: linear-gradient(180deg, #82b1ff, #665fff); }
.av[data-c="3"] { background: linear-gradient(180deg, #a0de7e, #54cb68); }
.av[data-c="4"] { background: linear-gradient(180deg, #53edd6, #28c9b7); }
.av[data-c="5"] { background: linear-gradient(180deg, #e0a2f3, #d669ed); }
.av.online::after { content: ''; position: absolute; z-index: 1; bottom: 1px; inset-inline-end: 1px; width: 26%; height: 26%; min-width: 12px; min-height: 12px; border-radius: 50%; background: var(--online); box-shadow: 0 0 0 3px var(--bg); animation: pop .4s var(--spring); }

/* ---------------------------------------------------------------- chat & wallpaper */
.chat { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--wbase); }
.wall, .wall > div { position: absolute; inset: 0; pointer-events: none; }
.wall { overflow: hidden; }
.wall .wall-grad {
  inset: -45%;
  background:
    radial-gradient(closest-side at 32% 30%, var(--w1), transparent),
    radial-gradient(closest-side at 72% 26%, var(--w2), transparent),
    radial-gradient(closest-side at 70% 74%, var(--w3), transparent),
    radial-gradient(closest-side at 28% 72%, var(--w4), transparent),
    var(--wbase);
  transition: transform 1.4s var(--ease);
}
.wall-doodle { background: var(--doodle); -webkit-mask: url(pattern.svg) 0 0 / 360px repeat; mask: url(pattern.svg) 0 0 / 360px repeat; }
.wall-stars  { background: var(--stars);  -webkit-mask: url(stars.svg) 0 0 / 400px repeat; mask: url(stars.svg) 0 0 / 400px repeat; animation: twinkle 6s ease-in-out infinite alternate; }
/* Phones show the chat over the list: pause the wallpaper while no chat is open (hidden tabs are throttled by the browser). */
@media (max-width: 760px) { .app:not(.chat-open) .wall-stars { animation-play-state: paused; } }
.wall .wall-clouds { top: auto; height: 38%; background: var(--clouds); -webkit-mask: url(clouds.svg) bottom center / cover no-repeat; mask: url(clouds.svg) bottom center / cover no-repeat; opacity: .85; }

.chat-empty { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; }
.chat-empty span { padding: 7px 16px; border-radius: 18px; background: var(--pill); color: #fff; font-size: 15px; font-weight: 500; backdrop-filter: blur(8px); animation: rise .5s var(--ease); }

/* Floating header: round back button, title pill, round menu button. */
.chat-top { position: absolute; z-index: 5; top: 0; inset-inline: 0; display: flex; align-items: center; gap: 8px; padding: max(env(safe-area-inset-top), 10px) 12px 10px; pointer-events: none; }
.chat-top > * { pointer-events: auto; }
.fbtn, .fpill { background: var(--float); color: var(--ink); box-shadow: 0 1px 4px var(--shadow); backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5); }
.fbtn { position: relative; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; transition: transform .25s var(--spring), background-color .2s; }
.fbtn:active { transform: scale(.9); }
.back-btn { color: var(--accent); }
.back-btn b { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; background: var(--badge); color: #fff; font-size: 12px; font-weight: 600; animation: pop .3s var(--spring); }
.back-btn b:empty { display: none; }
.fpill { flex: 1; min-width: 0; height: 56px; display: flex; align-items: center; gap: 12px; padding-inline: 7px 18px; border-radius: 28px; text-align: start; transition: transform .25s var(--spring); }
.fpill:active { transform: scale(.98); }
.peer-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.peer-text b { font-size: 17.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-text small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; color: var(--muted); transition: color .3s; }
.peer-text small.on { color: var(--accent-2); }
.peer-text small.swap { animation: swap .32s var(--ease); }
.dots { display: inline-flex; gap: 3px; margin-inline-start: 4px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }

/* ---------------------------------------------------------------- messages */
.msgs {
  position: absolute; inset: 0; z-index: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; overflow-anchor: none;
  display: flex; flex-direction: column;
  padding: calc(var(--head-h) + env(safe-area-inset-top) + 4px) max(12px, calc((100% - var(--col)) / 2)) calc(var(--composer-h, 76px) + 10px);
}
.msgs::before { content: ''; flex: 1; }
.msgs.chat-in { animation: chatIn .38s var(--ease); }

.day { position: sticky; top: calc(var(--head-h) + env(safe-area-inset-top)); z-index: 3; align-self: center; margin: 10px 0 6px; padding: 4px 13px; border-radius: 15px; background: var(--pill); color: #fff; font-size: 15px; font-weight: 600; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.unread-div { align-self: stretch; margin: 10px calc(-1 * max(12px, (100% - var(--col)) / 2)) 6px; padding: 5px; text-align: center; font-size: 14.5px; font-weight: 500; color: var(--ink-2); background: var(--pill); color: #fff; animation: rise .4s var(--ease); }
.loader { align-self: center; color: #fff; padding: 9px; background: var(--pill); border-radius: 50%; margin: 6px 0; }
.empty-chat { align-self: center; margin: auto 0; padding: 20px 28px; border-radius: 20px; text-align: center; background: var(--pill); color: #fff; backdrop-filter: blur(8px); animation: rise .5s var(--ease); }
.empty-chat .art { font-size: 52px; display: block; margin-bottom: 8px; animation: float 3s ease-in-out infinite; }

.b {
  position: relative; max-width: min(80%, 500px); margin-top: 2px; padding: 7px 12px 7px 12px;
  border-radius: 18px; font-size: var(--msg-font); line-height: 1.36; overflow-wrap: anywhere;
}
.b:not(.jp) { margin-top: 7px; }
.b.in  { align-self: flex-start; background: var(--in);  color: var(--in-ink);  transform-origin: var(--start) bottom; --q: var(--accent-2); }
.b.out { align-self: flex-end;   background: var(--out); color: var(--out-ink); transform-origin: var(--end) bottom;   --q: var(--out-quote); }
.b.in.jp  { border-start-start-radius: 6px; }
.b.in.jn  { border-end-start-radius: 6px; }
.b.out.jp { border-start-end-radius: 6px; }
.b.out.jn { border-end-end-radius: 6px; }
.b.in.tail  { border-end-start-radius: 0; }
.b.out.tail { border-end-end-radius: 0; }
.b.tail::after { content: ''; position: absolute; bottom: 0; width: 9px; height: 17px; background: inherit; -webkit-mask: no-repeat; mask: no-repeat; }
.b.in.tail::after  { inset-inline-start: -8.5px; -webkit-mask-image: var(--tail-s); mask-image: var(--tail-s); }
.b.out.tail::after { inset-inline-end: -8.5px;   -webkit-mask-image: var(--tail-e); mask-image: var(--tail-e); }

.b .txt { white-space: pre-wrap; }
.b a { color: var(--link); }
.meta {
  float: inline-end; position: relative; top: 4px; display: inline-flex; align-items: center; gap: 3px; height: 18px;
  margin-inline-start: 12px; margin-top: 4px; margin-bottom: -3px; font-size: 13px; line-height: 1; white-space: nowrap; user-select: none;
}
.b.in .meta  { color: var(--in-meta); }
.b.out .meta { color: var(--out-meta); }
.meta .ed { font-size: 12.5px; }
.tick { width: 19px; height: 19px; stroke-width: 2; color: var(--out-tick); }
.tick.draw path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .45s var(--ease) forwards; }
.tick.draw path + path { animation-delay: .14s; }
.b.pending .tick { animation: spin 2s linear infinite; }
.b.deleted .txt { font-style: italic; opacity: .65; }

.quote { display: block; width: 100%; min-width: 150px; margin: 2px 0 6px; padding: 5px 10px; text-align: start; border-inline-start: 3px solid var(--q); border-radius: 8px; background: color-mix(in srgb, var(--q) 14%, transparent); font-size: 15px; line-height: 1.35; color: inherit; transition: background-color .2s; }
.quote:hover { background: color-mix(in srgb, var(--q) 22%, transparent); }
.quote b { display: block; color: var(--q); font-size: 15px; font-weight: 600; }
.quote span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }

.reacts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.react { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px 0 8px; padding-inline: 8px 10px; border-radius: 15px; background: var(--react); color: inherit; font-size: 14px; font-weight: 600; transition: transform .2s var(--spring), background-color .2s; animation: pop .4s var(--spring); }
.react .e { font-size: 17px; line-height: 1; }
.react.on { background: var(--react-on); color: #fff; }
.react:active { transform: scale(.9); }
.b > .reacts { padding-bottom: 1px; }
.reacts .meta { float: none; top: 0; margin-inline-start: auto; align-self: flex-end; }

/* Time sits at the interface's end of the bubble (like Telegram), whatever the text direction. */
:root[dir="ltr"] .b:not(.emoji) .c > .meta { float: right; margin-left: 12px; margin-right: 0; }
:root[dir="rtl"] .b:not(.emoji) .c > .meta { float: left; margin-right: 12px; margin-left: 0; }

/* ---------------------------------------------------------------- Apple-style emoji images */
img.emj { display: inline-block; width: 1.2em; height: 1.2em; margin: 0 .05em; vertical-align: -.24em; object-fit: contain; pointer-events: none; }
.b.emoji img.emj { width: 1.08em; height: 1.08em; margin: 0 .02em; vertical-align: bottom; }
.react .e img.emj { width: 18px; height: 18px; margin: 0; vertical-align: middle; }
.ctx-react img.emj { width: 34px; height: 34px; margin: 0; }
.art img.emj { width: 1em; height: 1em; margin: 0; }
:root.emj-on .b.heart-pop::before { content: ''; background: var(--heart-img) center / 60px no-repeat; }

.b.emoji { background: none; padding: 0; }
.b.emoji::after { display: none; }
.b.emoji .c { display: flex; flex-direction: column; align-items: flex-end; }
.b.emoji .txt { font-size: calc(var(--msg-font) * 3.3); line-height: 1.15; }
.b.emoji .meta { float: none; top: 0; margin: 2px 0 0; padding: 0 8px; height: 22px; border-radius: 11px; background: var(--pill); color: #fff; }
.b.emoji .tick { color: #fff; }

.b.enter.out   { animation: popOut .42s var(--spring) both; }
.b.enter.in    { animation: popIn .4s var(--ease) both; }
.b.enter.emoji { animation: emojiIn .7s var(--spring) both; }
.b.swap  { animation: fadeIn .35s var(--ease); }
.b.flash { animation: flash 1.3s var(--ease); }
.b.swiping { transition: none; }
.b.swipe-back { transition: transform .35s var(--spring); }
.b.heart-pop::before { content: '❤️'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 46px; pointer-events: none; animation: heart .7s var(--ease) forwards; }
.sw-ic { position: absolute; top: 50%; inset-inline-end: -48px; width: 36px; height: 36px; margin-top: -18px; border-radius: 50%; display: grid; place-items: center; background: var(--pill); color: #fff; opacity: var(--p, 0); transform: scale(calc(.4 + var(--p, 0) * .6)); transition: background-color .2s; }
.sw-ic svg.i { width: 20px; height: 20px; }
.b.armed .sw-ic { background: var(--accent); }

.typing-b { display: flex; gap: 4px; padding: 14px 16px; }
.typing-b i { width: 7px; height: 7px; border-radius: 50%; background: var(--in-meta); animation: dot 1.2s infinite; }
.typing-b i:nth-child(2) { animation-delay: .15s; }
.typing-b i:nth-child(3) { animation-delay: .3s; }
.sk-b { height: 40px; border-radius: 18px; margin-top: 8px; opacity: .5; }
.sk-b.in { align-self: flex-start; }
.sk-b.out { align-self: flex-end; }

.lift-clone { position: fixed !important; z-index: 31; margin: 0 !important; pointer-events: none; transition: transform .28s var(--spring), box-shadow .28s; }
.lift-clone.up { transform: scale(1.03); box-shadow: 0 14px 34px var(--shadow-lg); }

.to-bottom { position: absolute; z-index: 5; bottom: calc(var(--composer-h, 76px) + 12px); inset-inline-end: max(14px, calc((100% - var(--col)) / 2 - 70px)); color: var(--muted); opacity: 0; transform: translateY(24px) scale(.5); pointer-events: none; transition: transform .35s var(--spring), opacity .2s; }
.to-bottom.show { opacity: 1; transform: none; pointer-events: auto; }
.to-bottom svg.i { width: 28px; height: 28px; color: var(--accent-2); }
.to-bottom b { position: absolute; top: -8px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; display: grid; place-items: center; background: var(--badge); color: #fff; font-size: 12.5px; animation: pop .35s var(--spring); }
.to-bottom b:empty { display: none; }

/* ---------------------------------------------------------------- composer (floating) */
.composer { position: absolute; z-index: 5; bottom: 0; inset-inline: 0; padding: 6px max(12px, calc((100% - var(--col)) / 2)) calc(12px + env(safe-area-inset-bottom)); }
.compose { display: flex; align-items: flex-end; gap: 8px; }
.input-box { flex: 1; min-width: 0; border-radius: 28px; background: var(--float); box-shadow: 0 1px 4px var(--shadow); backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5); }
.ctx-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s var(--ease); }
.ctx-wrap.on { grid-template-rows: 1fr; }
.ctx-inner { overflow: hidden; min-height: 0; }
.ctx-bar { display: flex; align-items: center; gap: 12px; padding: 8px 0 0; padding-inline: 18px 6px; color: var(--accent-2); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .3s var(--ease); }
.ctx-wrap.on .ctx-bar { opacity: 1; transform: none; }
.ctx-ic svg.i { width: 24px; height: 24px; }
.ctx-text { flex: 1; min-width: 0; padding-inline-start: 10px; border-inline-start: 2.5px solid var(--accent-2); line-height: 1.3; }
.ctx-text b { display: block; font-size: 15px; font-weight: 600; }
.ctx-text span { display: block; font-size: 15px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.input-row { display: flex; align-items: flex-end; gap: 2px; padding: 4px 8px; min-height: 56px; }
.input-row textarea { flex: 1; min-width: 0; max-height: 170px; padding: 12px 4px 11px; border: 0; outline: 0; resize: none; background: none; font-size: 17px; line-height: 1.4; color: var(--ink); }
.input-row textarea::placeholder { color: var(--muted); }
.input-row .icon-btn { width: 44px; height: 48px; }
.emoji-btn.on { color: var(--accent-2); }
.send { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--accent-2); color: var(--on-accent); box-shadow: 0 2px 8px var(--shadow); transition: transform .35s var(--spring), background-color .25s, color .25s; }
.send:active { transform: scale(.88); }
.send-ic { display: grid; transition: transform .4s var(--spring); }
.send-ic svg.i { width: 26px; height: 26px; stroke-width: 2.1; }
.send.idle .send-ic { transform: scale(.88) rotate(calc(-18deg * var(--dir))); }
.send.idle { opacity: .9; }
.send.fly .send-ic { animation: fly .55s var(--ease); }
.send.swap-ic .send-ic { animation: icSwap .35s var(--spring); }


/* ---------------------------------------------------------------- settings & profile */
.card { margin: 0 14px 14px; border-radius: 22px; background: var(--card); overflow: hidden; }
:root .page, :root .panel { --tf-bg: var(--bg); }
.page-body .card, .panel .card { animation: rise .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms + 40ms); }
.sec { padding: 16px 20px 6px; font-size: 15px; font-weight: 600; color: var(--accent); }
.cell { display: flex; align-items: center; gap: 18px; width: 100%; min-height: 56px; padding: 10px 18px; text-align: start; transition: background-color .15s; }
.cell:hover { background: var(--hover); }
.cell .ci { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.cell .ci svg.i { width: 24px; height: 24px; stroke-width: 2; }
.cell .ci.plain { width: 28px; height: 28px; background: none !important; color: var(--muted); }
.cell .cl { flex: 1; min-width: 0; font-size: 17px; }
.cell .cl small { display: block; margin-top: 1px; font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .cv { max-width: 45%; color: var(--accent); font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .chev { width: 20px; height: 20px; color: var(--muted); opacity: .55; }
.cell.danger { color: var(--danger); }
.cell.tall { min-height: 72px; }
.hint { padding: 0 20px 14px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.foot { padding: 6px 18px 20px; text-align: center; font-size: 13px; color: var(--muted); }

.me-head { text-align: center; padding: 6px 16px 20px; }
.me-head .ph { position: relative; display: inline-block; margin-bottom: 12px; }
.me-head .cam { position: absolute; bottom: 0; inset-inline-end: 0; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--bg); transition: transform .25s var(--spring); }
.me-head .cam:active { transform: scale(.9); }
.me-head .cam svg.i { width: 21px; height: 21px; }
.me-head .ph.busy::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 3px solid var(--accent); border-top-color: transparent; animation: spin .9s linear infinite; }
.me-head h3 { font-size: 26px; font-weight: 600; }
.me-head p { font-size: 15.5px; color: var(--muted); direction: ltr; unicode-bidi: plaintext; }

/* Profile tab & peer profile: colored hero header. */
.hero { position: relative; overflow: hidden; padding: calc(max(env(safe-area-inset-top), 10px) + 56px) 16px 22px; text-align: center; color: #fff; }
.hero-bg { position: absolute; inset: 0; z-index: 0; background: var(--hero, linear-gradient(160deg, #6a4fc8, #4b3a9a)); }
.hero-bg::after { content: ''; position: absolute; inset: 0; background: rgba(255, 255, 255, .13); -webkit-mask: url(pattern.svg) 0 0 / 300px repeat; mask: url(pattern.svg) 0 0 / 300px repeat; }
.hero > :not(.hero-bg) { position: relative; z-index: 1; }
.hero .av { margin: 0 auto 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: pop .5s var(--spring); }
.hero h2 { font-size: 27px; font-weight: 600; line-height: 1.2; }
.hero .st { font-size: 16px; opacity: .85; margin-top: 4px; }
.hero-top { position: absolute; top: 0; inset-inline: 0; display: flex; justify-content: space-between; padding: max(env(safe-area-inset-top), 8px) 8px; }
.hero-top .icon-btn { color: #fff; }
.hero-top .icon-btn:hover { background: rgba(255, 255, 255, .14); }
.hero-actions { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 10px; margin: 22px 4px 0; }
.hero-actions button { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 6px 10px; border-radius: 18px; background: rgba(255, 255, 255, .16); color: #fff; font-size: 15px; font-weight: 500; transition: transform .25s var(--spring), background-color .2s; }
.hero-actions button:hover { background: rgba(255, 255, 255, .22); }
.hero-actions button:active { transform: scale(.95); }
.hero-actions svg.i { width: 26px; height: 26px; }
.info { padding: 12px 22px; }
.info b { display: block; font-size: 17px; font-weight: 400; overflow-wrap: anywhere; }
.info b.link { color: var(--accent-2); }
.info small { font-size: 14.5px; color: var(--muted); }
.info + .info { border-top: 1px solid var(--sep); }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 8px 18px 16px; }
.theme-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px; border-radius: 16px; font-size: 14.5px; font-weight: 500; color: var(--muted); transition: color .2s; }
.theme-card.on { color: var(--accent); }
.tc-prev { position: relative; width: 100%; aspect-ratio: 3 / 4; padding: 10px 9px; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; box-shadow: 0 0 0 2px var(--sep); transition: box-shadow .25s, transform .35s var(--spring); }
.theme-card:hover .tc-prev { transform: translateY(-3px); }
.theme-card.on .tc-prev { box-shadow: 0 0 0 2.5px var(--accent); }
.tc-prev.light { background: linear-gradient(140deg, #dbddbb, #88b884); }
.tc-prev.dark  { background: linear-gradient(170deg, #0b1226, #24375e); }
.tc-prev.auto  { background: linear-gradient(140deg, #dbddbb 0 50%, #0b1226 50% 100%); }
.tc-prev > i { display: block; height: 11px; border-radius: 6px; width: 62%; }
.tc-prev .tin { align-self: flex-start; background: #fff; }
.tc-prev .tout { align-self: flex-end; background: #effdde; }
.tc-prev.dark .tin { background: #222; }
.tc-prev.dark .tout, .tc-prev.auto .tout { background: #26323e; }
.tc-check { position: absolute; top: 7px; inset-inline-end: 7px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; transform: scale(0); transition: transform .35s var(--spring); }
.tc-check svg.i { width: 14px; height: 14px; stroke-width: 3; }
.theme-card.on .tc-check { transform: scale(1); }

.preview { position: relative; margin: 6px 14px 4px; height: 170px; border-radius: 18px; overflow: hidden; background: var(--wbase); }
.preview .msgs-prev { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 14px 22px; }
.preview .b { animation: none; }
.slider { display: flex; align-items: center; gap: 14px; padding: 10px 20px 16px; color: var(--muted); }
.slider input { flex: 1; accent-color: var(--accent); }
.slider .sz { min-width: 28px; text-align: center; color: var(--ink); font-weight: 600; }

.colors { display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 20px 18px; }
.colors button { border-radius: 50%; transition: transform .25s var(--spring); }
.colors button:hover { transform: scale(1.1); }
.colors button .av { transition: box-shadow .25s; }
.colors button.on .av { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--accent); }
.edit-ph { display: grid; place-items: center; padding: 8px 0 26px; }
.edit-ph .ph { position: relative; }
.edit-ph .ph .av { animation: pop .45s var(--spring); }
.edit-ph .ph button { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .3); opacity: 0; transition: opacity .2s; }
.edit-ph .ph:hover button, .edit-ph .ph button:focus-visible { opacity: 1; }
.edit-ph .ph button svg.i { width: 34px; height: 34px; }
.form-pad { padding-top: 6px; }

/* Sub-pages slide over the sidebar (including the tab bar). */
.panel { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; background: var(--bg); transform: translateX(calc(100% * var(--dir))); box-shadow: 0 0 24px var(--shadow-lg); transition: transform var(--dur) var(--ease); }
.panel.in { transform: none; }
.side::after { content: ''; position: absolute; inset: 0; z-index: 7; background: #000; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); }
.side.covered::after { opacity: .18; }
.panel-head { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: max(env(safe-area-inset-top), 8px) 8px 4px; flex-shrink: 0; }
.panel-head h2 { flex: 1; font-size: 21px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head .icon-btn { color: var(--ink); }
.panel .scroller { padding-bottom: 110px; }
.panel.hero-panel .panel-head { position: absolute; z-index: 3; inset-inline: 0; top: 0; background: transparent; }
.panel.hero-panel .panel-head .icon-btn { color: #fff; }
.fab { position: absolute; z-index: 9; bottom: calc(24px + env(safe-area-inset-bottom)); inset-inline-end: 22px; width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); transition: transform .4s var(--spring), opacity .2s; }
.fab:active { transform: scale(.92); }
.fab.hide { transform: scale(0) rotate(calc(90deg * var(--dir))); opacity: 0; pointer-events: none; }
.fab svg.i { width: 28px; height: 28px; stroke-width: 2.2; }
.fab .spinner { display: none; width: 24px; height: 24px; }
.fab.loading svg.i { display: none; }
.fab.loading .spinner { display: block; }
.fab.shake { animation: shake .4s var(--ease); }

/* Peer profile slides over the chat. */
.peer-page { position: absolute; inset: 0; z-index: 9; overflow-y: auto; background: var(--bg-2); transform: translateX(calc(100% * var(--dir))); transition: transform var(--dur) var(--ease); }
.peer-page.in { transform: none; }
.peer-page .card { margin-top: 14px; }

/* ---------------------------------------------------------------- overlays */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .22); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fadeIn .2s; }
.scrim.clear { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.scrim.out { animation: fadeOut .18s forwards; }

/* Context menu: optional reaction strip on top, card of actions below. */
.ctx { position: fixed; z-index: 32; display: flex; flex-direction: column; gap: 10px; animation: menuIn .26s var(--spring); }
.ctx.out { animation: menuOut .16s ease-in forwards; }
.ctx-react { display: flex; gap: 2px; max-width: calc(100vw - 20px); overflow-x: auto; scrollbar-width: none; overscroll-behavior: contain; padding: 6px 8px; border-radius: 32px; background: var(--card); box-shadow: 0 8px 28px var(--shadow-lg); align-self: flex-start; }
.ctx-react button { flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%; font-size: 30px; line-height: 1; display: grid; place-items: center; transition: transform .25s var(--spring), background-color .15s; animation: pop .35s var(--spring) both; animation-delay: calc(var(--i, 0) * 30ms); }
.ctx-react button:hover { transform: scale(1.25); }
.ctx-react button.on { background: var(--tab-on); }
.ctx-card { min-width: 230px; max-width: 100%; padding: 6px 0; border-radius: 18px; background: var(--card); box-shadow: 0 10px 34px var(--shadow-lg);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; outline: 0; }
.ctx-item { display: flex; align-items: center; gap: 22px; width: 100%; min-height: 54px; padding: 0 22px; font-size: 17.5px; text-align: start; transition: background-color .15s; animation: rise .3s var(--ease) both; animation-delay: calc(var(--i, 0) * 25ms); }
.ctx-item:hover { background: var(--hover); }
.ctx-item > svg.i { color: var(--muted); }
.ctx-item.danger, .ctx-item.danger > svg.i { color: var(--danger); }
.ctx-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-block: 8px; }
.ctx-item > svg.i { flex-shrink: 0; }
.ctx-item:focus-visible { outline: 0; background: var(--hover); box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] .ctx-item:focus-visible { box-shadow: inset -3px 0 0 var(--accent); }
.ctx-item .val { color: var(--muted); font-size: 15px; }

.island { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; z-index: 40; transform: translateX(-50%); width: min(420px, calc(100% - 20px)); padding: 9px 10px; border-radius: 34px; overflow: hidden; display: flex; align-items: center; gap: 12px; background: #000; color: #fff; cursor: pointer; box-shadow: 0 14px 40px rgba(0, 0, 0, .35); animation: islandIn .6s var(--spring); }
.island.out { animation: islandOut .35s var(--ease) forwards; }
.island.bump { animation: islandBump .45s var(--spring); }
.island .av { box-shadow: none; }
.island .av::after { display: none; }
.island .txt { flex: 1; min-width: 0; text-align: start; }
.island b { display: block; font-size: 15px; font-weight: 600; }
.island p { font-size: 14px; color: #b0b0b5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.island .go { padding: 7px 15px; border-radius: 18px; background: #2f8be6; font-size: 14px; font-weight: 600; }
.island .bar { position: absolute; bottom: 0; inset-inline: 24px; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .3); transform-origin: var(--start); animation: shrink 5s linear forwards; }

.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 50; transform: translateX(-50%); max-width: calc(100% - 32px); display: flex; align-items: center; gap: 12px; padding: 12px 20px 12px 16px; padding-inline: 16px 20px; border-radius: 16px; background: rgba(36, 36, 40, .95); color: #fff; font-size: 15px; box-shadow: 0 10px 28px rgba(0, 0, 0, .3); animation: toastIn .4s var(--spring); }
.toast svg.i { width: 22px; height: 22px; }
.toast.out { animation: toastOut .25s var(--ease) forwards; }

/* ---------------------------------------------------------------- v2 components */
.grow { flex: 1; min-width: 0; }
.brand.grow { text-align: start; }

/* Selection bars (chat list and messages) */
.sel-bar { display: flex; align-items: center; gap: 4px; min-height: 64px; padding: max(env(safe-area-inset-top), 8px) 8px 4px; flex-shrink: 0; color: var(--accent); }
.sel-bar .icon-btn { color: var(--accent); }
.sel-bar.in { animation: selIn .3s var(--ease); }
.sel-count { flex: 1; min-width: 0; font-size: 21px; font-weight: 600; padding-inline-start: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-sel .sel-count { font-size: 19px; }
.sel-count.swap { animation: swap .25s var(--ease); }
.page.selecting > .top { display: none; }
.chat-top.selecting > :not(.msg-sel) { visibility: hidden; }
.msg-sel { position: absolute; top: max(env(safe-area-inset-top), 10px); inset-inline: 12px; height: 56px; min-height: 0; padding: 0 6px; }

/* Chat list rows */
.row-av { position: relative; flex-shrink: 0; display: grid; }
.sel-check { position: absolute; z-index: 2; bottom: -1px; inset-inline-end: -1px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--online); color: #fff; box-shadow: 0 0 0 2.5px var(--bg); transform: scale(0); transition: transform .3s var(--spring); }
.sel-check svg.i { width: 15px; height: 15px; stroke-width: 3; }
.row.sel .sel-check { transform: scale(1); }
.row.sel { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.row.sel .row-av .av { transform: scale(.88); }
.row-av .av { transition: transform .3s var(--spring); }
.row-name { display: inline-flex; align-items: center; gap: 4px; }
.row-name bdi { overflow: hidden; text-overflow: ellipsis; }
.row-ic { width: 17px; height: 17px; color: var(--muted); stroke-width: 2; }
.row-pin { width: 20px; height: 20px; color: var(--muted); transform: rotate(45deg); }
.badge.muted { background: var(--badge-mute); }
.badge.dot { min-width: 14px; width: 14px; height: 14px; padding: 0; }
.av.saved { background: linear-gradient(180deg, #5ab1ff, #2f8be6); color: #fff; }
.av.saved svg.i { width: 46%; height: 46%; stroke-width: 2.2; fill: #fff; stroke: #fff; }

.fab-new { position: absolute; z-index: 6; bottom: calc(96px + env(safe-area-inset-bottom)); inset-inline-end: 20px; width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent); transition: transform .4s var(--spring), opacity .2s; animation: pop .45s var(--spring) .2s both; }
.fab-new:active { transform: scale(.9); }
.fab-new.hide { transform: translateY(30px) scale(.4); opacity: 0; pointer-events: none; }
.fab-new svg.i { width: 26px; height: 26px; stroke-width: 2.1; }
.fab-new .ripple { background: rgba(255, 255, 255, .3); }

/* Pinned message bar */
.chat { --pin-h: 0px; }
.chat.has-pin { --pin-h: 60px; }
.pin-bar { position: absolute; z-index: 4; top: calc(var(--head-h) + env(safe-area-inset-top) - 6px); inset-inline: 12px; height: 54px; flex: none; gap: 10px; padding-inline: 14px 4px; border-radius: 20px; cursor: pointer; }
.pin-bar.in { animation: pinIn .4s var(--spring); }
.pin-line { width: 3px; align-self: stretch; margin: 9px 0; border-radius: 2px; background: var(--accent-2); }
.pin-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pin-text b { font-size: 15px; font-weight: 600; color: var(--accent-2); }
.pin-text span { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.msgs { padding-top: calc(var(--head-h) + var(--pin-h) + env(safe-area-inset-top) + 4px); transition: padding-top .3s var(--ease); }
.day { top: calc(var(--head-h) + var(--pin-h) + env(safe-area-inset-top)); }

/* Bubbles: selection */
.b-check { display: none; position: absolute; z-index: 2; top: 50%; margin-top: -12px; inset-inline-start: -38px; width: 24px; height: 24px; border-radius: 50%; place-items: center; border: 2px solid #fff; background: rgba(0, 0, 0, .18); color: transparent; transition: background-color .2s, border-color .2s; }
.b-check svg.i { width: 15px; height: 15px; stroke-width: 3; }
.msgs.selecting .b-check { display: grid; animation: pop .3s var(--spring); }
.msgs.selecting .b.in { margin-inline-start: 42px; }
.msgs.selecting .b { cursor: pointer; transition: margin .3s var(--ease); }
.b.sel .b-check { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.b.sel { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 70%, transparent); }
.msgs.selecting .b * { pointer-events: none; }

.fwd { font-size: 14.5px; line-height: 1.3; color: var(--q); margin: 1px 0 3px; }
.fwd b { font-weight: 600; }
.b.photo .fwd, .b.photo .quote { margin-inline: 6px; }
.b.bounce { animation: bounceE .6s var(--spring); }
.b.emoji.e1 .txt { font-size: calc(var(--msg-font) * 4.6); }
.b.emoji.e2 .txt { font-size: calc(var(--msg-font) * 3.8); }
.b.emoji.e3 .txt { font-size: calc(var(--msg-font) * 3.1); }
.b.emoji { cursor: pointer; }
.tick.err { color: var(--danger); }

/* Text formatting */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
code.mono { padding: .1em .35em; border-radius: 6px; background: color-mix(in srgb, currentColor 10%, transparent); }
pre.mono { display: block; margin: 4px 0; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, currentColor 8%, transparent); white-space: pre-wrap; overflow-x: auto; text-align: left; }
.spoiler { border-radius: 5px; cursor: pointer; transition: color .5s var(--ease), background-color .5s; }
.spoiler:not(.shown) { color: transparent; background-color: color-mix(in srgb, currentColor 0%, var(--q) 16%); background-image: radial-gradient(circle, color-mix(in srgb, var(--in-meta) 90%, transparent) .8px, transparent 1.2px); background-size: 5px 5px; animation: spoil 3s linear infinite; }
.spoiler:not(.shown) img { opacity: 0; }
.spoiler.shown { animation: fadeIn .4s; }

/* Photo bubbles */
.b.photo { padding: 3px; }
.media { position: relative; max-width: 100%; border-radius: 15px; overflow: hidden; background: color-mix(in srgb, var(--muted) 18%, transparent); cursor: zoom-in; isolation: isolate; }
.b.photo.jp .media, .b.photo.jn .media { border-radius: 15px; }
.media-thumb { position: absolute; inset: -12px; z-index: 0; background-size: cover; background-position: center; filter: blur(14px); transform: scale(1.08); }
.media-img { position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s var(--ease); }
.media.loaded .media-img { opacity: 1; }
.b.photo .c { padding: 6px 9px 4px; }
.b.media-only { background: none !important; padding: 0; box-shadow: none; }
.b.media-only::after { display: none; }
.b.media-only .media { border-radius: 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.meta.over { position: absolute; z-index: 3; float: none !important; top: auto; bottom: 7px; inset-inline-end: 7px; margin: 0 !important; height: 22px; padding: 0 8px; border-radius: 11px; background: rgba(0, 0, 0, .45); color: #fff !important; backdrop-filter: blur(6px); }
.meta.over .tick { color: #fff; }
.media-dl { position: absolute; z-index: 2; top: 50%; left: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; backdrop-filter: blur(6px); transition: transform .25s var(--spring); }
.media-dl:active { transform: scale(.9); }
.media-dl.busy svg { animation: dlBounce 1s ease-in-out infinite; }
.up-ring { position: absolute; z-index: 4; top: 50%; left: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; }
.up-ring svg { position: absolute; inset: 3px; width: 48px; height: 48px; transform: rotate(-90deg); animation: spin 2.4s linear infinite; }
.up-ring circle { fill: none; stroke-width: 3; stroke-linecap: round; }
.up-ring .trk { stroke: rgba(255, 255, 255, .2); }
.up-ring .bar { stroke: #fff; stroke-dasharray: 125.7; stroke-dashoffset: calc(125.7 * (1 - var(--p, 0))); transition: stroke-dashoffset .25s var(--ease); }
.up-x { position: relative; z-index: 1; display: grid; place-items: center; width: 30px; height: 30px; color: #fff; }
.up-x svg.i { width: 18px; height: 18px; stroke-width: 2.4; }
.vplay .up-ring { inset: 0; top: 0; left: 0; margin: 0; width: 100%; height: 100%; background: var(--q); }

/* Voice bubbles */
.b.voice { padding: 8px 14px 7px 8px; padding-inline: 8px 14px; min-width: min(260px, 100%); }
.voice { display: flex; align-items: center; gap: 11px; }
.vplay { position: relative; width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: var(--q); color: #fff; transition: transform .25s var(--spring); }
.vplay:active { transform: scale(.9); }
.vplay svg.i { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.b.out .vplay { color: var(--out); }
.vbody { flex: 1; min-width: 0; }
.wave { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.wave i { flex: 1; max-width: 3px; min-width: 2px; height: calc(2px + var(--h, 4) * .85px); border-radius: 2px; background: color-mix(in srgb, var(--q) 38%, transparent); transition: background-color .15s; }
.wave i.on { background: var(--q); }
.vmeta { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 13px; color: var(--in-meta); }
.b.out .vmeta { color: var(--out-meta); }
.vtime { font-variant-numeric: tabular-nums; }
.vspeed { display: none; height: 18px; padding: 0 6px; border-radius: 9px; background: color-mix(in srgb, var(--q) 18%, transparent); color: var(--q); font-size: 12px; font-weight: 700; place-items: center; }
.voice.active .vspeed { display: inline-grid; animation: pop .3s var(--spring); }
.vmeta .meta { float: none !important; top: 0; margin: 0 !important; margin-inline-start: auto !important; }
.voice.playing .vplay { box-shadow: 0 0 0 0 color-mix(in srgb, var(--q) 50%, transparent); animation: vpulse 1.6s ease-out infinite; }

.empty-chat .greet { display: block; margin: 14px auto 2px; font-size: 64px; line-height: 1; animation: wave 2.4s ease-in-out infinite; transform-origin: 70% 80%; cursor: pointer; }
.empty-chat .greet img.emj { width: 1em; height: 1em; }
.empty-chat > div { font-size: 14.5px; opacity: .9; max-width: 260px; margin: 4px auto 0; line-height: 1.45; }
.empty-chat b { display: block; font-size: 16px; }

/* Composer: attach, microphone, recording */
.compose { position: relative; }
.input-box { position: relative; }
.attach-btn { transition: width .25s var(--ease), opacity .2s, transform .25s var(--spring) !important; }
.attach-btn.hide { width: 0 !important; opacity: 0; transform: scale(.4); pointer-events: none; }
.send { position: relative; z-index: 1; }
.send::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: 50%; background: color-mix(in srgb, var(--accent-2) 30%, transparent); transform: scale(1); opacity: 0; transition: transform .12s linear, opacity .2s; }
.composer.recording .send { transform: scale(1.45); box-shadow: 0 6px 20px color-mix(in srgb, var(--accent-2) 45%, transparent); }
.composer.recording .send::before { opacity: 1; transform: scale(calc(1 + var(--lvl, 0) * .7)); }
.composer.rec-locked .send { transform: none; }
.composer.rec-locked .send::before { opacity: 0; }
.rec-bar { position: absolute; inset-inline: 0; bottom: 0; height: 56px; display: none; align-items: center; gap: 10px; padding-inline: 18px 16px; }
.composer.recording .rec-bar { display: flex; animation: fadeIn .2s; }
.composer.recording .input-row { visibility: hidden; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: #f04343; animation: blink 1s ease-in-out infinite; }
.rec-time { min-width: 62px; font-variant-numeric: tabular-nums; font-size: 16px; }
.rec-hint { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 15px; white-space: nowrap; transition: opacity .15s; }
.rec-hint svg.i { width: 18px; height: 18px; transform: scaleX(-1); animation: nudge 1.2s ease-in-out infinite; }
:root[dir="rtl"] .rec-hint svg.i { transform: none; }
.rec-cancel { display: none; flex: 1; text-align: center; color: var(--danger); font-weight: 600; font-size: 15px; }
.composer.rec-locked .rec-hint { display: none; }
.composer.rec-locked .rec-cancel { display: block; animation: fadeIn .2s; }
.rec-bar.cancel-shake { animation: shake .4s var(--ease); }
.rec-lock { position: absolute; z-index: 2; inset-inline-end: 6px; bottom: 82px; width: 44px; padding: 10px 0 8px; border-radius: 22px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--float); color: var(--muted); box-shadow: 0 2px 10px var(--shadow); opacity: 0; transform: translateY(20px); pointer-events: none; transition: opacity .2s, transform .3s var(--spring); }
.rec-lock svg.i { width: 21px; height: 21px; }
.rec-lock svg.i + svg.i { width: 16px; height: 16px; }
/* The "slide up to lock" hint only moves while it is visible (no endless hidden animation). */
.composer.recording:not(.rec-locked) .rec-lock svg.i + svg.i { animation: nudgeUp 1.2s ease-in-out infinite; }
.composer.recording:not(.rec-locked) .rec-lock { opacity: 1; transform: translateY(calc(var(--up, 0) * -.35px)); }

/* Emoji keyboard */
.emoji-kb { display: none; position: relative; flex-direction: column; background: var(--float); box-shadow: 0 1px 4px var(--shadow); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6); overflow: hidden; }
.composer.kb-open .emoji-kb { display: flex; }
.ek-tabs { display: flex; gap: 2px; padding: 8px 8px 4px; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.ek-tab { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: var(--muted); transition: background-color .2s, color .2s; }
.ek-tab svg.i { width: 23px; height: 23px; }
.ek-tab.on { background: var(--tab-on); color: var(--accent); }
.ek-search { display: flex; align-items: center; gap: 8px; height: 40px; margin: 2px 10px 6px; padding: 0 14px; border-radius: 20px; background: var(--field); color: var(--muted); flex-shrink: 0; }
.ek-search svg.i { width: 19px; height: 19px; }
.ek-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 15.5px; color: var(--ink); }
.ek-search input::-webkit-search-cancel-button { display: none; }
.ek-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 6px 56px; }
.ek-sec h4 { position: sticky; top: 0; z-index: 1; padding: 8px 8px 4px; font-size: 13.5px; font-weight: 600; color: var(--muted); background: linear-gradient(var(--card) 60%, transparent); }
.ek-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
.ek-e { height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 28px; line-height: 1; transition: transform .2s var(--spring), background-color .15s; }
.ek-e img.emj { width: 31px; height: 31px; margin: 0; }
.ek-e:hover { background: var(--hover); transform: scale(1.18); }
.ek-e:active { transform: scale(.85); }
.ek-none { padding: 20px; text-align: center; color: var(--muted); }
.ek-foot { position: absolute; bottom: 10px; inset-inline-end: 10px; }
.ek-back { width: 44px; height: 44px; background: var(--card); color: var(--ink-2); box-shadow: 0 2px 10px var(--shadow); }

/* Blocked / can't-message bar, drop zone */
.blocked-bar { position: absolute; z-index: 5; bottom: 0; inset-inline: 0; padding: 8px max(12px, calc((100% - var(--col)) / 2)) calc(12px + env(safe-area-inset-bottom)); }
.blocked-bar button { width: 100%; height: 54px; border-radius: 27px; background: var(--float); color: var(--accent); font-weight: 600; font-size: 16px; box-shadow: 0 1px 4px var(--shadow); backdrop-filter: blur(16px); }
.blocked-bar button:disabled { color: var(--muted); cursor: default; }
.drop-zone { position: absolute; inset: 12px; z-index: 8; display: grid; place-items: center; border: 3px dashed var(--accent); border-radius: 26px; background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(6px); color: var(--accent); pointer-events: none; animation: fadeIn .2s; }
.drop-zone div { display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 18px; font-weight: 600; }
.drop-zone svg.i { width: 56px; height: 56px; animation: float 2s ease-in-out infinite; }

/* Dialog (Telegram alert) */
.dialog-root { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; }
.dlg-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .42); animation: fadeIn .2s; }
.dlg { position: relative; width: min(350px, calc(100% - 44px)); padding: 22px 24px 10px; border-radius: 26px; background: var(--card); box-shadow: 0 20px 50px rgba(0, 0, 0, .35); animation: dlgIn .34s var(--spring); }
.dlg h3 { font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.dlg p { font-size: 16px; line-height: 1.5; color: var(--ink-2); }
.dlg-check { display: flex; align-items: center; gap: 14px; margin: 18px 0 2px; font-size: 16px; cursor: pointer; }
.dlg-check input { position: absolute; opacity: 0; pointer-events: none; }
.dlg-check .box { position: relative; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--muted); flex-shrink: 0; transition: background-color .2s, border-color .2s; }
.dlg-check .box::after { content: ''; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) scale(0); transition: transform .25s var(--spring); }
.dlg-check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.dlg-check input:checked + .box::after { transform: rotate(45deg) scale(1); }
.dlg-check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 18px; }
.dlg-btn { padding: 10px 16px; border-radius: 12px; color: var(--accent); font-size: 16px; font-weight: 600; transition: background-color .15s; }
.dlg-btn:hover { background: var(--hover); }
.dlg-btn.danger { color: var(--danger); }
.dialog-root.out .dlg { animation: dlgOut .18s ease-in forwards; }
.dialog-root.out .dlg-scrim { animation: fadeOut .2s forwards; }

/* Bottom sheet */
.sheet-root { position: fixed; inset: 0; z-index: 55; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); animation: fadeIn .25s; }
.sheet { position: absolute; bottom: 0; inset-inline: 0; margin: 0 auto; width: min(560px, 100%); max-height: 88dvh; display: flex; flex-direction: column; border-radius: 26px 26px 0 0; background: var(--card); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); animation: sheetIn .42s var(--ease); transition: transform .3s var(--ease); touch-action: pan-y; }
.sheet-grip { width: 40px; height: 5px; margin: 9px auto 4px; border-radius: 3px; background: var(--switch-off); flex-shrink: 0; }
.sheet-title { padding: 6px 22px 12px; font-size: 19px; font-weight: 600; flex-shrink: 0; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 16px; }
.sheet-root.out .sheet { animation: sheetOut .26s var(--ease) forwards; }
.sheet-root.out .sheet-scrim { animation: fadeOut .26s forwards; }
.sheet .card { background: var(--bg-2); }
.sheet-search { margin: 0 14px 8px; }
.fwd-list { padding: 0 0 10px; }
.fwd-list .row { min-height: 64px; }

.ps-grid { padding: 0 16px; }
.ps-item { position: relative; border-radius: 16px; overflow: hidden; animation: pop .35s var(--spring) both; animation-delay: calc(var(--i, 0) * 40ms); }
.ps-item img { display: block; width: 100%; max-height: 52dvh; object-fit: contain; background: var(--bg-2); border-radius: 16px; }
.ps-grid.multi { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.ps-grid.multi .ps-item img { aspect-ratio: 1; object-fit: cover; max-height: none; }
.ps-del { position: absolute; top: 6px; inset-inline-end: 6px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #fff; }
.ps-del svg.i { width: 16px; height: 16px; }
.ps-row { display: flex; align-items: flex-end; gap: 10px; padding: 14px 16px 4px; }
.ps-caption { flex: 1; min-width: 0; min-height: 50px; max-height: 120px; padding: 13px 18px; border: 0; outline: 0; resize: none; border-radius: 25px; background: var(--field); font-size: 17px; line-height: 1.4; color: var(--ink); }
.ps-send { width: 54px; height: 54px; }

/* QR code */
/* ---------------------------------------------------------------- QR code screen (qr.js) */
.qr-screen { position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column; align-items: center; overflow: hidden; color: #fff;
  background: var(--qr-bg, #6e7882); padding: max(env(safe-area-inset-top), 14px) 16px max(env(safe-area-inset-bottom), 16px); }
.qr-screen.in { animation: qrIn .38s var(--ease); }
.qr-screen.out { animation: qrOut .26s var(--ease) forwards; pointer-events: none; }
.qr-bg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.qr-top { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 560px; }
.qr-top > :only-child { margin-inline-end: auto; }
/* Glass controls over the coloured background: white-tinted, light rim, soft depth. */
.qr-round, .qr-pill, .qr-group { color: #fff; background: linear-gradient(180deg, rgba(255, 255, 255, .26), rgba(255, 255, 255, .1));
  box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .45), inset 0 1px 0 rgba(255, 255, 255, .5), 0 6px 20px rgba(0, 0, 0, .14);
  backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6); }
.qr-round { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; transition: transform var(--t-mid) var(--spring), background-color var(--t-fast); }
.qr-round svg.i { width: 26px; height: 26px; }
.qr-round:active, .qr-group button:active, .qr-pill:active { transform: scale(.9); }
.qr-pill { height: 50px; display: flex; align-items: center; gap: 10px; padding-inline: 16px 20px; border-radius: 25px; font-size: 17px; font-weight: 600; transition: transform var(--t-mid) var(--spring); }
.qr-stage { position: relative; z-index: 1; flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; pointer-events: none; }
/* Sizes follow the card's own width (--qw): percentage padding would follow the screen width.
   Side padding ≈ 4 modules of white around the code, the quiet zone the QR standard asks for. */
.qr-card2 { --qw: min(340px, 80vw, calc((100dvh - 250px) * .8)); pointer-events: auto; width: var(--qw);
  padding: calc(var(--qw) * .115) calc(var(--qw) * .115) calc(var(--qw) * .05); border-radius: calc(var(--qw) * .12); background: #fff; text-align: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 18px 50px rgba(0, 0, 0, .2); animation: qrCard .5s var(--spring) both .05s; }
.qr-code { display: block; width: 100%; height: auto; }
.qr-code > path, .qr-code circle, .qr-logo-b { fill: var(--qr); transition: fill var(--t-slow) var(--ease); }
.qr-user { display: block; margin-top: calc(var(--qw) * .06); font-size: calc(var(--qw) * .085); font-weight: 700; letter-spacing: .5px; color: var(--qr); line-height: 1.1;
  overflow-wrap: anywhere; transition: color var(--t-slow) var(--ease); }
.qr-bottom { position: relative; z-index: 2; width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.qr-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qr-group { display: flex; gap: 4px; height: 56px; padding: 4px; border-radius: 28px; }
.qr-group button { width: 64px; border-radius: 24px; display: grid; place-items: center; color: #fff; transition: background-color var(--t-fast), transform var(--t-mid) var(--spring); }
.qr-group button svg.i { width: 26px; height: 26px; }
.qr-group button.on { background: rgba(255, 255, 255, .28); }
.qr-drawer { border-radius: 26px; padding: 10px 0; background: rgba(20, 20, 24, .28);
  box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .3), 0 10px 30px rgba(0, 0, 0, .18);
  backdrop-filter: blur(22px) saturate(1.6); -webkit-backdrop-filter: blur(22px) saturate(1.6); animation: qrDrawer .32s var(--spring); }
.qr-drawer.out { animation: qrDrawerOut .2s var(--ease) forwards; }
.qr-choices { display: flex; gap: 10px; overflow-x: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 4px 14px; scroll-padding-inline: 14px; }
.qr-choices::-webkit-scrollbar { display: none; }
.qr-theme { flex-shrink: 0; position: relative; width: 62px; height: 92px; border-radius: 16px; background: radial-gradient(circle at 50% 42%, var(--a), var(--b));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); transition: transform var(--t-mid) var(--spring), box-shadow var(--t-fast); animation: pop .35s var(--spring) both; animation-delay: calc(var(--i, 0) * 25ms); }
.qr-theme i { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 7px; background: #fff;
  box-shadow: inset 0 0 0 7px #fff, inset 0 0 0 30px var(--q); }
.qr-theme.on { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25), 0 0 0 3px #fff; transform: scale(1.04); }
.qr-emoji { flex-shrink: 0; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; color: #fff; transition: background-color var(--t-fast), transform var(--t-mid) var(--spring);
  animation: pop .35s var(--spring) both; animation-delay: calc(var(--i, 0) * 20ms); }
.qr-emoji img.emj { width: 34px; height: 34px; margin: 0; }
.qr-emoji.on { background: rgba(255, 255, 255, .3); box-shadow: inset 0 0 0 2px #fff; }
.qr-theme:focus-visible, .qr-emoji:focus-visible, .qr-round:focus-visible, .qr-group button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.qr-scan { position: fixed; inset: 0; z-index: 46; background: #000; display: grid; place-items: center; animation: fadeIn .2s; }
.qr-scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.qr-scan-frame { position: relative; width: min(70vw, 300px); aspect-ratio: 1; border-radius: 28px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45), inset 0 0 0 3px #fff; }
.qr-scan-hint { position: absolute; bottom: calc(40px + env(safe-area-inset-bottom)); inset-inline: 24px; text-align: center; color: #fff; font-size: 16px; }
.qr-scan .qr-round { position: absolute; top: max(env(safe-area-inset-top), 14px); inset-inline-start: 16px; }
@keyframes qrIn { from { opacity: 0; transform: scale(1.04); } }
@keyframes qrOut { to { opacity: 0; transform: scale(1.03); } }
@keyframes qrCard { from { opacity: 0; transform: translateY(26px) scale(.9); } }
@keyframes qrDrawer { from { opacity: 0; transform: translateY(18px) scale(.97); } }
@keyframes qrDrawerOut { to { opacity: 0; transform: translateY(14px) scale(.98); } }
.btn.ghost { background: var(--field); color: var(--accent); }
.btn svg.i { width: 21px; height: 21px; }

/* Devices */
.cell .ci.dev { border-radius: 50%; background: #b4b8bf; }
.dev-big { width: 96px; height: 96px; margin: 8px auto 12px; border-radius: 50%; display: grid; place-items: center; background: #b4b8bf; color: #fff; animation: pop .45s var(--spring); }
.dev-big svg.i { width: 50px; height: 50px; stroke-width: 1.7; }
.dev-title { text-align: center; font-size: 22px; font-weight: 600; }
.dev-date { text-align: center; color: var(--muted); margin: 4px 0 18px; }
.btn.wide { width: calc(100% - 32px); margin: 18px 16px 6px; height: 56px; border-radius: 28px; }
.cell .cell-ic { width: 26px; height: 26px; }

/* Info rows with icons */
.info.with-ic { display: flex; align-items: center; gap: 22px; }
.info-ic { color: var(--muted); }
.info-txt { flex: 1; min-width: 0; }
button.info:hover { background: var(--hover); }
.info-card { margin-top: 14px; }
.big-ic { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(180deg, #5ab1ff, #2f8be6); animation: pop .45s var(--spring); }
.big-ic svg.i { width: 46px; height: 46px; }
.ph .av, .hero .av { cursor: zoom-in; }
.cell .cv.link { color: var(--accent); }
.ctx-info { display: flex; align-items: center; gap: 12px; padding: 10px 22px 12px; font-size: 14.5px; color: var(--muted); border-bottom: 1px solid var(--sep); margin-bottom: 4px; }
.ctx-info svg.i { width: 20px; height: 20px; color: var(--accent-2); }
.toast .grow { flex: 1; }
.toast-act { margin-inline-start: 8px; padding: 6px 12px; border-radius: 10px; color: #6ec1ff; font-weight: 700; }
.auth-brand { margin-top: 40px; font-size: 13px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }

/* Segmented tabs & shared media */
.seg { position: relative; display: flex; margin: 12px 12px 6px; padding: 4px; border-radius: 22px; background: var(--field); }
.seg-ind { position: absolute; top: 4px; bottom: 4px; border-radius: 18px; background: var(--card); box-shadow: 0 1px 3px var(--shadow); transition: left .38s var(--spring), width .38s var(--spring); }
.seg-btn { position: relative; z-index: 1; flex: 1; height: 38px; border-radius: 18px; font-size: 15px; font-weight: 500; color: var(--muted); transition: color .25s; }
.seg-btn.on { color: var(--ink); }
.seg-count { display: inline-block; min-width: 20px; height: 20px; padding: 0 6px; margin-inline-start: 6px; border-radius: 10px; font-size: 12px; line-height: 20px; font-weight: 600; vertical-align: 1px;
  background: color-mix(in srgb, currentColor 12%, transparent); animation: bump .35s var(--spring) both; }
.media-card { padding-bottom: 8px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 6px 10px 10px; }
.mg-tile { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background-size: cover; background-position: center; animation: pop .35s var(--spring) both; animation-delay: calc(var(--i, 0) * 25ms); }
.mg-tile img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; }
.mg-tile.loaded img { opacity: 1; }
.voice-list { display: flex; flex-direction: column; padding: 6px 12px 10px; }
.voice-list .b { max-width: 100%; }
.voice-list > .hint, .media-grid > .hint { grid-column: 1 / -1; padding: 24px; text-align: center; }
.peer-page { display: flex; flex-direction: column; overflow: hidden; }
.peer-page > .scroller { padding-bottom: 30px; }

/* Wallpapers */
.walls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 10px 16px 16px; }
.wall-opt { position: relative; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 2px var(--sep); transition: box-shadow .25s, transform .35s var(--spring);
  background: radial-gradient(closest-side at 30% 30%, var(--w1), transparent), radial-gradient(closest-side at 70% 70%, var(--w4), transparent), radial-gradient(closest-side at 75% 25%, var(--w2), transparent), var(--wbase); }
.wall-opt:hover { transform: translateY(-3px); }
.wall-opt.on { box-shadow: 0 0 0 2.5px var(--accent); }
.wall-opt.on .tc-check { transform: scale(1); }
.wall-opt > i { position: absolute; bottom: 12px; inset-inline-end: 10px; width: 52%; height: 12px; border-radius: 6px; background: var(--out); }
[data-wall]:not([data-wall="default"]) { --stars: transparent; --clouds: transparent; --doodle: light-dark(rgba(0, 0, 0, .13), rgba(255, 255, 255, .06)); --pill: light-dark(rgba(0, 0, 0, .32), rgba(20, 20, 20, .6)); }
[data-wall="ocean"]    { --w1: light-dark(#a8d8ea, #0b2a3d); --w2: light-dark(#5fa8d3, #0f3d57); --w3: light-dark(#cae9f5, #123a52); --w4: light-dark(#4c86c6, #1b5675); --wbase: light-dark(#7fb6dc, #08202f); }
[data-wall="sunset"]   { --w1: light-dark(#fbd3a0, #3a1c2b); --w2: light-dark(#f59c8b, #4a2136); --w3: light-dark(#fbe7b5, #3d2530); --w4: light-dark(#e98a9a, #5b2c3c); --wbase: light-dark(#f4b49a, #24121c); }
[data-wall="forest"]   { --w1: light-dark(#c8e6b0, #10231a); --w2: light-dark(#7fb77e, #173322); --w3: light-dark(#e1efc3, #1b2e22); --w4: light-dark(#5e9e6e, #21442d); --wbase: light-dark(#a3cf95, #0b1912); }
[data-wall="lavender"] { --w1: light-dark(#e3d4f5, #1e1530); --w2: light-dark(#b49be0, #2a1d45); --w3: light-dark(#f1e6fb, #241a38); --w4: light-dark(#9c84d6, #352659); --wbase: light-dark(#cbb6ec, #150f22); }
[data-wall="mono"]     { --w1: light-dark(#e9e9ec, #1b1b1d); --w2: light-dark(#cfd2d8, #232326); --w3: light-dark(#f4f4f6, #1f1f22); --w4: light-dark(#bfc3ca, #2a2a2e); --wbase: light-dark(#dcdde1, #141416); }
[data-wall="default"] .wall-opt, .wall-opt[data-wall="default"] { }

/* Photo viewer */
.viewer { position: fixed; inset: 0; z-index: 70; color: #fff; }
.vw-back { position: absolute; inset: 0; background: rgba(0, 0, 0, .94); animation: fadeIn .25s; transition: opacity .2s; }
.vw-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.vw-img { position: absolute; object-fit: contain; background-size: cover; background-position: center; user-select: none; -webkit-user-drag: none; will-change: transform; }
.vw-top { position: absolute; top: 0; inset-inline: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: max(env(safe-area-inset-top), 8px) 8px 18px; background: linear-gradient(rgba(0, 0, 0, .55), transparent); transition: opacity .25s; animation: fadeIn .3s; }
.vw-top .icon-btn { color: #fff; }
.vw-top .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.vw-who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.vw-who b { font-size: 16px; font-weight: 600; }
.vw-who small { font-size: 13.5px; opacity: .75; }
.vw-count { font-size: 14px; opacity: .8; padding: 0 6px; }
.vw-nav { position: absolute; top: 50%; z-index: 2; width: 52px; height: 52px; margin-top: -26px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .12); color: #fff; transition: opacity .25s, background-color .2s; }
.vw-nav:hover { background: rgba(255, 255, 255, .22); }
.vw-nav.prev { left: 16px; }
.vw-nav.next { right: 16px; }
.vw-nav.prev svg { transform: scaleX(-1); }
:root[dir="rtl"] .vw-nav.next svg.flip { transform: none; }
.vw-cap { position: absolute; bottom: 0; inset-inline: 0; z-index: 2; max-height: 30vh; overflow-y: auto; padding: 22px 20px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .65)); font-size: 16px; line-height: 1.5; text-align: center; transition: opacity .25s; }
.viewer.bare .vw-top, .viewer.bare .vw-cap, .viewer.bare .vw-nav { opacity: 0; pointer-events: none; }
.viewer.out .vw-back { animation: fadeOut .26s forwards; }
.viewer.out .vw-top, .viewer.out .vw-cap, .viewer.out .vw-nav { opacity: 0; }
@media (hover: none) { .vw-nav { display: none; } }

/* ---------------------------------------------------------------- v2.1: rich input, encryption, motion */
.rich { flex: 1; min-width: 0; max-height: 170px; overflow-y: auto; padding: 12px 4px 11px; outline: 0; font-size: 17px; line-height: 1.4; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; }
.rich:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.rich img.emj { width: 1.3em; height: 1.3em; vertical-align: -.3em; margin: 0 .03em; pointer-events: auto; }
.ps-caption.rich { padding: 13px 18px; border-radius: 25px; background: var(--field); max-height: 120px; }

.e2-banner { display: flex; align-items: center; gap: 12px; margin: 0 14px 8px; padding: 10px 14px; border-radius: 18px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); text-align: start; flex-shrink: 0; }
.e2-banner b { flex: 1; font-weight: 600; font-size: 15px; }
.e2-banner svg.i { width: 22px; height: 22px; }
.e2-banner svg.i:last-child { width: 18px; height: 18px; opacity: .7; }
.e2-banner.in { animation: rise .4s var(--spring); }
.e2-banner svg.i:first-child { animation: lockWiggle 2.6s ease-in-out infinite; }

.e2-sheet .sheet-body { padding: 4px 22px 22px; text-align: center; }
.e2-art { width: 92px; height: 92px; margin: 6px auto 16px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(180deg, #6fd36f, #2fb94f); box-shadow: 0 10px 30px color-mix(in srgb, #2fb94f 40%, transparent); animation: pop .5s var(--spring); }
.e2-art svg.i { width: 44px; height: 44px; stroke-width: 2; }
.e2-art svg.i rect { transition: transform .3s var(--ease); }
.e2-art svg.i path { transform-box: fill-box; transform-origin: 85% 100%; transition: transform .45s var(--spring); }
.e2-art.open svg.i path { transform: translateY(-3px) rotate(28deg); }
.e2-art.open { animation: bump .45s var(--spring); }
.e2-title { font-size: 21px; font-weight: 600; margin-bottom: 8px; }
.e2-text { color: var(--muted); font-size: 15px; line-height: 1.55; margin: 0 4px 20px; }
.e2-form { text-align: start; --tf-bg: var(--card); }
.e2-form .tf { margin: 0 0 8px; }
.e2-err { min-height: 22px; margin: 0 4px 10px; color: var(--danger); font-size: 14px; }
.shake-x { animation: shake .45s var(--ease); }

.verify-sheet .sheet-body { padding: 4px 22px 24px; text-align: center; }
.key-img { display: grid; grid-template-columns: repeat(8, 1fr); width: min(220px, 70vw); aspect-ratio: 1; margin: 4px auto 18px; border-radius: 16px; overflow: hidden; box-shadow: 0 0 0 1px var(--sep), 0 10px 28px var(--shadow); }
.key-img i { animation: keyCell .5s var(--ease) both; animation-delay: calc(var(--i) * 6ms); }
.key-emoji { display: flex; justify-content: center; gap: 14px; font-size: 38px; margin-bottom: 14px; }
.key-emoji img.emj { width: 46px; height: 46px; animation: emojiIn .6s var(--spring) both; }
.key-emoji img.emj:nth-child(2) { animation-delay: .08s; }
.key-emoji img.emj:nth-child(3) { animation-delay: .16s; }
.key-emoji img.emj:nth-child(4) { animation-delay: .24s; }
.key-hex { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: .5px; color: var(--ink-2); margin-bottom: 16px; }
.key-warn { display: flex; gap: 10px; align-items: center; text-align: start; padding: 12px 14px; margin: 4px 0 14px; border-radius: 14px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-size: 14.5px; }

.e2-lock { display: inline-block; width: 15px; height: 15px; margin-inline-end: 4px; vertical-align: -1px; color: var(--online); stroke-width: 2.4; animation: pop .4s var(--spring); }
.peer-text b { display: flex; align-items: center; }
.e2-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; font-size: 13.5px; opacity: .9; }
.e2-note svg.i { width: 16px; height: 16px; }
.sys-note { align-self: center; display: flex; align-items: center; gap: 8px; max-width: 90%; margin: 10px 0; padding: 8px 14px; border-radius: 16px; background: var(--pill); color: #fff; font-size: 14px; text-align: start; backdrop-filter: blur(8px); animation: rise .4s var(--ease); }
.sys-note.warn { background: color-mix(in srgb, var(--danger) 75%, #000); }
.sys-note svg.i { width: 18px; height: 18px; flex-shrink: 0; }
.b.locked-msg .txt { font-style: italic; opacity: .75; }
.inline-ic { display: inline-block; width: 16px; height: 16px; vertical-align: -2px; margin-inline-end: 4px; }
.media.locked::after, .media.failed::after { content: '🔒'; position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; font-size: 34px; }
.voice.loading .vplay svg { animation: pulseO 1s ease-in-out infinite; }

/* Motion: directional tab changes, folder swap, closing panels, profile collapse */
.page.in-next { animation: pageNext .34s var(--ease); }
.page.in-prev { animation: pagePrev .34s var(--ease); }
.page.leaving { display: flex !important; pointer-events: none; z-index: 0; animation: pageOut .22s var(--ease) forwards; }
.list.swap-list { animation: listSwap .32s var(--ease); }
.composer.kb-closing .emoji-kb { display: flex; animation: kbOut .2s var(--ease) forwards; }
.pin-bar.out { display: flex !important; animation: pinOut .22s var(--ease) forwards; }
.hero { --sc: 0; }
.hero > .av { transform: scale(calc(1 - var(--sc) * .35)) translateY(calc(var(--sc) * 18px)); opacity: calc(1 - var(--sc) * .6); transition: transform .05s linear; }
.hero h2, .hero .st { transform: translateY(calc(var(--sc) * -10px)); }
.b.enter .wave i, .voice-row .wave i { animation: waveIn .45s var(--spring) both; animation-delay: calc(var(--n, 0) * 9ms); }
.tab-badge.bump { animation: bump .45s var(--spring); }
.cell.rp:active, .info.rp:active { transform: scale(.99); }
.cell, .info { transition: background-color .15s, transform .2s var(--spring); }
.chat-top .fpill.swap .peer-text, .chat-top .fpill.swap #peerAvatar { animation: swap .35s var(--ease); }
.ek-tab { transition: background-color .25s, color .25s, transform .3s var(--spring); }
.ek-tab.on { transform: scale(1.06); }
.dlg-btn:active, .btn:active, .seg-btn:active { transform: scale(.96); }
.sel-check svg.i { stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .3s var(--ease) .1s; }
.row.sel .sel-check svg.i { stroke-dashoffset: 0; }
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

/* ---------------------------------------------------------------- keyframes */
@keyframes lockWiggle { 0%, 80%, 100% { transform: none; } 85% { transform: rotate(-12deg); } 90% { transform: rotate(10deg); } 95% { transform: rotate(-5deg); } }
@keyframes keyCell { from { opacity: 0; transform: scale(.4); } }
@keyframes pulseO  { 50% { opacity: .35; } }
@keyframes pageNext { from { opacity: 0; transform: translateX(calc(28px * var(--dir))); } }
@keyframes pagePrev { from { opacity: 0; transform: translateX(calc(-28px * var(--dir))); } }
@keyframes pageOut { to { opacity: 0; transform: scale(.98); } }
@keyframes listSwap { from { opacity: 0; transform: translateY(8px); } }
@keyframes kbOut   { to { opacity: 0; transform: translateY(20px) scale(.97); } }
@keyframes pinOut  { to { opacity: 0; transform: translateY(-12px) scale(.96); } }
@keyframes waveIn  { from { transform: scaleY(.1); opacity: 0; } }

@keyframes selIn   { from { opacity: 0; transform: translateY(-12px); } }
@keyframes pinIn   { from { opacity: 0; transform: translateY(-14px) scale(.96); } }
@keyframes bounceE { 30% { transform: scale(1.25) rotate(-6deg); } 60% { transform: scale(.94) rotate(3deg); } }
@keyframes spoil   { to { background-position: 20px -15px; } }
@keyframes dlBounce { 50% { transform: translateY(3px); } }
@keyframes vpulse  { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--q) 45%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes wave    { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-8deg); } }
@keyframes blink   { 50% { opacity: .2; } }
@keyframes nudge   { 50% { translate: calc(-4px * var(--dir)) 0; } }
@keyframes nudgeUp { 50% { translate: 0 -3px; } }
@keyframes dlgIn   { from { opacity: 0; transform: scale(.86); } }
@keyframes dlgOut  { to { opacity: 0; transform: scale(.92); } }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }
@keyframes kbIn    { from { opacity: 0; transform: translateY(24px); } }
@keyframes kbPop   { from { opacity: 0; transform: scale(.85) translateY(20px); } }

@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes rise    { from { opacity: 0; transform: translateY(12px); } }
@keyframes fadeIn  { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes pop     { from { transform: scale(0); } }
@keyframes bump    { 0% { transform: scale(.4); } 100% { transform: scale(1); } }
@keyframes swap    { from { opacity: 0; transform: translateY(6px); } }
@keyframes float   { 50% { transform: translateY(-8px); } }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
@keyframes dot     { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-3px); opacity: 1; } }
@keyframes draw    { to { stroke-dashoffset: 0; } }
@keyframes shake   { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes twinkle { to { opacity: .55; } }
@keyframes pageIn  { from { opacity: 0; transform: translateY(10px); } }
@keyframes tabPop  { 40% { transform: scale(1.22) translateY(-2px); } }
@keyframes rowIn   { from { opacity: 0; transform: translateY(14px); } }
@keyframes chatIn  { from { opacity: 0; transform: translateY(14px); } }
@keyframes popOut  { from { opacity: 0; transform: translateY(18px) scale(.88); } }
@keyframes popIn   { from { opacity: 0; transform: translateX(calc(-18px * var(--dir))) scale(.92); } }
@keyframes emojiIn { 0% { opacity: 0; transform: scale(.3) rotate(-18deg); } 60% { transform: scale(1.18) rotate(6deg); } 100% { transform: none; } }
@keyframes heart   { 0% { opacity: 0; transform: scale(.3); } 35% { opacity: 1; transform: scale(1.2); } 100% { opacity: 0; transform: scale(1.6) translateY(-30px); } }
@keyframes flash   { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 35% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 30%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
@keyframes fly     { 45% { transform: translate(calc(26px * var(--dir)), -26px) scale(.5); opacity: 0; } 46% { transform: translate(calc(-26px * var(--dir)), 26px) scale(.5); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes icSwap  { from { transform: scale(0) rotate(-90deg); } }
@keyframes menuIn  { from { opacity: 0; transform: scale(.8); } }
@keyframes menuOut { to { opacity: 0; transform: scale(.88); } }
@keyframes toastIn  { from { opacity: 0; transform: translate(-50%, 24px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 12px) scale(.95); } }
@keyframes shrink   { to { transform: scaleX(0); } }
@keyframes islandIn  { from { clip-path: inset(0 calc(50% - 62px) calc(100% - 36px) calc(50% - 62px) round 18px); opacity: .5; } to { clip-path: inset(0 round 34px); opacity: 1; } }
@keyframes islandOut { to { clip-path: inset(0 calc(50% - 62px) calc(100% - 36px) calc(50% - 62px) round 18px); opacity: 0; } }
@keyframes islandBump { 40% { transform: translateX(-50%) scale(1.04); } }

/* ---------------------------------------------------------------- mobile navigation */
@media (max-width: 760px) {
  .app { display: block; position: relative; overflow: hidden; }
  .side, .chat { position: absolute; inset: 0; }
  .side { border: 0; transition: transform var(--dur) var(--ease); }
  .side::before { content: ''; position: absolute; inset: 0; z-index: 20; background: #000; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); }
  .chat { z-index: 3; transform: translateX(calc(100% * var(--dir))); visibility: hidden; box-shadow: 0 0 40px rgba(0, 0, 0, .3); transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur); }
  .app.chat-open .chat { transform: none; visibility: visible; transition: transform var(--dur) var(--ease), visibility 0s; }
  .app.chat-open .side { transform: translateX(calc(-25% * var(--dir))); }
  .app.chat-open .side::before { opacity: .2; }
  .app.dragging .chat { transition: none; visibility: visible; transform: translateX(calc(var(--drag, 0) * 100% * var(--dir))); }
  .app.dragging .side { transition: none; transform: translateX(calc((1 - var(--drag, 0)) * -25% * var(--dir))); }
  .app.dragging .side::before { transition: none; opacity: calc((1 - var(--drag, 0)) * .2); }
  .chat-empty { display: none; }
  .b { max-width: 86%; }
  .to-bottom { inset-inline-end: 12px; }
  .emoji-kb { height: min(330px, 46dvh); margin-top: 8px; border-radius: 24px; animation: kbIn .32s var(--ease); }
  .msg-sel { inset-inline: 12px; }
  .pin-bar { inset-inline: 12px; }
}
@media (min-width: 761px) {
  .back-btn { display: none; }
  .chat-top { padding-inline: max(12px, calc((100% - var(--col)) / 2)); }
  .emoji-kb { position: absolute; bottom: calc(100% - 2px); inset-inline-start: max(12px, calc((100% - var(--col)) / 2)); z-index: 6; width: 380px; height: 420px; border-radius: 22px; box-shadow: 0 12px 40px var(--shadow-lg); transform-origin: var(--start) bottom; animation: kbPop .32s var(--spring); }
  .msg-sel, .pin-bar { inset-inline: max(12px, calc((100% - var(--col)) / 2)); }
}

/* ================================================================ liquid glass
 * Used only on surfaces that float above content: chat header pills, composer, tab bar, pinned bar,
 * scroll-to-bottom, selection bar, menus, dialogs, sheets and toasts. Lists, settings pages and
 * message bubbles stay solid for readability. Three ingredients:
 *   tint      a translucent fill that adapts to light / dark;
 *   edge      a hairline rim plus a brighter top highlight (light catching the glass);
 *   depth     a soft two-layer shadow.
 * Menus, dialogs and sheets carry text you read, so they use the stronger, less transparent tint.
 * Without backdrop-filter support every surface falls back to its solid colour (end of section).
 */
:root {
  --glass:        light-dark(rgba(255, 255, 255, .66), rgba(28, 28, 30, .6));
  --glass-strong: light-dark(rgba(255, 255, 255, .84), rgba(34, 34, 36, .82));
  --glass-blur:   blur(22px) saturate(1.8);
  --glass-rim:    light-dark(rgba(255, 255, 255, .75), rgba(255, 255, 255, .11));
  --glass-hi:     light-dark(rgba(255, 255, 255, .95), rgba(255, 255, 255, .16));
  --glass-sheen:  linear-gradient(180deg, light-dark(rgba(255, 255, 255, .5), rgba(255, 255, 255, .07)) 0%, transparent 46%);
  --glass-edge:   inset 0 0 0 .5px var(--glass-rim), inset 0 1px 0 var(--glass-hi);
  --glass-depth:  0 1px 2px light-dark(rgba(20, 40, 60, .08), rgba(0, 0, 0, .3)), 0 8px 26px light-dark(rgba(20, 40, 60, .13), rgba(0, 0, 0, .42));
  /* motion tokens shared by the glass states */
  --t-fast: .16s;
  --t-mid:  .28s;
  --t-slow: .45s;
}
.fbtn, .fpill, .input-box, .tabbar, .emoji-kb, .blocked-bar button {
  background: var(--glass-sheen), var(--glass);
  box-shadow: var(--glass-edge), var(--glass-depth);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
}
.tabbar { box-shadow: var(--glass-edge), var(--glass-depth); }
/* Pills that carry text (chat name, pinned message, selection bar) use the denser tint, so text
   scrolling behind them never competes with their own. Round icon buttons keep the lighter glass. */
.fpill { background: var(--glass-sheen), var(--glass-strong); }
.tab-badge { box-shadow: 0 0 0 2px light-dark(#fff, #1c1c1e); }
.ctx-card, .ctx-react, .dlg, .sheet {
  background: var(--glass-sheen), var(--glass-strong);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
}
.ctx-card, .ctx-react { box-shadow: var(--glass-edge), 0 12px 38px var(--shadow-lg); }
.dlg { box-shadow: var(--glass-edge), 0 24px 60px rgba(0, 0, 0, .32); }
.sheet { box-shadow: inset 0 1px 0 var(--glass-hi), 0 -10px 40px rgba(0, 0, 0, .22); }
.sheet .card { background: light-dark(rgba(242, 243, 246, .8), rgba(18, 18, 20, .55)); }
.toast { background: rgba(28, 28, 32, .78); box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .14), inset 0 1px 0 rgba(255, 255, 255, .12), 0 10px 28px rgba(0, 0, 0, .3);
  backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6); }
/* Solid accent buttons get the same light: a top highlight and a soft coloured shadow. */
.send, .fab { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 6px 18px color-mix(in srgb, var(--accent-2) 40%, transparent); }
/* Pressed and focused states: glass dims slightly and sinks, then springs back. */
.fbtn, .fpill, .tab, .send, .fab { transition: transform var(--t-mid) var(--spring), background-color var(--t-fast), box-shadow var(--t-mid) var(--ease), filter var(--t-fast); }
.fbtn:active, .fpill:active { filter: brightness(.96); }
.fbtn:focus-visible, .fpill:focus-visible, .send:focus-visible { outline: 0; box-shadow: var(--glass-edge), 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
/* Messages fade out under the floating header and composer instead of showing as raw text between
   the glass pills. Fully opaque again by the header's lower edge, where the first message, the
   pinned bar and the floating date sit. */
.msgs { --fade: linear-gradient(to bottom, transparent calc(env(safe-area-inset-top) + 4px), #000 calc(env(safe-area-inset-top) + 62px),
          #000 calc(100% - var(--composer-h, 76px) + 14px), transparent calc(100% - 8px));
  -webkit-mask-image: var(--fade); mask-image: var(--fade); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .fbtn, .fpill, .input-box, .tabbar, .emoji-kb, .blocked-bar button { background: var(--card); }
  .ctx-card, .ctx-react, .dlg, .sheet { background: var(--card); }
  .toast { background: rgba(36, 36, 40, .97); }
}
/* "Reduce transparency" (Windows / some browsers expose it): solid surfaces, same shapes. */
@media (prefers-reduced-transparency: reduce) {
  .fbtn, .fpill, .input-box, .tabbar, .emoji-kb, .blocked-bar button, .ctx-card, .ctx-react, .dlg, .sheet {
    background: var(--card); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* Motion switches: OS preference or the in-app "Animations" toggle. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .attach-btn { transition-duration: .01ms !important; } /* has its own !important transition */
  html { scroll-behavior: auto !important; }
}
.no-motion *, .no-motion *::before, .no-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
.no-motion .attach-btn { transition-duration: .01ms !important; }
