:root {
  /* Dark Telegram-like palette (unchanged) */
  --bg: #0e1621;
  --panel: #17212b;
  --pane: #0e1621;
  --sidebar: #17212b;
  --line: #242f3d;
  --text: #f5f5f5;
  --muted: #8b9bb4;
  --accent: #2aabee;
  --danger: #e53935;
  --ok: #4caf50;
  --warn: #ffb300;
  --radius: 12px;
  --font: "Segoe UI", system-ui, sans-serif;
  --topbar-h: 52px;
  --sidebar-w: 340px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --z-base: 1;
  --z-sticky: 20;
  --z-flash: 30;
  --z-topbar: 40;
  --z-menu: 50;
  --z-drawer: 60;
  --z-modal: 70;
}

/* Light theme (Night Mode off) — TG-1412 */
html[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f4f4f5;
  --pane: #ffffff;
  --sidebar: #ffffff;
  --line: #e4e4e7;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2aabee;
}
* { box-sizing: border-box; }
html {
  height: 100%;
  scroll-padding-block-start: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
}
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
.linkish {
  color: var(--muted); background: none; border: 0; cursor: pointer; font: inherit;
  padding: var(--space-1) var(--space-2); border-radius: 6px;
}
.linkish:hover { color: var(--text); background: rgba(255,255,255,.04); }
.inline { display: inline; margin: 0; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
h1, h2, .empty-state h2 { text-wrap: balance; }
.muted, .dialog-preview, .presence-line { text-wrap: pretty; }

/* —— Top bar —— */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-4);
  padding-block: 0;
  padding-inline: max(var(--space-4), env(safe-area-inset-left, 0px)) max(var(--space-4), env(safe-area-inset-right, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: var(--z-topbar);
}
.topbar-left { display: flex; align-items: center; gap: 1.25rem; min-width: 0; }
.brand { font-weight: 700; color: var(--text); }
.topbar-primary { display: flex; gap: .85rem; align-items: center; }
.topbar-primary a { color: var(--muted); padding: var(--space-1) var(--space-2); border-radius: 6px; }
.topbar-primary a:hover,
.topbar-primary a.active { color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

/* —— Menus —— */
.menu { position: relative; }
.menu-summary {
  list-style: none; cursor: pointer; color: var(--muted);
  padding: .35rem .55rem; border-radius: 8px; border: 1px solid transparent;
}
.menu-summary::-webkit-details-marker { display: none; }
.menu[open] > .menu-summary,
.menu-summary:hover { color: var(--text); background: rgba(255,255,255,.04); border-color: var(--line); }
.menu-panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 200px;
  background: #1a2734; border: 1px solid var(--line); border-radius: 10px;
  padding: .4rem; box-shadow: 0 16px 40px rgba(0,0,0,.4); z-index: var(--z-menu);
  display: flex; flex-direction: column; gap: .1rem;
}
.menu-panel a, .menu-panel button.linkish {
  display: block; padding: .55rem .7rem; border-radius: 8px; color: var(--text); text-align: start; width: 100%;
}
.menu-panel a:hover, .menu-panel button.linkish:hover { background: rgba(42,171,238,.12); }
.menu-panel hr { border: 0; border-top: 1px solid var(--line); margin: .35rem 0; }
.menu-compact .menu-panel { inset-inline-end: 0; inset-inline-start: auto; }
.menu-compact summary.icon-btn { list-style: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; min-width: 2.25rem; min-height: 2.25rem;
  border-radius: 8px; border: 1px solid var(--line);
  background: #0f1822; color: var(--text); cursor: pointer; font: inherit; text-decoration: none;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* —— Page shells —— */
.wrap {
  max-width: 820px; margin: 0 auto;
  padding: var(--space-5) max(var(--space-4), env(safe-area-inset-left, 0px)) 3rem max(var(--space-4), env(safe-area-inset-right, 0px));
}
.app-main {
  max-width: none; margin: 0; padding: 0;
  height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top, 0px));
  overflow: hidden;
}
/* Telegram-like: no global topbar on chat shell */
.app-chat .site-topbar { display: none; }
.app-chat .app-main {
  height: 100dvh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
}
.app-chat .flash {
  margin: 0; position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + .5rem);
  left: 50%; transform: translateX(-50%);
  z-index: var(--z-flash); max-width: 420px; width: calc(100% - 2rem);
}
.auth-card, .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.auth-card { max-width: 420px; margin: 4rem auto; }
.auth-alt {
  display: flex; flex-direction: column; gap: .55rem;
  margin-top: 1rem;
}
.auth-alt .btn, .auth-card .btn.ghost {
  display: inline-flex; justify-content: center; align-items: center;
  width: 100%; text-decoration: none;
}
.claim-wrap { word-break: break-all; }
.claim-url { font-size: .8rem; }
h1 { margin-top: 0; font-size: 1.6rem; }
.muted { color: var(--muted); }
.error { color: #ff8a80; }
.tiny { font-size: .8rem; margin: .25rem 0 0; }
.flash { list-style: none; padding: 0; }
.flash li { padding: .65rem .85rem; border-radius: 8px; margin-bottom: .5rem; background: #1e2c3a; }
.flash .success { border-inline-start: 3px solid var(--ok); }
.flash .info { border-inline-start: 3px solid var(--accent); }
.flash .error, .flash .warning { border-inline-start: 3px solid var(--warn); }
input[type=text], input[type=email], input[type=password], input[type=file], input[type=search], select, textarea {
  width: 100%; padding: .7rem .8rem; margin: .35rem 0 .85rem;
  border-radius: 8px; border: 1px solid var(--line); background: #0f1822; color: var(--text);
  font-size: 1rem; /* avoid iOS zoom */
}
html[data-theme="light"] input[type=text],
html[data-theme="light"] input[type=email],
html[data-theme="light"] input[type=password],
html[data-theme="light"] input[type=file],
html[data-theme="light"] input[type=search],
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  background: #fff;
}
button, .btn {
  background: var(--accent); color: #041018; border: 0; border-radius: 8px;
  padding: .65rem 1rem; font-weight: 650; cursor: pointer;
}
button.danger { background: transparent; color: #ff8a80; border: 1px solid #5a3030; }
.btn { display: inline-block; text-decoration: none; }
.btn-secondary {
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.row input { flex: 1; min-width: 140px; margin-bottom: 0; }
.tiles { list-style: none; padding: 0; display: grid; gap: .65rem; }
.tiles li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .9rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  min-width: 0;
}
.tiles span { color: var(--muted); font-size: .85rem; }
.list { list-style: none; padding: 0; margin: 1rem 0 0; }
.list li {
  display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  padding: .85rem 0; border-bottom: 1px solid var(--line); min-width: 0;
}
.list small { display: block; color: var(--muted); }
.avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin-bottom: 1rem; }

/* —— Profile page (better-layout + baseline-ui + harden) —— */
.profile-page {
  max-width: 520px;
  margin: 0 auto;
  padding-block: var(--space-4) var(--space-5);
  min-width: 0;
}
.profile-page-head { margin-bottom: var(--space-4); }
.profile-page-head h1 {
  margin: var(--space-2) 0 var(--space-1);
  font-size: clamp(1.35rem, 2.5vw, 1.7rem);
  text-wrap: balance;
}
.profile-lede { margin: 0; text-wrap: pretty; }
.profile-back {
  display: inline-flex; align-items: center; gap: .35rem;
  color: var(--muted); font-size: .95rem; padding: .25rem 0;
  min-height: 2.25rem;
}
.profile-back:hover { color: var(--text); }
.profile-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: 0 16px 40px rgba(0,0,0,.22);
  min-width: 0;
}
.profile-hero {
  display: flex; align-items: center; gap: var(--space-4);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.profile-avatar-wrap {
  position: relative;
  width: 5.5rem; height: 5.5rem; min-width: 5.5rem; min-height: 5.5rem;
  flex-shrink: 0;
}
.profile-avatar {
  width: 100%; height: 100%;
  border-radius: 50%; overflow: hidden;
  background: #1e3344;
  display: inline-flex; align-items: center; justify-content: center;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-avatar-fallback {
  font-size: 1.85rem; font-weight: 700; color: var(--text); line-height: 1;
}
.profile-avatar-cam {
  position: absolute;
  inset-inline-end: -2px; bottom: -2px;
  width: 2rem; height: 2rem; min-width: 2rem; min-height: 2rem;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #041018;
  border: 2px solid var(--panel);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.profile-avatar-cam:hover { filter: brightness(1.08); }
.profile-avatar-cam:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.profile-photo-input {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important; border: 0 !important;
}
.visually-hidden {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important; border: 0 !important;
}
.profile-photo-hint { margin-top: .35rem; }
.profile-photo-error { margin-top: .35rem; }
.profile-hero-meta { min-width: 0; flex: 1; display: grid; gap: .2rem; }
.profile-hero-name {
  font-size: 1.2rem; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-hero-user {
  color: var(--accent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-hero-user.is-empty { color: var(--muted); font-weight: 400; }
.profile-hero-email {
  font-size: .9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-form { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.profile-fields { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.profile-form .field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.profile-form .field label {
  font-weight: 650; font-size: .92rem; color: var(--text);
}
.profile-form .field input,
.profile-form .field textarea {
  margin: 0; width: 100%; min-width: 0;
  overflow-wrap: anywhere;
}
.profile-form .field textarea { resize: vertical; min-height: 5.5rem; }
.field-hint {
  margin: 0; color: var(--muted); font-size: .8rem; text-wrap: pretty;
}
.field-prefix {
  display: flex; align-items: stretch; min-width: 0;
  border: 1px solid var(--line); border-radius: 8px; background: #0f1822;
  overflow: hidden;
}
html[data-theme="light"] .field-prefix { background: #fff; }
.field-prefix-mark {
  display: inline-flex; align-items: center; padding-inline: .75rem;
  color: var(--muted); background: rgba(255,255,255,.03);
  border-inline-end: 1px solid var(--line); flex-shrink: 0;
}
.field-prefix input {
  border: 0 !important; margin: 0 !important; background: transparent !important;
  border-radius: 0 !important; flex: 1; min-width: 0;
}
.profile-form-errors {
  padding: .65rem .85rem; border-radius: 8px;
  background: rgba(229,57,53,.12); border: 1px solid #5a3030; color: #ff8a80;
}
.profile-actions {
  display: flex; flex-wrap: wrap; gap: var(--space-3);
  padding-top: var(--space-1);
}
.profile-actions .btn,
.profile-actions .btn-secondary {
  min-height: 2.5rem; padding-inline: 1.1rem;
}
@media (max-width: 520px) {
  .profile-page { padding-inline: 0; }
  .profile-card { padding: var(--space-4); }
  .profile-hero { gap: var(--space-3); }
  .profile-avatar-wrap { width: 4.5rem; height: 4.5rem; min-width: 4.5rem; min-height: 4.5rem; }
  .profile-actions { flex-direction: column; }
  .profile-actions .btn,
  .profile-actions .btn-secondary { width: 100%; text-align: center; }
}

/* —— Two-pane chat frame —— */
.chat-frame {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100%;
  background: var(--pane);
}
.chat-sidebar {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--sidebar); border-inline-end: 1px solid var(--line);
}
/* Telegram sidebar chrome */
.tg-side-head {
  display: flex; align-items: center; gap: .55rem;
  padding: .65rem .75rem .45rem; flex-shrink: 0;
}
.burger-btn { border-radius: 50%; border-color: transparent; background: transparent; font-size: 1.15rem; }
.burger-btn:hover { background: rgba(255,255,255,.06); border-color: transparent; color: var(--text); }
html[data-theme="light"] .burger-btn:hover { background: rgba(15,23,42,.06); }

/* —— Desktop drawer (TG-1400…) —— */
.tg-drawer-root {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  pointer-events: none;
}
.tg-drawer-root.is-open { pointer-events: auto; }
.tg-drawer-backdrop {
  position: absolute; inset: 0; border: 0; padding: 0; margin: 0;
  background: rgba(0,0,0,.45); cursor: pointer;
  opacity: 0; transition: opacity .18s ease;
}
.tg-drawer-root.is-open .tg-drawer-backdrop { opacity: 1; }
.tg-drawer {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  width: min(300px, 88vw); max-width: 100%;
  background: #211b24; color: #f5f5f5;
  display: flex; flex-direction: column; gap: 0;
  padding: .85rem 0 1rem;
  box-shadow: 8px 0 32px rgba(0,0,0,.45);
  transform: translateX(-105%);
  transition: transform .18s ease;
  overflow-y: auto;
}
html[data-theme="light"] .tg-drawer {
  background: #f7f7f8; color: var(--text);
  box-shadow: 8px 0 32px rgba(15,23,42,.12);
}
.tg-drawer-root.is-open .tg-drawer { transform: translateX(0); }
.tg-drawer-accounts { padding: 0 .35rem .35rem; }
.tg-drawer-account-head {
  width: 100%; display: flex; align-items: center; gap: .75rem;
  padding: .55rem .85rem; border: 0; background: transparent; color: inherit;
  font: inherit; text-align: start; cursor: pointer; border-radius: 10px;
}
.tg-drawer-account-head:hover { background: rgba(255,255,255,.06); }
html[data-theme="light"] .tg-drawer-account-head:hover { background: rgba(15,23,42,.05); }
.tg-drawer-avatar {
  width: 2.65rem; height: 2.65rem; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2aabee, #8774e1);
  font-weight: 700; overflow: hidden; color: #fff;
}
.tg-drawer-avatar.sm { width: 2.1rem; height: 2.1rem; font-size: .85rem; }
.tg-drawer-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tg-drawer-account-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .1rem; }
.tg-drawer-account-name {
  font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tg-drawer-account-sub { font-size: .8rem; }
.tg-drawer-chevron {
  color: #a78bfa; transition: transform .15s ease; font-size: .85rem;
}
.tg-drawer-accounts[data-accounts-open="1"] .tg-drawer-chevron { transform: rotate(180deg); }
.tg-drawer-account-list { display: flex; flex-direction: column; gap: .15rem; padding: .15rem 0 .35rem; }
.tg-drawer-account-row {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  padding: .55rem .85rem; border-radius: 10px; color: inherit; text-decoration: none;
  border: 0; background: transparent; font: inherit; text-align: start; cursor: pointer;
}
.tg-drawer-account-row:hover { background: rgba(135,116,225,.12); }
.tg-drawer-account-row.is-current { background: rgba(255,255,255,.04); cursor: default; }
.tg-drawer-account-switch { margin: 0; }
.tg-drawer-unread {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; margin-top: .15rem;
  border-radius: 999px; background: #8774e1; color: #fff;
  font-size: .7rem; font-weight: 700; line-height: 1; align-self: flex-start;
}
.tg-drawer-add-account { color: #c4b5fd; }
.tg-drawer-add-account:hover { background: rgba(167,139,250,.12); }
.tg-drawer-check { color: #a78bfa; margin-inline-start: auto; }
.tg-drawer-icon.plus {
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(167,139,250,.2); color: #c4b5fd; font-weight: 700; font-size: 1.15rem;
}
.tg-drawer-item {
  display: flex; align-items: center; gap: .9rem;
  padding: .7rem 1.15rem; color: inherit; text-decoration: none;
  width: 100%; border: 0; background: transparent; font: inherit; text-align: start; cursor: pointer;
}
.tg-drawer-item:hover { background: rgba(255,255,255,.06); }
html[data-theme="light"] .tg-drawer-item:hover { background: rgba(15,23,42,.05); }

/* —— New Group modal (Telegram Desktop) —— */
.tg-modal-root {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  pointer-events: none;
}
.tg-modal-root[hidden] { display: none !important; }
.tg-modal-root.is-open { pointer-events: auto; }
.tg-modal-backdrop {
  position: absolute; inset: 0; border: 0; padding: 0; margin: 0;
  background: rgba(0,0,0,.55); cursor: pointer;
  opacity: 0; transition: opacity .16s ease;
}
.tg-modal-root.is-open .tg-modal-backdrop { opacity: 1; }
.tg-modal {
  position: relative;
  width: min(420px, 100%);
  background: #211b24;
  color: #f5f5f5;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  padding: 1.15rem 1.15rem .65rem;
  transform: translateY(8px) scale(.98);
  opacity: 0;
  transition: transform .16s ease, opacity .16s ease;
}
html[data-theme="light"] .tg-modal {
  background: #f7f7f8; color: var(--text);
  box-shadow: 0 24px 64px rgba(15,23,42,.18);
}
.tg-modal-root.is-open .tg-modal { transform: none; opacity: 1; }
.tg-modal-top {
  display: flex; align-items: center; gap: 1rem; min-width: 0;
  padding: .25rem .15rem .35rem;
}
.tg-modal-avatar-wrap {
  position: relative; width: 4rem; height: 4rem; flex-shrink: 0;
}
.tg-modal-avatar {
  position: relative;
  width: 100%; height: 100%; border-radius: 50%;
  background: #64b5ef;
  color: #fff;
  display: grid; place-items: center;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.tg-modal-cam-icon {
  display: block;
  width: 1.55rem; height: 1.55rem;
  margin: 0; flex-shrink: 0;
  opacity: .98;
  pointer-events: none;
}
.tg-modal-avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.tg-modal-avatar.has-photo .tg-modal-cam-icon { display: none; }
.tg-modal-avatar-hit {
  position: absolute; inset: 0; border-radius: 50%; cursor: pointer;
  z-index: 1;
}
.tg-modal-avatar-wrap:hover .tg-modal-avatar {
  filter: brightness(1.06);
}
.tg-modal-photo-input {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0,0,0,0) !important;
  border: 0 !important;
}
.tg-modal-fields { flex: 1; min-width: 0; }
.tg-modal-float {
  display: block; position: relative;
  border-bottom: 1px solid #8774e1;
  padding-top: 1rem;
}
.tg-modal-float-label {
  position: absolute; inset-inline-start: 0; top: 0;
  font-size: .8rem; color: #a78bfa; font-weight: 500;
}
.tg-modal-float input {
  width: 100%; margin: 0; border: 0 !important; background: transparent !important;
  padding: .35rem 0 .55rem !important; border-radius: 0 !important;
  color: inherit; font-size: 1.05rem; outline: none;
}
.tg-modal-float input:focus { box-shadow: none; }
.tg-modal-more {
  border: 0; background: transparent; color: var(--muted);
  font-size: 1.25rem; cursor: pointer; padding: .25rem; align-self: flex-start;
}
.tg-modal-actions {
  display: flex; justify-content: flex-end; gap: .15rem;
  padding: .85rem 0 .25rem;
}
.tg-modal-textbtn {
  border: 0; background: transparent; color: #c4b5fd;
  font: inherit; font-weight: 650; cursor: pointer;
  padding: .55rem .85rem; border-radius: 8px;
}
.tg-modal-textbtn:hover { background: rgba(167,139,250,.12); }
.tg-modal-textbtn.is-primary { color: #d4c4ff; }
.tg-modal-heading {
  margin: 0; font-size: 1.05rem; font-weight: 600; line-height: 1.25;
}
.tg-modal-sub { margin: .2rem 0 0; font-size: .85rem; }
.tg-modal-profile { width: min(420px, calc(100vw - 1.5rem)); }
.tg-modal-profile-fields {
  display: flex; flex-direction: column; gap: .85rem;
  padding: 0 1.1rem 1rem;
}
.tg-modal-float-prefix .tg-modal-username-row {
  display: flex; align-items: baseline; width: 100%; gap: .15rem;
}
.tg-modal-float-prefix .tg-modal-username-row:not(.tg-channel-link-row)::before {
  content: "@";
  flex-shrink: 0;
  font-size: 1.05rem; font-weight: 600; line-height: 1.35;
  color: var(--muted); pointer-events: none;
}
.tg-modal-float-prefix input {
  flex: 1; min-width: 0; width: auto !important; margin: 0 !important;
  padding: .35rem 0 .55rem !important;
}
.tg-modal-float-area {
  border-bottom: 0 !important;
}
.tg-modal-float-area textarea {
  width: 100%; display: block;
  margin: 0 !important; min-height: 3rem; max-height: 7rem; resize: none;
  background: transparent !important;
  border: 0 !important; border-radius: 0 !important;
  color: inherit; font: inherit; font-size: 1.05rem; line-height: 1.35;
  padding: .35rem 0 .45rem !important;
  outline: none !important;
  -webkit-appearance: none; appearance: none;
  overflow-y: auto;
  box-shadow: 0 1px 0 #8774e1 !important;
}
.tg-modal-float-area textarea:focus {
  outline: none !important;
  box-shadow: 0 1px 0 #8774e1 !important;
  border: 0 !important;
}

.tg-modal-channel { width: min(420px, calc(100vw - 1.5rem)); }
.tg-modal-avatar-static {
  display: flex; align-items: center; justify-content: center;
  background: rgba(42,171,238,.18);
}
.tg-modal-channel-ico { font-size: 1.45rem; line-height: 1; }
.tg-modal-hint {
  margin: .35rem 0 0; font-size: .78rem; line-height: 1.3;
}
.tg-modal-check {
  display: flex; align-items: flex-start; gap: .65rem;
  margin-top: .15rem; cursor: pointer; font-size: .92rem; line-height: 1.35;
}
.tg-modal-check input {
  width: auto; margin: .2rem 0 0; flex-shrink: 0; accent-color: #8774e1;
}
.empty-actions { display: flex; flex-wrap: wrap; gap: .5rem; }


.tg-channel-step[hidden] { display: none !important; }
.tg-channel-privacy { display: flex; flex-direction: column; gap: .85rem; padding: .25rem 1.1rem 1rem; }
.tg-channel-radio {
  display: flex; align-items: flex-start; gap: .75rem;
  cursor: pointer; padding: .15rem 0;
}
.tg-channel-radio input { position: absolute; opacity: 0; pointer-events: none; }
.tg-channel-radio-mark {
  width: 1.15rem; height: 1.15rem; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); margin-top: .15rem; flex-shrink: 0;
  box-sizing: border-box;
}
.tg-channel-radio.is-selected .tg-channel-radio-mark {
  border-color: #8774e1;
  box-shadow: inset 0 0 0 3px #17212b, inset 0 0 0 7px #8774e1;
}
html[data-theme="light"] .tg-channel-radio.is-selected .tg-channel-radio-mark {
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #8774e1;
}
.tg-channel-radio-body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.tg-channel-radio-body strong { font-weight: 600; font-size: .98rem; }
.tg-channel-radio-body .muted { font-size: .82rem; line-height: 1.35; }
.tg-channel-link-row { display: flex; align-items: baseline; gap: 0; }
.tg-channel-link-prefix {
  flex-shrink: 0; color: var(--muted); font-size: 1.05rem; font-weight: 500;
  padding: .35rem 0 .55rem; line-height: 1.35;
}
.tg-channel-link-row input { flex: 1; min-width: 0; padding-inline-start: .15rem !important; }

/* —— Settings hub modal (TG-1411) —— */
.tg-modal-settings { width: min(420px, calc(100vw - 1.5rem)); padding-bottom: .5rem; }
.tg-settings-head { padding: .15rem .25rem .65rem; }
.tg-settings-profile {
  display: flex; align-items: center; gap: .85rem; width: 100%;
  border: 0; background: transparent; color: inherit; text-align: start;
  padding: .45rem .55rem; border-radius: 12px; cursor: pointer;
}
.tg-settings-profile:hover { background: rgba(255,255,255,.05); }
html[data-theme="light"] .tg-settings-profile:hover { background: rgba(15,23,42,.05); }
.tg-settings-avatar {
  width: 3.25rem; height: 3.25rem; border-radius: 50%; flex-shrink: 0;
  overflow: hidden; display: grid; place-items: center;
  background: rgba(42,171,238,.22);
}
.tg-settings-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tg-settings-avatar-letter {
  font-size: 1.25rem; font-weight: 650; color: #fff; line-height: 1;
}
.tg-settings-who { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.tg-settings-who strong { font-size: 1.05rem; font-weight: 650; }
.tg-settings-list { display: flex; flex-direction: column; padding: .15rem 0 .35rem; }
.tg-settings-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .72rem .85rem; border-radius: 10px;
  color: inherit; text-decoration: none; border: 0; background: transparent;
  width: 100%; text-align: start; cursor: pointer; font: inherit;
}
.tg-settings-row:hover { background: rgba(135,116,225,.14); }
.tg-settings-ico { width: 1.5rem; text-align: center; flex-shrink: 0; opacity: .92; }
.tg-settings-label { flex: 1; min-width: 0; font-size: .95rem; }
.tg-settings-chevron { color: var(--muted); font-size: 1.15rem; line-height: 1; }
.tg-settings-logout { margin: .15rem .15rem 0; }
.tg-settings-row.is-danger { color: #e35d6a; }
.tg-settings-row.is-danger:hover { background: rgba(227,93,106,.12); }

.tg-modal-section-head {
  display: flex; align-items: center; gap: .55rem;
  padding: .35rem .55rem .75rem;
}
.tg-modal-section-head .tg-modal-heading { margin: 0; font-size: 1.15rem; font-weight: 650; }
.tg-modal-back {
  width: 2rem; height: 2rem; border: 0; border-radius: 50%;
  background: transparent; color: #8774e1; font-size: 1.55rem; line-height: 1;
  cursor: pointer; display: grid; place-items: center; flex-shrink: 0;
}
.tg-modal-back:hover { background: rgba(135,116,225,.14); }
.tg-modal-hint-pad { padding: 0 1.1rem .65rem; margin: 0; font-size: .85rem; line-height: 1.35; }
.tg-modal-divider { height: 1px; background: rgba(255,255,255,.08); margin: .55rem 0 .85rem; }
html[data-theme="light"] .tg-modal-divider { background: rgba(15,23,42,.08); }
.tg-modal-textbtn.is-danger { color: #e35d6a; }
.ok-text { color: #4fae4e; }

.tg-privacy-list { display: flex; flex-direction: column; gap: .15rem; padding: 0 .35rem .5rem; }
.tg-privacy-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .65rem .75rem; border-radius: 10px; cursor: pointer;
}
.tg-privacy-row:hover { background: rgba(135,116,225,.1); }
.tg-privacy-label { font-size: .94rem; min-width: 0; }
.tg-privacy-select {
  max-width: 42%; min-width: 7.5rem;
  background: transparent; color: #8774e1; border: 0; font: inherit; font-size: .9rem;
  text-align: end; cursor: pointer; outline: none;
}
html[data-theme="light"] .tg-privacy-select { color: #6b5ce0; }
.tg-privacy-select option { color: #111; background: #fff; }

.tg-session-list { list-style: none; margin: 0; padding: .15rem .35rem .5rem; display: flex; flex-direction: column; gap: .25rem; }
.tg-session-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem .75rem; border-radius: 10px;
}
.tg-session-row:hover { background: rgba(255,255,255,.04); }
html[data-theme="light"] .tg-session-row:hover { background: rgba(15,23,42,.04); }
.tg-session-body { display: flex; flex-direction: column; gap: .12rem; min-width: 0; flex: 1; }
.tg-session-body strong { font-size: .95rem; }
.tg-session-body small { font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

body.modal-open { overflow: hidden; }
.tg-drawer-icon {
  width: 1.5rem; text-align: center; flex-shrink: 0; opacity: .92; font-size: 1.05rem;
}
.tg-drawer-sep {
  border: 0; border-top: 1px solid rgba(255,255,255,.08); margin: .35rem 0;
}
html[data-theme="light"] .tg-drawer-sep { border-top-color: var(--line); }
.tg-drawer-night { cursor: default; }
.tg-night-toggle {
  margin-inline-start: auto;
  width: 2.6rem; height: 1.35rem; border-radius: 999px; border: 0;
  background: #3f3a45; position: relative; cursor: pointer; flex-shrink: 0;
  padding: 0;
}
.tg-night-toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 1.05rem; height: 1.05rem; border-radius: 50%;
  background: #f5f5f5; transition: transform .15s ease, background .15s ease;
}
.tg-night-toggle.is-on { background: #8774e1; }
.tg-night-toggle.is-on::after { transform: translateX(1.2rem); background: #fff; }
body.drawer-open { overflow: hidden; }
.settings-logout { margin-top: 1.5rem; }
.btn.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--text);
}
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.tg-search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .35rem;
  background: #242f3d; border-radius: 999px; padding: .15rem .45rem .15rem .7rem;
  border: 1px solid transparent;
}
html[data-theme="light"] .tg-search { background: #f1f5f9; }
.tg-search:focus-within { border-color: var(--accent); background: #1c2733; }
html[data-theme="light"] .tg-search:focus-within { background: #e8eef5; }
.tg-search-icon { color: var(--muted); flex-shrink: 0; }
.tg-search input {
  margin: 0; border: 0; background: transparent; padding: .45rem .25rem;
  font-size: 1rem; flex: 1; min-width: 0; width: auto;
}
.tg-search-go {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 1.8rem; height: 1.8rem; border-radius: 50%; font: inherit;
}
.tg-search-go:hover { color: var(--accent); }
.tg-search-error { padding: 0 .85rem .35rem; margin: 0; }
.folder-tabs {
  display: flex; flex-wrap: nowrap; gap: .35rem;
  padding: 0 .75rem .45rem; overflow-x: auto; scrollbar-width: thin; flex-shrink: 0;
}
.folder-tabs a {
  padding: .28rem .6rem; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-size: .8rem; white-space: nowrap; flex-shrink: 0;
}
.folder-tabs a.active, .folder-tabs a:hover { background: rgba(42,171,238,.15); color: var(--text); }

.people-results {
  flex-shrink: 0; border-bottom: 1px solid var(--line);
  max-height: 40%; overflow-y: auto;
}
.people-label {
  padding: .45rem .85rem .2rem; color: var(--accent); font-size: .75rem;
  font-weight: 700; text-transform: uppercase;
}
.people-list { list-style: none; padding: 0; margin: 0; }
.people-list li a {
  display: flex; gap: .7rem; align-items: center; padding: .55rem .85rem; color: inherit;
}
.people-list li a:hover { background: rgba(42,171,238,.1); }
.people-meta { min-width: 0; flex: 1; }
.people-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people-sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dialog-list {
  list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; min-height: 0;
}
.dialog-list li { position: relative; }
.dialog-list li.is-active { background: #2b5278; }
.dialog-list li.pinned { background: rgba(255,255,255,.02); }
.dialog-list li.is-active.pinned { background: #2b5278; }
.dialog-list a { display: block; padding: .65rem .85rem; color: inherit; }
.dialog-list a:hover { background: rgba(42,171,238,.08); }
.dialog-list li.is-active a:hover { background: transparent; }
.dialog-row { display: flex; gap: .75rem; align-items: center; min-width: 0; }
.dialog-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.05rem; background: #243447;
}
.dialog-avatar.ch { background: #3d3420; }
.dialog-avatar.gr { background: #1e3344; }
.dialog-avatar.archive { background: #3a4a5c; font-size: 1.1rem; }
.dialog-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.dialog-top, .dialog-bottom {
  display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; min-width: 0;
}
.dialog-title {
  font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.dialog-time { font-size: .75rem; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.dialog-preview {
  font-size: .85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1;
}
.unread-badge {
  min-width: 1.35rem; height: 1.35rem; padding: 0 .4rem;
  border-radius: 999px; background: var(--accent); color: #041018;
  font-size: .75rem; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.dot-online {
  display: inline-block; width: .5rem; height: .5rem; border-radius: 50%;
  background: #4caf50; margin-inline-start: .3rem; vertical-align: middle;
}
.pin-mark { margin-inline-end: .2rem; }
.dialog-item.is-hidden-by-search { display: none; }
.archive-row .dialog-title { font-weight: 600; }

/* Harden empty states */
.empty-side {
  padding: var(--space-5) var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start;
}
.empty-side p { margin: 0; }
.empty-side .empty-actions { margin-top: var(--space-2); justify-content: flex-start; }

/* —— Thread pane —— */
.chat-pane {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--pane);
}
.empty-pane { align-items: center; justify-content: center; padding: var(--space-4); }
.empty-state {
  text-align: center; padding: var(--space-5); max-width: 360px;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
}
.empty-mark { font-size: 2.5rem; line-height: 1; }
.empty-state h2 { margin: 0; font-size: 1.4rem; }
.empty-state .muted { margin: 0; }
.empty-actions {
  display: flex; gap: var(--space-2); justify-content: center;
  margin-top: var(--space-3); flex-wrap: wrap;
}
.empty-hint-box {
  margin: auto; text-align: center; max-width: 320px;
  display: flex; flex-direction: column; gap: var(--space-2); align-items: center;
  padding: var(--space-4);
}
.empty-results {
  margin: var(--space-5) 0;
  padding: var(--space-5); text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}

.chat-head {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1rem; border-bottom: 1px solid var(--line);
  background: var(--panel); flex-shrink: 0;
}
.back-chats {
  display: none; width: 2.25rem; height: 2.25rem; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text); background: #0f1822; border: 1px solid var(--line);
  text-decoration: none; flex-shrink: 0;
}
.chat-head-main { flex: 1; min-width: 0; }
.chat-head h1 {
  margin: 0; font-size: 1.05rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.presence-line, .typing-line {
  color: var(--muted); font-size: .8rem; margin-top: .1rem; min-height: 1em;
}
.typing-line { color: var(--accent); font-style: italic; }
.head-menu { flex-shrink: 0; }

.action-bar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  padding: .55rem .85rem; margin: .55rem .85rem 0;
  background: #1a2734; border: 1px solid var(--line); border-radius: 8px; flex-shrink: 0;
}
.channel-dm-note, .channel-dm-form { margin: .5rem .85rem 0; }
.pin-bar {
  background: #13202c; border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .75rem; margin: .55rem .85rem 0; font-size: .9rem; flex-shrink: 0;
}
.pin-label { color: var(--accent); font-weight: 650; margin-bottom: .25rem; }
.pin-bar ul { list-style: none; padding: 0; margin: 0; }
.pin-bar li { padding: .15rem 0; }

.msg-stream {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: .85rem 1rem 1rem; display: flex; flex-direction: column; gap: .55rem;
  scroll-padding-block-end: 1rem;
}
.bubble {
  max-width: min(560px, 92%); padding: .65rem .8rem; border-radius: 12px;
  background: #182533; border: 1px solid var(--line); min-width: 0;
}
.bubble.mine { align-self: flex-end; background: #2b5278; }
.bubble.theirs { align-self: flex-start; }
.bubble.deleted { opacity: .7; }
.bubble .body { overflow-wrap: anywhere; word-break: break-word; }
.bubble .body code { background: rgba(0,0,0,.25); padding: .1rem .3rem; border-radius: 4px; }
.bubble .meta { color: var(--muted); font-size: .75rem; margin-top: .35rem; font-variant-numeric: tabular-nums; }
.bubble .actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .35rem; }
.reply-quote {
  border-inline-start: 3px solid var(--accent); padding: .25rem .5rem; margin-bottom: .4rem;
  color: #cfe8f7; font-size: .85rem; background: rgba(0,0,0,.15); border-radius: 0 6px 6px 0;
  overflow-wrap: anywhere;
}
.receipt { margin-inline-start: .35rem; color: #9fd6ff; }
.receipt[data-receipt="read"] { color: #7dfff0; }
.danger-text { color: #ff8a80 !important; }
.empty-hint { text-align: center; margin: auto; }

.composer {
  display: flex; flex-direction: column; align-items: stretch; gap: .35rem;
  border-top: 1px solid var(--line);
  padding: .65rem .85rem calc(.85rem + env(safe-area-inset-bottom, 0px));
  background: var(--panel); flex-shrink: 0;
}
.composer-locked { padding: .85rem 1rem; border-top: 1px solid var(--line); margin: 0; }
.composer-tools {
  display: flex; flex-wrap: nowrap; gap: .3rem; align-items: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: .15rem; margin-bottom: .15rem;
}
.composer-tools-sep {
  width: 1px; height: 1.4rem; background: var(--line); margin: 0 .25rem;
  flex-shrink: 0;
}
.tool-btn {
  background: #0f1822; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: .35rem .55rem; cursor: pointer; font: inherit;
  min-height: 2.25rem; flex-shrink: 0;
}
.composer-row { display: flex; gap: .5rem; align-items: end; width: 100%; min-width: 0; }
.composer-row textarea { flex: 1; min-width: 0; margin: 0; max-height: 140px; }
.composer-row button { flex-shrink: 0; }
.sticker-btn {
  background: #0f1822; border: 1px solid var(--line); border-radius: 8px;
  font-size: 1.2rem; cursor: pointer; padding: .2rem .35rem;
  min-width: 2.25rem; min-height: 2.25rem; flex-shrink: 0;
}

/* —— Media / groups / channels / P7 —— */
.att-grid { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .35rem; }
.att-photo img { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; object-fit: cover; }
.att-video { max-width: 280px; border-radius: 8px; background: #000; }
.att-video-note {
  width: 180px; height: 180px; border-radius: 50%; object-fit: cover;
  background: #000; border: 3px solid rgba(42,171,238,.5);
}
.att-voice { width: min(260px, 100%); }
.att-file {
  display: inline-block; padding: .45rem .65rem; background: rgba(0,0,0,.2);
  border-radius: 8px; color: #cfe8f7; overflow-wrap: anywhere;
}
.bubble.scheduled { outline: 1px dashed rgba(255,179,0,.5); }
.schedule-badge { color: var(--warn) !important; }
.group-tag, .channel-tag {
  display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase;
  color: #041018; border-radius: 4px;
  padding: .1rem .35rem; margin-inline-end: .35rem; vertical-align: middle;
}
.group-tag { background: #7dd3fc; }
.channel-tag { background: #fbbf24; }
.mention { color: #7dd3fc; font-weight: 650; }
.check { display: flex; gap: .5rem; align-items: center; margin: .5rem 0; }
.panel h2 { margin-top: 0; font-size: 1.05rem; }
.panel + .panel { margin-top: 1rem; }
.stats-strip, .stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: .75rem; margin-bottom: 1rem;
}
.stat-card, .stats-strip > div {
  background: #13202c; border: 1px solid var(--line); border-radius: 10px; padding: .85rem;
  min-width: 0;
}
.stat-n { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.comments-box { margin-top: .35rem; }
.comment-list { margin: .35rem 0; display: flex; flex-direction: column; gap: .25rem; }
.comment-item { font-size: .9rem; background: rgba(0,0,0,.15); padding: .35rem .5rem; border-radius: 6px; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: .35rem; margin-top: .35rem; min-width: 0; }
.comment-form input { margin: 0; flex: 1; min-width: 0; }
.views { color: var(--muted); }
.search-tabs { display: flex; gap: .75rem; margin: 1rem 0; flex-wrap: wrap; }
.search-tabs a.active { color: var(--text); font-weight: 700; border-bottom: 2px solid var(--accent); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.media-card {
  background: #13202c; border: 1px solid var(--line); border-radius: 8px; padding: .35rem;
  display: flex; flex-direction: column; gap: .25rem; color: inherit; min-height: 90px; min-width: 0;
}
.media-card img, .media-card video { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; }
/* Legacy inline action/react bars replaced by right-click menu */
.bubble > .actions,
.bubble > .react-bar { display: none !important; }
.react-summary-chips {
  display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .35rem;
}
.react-chip {
  display: inline-flex; align-items: center;
  padding: .1rem .4rem; border-radius: 999px;
  background: rgba(255,255,255,.08); border: 1px solid var(--line);
  font-size: .85rem; line-height: 1.3;
}
.bubble.is-selected {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Telegram-style message context menu */
.msg-ctx-menu {
  position: fixed; z-index: 80;
  display: flex; flex-direction: column; gap: .45rem;
  min-width: 210px; max-width: min(280px, calc(100vw - 16px));
  pointer-events: auto;
}
.msg-ctx-menu[hidden] { display: none !important; }
.msg-ctx-react {
  display: flex; align-items: center; gap: .15rem;
  padding: .35rem .4rem; border-radius: 999px;
  background: rgba(33, 27, 36, .92);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 10px 28px rgba(0,0,0,.45);
  backdrop-filter: blur(10px);
}
html[data-theme="light"] .msg-ctx-react {
  background: rgba(255,255,255,.96); border-color: var(--line);
}
.msg-ctx-emoji {
  border: 0; background: transparent; cursor: pointer;
  width: 2rem; height: 2rem; border-radius: 50%;
  font-size: 1.15rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.msg-ctx-emoji:hover { background: rgba(255,255,255,.08); transform: scale(1.12); }
.msg-ctx-list {
  display: flex; flex-direction: column; gap: .05rem;
  padding: .35rem; border-radius: 14px;
  background: rgba(33, 27, 36, .94);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
  backdrop-filter: blur(12px);
}
html[data-theme="light"] .msg-ctx-list {
  background: rgba(255,255,255,.97); border-color: var(--line);
}
.msg-ctx-item {
  display: flex; align-items: center; gap: .75rem;
  width: 100%; border: 0; background: transparent;
  color: inherit; font: inherit; text-align: start;
  padding: .65rem .75rem; border-radius: 10px; cursor: pointer;
}
.msg-ctx-item:hover { background: rgba(42,171,238,.14); }
.msg-ctx-item.is-danger { color: #ff8a80; }
.msg-ctx-ico { width: 1.25rem; text-align: center; opacity: .9; }

.react-bar { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .3rem; align-items: center; }
.react-btn {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: .05rem .25rem; cursor: pointer; font-size: 1rem;
  min-width: 2rem; min-height: 2rem;
}
.react-btn:hover { border-color: var(--line); background: rgba(255,255,255,.05); }
.react-summary { color: var(--muted); font-size: .85rem; margin-inline-start: .25rem; }
.qr-box { background: #fff; display: inline-block; padding: .75rem; border-radius: 8px; margin: 1rem 0; }
.claim-url { overflow-wrap: anywhere; font-size: .8rem; }

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

/* —— Responsive: hold two-pane until it breaks —— */
@media (max-width: 860px) {
  :root { --sidebar-w: 100%; }
  .chat-frame { grid-template-columns: minmax(0, 1fr); }
  .list-mode .chat-pane,
  .thread-mode .chat-sidebar { display: none; }
  .list-mode .chat-sidebar,
  .thread-mode .chat-pane { display: flex; }
  .back-chats { display: inline-flex; }
}
@media (max-width: 640px) {
  .topbar { padding-inline: max(.75rem, env(safe-area-inset-left, 0px)) max(.75rem, env(safe-area-inset-right, 0px)); }
  .topbar-primary a:nth-child(3) { display: none; }
  .bubble { max-width: 94%; }
  .empty-actions { flex-direction: column; width: 100%; }
  .empty-actions .btn { width: 100%; }
}
