/* ========== Токены тем ========== */
:root, [data-theme="default"] {
  --bg: #f1f2f7; --surface: #ffffff; --surface-2: #f6f7fb; --text: #12141c; --muted: #6a7080; --line: #e3e6ee;
  --accent: #5b6cff; --accent-2: #22b5f0; --accent-ink: #fff;
  --header-bg: linear-gradient(135deg, #6d5dfc, #3d7bf0); --header-ink: #fff;
  --me-bg: linear-gradient(135deg, #6d5dfc, #4a78f5); --me-ink: #fff;
  --them-bg: #fff; --them-ink: #12141c; --them-line: #e3e6ee;
  --danger: #e5484d; --ok: #2fb86b;
  --radius: 14px; --bubble-r: 18px; --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --glass: var(--surface); --shadow: 0 8px 30px rgba(20, 24, 50, .14);
  --glow: none; --title-tr: none; --title-ls: 0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  [data-theme="default"] {
    --bg: #0d0e13; --surface: #171923; --surface-2: #1d2030; --text: #eef0f6; --muted: #8a90a3; --line: #272b3a;
    --header-bg: #171923; --them-bg: #212435; --them-ink: #eef0f6; --them-line: #2a2e42;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* Новогодняя */
[data-theme="newyear"] {
  --bg: #0a1d42; --surface: rgba(255,255,255,.08); --surface-2: rgba(255,255,255,.12); --text: #f7f8fc; --muted: #a9bad8; --line: rgba(255,255,255,.16);
  --accent: #ff4b5c; --accent-2: #3ddc84; --accent-ink: #fff;
  --header-bg: linear-gradient(90deg, #a60f26, #e63946 50%, #a60f26); --header-ink: #fff;
  --me-bg: linear-gradient(135deg, #e63946, #b3122b); --me-ink: #fff;
  --them-bg: rgba(255,255,255,.13); --them-ink: #f7f8fc; --them-line: rgba(255,255,255,.18);
  --danger: #ff8a8a; --ok: #3ddc84;
  --radius: 16px; --bubble-r: 20px;
  --glass: rgba(10, 29, 66, .72); --shadow: 0 10px 34px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
/* Киберпанк */
[data-theme="cyberpunk"] {
  --bg: #0a0414; --surface: #150a26; --surface-2: #1d1034; --text: #e9fbff; --muted: #9a86c4; --line: #3a1f63;
  --accent: #ff2a6d; --accent-2: #05d9e8; --accent-ink: #fff;
  --header-bg: linear-gradient(90deg, #12061f, #240b3d); --header-ink: #05d9e8;
  --me-bg: linear-gradient(135deg, #ff2a6d, #b5179e); --me-ink: #fff;
  --them-bg: #1a0e30; --them-ink: #e9fbff; --them-line: #05d9e8;
  --danger: #ff5d73; --ok: #05ffa1;
  --radius: 4px; --bubble-r: 4px; --font: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --glass: rgba(21, 10, 38, .86); --shadow: 0 0 24px rgba(255, 42, 109, .25);
  --glow: 0 0 8px rgba(5, 217, 232, .7); --title-tr: uppercase; --title-ls: .12em;
  color-scheme: dark;
}
/* Айти / Matrix */
[data-theme="matrix"] {
  --bg: #000; --surface: #021006; --surface-2: #04200c; --text: #2bff6d; --muted: #12a63f; --line: #0c5a22;
  --accent: #00ff41; --accent-2: #00ff41; --accent-ink: #001a07;
  --header-bg: #000; --header-ink: #00ff41;
  --me-bg: rgba(0, 255, 65, .14); --me-ink: #8dffb0;
  --them-bg: rgba(0, 12, 3, .92); --them-ink: #2bff6d; --them-line: #0c5a22;
  --danger: #ff4d4d; --ok: #00ff41;
  --radius: 2px; --bubble-r: 2px; --font: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --glass: rgba(0, 10, 2, .88); --shadow: 0 0 22px rgba(0, 255, 65, .18);
  --glow: 0 0 6px rgba(0, 255, 65, .65); --title-tr: lowercase; --title-ls: .04em;
  color-scheme: dark;
}

/* ========== База ========== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: var(--bg); }
body { font: 16px/1.4 var(--font); color: var(--text); -webkit-text-size-adjust: 100%; touch-action: manipulation; -webkit-touch-callout: none; }
[data-theme="newyear"] body { background: linear-gradient(180deg, #071633 0%, #0e2a5e 60%, #143a74 100%) fixed; }
[data-theme="cyberpunk"] body { background: radial-gradient(1200px 600px at 80% -10%, rgba(255,42,109,.22), transparent 60%), radial-gradient(900px 500px at 0% 110%, rgba(5,217,232,.18), transparent 60%), #0a0414 fixed; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
h1, h2, h3 { margin: 0; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.fill { fill: currentColor; stroke: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; display: none; }
[data-fx="on"] #fx { display: block; }
#app { position: relative; z-index: 1; height: var(--app-h, 100dvh); display: flex; flex-direction: column; overflow: hidden; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* Киберпанк: линии развёртки; Matrix: курсор */
[data-theme="cyberpunk"] body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 1px, transparent 1px 3px); mix-blend-mode: overlay; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ========== Кнопки и поля ========== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; transition: transform .08s, opacity .15s; text-transform: var(--title-tr); letter-spacing: var(--title-ls); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--me-bg); color: var(--me-ink); border-color: transparent; box-shadow: var(--glow); }
[data-theme="matrix"] .btn.primary { border: 1px solid var(--accent); }
[data-theme="cyberpunk"] .btn.primary { border: 1px solid var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; transition: background .15s, transform .08s; }
.iconbtn:active { transform: scale(.9); background: rgba(127,127,127,.2); }
.input { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); outline: none; font-size: 16px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; color: var(--muted); }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0 10px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.45; }

/* ========== Вход ========== */
.auth { flex: 1; overflow-y: auto; display: flex; padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom)); }
.auth-card { width: min(100%, 400px); margin: auto; background: var(--glass); border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px); padding: 26px 22px; box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.logo { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 12px; display: block; box-shadow: var(--shadow); }
.auth h1 { text-align: center; font-size: 26px; margin-bottom: 4px; text-transform: var(--title-tr); letter-spacing: var(--title-ls); text-shadow: var(--glow); }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 22px; font-size: 15px; }
.auth .authalt { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.auth .authalt button { color: var(--accent-2); font-weight: 600; }

/* ========== Каркас ========== */
.shell { flex: 1; display: grid; grid-template-columns: 1fr; min-height: 0; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--glass); }
.shell[data-view="list"] .pane-main, .shell[data-view="main"] .pane-list { display: none; }
@media (min-width: 900px) {
  .shell { grid-template-columns: 380px 1fr; }
  .shell[data-view="list"] .pane-main, .shell[data-view="main"] .pane-list { display: flex; }
  .pane-list { border-right: 1px solid var(--line); }
  .pane-main .back { display: none; }
}
.placeholder { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 30px; }
.placeholder .big { font-size: 56px; margin-bottom: 8px; }

.topbar { display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; min-height: calc(56px + env(safe-area-inset-top));
  background: var(--header-bg); color: var(--header-ink); position: relative; flex: none; border-bottom: 1px solid transparent; }
[data-theme="cyberpunk"] .topbar { border-bottom: 1px solid var(--accent-2); box-shadow: 0 2px 18px rgba(5,217,232,.25); }
[data-theme="matrix"] .topbar { border-bottom: 1px solid var(--line); }
[data-theme="matrix"] .topbar h1::before { content: "> "; }
.topbar h1 { font-size: 18px; font-weight: 700; text-transform: var(--title-tr); letter-spacing: var(--title-ls); text-shadow: var(--glow); }
.topbar .sub { font-size: 12px; opacity: .8; }
.topbar .grow { padding: 0 4px; }
/* гирлянда */
[data-theme="newyear"] .topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -9px; height: 10px; pointer-events: none; z-index: 2;
  background:
    radial-gradient(circle at 12px 4px, #ffd166 0 3px, transparent 4px) 0 0 / 48px 10px,
    radial-gradient(circle at 24px 5px, #3ddc84 0 3px, transparent 4px) 0 0 / 48px 10px,
    radial-gradient(circle at 36px 4px, #5ac8fa 0 3px, transparent 4px) 0 0 / 48px 10px,
    radial-gradient(circle at 0px 5px, #ff7a8a 0 3px, transparent 4px) 0 0 / 48px 10px;
  animation: twinkle 1.6s ease-in-out infinite alternate; filter: drop-shadow(0 0 4px rgba(255,255,255,.6)); }
@keyframes twinkle { from { opacity: .55; } to { opacity: 1; } }

.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.tabbar { display: flex; flex: none; padding-bottom: env(safe-area-inset-bottom); background: var(--glass); border-top: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.tab { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; color: var(--muted); position: relative; text-transform: var(--title-tr); }
.tab.active { color: var(--accent); text-shadow: var(--glow); }
[data-theme="default"] .tab.active { color: var(--accent); }
.tab .badge { position: absolute; top: 4px; left: calc(50% + 6px); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.fab { position: absolute; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--me-bg); color: var(--me-ink); display: grid; place-items: center; box-shadow: var(--shadow); z-index: 5; }
.pane-list { position: relative; }

/* ========== Списки ========== */
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); transition: background .12s; }
.row:active, .row.active { background: var(--surface-2); }
.row .name { font-weight: 600; }
.row .preview { color: var(--muted); font-size: 14px; }
.row .meta { display: grid; justify-items: end; gap: 4px; font-size: 12px; color: var(--muted); }
.section-title { padding: 16px 14px 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.searchbox { padding: 10px 12px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; position: relative; overflow: hidden; user-select: none; }
[data-theme="cyberpunk"] .avatar, [data-theme="matrix"] .avatar { border-radius: 6px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 96px; height: 96px; font-size: 36px; }
.avatar.xl { width: 140px; height: 140px; font-size: 52px; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }

/* ========== Чат ========== */
.chat { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 10px 6px; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.day { align-self: center; margin: 10px 0 6px; padding: 3px 12px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.msg.me { justify-content: flex-end; }
.msg .avatar { margin-bottom: 2px; }
.bubble { max-width: min(78%, 520px); padding: 8px 12px 6px; border-radius: var(--bubble-r); position: relative; word-break: break-word; overflow-wrap: anywhere; user-select: none; -webkit-user-select: none; }
.me .bubble { background: var(--me-bg); color: var(--me-ink); border-bottom-right-radius: 6px; }
.them .bubble { background: var(--them-bg); color: var(--them-ink); border: 1px solid var(--them-line); border-bottom-left-radius: 6px; }
[data-theme="cyberpunk"] .me .bubble { clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%); border-radius: 0; }
[data-theme="cyberpunk"] .them .bubble { clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px); border-radius: 0; }
[data-theme="matrix"] .bubble { border: 1px solid var(--line); }
[data-theme="matrix"] .me .bubble { border-color: var(--accent); box-shadow: var(--glow); }
.bubble .who { font-size: 12px; font-weight: 700; margin-bottom: 2px; color: var(--accent-2); }
.bubble .text { white-space: pre-wrap; }
.bubble .time { display: block; text-align: right; font-size: 11px; opacity: .65; margin-top: 2px; }
.bubble.bad { opacity: .6; font-style: italic; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 190px; padding: 2px 0; }
.voice .play { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; flex: none; }
.them .voice .play { background: var(--accent); color: var(--accent-ink); }
.voice .track { flex: 1; height: 5px; border-radius: 3px; background: rgba(127,127,127,.35); overflow: hidden; }
.voice .fill { height: 100%; width: 0; background: currentColor; transition: width .1s linear; }
.voice .dur { font-size: 12px; opacity: .8; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.loadmore { align-self: center; color: var(--accent-2); font-size: 14px; padding: 6px 12px; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--glass); border-top: 1px solid var(--line); flex: none; }
.composer textarea { flex: 1; resize: none; max-height: 140px; min-height: 44px; padding: 11px 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface-2); outline: none; line-height: 1.3; }
[data-theme="cyberpunk"] .composer textarea, [data-theme="matrix"] .composer textarea { border-radius: var(--radius); }
.composer textarea:focus { border-color: var(--accent); }
.composer .round { width: 44px; height: 44px; border-radius: 50%; background: var(--me-bg); color: var(--me-ink); display: grid; place-items: center; flex: none; box-shadow: var(--glow); }
[data-theme="matrix"] .composer .round { border: 1px solid var(--accent); border-radius: 4px; }
.recbar { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 8px; min-height: 44px; }
.recdot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }
.recbar .t { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ========== Окна ========== */
.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: min(100%, 520px); max-height: 88%; overflow-y: auto; background: var(--surface); background-image: linear-gradient(var(--glass), var(--glass)); border: 1px solid var(--line); border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); animation: rise .2s ease-out; box-shadow: var(--shadow); }
[data-theme="cyberpunk"] .sheet, [data-theme="matrix"] .sheet { border-radius: 6px 6px 0 0; }
@media (min-width: 700px) { .sheet-back { align-items: center; } .sheet { border-radius: 22px; max-height: 80%; } }
.sheet h2 { font-size: 20px; margin-bottom: 12px; text-transform: var(--title-tr); letter-spacing: var(--title-ls); text-shadow: var(--glow); }
.sheet .actions { display: grid; gap: 10px; margin-top: 16px; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 14px 6px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); }
.menu-item.danger { color: var(--danger); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.kv { display: grid; gap: 4px; margin: 12px 0; }
.kv b { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .06em; word-spacing: .3em; line-height: 1.7; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.chip.pick { cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.profile-head { display: grid; justify-items: center; gap: 8px; padding: 22px 16px 10px; text-align: center; }
.profile-head h2 { font-size: 22px; }
.card { margin: 10px 12px; padding: 14px; border-radius: var(--radius); background: var(--surface); background-image: linear-gradient(var(--glass), var(--glass)); border: 1px solid var(--line); }
.card h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-card { border-radius: var(--radius); border: 2px solid var(--line); overflow: hidden; text-align: left; transition: border-color .15s, transform .1s; }
.theme-card:active { transform: scale(.97); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.theme-card .sw { height: 56px; display: flex; align-items: flex-end; gap: 6px; padding: 8px; }
.theme-card .sw i { display: block; height: 16px; border-radius: 8px; }
.theme-card .nm { padding: 8px 10px; font-size: 14px; font-weight: 600; background: var(--surface-2); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.banner { margin: 10px 12px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--accent); font-size: 14px; }
.banner b { color: var(--accent-2); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); font-size: 12px; border: 1px solid var(--line); }
.tiny-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

/* ========== Звонок ========== */
.call { position: fixed; inset: 0; z-index: 60; background: #05060a; color: #fff; display: flex; flex-direction: column; font-family: var(--font); }
.call video.remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05060a; }
.call video.local { position: absolute; right: 14px; top: calc(14px + env(safe-area-inset-top)); width: 104px; height: 148px; object-fit: cover; border-radius: 14px; border: 2px solid rgba(255,255,255,.3); background: #111; z-index: 3; }
.call video.local.back { transform: none; }
.call .info { position: relative; z-index: 2; display: grid; justify-items: center; gap: 10px; padding-top: calc(70px + env(safe-area-inset-top)); text-shadow: 0 1px 12px rgba(0,0,0,.6); }
.call.videoing .info { padding-top: calc(16px + env(safe-area-inset-top)); justify-items: start; padding-left: 16px; }
.call .info .nm { font-size: 26px; font-weight: 700; }
.call .info .st { opacity: .8; font-variant-numeric: tabular-nums; }
.call .pulse { animation: ring 1.6s infinite; border-radius: 50%; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.35); } 100% { box-shadow: 0 0 0 36px rgba(255,255,255,0); } }
.call .controls { position: relative; z-index: 3; margin-top: auto; display: flex; justify-content: center; gap: 18px; padding: 20px 20px calc(34px + env(safe-area-inset-bottom)); }
.call .ctl { width: 62px; height: 62px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: #fff; }
.call .ctl.off { background: #fff; color: #111; }
.call .ctl.end { background: #e5484d; transform: rotate(0); }
.call .ctl.end svg { transform: rotate(135deg); }
.call .ctl.ok { background: #2fb86b; }
.call-audio-only .info { padding-top: calc(110px + env(safe-area-inset-bottom)); }

/* ========== Уведомления ========== */
#toasts { position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top)); z-index: 90; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: min(92%, 420px); padding: 11px 16px; border-radius: 14px; background: var(--surface); background-image: linear-gradient(var(--glass), var(--glass)); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 14px; animation: rise .2s ease-out; }
.toast.err { border-color: var(--danger); }

/* Снег идёт поверх интерфейса, «дождь» Matrix лежит под ним */
[data-theme="newyear"] #fx { z-index: 30; }
[data-theme="matrix"] .pane { background: rgba(0, 6, 1, .62); }
[data-theme="matrix"] .tabbar, [data-theme="matrix"] .composer { background: rgba(0, 8, 2, .88); }

.tabbody { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tabbody > .scroll { flex: 1; }
.tab .badge.hidden { display: none; }

/* ========== Фото и видео в чате ========== */
.bubble.media { padding: 4px 4px 4px; }
.bubble.media .time { padding: 0 6px 2px; }
.mediabox { position: relative; width: min(260px, 62vw); max-width: 100%; max-height: 60vh; border-radius: calc(var(--bubble-r) - 4px); overflow: hidden; background: rgba(127,127,127,.25); display: grid; place-items: center; cursor: pointer; }
[data-theme="cyberpunk"] .mediabox, [data-theme="matrix"] .mediabox { border-radius: 2px; }
.mediabox img, .mediabox video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mediabox .overlay-btn { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.28); color: #fff; font-size: 13px; text-align: center; padding: 6px; }
.mediabox .overlay-btn svg { width: 46px; height: 46px; }
.mediabox .badge-dur { position: absolute; left: 8px; bottom: 6px; font-size: 12px; color: #fff; background: rgba(0,0,0,.55); padding: 1px 7px; border-radius: 8px; }
.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.94); display: grid; place-items: center; animation: fade .15s; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.viewer .x { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; color: #fff; background: rgba(255,255,255,.18); }
.sending { padding: 6px 14px; font-size: 13px; color: var(--muted); background: var(--glass); border-top: 1px solid var(--line); flex: none; }

/* ========== Лента ========== */
.post { background: var(--surface); background-image: linear-gradient(var(--glass), var(--glass)); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 12px; padding: 12px 12px 6px; }
.phead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pbody { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 10px; }
.pgrid { display: grid; gap: 4px; margin-bottom: 8px; border-radius: calc(var(--radius) - 4px); overflow: hidden; }
.pgrid.n2, .pgrid.n4 { grid-template-columns: 1fr 1fr; }
.pgrid.n3 { grid-template-columns: 1fr 1fr; }
.pgrid.n3 .pmedia:first-child { grid-column: 1 / 3; }
.pmedia { position: relative; width: 100%; background: rgba(127,127,127,.2); display: grid; place-items: center; overflow: hidden; cursor: pointer; max-height: 70vh; }
.pmedia img, .pmedia video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pmedia .overlay-btn { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.25); color: #fff; }
.pmedia .overlay-btn svg { width: 52px; height: 52px; }
.pmedia .badge-dur { position: absolute; left: 8px; bottom: 6px; font-size: 12px; color: #fff; background: rgba(0,0,0,.55); padding: 1px 7px; border-radius: 8px; }
.pacts { display: flex; gap: 6px; padding: 2px 0 4px; }
.act { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 19px; color: var(--muted); transition: background .12s, color .12s, transform .08s; }
.act:active { transform: scale(.94); background: var(--surface-2); }
.act.on { color: #ff4d6d; }
.act span { font-size: 14px; min-width: 8px; }
.comments { padding-bottom: 12px; }
.comment { display: flex; gap: 10px; padding: 8px 14px; align-items: flex-start; }
.cbody { white-space: pre-wrap; overflow-wrap: anywhere; }
.postchip { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 210px; text-align: left; padding: 4px; }
.pc-thumb { width: 54px; height: 54px; border-radius: 10px; background: rgba(127,127,127,.25); overflow: hidden; display: grid; place-items: center; flex: none; }
.pc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pc-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.me .postchip .hint { color: inherit; opacity: .8; }

/* ========== Стикеры ========== */
.stickerpanel { flex: none; height: 260px; display: flex; flex-direction: column; background: var(--glass); border-top: 1px solid var(--line); }
.stabs { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.stab { padding: 6px 14px; border-radius: 16px; font-size: 14px; color: var(--muted); }
.stab.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.sgrid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; padding: 10px; align-content: start; -webkit-overflow-scrolling: touch; }
.stile { position: relative; aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; transition: transform .08s; }
.stile:active { transform: scale(.92); }
.stile img, .stile video { width: 100%; height: 100%; object-fit: contain; }
.stile.add { flex-direction: column; gap: 2px; color: var(--accent-2); border: 2px dashed var(--line); background: transparent; font-size: 11px; align-content: center; }
.stile .sdel { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; display: grid; place-items: center; }
.stile .sdel svg { width: 14px; height: 14px; }
.bubble.sticker { background: transparent !important; border: 0 !important; box-shadow: none; clip-path: none !important; padding: 0; }
.bubble.sticker .time { padding: 0 4px; color: var(--muted); }
.stickerimg { display: block; width: min(170px, 46vw); max-height: 170px; object-fit: contain; }
video.stickerimg { border-radius: 12px; }
.bubble.gifb { padding: 3px; }
.gifmedia { display: block; width: min(240px, 60vw); max-height: 300px; border-radius: calc(var(--bubble-r) - 3px); object-fit: cover; }

/* ========== Серверы и голосовые каналы ========== */
.chsec { display: flex; align-items: center; }
.chrow { display: flex; align-items: center; margin: 1px 8px; border-radius: 10px; }
.chrow.active { background: var(--surface-2); }
.chmain { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 9px 10px; text-align: left; color: var(--muted); }
.chrow.active .chmain, .chmain:active { color: var(--text); }
.chmain svg { width: 18px; height: 18px; }
.chusers { margin: 0 8px 4px 36px; display: grid; gap: 2px; }
.chuser { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); padding: 2px 0; }
.vstage { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); grid-auto-rows: minmax(140px, 1fr); gap: 8px; padding: 10px; align-content: start; }
.vstage.single { grid-template-columns: 1fr; }
.vtile { position: relative; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; min-height: 140px; }
.vtile.vid { background: #000; cursor: pointer; }
.vtile.vid video { width: 100%; height: 100%; object-fit: contain; display: block; }
.vtile.big { position: fixed; inset: 0; z-index: 55; border-radius: 0; }
.vtile .vname { position: absolute; left: 8px; bottom: 6px; max-width: calc(100% - 16px); padding: 2px 8px; font-size: 13px; background: rgba(0,0,0,.55); color: #fff; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vtile .vname small { opacity: .8; }
.vcontrols { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; padding: 12px 12px calc(14px + env(safe-area-inset-bottom)); background: var(--glass); border-top: 1px solid var(--line); }
.vcontrols .ctl { width: 54px; height: 54px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; border: 1px solid var(--line); transition: transform .08s; }
.vcontrols .ctl:active { transform: scale(.92); }
.vcontrols .ctl.off { background: var(--text); color: var(--bg); }
.vcontrols .ctl.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.vcontrols .ctl.end { background: #e5484d; color: #fff; border-color: transparent; }
.vcontrols .ctl.end svg { transform: rotate(135deg); }
.vcbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: color-mix(in srgb, var(--ok) 22%, var(--surface)); border-top: 1px solid var(--line); flex: none; }
.vcbar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); animation: pulse 1.4s infinite; flex: none; }
.vcbar .info { flex: 1; min-width: 0; text-align: left; }
.pane-list .back-always { display: grid; }
.tab { font-size: 10.5px; }
.tab svg { width: 21px; height: 21px; }

/* ========== Сторис ========== */
.tray { display: flex; gap: 12px; padding: 12px 12px 10px; overflow-x: auto; border-bottom: 1px solid var(--line); -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tray::-webkit-scrollbar { display: none; }
.story-item { position: relative; flex: none; width: 66px; text-align: center; }
.ring { display: block; width: 66px; height: 66px; padding: 3px; border-radius: 50%; background: var(--line); transition: transform .08s; }
.ring:active { transform: scale(.94); }
.ring.unseen { background: conic-gradient(from 200deg, var(--accent), var(--accent-2), #ff4d6d, var(--accent)); }
.ring.add { background: transparent; border: 2px dashed var(--line); padding: 2px; }
.ring .avatar { width: 100%; height: 100%; border: 3px solid var(--bg); }
.ring.add .avatar { opacity: .75; }
[data-theme="cyberpunk"] .ring, [data-theme="matrix"] .ring { border-radius: 10px; }
.plusbadge { position: absolute; right: 1px; top: 44px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; border: 2px solid var(--bg); }
.plusbadge svg { width: 14px; height: 14px; stroke-width: 3; }
.sname { font-size: 12px; margin-top: 4px; color: var(--muted); }
.storyview { position: fixed; inset: 0; z-index: 65; background: #000; color: #fff; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; font-family: var(--font); }
.sv-media { position: absolute; inset: 0; display: grid; place-items: center; }
.sv-media img, .sv-media video { width: 100%; height: 100%; object-fit: contain; }
.sv-zone { position: absolute; top: 90px; bottom: 80px; z-index: 2; }
.sv-zone.l { left: 0; width: 32%; }
.sv-zone.r { right: 0; width: 68%; }
.sv-top { position: relative; z-index: 3; padding: calc(10px + env(safe-area-inset-top)) 12px 24px; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.sv-bars { display: flex; gap: 4px; margin-bottom: 10px; }
.sv-bar { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.35); overflow: hidden; }
.sv-bar i { display: block; height: 100%; width: 0; background: #fff; }
.sv-head { display: flex; align-items: center; gap: 10px; }
.sv-head .iconbtn { color: #fff; }
.sv-caption { position: absolute; left: 16px; right: 16px; bottom: 92px; z-index: 3; text-align: center; font-size: 18px; text-shadow: 0 1px 8px rgba(0,0,0,.8); pointer-events: none; white-space: pre-wrap; }
.sv-foot { position: relative; z-index: 3; margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 24px 12px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.sv-reply { flex: 1; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid rgba(255,255,255,.5); background: rgba(0,0,0,.35); color: #fff; font-size: 16px; outline: none; }
.sv-reply::placeholder { color: rgba(255,255,255,.7); }
.sv-foot .iconbtn { color: #fff; }
.sv-views { margin: 0 auto; padding: 10px 18px; border-radius: 20px; background: rgba(255,255,255,.18); color: #fff; font-size: 15px; }

/* ========== Ответы, галочки, видеокружки, анимации ========== */
.quote { border-left: 3px solid var(--accent-2); padding: 3px 8px; margin: 0 0 4px; border-radius: 4px; background: rgba(127,127,127,.18); cursor: pointer; max-width: 100%; }
.me .quote { border-left-color: rgba(255,255,255,.85); background: rgba(255,255,255,.18); }
.rq-who { font-size: 12px; font-weight: 700; color: var(--accent-2); }
.me .quote .rq-who { color: #fff; }
.rq-text { font-size: 13px; opacity: .85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.replybar { flex: none; display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-top: 1px solid var(--line); background: var(--glass); border-left: 3px solid var(--accent); color: var(--accent-2); }
.replybar .rq-text { color: var(--text); }
.msg.armed .bubble { box-shadow: 0 0 0 2px var(--accent); }
.msg { transition: transform .18s ease; }
.bubble { touch-action: pan-y; }
.msg.flash .bubble { animation: flashbub 1.2s ease; }
@keyframes flashbub { 0%, 60% { box-shadow: 0 0 0 3px var(--accent), 0 0 18px var(--accent); } 100% { box-shadow: none; } }

.tick { display: inline-grid; vertical-align: -3px; margin-left: 4px; }
.tick svg { width: 15px; height: 15px; stroke-width: 2.4; }
.tick[data-st="sent"], .tick[data-st="delivered"] { opacity: .7; }
.tick[data-st="read"] { color: #5de0ff; opacity: 1; filter: drop-shadow(0 0 3px rgba(93,224,255,.7)); }
[data-theme="default"] .me .tick[data-st="read"] { color: #bfe9ff; }
.tick svg { animation: tickin .25s ease-out; }
@keyframes tickin { from { transform: scale(.4); opacity: 0; } }

.msg.fresh.me { animation: popRight .26s cubic-bezier(.2, .9, .3, 1.2); transform-origin: right bottom; }
.msg.fresh.them { animation: popLeft .26s cubic-bezier(.2, .9, .3, 1.2); transform-origin: left bottom; }
@keyframes popRight { from { opacity: 0; transform: translateX(16px) scale(.85); } }
@keyframes popLeft { from { opacity: 0; transform: translateX(-16px) scale(.85); } }
.msg.fresh .stickerimg, .msg.fresh .gifmedia { animation: bounceIn .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes bounceIn { from { transform: scale(.3) rotate(-8deg); opacity: 0; } }
.composer .round.sent { animation: rocket .45s ease; }
@keyframes rocket { 40% { transform: translate(6px, -8px) rotate(-12deg) scale(1.12); } 100% { transform: none; } }
.pane-main > .chat { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }
.badge { animation: bump .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump { from { transform: scale(.4); } }
/* списки перерисовываются часто, поэтому без анимации появления (иначе мерцают) */
.modebtn.hidden { display: none; }

/* видеокружок в чате */
.bubble.vnb { background: transparent !important; border: 0 !important; box-shadow: none; clip-path: none !important; padding: 0; }
.bubble.vnb .time { padding: 0 4px; color: var(--muted); }
.vnote { position: relative; width: min(220px, 58vw); aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: #111; cursor: pointer; box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.vnote img, .vnote video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vnote .overlay-btn { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.28); color: #fff; font-size: 13px; }
.vnote .overlay-btn svg { width: 44px; height: 44px; }
.vnote .badge-dur { position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; font-size: 12px; color: #fff; background: rgba(0,0,0,.55); padding: 1px 8px; border-radius: 8px; }
.vn-mute { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.vn-mute svg { width: 16px; height: 16px; }

/* запись кружка */
.vnrec { position: fixed; inset: 0; z-index: 66; background: rgba(0,0,0,.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: #fff; font-family: var(--font); animation: fade .15s; }
.vn-stage { position: relative; width: min(300px, 80vw); aspect-ratio: 1; }
.vn-circle { position: absolute; inset: 14px; border-radius: 50%; overflow: hidden; background: #000; }
.vn-video { width: 100%; height: 100%; object-fit: cover; }
.vn-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.vn-ring circle { stroke: rgba(255,255,255,.15); }
.vn-ring .vn-arc { stroke: #ff4d6d; stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.vn-time { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; }
.vn-controls { display: flex; align-items: center; gap: 28px; }
.vn-btn { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; display: grid; place-items: center; }
.vn-btn.go { background: var(--accent); color: var(--accent-ink); }
.vn-btn[disabled] { opacity: .5; }
.vn-rec { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; display: grid; place-items: center; }
.vn-rec i { width: 56px; height: 56px; border-radius: 50%; background: #ff4d6d; transition: all .2s; }
.vn-rec.on i { width: 28px; height: 28px; border-radius: 8px; }

/* переключатель */
.switch-row { cursor: pointer; }
.switch { position: relative; width: 48px; height: 28px; border-radius: 14px; background: var(--line); transition: background .18s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }
.segmented { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.segmented button { flex: 1; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.segmented button.on { background: var(--accent); color: var(--accent-ink); }

/* большое сердце при лайке */
.heartpop { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: #fff; animation: heartpop .8s ease forwards; }
.heartpop svg { width: 96px; height: 96px; fill: #ff4d6d; stroke: none; filter: drop-shadow(0 4px 12px rgba(0,0,0,.4)); }
@keyframes heartpop { 0% { transform: scale(.2); opacity: 0; } 30% { transform: scale(1.15); opacity: 1; } 60% { transform: scale(1); } 100% { transform: scale(1.1) translateY(-20px); opacity: 0; } }
.act.on svg { animation: likebounce .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes likebounce { from { transform: scale(.3); } }

/* страница человека */
.uhead { padding: 18px 16px 8px; display: grid; justify-items: center; gap: 6px; text-align: center; }
.ustats { display: flex; gap: 6px; justify-content: center; margin: 8px 0 4px; width: 100%; }
.ustat { flex: 1; max-width: 110px; padding: 8px 4px; border-radius: 12px; text-align: center; }
.ustat:active { background: var(--surface-2); }
.ustat b { display: block; font-size: 18px; }
.ustat span { font-size: 12px; color: var(--muted); }
.uacts { display: flex; gap: 8px; padding: 6px 16px 12px; width: 100%; max-width: 440px; margin: 0 auto; }
.uacts .btn { flex: 1; min-height: 42px; padding: 0 12px; }
.pgridp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; }
.ptile { position: relative; aspect-ratio: 1; background: var(--surface-2); overflow: hidden; display: grid; place-items: center; padding: 6px; text-align: center; font-size: 12px; color: var(--muted); }
.ptile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ptile .multi { position: absolute; top: 5px; right: 5px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }
.ptile .multi svg { width: 18px; height: 18px; }
.ptile .txt { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); }
.segtabs { display: flex; border-bottom: 1px solid var(--line); }
.segtabs button { flex: 1; padding: 10px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.segtabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* ========== Новые темы с фонами ========== */
/* Космос */
[data-theme="space"] {
  --bg: #05060f; --surface: rgba(255,255,255,.06); --surface-2: rgba(255,255,255,.1); --text: #eef1ff; --muted: #9aa3d0; --line: rgba(255,255,255,.14);
  --accent: #7c8cff; --accent-2: #ffd27a; --accent-ink: #0a0c20;
  --header-bg: linear-gradient(90deg, #0a0e2a, #1a1650); --header-ink: #fff;
  --me-bg: linear-gradient(135deg, #6d7cff, #a06bff); --me-ink: #fff;
  --them-bg: rgba(255,255,255,.1); --them-ink: #eef1ff; --them-line: rgba(255,255,255,.14);
  --danger: #ff8a9a; --ok: #6ee7b7; --radius: 16px; --bubble-r: 20px;
  --glass: rgba(6, 8, 22, .34); --shadow: 0 10px 34px rgba(0,0,0,.55); --glow: 0 0 10px rgba(124,140,255,.5);
  color-scheme: dark;
}
[data-theme="space"] body { background: radial-gradient(900px 500px at 15% 10%, rgba(110,80,220,.35), transparent 60%), radial-gradient(800px 500px at 90% 90%, rgba(40,110,200,.3), transparent 60%), #05060f fixed; }

/* Сакура */
[data-theme="sakura"] {
  --bg: #fff0f5; --surface: #ffffff; --surface-2: #ffe4ee; --text: #3d2230; --muted: #9a6b80; --line: #f8cfdd;
  --accent: #e75480; --accent-2: #c2336a; --accent-ink: #fff;
  --header-bg: linear-gradient(135deg, #f0709a, #e75480); --header-ink: #fff;
  --me-bg: linear-gradient(135deg, #f0709a, #e0457a); --me-ink: #fff;
  --them-bg: #fff; --them-ink: #3d2230; --them-line: #f8cfdd;
  --danger: #d6336c; --ok: #2f9e6b; --radius: 18px; --bubble-r: 22px;
  --glass: rgba(255, 244, 248, .8); --shadow: 0 8px 28px rgba(231,84,128,.22);
  color-scheme: light;
}
[data-theme="sakura"] body { background: linear-gradient(180deg, #fff0f5, #ffe0ec 60%, #ffd1e2) fixed; }

/* Дождь */
[data-theme="rain"] {
  --bg: #141824; --surface: #1b2133; --surface-2: #232b42; --text: #dfe6f7; --muted: #8a96b5; --line: #2c3652;
  --accent: #7aa2f7; --accent-2: #7dcfff; --accent-ink: #0b1020;
  --header-bg: linear-gradient(90deg, #161b28, #1d2540); --header-ink: #dfe6f7;
  --me-bg: linear-gradient(135deg, #7aa2f7, #5b7fd6); --me-ink: #0b1020;
  --them-bg: #232b42; --them-ink: #dfe6f7; --them-line: #2c3652;
  --danger: #f7768e; --ok: #9ece6a; --radius: 14px; --bubble-r: 18px;
  --glass: rgba(20, 24, 36, .72); --shadow: 0 10px 30px rgba(0,0,0,.5);
  color-scheme: dark;
}
[data-theme="rain"] body { background: radial-gradient(circle at 20% 28%, rgba(255,190,110,.13), transparent 40%), radial-gradient(circle at 82% 70%, rgba(120,170,255,.14), transparent 45%), linear-gradient(180deg, #0f1320, #1a2236 60%, #202a42) fixed; }

/* Синтвейв */
[data-theme="synthwave"] {
  --bg: #1a0833; --surface: rgba(40,10,70,.6); --surface-2: rgba(80,20,120,.5); --text: #fdeaff; --muted: #c79be0; --line: rgba(255,60,172,.35);
  --accent: #ff3cac; --accent-2: #2de2e6; --accent-ink: #fff;
  --header-bg: linear-gradient(90deg, #2b0a4a, #5a1170); --header-ink: #2de2e6;
  --me-bg: linear-gradient(135deg, #ff3cac, #784ba0); --me-ink: #fff;
  --them-bg: rgba(35,10,70,.88); --them-ink: #fdeaff; --them-line: #2de2e6;
  --danger: #ff6b8b; --ok: #2de2e6; --radius: 8px; --bubble-r: 12px;
  --glass: rgba(26, 8, 51, .3); --shadow: 0 0 26px rgba(255,60,172,.25); --glow: 0 0 10px rgba(255,60,172,.6);
  --title-tr: uppercase; --title-ls: .1em;
  color-scheme: dark;
}
[data-theme="synthwave"] body { background: linear-gradient(180deg, transparent 0, transparent 66%, #1a0833 66.2%, #1a0833 100%), radial-gradient(circle at 50% calc(66% - 11vmin), #ffe66d 0, #ff9a5a 8.5vmin, #ff3cac 12vmin, transparent 12.3vmin), linear-gradient(180deg, #12002b 0%, #3a0a5c 45%, #c2257f 62%, #ff7a59 66%) fixed; }
[data-theme="synthwave"] body::before { content: ""; position: fixed; left: -60%; right: -60%; bottom: 0; height: 34vh; pointer-events: none; z-index: 0; transform: perspective(240px) rotateX(62deg); transform-origin: bottom;
  background: repeating-linear-gradient(90deg, rgba(255,60,172,.6) 0 2px, transparent 2px 64px), repeating-linear-gradient(0deg, rgba(255,60,172,.6) 0 2px, transparent 2px 40px);
  -webkit-mask-image: linear-gradient(transparent, #000 45%); mask-image: linear-gradient(transparent, #000 45%); animation: gridmove 2.2s linear infinite; }
@keyframes gridmove { from { background-position: 0 0, 0 0; } to { background-position: 0 0, 0 40px; } }

/* Северное сияние */
[data-theme="aurora"] {
  --bg: #06141c; --surface: rgba(255,255,255,.07); --surface-2: rgba(255,255,255,.11); --text: #e8fff4; --muted: #8fb9ae; --line: rgba(255,255,255,.14);
  --accent: #2dd4bf; --accent-2: #a78bfa; --accent-ink: #04201c;
  --header-bg: linear-gradient(90deg, #08222c, #0e3a3a); --header-ink: #e8fff4;
  --me-bg: linear-gradient(135deg, #14b8a6, #6366f1); --me-ink: #fff;
  --them-bg: rgba(255,255,255,.1); --them-ink: #e8fff4; --them-line: rgba(255,255,255,.14);
  --danger: #ff8a8a; --ok: #4ade80; --radius: 16px; --bubble-r: 20px;
  --glass: rgba(6, 20, 28, .28); --shadow: 0 10px 34px rgba(0,0,0,.5); --glow: 0 0 10px rgba(45,212,191,.5);
  color-scheme: dark;
}
[data-theme="aurora"] body { background: linear-gradient(180deg, #030b12, #06141c 55%, #0a2229) fixed; }
[data-theme="aurora"] body::before { content: ""; position: fixed; inset: -25%; pointer-events: none; z-index: 0; filter: blur(34px); opacity: 1;
  background: radial-gradient(45% 30% at 30% 24%, rgba(45,212,191,.9), transparent), radial-gradient(38% 32% at 72% 18%, rgba(167,139,250,.85), transparent), radial-gradient(46% 26% at 50% 42%, rgba(74,222,128,.65), transparent);
  animation: auroramove 14s ease-in-out infinite alternate; }
@keyframes auroramove { from { transform: translateX(-7%) skewX(-7deg); opacity: .75; } to { transform: translateX(7%) skewX(7deg) scale(1.12); opacity: 1; } }
[data-theme="aurora"] body::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 17vh; background: #02090d; clip-path: polygon(0 100%, 0.0% 87%, 2.0% 62%, 4.1% 87%, 3.5% 85%, 5.2% 57%, 7.0% 85%, 6.5% 92%, 8.4% 78%, 10.3% 92%, 9.7% 92%, 11.2% 76%, 12.7% 92%, 12.2% 93%, 14.2% 79%, 16.2% 93%, 15.6% 89%, 16.8% 69%, 17.9% 89%, 17.6% 84%, 19.1% 55%, 20.6% 84%, 20.1% 88%, 21.3% 67%, 22.5% 88%, 22.2% 84%, 23.3% 55%, 24.5% 84%, 24.1% 81%, 25.4% 46%, 26.6% 81%, 26.2% 89%, 28.0% 68%, 29.7% 89%, 29.2% 81%, 31.2% 45%, 33.3% 81%, 32.6% 81%, 34.3% 46%, 36.0% 81%, 35.5% 93%, 37.6% 79%, 39.7% 93%, 39.0% 93%, 40.7% 80%, 42.4% 93%, 41.9% 91%, 43.2% 74%, 44.6% 91%, 44.2% 91%, 45.9% 73%, 47.5% 91%, 47.0% 81%, 48.4% 46%, 49.8% 81%, 49.4% 79%, 50.7% 39%, 52.0% 79%, 51.6% 81%, 53.3% 45%, 54.9% 81%, 54.4% 90%, 55.9% 70%, 57.4% 90%, 56.9% 81%, 58.7% 47%, 60.5% 81%, 60.0% 81%, 61.2% 46%, 62.3% 81%, 62.0% 89%, 63.6% 69%, 65.2% 89%, 64.7% 82%, 66.2% 48%, 67.7% 82%, 67.3% 87%, 68.9% 62%, 70.4% 87%, 69.9% 84%, 71.4% 53%, 72.9% 84%, 72.4% 88%, 74.3% 67%, 76.2% 88%, 75.7% 78%, 77.5% 38%, 79.4% 78%, 78.8% 92%, 80.5% 77%, 82.2% 92%, 81.7% 82%, 83.3% 49%, 84.9% 82%, 84.4% 86%, 86.2% 61%, 88.1% 86%, 87.5% 87%, 89.2% 64%, 90.9% 87%, 90.4% 92%, 91.6% 78%, 92.9% 92%, 92.5% 85%, 93.8% 56%, 95.0% 85%, 94.6% 86%, 95.9% 61%, 97.1% 86%, 96.8% 83%, 98.3% 51%, 99.8% 83%, 99.4% 79%, 100.5% 40%, 101.7% 79%, 100% 100%); pointer-events: none; z-index: 0; }

[data-theme="sakura"] #fx, [data-theme="rain"] #fx { z-index: 30; }
[data-theme="synthwave"] .topbar { border-bottom: 1px solid var(--accent); box-shadow: 0 2px 18px rgba(255,60,172,.3); }
[data-theme="space"] .topbar, [data-theme="aurora"] .topbar { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

/* ========== Статус сети ========== */
.avwrap { position: relative; display: inline-block; flex: none; }
.avwrap .dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--ok); border: 2px solid var(--bg); box-shadow: 0 0 6px var(--ok); }
.avwrap .avatar.sm + .dot { width: 10px; height: 10px; }
.topbar .sub.online { color: #8cffb0; opacity: 1; }
.sub.typing, .preview.typing { color: var(--accent-2) !important; opacity: 1; font-style: italic; }


/* ========== Каналы и администрирование ========== */
.chfeed { padding: 4px 0 12px; gap: 0; }
.chfeed .post { margin: 8px 10px; }
.chfoot { flex: none; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--glass); }
.chfoot .btn { flex: 1; min-height: 44px; }
.chwrite { flex: 1; min-height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); display: flex; align-items: center; gap: 8px; padding: 0 16px; text-align: left; }
.admtabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.admtabs::-webkit-scrollbar { display: none; }
.admtabs button { flex: none; padding: 7px 14px; border-radius: 16px; color: var(--muted); font-weight: 600; font-size: 14px; }
.admtabs button.on { background: var(--accent); color: var(--accent-ink); }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; padding: 10px 12px; }
.stat { background: var(--surface); background-image: linear-gradient(var(--glass), var(--glass)); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.pill.bad { background: var(--danger); color: #fff; border-color: transparent; }
.pill.good { background: var(--ok); color: #04210f; border-color: transparent; }
.logrow { padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.logrow .hint { display: block; }

.avatar.xs { width: 22px; height: 22px; font-size: 9px; border: 2px solid var(--bg); }
.likesline { display: flex; align-items: center; gap: 8px; padding: 2px 4px 4px; font-size: 14px; text-align: left; }
.likesline .faces { display: inline-flex; }
.likesline .faces .avatar + .avatar { margin-left: -8px; }
.likesline .ltext { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.likesline-slot:empty { display: none; }

/* ========== Реакции, закреп, пересылка, удобства ========== */
.reactbar { display: flex; gap: 2px; overflow-x: auto; padding: 4px 0 10px; margin: 0 -6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.reactbar::-webkit-scrollbar { display: none; }
.reactbar button { flex: none; width: 46px; height: 46px; border-radius: 50%; font-size: 26px; display: grid; place-items: center; transition: transform .12s; }
.reactbar button:active { transform: scale(1.4); }
.reactbar button.on { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--accent); }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 0; }
.rchip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; background: rgba(127,127,127,.22); font-size: 14px; line-height: 20px; transition: transform .12s, background .15s; animation: chipin .3s cubic-bezier(.2, 1.6, .4, 1); }
.rchip b { font-size: 12px; }
.rchip.mine { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 1.5px var(--accent); }
.me .rchip { background: rgba(255,255,255,.2); }
.me .rchip.mine { background: #fff; color: #222; }
.rchip:active { transform: scale(.9); }
@keyframes chipin { from { transform: scale(.3); opacity: 0; } }
.floaty { position: absolute; right: 14px; top: 0; font-size: 28px; pointer-events: none; animation: floatup 1s ease-out forwards; z-index: 5; }
@keyframes floatup { 0% { transform: translateY(0) scale(.5); opacity: 0; } 20% { opacity: 1; transform: translateY(-14px) scale(1.2); } 100% { transform: translateY(-70px) scale(1); opacity: 0; } }
.fwd { font-size: 12px; color: var(--accent-2); margin-bottom: 3px; display: flex; gap: 4px; align-items: center; }
.me .fwd { color: #fff; opacity: .9; }
.fwd svg { width: 13px; height: 13px; }
.edited { font-size: 11px; opacity: .7; margin-right: 2px; }
a.lnk { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.them a.lnk { color: var(--accent-2); }
.pinbar { flex: none; display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--glass); border-left: 3px solid var(--accent); color: var(--accent-2); cursor: pointer; animation: fadeIn .2s ease; }
.pinbar .rq-text { color: var(--text); }
.tobottom { position: absolute; right: 14px; bottom: 82px; z-index: 6; width: 44px; height: 44px; border-radius: 50%; background: var(--surface); background-image: linear-gradient(var(--glass), var(--glass)); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; animation: fadeIn .18s ease; }
.tobottom .nb { position: absolute; top: -8px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.mini { display: inline-grid; vertical-align: -2px; margin-left: 4px; opacity: .6; }
.mini svg { width: 14px; height: 14px; }
.badge.muted-b { background: var(--muted); }
.row.pinned { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.forwardlist { max-height: 52vh; overflow-y: auto; margin: 0 -6px; }
.forwardlist .row { padding-left: 6px; padding-right: 6px; }
.fwdmark { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; transition: all .12s; flex: none; }
.fwdmark svg { width: 14px; height: 14px; stroke-width: 3; }
.row.picked .fwdmark { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.viewer .dl { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 62px; color: #fff; background: rgba(255,255,255,.18); }

/* ========== Общая полировка ========== */
.messages { gap: 8px; padding-top: 14px; }
.msg.cont { margin-top: -6px; }
.me.cont .bubble { border-top-right-radius: 8px; }
.them.cont .bubble { border-top-left-radius: 8px; }
.bubble { box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.bubble.sticker, .bubble.vnb { box-shadow: none; }
.topbar { box-shadow: 0 1px 12px rgba(0,0,0,.12); z-index: 3; }
.composer { box-shadow: 0 -1px 12px rgba(0,0,0,.08); }
.composer textarea { transition: border-color .15s, box-shadow .15s; }
.composer textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.row { transition: background .12s, transform .08s; }
@media (hover: hover) {
  .row:hover { background: var(--surface-2); }
  .btn:hover, .iconbtn:hover, .act:hover { filter: brightness(1.08); }
  .bubble:hover .rchip { filter: brightness(1.05); }
  .theme-card:hover { transform: translateY(-2px); }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus-visible, textarea:focus-visible { outline: none; }
body, .pane, .topbar, .tabbar, .composer, .sheet, .card, .bubble { transition: background-color .35s, color .25s, border-color .35s; }
@media (hover: hover) and (pointer: fine) {
  .scroll, .messages, .sgrid, .forwardlist { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
}
.empty .big, .empty > div:first-child { animation: floaty2 3s ease-in-out infinite; }
@keyframes floaty2 { 50% { transform: translateY(-5px); } }
.shimmer { background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 60%, var(--text) 8%) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.tab.active svg { animation: tabpop .3s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes tabpop { from { transform: scale(.7); } }
.sheet { animation: rise .24s cubic-bezier(.2, .9, .3, 1); }
.toast { animation: rise .25s cubic-bezier(.2, 1.3, .4, 1); }

/* ========== Кто говорит (как в Discord) ========== */
.vtile { transition: box-shadow .15s, border-color .15s; }
.vtile.speaking { border-color: #3ddc84; box-shadow: 0 0 0 3px #3ddc84, 0 0 26px rgba(61,220,132,.55); }
.vtile.speaking .avatar { animation: speakpulse 1s ease-in-out infinite; }
@keyframes speakpulse { 50% { transform: scale(1.06); box-shadow: 0 0 0 8px rgba(61,220,132,.25); } }
.chuser.speaking .avatar { box-shadow: 0 0 0 2px #3ddc84, 0 0 10px rgba(61,220,132,.7); }
.chuser.speaking { color: var(--text); }
.call .avatar.speaking { animation: callspeak 1s ease-in-out infinite; box-shadow: 0 0 0 4px #3ddc84; }
@keyframes callspeak { 50% { box-shadow: 0 0 0 16px rgba(61,220,132,.2); } }

/* показать/скрыть пароль */
.pwwrap { position: relative; }
.pwwrap .input { padding-right: 48px; }
.pweye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.pweye:hover { color: var(--text); }
.pweye .i { width: 20px; height: 20px; }

/* близкие друзья: зелёный кружок и бейдж */
.ring.unseen.close { background: conic-gradient(from 200deg, #22c55e, #86efac, #16a34a, #22c55e); }
.ring.seen.close { background: color-mix(in srgb, #22c55e 45%, var(--line)); }
.cfbadge { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; padding: 1px 8px; border-radius: 10px; background: #16a34a; color: #fff; font-size: 11px; font-weight: 700; }
.cfbadge .i { width: 11px; height: 11px; }
.segmented .closebtn.on { background: #16a34a; color: #fff; }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }

/* разовые фото и видео */
.oncepill { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border-radius: 16px; background: color-mix(in srgb, #ff4d6d 14%, var(--surface-2)); border: 1px dashed color-mix(in srgb, #ff4d6d 55%, var(--line)); min-width: 200px; text-align: left; color: inherit; }
.oncepill:disabled { cursor: default; }
.oncepill.opened { opacity: .65; border-style: solid; background: var(--surface-2); border-color: var(--line); }
.oncepill .ocircle { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #ff4d6d; color: #fff; flex: none; }
.oncepill.opened .ocircle { background: var(--muted); }
.oncepill .ocircle .i { width: 20px; height: 20px; }
.oncepill .otext { display: flex; flex-direction: column; font-size: 14px; line-height: 1.25; }
.oncepill .otext small { color: var(--muted); font-size: 12px; }
.onceview { position: fixed; inset: 0; z-index: 90; background: #000; display: grid; place-items: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; animation: fade .15s; }
.onceview img, .onceview video { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.onceview .ov-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: linear-gradient(#000a, transparent); color: #fff; }
.onceview .ov-note { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.onceview .ov-note .i { width: 16px; height: 16px; color: #ff4d6d; }
.onceview .ov-count { font-variant-numeric: tabular-nums; font-weight: 700; }
.onceview .iconbtn { color: #fff; background: rgba(255,255,255,.18); }
.onceview .ov-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.2); }
.onceview .ov-bar i { display: block; height: 100%; width: 100%; background: #ff4d6d; }

/* лайк истории */
.sv-like { color: #fff; }
.sv-like.on { color: #ff4d6d; }
.sv-like.on .i { fill: #ff4d6d; }
.sv-like.pop .i { animation: svpop .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes svpop { 0% { transform: scale(.7); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
.likedmark { color: #ff4d6d; display: inline-flex; margin-right: 6px; }
.likedmark .i { width: 16px; height: 16px; fill: #ff4d6d; }
.sv-caption { max-height: 30vh; overflow-y: auto; bottom: 150px; }

/* обновление свайпом вниз */
.ptr { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 8px); z-index: 60; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.25); color: var(--accent); opacity: 0; transform: translate(-50%, -52px); pointer-events: none; }
.ptr .i { width: 20px; height: 20px; }
.ptr.spin .i { animation: ptrspin .8s linear infinite; }
@keyframes ptrspin { to { transform: rotate(360deg); } }

/* упоминания @ник */
.mention { color: var(--accent-2); font-weight: 600; text-decoration: none; cursor: pointer; }
.mention:hover { text-decoration: underline; }
.mention.me { background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 6px; padding: 0 3px; }
.msg.me .bubble .mention { color: inherit; text-decoration: underline; }
.mentionpop { position: fixed; z-index: 85; max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.35); padding: 4px; }
.mentionpop .mrow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; text-align: left; color: inherit; }
.mentionpop .mrow.on, .mentionpop .mrow:hover { background: var(--surface-2); }
.pill .i, .hint .i.inl { width: 12px; height: 12px; vertical-align: -2px; }

/* ответы и лайки комментариев */
.comment.reply { margin-left: 44px; padding-top: 4px; }
.cactions { display: flex; gap: 14px; margin-top: 2px; }
.creply { color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 2px 0; }
.creply:hover { color: var(--text); }
.clikewrap { display: flex; flex-direction: column; align-items: center; min-width: 30px; }
.clike { width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); border-radius: 50%; }
.clike .i { width: 17px; height: 17px; }
.clike.on { color: #ff4d6d; }
.clike.on .i { animation: svpop .35s cubic-bezier(.2,1.6,.4,1); }
.ccount { font-size: 12px; color: var(--muted); margin-top: -4px; }

/* история: быстрые реакции, свайп вниз */
.storyview { touch-action: none; overflow: hidden; }
.sv-replywrap { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.sv-replyrow { display: flex; align-items: center; gap: 8px; }
.sv-quick { display: flex; justify-content: space-between; padding: 0 4px; }
.sv-quick button { font-size: 28px; line-height: 1; padding: 4px 6px; transition: transform .12s; }
.sv-quick button:active { transform: scale(1.35); }
.sv-fly { position: fixed; z-index: 5; pointer-events: none; animation: svfly 1.5s ease-out forwards; }
@keyframes svfly { 0% { transform: translate(0, 0) scale(.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(var(--dx), -55vh) scale(1.2); opacity: 0; } }

/* реакции: сетка из 100 эмодзи */
.reactbar button.more { background: var(--surface-2); color: var(--muted); }
.reactbar button.more .i { width: 20px; height: 20px; }
.reactgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 2px; max-height: 38vh; overflow-y: auto; padding: 4px 0 10px; }
.reactgrid button { height: 44px; font-size: 25px; border-radius: 12px; display: grid; place-items: center; transition: transform .12s; }
.reactgrid button:active { transform: scale(1.35); }
.reactgrid button.on { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--accent); }
/* карточка «ответ на историю» */
.quote.storyref { display: flex; gap: 8px; align-items: center; cursor: default; }
.sr-thumb { width: 34px; height: 48px; border-radius: 8px; overflow: hidden; flex: none; background: rgba(127,127,127,.3); display: grid; place-items: center; }
.sr-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sr-thumb.gone { opacity: .5; }
.bigemoji { font-size: 44px; line-height: 1.15; }

/* исчезающие сообщения */
.ttlchip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--accent-2); padding: 3px 8px; border-radius: 12px; background: var(--surface-2); white-space: nowrap; }
.ttlchip .i { width: 13px; height: 13px; }
.ttlbadge { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; color: var(--accent-2); font-size: 11px; }
.ttlbadge .i { width: 11px; height: 11px; }
.ttlbadge b { font-weight: 600; }
.bubble { position: relative; }
.msg.dissolve { animation: dissolve .8s ease-in forwards; pointer-events: none; }
.msg.dissolve .bubble { overflow: visible; }
@keyframes dissolve { 0% { opacity: 1; filter: blur(0); transform: none; } 55% { opacity: .75; filter: blur(1px); } 100% { opacity: 0; filter: blur(7px); transform: translateY(-8px) scale(.94); } }
.dust { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); opacity: 0; animation: dust .7s ease-out forwards; pointer-events: none; }
@keyframes dust { 0% { opacity: .95; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.2); } }
/* обои чата */
.wpbg { position: absolute; inset: 0; z-index: -1; background-size: cover; background-position: center; pointer-events: none; }
.wpbg::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,var(--dim, .35)); }
.chat.haswp .messages { background: transparent; }
.wp-preview { position: relative; height: 190px; border-radius: 16px; overflow: hidden; background: var(--surface-2) center / cover; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 16px; }
.wp-dim { position: absolute; inset: 0; }
.wp-bub { position: relative; padding: 7px 12px; border-radius: 14px; font-size: 14px; max-width: 70%; }
.wp-bub.them { background: var(--bubble-them, var(--surface)); align-self: flex-start; }
.wp-bub.me { background: var(--accent); color: var(--accent-ink); align-self: flex-end; }
.wp-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.wp-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.wp-swatches button { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--line); }
.menu-item.picked { color: var(--accent-2); font-weight: 700; }

/* активность и колокольчик */
.bellbtn { position: relative; }
.bellbadge { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #ff4d6d; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.act-row { align-items: center; }
.act-row.unread { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.act-ava { position: relative; flex: none; }
.act-kind { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--accent); border: 2px solid var(--bg); }
.act-kind .i { width: 11px; height: 11px; }
.act-kind.like, .act-kind.comment_like, .act-kind.story_like { background: #ff4d6d; }
.act-kind.follow { background: #22c55e; }
.act-kind.mention { background: #f59e0b; }
.act-text { font-size: 14px; line-height: 1.3; }
.act-quote { color: var(--muted); }
.act-thumb { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; flex: none; background: var(--surface-2); }
.act-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* наборы стикеров */
.pack-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.pack-prev { font-size: 22px; letter-spacing: 2px; margin: 2px 0; }

/* разовые фото и видео: анимации */
.oncepill:not(.opened):not(:disabled) { animation: oncePulse 2.2s ease-in-out infinite; }
.oncepill:not(.opened) .ocircle .i { animation: flameFlicker 1.1s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes oncePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,77,109,.0); } 50% { box-shadow: 0 0 0 7px rgba(255,77,109,.18); } }
@keyframes flameFlicker { 0%, 100% { transform: scale(1) rotate(0); } 25% { transform: scale(1.12, .94) rotate(-4deg); } 55% { transform: scale(.94, 1.1) rotate(3deg); } 80% { transform: scale(1.06) rotate(-2deg); } }
.oncepill.burnt { animation: burnt 1.1s ease-out; }
.oncepill.burnt .ocircle { animation: burntIcon .9s ease-out; }
@keyframes burnt { 0% { box-shadow: 0 0 0 0 rgba(255,150,40,.9), 0 0 24px rgba(255,120,40,.8); filter: brightness(1.6); } 100% { box-shadow: 0 0 0 16px rgba(255,150,40,0), 0 0 0 rgba(255,120,40,0); filter: none; } }
@keyframes burntIcon { 0% { transform: scale(1.5) rotate(-20deg); } 60% { transform: scale(.85); } 100% { transform: scale(1); } }
.onceview { animation: ovIn .38s cubic-bezier(.2,.9,.3,1); }
.onceview img, .onceview video { animation: ovReveal .5s cubic-bezier(.2,.9,.3,1); }
@keyframes ovIn { from { opacity: 0; background: #000; } to { opacity: 1; } }
@keyframes ovReveal { from { opacity: 0; transform: scale(.88); filter: blur(14px) brightness(1.8); } to { opacity: 1; transform: none; filter: none; } }
.onceview.burn { animation: ovBurn .9s ease-in forwards; pointer-events: none; }
.onceview.burn img, .onceview.burn video { animation: ovBurnMedia .9s ease-in forwards; }
@keyframes ovBurn { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes ovBurnMedia { 0% { filter: none; transform: none; } 40% { filter: sepia(1) saturate(4) hue-rotate(-20deg) brightness(1.15); } 100% { filter: sepia(1) saturate(5) brightness(.2) blur(10px); transform: scale(1.06) translateY(-14px); opacity: 0; } }
.ember { position: absolute; border-radius: 50%; background: radial-gradient(circle, #fff6a8, #ff8a1f 55%, rgba(255,60,0,0)); opacity: 0; animation: ember .9s ease-out forwards; pointer-events: none; z-index: 2; }
@keyframes ember { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.2); } }
.onceview .ov-count { position: relative; isolation: isolate; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; background: conic-gradient(#ff4d6d calc(var(--p, 1) * 360deg), rgba(255,255,255,.22) 0); }
.onceview .ov-count::before { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: #111; z-index: -1; }
.onceview .ov-count:empty { display: none; }
.onceview .ov-note .i { animation: flameFlicker 1.1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .oncepill, .oncepill .ocircle .i, .onceview .ov-note .i { animation: none !important; } }
