/* V2 theme for the chat app (index.html only; the admin panel keeps style.css as is).
   Near-black ground, burgundy accent, Space Grotesk display over Inter body. */
:root, :root:not([data-x]) {
  --bg: #0A0A0D;
  --bg-2: #0A0A0D;
  --surface: #15151A;
  --surface-2: #222229;
  --line: #202027;
  --chat-bg: #0A0A0D;
  --chat-pattern: transparent;
  --text: #F2F2F4;
  --muted: #8D909B;
  --muted-2: #A3A6B0;
  --border: #24242B;
  --accent: #5E1229;
  --accent-2: #761A35;
  --on-accent: #FFFFFF;
  --in: #15151A;
  --out: #5E1229;
  --out-meta: #F2C6D3;
  --quote-bg: rgba(255,255,255,.06);
  --hover: #1B1B21;
  --danger: #FF6B6B;
  --shadow: none;
  --radius: 22px;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
body { background: var(--bg); }

/* accent-filled things get dark text */
.btn.primary, .send-btn, .badge, .tab.active, .presets button.on, .item.active,
.reaction.mine, .file-link .ic, .vo-box.open .vo-ic, .timer-badge { color: var(--on-accent); }
.btn.primary:hover { color: var(--on-accent); }
.tab.active { background: var(--accent); }
.dialog, .menu, .reaction-picker { background: var(--surface); border: 1px solid var(--border); }
.btn { background: var(--surface); border-color: var(--border); border-radius: 999px; }
input:not([type=checkbox]):not([type=file]), select, textarea { background: var(--surface); border-color: var(--border); border-radius: 14px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 28px; box-shadow: none; }
.auth-card h1, .dialog h3 { font-family: var(--display); letter-spacing: -0.01em; }
.logo { border-radius: 24px; color: var(--on-accent); }

/* avatars: rounded tiles */
.avatar { border-radius: 36%; font-family: var(--display); color: rgba(10,10,13,.82); }
.avatar.xl { border-radius: 40px; }
.avatar.online::after { border-color: var(--surface); bottom: -2px; inset-inline-end: -2px; }

/* ── chat list ── */
.sidebar { background: var(--bg); border-color: var(--line); }
.side-head { padding: 24px 22px 0; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.brand-mark svg { width: 16px; height: 16px; fill: none; }
.brand-name { font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.side-head .me { padding: 0; border-radius: 50%; }
.side-head .me:hover { background: none; }
.side-head .avatar { width: 44px; height: 44px; border-radius: 50%; box-shadow: 0 0 0 2px #26262E; }
.hero { padding: 28px 22px 0; }
.hello { margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.hero h1 { margin: 0; font-family: var(--display); font-size: 40px; line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; }
.search { margin: 22px 22px 0; }
.search svg { inset-inline-start: 18px; width: 18px; height: 18px; color: #7C7F8A; }
.search input:not([type=checkbox]):not([type=file]) { height: 52px; border-radius: 26px; padding-inline: 46px 56px; background: var(--surface); border-color: transparent; }
.search input::placeholder { color: #7C7F8A; opacity: 1; }
.at-chip { position: absolute; inset-inline-end: 8px; top: 50%; translate: 0 -50%; height: 36px; padding: 0 12px; border-radius: 18px; background: var(--surface-2); color: #B7B9C2; font-size: 13px; font-weight: 500; display: grid; place-items: center; pointer-events: none; }
.dialog .search { margin: 0 0 8px; }
.dialog .search input:not([type=checkbox]):not([type=file]) { padding-inline-end: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; padding: 30px 22px 12px; }
.section-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.section-head span { font-size: 13px; color: var(--muted); }
.search:has(input:not(:placeholder-shown)) ~ .section-head { display: none; }
.list { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 8px; }
#searchResults { padding-top: 16px; }
.list-label { padding: 4px 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.item { gap: 14px; padding: 14px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line); }
.item:hover { background: var(--hover); }
.item.active { background: var(--accent); border-color: var(--accent); }
.item.active .preview, .item.active .time { color: rgba(10,10,13,.7); }
.item.active .badge { background: var(--on-accent); color: var(--accent); }
.item .avatar { width: 56px; height: 56px; border-radius: 20px; font-size: 22px; }
.item .body { display: flex; flex-direction: column; gap: 6px; }
.item .name { font-size: 16px; }
.item .preview { color: var(--muted-2); }
.archived-toggle { color: var(--muted); border-radius: 18px; }
.empty-note { color: var(--muted); }
.bottom-nav { flex: none; margin: 8px 22px max(26px, env(safe-area-inset-bottom)); height: 68px; padding: 0 8px; gap: 6px; border-radius: 34px; background: #17171C; border: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.bottom-nav svg { width: 22px; height: 22px; fill: none; }
.bottom-nav > button, .bottom-nav > .menu-wrap > button { border: 0; display: grid; place-items: center; }
.bottom-nav .menu { min-width: 240px; }
.bottom-nav .menu button, .bottom-nav .menu a { white-space: nowrap; }
.nav-pill { height: 52px; padding: 0 18px; border-radius: 26px; background: var(--accent); color: var(--on-accent); display: flex !important; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.nav-pill svg { width: 20px; height: 20px; }
.nav-btn { width: 52px; height: 52px; border-radius: 50%; background: transparent; color: var(--muted-2); }
.nav-btn:hover { background: var(--hover); color: var(--text); }
.bottom-nav .menu.up { inset-inline-end: -8px; margin-bottom: 14px; }

/* ── conversation ── */
.chat { background: var(--chat-bg); background-image: none; }
.pill { background: var(--surface); color: var(--muted); border-radius: 999px; padding: 10px 18px; }
.chat-head { gap: 10px; padding: 20px 16px 8px; background: transparent; border: 0; }
.chat-head .icon-btn { width: 44px; height: 44px; flex: none; background: var(--surface); color: #C9CBD3; }
.chat-head .icon-btn:hover { background: var(--surface-2); }
.chat-head .icon-btn svg { width: 20px; height: 20px; }
.chat-head .peer { height: 56px; padding: 0 12px 0 6px; border-radius: 28px; background: var(--surface); gap: 10px; }
.chat-head .peer:hover { background: var(--hover); }
.chat-head .avatar { width: 44px; height: 44px; border-radius: 16px; font-size: 18px; }
.chat-title .name { font-size: 15px; font-weight: 600; }
.chat-head .status { font-size: 12px; color: var(--muted); }
.pinned-bar { background: var(--surface); border: 0; margin: 4px 16px 0; width: auto; border-radius: 18px; padding: 8px 12px; }
.messages { padding-top: 16px; padding-bottom: 16px; gap: 6px; }
.day { display: flex; align-items: center; gap: 12px; align-self: stretch; margin: 12px 0 8px; position: static; color: var(--muted); font-size: 12px; font-weight: 500; }
.day::before, .day::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.day span { background: none; color: inherit; padding: 0; font-size: 12px; }
.sys span { background: var(--surface); color: var(--muted); }
.bubble { padding: 10px 14px 7px; border-radius: 22px; box-shadow: none; }
.msg.in .bubble { background: var(--in); border: 1px solid var(--line); border-end-start-radius: 6px; }
.msg.out .bubble { background: var(--out); color: var(--on-accent); border-end-end-radius: 6px; font-weight: 500; }
.msg.out .bubble .text { color: var(--on-accent); }
.bubble.media { padding: 4px; }
.bubble img, .bubble video { border-radius: 18px; }
.msg.out .meta { color: rgba(255,255,255,.7); }
.msg.out .quote { background: rgba(255,255,255,.08); border-color: var(--on-accent); }
.msg.out .quote b, .msg.out .fwd { color: var(--on-accent); }
.reaction { background: rgba(255,255,255,.08); }
.msg.out .reaction { background: rgba(255,255,255,.1); }
.msg.out .reaction.mine { background: var(--on-accent); color: var(--accent); }
.msg.out .vo-box .vo-ic, .msg.out .file-link .ic { background: var(--on-accent); color: var(--accent); }
.msg .acts .icon-btn { background: var(--surface-2); color: var(--text); }

.bottom { padding-bottom: max(26px, env(safe-area-inset-bottom)); }
.composer { align-items: center; gap: 6px; padding: 6px; border-radius: 32px; background: var(--surface); border: 1px solid var(--surface-2); }
.composer .icon-btn { width: 48px; height: 48px; background: var(--surface-2); box-shadow: none; color: #C9CBD3; }
.composer textarea { background: transparent; box-shadow: none; border: 0; border-radius: 0; padding: 13px 8px; }
.composer textarea:focus { box-shadow: none; }
.composer.editing { box-shadow: 0 0 0 2px var(--accent); }
.composer.editing textarea { box-shadow: none; }
.composer .menu.up { inset-inline-end: auto; inset-inline-start: -6px; margin-bottom: 14px; }
.send-btn { width: 48px; height: 48px; box-shadow: none; }
.send-btn:hover { color: var(--on-accent); }
.reply-bar, .rec-bar { background: var(--surface); box-shadow: none; border: 1px solid var(--surface-2); }
.reply-bar { border-radius: 22px; margin-bottom: 6px; }
.reply-bar:not([hidden]) ~ .composer { margin-top: 0; }
.rec-bar { border-radius: 32px; padding: 6px 6px 6px 12px; }

@media (max-width: 760px) {
  .bottom { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}

/* ── profile: bottom sheet ── */
.dialog.sheet { margin: auto auto 0; width: min(480px, 100%); max-height: calc(100dvh - 40px); padding: 10px 20px 28px; border-radius: 32px 32px 0 0; background: #141418; border: 0; border-top: 1px solid var(--border); }
.dialog.sheet::backdrop { background: rgba(0,0,0,.62); }
/* scrolling the sheet: stays inside it (no bounce, no scrolling the chat behind it), the top bar with
   Close stays put, and the last row clears the phone's home bar */
.dialog.sheet { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.dialog.sheet .sheet-handle, .dialog.sheet .sheet-head { position: sticky; z-index: 3; background: #141418; }
.dialog.sheet .sheet-handle { top: 0; box-shadow: 0 -10px 0 #141418; }
.dialog.sheet .sheet-head { top: 5px; margin: 0 -20px; padding: 8px 20px; }
.dialog.sheet .photo-btn, .dialog.sheet .avatar { z-index: 1; }
html:has(dialog[open].sheet), html:has(dialog[open].sheet) body { overflow: hidden; overscroll-behavior: none; }
.sheet form { gap: 18px; }
.sheet-handle { justify-self: center; width: 40px; height: 5px; border-radius: 3px; background: #33333C; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sheet-btn { justify-self: end; height: 44px; padding: 0 18px; border: 0; border-radius: 22px; background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 600; cursor: pointer; }
.sheet .profile-photo { position: relative; justify-self: center; }
.sheet .avatar.xl { width: 96px; height: 96px; border-radius: 34px; font-size: 38px; background-color: #1B3B38; color: #CFFAF2; }
.photo-btn { position: absolute; right: -6px; bottom: -6px; width: 40px; height: 40px; padding: 0; border: 3px solid #141418; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; cursor: pointer; }
.photo-btn svg { width: 17px; height: 17px; }
.field-card { border-radius: 22px; background: var(--hover); border: 1px solid var(--border); overflow: hidden; }
.field { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field-value { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.field-value.muted { font-size: 15px; font-weight: 400; color: var(--muted-2); }
.field-sep { height: 1px; margin-inline-start: 16px; background: #26262E; }
.privacy { display: flex; flex-direction: column; gap: 8px; }
.privacy[hidden] { display: none; }
.group-label { padding: 0 4px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sheet .toggle-row { padding: 12px 12px 12px 16px; border-radius: 22px; background: var(--hover); border: 1px solid var(--border); gap: 14px; }
.toggle-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 15px; font-weight: 500; }
.toggle-text small { font-size: 12px; font-weight: 400; line-height: 1.4; color: var(--muted); }
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 48px !important; height: 28px; margin: 8px 2px; padding: 0; border-radius: 14px; background: #33333C; position: relative; cursor: pointer; transition: background .2s; }
input.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted-2); transition: transform .2s, background .2s; }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(20px); background: var(--on-accent); }
input.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── love letters ── */
.sidebar.love-mode > .hero, .sidebar.love-mode > .search, .sidebar.love-mode > .section-head, .sidebar.love-mode > .list { display: none !important; }
.love-view { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px 8px; display: flex; flex-direction: column; gap: 10px; }
.love-view[hidden] { display: none; }
.love-view .love-list { max-height: none; overflow: visible; gap: 8px; }
.love-top { display: flex; justify-content: flex-end; }
.lock-chip { height: 32px; padding: 0 12px; border-radius: 16px; background: var(--surface); color: var(--muted-2); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.lock-chip svg { width: 13px; height: 13px; }
.love-hero { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.love-mark { width: 44px; height: 44px; border-radius: 16px; background: #FF9EC4; color: #2A0A18; display: grid; place-items: center; }
.love-mark svg { width: 22px; height: 22px; }
.love-hero h2 { margin: 0; font-family: var(--display); font-size: 40px; line-height: 1; font-weight: 700; letter-spacing: -0.03em; }
.love-sub { margin: 0 0 8px; font-size: 15px; line-height: 1.5; color: var(--muted-2); }
.love-view .love-row { padding: 12px; border-radius: 22px; background: var(--surface); border-color: var(--line); }
.love-view .love-row.unopened { border-color: #FF9EC4; background: #1E151A; }
.love-row.unopened .love-to { font-weight: 700; }
.love-new { flex: none; height: 24px; padding: 0 10px; border-radius: 12px; background: #FF9EC4; color: #2A0A18; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
/* tabs: whichever is current gets the filled pill */
.nav-pill:not([aria-current]) { background: transparent; color: var(--muted-2); }
.nav-pill:not([aria-current]):hover { background: var(--hover); color: var(--text); }
#navLove { position: relative; }
#navLove[aria-current] { background: #FF9EC4; color: #2A0A18; }
.nav-dot { position: absolute; top: 4px; inset-inline-end: 2px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; background: #FF9EC4; color: #2A0A18; font-size: 11px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px #17171C; }
.nav-dot[hidden] { display: none; }
#navLove[aria-current] .nav-dot { display: none; }
.love-empty { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 40px 0 32px; text-align: center; }
.love-empty p { margin: 8px 0 0; font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.envelope { position: relative; width: 148px; height: 112px; box-sizing: border-box; border-radius: 22px; background: var(--surface); border: 1px solid #26262E; }
.envelope svg { position: absolute; inset: -1px; width: 148px; height: 112px; }
.envelope span { position: absolute; left: 50%; top: 50%; margin: -4px 0 0 -22px; width: 44px; height: 44px; border-radius: 50%; background: #FF9EC4; color: #2A0A18; display: grid; place-items: center; box-shadow: 0 0 0 6px var(--bg); }
.envelope span svg { position: static; width: 20px; height: 20px; }

/* ── settings menu (gear) ── */
.bottom-nav .nav-pill { margin-inline-end: auto; }
#sideMenuBtn[aria-expanded="true"], .menu-wrap:has(> .menu:not([hidden])) > #sideMenuBtn { background: var(--surface-2); color: var(--text); }
.bottom-nav .settings-menu { inset-inline-end: -8px; width: 290px; max-width: calc(100vw - 32px); min-width: 0; padding: 8px; border-radius: 26px; background: #17171C; border: 1px solid var(--border); box-shadow: 0 18px 50px rgba(0,0,0,.55); display: flex; flex-direction: column; gap: 8px; }
.bottom-nav .settings-menu[hidden] { display: none; }
.settings-menu button, .settings-menu a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 10px; border-radius: 16px; font-size: 15px; font-weight: 500; color: var(--text); cursor: pointer; }
.settings-menu button:hover, .settings-menu a:hover { background: var(--hover); color: var(--text); }
.settings-menu button:focus-visible, .settings-menu a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.settings-menu a[hidden] { display: none; }
.menu-me { padding: 8px 10px !important; background: var(--surface) !important; border-radius: 20px !important; }
.menu-me .avatar { width: 44px; height: 44px; border-radius: 16px; font-size: 18px; }
.menu-me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.menu-me-text b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.menu-me-text small { font-size: 12px; font-weight: 400; color: var(--muted); }
.menu-group { display: flex; flex-direction: column; padding: 4px; border-radius: 20px; background: var(--surface); }
.mi-ic { width: 34px; height: 34px; flex: none; border-radius: 11px; background: var(--surface-2); color: #C9CBD3; display: grid; place-items: center; }
.mi-ic svg { width: 18px; height: 18px; }
.mi-label { flex: 1; min-width: 0; text-align: start; }
.mi-chev { width: 16px; height: 16px; flex: none; color: #5C5F69; }
[dir="rtl"] .mi-chev { transform: scaleX(-1); }
.menu-out { justify-content: center; color: var(--danger) !important; font-weight: 600 !important; }
.menu-out svg { width: 18px; height: 18px; }
.menu-out:hover { background: rgba(255,107,107,.1) !important; }

/* ── notifications page ── */
#notifyBtn[data-tone="ok"] small { color: var(--accent); }
#notifyBtn[data-tone="warn"] small { color: #FFB86B; }
#notifyBtn[data-tone="bad"] small { color: var(--danger); }
#sideMenuBtn[aria-current] { background: var(--surface-2); color: var(--text); }
.notify-view { gap: 14px; }
.notify-mark { background: var(--accent); color: var(--on-accent); }
.nf-status { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); }
.nf-dot { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px rgba(141,144,155,.15); }
.nf-status[data-tone="ok"] .nf-dot { background: var(--accent); box-shadow: 0 0 0 5px rgba(94,18,41,.35); }
.nf-status[data-tone="warn"] .nf-dot { background: #FFB86B; box-shadow: 0 0 0 5px rgba(255,184,107,.15); }
.nf-status[data-tone="bad"] .nf-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(255,107,107,.15); }
.nf-status-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nf-status-text b { font-family: var(--display); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.nf-status-text small { font-size: 13px; color: var(--muted-2); }
.nf-group { padding: 0; }
.nf-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 14px 8px 16px; font-size: 15px; font-weight: 500; cursor: pointer; }
.nf-row .mi-label small { display: block; margin-top: 3px; font-size: 12px; font-weight: 400; color: var(--muted); }
.notify-view .group-label { margin-top: 6px; }
.nf-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.nf-chips button { height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; }
.nf-chips button:hover:not(:disabled) { background: var(--hover); }
.nf-chips button[aria-pressed="true"] { background: #FFB86B; border-color: #FFB86B; color: #0A0A0D; }
.nf-chips button:disabled, .nf-test:disabled { opacity: .4; cursor: not-allowed; }
.nf-resume { height: 52px; border: 0; border-radius: 26px; background: var(--accent); color: var(--on-accent); font-size: 15px; font-weight: 600; cursor: pointer; }
.nf-resume[hidden] { display: none; }
.nf-test { height: 48px; margin-top: 4px; border: 1px solid var(--border); border-radius: 24px; background: transparent; color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; }
.nf-test:hover:not(:disabled) { background: var(--hover); }
.nf-help { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted-2); }
.nf-help:empty { display: none; }

/* header with the call buttons: keep the name readable */
.chat-head .peer { flex: 1 1 0; min-width: 0; }
.chat-head .chat-title { flex: 1; min-width: 0; overflow: hidden; }
.chat-head .status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
  .chat-head { gap: 6px; padding-inline: 10px; }
  .chat-head .icon-btn { width: 38px; height: 38px; }
  .chat-head .icon-btn svg { width: 18px; height: 18px; }
  .chat-head .peer { padding-inline-end: 8px; }
  #timerBtn { display: none; } /* still in the ⋮ menu: "Auto-delete messages" */
}

/* swipe right: the reply icon shows on the left side */
.msg.swipe-right .swipe-icon { right: auto; left: -42px; }

/* tap menu on a message: reactions row + actions list */
.msg-menu-layer { position: fixed; z-index: 160; display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: calc(100vw - 16px); animation: menuIn .14s ease-out; }
@keyframes menuIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.msg-menu-rx { display: flex; gap: 2px; padding: 6px 8px; border-radius: 26px; background: var(--surface, var(--bg)); border: 1px solid var(--border); box-shadow: 0 8px 28px rgba(0,0,0,.35); overflow-x: auto; scrollbar-width: none; }
.msg-menu-rx button { border: 0; background: none; font-size: 24px; line-height: 1; padding: 5px; border-radius: 50%; cursor: pointer; transition: transform .1s; flex: none; }
.msg-menu-rx button:hover, .msg-menu-rx button:active { transform: scale(1.22); }
.msg-menu-rx button.mine { background: var(--hover); }
.msg-menu-list { min-width: 210px; align-self: flex-start; display: flex; flex-direction: column; padding: 6px 0; border-radius: 14px; background: var(--surface, var(--bg)); border: 1px solid var(--border); box-shadow: 0 8px 28px rgba(0,0,0,.35); }
.msg-menu-list button { display: flex; align-items: center; gap: 18px; border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; padding: 11px 20px; text-align: start; cursor: pointer; }
.msg-menu-list button:hover, .msg-menu-list button:active { background: var(--hover); }
.msg-menu-list button svg { width: 22px; height: 22px; fill: currentColor; opacity: .85; flex: none; }
.msg-menu-list button.danger { color: var(--danger); }
.msg.menu-open .bubble { filter: brightness(1.12); }
@media (hover: none) { .msg .acts { display: none; } }

/* double-tap heart */
.bubble { position: relative; }
.heart-pop { position: absolute; left: 50%; top: 50%; font-size: 42px; pointer-events: none; transform: translate(-50%, -50%) scale(.2); animation: heartPop .8s ease-out forwards; z-index: 3; }
@keyframes heartPop { 30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; } 60% { transform: translate(-50%, -50%) scale(1); } 100% { transform: translate(-50%, -90%) scale(1); opacity: 0; } }

/* ── small menus & popups: one modern style (matches the message tap menu) ── */
.menu.pop-menu { padding: 6px 0; border-radius: 16px; min-width: 240px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 12px 36px rgba(0,0,0,.4); transform-origin: top right; animation: popIn .14s ease-out; }
.menu.pop-menu.up { transform-origin: bottom left; }
@keyframes popIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.menu.pop-menu > button { display: flex; align-items: center; gap: 16px; border-radius: 0; padding: 11px 18px; font-size: 15px; color: var(--text); white-space: nowrap; }
.menu.pop-menu > button:hover, .menu.pop-menu > button:active { background: var(--hover); }
.menu.pop-menu > button > svg { width: 21px; height: 21px; flex: none; opacity: .85; }
.menu.pop-menu > button.danger { color: var(--danger); }
.menu.pop-menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }
/* attach menu: coloured round icons */
.attach-menu { min-width: 220px; }
.attach-menu .ai { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; }
.attach-menu .ai svg { width: 19px; height: 19px; }
.attach-menu .ai-photo { background: linear-gradient(135deg, #5b8cff, #3a5bdc); }
.attach-menu .ai-once { background: linear-gradient(135deg, #b06bff, #7b3fe0); }
.attach-menu .ai-file { background: linear-gradient(135deg, #ffb547, #f07b1e); }
.attach-menu > button { gap: 14px; padding: 8px 16px; }
/* old hover reaction picker: same pill as the tap menu */
.reaction-picker { border-radius: 26px; padding: 6px 8px; box-shadow: 0 8px 28px rgba(0,0,0,.35); animation: popIn .14s ease-out; }
.reaction-picker button { font-size: 24px; padding: 5px; }
/* dialogs: softer, rounder, blurred backdrop */
.dialog:not(.sheet) { border-radius: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: popIn .16s ease-out; }
.dialog::backdrop { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
/* timed messages: just a small clock, no countdown */
.meta .exp { opacity: .8; }
.pop-menu svg { fill: none !important; }
.pop-menu svg text { fill: currentColor !important; }
.chat-head, .bottom { position: relative; z-index: 40; }

/* ── Telegram-style profile ── */
.prof-hero { text-align: center; margin: -4px 0 14px; }
.prof-name { font-size: 22px; font-weight: 700; word-break: break-word; }
.prof-status { font-size: 14px; color: var(--muted); margin-top: 2px; }
.prof-status.on { color: var(--accent); }
.profile.peer .field-sep, .profile.peer .field:has(#profSub) { display: none; }
.prof-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.prof-actions button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border: 0; border-radius: 16px;
  background: var(--surface-2, var(--hover)); color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.prof-actions button:active { transform: scale(.96); }
.prof-actions svg { width: 22px; height: 22px; }
.shared-list { margin-top: 14px; display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; background: var(--surface-2, var(--surface)); }
.shared-list button { display: flex; align-items: center; gap: 18px; padding: 13px 18px; border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; text-align: start; cursor: pointer; }
.shared-list button + button:not([hidden]) { border-top: 1px solid var(--border); }
.shared-list button:hover { background: var(--hover); }
.shared-list button svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.shared-list .sl-empty { padding: 14px 18px; font-size: 14px; }
/* shared media sheet */
.shared-sheet .shared-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 4px -4px 12px; padding: 0 4px; }
.shared-tabs button { flex: none; border: 0; border-radius: 999px; padding: 8px 14px; background: var(--surface-2, var(--surface)); color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.shared-tabs button.on { background: var(--accent); color: var(--on-accent, #000); }
.shared-body { max-height: 60dvh; overflow-y: auto; }
.shared-body.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; border-radius: 14px; }
.shared-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.shared-row:last-child { border-bottom: 0; }
.sr-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent); color: var(--on-accent, #000); font-weight: 700; font-size: 18px; text-decoration: none; }
.sr-ic svg { width: 22px; height: 22px; fill: currentColor; }
.sr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sr-body b, .sr-body a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.sr-body a { color: var(--accent); text-decoration: none; }
.sr-body small { color: var(--muted); font-size: 12px; }
.sr-body audio { width: 100%; height: 36px; }
.sr-jump svg { width: 18px; height: 18px; }
.dialog.profile form, .shared-sheet form { width: 100%; grid-template-columns: minmax(0, 1fr); }
.prof-actions svg, .shared-list svg { fill: none !important; }

/* ── emoji & sticker panel ── */
#emojiBtn svg { width: 24px; height: 24px; fill: none; }
#emojiBtn.on { color: var(--accent); }
.emoji-panel { margin: 0 0 8px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); overflow: hidden;
  display: flex; flex-direction: column; height: min(340px, 42dvh); animation: popIn .14s ease-out; }
.emoji-tabs { display: flex; gap: 6px; padding: 8px 10px 4px; flex: none; }
.emoji-tabs button { border: 0; border-radius: 999px; padding: 7px 14px; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.emoji-tabs button.on { background: var(--surface-2, var(--hover)); color: var(--text); }
.emoji-tab-body { flex: 1; min-height: 0; overflow-y: auto; }
.emoji-tab-body[hidden] { display: none; }
emoji-picker { width: 100%; height: 100%; --background: transparent; --border-color: transparent; --border-size: 0;
  --input-border-color: var(--border); --input-font-color: var(--text); --input-placeholder-color: var(--muted);
  --indicator-color: var(--accent); --button-hover-background: var(--hover); --button-active-background: var(--surface-2, var(--hover));
  --outline-color: var(--accent); --category-font-color: var(--muted); --emoji-size: 1.6rem; --num-columns: 8; }
@media (max-width: 420px) { emoji-picker { --num-columns: 7; --emoji-size: 1.5rem; } }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; padding: 6px 10px 12px; }
.sticker-grid button { aspect-ratio: 1; border: 0; background: none; border-radius: 14px; padding: 6px; cursor: pointer; display: grid; place-items: center; }
.sticker-grid button:hover, .sticker-grid button:active { background: var(--hover); }
.sticker-grid .sticker-el { width: 100%; height: 100%; object-fit: contain; }
/* sticker messages: no bubble */
.bubble.sticker { background: none !important; box-shadow: none; padding: 0; min-width: 0; }
.bubble.sticker .sticker-el { width: 160px; height: 160px; object-fit: contain; display: block; }
.bubble.sticker .meta { display: inline-flex; margin-top: 2px; padding: 1px 8px; border-radius: 10px; background: rgba(0,0,0,.45); color: #fff !important; float: right; }
.bubble.sticker .meta * { color: #fff !important; }
.sticker-el.broken { display: grid; place-items: center; font-size: 48px; }
/* love letter card */
.love-card { display: flex; align-items: center; gap: 12px; padding: 6px 4px 4px; text-decoration: none; color: inherit; }
.lc-env { font-size: 38px; line-height: 1; animation: lcBeat 1.6s ease-in-out infinite; }
@keyframes lcBeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.15); } 30% { transform: scale(1); } 45% { transform: scale(1.1); } }
.lc-text { display: flex; flex-direction: column; gap: 2px; }
.lc-text b { font-size: 15px; }
.lc-text small { opacity: .75; font-size: 12.5px; }
.bubble.love { min-width: 220px; }
/* clickable links in messages */
.msg .text a.msg-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.msg.in .text a.msg-link { color: var(--accent); }
.sticker-el { background: none !important; border-radius: 0 !important; box-shadow: none !important; }

/* panel sits under the text box, in the keyboard's place */
.emoji-panel { margin: 8px 0 0; height: min(300px, 40dvh); }
.bottom:has(.emoji-panel:not([hidden])) { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#emojiBtn .ic-kbd { display: none; }
#emojiBtn.on .ic-smile { display: none; }
#emojiBtn.on .ic-kbd { display: block; }
@media (hover: none), (pointer: coarse) {
  .emoji-panel { border-radius: 22px 22px 18px 18px; }
}
/* phones: the panel is as tall as the keyboard (measured; ~ a typical keyboard until then) and sits flush at the bottom */
@media (hover: none), (pointer: coarse) {
  .emoji-panel { height: var(--kb-h, min(270px, 36dvh)); margin: 8px -12px 0; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .bottom:has(.emoji-panel:not([hidden])) { padding-bottom: 0; }
  .emoji-panel .emoji-tab-body { padding-bottom: env(safe-area-inset-bottom); }
}
/* emoji panel: tighter header, search behind a 🔍 button on the right */
.emoji-tabs { padding: 6px 8px 2px; align-items: center; }
.emoji-tabs button { padding: 6px 12px; }
.emoji-tabs .emoji-search-btn { margin-inline-start: auto; width: 36px; height: 36px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.emoji-tabs .emoji-search-btn[hidden] { display: none; }
.emoji-tabs .emoji-search-btn svg { width: 19px; height: 19px; fill: none; }
.emoji-tabs .emoji-search-btn.on { background: var(--surface-2, var(--hover)); color: var(--accent); }
.sticker-grid { padding-top: 4px; }
.emoji-tabs .emoji-del-btn + .emoji-search-btn { margin-inline-start: 0; }
.emoji-tabs .emoji-del-btn svg { width: 21px; height: 21px; }

/* panel: bigger default, resizable from the top bar, a second delete button bottom-right */
.emoji-panel { position: relative; height: var(--kb-h, min(340px, 45dvh)); }
@media (hover: none), (pointer: coarse) { .emoji-panel { height: var(--kb-h, min(340px, 45dvh)); } }
.emoji-panel.resizing { user-select: none; }
.panel-grip { flex: none; height: 16px; display: grid; place-items: center; cursor: ns-resize; touch-action: none; }
.panel-grip span { width: 38px; height: 4px; border-radius: 4px; background: var(--border); }
.panel-grip:hover span, .emoji-panel.resizing .panel-grip span { background: var(--muted); }
.emoji-tabs { padding-top: 0; }
.emoji-del-float { position: absolute; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 3; width: 50px; height: 50px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2, var(--surface)); color: var(--text); display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.4); cursor: pointer; }
.emoji-del-float:active { transform: scale(.92); }
.emoji-del-float[hidden] { display: none; }
.emoji-del-float svg { width: 22px; height: 22px; fill: none; }

/* connection status pill (Connecting… / Waiting for network…) */
#connBar {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 50%; transform: translateX(-50%);
  z-index: 9999; padding: 6px 14px; border-radius: 999px; font-size: 13px; pointer-events: none;
  background: rgba(20, 24, 30, .88); color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
#connBar[hidden] { display: none; }

/* ── photos, Telegram-style: right-sized box, blurred preview, fade-in, upload ring ── */
.bubble .photo { position: relative; max-width: 100%; border-radius: 18px; overflow: hidden; background: #1B1B22 center / cover no-repeat; }
.bubble .photo::before { content: ''; position: absolute; inset: -12px; background: inherit; filter: blur(14px); transform: scale(1.1); }
.bubble .photo img { position: relative; display: block; width: 100%; height: 100%; max-height: none; object-fit: cover; border-radius: 0; background: none; opacity: 0; transition: opacity .25s ease; }
.bubble .photo.loaded img { opacity: 1; }
.bubble .photo.free { width: auto; }
.bubble .photo.free img { width: auto; height: auto; max-width: min(320px, 100%); max-height: 420px; }
.bubble .photo.failed::after { content: '⚠'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; color: #fff; }
.bubble .photo:not(.loaded):not(.failed)::after { content: ''; position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; margin: -18px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: photoSpin .8s linear infinite; }
@keyframes photoSpin { to { transform: rotate(360deg); } }
.msg.pending .bubble.media { opacity: 1; }
.photo.sending img { filter: brightness(.7); }
.photo .ring { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; transform: rotate(-90deg); }
.photo .ring circle { fill: rgba(0,0,0,.45); stroke: none; }
.photo .ring .fg { fill: none; stroke: #fff; stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 4 100; transition: stroke-dasharray .2s; }

/* ── "can't be saved" photos: no long-press save menu, no selecting, no dragging ── */
.photo.nosave img, .lightbox.nosave img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
.photo.nosave-badge::after, .photo.nosave-badge.loaded::after { content: ''; position: absolute; top: 8px; inset-inline-end: 8px; left: auto; width: 26px; height: 26px; margin: 0; border: 0; border-radius: 50%; animation: none;
  background: rgba(0,0,0,.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='9' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E") center / 14px no-repeat; }
.ai-nosave { background: #3A2E5C; color: #CDB8FF; }

/* Telegram alerts (Alerts page) */
.tg-box { margin-top: 18px; }
.tg-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.tg-head { display: flex; align-items: center; gap: 12px; }
.tg-ic { width: 40px; height: 40px; border-radius: 50%; background: #229ED9; color: #fff; display: grid; place-items: center; flex: none; }
.tg-ic svg { width: 21px; height: 21px; margin-inline-start: -2px; }
.tg-code { font: 700 30px/1.2 var(--display); letter-spacing: 6px; text-align: center; padding: 10px; border-radius: 14px; background: var(--surface-2); user-select: all; }
.tg-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tg-open, .tg-unlink { height: 42px; padding: 0 18px; border-radius: 21px; display: inline-flex; align-items: center; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; }
.tg-open { background: var(--accent); color: var(--on-accent); border: 0; }
.tg-unlink { background: transparent; color: var(--danger); border: 1px solid var(--border); }
