:root {
  --bg: #0d0b1a;
  --bg2: #15122b;
  --panel: rgba(30, 26, 58, 0.72);
  --panel-solid: #1c1838;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f1eefe;
  --muted: #a39cc7;
  --accent: #8b5cf6;
  --accent2: #ec4899;
  --mine: linear-gradient(135deg, #7c3aed, #db2777);
  --theirs: #262145;
  --danger: #f87171;
  --ok: #34d399;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --blob-opacity: 0.45;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f3ff;
    --bg2: #ffffff;
    --panel: rgba(255, 255, 255, 0.78);
    --panel-solid: #ffffff;
    --border: rgba(60, 30, 120, 0.12);
    --text: #1d1636;
    --muted: #6d6590;
    --theirs: #ece7fb;
    --shadow: 0 10px 40px rgba(80, 50, 160, 0.15);
    --blob-opacity: 0.25;
  }
}
:root[data-theme="light"] {
  --bg: #f6f3ff;
  --bg2: #ffffff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --border: rgba(60, 30, 120, 0.12);
  --text: #1d1636;
  --muted: #6d6590;
  --theirs: #ece7fb;
  --shadow: 0 10px 40px rgba(80, 50, 160, 0.15);
  --blob-opacity: 0.25;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }

/* Фоновые пятна */
.bg-blobs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-blobs i {
  position: absolute; width: 520px; height: 520px; border-radius: 50%;
  filter: blur(90px); opacity: var(--blob-opacity); animation: float 18s ease-in-out infinite alternate;
}
.bg-blobs i:nth-child(1) { background: var(--b1, #7c3aed); top: -160px; left: -120px; }
.bg-blobs i:nth-child(2) { background: var(--b2, #db2777); bottom: -200px; right: -140px; animation-delay: -6s; }
.bg-blobs i:nth-child(3) { background: var(--b3, #0ea5e9); top: 40%; left: 55%; width: 360px; height: 360px; animation-delay: -12s; }
.bg-blobs i { transition: background 1s; }

/* Темы оформления */
:root[data-skin="sunset"] { --accent: #f97316; --accent2: #e11d48; --mine: linear-gradient(135deg, #ea580c, #e11d48); --b1: #f97316; --b2: #be123c; --b3: #facc15; }
:root[data-skin="ocean"] { --accent: #0ea5e9; --accent2: #6366f1; --mine: linear-gradient(135deg, #0284c7, #4f46e5); --b1: #0ea5e9; --b2: #1e40af; --b3: #22d3ee; }
:root[data-skin="forest"] { --accent: #22c55e; --accent2: #0d9488; --mine: linear-gradient(135deg, #16a34a, #0f766e); --b1: #15803d; --b2: #065f46; --b3: #84cc16; }
:root[data-skin="sakura"] { --accent: #f472b6; --accent2: #c084fc; --mine: linear-gradient(135deg, #ec4899, #a855f7); --b1: #f9a8d4; --b2: #c084fc; --b3: #fb7185; }
:root[data-skin="matrix"] { --accent: #22c55e; --accent2: #4ade80; --mine: linear-gradient(135deg, #15803d, #166534); --b1: #052e16; --b2: #14532d; --b3: #166534; }
:root[data-skin="matrix"]:not([data-theme="light"]) { --bg: #020804; --bg2: #04110a; --panel: rgba(4, 20, 10, .78); --panel-solid: #06180d; --theirs: #0b2414; --text: #b7f7c8; --muted: #5fae78; }
:root[data-skin="matrix"] .bubble, :root[data-skin="matrix"] .room-title { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
:root[data-font="s"] body { font-size: 14px; }
:root[data-font="l"] body { font-size: 17px; }
:root[data-font="l"] .bubble { line-height: 1.5; }
@keyframes float { to { transform: translate(60px, 40px) scale(1.15); } }

.screen { position: relative; z-index: 1; height: 100%; }

/* ===== Вход ===== */
#welcome { display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.card {
  width: 100%; max-width: 420px; padding: 32px 28px; border-radius: 28px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); text-align: center;
  margin: auto;
}
.logo { font-size: 64px; line-height: 1; animation: wobble 3s ease-in-out infinite; display: inline-block; }
@keyframes wobble { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.06); } }
h1 {
  margin: 8px 0 4px; font-size: 34px; letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { margin: 0 0 22px; color: var(--muted); }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, textarea {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--bg2); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 92, 246, .25); }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; }
.avatars button {
  width: 42px; height: 42px; font-size: 22px; border-radius: 12px; cursor: pointer;
  border: 2px solid transparent; background: var(--bg2); transition: transform .12s;
}
.avatars button:hover { transform: scale(1.12); }
.avatars button[aria-checked="true"] { border-color: var(--accent); transform: scale(1.08); }

.btn {
  border: 1px solid var(--border); background: var(--bg2); padding: 10px 16px; border-radius: 14px;
  cursor: pointer; font-weight: 600; transition: transform .1s, filter .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0; }
.btn.big { width: 100%; padding: 14px; font-size: 16px; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.join-details { margin-top: 14px; text-align: left; color: var(--muted); }
.join-details summary { cursor: pointer; text-align: center; }
.row { display: flex; gap: 8px; margin-top: 10px; }
.invite-box { margin-bottom: 8px; }
.invite-box p { margin: 0 0 12px; }
.error { color: var(--danger); margin: 12px 0 0; }
.install-btn { width: 100%; margin-top: 14px; border-style: dashed; animation: pop .3s; }
.install-hint { font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.features {
  list-style: none; padding: 0; margin: 22px 0 0; display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; font-size: 12.5px; color: var(--muted); text-align: left;
}
.features li { background: var(--bg2); border: 1px solid var(--border); padding: 8px 10px; border-radius: 12px; }

/* ===== Чат ===== */
#chat { display: flex; flex-direction: column; max-width: 860px; margin: 0 auto; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--panel); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.room-info { flex: 1; min-width: 0; }
.room-title { font-weight: 700; font-size: 17px; letter-spacing: 2px; }
.room-sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #fbbf24; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--danger); }
.icon-btn {
  background: transparent; border: 0; font-size: 20px; width: 40px; height: 40px; border-radius: 12px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none; position: relative;
}
.icon-btn:hover { background: rgba(139, 92, 246, .15); }
.ttl small {
  position: absolute; bottom: 1px; right: 0; font-size: 9px; font-weight: 700;
  background: var(--accent2); color: #fff; border-radius: 6px; padding: 0 3px;
}
.ttl small:empty { display: none; }

.messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: smooth; overscroll-behavior: contain;
}
.system {
  align-self: center; text-align: center; font-size: 12.5px; color: var(--muted); max-width: 520px;
  background: var(--panel); border: 1px solid var(--border); padding: 8px 14px; border-radius: 14px; margin: 6px 0;
}

.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 82%; animation: pop .22s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.cont { margin-top: -1px; }
.msg.cont .avatar { visibility: hidden; }
.msg.cont .name { display: none; }
.msg + .msg:not(.cont) { margin-top: 8px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; font-size: 19px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.c0 { background: #7c3aed; } .c1 { background: #db2777; } .c2 { background: #0ea5e9; } .c3 { background: #10b981; }
.c4 { background: #f59e0b; } .c5 { background: #ef4444; } .c6 { background: #6366f1; } .c7 { background: #14b8a6; }
.t0 { color: #a78bfa; } .t1 { color: #f472b6; } .t2 { color: #38bdf8; } .t3 { color: #34d399; }
.t4 { color: #fbbf24; } .t5 { color: #f87171; } .t6 { color: #818cf8; } .t7 { color: #2dd4bf; }

.bubble-wrap { min-width: 0; display: flex; flex-direction: column; }
.msg.mine .bubble-wrap { align-items: flex-end; }
.name { font-size: 12.5px; font-weight: 700; margin: 0 0 2px 10px; }
.bubble {
  position: relative; padding: 8px 12px 6px; border-radius: 18px; background: var(--theirs);
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; cursor: default;
  border-bottom-left-radius: 6px;
}
.msg.mine .bubble { background: var(--mine); color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.bubble.big-emoji { background: transparent !important; font-size: 46px; line-height: 1.1; padding: 0 4px; }
.bubble img { display: block; max-width: min(320px, 100%); max-height: 360px; border-radius: 12px; margin: 2px 0 4px; cursor: zoom-in; }
.meta { font-size: 11px; opacity: .65; text-align: right; margin-top: 2px; user-select: none; }
.meta .burn { margin-right: 4px; }
.msg.failed .meta { color: var(--danger); opacity: 1; cursor: pointer; }
.msg.pending .meta { opacity: .4; }
.messages .msg.burning { animation: burn 1s forwards; }
@keyframes burn { to { opacity: 0; transform: scale(.85); filter: blur(6px); } }
.quote {
  border-left: 3px solid var(--accent2); padding: 2px 8px; margin: 0 0 4px; font-size: 13px; opacity: .85;
  border-radius: 4px; background: rgba(0, 0, 0, .12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px;
}

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.reactions button {
  border: 1px solid var(--border); background: var(--panel-solid); border-radius: 999px; padding: 1px 8px;
  font-size: 13px; cursor: pointer;
}
.reactions button.me { border-color: var(--accent); background: rgba(139, 92, 246, .25); }

.actions {
  display: flex; gap: 2px; opacity: 0; transition: opacity .12s; align-self: center;
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: 999px; padding: 2px;
}
.msg:hover .actions, .msg.show-actions .actions { opacity: 1; }
.actions { flex: none; }
.actions button { border: 0; background: transparent; font-size: 16px; cursor: pointer; padding: 3px 5px; border-radius: 999px; flex: none; }
.actions button:hover { background: rgba(139, 92, 246, .2); transform: scale(1.2); }

.typing { min-height: 20px; padding: 0 20px 2px; font-size: 12.5px; color: var(--muted); }
.typing:not(:empty)::after { content: ""; display: inline-block; width: 18px; animation: dots 1.2s steps(4) infinite; text-align: left; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.reply-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 12px;
  padding: 6px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px 14px 0 0; font-size: 13px;
}
.reply-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.emoji-panel {
  margin: 0 12px; padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px;
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: 16px; max-height: 200px; overflow-y: auto;
}
.emoji-panel button { font-size: 22px; background: transparent; border: 0; padding: 4px; cursor: pointer; border-radius: 10px; }
.emoji-panel button:hover { background: rgba(139, 92, 246, .2); }

.composer {
  display: flex; align-items: flex-end; gap: 4px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--border);
}
.composer textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 10px 14px; line-height: 1.4; }
.send-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; cursor: pointer; font-size: 18px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); transition: transform .1s;
}
.send-btn:active { transform: scale(.9) rotate(-15deg); }

/* Голосовые */
.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.voice-play {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; flex: none; font-size: 14px;
  background: rgba(255, 255, 255, .2); color: #fff;
}
.msg:not(.mine) .voice-play, .rec-preview .voice-play { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 30px; flex: 1; cursor: pointer; min-width: 110px; }
.voice-wave i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: currentColor; opacity: .35; height: 15%; }
.voice-wave i.on { opacity: 1; }
.voice-info { font-size: 11.5px; display: flex; flex-direction: column; align-items: flex-end; min-width: 38px; font-variant-numeric: tabular-nums; }
.voice-fx { font-size: 15px; line-height: 1; }
.voice-err { font-size: 12.5px; opacity: .8; }

.recorder {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--border);
}
.fx-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.fx-row::-webkit-scrollbar { display: none; }
.fx-row button {
  flex: none; border: 1px solid var(--border); background: var(--bg2); border-radius: 999px; padding: 6px 12px;
  cursor: pointer; font-size: 13px; white-space: nowrap; transition: transform .1s;
}
.fx-row button:active { transform: scale(.95); }
.fx-row button[aria-checked="true"] { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }
.rec-main { display: flex; align-items: center; gap: 8px; }
.rec-live { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #ef4444; flex: none; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.4); opacity: .5; } }
.rec-hint { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-preview { flex: 1; min-width: 0; background: var(--theirs); border-radius: 18px; padding: 4px 10px; }
.send-btn.stop { background: #ef4444; font-size: 15px; }

/* ===== Меню вложений, окна ===== */
.attach-menu {
  display: flex; gap: 8px; margin: 0 12px 6px; padding: 8px; background: var(--panel-solid);
  border: 1px solid var(--border); border-radius: 18px; animation: pop .18s; width: max-content; max-width: calc(100% - 24px);
}
.attach-menu button {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 14px; border: 0; border-radius: 14px;
  background: transparent; cursor: pointer; font-size: 12.5px; transition: transform .12s, background .15s;
}
.attach-menu button span { font-size: 26px; }
.attach-menu button:hover { background: rgba(139, 92, 246, .18); transform: translateY(-2px); }

.modal {
  position: fixed; inset: 0; z-index: 55; background: rgba(5, 4, 12, .6); display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: fadein .2s; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.sheet {
  width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: 24px; padding: 16px; box-shadow: var(--shadow); animation: pop .22s;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; font-size: 17px; }
.poll-opts-edit { display: flex; flex-direction: column; gap: 8px; }
.poll-opts-edit .row { margin: 0; }

/* Опрос в сообщении */
.poll { min-width: 230px; max-width: 320px; white-space: normal; }
.poll-q { font-weight: 700; margin-bottom: 8px; }
.poll-opt {
  position: relative; display: flex; justify-content: space-between; gap: 10px; width: 100%; margin-bottom: 6px; padding: 8px 10px;
  border-radius: 12px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(0, 0, 0, .12); cursor: pointer; overflow: hidden;
  text-align: left; color: inherit; font: inherit;
}
.msg:not(.mine) .poll-opt { border-color: var(--border); }
.poll-opt::before {
  content: ""; position: absolute; inset: 0; width: var(--p, 0%); background: rgba(139, 92, 246, .35);
  transition: width .45s cubic-bezier(.2, .8, .2, 1);
}
.msg.mine .poll-opt::before { background: rgba(255, 255, 255, .25); }
.poll-opt.chosen { border-color: #fff; font-weight: 700; }
.msg:not(.mine) .poll-opt.chosen { border-color: var(--accent); }
.poll-opt > span { position: relative; }
.poll-total { font-size: 12px; opacity: .75; }

/* Удалённые и изменённые */
.deleted .bubble { font-style: italic; opacity: .6; }
.meta .edited { margin-right: 4px; }

/* Рисовалка */
.draw-sheet { max-width: 560px; }
.draw-canvas {
  background: #fff; border-radius: 16px; touch-action: none; cursor: crosshair; align-self: center; flex: none;
}
.draw-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.draw-colors, .draw-sizes { display: flex; gap: 6px; flex-wrap: wrap; }
.draw-colors { flex: 1; }
.draw-colors button {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; transition: transform .1s;
}
.draw-colors button[aria-checked="true"] { transform: scale(1.2); border-color: var(--accent); box-shadow: 0 0 0 2px var(--panel-solid), 0 0 0 4px var(--accent); }
.draw-sizes button {
  width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.draw-sizes button i { display: block; border-radius: 50%; background: var(--text); }
.draw-sizes button[aria-checked="true"] { border-color: var(--accent); background: rgba(139, 92, 246, .2); }

/* ===== Поиск и закреп ===== */
.search-bar, .pin-bar {
  display: flex; align-items: center; gap: 8px; margin: 8px 12px 0; padding: 6px 8px 6px 12px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--border); animation: pop .2s;
}
.search-bar input { flex: 1; padding: 8px 10px; border-radius: 10px; }
.search-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pin-bar { cursor: pointer; border-left: 3px solid var(--accent); }
.pin-ico { font-size: 18px; }
.pin-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pin-body small { color: var(--accent); font-weight: 700; font-size: 11.5px; }
.pin-body span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.msg.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 4px var(--accent); } }
.msg .pinned-mark { margin-right: 3px; }

/* ===== Панель эмодзи / стикеров ===== */
.emoji-panel { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: hidden; }
.panel-tabs { display: flex; gap: 6px; }
.panel-tabs button {
  flex: 1; border: 1px solid var(--border); background: var(--bg2); border-radius: 10px; padding: 6px; cursor: pointer; font-size: 13px;
}
.panel-tabs button[aria-selected="true"] { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; overflow-y: auto; }
.panel-grid button { font-size: 22px; background: transparent; border: 0; padding: 4px; cursor: pointer; border-radius: 10px; }
.panel-grid button:hover { background: rgba(139, 92, 246, .2); }
.panel-grid.stickers { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
.panel-grid.stickers button { font-size: 40px; }
.panel-grid.stickers button:hover span { animation-iteration-count: infinite; }

/* ===== Стикеры ===== */
.bubble.sticker-bubble { background: transparent !important; padding: 0 4px; }
.sticker { display: inline-block; font-size: 84px; line-height: 1.05; }
.panel-grid .sticker { font-size: 40px; }
.sticker.play { animation-duration: 1s; animation-iteration-count: 3; animation-timing-function: ease-in-out; }
.panel-grid button:hover .sticker { animation-duration: 1s; animation-timing-function: ease-in-out; }
.a-bounce { animation-name: st-bounce; } .a-shake { animation-name: st-shake; } .a-beat { animation-name: st-beat; }
.a-flicker { animation-name: st-flicker; } .a-pop { animation-name: st-pop; } .a-spin { animation-name: st-spin; }
.a-wave { animation-name: st-wave; transform-origin: 70% 80%; } .a-float { animation-name: st-float; } .a-wobble { animation-name: st-wobble; }
.a-rocket { animation-name: st-rocket; } .a-tilt { animation-name: st-tilt; } .a-boom { animation-name: st-boom; }
@keyframes st-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22px) scale(1.05, .95); } 60% { transform: translateY(0) scale(1.1, .9); } }
@keyframes st-shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(6deg); } }
@keyframes st-beat { 0%, 100% { transform: scale(1); } 20% { transform: scale(1.25); } 40% { transform: scale(1); } 60% { transform: scale(1.18); } }
@keyframes st-flicker { 0%, 100% { transform: scale(1) rotate(0); filter: brightness(1); } 25% { transform: scale(1.08, .94) rotate(-3deg); filter: brightness(1.3); } 75% { transform: scale(.95, 1.08) rotate(3deg); } }
@keyframes st-pop { 0% { transform: scale(.3); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes st-spin { to { transform: rotate(360deg); } }
@keyframes st-wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(20deg); } 50% { transform: rotate(-10deg); } 75% { transform: rotate(16deg); } }
@keyframes st-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes st-wobble { 0%, 100% { transform: scale(1, 1); } 30% { transform: scale(1.2, .8); } 50% { transform: scale(.85, 1.15); } 70% { transform: scale(1.08, .92); } }
@keyframes st-rocket { 0% { transform: translate(0, 0); } 50% { transform: translate(14px, -26px) rotate(8deg); } 51% { transform: translate(-14px, 26px); opacity: 0; } 100% { transform: translate(0, 0); opacity: 1; } }
@keyframes st-tilt { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-18deg) translateX(-4px); } }
@keyframes st-boom { 0% { transform: scale(1); } 40% { transform: scale(1.45); filter: hue-rotate(40deg); } 100% { transform: scale(1); } }

/* ===== Игры ===== */
.attach-menu { display: grid; grid-template-columns: repeat(3, 1fr); }
.attach-menu button span { white-space: nowrap; }
.game { min-width: 210px; white-space: normal; }
.ttt-board { display: grid; grid-template-columns: repeat(3, 56px); gap: 6px; margin: 6px 0; justify-content: center; }
.ttt-board button {
  width: 56px; height: 56px; border-radius: 14px; border: 0; cursor: pointer; font-size: 30px; font-weight: 900;
  background: rgba(0, 0, 0, .18); color: inherit; transition: transform .1s, background .15s;
}
.msg:not(.mine) .ttt-board button { background: rgba(139, 92, 246, .12); }
.ttt-board button.can:hover { background: rgba(255, 255, 255, .22); transform: scale(1.06); }
.ttt-board button:disabled { cursor: default; }
.ttt-board button.x { color: #fca5a5; }
.ttt-board button.o { color: #93c5fd; }
.msg:not(.mine) .ttt-board button.x { color: #ef4444; }
.msg:not(.mine) .ttt-board button.o { color: #3b82f6; }
.ttt-board button.placed { animation: st-pop .3s; }
.ttt-board button.win { background: rgba(250, 204, 21, .45) !important; animation: st-beat 1s 2; }
.game-status { text-align: center; font-size: 13.5px; font-weight: 600; }
.game-again { display: block; margin: 8px auto 0; }
.dice-box { display: flex; align-items: center; gap: 12px; padding: 4px 2px; }
.dice-face { font-size: 64px; line-height: 1; display: inline-block; }
.dice-face.rolling { animation: dice-roll .25s linear infinite; }
@keyframes dice-roll { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(.85); } 100% { transform: rotate(360deg) scale(1); } }
.coin-face { font-size: 60px; line-height: 1; display: inline-block; }
.coin-face.flipping { animation: coin-flip 1.4s cubic-bezier(.3, .7, .4, 1); }
@keyframes coin-flip { 0% { transform: translateY(0) rotateY(0); } 50% { transform: translateY(-40px) rotateY(900deg); } 100% { transform: translateY(0) rotateY(1800deg); } }
.game-result { font-weight: 700; }
.game-result small { display: block; font-weight: 400; opacity: .75; }

/* ===== Настройки ===== */
.set-group { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.set-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.avatars.small button { width: 36px; height: 36px; font-size: 19px; }
.color-dots { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dots button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-dots button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--panel-solid), 0 0 0 4px var(--text); }
.skins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.skins button {
  border: 2px solid var(--border); border-radius: 14px; padding: 10px 6px; cursor: pointer; color: #fff; font-weight: 700; font-size: 13px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .5); transition: transform .12s;
}
.skins button:hover { transform: translateY(-2px); }
.skins button[aria-checked="true"] { border-color: var(--text); transform: scale(1.04); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; border: 1px solid var(--border); background: var(--bg2); border-radius: 10px; padding: 8px; cursor: pointer; }
.seg button[aria-checked="true"] { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }
.set-hint { font-size: 12px; color: var(--muted); margin: 0; }
.trust-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 16px; font-size: 13px; }
.trust-links a, .link-btn { color: var(--accent); text-decoration: none; background: none; border: 0; cursor: pointer; padding: 0; font: inherit; font-size: 13px; }
.trust-links a:hover, .link-btn:hover { text-decoration: underline; }
a.btn { display: block; text-align: center; text-decoration: none; color: inherit; }
.about { max-width: 560px; text-align: left; font-size: 14px; line-height: 1.5; }
.about h3 { margin: 10px 0 2px; font-size: 15px; }
.about p { margin: 4px 0; }
.about ul { margin: 4px 0; padding-left: 20px; }
.about li { margin-bottom: 4px; }
.about code { background: var(--bg2); padding: 1px 5px; border-radius: 6px; font-size: 12.5px; }
.hashes {
  white-space: pre-wrap; word-break: break-all; font-size: 11px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px; margin: 6px 0; font-family: ui-monospace, Consolas, monospace;
}
.push-diag { white-space: pre-line; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
.push-diag:empty { display: none; }
.notify-ask { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: 13px; }

/* ===== Звонки ===== */
.btn.accent { background: linear-gradient(135deg, #10b981, #059669); color: #fff; border: 0; }
.call-banner {
  display: flex; align-items: center; gap: 10px; margin: 8px 12px 0; padding: 8px 12px; border-radius: 14px;
  background: rgba(16, 185, 129, .15); border: 1px solid rgba(16, 185, 129, .4); font-size: 13.5px; animation: pop .25s;
}
.call-banner span:nth-child(2) { flex: 1; }
.call-banner-dot { width: 10px; height: 10px; border-radius: 50%; background: #10b981; animation: pulse 1.2s infinite; }

.call-btn {
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; font-size: 24px; color: #fff;
  background: rgba(255, 255, 255, .16); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .12s, background .15s; display: inline-flex; align-items: center; justify-content: center;
}
.call-btn:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .25); }
.call-btn:active { transform: scale(.92); }
.call-btn.off { background: #fff; color: #111; }
.call-btn.off::after { content: ""; position: absolute; width: 34px; height: 3px; background: #ef4444; transform: rotate(-45deg); border-radius: 2px; }
.call-btn { position: relative; }
.call-btn.hang { background: #ef4444; }
.call-btn.hang { font-size: 26px; }
.call-btn.hang::before { content: none; }
#call-hang, #ring-decline { transform: rotate(135deg); }
#call-hang:hover, #ring-decline:hover { transform: rotate(135deg) translateY(2px); }
.call-btn.accept { background: #10b981; animation: wiggle 1s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(-15deg); } 30% { transform: rotate(12deg); } 45% { transform: rotate(-8deg); } 60% { transform: rotate(0); } }

.ring {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: #fff; padding: 24px 16px;
  background: radial-gradient(circle at 50% 35%, #4c1d95 0%, #1e1b4b 55%, #0b0a18 100%); animation: fadein .25s;
}
@keyframes fadein { from { opacity: 0; } }
.ring-waves { position: relative; width: 160px; height: 160px; display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.ring-waves i {
  position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(236, 72, 153, .7);
  animation: ripple 2.4s ease-out infinite;
}
.ring-waves i:nth-child(2) { animation-delay: .8s; }
.ring-waves i:nth-child(3) { animation-delay: 1.6s; }
@keyframes ripple { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.ring-av {
  width: 110px; height: 110px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 58px; box-shadow: 0 0 40px rgba(236, 72, 153, .5); animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.06); } }
.ring-name { font-size: 26px; font-weight: 800; }
.ring-kind { color: rgba(255, 255, 255, .7); }
.ring-actions { display: flex; gap: 34px; margin-top: 40px; }
.ring-act { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: rgba(255, 255, 255, .8); }

.call {
  position: fixed; inset: 0; z-index: 65; background: #07060f; color: #fff; display: flex; flex-direction: column; animation: fadein .25s;
}
.call-top {
  display: flex; justify-content: center; gap: 10px; padding: 14px 16px calc(6px); font-weight: 600;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); z-index: 2;
}
.call-grid {
  flex: 1; min-height: 0; display: grid; gap: 8px; padding: 8px; grid-template-columns: repeat(var(--cols, 1), 1fr);
  grid-auto-rows: 1fr;
}
.tile {
  position: relative; border-radius: 22px; overflow: hidden; min-height: 0;
  background: radial-gradient(circle at 50% 40%, #2e1065, #12101f); transition: box-shadow .15s;
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .3s; }
.tile.has-video video { opacity: 1; }
.tile-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.tile.has-video .tile-ph { display: none; }
.tile-av {
  width: 96px; height: 96px; border-radius: 50%; font-size: 50px; display: flex; align-items: center; justify-content: center;
  transition: transform .12s, box-shadow .12s;
}
.tile.speaking { box-shadow: inset 0 0 0 3px #34d399; }
.tile.speaking .tile-av { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(52, 211, 153, .35), 0 0 30px rgba(52, 211, 153, .5); }
.tile-name {
  position: absolute; left: 10px; bottom: 10px; padding: 4px 10px; border-radius: 999px; font-size: 13px;
  background: rgba(0, 0, 0, .45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.tile-status { position: absolute; top: 10px; left: 0; right: 0; text-align: center; font-size: 12.5px; opacity: .75; }
.call-self {
  position: absolute; right: 14px; bottom: 104px; width: 116px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .25); transform: scaleX(-1); z-index: 3;
  animation: pop .3s;
}
.call-self.back { transform: none; }
.call-unmute {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; padding: 16px 22px; font-size: 16px;
}
.call-controls {
  display: flex; justify-content: center; gap: 16px; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); z-index: 2;
}

/* Дождь из эмодзи */
.rain { position: fixed; top: -50px; z-index: 40; pointer-events: none; font-size: 30px; animation: fall linear forwards; }
.rise { position: fixed; bottom: -50px; z-index: 40; pointer-events: none; font-size: 30px; animation: rise ease-out forwards; }
@keyframes rise { to { transform: translateY(-115vh) translateX(var(--dx, 0)) scale(1.3); opacity: 0; } }
.reactions button.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.35); } }
.msg:not(.mine) { animation-name: in-left; }
.msg.mine { animation-name: in-right; }
@keyframes in-left { from { opacity: 0; transform: translateX(-24px) scale(.96); } }
@keyframes in-right { from { opacity: 0; transform: translateX(24px) scale(.96); } }
.icon-btn { transition: transform .12s, background .15s; }
.icon-btn:hover { transform: translateY(-1px); }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 50;
  background: var(--panel-solid); border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 10px 18px; border-radius: 14px; animation: pop .2s; max-width: calc(100% - 32px); text-align: center;
}
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .85); display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }

/* Конфетти */
.confetti { position: fixed; top: -40px; z-index: 40; pointer-events: none; font-size: 26px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-width: 560px) {
  .card { padding: 24px 18px; }
  .msg { max-width: 92%; }
  .topbar { padding: 10px 12px; gap: 6px; }
  .room-title { font-size: 15px; letter-spacing: 1px; }
  .features { grid-template-columns: 1fr; }
  .actions { opacity: 1; }
  /* На телефоне действия с сообщением — отдельная панель внизу экрана */
  .msg.show-actions .actions {
    position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 10px; border-radius: 20px;
    box-shadow: var(--shadow); animation: pop .18s;
  }
  .msg.show-actions .actions button { font-size: 24px; padding: 8px 10px; min-width: 46px; min-height: 46px; }
  .msg.show-actions .bubble { box-shadow: 0 0 0 2px var(--accent); }
  .hide-sm { display: none; }
  .topbar .icon-btn { width: 34px; height: 34px; font-size: 18px; }
  .call-btn { width: 54px; height: 54px; }
  .call-controls { gap: 12px; }
  .call-self { width: 96px; bottom: 96px; }
  .ring-actions { gap: 22px; }
  .msg:not(.show-actions) .actions { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Язык интерфейса ---------- */
.lang-row { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.lang-select {
  font: inherit; color: inherit; border: 1px solid var(--border); background: var(--bg2);
  border-radius: 10px; padding: 7px 10px; cursor: pointer;
}
.set-group .lang-select { width: 100%; padding: 10px 12px; }

/* Иврит и другие языки справа налево */
[dir="rtl"] .field, [dir="rtl"] .join-details, [dir="rtl"] .about { text-align: right; }
[dir="rtl"] .meta { text-align: left; }
[dir="rtl"] .meta .burn, [dir="rtl"] .meta .edited, [dir="rtl"] .msg .pinned-mark { margin-right: 0; margin-left: 4px; }
[dir="rtl"] .about ul { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .pin-bar { border-left: 0; border-right: 3px solid var(--accent); }
[dir="rtl"] #leave-btn { transform: scaleX(-1); }
