/* Club SaaS — визуал в духе Telegram + Instagram. mobile-first */
:root {
  --bg: #ffffff;
  --fg: #0b0b0f;
  --muted: #8a8f98;
  --soft: #f1f2f4;
  --line: #ededf0;
  --tg-blue: #3390ec;
  --tg-out: #eeffde;
  --tg-chatbg: #e7ebf0;
  --ig: linear-gradient(135deg, #feda75 0%, #fa7e1e 25%, #d62976 55%, #962fbf 80%, #4f5bd5 100%);
  --ig-solid: #d62976;
  --danger: #ff3b30;
  --radius: 16px;
  --pill: 999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 150ms;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--fg); line-height: 1.42; -webkit-font-smoothing: antialiased; overflow: hidden; }
a { color: var(--tg-blue); text-decoration: none; }
.ic { width: 22px; height: 22px; flex: 0 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; }

/* ---------- вход (Instagram-onboarding) ---------- */
.screen { max-width: 420px; margin: 0 auto; padding: 28px 22px 40px; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 34px 0 30px; }
.brand .logo { width: 72px; height: 72px; border-radius: 24px; background: var(--ig); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 30px; box-shadow: 0 10px 30px rgba(214,41,118,.35); }
.brand .t { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand .s { font-size: 13px; color: var(--muted); }
h1 { font-size: 27px; font-weight: 800; letter-spacing: -.03em; text-align: center; }
.sub { color: var(--muted); font-size: 14px; margin: 8px 0 24px; text-align: center; }
.card { background: transparent; border: none; padding: 0; }
.card + .card { margin-top: 12px; }
.btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 14px 18px; border-radius: 14px; border: none; background: var(--soft); color: var(--fg); font: inherit; font-size: 15px; font-weight: 650; cursor: pointer; min-height: 52px; text-decoration: none; transition: transform var(--t-fast) var(--ease), filter var(--t-fast) var(--ease); }
.btn:active { transform: scale(.97); }
.btn + .btn { margin-top: 10px; }
.btn.primary { background: #0b0b0f; color: #fff; }
.btn.ok { background: #0b0b0f; color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { min-height: 40px; padding: 9px 14px; font-size: 13.5px; border-radius: 12px; }
.btn.tg, .btn.vk, .btn.max { background: var(--soft); color: var(--fg); }
.btn:disabled { opacity: .5; }
.btn .ic { width: 20px; height: 20px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 20px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.inp { width: 100%; padding: 14px 16px; border: none; border-radius: 14px; font: inherit; font-size: 16px; background: var(--soft); color: var(--fg); min-height: 52px; }
.inp:focus { outline: none; box-shadow: 0 0 0 2px rgba(214,41,118,.35); }
.inp.grow { flex: 1; min-width: 0; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: center; }
.ok-t { color: #34c759; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: var(--pill); background: var(--soft); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.owner { display: flex; align-items: center; gap: 14px; }
.pf-avatar-wrap { position: relative; flex: 0 0 auto; cursor: pointer; }
.pf-avatar-wrap:active { transform: scale(.97); }
.pf-cam { position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%; background: #0b0b0f; color: #fff; display: grid; place-items: center; border: 2px solid #fff; }
.pf-cam .ic { width: 14px; height: 14px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: #e3e6ea; display: grid; place-items: center; font-weight: 700; color: #6b7784; font-size: 22px; overflow: hidden; flex: 0 0 auto; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 36px; height: 36px; font-size: 15px; }
.avatar.xs { width: 30px; height: 30px; font-size: 13px; }
.rows { margin-top: 2px; }
.r { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.r:last-child { border-bottom: none; }
.r .k { color: var(--muted); font-size: 14px; font-weight: 500; }
.r .v { font-size: 14px; font-weight: 600; text-align: right; word-break: break-all; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.dev-note { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- приложение ---------- */
.app { max-width: 680px; margin: 0 auto; height: var(--app-h, 100dvh); display: flex; flex-direction: column; background: #fff; overflow: hidden; }
.appbar { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 6; min-height: 56px; }
.appbar .logo { width: 36px; height: 36px; border-radius: 50%; background: var(--ig); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; flex: 0 0 auto; overflow: hidden; }
.appbar .logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.appbar .who { font-weight: 750; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .btn { min-height: 40px; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; }
.appbar .btn .ic { width: 18px; height: 18px; }
.tabs { display: flex; gap: 6px; padding: 8px 14px; background: #fff; position: sticky; top: 56px; z-index: 5; }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px; border: none; background: transparent; font: inherit; font-size: 14.5px; font-weight: 650; color: var(--muted); border-radius: 12px; cursor: pointer; }
.tab.on { background: var(--soft); color: var(--fg); }

/* ---------- список чатов ---------- */
.rooms { flex: 1; overflow-y: auto; padding: 4px 0 20px; }
.rooms > .row { padding: 8px 14px 12px; }
.room { display: flex; align-items: center; gap: 13px; padding: 9px 14px; cursor: pointer; }
.room:active { background: var(--soft); }
.roomav { width: 56px; height: 56px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; font-weight: 700; font-size: 22px; overflow: hidden; background: #e3e6ea; }
.roomav img { width: 100%; height: 100%; object-fit: cover; }
.room .nm { font-weight: 700; font-size: 15.5px; }
.room .lv { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.room .badge { margin-left: auto; background: var(--tg-blue); color: #fff; font-size: 12px; font-weight: 700; border-radius: var(--pill); padding: 2px 9px; min-width: 22px; text-align: center; }

/* ---------- чат (Telegram) ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--tg-chatbg); }
.msgs { flex: 1; overflow-y: auto; padding: 14px 10px 8px; display: flex; flex-direction: column; gap: 3px; }
.mrow { display: flex; gap: 8px; align-items: flex-end; }
.mrow.me { flex-direction: row-reverse; }
.m { max-width: 80%; padding: 7px 12px 6px; border-radius: 16px; background: #fff; box-shadow: 0 1px 1px rgba(16,35,47,.06); align-self: flex-start; }
.m.me { background: var(--tg-out); }
.m .au { font-size: 13px; font-weight: 650; color: var(--tg-blue); margin-bottom: 1px; cursor: pointer; }
.fwd { font-size: 12.5px; font-weight: 700; color: var(--tg-blue); margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
.fwd .ic { width: 14px; height: 14px; }
.m .bd { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.m .mt { font-size: 11px; color: #9aa3ab; text-align: right; margin-top: 2px; }
.m.del .bd { color: var(--muted); font-style: italic; }
.m .rx { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.m .rx .chip { font-size: 12px; background: rgba(51,144,236,.12); border-radius: var(--pill); padding: 1px 8px; cursor: pointer; }
.m .rx .chip.on { background: rgba(51,144,236,.28); }
.m .acts { display: none; }
.chat .typing { font-size: 12px; color: var(--muted); padding: 0 14px 4px; height: 15px; }
.emoji-pop { display: flex; gap: 6px; padding: 6px 0 0; }
.emoji-pop button { border: none; background: var(--soft); border-radius: 50%; width: 34px; height: 34px; font-size: 17px; cursor: pointer; }
.quote { border-left: 3px solid var(--tg-blue); background: rgba(51,144,236,.08); border-radius: 6px; padding: 3px 8px; margin-bottom: 4px; font-size: 12.5px; cursor: pointer; }
.quote .qa { display: block; font-weight: 700; color: var(--tg-blue); }
.quote .qb { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 58vw; }
.reply-bar, .pinned-bar { display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: #fff; border-top: 1px solid var(--line); cursor: pointer; }
.pinned-bar { background: #fffdf2; border-top: none; border-bottom: 1px solid var(--line); }
.reply-bar .qa, .pinned-bar .qa { font-weight: 700; font-size: 12.5px; color: var(--tg-blue); display: block; }
.reply-bar .qb, .pinned-bar .qb { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar .rb-body, .pinned-bar .pb-body { flex: 1; min-width: 0; }
.reply-bar .rb-x, .pinned-bar .pb-x { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 16px; padding: 4px 6px; }
.pinned-bar .ic { width: 16px; height: 16px; }

/* композер */
.composer { display: flex; align-items: center; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); position: sticky; bottom: 0; }
.composer .inp { background: var(--soft); border-radius: var(--pill); min-height: 44px; padding: 11px 16px; font-size: 15px; }
.composer .inp:focus { box-shadow: none; }
.composer .btn { border: none; background: none; min-height: 44px; padding: 8px; color: var(--muted); border-radius: 50%; width: 44px; }
.composer .btn .ic { width: 23px; height: 23px; }
.composer .btn.primary { background: #0b0b0f; color: #fff; width: 46px; height: 46px; padding: 0; }
.composer .btn.primary .ic { width: 20px; height: 20px; }

/* вложения */
.atts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.att-img { max-width: 240px; max-height: 320px; border-radius: 12px; display: block; }
.att-vid { max-width: 260px; border-radius: 12px; background: #000; display: block; }
.att-aud { max-width: 240px; display: block; }
.att-file { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.05); border-radius: 12px; padding: 10px 12px; color: var(--fg); }
.att-file .fn { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.att-file .fs { font-size: 11px; color: var(--muted); margin-left: auto; }
.att-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; max-width: 264px; }
.att-grid a { display: block; }
.att-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.att-ico { width: 30px; height: 30px; border-radius: 8px; background: var(--tg-blue); color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.att-ico .ic { width: 16px; height: 16px; }

/* голосовые */
#btn-mic.on { color: var(--danger); }
.rec-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-top: 1px solid var(--line); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }
.rec-bar #rec-time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.rec-bar .btn { width: auto; margin-left: auto; }
.voice { display: flex; align-items: center; gap: 9px; min-width: 190px; }
.v-play { border: none; background: var(--tg-blue); color: #fff; border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.v-play .ic { width: 18px; height: 18px; }
.v-play:active { transform: scale(.94); }
.v-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 22px; }
.v-wave i { flex: 1; height: 6px; border-radius: 2px; background: rgba(51,144,236,.35); }
.v-wave i:nth-child(2n) { height: 12px; } .v-wave i:nth-child(3n) { height: 18px; } .v-wave i:nth-child(4n) { height: 9px; }
.v-wave.playing i { animation: wv .8s infinite alternate; }
@keyframes wv { from { background: rgba(51,144,236,.35) } to { background: var(--tg-blue) } }
.v-time { font-size: 12px; color: var(--muted); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.m.flash { box-shadow: 0 0 0 2px var(--tg-blue); }
.m { user-select: none; -webkit-user-select: none; }

/* ---------- лента (Instagram) ---------- */
.feed { flex: 1; overflow-y: auto; padding: 0 0 24px; background: #fff; }
.stories { display: flex; gap: 14px; overflow-x: auto; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.story { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; flex: 0 0 auto; width: 70px; }
.story .sring { width: 64px; height: 64px; border-radius: 50%; padding: 3px; background: var(--ig); }
.story .sring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid #fff; display: block; }
.story span { font-size: 11.5px; color: var(--fg); max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story:active .sring { transform: scale(.95); }
.story.seen .sring { background: #d3d7db; }
.story.seen span { color: var(--muted); }
#pc { padding: 14px; border-bottom: 1px solid var(--line); }
#pc textarea { width: 100%; border: none; font-size: 15px; resize: none; font-family: inherit; }
#pc textarea:focus { outline: none; }
.pc-attach { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; font-weight: 650; color: var(--ig-solid); cursor: pointer; }
.pc-attach .ic { width: 17px; height: 17px; }
#pc .row { margin-top: 10px; }
.post { padding: 14px 14px 6px; border-bottom: 1px solid var(--line); }
.phead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.phead .nm { font-weight: 700; font-size: 14px; }
.phead .tm { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.p-more { border: none; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 3px 6px; }
.pbody { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 8px; }
.media { width: 100%; border-radius: 12px; background: #000; display: block; max-height: 480px; object-fit: contain; }
.pmedia { margin: 4px 0 8px; }
.poll { margin: 6px 0 4px; }
.poll .q { font-weight: 700; font-size: 14.5px; margin-bottom: 8px; }
.poll-opt { position: relative; width: 100%; text-align: left; border: none; background: var(--soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; font: inherit; font-size: 14px; overflow: hidden; }
.poll-opt .bar { position: absolute; inset: 0 auto 0 0; background: rgba(214,41,118,.14); width: 0; }
.poll-opt .lab { position: relative; display: flex; justify-content: space-between; gap: 10px; }
.poll-opt.on { box-shadow: inset 0 0 0 2px var(--ig-solid); }
.poll .tot { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.preacts { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.preacts .chip { font-size: 13px; background: var(--soft); border-radius: var(--pill); padding: 4px 10px; cursor: pointer; }
.preacts .chip.on { background: rgba(214,41,118,.14); }
.react-add { border: none; background: none; cursor: pointer; color: var(--fg); display: inline-flex; padding: 2px; }
.react-add .ic { width: 22px; height: 22px; }
.linkbtn { border: none; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 8px 0 0; text-align: left; display: inline-flex; align-items: center; gap: 6px; }
.comments { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.cmt { display: flex; gap: 6px; font-size: 13.5px; padding: 3px 0; }
.cmt .au { font-weight: 700; flex: 0 0 auto; }
.cmt .bd { overflow-wrap: anywhere; }
.crow { display: flex; gap: 8px; margin-top: 8px; }
.crow .inp { border-radius: var(--pill); background: var(--soft); min-height: 42px; }
.pmedia audio { width: 100%; }
.feed .empty { padding: 40px 14px; }

/* сторис-просмотр */
.story-ov { position: fixed; inset: 0; z-index: 90; background: rgba(6,8,12,.92); display: flex; align-items: center; justify-content: center; padding: 16px; animation: ovIn .18s var(--ease); }
.story-box { width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 22px; overflow: hidden; }
.sv-head { display: flex; align-items: center; gap: 10px; padding: 14px; }
.sv-av { width: 38px; height: 38px; border-radius: 50%; background: var(--ig); color: #fff; display: grid; place-items: center; font-weight: 700; overflow: hidden; }
.sv-av img { width: 100%; height: 100%; object-fit: cover; }
.sv-au { font-weight: 700; font-size: 14.5px; flex: 1; }
.sv-t { font-size: 11px; color: var(--muted); font-weight: 500; }
.sv-x { border: none; background: none; cursor: pointer; font-size: 17px; color: var(--muted); }
.sv-media { width: 100%; max-height: 60vh; object-fit: contain; background: #000; display: block; }
.sv-cap { padding: 14px; font-size: 15px; white-space: pre-wrap; }
.sv-link { margin: 0 14px 12px; width: auto; display: inline-flex; }
.sv-poll { padding: 0 14px 12px; }
.sv-reacts { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sv-emoji { display: flex; gap: 6px; }
.sv-emoji button { border: none; background: var(--soft); border-radius: 50%; width: 38px; height: 38px; font-size: 19px; cursor: pointer; }
.sv-rx { font-size: 13px; color: var(--muted); }

/* ---------- сторис: полноэкранный просмотр ---------- */
.story-ov { position: fixed; inset: 0; z-index: 90; background: #000; display: flex; align-items: center; justify-content: center; }
.s2 { position: relative; width: 100%; max-width: 430px; height: 100%; background: #000; color: #fff; overflow: hidden; }
@media (min-width: 640px) { .story-ov { background: rgba(0,0,0,.92); } .s2 { height: 90vh; border-radius: 18px; } }
.s2-progress { position: absolute; top: 8px; left: 10px; right: 10px; display: flex; gap: 4px; z-index: 4; }
.s2-progress .seg { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.35); overflow: hidden; }
.s2-progress .seg i { display: block; height: 100%; width: 0; background: #fff; }
.s2-progress .seg i.full { width: 100%; }
.s2-progress .seg i.run { animation: storybar linear forwards; }
@keyframes storybar { from { width: 0 } to { width: 100% } }
.s2-head { position: absolute; top: 20px; left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; z-index: 3; }
.s2-av { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; background: #333; display: grid; place-items: center; font-weight: 700; }
.s2-av img { width: 100%; height: 100%; object-fit: cover; }
.s2-au { flex: 1; font-weight: 700; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.s2-t { font-size: 11px; opacity: .85; font-weight: 500; }
.s2-x { border: none; background: none; color: #fff; font-size: 20px; cursor: pointer; }
.s2-body { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.s2-media { width: 100%; height: 100%; object-fit: contain; }
.s2-sheet { position: absolute; left: 12px; right: 12px; bottom: 74px; z-index: 3; display: flex; flex-direction: column; gap: 10px; max-height: 60%; overflow-y: auto; }
.s2-cap { font-size: 15px; white-space: pre-wrap; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.s2-link { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; background: rgba(255,255,255,.18); color: #fff; padding: 9px 14px; border-radius: 999px; font-weight: 650; font-size: 13.5px; text-decoration: none; }
.s2-link .ic { width: 16px; height: 16px; }
.s2-sheet .poll-opt { background: rgba(255,255,255,.14); color: #fff; }
.s2-sheet .poll-opt .bar { background: rgba(255,255,255,.3); }
.s2-sheet .poll .q, .s2-sheet .poll .tot { color: #fff; }
.s2-foot { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 10px; z-index: 3; }
.s2-foot .sv-emoji { display: flex; gap: 8px; }
.s2-foot .sv-emoji button { border: none; background: rgba(255,255,255,.2); border-radius: 50%; width: 40px; height: 40px; font-size: 20px; cursor: pointer; }
.s2-foot .sv-rx { font-size: 13px; opacity: .9; }
.s2-zone { position: absolute; top: 60px; bottom: 66px; z-index: 2; cursor: pointer; }
.s2-zone.left { left: 0; width: 32%; }
.s2-zone.right { right: 0; width: 68%; }

/* экраны-оверлеи занимают весь объём */
#profile-view, #plans-view, #admin-view { flex: 1; min-height: 0; }
#adm-tabs { position: static; top: auto; overflow-x: auto; flex-wrap: nowrap; padding: 10px 12px 6px; gap: 6px; scrollbar-width: none; }
#adm-tabs::-webkit-scrollbar { display: none; }
#adm-tabs .tab { flex: 0 0 auto; padding: 8px 14px; border-bottom: none; border-radius: var(--pill); }
#adm-tabs .tab.on { background: var(--soft); color: var(--fg); border-bottom: none; }

/* нижняя навигация (новый Telegram) */
.bottomnav { display: flex; flex: 0 0 auto; border-top: 1px solid var(--line); background: #fff; padding-bottom: env(safe-area-inset-bottom); }
.bottomnav .navi { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border: none; background: none; font: inherit; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; }
.bottomnav .navi .ic { width: 24px; height: 24px; }
.bottomnav .navi.on { color: var(--tg-blue); }

/* ---------- раскладка: контейнеры ---------- */
.appmain { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.appcontent { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card { background: var(--soft); border-radius: 14px; padding: 12px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--fg); cursor: pointer; }
.chk input { width: 18px; height: 18px; }
.stat-v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat-t { font-size: 12px; color: var(--muted); }

/* ---------- десктоп: как web.telegram (левая панель + контент) ---------- */
@media (min-width: 1024px) {
  body { background: #fafafa; }
  .app { flex-direction: row; max-width: none; box-shadow: 0 0 60px rgba(0,0,0,.06); }
  #tabs { order: -1; flex-direction: column; width: 90px; border-top: none; border-right: 1px solid var(--line); padding: 16px 8px; gap: 4px; justify-content: flex-start; }
  #tabs .navi { padding: 12px 4px; font-size: 12px; }
  #tabs .navi .ic { width: 26px; height: 26px; }
  .feed .post, #pc, .stories { max-width: 680px; margin-left: auto; margin-right: auto; }
  .appcontent.split { flex-direction: row; }
  .appcontent.split .rooms-view { flex: 0 0 340px; border-right: 1px solid var(--line); overflow-y: auto; }
  .appcontent.split .chat-view { flex: 1; }
  .appcontent.split .feed-view { display: none; }
}

/* участники */
.members { flex: 1; overflow-y: auto; padding: 12px 14px; }
.msearch { margin-bottom: 10px; }
.member { display: flex; align-items: center; gap: 13px; padding: 10px 0; cursor: pointer; border-bottom: 1px solid var(--line); }
.member .nm { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.member .rl { font-size: 11px; color: var(--muted); margin-left: auto; text-transform: uppercase; }
.member .bio { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.member .me-tag { font-size: 10px; color: var(--ig-solid); background: rgba(214,41,118,.12); border-radius: var(--pill); padding: 1px 8px; font-weight: 700; }

/* админка */
.adm-room { border-bottom: 1px solid var(--line); padding: 14px 0; }
.adm-head { display: flex; align-items: center; gap: 10px; }
.adm-bg { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.adm-bg .sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.adm-prev { height: 60px; border-radius: 14px; margin-top: 10px; }
.admsec-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 8px 0 6px; }
.role-sel { width: auto; min-width: 120px; }
.adm-person { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.adm-person .rp-more { font-size: 18px; }

/* меню / модалки / тост */
.msgmenu { position: fixed; z-index: 70; background: #fff; border-radius: 16px; box-shadow: 0 12px 40px rgba(16,35,47,.22); padding: 8px; min-width: 196px; animation: mdIn .15s var(--ease); }
.msgmenu .mm-emoji { display: flex; gap: 6px; padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.msgmenu .mm-emoji button { border: none; background: var(--soft); border-radius: 50%; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
.msgmenu > button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: none; background: none; font: inherit; font-size: 14.5px; font-weight: 600; padding: 10px; border-radius: 10px; cursor: pointer; color: var(--fg); }
.msgmenu > button:hover { background: var(--soft); }
.msgmenu > button.danger { color: var(--danger); }
.msgmenu > button .ic { width: 18px; height: 18px; color: var(--muted); }
.react-add .ic { width: 22px; height: 22px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(6,8,12,.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 80; animation: ovIn .16s var(--ease); }
.modal { width: 100%; max-width: 360px; background: #fff; border-radius: 20px; box-shadow: 0 18px 50px rgba(16,35,47,.26); padding: 20px; animation: mdIn .18s var(--ease); }
.modal h3 { font-size: 17px; font-weight: 750; margin-bottom: 8px; letter-spacing: -.02em; }
.modal p { font-size: 14px; color: var(--muted); margin-bottom: 16px; line-height: 1.5; }
.modal .inp { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal .actions .btn { width: auto; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #16181c; color: #fff; padding: 12px 18px; border-radius: var(--pill); font-size: 13.5px; max-width: 90vw; box-shadow: 0 12px 34px rgba(0,0,0,.3); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease), transform .2s var(--ease); z-index: 95; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* автодополнение @ */
.ac { display: none; }
.ac.show { display: block; margin: 0 14px 6px; border-radius: 16px; background: #fff; box-shadow: 0 10px 30px rgba(16,35,47,.16); overflow: hidden; }
.ac-item { display: flex; align-items: baseline; gap: 8px; padding: 11px 14px; cursor: pointer; }
.ac-item:hover, .ac-item:active { background: var(--soft); }
.ac-n { font-weight: 700; font-size: 14px; color: var(--ig-solid); }
.ac-d { font-size: 12.5px; color: var(--muted); }

.mention { color: var(--ig-solid); font-weight: 650; cursor: pointer; }
.bd a, .pbody a, .cmt .bd a, .bio a { color: var(--tg-blue); word-break: break-word; }

/* анимации */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes riseIn { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }
@keyframes ovIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes mdIn { from { opacity: 0; transform: translateY(6px) scale(.98) } to { opacity: 1; transform: none } }
.mrow { animation: riseIn .2s var(--ease) both; }
.view-in { animation: viewIn .2s var(--ease) both; }
.post { animation: riseIn .22s var(--ease) both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* ---------- эффект реакции (взрыв) ---------- */
.burst { position: fixed; transform: translate(-50%,-50%); font-size: 30px; pointer-events: none; z-index: 120; animation: burstup .9s var(--ease) forwards; }
@keyframes burstup { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.4) } 25% { opacity: 1 } 100% { opacity: 0; transform: translate(-50%,-170%) scale(1.7) } }
.m .rx .chip, .preacts .chip { animation: chipPop .22s var(--ease); }
@keyframes chipPop { from { transform: scale(.6) } to { transform: none } }

/* ---------- конструктор опроса ---------- */
.opt-row { display: flex; gap: 8px; margin-top: 8px; }
.opt-row .inp { flex: 1; min-height: 48px; }
.opt-row .opt-correct, .opt-row .opt-del { width: 48px; min-height: 48px; border: none; border-radius: 12px; background: var(--soft); color: var(--muted); cursor: pointer; display: grid; place-items: center; flex: 0 0 auto; }
.opt-row .opt-correct .ic, .opt-row .opt-del .ic { width: 18px; height: 18px; }
.opt-row .opt-correct.on { background: rgba(52,199,89,.18); color: #1a9e43; }
.poll-opt.correct { box-shadow: inset 0 0 0 2px #34c759; }
#pc .btn { min-height: 48px; }
#pc .poll-opt { min-height: 48px; }

/* ---------- «чувство» приложения ---------- */
* { -webkit-tap-highlight-color: transparent; }
html { overscroll-behavior-y: none; }
.msgs, .rooms, .feed, .members, .stories { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; scrollbar-width: none; }
.msgs::-webkit-scrollbar, .rooms::-webkit-scrollbar, .feed::-webkit-scrollbar, .members::-webkit-scrollbar, .stories::-webkit-scrollbar { display: none; }
button, .btn, .room, .member, .tab, .story, .poll-opt, .chip { touch-action: manipulation; }
.room:active, .member:active { background: var(--soft); }
.mention:active, .linkbtn:active { opacity: .6; }

/* ---------- симпатичные алерты ---------- */
#toast { display: flex; align-items: center; gap: 11px; text-align: left; padding: 12px 16px; border-radius: 16px; background: #16181c; }
#toast .ti { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: rgba(255,255,255,.16); color: #fff; }
#toast .ti .ic { width: 15px; height: 15px; }
#toast.ok .ti { background: #34c759; }
#toast.err .ti { background: var(--danger); }
#toast.info .ti { background: var(--tg-blue); }
#toast .tm { flex: 1; }
.modal .micon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 12px; background: var(--soft); color: var(--fg); }
.modal .micon .ic { width: 22px; height: 22px; }
.modal .micon.danger { background: rgba(255,59,48,.14); color: var(--danger); }
.pf-err { color: var(--danger); font-size: 13.5px; font-weight: 650; margin: 0 0 12px; padding: 11px 14px; background: rgba(255,59,48,.1); border-radius: 12px; display: flex; gap: 8px; align-items: center; }
.pf-err::before { content: '⚠'; font-size: 15px; }
.pview-head { display: flex; align-items: center; gap: 14px; }
.pview-name { font-weight: 750; font-size: 18px; letter-spacing: -.02em; }
.pview-nick { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.pview-bio { font-size: 14.5px; margin-top: 12px; white-space: pre-wrap; }
.pview-bio:empty { display: none; }

/* ---------- полировка: единообразие ---------- */
.brand { margin: 30px 0 24px; }
.card > .pill { margin-bottom: 6px; }
.feed { padding-bottom: 28px; }
.post:last-child { border-bottom: none; }
.composer .btn { width: 44px; height: 44px; }
.composer .btn.primary { width: 44px; height: 44px; }
.tab .ic { width: 20px; height: 20px; }
.rooms { padding-top: 6px; }
.story .sring img { aspect-ratio: 1; }
.appbar .logo { width: 34px; height: 34px; }
.m .mt { margin-top: 3px; }
.poll-opt + .poll-opt { margin-top: 0; }
.comments .crow .btn { width: auto; }

@media (min-width: 900px) {
  body { background: #fafafa; }
  .app { background: #fff; box-shadow: 0 0 60px rgba(0,0,0,.06); }
}
