:root {
  --bg: #000;
  --card: #0e0e11;
  --card2: #16161b;
  --line: #24242b;
  --text: #f2f2f5;
  --muted: #8b8b97;
  --accent: #fff;
  --danger: #ff5d6c;
  --ok: #4cd08a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-size: 16px; line-height: 1.4; }
html { min-height: 100%; background-color: var(--bg); background-image: radial-gradient(ellipse at 50% -15%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 55%); background-attachment: fixed; }
body { min-height: 100vh; background: transparent; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
[hidden] { display: none !important; }

.glow { text-shadow: 0 0 8px rgba(255,255,255,.8), 0 0 24px rgba(255,255,255,.5); animation: pulse 2.4s ease-in-out infinite alternate; }
@keyframes pulse { from { text-shadow: 0 0 6px rgba(255,255,255,.5), 0 0 16px rgba(255,255,255,.3); }
                   to   { text-shadow: 0 0 10px rgba(255,255,255,.95), 0 0 32px rgba(255,255,255,.6); } }
.brand { font-weight: 900; font-size: 26px; letter-spacing: 1px; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer;
  background: var(--accent); color: #000; font-weight: 700; font-size: 15px; padding: 10px 18px; border-radius: 10px; font-family: inherit; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { font-size: 18px; padding: 14px 26px; box-shadow: 0 0 18px rgba(255,255,255,.35); }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 6px; font-family: inherit; }
.link:hover { color: var(--text); }
.link.danger:hover { color: var(--danger); }

/* вход */
.login { min-height: 90vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; }
.login .brand { font-size: 64px; margin: 0; }

/* шапка */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(0,0,0,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.nav { display: flex; align-items: center; gap: 10px; }
.nav a { color: var(--muted); font-size: 15px; padding: 4px 6px; }
.nav a:hover, .nav a.active { color: var(--text); }

.view { max-width: 640px; margin: 0 auto; padding: 16px 12px 60px; display: flex; flex-direction: column; gap: 14px; }

/* карточки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.input { width: 100%; background: var(--card2); border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  padding: 10px 12px; font-size: 16px; font-family: inherit; resize: vertical; }
.input:focus { outline: none; border-color: #555; }

/* создание поста */
.composer { display: flex; flex-direction: column; gap: 10px; }
.composer .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.composer .row .spacer { flex: 1; }
.preview img, .preview video { max-width: 100%; max-height: 280px; border-radius: 10px; display: block; background: #000; }
.progress { height: 6px; background: var(--card2); border-radius: 3px; overflow: hidden; }
.progress-in { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* пост */
.post { display: flex; flex-direction: column; gap: 10px; }
.post-head { display: flex; align-items: center; gap: 10px; }
.who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { margin-left: 6px; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--accent); color: #000; vertical-align: middle; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.avatar.big { width: 72px; height: 72px; font-size: 30px; }
.body { margin: 0; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.media { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; background: #000; display: block; }
.expired { padding: 22px; text-align: center; color: var(--muted); background: var(--card2); border-radius: 10px; }

.reactions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.react { background: var(--card2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 15px; font-family: inherit; }
.react.on { border-color: #fff; box-shadow: 0 0 8px rgba(255,255,255,.35); }
.react:hover { border-color: #666; }

.comments { display: flex; flex-direction: column; gap: 8px; }
.comment { display: flex; gap: 8px; align-items: flex-start; background: var(--card2); border-radius: 10px; padding: 10px; }
.comment.comment-reply { margin-left: 30px; border-left: 2px solid var(--line); }
.comment .c-body { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.comment-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.comment b { margin-right: 2px; }
.comment .body { line-height: 1.45; }
.comment-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.comment-like { background: transparent; border: 1px solid transparent; color: var(--muted); border-radius: 999px; padding: 3px 8px; cursor: pointer; font: inherit; font-size: 13px; }
.comment-like.on { color: var(--text); border-color: var(--line); background: var(--card); }
.comment-form { display: flex; gap: 8px; align-items: center; }
.comment-form .input { flex: 1; min-width: 0; }
.comment-form .btn { white-space: nowrap; }
.comment-form .icon-btn { flex: none; }
.stk { height: 96px; width: auto; max-width: 100%; vertical-align: middle; object-fit: contain; }
.stickers-only .stk { height: 160px; }
.comment .stk { height: auto; width: auto; max-width: min(180px, 100%); max-height: 180px; object-fit: contain; vertical-align: middle; border-radius: 12px; background: rgba(0,0,0,.14); }
.comment .body.stickers-only { display: inline-flex; align-items: center; min-height: 32px; margin: 2px 0 4px; }
.comment .body:not(.stickers-only) .stk { margin: 4px 2px; }
.comment video.stk { display: inline-block; }
.sticker-panel

/* профиль, админка */
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head h2 { margin: 0 0 4px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.users { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--card2); border-radius: 10px; padding: 10px; }
.user-row .info { flex: 1; min-width: 160px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); }
.tag.pending { color: #ffd166; border-color: #ffd166; }
.tag.banned { color: var(--danger); border-color: var(--danger); }
.tag.approved { color: var(--ok); border-color: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--card2); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }

 .profile-achievements, .profile-stats { display: flex; flex-direction: column; gap: 8px; background: var(--card2); border-radius: 10px; padding: 10px; }
.achievement-list { display: flex; flex-wrap: wrap; gap: 6px; }
.achievement { display: inline-flex; flex-direction: column; gap: 2px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.achievement small { max-width: 260px; color: var(--muted); font-size: 11px; }
.profile-stats span { color: var(--muted); font-size: 14px; }
.delete-post { margin-left: auto; padding: 6px 10px; font-size: 13px; color: var(--danger); }
.achievement-create, .achievement-award { display: flex; gap: 8px; }
.achievement-icon { width: 72px; flex: none; text-align: center; font-size: 22px; }
.theme-settings { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border-radius: 10px; background: var(--card2); }
.theme-select { max-width: 180px; }

/* аватарки */
img.avatar { object-fit: cover; display: block; background: var(--card2); }
.avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.setup-ava { display: flex; justify-content: center; }
.login .input { max-width: 320px; text-align: center; }

/* стикеры */
.stk { height: 96px; width: auto; max-width: 100%; vertical-align: middle; object-fit: contain; }
.stickers-only .stk { height: 160px; }
.comment .stk { height: 72px; }
.sticker-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px;
  max-height: 230px; overflow: auto; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.sticker-btn { background: none; border: 0; cursor: pointer; padding: 2px; border-radius: 8px; }
.sticker-btn:hover { background: var(--card); }
.sticker-btn img, .sticker-btn video { width: 100%; height: 64px; object-fit: contain; display: block; pointer-events: none; }
.rich-preview { background: var(--card2); border-radius: 10px; padding: 8px 10px; }
.rich-preview .body { margin: 0; }
.sticker-panel .small { grid-column: 1 / -1; }

/* компактная публикация */
.icon-btn { width: 42px; height: 42px; padding: 0; font-size: 20px; flex: none; }
.post-composer.collapsed { padding: 8px; min-height: 58px; }
.compose-toggle { margin-left: auto; }
.post-composer.collapsed > :not(.compose-toggle) { display: none; }
.post-composer:not(.collapsed) > .compose-toggle { display: none; }
.chat-members-btn { align-self: flex-start; padding: 0; background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.member-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.member-item { display: flex; align-items: center; gap: 6px; padding: 5px 9px; background: var(--card2); border-radius: 999px; font-size: 13px; }
.chat-view { height: calc(100dvh - 74px); min-height: 0; overflow: hidden; padding-bottom: 8px; gap: 8px; }
.chat-view .msgs { flex: 1; min-height: 0; overflow-y: auto; }
.chat-view .chat-composer { position: relative; bottom: auto; flex: none; }
.chat-view > .chat-head, .chat-view > .member-list, .chat-view > .card, .chat-view > button { flex: none; }
.chat-view > .msgs { min-height: 0; }

@media (max-width: 600px) {
  .view.chat-view { height: calc(100dvh - 62px - env(safe-area-inset-top)); padding: 8px; gap: 6px; }
  .chat-head { padding: 9px; }
  .chat-composer { padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
  .chat-input { gap: 6px; }
  .chat-input .input { font-size: 16px; }
  .icon-btn { width: 40px; height: 40px; }
}

.avatar.group { background: var(--card2); border: 1px solid var(--line); font-size: 18px; }
.chat-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.chat-row:hover { border-color: #444; }
.chat-row .meta { flex: 1; min-width: 0; }
.chat-row .t { font-weight: 700; }
.chat-row .last { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-btn { display: flex; align-items: center; gap: 10px; width: 100%; background: var(--card2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 16px; font-family: inherit; text-align: left; }
.person-btn:hover { border-color: #666; }
.people { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.person { display: flex; align-items: center; gap: 10px; padding: 4px 2px; cursor: pointer; }
.chat-head { display: flex; align-items: center; gap: 10px; }
.msgs { display: flex; flex-direction: column; gap: 8px; padding-bottom: 6px; }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.mine { flex-direction: row-reverse; }
.bubble { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; max-width: 78%; overflow-wrap: anywhere; }
.msg.mine .bubble { background: #fff; color: #000; border-color: #fff; }
.bname { font-size: 12px; font-weight: 700; margin-bottom: 2px; color: var(--muted); }
.mbody { margin: 0; white-space: pre-wrap; }
.mbody.stickers-only .stk { height: 120px; }
.mtime { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.msg.mine .mtime { color: #666; }
.bubble .media { max-height: 300px; margin: 4px 0; }
.chat-composer { position: sticky; bottom: 0; background: rgba(0,0,0,.94); padding: 10px 0 8px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input .input { flex: 1; min-height: 42px; max-height: 120px; }
.chat-input .btn { padding: 10px 12px; }
