:root {
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #d7f0ec;
  --bg: #eef2f3;
  --surface: #ffffff;
  --surface-2: #f5f7f8;
  --line: #dde3e6;
  --text: #15202b;
  --muted: #5b6b78;
  --bubble-in: #ffffff;
  --bubble-out: #d7f0ec;
  --danger: #c0352b;
  --ok: #1a7f4b;
  --read: #1d6fd1;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(15, 30, 40, .18);
}
:root[data-theme='dark'] {
  --brand: #2dd4bf;
  --brand-ink: #04211e;
  --brand-soft: #123b37;
  --bg: #0b1113;
  --surface: #131c1f;
  --surface-2: #19252a;
  --line: #24343a;
  --text: #e6eef0;
  --muted: #8ea0a9;
  --bubble-in: #1b272c;
  --bubble-out: #14423d;
  --danger: #ff7a70;
  --ok: #4ade80;
  --read: #60a5fa;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--text-scale, 1)); -webkit-text-size-adjust: 100%; }
html, body { height: 100%; margin: 0; }
body { overflow: hidden; overscroll-behavior: none; }
#root { height: 100%; height: var(--app-h, 100dvh); }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- generic controls */
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600;
  background: var(--brand); color: var(--brand-ink); min-height: 44px;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.link { background: none; color: var(--brand); padding: 6px 8px; min-height: 0; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent;
  display: inline-grid; place-items: center; font-size: 20px; color: var(--muted); flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.primary { background: var(--brand); color: var(--brand-ink); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: .85rem; color: var(--muted); font-weight: 600; }
.input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 11px 12px; min-height: 44px;
}
textarea.input { resize: vertical; min-height: 80px; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 4px 0 8px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- avatar */
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none; overflow: hidden; position: relative;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1.05rem; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 36px; height: 36px; font-size: .9rem; }
.avatar.lg { width: 96px; height: 96px; font-size: 2rem; }
.avatar .dot {
  position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ok); border: 2px solid var(--surface);
}

/* ---------- auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--brand-soft), var(--bg)); }
.auth-card { width: min(420px, 100%); background: var(--surface); border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 12px 0 6px; font-size: 1.5rem; }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; }
.auth-tools { display: flex; gap: 8px; margin-top: 18px; }
.dev-box { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-size: .9rem; }

/* ---------- app shell */
.app { height: 100%; max-height: 100dvh; display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); background: var(--surface); }
.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; background: var(--surface); position: relative; }
.side-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px; }
.search { flex: 1; position: relative; }
.search .input { border-radius: 22px; background: var(--surface-2); padding-left: 14px; }
.filters { display: flex; gap: 6px; padding: 6px 10px 8px; overflow-x: auto; scrollbar-width: none; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 18px; padding: 6px 12px;
  font-size: .85rem; white-space: nowrap; color: var(--muted); min-height: 34px;
}
.chip[aria-pressed='true'] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.netbar { padding: 6px 12px; font-size: .85rem; text-align: center; background: var(--surface-2); color: var(--muted); border-bottom: 1px solid var(--line); }
.netbar.offline { background: #fbe9e7; color: #8a2b22; }
:root[data-theme='dark'] .netbar.offline { background: #3a1d1a; color: #ffb4ab; }
.chatlist { flex: 1; overflow-y: auto; min-height: 0; }
.section-title { padding: 10px 14px 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.ci {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 10px 12px;
  border: 0; background: transparent; border-bottom: 1px solid transparent;
}
.ci:hover { background: var(--surface-2); }
.ci[aria-current='true'] { background: var(--brand-soft); }
.ci-main { flex: 1; min-width: 0; }
.ci-top, .ci-bot { display: flex; align-items: baseline; gap: 8px; }
.ci-title { font-weight: 650; flex: 1; min-width: 0; }
.ci-time { font-size: .75rem; color: var(--muted); flex: none; }
.ci-last { flex: 1; min-width: 0; color: var(--muted); font-size: .9rem; }
.ci-last .draft { color: var(--danger); }
.badge {
  min-width: 22px; height: 22px; border-radius: 11px; padding: 0 6px; background: var(--brand); color: var(--brand-ink);
  font-size: .75rem; font-weight: 700; display: inline-grid; place-items: center; flex: none;
}
.badge.muted { background: var(--muted); color: var(--surface); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin: 8px 0; }

/* ---------- chat pane */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.placeholder { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 60px; }
.chat-head .who { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px; display: flex; gap: 10px; align-items: center; }
.chat-head .who b { display: block; }
.chat-head .sub { font-size: .82rem; color: var(--muted); }
.chat-head .sub.live { color: var(--brand); }
.back { display: none; }
.pinbar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: .9rem; text-align: left; width: 100%; border-left: 0; border-right: 0; border-top: 0; }
.pinbar b { color: var(--brand); }
.messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 12px 10px 8px; min-height: 0; display: flex; flex-direction: column; }
.messages > :first-child { margin-top: auto; }
.day { align-self: center; background: var(--surface); color: var(--muted); font-size: .78rem; padding: 3px 12px; border-radius: 12px; margin: 10px 0; border: 1px solid var(--line); }
.unread-div { align-self: stretch; text-align: center; color: var(--brand); font-size: .8rem; font-weight: 700; padding: 6px; margin: 6px 0; background: var(--brand-soft); border-radius: 8px; }
.msg { display: flex; margin: 2px 0; max-width: 100%; }
.msg.out { justify-content: flex-end; }
.bubble {
  max-width: min(560px, 82%); background: var(--bubble-in); border-radius: var(--radius); padding: 7px 10px 5px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06); position: relative; min-width: 72px; overflow-wrap: anywhere;
}
.msg.out .bubble { background: var(--bubble-out); border-bottom-right-radius: 4px; }
.msg.in .bubble { border-bottom-left-radius: 4px; }
.msg.hl .bubble { outline: 3px solid var(--brand); }
.msg.pending .bubble { opacity: .7; }
.sender { font-size: .82rem; font-weight: 700; color: var(--brand); margin-bottom: 2px; }
.text { white-space: pre-wrap; }
.meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; font-size: .72rem; color: var(--muted); margin-top: 2px; }
.tick.read { color: var(--read); }
.tick.failed { color: var(--danger); font-weight: 700; }
.quote { border-left: 3px solid var(--brand); padding: 2px 8px; margin-bottom: 5px; font-size: .85rem; background: rgba(15, 118, 110, .08); border-radius: 4px; cursor: pointer; }
.quote b { display: block; color: var(--brand); }
.fwd { font-size: .8rem; color: var(--brand); margin-bottom: 3px; font-style: italic; }
.media img, .media video { max-width: 100%; max-height: 360px; border-radius: 10px; display: block; cursor: zoom-in; }
.media video { cursor: default; }
.media audio { width: min(300px, 70vw); height: 40px; }
.filecard { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; padding: 4px 0; }
.filecard .ficon { width: 42px; height: 42px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: .75rem; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 1px 8px; font-size: .85rem; min-height: 26px; }
.react.mine { background: var(--brand-soft); border-color: var(--brand); }
.more { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); opacity: 0; font-size: 16px; }
.bubble:hover .more, .more:focus-visible { opacity: 1; background: var(--surface-2); }
@media (hover: none) { .more { opacity: .55; } }
.jump { position: absolute; right: 16px; bottom: 90px; z-index: 5; }

.composer-wrap { background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.ctx { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-left: 3px solid var(--brand); margin: 0 8px 6px; background: var(--surface-2); border-radius: 6px; font-size: .88rem; }
.composer { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea {
  flex: 1; border: 1px solid var(--line); background: var(--surface-2); border-radius: 22px; padding: 10px 14px;
  resize: none; max-height: 160px; min-height: 44px; line-height: 1.35;
}
.cstate { text-align: center; padding: 14px; color: var(--muted); font-size: .92rem; }
.recorder { display: flex; align-items: center; gap: 10px; flex: 1; padding: 0 6px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.recorder audio { flex: 1; min-width: 0; height: 40px; }

/* ---------- overlays */
.overlay { position: fixed; inset: 0; background: rgba(5, 12, 15, .55); display: grid; place-items: center; z-index: 50; padding: 12px; }
.modal { background: var(--surface); width: min(520px, 100%); max-height: min(88vh, 760px); border-radius: 18px; display: flex; flex-direction: column; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal h3 { margin: 18px 0 8px; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.modal h3:first-child { margin-top: 0; }
.menu { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; max-width: 92vw; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 8px; min-height: 44px; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu .emoji-row { display: flex; gap: 2px; padding: 4px; flex-wrap: wrap; }
.menu .emoji-row button { width: 40px; padding: 6px; text-align: center; font-size: 20px; }
.toasts, #toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 80; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: #1f2d33; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: .92rem; }
.lightbox { background: rgba(0, 0, 0, .9); }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 6px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; width: 100%; text-align: left; background: none; border: 0; }
.list-item.clickable:hover { background: var(--surface-2); }
.tag { font-size: .72rem; background: var(--brand-soft); color: var(--brand); padding: 1px 8px; border-radius: 10px; font-weight: 700; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.invite { word-break: break-all; background: var(--surface-2); padding: 10px; border-radius: 10px; font-size: .9rem; }
.sel-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* ---------- responsive layouts
   phone  <= 600px : one pane at a time + bottom navigation
   tablet 601-1279 : list + chat (portrait and landscape)
   wide   >= 1280  : list + chat + docked info pane
   Safe areas keep controls clear of notches, rounded corners and home indicators. */
.app { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.side-head, .chat-head { padding-top: calc(6px + env(safe-area-inset-top)); }
.infopane { display: none; }
.bottomnav { display: none; }
.sidebar, .main { min-width: 0; }

@media (min-width: 601px) and (max-width: 900px) {
  .app { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); }
  .ci { padding: 10px 8px; gap: 10px; }
  .avatar { width: 44px; height: 44px; }
}
@media (min-width: 1280px) {
  .app { grid-template-columns: 360px minmax(0, 1fr); }
  .app[data-info='open'] { grid-template-columns: 360px minmax(0, 1fr) 340px; }
  .app[data-info='open'] .infopane { display: block; }
  .infopane { border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; background: var(--surface); min-height: 0; }
}
@media (min-width: 1800px) {
  .app { grid-template-columns: 420px minmax(0, 1fr); }
  .app[data-info='open'] { grid-template-columns: 420px minmax(0, 1fr) 380px; }
  .bubble { max-width: min(680px, 70%); }
}
@media (max-width: 600px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app .main { display: none; }
  .app[data-view='chat'] .sidebar { display: none; }
  .app[data-view='chat'] .main { display: flex; }
  .back { display: inline-grid; }
  .bubble { max-width: 88%; }
  .overlay { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .app[data-view='list'] .bottomnav {
    display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: var(--surface);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav button { border: 0; background: none; min-height: 56px; display: grid; place-items: center; gap: 0; font-size: .75rem; color: var(--muted); padding: 6px 0; }
  .bottomnav button[aria-current='true'] { color: var(--brand); font-weight: 700; }
  .bottomnav .gl { font-size: 22px; line-height: 1; }
  .icon-btn { width: 48px; height: 48px; }
  .ci { padding: 12px; }
}
@media (hover: none) and (pointer: coarse) {
  .btn, .chip, .menu button, .input { min-height: 48px; }
  .more { opacity: .6; width: 36px; height: 36px; }
}
/* phone in landscape: short viewport, reclaim vertical space */
@media (max-height: 480px) and (orientation: landscape) {
  .side-head, .chat-head { min-height: 48px; padding-top: calc(2px + env(safe-area-inset-top)); padding-bottom: 2px; }
  .filters { display: none; }
  .messages { padding-top: 4px; }
  .bottomnav button { min-height: 44px; }
  .modal { max-height: 96vh; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (forced-colors: active) { .bubble, .ci, .btn { border: 1px solid CanvasText; } }

.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.keys dt, .keys dd { margin: 0; }
kbd { background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; font: inherit; font-size: .85rem; white-space: nowrap; }
.infopane h2 { overflow-wrap: anywhere; }

.steps { padding-left: 20px; margin: 8px 0 14px; }
.steps li { margin: 6px 0; }

/* animated buttons (shared by the whole app) */
.btn, .icon-btn, .chip, .menu button, .bottomnav button, .adm-tabs button { position: relative; overflow: hidden; transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease, color .2s ease, filter .2s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 32%, transparent); filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: scale(.97); box-shadow: none; }
.btn.secondary:hover:not(:disabled) { box-shadow: 0 4px 12px rgba(0, 0, 0, .12); }
.icon-btn:hover { transform: scale(1.1); }
.icon-btn:active { transform: scale(.9); }
.chip:hover { transform: translateY(-1px); }
.chip:active, .menu button:active, .bottomnav button:active { transform: scale(.96); }
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .25; transform: scale(0); pointer-events: none; animation: ripple .6s ease-out forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }


/* =====================================================================
   Suhbat-dosh visual theme (matches the design mockup): blue accent, left
   navigation rail, underline tabs, rounded bubbles, round send button.
   Declared last so it overrides the base rules above.
   ===================================================================== */
:root {
  --brand: #2f6bff;
  --brand-ink: #ffffff;
  --brand-soft: #e4edff;
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f1f4fa;
  --line: #e3e8f1;
  --text: #0f1b3d;
  --muted: #6b7794;
  --bubble-in: #ffffff;
  --bubble-out: #dbe8ff;
  --read: #2f6bff;
  --radius: 18px;
  --shadow: 0 10px 34px rgba(24, 44, 97, .16);
}
:root[data-theme='dark'] {
  --brand: #5b8cff;
  --brand-ink: #071230;
  --brand-soft: #1b2a52;
  --bg: #0c1220;
  --surface: #131b2e;
  --surface-2: #1a2338;
  --line: #25304a;
  --text: #e8edf8;
  --muted: #8b97b4;
  --bubble-in: #1a2338;
  --bubble-out: #1f3a78;
  --read: #8fb0ff;
  --shadow: 0 10px 34px rgba(0, 0, 0, .55);
}
body { font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif; background: var(--bg); color: var(--text); }
.ico { flex: none; display: block; }
.only-mobile { display: none; }

/* ---- shell */
.app { grid-template-columns: 104px minmax(300px, 380px) minmax(0, 1fr); background: var(--surface); }
.app[data-info='open'] .infopane { display: none; }
.rail { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 18px 10px 14px; border-right: 1px solid var(--line); background: var(--surface); min-height: 0; }
.rail-brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; padding: 2px 6px 18px; text-align: center; color: var(--text); }
.rail-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rail-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; border-radius: 16px; padding: 12px 4px; color: var(--muted); font-size: .75rem; font-weight: 600; }
.rail-item:hover { background: var(--surface-2); color: var(--text); }
.rail-item.active { background: var(--brand-soft); color: var(--brand); }
.rail-item.soon { opacity: .7; }
.rail-ico { position: relative; display: grid; place-items: center; }
.rail-badge { position: absolute; top: -6px; right: -10px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-size: .65rem; display: grid; place-items: center; padding: 0 4px; }
.rail-me { border: 0; background: none; align-self: center; padding: 6px; border-radius: 50%; }
.rail-me .avatar { width: 44px; height: 44px; }

.sidebar { background: var(--surface); }
.side-head2 { display: flex; align-items: center; gap: 4px; padding: 20px 14px 8px 20px; }
.view-title { margin: 0; font-size: 1.55rem; letter-spacing: -.02em; }
.brand-word { display: none; font-weight: 800; font-size: 1.6rem; letter-spacing: -.02em; }
.side-head2 .icon-btn { color: var(--brand); }
.search { position: relative; margin: 6px 16px 10px; flex: none; }
.search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 42px; border-radius: 14px; background: var(--surface-2); border-color: transparent; min-height: 46px; }
.search .input:focus { background: var(--surface); border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }

.tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.tab { border: 0; background: none; padding: 10px 10px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; border-radius: 8px 8px 0 0; }
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--brand); border-bottom-color: var(--brand); }

.chatlist { padding: 6px 8px 8px; }
.ci { border-radius: 16px; padding: 10px 12px; gap: 14px; }
.ci:hover { background: var(--surface-2); }
.ci[aria-current='true'] { background: var(--brand-soft); }
.ci .avatar { width: 52px; height: 52px; }
.ci-title { font-weight: 700; font-size: 1rem; }
.ci-time { font-size: .78rem; color: var(--muted); }
.ci-time.hot { color: var(--brand); font-weight: 600; }
.badge { background: var(--brand); color: var(--brand-ink); min-width: 24px; height: 24px; border-radius: 12px; }
.badge.muted { background: var(--muted); color: var(--surface); }
.empty-emoji { font-size: 44px; }
.section-title { padding: 14px 12px 6px; }

/* ---- chat pane */
.main { background: var(--bg); }
.chat-head { min-height: 72px; padding: 10px 16px; gap: 6px; background: var(--surface); }
.chat-head .who { gap: 12px; }
.chat-head .who .avatar { width: 48px; height: 48px; }
.chat-head .who b { font-size: 1.1rem; }
.chat-head .sub { margin-top: 1px; }
.chat-head .sub.live { color: var(--brand); font-weight: 600; }
.chat-head .icon-btn { color: var(--text); }
.messages { padding: 18px clamp(12px, 4%, 40px) 10px; }
.day { background: color-mix(in srgb, var(--surface) 80%, transparent); border: 0; color: var(--muted); font-weight: 600; padding: 6px 16px; border-radius: 14px; }
.bubble { border-radius: 18px; padding: 9px 14px 6px; box-shadow: 0 1px 2px rgba(24, 44, 97, .08); max-width: min(620px, 78%); }
.msg.out .bubble { background: var(--bubble-out); border-bottom-right-radius: 6px; }
.msg.in .bubble { border-bottom-left-radius: 6px; }
.text { font-size: 1rem; line-height: 1.4; }
.meta { gap: 5px; margin-top: 3px; }
.tick { display: inline-flex; align-items: center; color: var(--muted); }
.tick.read { color: var(--read); }
.quote { border-left-color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, transparent); }
.quote b, .sender, .fwd { color: var(--brand); }
.typing-dots { display: inline-flex; gap: 5px; align-items: center; padding: 14px 18px; min-width: 0; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }

.composer-wrap { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); }
.composer { align-items: center; gap: 8px; }
.composer .icon-btn { color: var(--muted); }
.composer .icon-btn:hover { color: var(--brand); }
.field-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 26px; padding: 3px 6px 3px 18px; border: 1px solid transparent; transition: border-color .2s, box-shadow .2s, background .2s; }
.field-wrap:focus-within { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.composer textarea { border: 0; background: transparent; padding: 11px 4px; min-height: 44px; outline: none; flex: 1; min-width: 0; border-radius: 0; }
.send-btn { flex: none; width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 40%, transparent); transition: transform .15s, box-shadow .2s, opacity .2s; position: relative; overflow: hidden; }
.send-btn .ico { transform: translateX(1px); }
.send-btn:hover { transform: scale(1.06); }
.send-btn:active { transform: scale(.94); }
.send-btn.idle { box-shadow: 0 4px 10px color-mix(in srgb, var(--brand) 25%, transparent); }

.btn { border-radius: 12px; }
.btn.danger { background: #e5484d; }
a { color: var(--brand); }
.bottomnav { display: none; }

/* ---- layouts */
@media (min-width: 601px) and (max-width: 900px) {
  .app { grid-template-columns: 84px minmax(250px, 320px) minmax(0, 1fr); }
  .rail-brand { font-size: .95rem; padding-bottom: 12px; }
  .rail-item { font-size: .68rem; }
  .ci .avatar { width: 46px; height: 46px; }
  .view-title { font-size: 1.35rem; }
}
@media (min-width: 1280px) {
  .app { grid-template-columns: 104px 380px minmax(0, 1fr); }
  .app[data-info='open'] { grid-template-columns: 104px 380px minmax(0, 1fr) 340px; }
  .app[data-info='open'] .infopane { display: block; }
}
@media (min-width: 1800px) {
  .app { grid-template-columns: 116px 420px minmax(0, 1fr); }
  .app[data-info='open'] { grid-template-columns: 116px 420px minmax(0, 1fr) 380px; }
}
@media (max-width: 600px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .only-mobile { display: inline-grid; }
  .brand-word { display: block; color: var(--text); }
  .view-title { display: none; }
  .app[data-section='contacts'] .view-title, .app[data-section='archive'] .view-title { display: block; }
  .app[data-section='contacts'] .brand-word, .app[data-section='archive'] .brand-word { display: none; }
  .side-head2 { padding: calc(14px + env(safe-area-inset-top)) 8px 6px 18px; }
  .tabs { border-bottom: 0; gap: 8px; padding: 4px 16px 10px; }
  .tab { border: 0; border-radius: 20px; background: var(--surface-2); padding: 8px 16px; margin: 0; }
  .tab[aria-selected='true'] { background: var(--brand); color: var(--brand-ink); }
  .app[data-view='list'] .bottomnav { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--surface); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
  .bottomnav button { border: 0; background: none; display: grid; justify-items: center; gap: 3px; font-size: .72rem; color: var(--muted); padding: 6px 0; min-height: 56px; }
  .bottomnav button[aria-current='true'] { color: var(--brand); font-weight: 700; }
  .chat-head { min-height: 64px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; }
  .messages { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 480px) { .hide-narrow { display: none; } }

.rail-brand { font-size: 1rem; line-height: 1.15; overflow-wrap: anywhere; hyphens: manual; padding: 2px 4px 16px; }
@media (min-width: 601px) and (max-width: 900px) { .rail-brand { font-size: .8rem; } }

/* ---- resizable sidebar: width comes from --sidebar-w (set by the divider, remembered per device) */
.app { --rail-w: 104px; grid-template-columns: var(--rail-w) var(--sidebar-w, 380px) minmax(0, 1fr); }
@media (min-width: 601px) and (max-width: 900px) {
  .app { --rail-w: 84px; grid-template-columns: var(--rail-w) var(--sidebar-w, 300px) minmax(0, 1fr); }
}
@media (min-width: 1280px) {
  .app { grid-template-columns: var(--rail-w) var(--sidebar-w, 380px) minmax(0, 1fr); }
  .app[data-info='open'] { grid-template-columns: var(--rail-w) var(--sidebar-w, 380px) minmax(0, 1fr) 340px; }
}
@media (min-width: 1800px) {
  .app { --rail-w: 116px; grid-template-columns: var(--rail-w) var(--sidebar-w, 420px) minmax(0, 1fr); }
  .app[data-info='open'] { grid-template-columns: var(--rail-w) var(--sidebar-w, 420px) minmax(0, 1fr) 380px; }
}
@media (max-width: 600px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .resizer { display: none; }
}
.sidebar { position: relative; }
.resizer { position: absolute; top: 0; bottom: 0; right: -5px; width: 10px; cursor: col-resize; z-index: 8; touch-action: none; outline: none; }
.resizer::after { content: ''; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .15s; }
.resizer:hover::after, .resizer:focus-visible::after, body.resizing .resizer::after { background: var(--brand); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe, body.resizing video { pointer-events: none; }

/* ---- drag & drop of files */
.drop-overlay { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; pointer-events: none; background: color-mix(in srgb, var(--brand) 16%, transparent); backdrop-filter: blur(3px); }
.drop-overlay.on { display: grid; animation: rise .18s both; }
.drop-card { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 34px 48px; border-radius: 24px; background: var(--surface); border: 3px dashed var(--brand); box-shadow: var(--shadow); max-width: min(90vw, 460px); }
.drop-ico { font-size: 44px; color: var(--brand); animation: bob 1.1s ease-in-out infinite; }
.drop-title { font-size: 1.25rem; }
.drop-sub { color: var(--muted); overflow-wrap: anywhere; }
.ci.drop-target { outline: 2px dashed var(--brand); outline-offset: -2px; background: var(--brand-soft); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes bob { 50% { transform: translateY(6px); } }

/* horizontally scrolling rows: visible hint that more is available, grab cursor while dragging */
.tabs { cursor: grab; scroll-behavior: smooth; -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 28px), transparent 100%); }
.tabs.dragging { cursor: grabbing; scroll-behavior: auto; user-select: none; }
.tabs .tab { cursor: pointer; flex: none; }

/* ---- calls */
.call-overlay { position: fixed; inset: 0; z-index: 100; background: #0b1220; color: #fff; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; animation: rise .2s both; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0b1220; }
.call-overlay:not(.video) .call-remote { opacity: 0; }
.call-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5, 10, 25, .55), rgba(5, 10, 25, .15) 40%, rgba(5, 10, 25, .65)); pointer-events: none; }
.call-top { position: relative; z-index: 2; text-align: center; padding: calc(40px + env(safe-area-inset-top)) 20px 0; display: grid; gap: 8px; justify-items: center; }
.call-who { display: grid; gap: 10px; justify-items: center; font-size: 1.4rem; }
.call-who .avatar { width: 112px; height: 112px; font-size: 2.4rem; box-shadow: 0 0 0 6px rgba(255, 255, 255, .12); }
.call-overlay:not(.live) .call-who .avatar { animation: callpulse 1.6s ease-in-out infinite; }
.call-overlay.video.live .call-who .avatar { display: none; }
@keyframes callpulse { 50% { box-shadow: 0 0 0 16px rgba(255, 255, 255, .06); } }
.call-status { opacity: .85; min-height: 1.3em; }
.call-time { font-variant-numeric: tabular-nums; opacity: .9; }
.call-local { position: absolute; right: 16px; bottom: calc(130px + env(safe-area-inset-bottom)); width: min(32vw, 160px); aspect-ratio: 3 / 4; object-fit: cover; border-radius: 16px; background: #1a2338; z-index: 3; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); transform: scaleX(-1); }
.call-controls { position: relative; z-index: 4; display: flex; justify-content: center; gap: 22px; padding: 0 20px calc(36px + env(safe-area-inset-bottom)); grid-row: 3; }
.call-btn { width: 64px; height: 64px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, .18); backdrop-filter: blur(8px); transition: transform .15s, background .2s; position: relative; overflow: hidden; }
.call-btn:hover { transform: scale(1.08); }
.call-btn:active { transform: scale(.93); }
.call-btn.off { background: #fff; color: #0b1220; }
.call-btn.decline { background: #e5484d; }
.call-btn.decline .ico { transform: rotate(135deg); }
.call-btn.accept { background: #22b573; animation: callpulse2 1.4s ease-in-out infinite; }
@keyframes callpulse2 { 50% { box-shadow: 0 0 0 12px rgba(34, 181, 115, .18); } }
.call-chip { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 16px; background: var(--surface); color: var(--text); padding: 8px 14px; box-shadow: 0 1px 2px rgba(24, 44, 97, .08); }
.call-chip small { color: var(--muted); }
.call-chip.bad { color: #e5484d; }
.call-chip:hover { background: var(--brand-soft); }
.msg.call-entry { justify-content: center; margin: 6px 0; }
.ci-title.bad, .ci-last.bad { color: #e5484d; }
.call-ico { color: var(--brand); display: grid; place-items: center; }

/* =====================================================================
   Suhbat-dosh look #2 (ChatWave-style): indigo/violet accent, lavender
   background, white incoming bubbles, filled indigo outgoing bubbles.
   ===================================================================== */
:root {
  --brand: #5b44f2;
  --brand-2: #8a6cff;
  --brand-ink: #ffffff;
  --brand-soft: #ece9ff;
  --bg: #f3f1fd;
  --surface: #ffffff;
  --surface-2: #f5f3ff;
  --line: #e6e2f8;
  --text: #15123b;
  --muted: #6f6c92;
  --bubble-in: #ffffff;
  --bubble-out: #5b44f2;
  --read: #ffffff;
  --shadow: 0 12px 36px rgba(58, 40, 160, .18);
}
:root[data-theme='dark'] {
  --brand: #8d7bff;
  --brand-2: #b19cff;
  --brand-ink: #0e0a2e;
  --brand-soft: #25205a;
  --bg: #0e0c22;
  --surface: #171433;
  --surface-2: #1f1b40;
  --line: #2c2759;
  --text: #ebe9fb;
  --muted: #9a97c0;
  --bubble-in: #1f1b40;
  --bubble-out: #5b44f2;
  --read: #ffffff;
  --shadow: 0 12px 36px rgba(0, 0, 0, .55);
}

/* gradient accents like the mockup */
.btn:not(.secondary):not(.link):not(.danger):not(.cta), .send-btn, .rail-badge, .badge:not(.muted), .tab[aria-selected='true'] {
  --g: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.btn:not(.secondary):not(.link):not(.danger):not(.cta) { background-image: var(--g); }
.send-btn { background-image: var(--g); }
.badge:not(.muted) { background-image: var(--g); }
.ci .badge:not(.muted) { background: #22b573; background-image: none; color: #fff; } /* unread counters are green in the mockup */
.rail-badge { background: #22b573; }

/* outgoing bubbles: white text on indigo */
.msg.out .bubble { background: var(--bubble-out); color: #fff; box-shadow: 0 6px 16px rgba(91, 68, 242, .28); }
.msg.out .bubble a { color: #fff; text-decoration: underline; }
.msg.out .bubble .meta, .msg.out .bubble .muted, .msg.out .bubble .tick { color: rgba(255, 255, 255, .82); }
.msg.out .bubble .tick.read { color: #fff; }
.msg.out .bubble .quote { background: rgba(255, 255, 255, .16); border-left-color: #fff; color: #fff; }
.msg.out .bubble .quote b, .msg.out .bubble .fwd { color: #fff; }
.msg.out .bubble .react { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .35); color: #fff; }
.msg.out .bubble .react.mine { background: rgba(255, 255, 255, .32); }
.msg.out .bubble .more { color: rgba(255, 255, 255, .85); }
.msg.out .bubble .filecard .ficon { background: #fff; color: var(--brand); }
.msg.in .bubble { box-shadow: 0 2px 8px rgba(58, 40, 160, .08); }
.quote { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.call-chip { background: var(--surface); }
.msg.out .call-chip { background: var(--surface); color: var(--text); }

/* chat list: selected row + times */
.ci[aria-current='true'] { background: var(--brand-soft); }
.ci-time.hot { color: var(--brand); }
.tab[aria-selected='true'] { color: var(--brand); border-bottom-color: var(--brand); }

/* "recent" avatars row (like the stories strip in the mockup) */
.recent { display: flex; gap: 14px; padding: 6px 18px 12px; overflow-x: auto; scrollbar-width: none; flex: none; }
.recent button { border: 0; background: none; display: grid; justify-items: center; gap: 4px; min-width: 62px; color: var(--muted); font-size: .72rem; }
.recent .avatar { width: 56px; height: 56px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand-2); }
.recent b { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }
.recent .avatar .dot { width: 14px; height: 14px; }

/* composer: round "+" and filled mic like the mockup */
.composer .icon-btn.attach { background: var(--brand-soft); color: var(--brand); border-radius: 50%; }
.composer .icon-btn.attach:hover { background: var(--brand); color: #fff; }

/* ---- animated call buttons ------------------------------------------------ */
.call-start { position: relative; color: var(--brand) !important; }
.call-start::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--brand); opacity: 0; transform: scale(.6); }
.call-start:hover::before, .call-start:focus-visible::before { animation: halo 1.2s ease-out infinite; }
.call-start .ico { transition: transform .2s; }
.call-start:hover .ico, .call-start:focus-visible .ico { animation: ring 0.9s ease-in-out infinite; transform-origin: 50% 60%; }
.call-start.video:hover .ico { animation: pop 0.9s ease-in-out infinite; }
.call-start.is-calling .ico { animation: ring .6s ease-in-out infinite; }
@keyframes halo { 0% { opacity: .28; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.5); } }
@keyframes ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(-16deg); } 30% { transform: rotate(14deg); } 45% { transform: rotate(-10deg); } 60% { transform: rotate(8deg); } 75% { transform: rotate(-4deg); } }
@keyframes pop { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.18); } }

/* call screen: blurred backdrop, labelled controls */
.call-overlay { background: radial-gradient(120% 80% at 50% 0%, #2b2470 0%, #0d0b22 60%); }
.call-bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(48px) saturate(1.2); opacity: .55; transform: scale(1.1); }
.call-controls { gap: 18px; }
.call-ctl { display: grid; justify-items: center; gap: 8px; color: #fff; font-size: .8rem; }
.call-ctl .call-btn { width: 62px; height: 62px; }
.call-btn.decline { animation: breathe 2.2s ease-in-out infinite; }
.call-overlay.live .call-btn.decline { animation: none; }
.call-btn.accept { animation: wiggle 1.6s ease-in-out infinite, callpulse2 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 10px rgba(229, 72, 77, .18); } }
@keyframes wiggle { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-12deg); } 80% { transform: rotate(10deg); } 90% { transform: rotate(-6deg); } }
.call-quality { display: inline-flex; gap: 3px; align-items: flex-end; height: 16px; margin-left: 8px; vertical-align: middle; }
.call-quality i { width: 4px; background: rgba(255, 255, 255, .35); border-radius: 2px; }
.call-quality i:nth-child(1) { height: 5px; } .call-quality i:nth-child(2) { height: 9px; } .call-quality i:nth-child(3) { height: 13px; }
.call-quality[data-q='1'] i:nth-child(-n+1), .call-quality[data-q='2'] i:nth-child(-n+2), .call-quality[data-q='3'] i { background: #3ddc97; }
.call-quality[data-q='1'] i:nth-child(1) { background: #ff7a7a; }
.call-quality[data-q='2'] i:nth-child(-n+2) { background: #ffcc4d; }
@media (prefers-reduced-motion: reduce) { .call-start::before, .call-start .ico, .call-btn { animation: none !important; } }

@media (max-width: 600px) {
  .tab[aria-selected='true'] { background-image: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-bottom-color: transparent; }
}

.update-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 95; display: flex; align-items: center; gap: 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px 10px 16px; box-shadow: var(--shadow); max-width: min(94vw, 560px); animation: rise .25s both; }
.update-banner .btn { min-height: 38px; padding: 6px 14px; }

/* ---- bubbles with previews */
.media-btn { border: 0; padding: 0; background: none; display: block; position: relative; cursor: zoom-in; border-radius: 12px; overflow: hidden; max-width: 100%; }
.media-btn img { display: block; width: 100%; max-width: 340px; max-height: 360px; object-fit: cover; border-radius: 12px; background: var(--surface-2); }
.media-btn.video { cursor: pointer; }
.media-btn.video img, .poster-empty { width: 300px; max-width: 100%; aspect-ratio: 16 / 9; background: #1a1740; }
.play-badge { position: absolute; inset: 0; margin: auto; width: 56px; height: 56px; border-radius: 50%; background: rgba(15, 12, 40, .62); color: #fff; display: grid; place-items: center; backdrop-filter: blur(4px); transition: transform .15s; }
.media-btn.video:hover .play-badge { transform: scale(1.1); }
.media-size { position: absolute; left: 8px; bottom: 8px; background: rgba(15, 12, 40, .6); color: #fff; font-size: .72rem; padding: 2px 8px; border-radius: 10px; }
button.filecard { border: 0; background: none; text-align: left; width: 100%; color: inherit; cursor: pointer; }

/* ---- in-place viewer */
body.viewer-open { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 105; background: rgba(8, 6, 24, .94); color: #fff; display: grid; grid-template-rows: auto 1fr; animation: rise .15s both; }
.viewer-bar { display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: linear-gradient(180deg, rgba(0, 0, 0, .55), transparent); z-index: 2; }
.viewer-bar .icon-btn { color: #fff; }
.viewer-title { display: grid; min-width: 0; margin-left: 6px; }
.viewer-title b, .viewer-title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title small { opacity: .7; }
.viewer-count, .viewer-zoom { font-size: .85rem; opacity: .8; min-width: 3.2em; text-align: center; }
.viewer-stage { position: relative; display: grid; place-items: center; overflow: hidden; touch-action: none; min-height: 0; }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; transition: transform .12s ease-out, filter .25s; user-select: none; cursor: zoom-in; }
.viewer.zoomed .viewer-img { cursor: grab; transition: none; }
.viewer-img.loading { filter: blur(6px); }
.viewer-video { max-width: 100%; max-height: 100%; background: #000; }
.viewer-pdf { width: min(100%, 980px); height: 100%; border: 0; background: #fff; }
.viewer-doc { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 24px; }
.viewer-doc .big-ico { font-size: 56px; }
.viewer-error { text-align: center; padding: 24px; }
.viewer-status { position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); font-size: .85rem; opacity: .85; pointer-events: none; }
.viewer-status:empty { display: none; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; border: 0; background: rgba(255, 255, 255, .1); color: #fff; z-index: 3; display: grid; place-items: center; transition: background .2s; }
.viewer-nav:hover { background: rgba(255, 255, 255, .22); }
.viewer-nav.prev { left: 0; border-radius: 0 14px 14px 0; }
.viewer-nav.next { right: 0; border-radius: 14px 0 0 14px; }
.viewer-nav.next .ico { transform: rotate(180deg); }
.viewer-nav[hidden] { display: none; }
@media (max-width: 600px) { .viewer-nav { display: none; } .viewer-bar .z, .viewer-zoom { display: none; } }

/* ---- media & files panel */
.media-modal .modal-body { padding-top: 6px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 10px 0; }
.media-cell { position: relative; border: 0; padding: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.media-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-cell .play { position: absolute; right: 6px; bottom: 6px; background: rgba(15, 12, 40, .65); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; }
.media-list { margin: 10px 0; }
.media-list .ficon { width: 42px; height: 42px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: .72rem; flex: none; }

/* ---- call quality UI */
.call-stats { font-size: .78rem; opacity: .7; min-height: 1em; }
.call-panel { position: absolute; right: 16px; bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 6; width: min(360px, calc(100vw - 32px)); max-height: 60vh; overflow: auto;
  background: rgba(20, 17, 52, .94); color: #fff; border: 1px solid rgba(255, 255, 255, .14); border-radius: 18px; padding: 14px 16px; backdrop-filter: blur(10px); box-shadow: var(--shadow); }
.call-panel h3 { margin: 0 0 8px; color: #fff; text-transform: none; font-size: 1rem; }
.call-panel .field > span { color: rgba(255, 255, 255, .7); }
.call-panel .input { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .18); }
.call-panel option { color: #000; }
.call-panel .muted { color: rgba(255, 255, 255, .6); }
.test-video { width: 100%; max-height: 240px; border-radius: 14px; background: #0d0b22; object-fit: cover; transform: scaleX(-1); margin-bottom: 8px; }
.meter { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22b573, #ffd23f, #e5484d); transition: width .06s linear; }

/* brand logo (yellow face) in the rail and the list header */
.rail-brand { display: grid; place-items: center; padding: 4px 0 16px; }
.brand-logo { width: 48px; height: 48px; border-radius: 14px; display: block; box-shadow: 0 4px 12px rgba(251, 199, 0, .35); }
.brand-logo.sm { width: 32px; height: 32px; border-radius: 10px; box-shadow: none; }
.app[data-section] .brand-word, .brand-word { align-items: center; gap: 10px; }
@media (min-width: 901px) { .app .brand-word { display: none; } }
@media (max-width: 600px) { .brand-word { display: flex; } }

/* sign-in screen must scroll on short phone screens (body itself never scrolls) */
.auth { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: block; padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.auth > .auth-card, .auth > * { margin-left: auto; margin-right: auto; }
.auth-card { margin-top: max(0px, calc((100dvh - 640px) / 2)); }

/* round logo everywhere */
.auth-logo, .brand-logo, .brand-logo.sm { border-radius: 50%; }

/* =====================================================================
   Look #3: colours taken from the logo — sunny yellow + charcoal.
   (--brand is the yellow fill, --brand-ink the charcoal text on it,
   --brand-text a darker gold for coloured text on light surfaces.)
   ===================================================================== */
:root {
  --brand: #fbc700;
  --brand-2: #ffdf0b;
  --brand-ink: #2b2b2e;
  --brand-text: #8a5a00;
  --brand-soft: #fff3b8;
  --bg: #fffaea;
  --surface: #ffffff;
  --surface-2: #fff7da;
  --line: #f0e3b0;
  --text: #25231a;
  --muted: #7b7458;
  --bubble-in: #ffffff;
  --bubble-out: #ffd400;
  --read: #0b6b3a;
  --shadow: 0 12px 36px rgba(138, 90, 0, .18);
  --g: linear-gradient(135deg, #ffe433, #fbc700);
}
:root[data-theme='dark'] {
  --brand: #ffd400;
  --brand-2: #ffe55c;
  --brand-ink: #232220;
  --brand-text: #ffd84a;
  --brand-soft: #3a3410;
  --bg: #171613;
  --surface: #22201b;
  --surface-2: #2c2923;
  --line: #3b372c;
  --text: #f6f1df;
  --muted: #aca58a;
  --bubble-in: #2c2923;
  --bubble-out: #ffd400;
  --read: #0b6b3a;
  --shadow: 0 12px 36px rgba(0, 0, 0, .55);
  --g: linear-gradient(135deg, #ffe433, #fbc700);
}

.btn:not(.secondary):not(.link):not(.danger):not(.cta), .send-btn, .badge:not(.muted) { background-image: var(--g); color: var(--brand-ink); }
.btn:hover:not(:disabled) { box-shadow: 0 6px 16px rgba(251, 199, 0, .45); }
.send-btn { box-shadow: 0 6px 16px rgba(251, 199, 0, .5); }
.btn.secondary { color: var(--text); }
.tab[aria-selected='true'], .tab[aria-selected='true'] * { color: var(--brand-text); }
.tab[aria-selected='true'] { border-bottom-color: var(--brand); }
@media (max-width: 600px) { .tab[aria-selected='true'] { background-image: var(--g); color: var(--brand-ink); } }
/* coloured text on light surfaces */
a, .btn.link, .chat-head .sub.live, .pinbar b, .unread-div, .sender, .quote b, .fwd, .tag, .ci-time.hot, .call-ico, .call-start { color: var(--brand-text) !important; }
.unread-div { background: var(--brand-soft); }
.tag { background: var(--brand-soft); }
.quote { border-left-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); }
.ci[aria-current='true'] { background: var(--brand-soft); }
.rail-item[aria-current='true'] { background: var(--brand-soft); color: var(--text); }
.bottomnav button[aria-current='true'] { color: var(--brand-text); }
.composer .icon-btn.attach { background: var(--brand-soft); color: var(--brand-text); }
.composer .icon-btn.attach:hover { background: var(--brand); color: var(--brand-ink); }
.call-start::before { background: var(--brand); }
/* outgoing bubbles: charcoal text on yellow */
.msg.out .bubble { background: var(--bubble-out); color: #2b2b2e; box-shadow: 0 6px 16px rgba(251, 199, 0, .35); }
.msg.out .bubble a { color: #3b2a00 !important; text-decoration: underline; }
.msg.out .bubble .meta, .msg.out .bubble .muted, .msg.out .bubble .tick, .msg.out .bubble .more { color: rgba(43, 43, 46, .72); }
.msg.out .bubble .tick.read { color: #0b6b3a; }
.msg.out .bubble .quote { background: rgba(43, 43, 46, .09); border-left-color: #2b2b2e; color: #2b2b2e; }
.msg.out .bubble .quote b, .msg.out .bubble .fwd { color: #2b2b2e !important; }
.msg.out .bubble .react { background: rgba(43, 43, 46, .08); border-color: rgba(43, 43, 46, .25); color: #2b2b2e; }
.msg.out .bubble .react.mine { background: rgba(43, 43, 46, .18); }
.msg.out .bubble .filecard .ficon { background: #2b2b2e; color: #ffd400; }
.msg.in .bubble { box-shadow: 0 2px 8px rgba(138, 90, 0, .09); }
.recent .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand); }
.call-overlay { background: radial-gradient(120% 80% at 50% 0%, #4a3c0c 0%, #14120a 62%); }
.rail-brand .brand-logo { box-shadow: 0 4px 12px rgba(251, 199, 0, .45); }

/* online dot sits on top of the avatar (the avatar no longer clips it) */
.avatar { overflow: visible; }
.avatar img { border-radius: 50%; }
.avatar .dot { right: -1px; bottom: -1px; width: 14px; height: 14px; border: 2.5px solid var(--surface); z-index: 2; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }
.avatar.sm .dot { width: 11px; height: 11px; border-width: 2px; }
.avatar.lg .dot { width: 20px; height: 20px; right: 4px; bottom: 4px; border-width: 3px; }
.recent .avatar .dot { width: 15px; height: 15px; right: 0; bottom: 0; }
.ci[aria-current='true'] .avatar .dot { border-color: var(--brand-soft); }

/* sign-in screen: tidy bottom row */
.btn.with-ico { display: flex; align-items: center; justify-content: center; gap: 10px; }
.auth-tools { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 18px; }
.auth-tools select { width: 100%; min-height: 46px; }
.btn.dl-link { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; width: 100%; white-space: nowrap; color: var(--text) !important; }
@media (min-width: 420px) { .auth-tools { grid-template-columns: 1fr 1.4fr; } }
.rail-item.active { color: var(--brand-text); }
.rail-item.active .rail-ico { color: var(--brand-text); }

/* ---- selection mode, info quick-actions, media counts */
.msg.selectable { cursor: pointer; position: relative; }
.msg.selectable .selbox { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); display: inline-grid; place-items: center; flex: none; align-self: center; margin: 0 8px; color: var(--brand-ink); }
.msg.sel .selbox { background: var(--brand); border-color: var(--brand); }
.msg.selectable.out { flex-direction: row-reverse; }
.msg.sel .bubble { outline: 2px solid var(--brand); }
.msg.selectable .more { display: none; }
.selbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.composer-wrap.selecting .composer, .composer-wrap.selecting .ctx { display: none; }
.info-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; margin: 14px 0; }
.info-actions button { display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; font-size: .78rem; font-weight: 600; transition: transform .15s, background-color .2s; }
.info-actions button:hover { background: var(--brand-soft); transform: translateY(-1px); }
.info-actions button .ico { color: var(--brand-text); }
.info-counts { display: grid; gap: 2px; margin: 8px 0 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.info-counts button { display: flex; align-items: center; gap: 14px; border: 0; background: none; padding: 10px 6px; border-radius: 12px; text-align: left; font: inherit; color: var(--text); }
.info-counts button:hover { background: var(--surface-2); }
.info-counts .ico { color: var(--muted); }
.info-counts b { margin-right: 4px; }
.rail-brand { display: grid; justify-items: center; gap: 6px; padding: 6px 0 14px; }
.brand-name { font-size: .72rem; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; color: var(--text); line-height: 1; }

/* ---- call window: a centred card on desktop (like Telegram), full screen on phones or via the button */
.call-overlay { background: rgba(10, 9, 6, .62); backdrop-filter: blur(6px); display: grid; grid-template-rows: none; place-items: center; }
.call-card { position: relative; width: min(760px, 94vw); height: min(620px, 88vh); border-radius: 26px; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto;
  background: radial-gradient(120% 80% at 50% 0%, #4a3c0c 0%, #14120a 62%); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.call-overlay.full .call-card, .call-overlay.video.live .call-card.fullish { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
@media (max-width: 700px), (max-height: 560px) { .call-card { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; } }
.call-card .call-remote { object-fit: contain; }
@media (max-width: 700px) { .call-card .call-remote { object-fit: cover; } }
.call-card .call-controls { gap: 14px; padding-bottom: calc(26px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
.call-card .call-ctl .call-btn { width: 56px; height: 56px; }
.call-card .call-btn.end { width: 66px; height: 66px; }
.call-ctl { position: relative; }
.call-ctl span { max-width: 84px; text-align: center; line-height: 1.15; }
.call-btn.on { background: rgba(255, 255, 255, .28); }
.call-btn.off { background: #fff; color: #14120a; }
.call-chev { position: absolute; top: -4px; right: -4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .28); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); transition: background-color .2s, transform .15s; padding: 0; min-height: 0; }
.call-chev .ico { transform: rotate(90deg); }
.call-chev:hover { background: rgba(255, 255, 255, .45); transform: scale(1.1); }
.call-fs { position: absolute; top: 14px; right: 14px; z-index: 6; width: 36px; height: 36px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .16); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); }
.call-fs:hover { background: rgba(255, 255, 255, .3); }
.call-local.screen { transform: none; object-fit: contain; }
.call-overlay.rvoff .call-remote { opacity: 0; }
.call-overlay.rvoff .call-who .avatar { display: grid !important; }
.call-panel { z-index: 7; }
.menu { z-index: 200; }

/* ===== composer: one round button (microphone when empty, plane when typing), no scrollbar arrows ===== */
.composer textarea { scrollbar-width: none; -ms-overflow-style: none; overflow-y: auto; }
.composer textarea::-webkit-scrollbar { display: none; width: 0; height: 0; }
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send-btn { touch-action: none; user-select: none; -webkit-user-select: none; }
.send-btn[data-mode='mic'] { background: var(--g); }
.composer .rec-hint { color: var(--muted); font-size: .9rem; white-space: nowrap; opacity: 0; transition: opacity .2s, transform .2s; }

/* ===== recording bar ===== */
.recbar { display: none; flex: 1; min-width: 0; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 26px; padding: 4px 10px 4px 6px; min-height: 50px; }
.composer.recording > .attach, .composer.recording > .field-wrap { display: none; }
.composer.recording > .recbar { display: flex; }
.composer.recording .send-btn[data-mode='mic'] { background: var(--danger); color: #fff; animation: recpulse 1.4s ease-in-out infinite; }
@keyframes recpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .5); } 50% { box-shadow: 0 0 0 12px rgba(229, 72, 77, 0); } }
.recbar .rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; flex: none; }
.recbar .rec-time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 40px; }
.recbar .rec-wave { flex: 1; min-width: 0; height: 32px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.recbar .rec-wave i { width: 3px; border-radius: 2px; background: var(--brand-text); flex: none; height: 4px; transition: height .08s; }
.composer.recording:not(.locked) .rec-hint { opacity: 1; }
.composer.recording:not(.locked) .rec-trash { display: none; }
.composer.recording.cancelling .recbar { background: color-mix(in srgb, var(--danger) 16%, var(--surface-2)); }
.composer.recording.cancelling .rec-hint { color: var(--danger); transform: translateX(-8px); }
.composer.recording.locked .rec-hint { display: none; }
.rec-trash { color: var(--danger) !important; }

/* ===== voice message bubble ===== */
.voice { display: flex; align-items: center; gap: 12px; min-width: min(250px, 66vw); max-width: 320px; padding: 2px 0; }
.voice-play { width: 46px; height: 46px; border-radius: 50%; border: 0; flex: none; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 40%, transparent); transition: transform .15s; padding: 0; }
.voice-play:hover { transform: scale(1.06); }
.voice-play:active { transform: scale(.94); }
.voice-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.voice-title { font-weight: 700; font-size: .9rem; }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.voice-wave i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: color-mix(in srgb, var(--text) 28%, transparent); transition: background-color .12s; }
.voice-wave i.on { background: var(--brand-text); }
.msg.out .bubble .voice-wave i { background: rgba(43, 43, 46, .3); }
.msg.out .bubble .voice-wave i.on { background: #2b2b2e; }
.msg.out .bubble .voice-play { background: #2b2b2e; color: #ffd400; box-shadow: none; }
.voice-foot { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg.out .bubble .voice-foot { color: rgba(43, 43, 46, .72); }
.voice-speed { border: 1px dashed currentColor; background: none; border-radius: 8px; padding: 0 6px; font: inherit; font-weight: 800; color: var(--brand-text); cursor: pointer; }
.msg.out .bubble .voice-speed { color: #2b2b2e; }

/* ===== top audio player (like Telegram) ===== */
.gplayer { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 90; width: min(640px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: rise .22s both; }
.gp-row { display: flex; align-items: center; gap: 2px; padding: 6px 8px; }
.gp-row .icon-btn { color: var(--brand-text); }
.gp-row .icon-btn:disabled { opacity: .3; }
.gp-play { background: var(--brand-soft); border-radius: 50% !important; }
.gp-title { flex: 1; min-width: 0; padding: 0 10px; font-size: .92rem; }
.gp-time { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; margin-right: 6px; white-space: nowrap; }
.gp-speed { border: 1px dashed var(--brand-text); background: none; color: var(--brand-text); border-radius: 8px; padding: 2px 6px; font: inherit; font-weight: 800; font-size: .82rem; cursor: pointer; margin-right: 4px; }
.gp-prog { height: 3px; background: var(--line); }
.gp-prog i { display: block; height: 100%; width: 0; background: var(--g); transition: width .25s linear; }
@media (max-width: 480px) { .gp-time { display: none; } }

/* ===== update notice: a small card that sits in the sidebar corner, never against the window edge ===== */
.update-banner { position: fixed; left: calc(var(--rail-w, 104px) + 12px); bottom: 14px; transform: none; width: min(calc(var(--sidebar-w, 380px) - 24px), calc(100vw - 24px)); max-width: none;
  z-index: 95; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; padding: 10px 8px 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 14px 40px rgba(0, 0, 0, .22); animation: rise .25s both; }
.ub-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--g); color: var(--brand-ink); }
.ub-text { display: grid; min-width: 0; line-height: 1.25; }
.ub-text b { font-size: .95rem; }
.ub-text span { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ub-btn { border: 0; border-radius: 999px; padding: 9px 14px; background: var(--g); color: var(--brand-ink); font: inherit; font-weight: 800; font-size: .84rem; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; cursor: pointer; transition: transform .15s, box-shadow .2s; }
.ub-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(251, 199, 0, .45); }
.ub-x { border: 0; background: none; color: var(--muted); width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.ub-x:hover { background: var(--surface-2); }
@media (max-width: 600px) {
  .update-banner { left: 12px; right: 12px; width: auto; bottom: calc(76px + env(safe-area-inset-bottom)); grid-template-columns: auto 1fr auto auto; }
  .ub-text span { display: none; }
}

/* ===== phone polish: compact like Telegram, nothing runs past the edge (checked at 320px) ===== */
.gplayer { left: 0; width: 100%; top: 0; transform: none; border-radius: 0; border-width: 0 0 1px; max-width: none; box-shadow: 0 8px 18px rgba(0, 0, 0, .08); animation: gpdrop .2s both; }
@keyframes gpdrop { from { opacity: 0; } to { opacity: 1; } }
.has-gplayer .messages { padding-top: 54px; }
.gp-row { padding: 4px 6px; }
.gp-title { white-space: nowrap; }
.filecard .ficon, .media-list .ficon { flex: none; width: 46px; height: 46px; border-radius: 12px; font-size: .72rem; letter-spacing: -.01em; overflow: hidden; }
.filecard .fname { display: grid; min-width: 0; gap: 2px; line-height: 1.25; }
.filecard .fname b { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .95rem; }
.filecard .fname .muted { font-size: .82rem; }
@media (hover: none) and (pointer: coarse) { .more { display: none; } } /* long-press opens the menu, as in Telegram */
@media (max-width: 600px) {
  .brand-word { white-space: nowrap; font-size: 1.35rem; gap: 8px; }
  .brand-word .brand-logo { width: 30px; height: 30px; }
  .chat-head { gap: 2px; padding-left: 4px; padding-right: 4px; }
  .chat-head .icon-btn { width: 40px; min-width: 40px; }
  .chat-head .who { gap: 10px; padding: 2px; }
  .chat-head .who .avatar { width: 40px; height: 40px; flex: none; }
  .chat-head .who b { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-head .sub { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .composer-wrap { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .composer { gap: 6px; }
  .composer .icon-btn.attach { width: 40px; height: 40px; flex: none; }
  .field-wrap { padding: 2px 4px 2px 14px; min-height: 44px; }
  .composer textarea { padding: 9px 2px; min-height: 40px; font-size: 1rem; }
  .field-wrap .icon-btn { width: 36px; height: 36px; padding: 0; }
  .send-btn { width: 44px; height: 44px; }
  .recbar { min-height: 44px; }
  .bubble { max-width: 86%; }
}

/* ===== floating bottom navigation pill (like Telegram) ===== */
@media (max-width: 600px) {
  .app[data-view='list'] .bottomnav {
    position: fixed; z-index: 40; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 6px; border: 1px solid var(--line); border-radius: 30px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .16);
  }
  .bottomnav button { min-height: 54px; border-radius: 24px; gap: 2px; justify-items: center; align-content: center; padding: 4px 2px; font-size: .74rem; }
  .bottomnav button[aria-current='true'] { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
  .bottomnav .nb-ico { position: relative; display: grid; place-items: center; }
  .bottomnav .nb-badge { position: absolute; top: -7px; left: 52%; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--g); color: var(--brand-ink);
    font-size: .72rem; font-weight: 800; line-height: 20px; text-align: center; box-sizing: border-box; border: 2px solid var(--surface); line-height: 16px; }
  .bottomnav .nb-badge[hidden] { display: none; }
  .bottomnav .nb-label { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .app[data-view='list'] .chatlist { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* update card v3: icon + text on top, full-width button below - never clips the title */
.update-banner, .update-banner[class] { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'ico text x' 'btn btn btn'; row-gap: 10px; padding: 12px 10px 12px 14px; }
.ub-ico { grid-area: ico; }
.ub-text { grid-area: text; }
.ub-text b { font-size: 1rem; }
.ub-text span { white-space: normal; display: block; font-size: .84rem; }
.ub-x { grid-area: x; align-self: start; }
.ub-btn { grid-area: btn; width: 100%; padding: 11px 14px; font-size: .9rem; }
@media (max-width: 600px) {
  .update-banner { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ub-text span { display: block; }
}

/* ===== bots: inline keyboard, token box, commands button ===== */
.ikb { display: grid; gap: 6px; margin-top: 8px; }
.ikb-row { display: flex; gap: 6px; }
.ikb-btn { flex: 1; min-width: 0; border: 0; border-radius: 10px; padding: 9px 10px; font: inherit; font-weight: 700; font-size: .92rem; cursor: pointer;
  background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: background .15s, transform .1s; }
.ikb-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 16%, transparent); }
.ikb-btn:active:not(:disabled) { transform: scale(.97); }
.ikb-btn:disabled { opacity: .55; cursor: default; }
.msg.out .bubble .ikb-btn { background: rgba(43, 43, 46, .14); color: #2b2b2e; }
.icon-btn.bot-cmd { font-weight: 800; font-size: 1.15rem; color: var(--brand-text); }
.bot-token-val { display: block; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); word-break: break-all; font-size: .85rem; user-select: all; margin: 6px 0 10px; }
.bot-row { border-bottom: 1px solid var(--line); padding: 4px 0 10px; }
.bot-detail { padding: 8px 0 0; }
.bot-new { background: var(--brand-soft); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.bots-modal textarea.input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; }

/* ===== polls, folders, global search, pins ===== */
.poll { display: grid; gap: 6px; min-width: min(260px, 70vw); }
.poll-q { font-weight: 800; font-size: 1.02rem; line-height: 1.3; overflow-wrap: anywhere; }
.poll-sub { font-size: .8rem; color: var(--muted); }
.msg.out .bubble .poll-sub, .msg.out .bubble .poll-foot { color: rgba(43, 43, 46, .72); }
.poll-opt { position: relative; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; text-align: left; border: 0; border-radius: 10px;
  padding: 8px 10px; background: color-mix(in srgb, var(--text) 7%, transparent); font: inherit; color: inherit; cursor: pointer; overflow: hidden; }
.poll-opt:disabled { cursor: default; }
.poll-opt .poll-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--brand); transition: width .35s ease; }
.poll-mark { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; }
.poll-opt.mine .poll-mark { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.poll-text { overflow-wrap: anywhere; }
.poll-pct { font-weight: 800; font-variant-numeric: tabular-nums; }
.poll-foot { display: flex; align-items: center; justify-content: space-between; font-size: .82rem; color: var(--muted); }
.poll-opts { display: grid; gap: 8px; margin: 10px 0; }
.pin-ico { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: var(--muted); }
.folder-chats { max-height: 46vh; overflow: auto; display: grid; gap: 2px; margin: 10px 0; }
.folder-chat { padding: 6px 4px; border-radius: 10px; }
.folder-chat:hover { background: var(--surface-2); }
.gs-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 10px 0; }
.gs-results { display: grid; gap: 2px; max-height: 46vh; overflow: auto; }
.quiet-times { gap: 8px; align-items: center; flex-wrap: wrap; }
.quiet-times .input { width: auto; }
.sched-item .ellipsis { max-width: 100%; }

/* ===== group calls ===== */
.gc-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--brand-soft); border-bottom: 1px solid var(--line); color: var(--brand-text); }
.gc-bar[hidden] { display: none; }
.gc-bar .btn { min-height: 34px; padding: 4px 14px; }
.live-call { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: var(--ok, #22a559); animation: pulse 1.4s infinite; }
.gcall { position: fixed; inset: 0; z-index: 120; display: grid; grid-template-rows: auto 1fr auto; background: #15161a; color: #fff; }
.gcall.min { inset: auto 12px calc(12px + env(safe-area-inset-bottom)) auto; width: 220px; height: auto; border-radius: 18px; grid-template-rows: auto; box-shadow: 0 12px 30px rgba(0, 0, 0, .35); }
.gcall.min .gc-grid, .gcall.min .gc-controls { display: none; }
.gc-head { display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
.gc-head b { flex: 1; min-width: 0; }
.gc-time { font-variant-numeric: tabular-nums; opacity: .8; }
.gc-grid { display: grid; gap: 8px; padding: 8px; min-height: 0; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.gc-grid[data-n='2'] { grid-template-columns: 1fr; }
.gc-grid[data-n='3'], .gc-grid[data-n='4'] { grid-template-columns: 1fr 1fr; }
.gc-grid[data-n='5'], .gc-grid[data-n='6'] { grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) {
  .gc-grid[data-n='2'] { grid-template-columns: 1fr 1fr; }
  .gc-grid[data-n='5'], .gc-grid[data-n='6'] { grid-template-columns: 1fr 1fr 1fr; }
}
.gc-tile { position: relative; border-radius: 16px; overflow: hidden; background: #24262d; display: grid; place-items: center; min-height: 0; }
.gc-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.gc-tile.has-video video { opacity: 1; }
.gc-tile.has-video .gc-avatar { display: none; }
.gc-tile.connecting::after { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, .25); }
.gc-name { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 6px; align-items: center; padding: 3px 10px; border-radius: 12px; background: rgba(0, 0, 0, .5); font-size: .85rem; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-muted { color: #ff6b6b; display: inline-flex; opacity: .95; }
.gc-controls { display: flex; justify-content: center; gap: 18px; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); }
.gc-btn { width: 58px; height: 58px; border-radius: 50%; border: 0; background: #34363f; color: #fff; display: grid; place-items: center; cursor: pointer; transition: transform .15s, background .2s; }
.gc-btn:hover { transform: scale(1.06); }
.gc-btn.off { background: #fff; color: #1b1c20; }
.gc-btn.end { background: #e5484d; }
.gc-btn.end .ico { transform: rotate(135deg); }
.gc-btn.small { width: 38px; height: 38px; background: transparent; }
.gcall.min .gc-head { padding-top: 8px; }

/* long menus scroll instead of running off the screen */
.menu { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
@media (hover: none) and (pointer: coarse) { .menu button { min-height: 44px; } }

/* ===== phone: compact, Telegram-like chat list (no big avatar row, search on demand, floating compose button) ===== */
.fab { display: none; }
.update-snack { position: fixed; z-index: 140; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 999px; background: #2b2b2e; color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); font-size: .9rem; }
.update-snack .us-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.update-snack .us-btn { border: 0; border-radius: 999px; padding: 6px 14px; background: var(--g); color: var(--brand-ink); font: inherit; font-weight: 800; cursor: pointer; white-space: nowrap; }
.update-snack .us-x { border: 0; background: none; color: #fff; opacity: .7; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
@media (max-width: 600px) {
  .sidebar .recent { display: none; }
  .sidebar:not([data-search='open']) .search { display: none; }
  .side-head2 { padding: calc(6px + env(safe-area-inset-top)) 4px 2px 14px; min-height: 52px; }
  .side-head2 .compose-btn { display: none; }
  .brand-word { font-size: 1.2rem; gap: 8px; }
  .brand-word .brand-logo { width: 28px; height: 28px; }
  .search { margin: 2px 12px 6px; }
  .search .input { min-height: 42px; }
  .tabs { margin: 2px 10px 6px; padding: 4px; gap: 2px; background: var(--surface-2); border-radius: 22px; border-bottom: 0; }
  .tab { padding: 6px 12px; font-size: .9rem; background: transparent; }
  .tab[aria-selected='true'] { background: var(--surface); color: var(--brand-text); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); background-image: none; }
  .chatlist { padding: 0 0 calc(110px + env(safe-area-inset-bottom)); }
  .ci { padding: 7px 14px; gap: 12px; border-radius: 0; }
  .ci .avatar { width: 50px; height: 50px; font-size: 1.1rem; }
  .ci-title { font-size: .98rem; }
  .ci-last { font-size: .88rem; }
  .app[data-view='list'] .bottomnav { left: 12px; right: 12px; padding: 4px; border-radius: 26px; }
  .bottomnav button { min-height: 46px; font-size: .68rem; gap: 1px; }
  .bottomnav button .ico { width: 22px; height: 22px; }
  .fab { display: grid; place-items: center; position: fixed; z-index: 39; right: 16px; bottom: calc(82px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%;
    border: 0; background-image: var(--g); color: var(--brand-ink); box-shadow: 0 8px 20px rgba(251, 199, 0, .5); cursor: pointer; }
  .app:not([data-view='list']) .fab { display: none; }
}

/* ===== settings, laid out like Telegram (sections with icons, sub-pages with a back arrow) ===== */
.avatar.xl { width: 120px; height: 120px; font-size: 2.6rem; }
.modal.settings-modal { width: min(480px, 100vw); height: min(780px, 92vh); height: min(780px, 92dvh); max-height: none; padding: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--surface-2); border-radius: 22px; }
.settings-modal > .modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0; overscroll-behavior: contain; }
@media (max-width: 600px) {
  .modal.settings-modal { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
}
.st-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.st-head h2 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.st-head .icon-btn { color: var(--muted); }
.st-page { padding: 0 0 calc(24px + env(safe-area-inset-bottom)); }
.st-me { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--surface); }
.st-me-photo { position: relative; border: 0; background: none; padding: 0; flex: none; cursor: pointer; }
.st-me-photo .avatar { width: 72px; height: 72px; font-size: 1.6rem; }
.st-cam { position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--g); color: var(--brand-ink); display: grid; place-items: center; border: 2px solid var(--surface); }
.st-me-text { display: grid; gap: 2px; text-align: left; min-width: 0; border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.st-me-text b { font-size: 1.2rem; }
.st-me-text span { color: var(--muted); font-size: .95rem; }
.accent { color: var(--brand-text) !important; }
.sgroup { background: var(--surface); margin-top: 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sheading { padding: 18px 18px 6px; font-weight: 800; font-size: .88rem; color: var(--brand-text); }
.snote { padding: 8px 18px 4px; font-size: .84rem; color: var(--muted); line-height: 1.4; }
.srow { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 54px; padding: 8px 16px; border: 0; background: none; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.srow:hover { background: var(--surface-2); }
.srow.static { cursor: default; }
.srow.static:hover { background: none; }
.srow.danger { color: var(--danger); }
.srow-ico { flex: none; width: 24px; height: 24px; color: var(--muted); display: grid; place-items: center; }
.srow-ico.none { width: 2px; }
.srow.danger .srow-ico { color: var(--danger); }
.srow-label { flex: 1; min-width: 0; display: grid; gap: 2px; }
.srow-label small { color: var(--muted); font-size: .82rem; }
.srow-value { color: var(--brand-text); font-weight: 600; flex: none; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow-go { color: var(--muted); display: grid; opacity: .7; }
.sgroup .srow + .srow, .sgroup .sinfo + .sinfo { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.sfield { padding: 10px 16px; display: grid; gap: 6px; }
.sfield > span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.sfield .row.between { justify-content: space-between; }
.sfield input[type='range'] { width: 100%; accent-color: var(--brand); }
.sinfo { display: flex; align-items: center; padding: 12px 16px; gap: 10px; }
.sinfo-main { flex: 1; min-width: 0; }
.sinfo-value { font-size: 1.02rem; overflow-wrap: anywhere; }
.sinfo-cap { color: var(--muted); font-size: .84rem; margin-top: 2px; }
.st-hero { display: grid; justify-items: center; gap: 4px; padding: 22px 16px 18px; background: var(--surface); text-align: center; }
.st-hero.small { padding: 16px; }
.st-hero h3 { margin: 8px 0 0; font-size: 1.4rem; }
.st-hero-photo { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.switch { position: relative; flex: none; width: 46px; height: 26px; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 13px; background: color-mix(in srgb, var(--muted) 45%, transparent); transition: background .2s; pointer-events: none; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 3px solid var(--brand-soft); }
.radio { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); position: relative; }
.radio.on { border-color: var(--brand); }
.radio.on::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--brand); }
.theme-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 10px 16px 4px; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 0; padding-bottom: 14px; }
.theme-tile { border: 2px solid transparent; border-radius: 16px; background: none; padding: 0; font: inherit; color: var(--text); cursor: pointer; display: grid; gap: 6px; justify-items: center; }
.tt-prev { display: grid; gap: 6px; align-content: center; width: 100%; height: 78px; border-radius: 14px; padding: 10px; background: #fff7d6; box-sizing: border-box; }
.tt-prev i { display: block; height: 14px; border-radius: 7px; background: #fff; width: 70%; }
.tt-prev i + i { background: #ffd400; justify-self: end; width: 60%; }
.theme-tile.dark .tt-prev { background: #1c1d22; }
.theme-tile.dark .tt-prev i { background: #34363f; }
.theme-tile.auto .tt-prev { background: linear-gradient(110deg, #fff7d6 50%, #1c1d22 50%); }
.theme-tile.on { border-color: var(--brand); }
.tt-name { font-weight: 600; font-size: .9rem; padding-bottom: 4px; }
.keys.sfield { grid-template-columns: auto 1fr; gap: 6px 14px; }

.st-hero h3, .sheading, .st-me-text b { text-transform: none; letter-spacing: 0; }

/* avatars in the settings screens are always round, whatever the photo's shape or the flex layout around them */
.st-me-photo, .st-hero-photo { display: block; line-height: 0; border-radius: 50%; overflow: visible; }
.st-me-photo { width: 72px; height: 72px; }
.st-hero-photo { width: 120px; height: 120px; }
.st-hero.small .st-hero-photo { width: 96px; height: 96px; }
.st-me-photo .avatar, .st-hero-photo .avatar { width: 100%; height: 100%; min-width: 0; aspect-ratio: 1 / 1; border-radius: 50%; overflow: hidden; display: grid; place-items: center; }
.st-me-photo .avatar img, .st-hero-photo .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ===== calls: dock with round buttons, small rounded self-view, timer pill (like the reference designs) ===== */
.call-card .call-controls { align-self: end; justify-self: center; width: max-content; max-width: calc(100% - 24px); margin: 0 auto calc(18px + env(safe-area-inset-bottom));
  padding: 10px 14px; gap: 12px; flex-wrap: nowrap; background: rgba(18, 18, 22, .62); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-radius: 40px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.call-card .call-ctl { display: grid; justify-items: center; gap: 4px; }
.call-card .call-ctl span { font-size: .68rem; opacity: .8; }
.call-card .call-ctl .call-btn { width: 52px; height: 52px; }
.call-card .call-btn.end { width: 62px; height: 62px; background: #ff3b30; box-shadow: 0 8px 22px rgba(255, 59, 48, .5); }
.call-card .call-local { top: calc(64px + env(safe-area-inset-top)); right: 14px; bottom: auto; width: 96px; border-radius: 18px; border: 2px solid rgba(255, 255, 255, .85); box-shadow: 0 10px 26px rgba(0, 0, 0, .4); }
.call-card .call-time { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: rgba(0, 0, 0, .45); font-variant-numeric: tabular-nums; font-weight: 700; }
.call-card .call-time::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #ff3b30; }
.call-card .call-time:empty { display: none; }
.call-card { box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
@media (max-width: 700px) { .call-card .call-local { width: 88px; } }

/* group calls: rounded tiles, dock like the reference */
.gc-grid { gap: 10px; padding: 10px; }
.gc-tile { border-radius: 22px; }
.gc-controls { gap: 14px; padding: 10px 16px; margin: 0 auto calc(16px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 24px);
  background: rgba(40, 40, 46, .85); backdrop-filter: blur(14px); border-radius: 40px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.gc-btn.end { width: 66px; height: 66px; background: #ff3b30; order: 0; }
.gc-name { background: rgba(0, 0, 0, .45); backdrop-filter: blur(6px); }

/* ===== QR code, photo album, birthday ===== */
.qr-box { display: grid; justify-items: center; gap: 4px; padding: 10px 0 4px; }
.qr-svg { width: min(260px, 70vw); height: auto; border-radius: 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; }
.photo-tile { position: relative; aspect-ratio: 1 / 1; border: 0; padding: 0; background: var(--surface-2); overflow: hidden; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.photo-tile:hover img { transform: scale(1.05); }
.photo-tile.current::after { content: ''; position: absolute; inset: auto 6px 6px auto; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.photo-tile.add { background: var(--brand-soft); color: var(--brand-text); }
.sgroup.album { padding: 0; }
.auth-admin { display: block; text-align: center; margin: 14px auto 0; color: var(--muted); font-size: .88rem; text-decoration: underline; }

/* notification window placement (desktop app) */
.notif-place { padding: 14px 16px 10px; }
.np-screen { position: relative; width: min(100%, 300px); aspect-ratio: 16 / 9; margin: 0 auto; border-radius: 12px; border: 6px solid #2b2b2e; background: var(--brand-soft); }
.np-corner { position: absolute; width: 44%; display: grid; gap: 3px; padding: 4px; border: 0; background: transparent; cursor: pointer; opacity: .35; transition: opacity .15s; }
.np-corner i { display: block; height: 6px; border-radius: 3px; background: var(--muted); }
.np-corner.on { opacity: 1; }
.np-corner.on i { background: var(--brand); }
.np-corner.tl { left: 2px; top: 2px; } .np-corner.tr { right: 2px; top: 2px; } .np-corner.bl { left: 2px; bottom: 2px; } .np-corner.br { right: 2px; bottom: 2px; }
.np-counts { display: flex; gap: 6px; padding: 6px 0 4px; }
.np-counts button { flex: 1; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 10px 0; font: inherit; font-weight: 700; cursor: pointer; color: var(--text); }
.np-counts button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.st-hero h3 { color: var(--text); }

/* an avatar is always an exact circle: the photo is pinned to the square (a tall photo used to stretch it into an egg) */
.avatar { aspect-ratio: 1 / 1; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ===== stories ===== */
.stories-bar { display: flex; gap: 12px; padding: 6px 14px 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.stories-bar::-webkit-scrollbar { display: none; }
.story-item { position: relative; flex: none; width: 62px; display: grid; justify-items: center; gap: 4px; border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: var(--text); }
.story-ring { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; padding: 3px; background: linear-gradient(135deg, #fbc700, #ff8a00); box-sizing: border-box; }
.story-ring .avatar { width: 100%; height: 100%; border: 2px solid var(--surface); box-sizing: border-box; }
.story-item.seen .story-ring { background: var(--line); }
.story-item.mine:not(.has) .story-ring { background: var(--surface-2); }
.story-add { position: absolute; right: 2px; top: 38px; width: 20px; height: 20px; border-radius: 50%; background: var(--g); color: var(--brand-ink); display: grid; place-items: center; border: 2px solid var(--surface); }
.story-name { max-width: 62px; font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.story-viewer { position: fixed; inset: 0; z-index: 130; background: #000; display: grid; grid-template-rows: auto auto 1fr auto; color: #fff; }
.sv-bars { display: flex; gap: 4px; padding: calc(8px + env(safe-area-inset-top)) 10px 4px; }
.sv-bar { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.sv-bar i { display: block; height: 100%; width: 0; background: #fff; }
.sv-bar.done i { width: 100%; }
.sv-bar.now i { width: 100%; animation: svfill 5.5s linear; }
@keyframes svfill { from { width: 0; } to { width: 100%; } }
.sv-head { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.sv-head small { display: block; opacity: .75; }
.sv-head .icon-btn { color: #fff; }
.sv-stage { position: relative; display: grid; place-items: center; overflow: hidden; margin: 0 auto; width: min(100%, 520px); }
.sv-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sv-text { position: absolute; padding: 24px; font-size: 1.7rem; font-weight: 800; text-align: center; overflow-wrap: anywhere; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .3); }
.sv-text.cap { bottom: 0; left: 0; right: 0; font-size: 1.05rem; font-weight: 600; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); padding: 40px 18px 18px; }
.sv-foot { min-height: 20px; padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); text-align: center; }
.sv-views { border: 0; border-radius: 999px; padding: 8px 16px; background: rgba(255, 255, 255, .18); color: #fff; font: inherit; cursor: pointer; }
.sv-nav { position: absolute; top: 90px; bottom: 70px; width: 38%; border: 0; background: none; cursor: pointer; opacity: 0; }
.sv-nav.prev { left: 0; }
.sv-nav.next { right: 0; }
.story-text { min-height: 120px; font-size: 1.2rem; font-weight: 700; border-radius: 16px; }
.story-colors { display: flex; gap: 8px; margin: 10px 0; }
.story-color { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.story-color.on { border-color: var(--text); }
.story-tile { background: var(--surface-2); }
.story-tile-text { padding: 8px; font-size: .78rem; text-align: center; overflow: hidden; }
.story-tile-date { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 6px; padding: 1px 5px; font-size: .68rem; }

/* ===== QR scanner, auto-delete chip, big emoji ===== */
.scan-frame { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; }
.scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-corners { position: absolute; inset: 14%; border: 3px solid var(--brand); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none; }
.ttl-chip { font-size: .72rem; font-weight: 700; color: var(--brand-text); background: var(--brand-soft); border-radius: 8px; padding: 1px 6px; margin-left: 6px; white-space: nowrap; }
.bubble.big-emoji { background: transparent !important; box-shadow: none !important; padding: 2px 4px; }
.bubble.big-emoji .text { font-size: 3.4rem; line-height: 1.1; }
.bubble.big-emoji .meta { color: var(--muted) !important; }

/* ===== gestures ===== */
.msg, .ci { touch-action: pan-y; }
.msg .bubble { transition: transform .18s ease; }
.msg.swiping .bubble { transition: none; }
.msg.swiping::after { content: '\21A9'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: color-mix(in srgb, var(--brand) 30%, var(--surface)); color: var(--brand-text); font-weight: 800; }
.msg { position: relative; }
.ci { transition: transform .18s ease; }
.edge-hint { position: fixed; z-index: 300; left: 0; top: 50%; width: 42px; height: 42px; margin-top: -21px; border-radius: 0 21px 21px 0; background: rgba(30, 30, 34, .78); pointer-events: none; }
.edge-hint::before { content: '\2039'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.8rem; line-height: 1; }
.edge-hint[hidden] { display: none; }

.stories-bar[hidden] { display: none; }

/* ===== call and dialog buttons scale to any screen (320 px phones, tablets, short landscape screens) ===== */
.call-card .call-controls { flex-wrap: wrap; justify-content: center; gap: clamp(6px, 2vw, 14px); padding: clamp(6px, 1.6vw, 10px) clamp(8px, 3vw, 16px); max-width: calc(100vw - 16px); }
.call-card .call-ctl .call-btn { width: clamp(42px, 13.5vw, 56px); height: clamp(42px, 13.5vw, 56px); }
.call-card .call-btn.end { width: clamp(50px, 16vw, 64px); height: clamp(50px, 16vw, 64px); }
.call-card .call-ctl span { max-width: 64px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 380px) { .call-card .call-ctl span { display: none; } .call-card .call-controls { gap: 6px; } }
@media (max-height: 520px) { .call-card .call-ctl span { display: none; } .call-card .call-controls { margin-bottom: 8px; padding: 6px 10px; } .call-card .call-local { width: 72px; top: 52px; } }
.gc-controls { flex-wrap: wrap; justify-content: center; gap: clamp(8px, 2.4vw, 16px); }
.gc-btn { width: clamp(44px, 14vw, 58px); height: clamp(44px, 14vw, 58px); }
.gc-btn.end { width: clamp(52px, 17vw, 66px); height: clamp(52px, 17vw, 66px); }
.modal .row, .st-page .row { flex-wrap: wrap; }
.btn { max-width: 100%; }
@media (max-width: 360px) { .composer { gap: 4px; } .send-btn { width: 42px; height: 42px; } .composer .icon-btn.attach { width: 36px; height: 36px; } .bottomnav button { font-size: .62rem; } }
/* controls wrap inside the screen instead of being as wide as one row of buttons */
.call-card .call-controls, .gc-controls { width: fit-content; max-width: calc(100% - 16px); box-sizing: border-box; }
.call-card { grid-template-columns: minmax(0, 1fr); }
.call-card > * { min-width: 0; }
/* the blurred backdrop is bigger than the card: it must never make the card scrollable (that shifted the buttons) */
.call-card { overflow: hidden; overflow: clip; }
.call-bg { max-width: none; }

/* ===== shared location / contact cards, tappable phone numbers ===== */
.bubble a.tel { text-decoration: underline; text-underline-offset: 2px; }
.geo-card { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 220px; padding: 10px; border-radius: 14px; border: 0; background: rgba(0,0,0,.06); color: inherit; text-align: left; cursor: pointer; }
.geo-pin { width: 46px; height: 46px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; flex: none; }
.geo-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.geo-open { font-size: .8rem; text-decoration: underline; }
.contact-card { display: flex; flex-direction: column; gap: 8px; min-width: 220px; padding: 4px 0; }
.contact-top { display: flex; align-items: center; gap: 10px; }
.contact-txt { display: flex; flex-direction: column; min-width: 0; }
.contact-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.contact-list { max-height: 40vh; overflow: auto; margin: 8px 0; }
.contact-manual { display: grid; gap: 8px; padding-top: 8px; }

/* ===== minimal language picker on the sign-in card ===== */
.auth-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.auth-tools select { width: auto; min-height: 0; padding: 6px 4px 6px 2px; border: 0; background-color: transparent; box-shadow: none; font-size: .9rem; color: var(--muted, #7a6d3a); cursor: pointer; border-radius: 8px; }
.auth-tools select:hover, .auth-tools select:focus-visible { color: var(--text); }
.auth-tools .dl-link { width: auto; min-height: 0; padding: 8px 12px; font-size: .88rem; }
