:root {
  --bg: #050505;
  --panel: rgba(31,31,31,.82);
  --panel-2: rgba(57,57,57,.72);
  --text-base: #ffffff;
  --text: var(--text-base);
  --muted: #9a9a9a;
  --accent: #ffffff;
  --btn-bg: rgba(80,80,80,.85);
  --btn-text: #ffffff;
  --line: rgba(255,255,255,.11);
}
* { box-sizing: border-box; }
html {
  min-height: 100%;
  background: #0a0a0a;
}
body {
  margin: 0;
  min-height: 100vh;
  background: #0a0a0a;
  color: var(--text);
  font: 15px/1.45 Inter, Segoe UI, Arial, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
  position: relative;
}
p, h1, h2, h3, strong, small, .bubble, .post, .room, .chat-title, .chat-preview {
  overflow-wrap: anywhere;
  word-break: break-word;
}
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-corner { background: transparent; }
button, input, textarea { font: inherit; }
button {
  cursor: pointer;
  border: 0;
  color: var(--btn-text);
  background: var(--panel-2);
}
button.primary, .tab.active, #newRoomBtn {
  background: var(--btn-bg);
  color: var(--btn-text) !important;
  font-weight: 800;
}
.hidden { display: none !important; }
/* z-index: 0 + pointer-events:none — не уходит «за» body (белый/серый экран) */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: #0a0a0a;
  background-image: linear-gradient(rgba(0,0,0,.45), rgba(0,0,0,.55)), url("/background.png");
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: saturate(.85);
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.15);
}
#auth, #app, #buildTag {
  position: relative;
  z-index: 1;
}

.text-backdrop {
  background: rgba(0,0,0,.55);
  border-radius: 12px;
  padding: 16px 18px;
  backdrop-filter: blur(6px);
}

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(390px, 100%);
  min-height: 620px;
  padding: 34px 28px;
  border-radius: 26px;
  background: rgba(16,16,16,.76);
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
  backdrop-filter: blur(16px);
}
.auth-logo { width: 88px; height: 88px; object-fit: contain; display: block; margin: 0 auto 12px; border-radius: 20px; }
h1, h2, h3, p { margin-top: 0; }
.auth-card h1 { text-align: center; font-size: 42px; margin-bottom: 6px; }
.auth-card p { text-align: center; color: var(--muted); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 22px 0; }
.tab, .primary, .nav, .profile-actions button, .plans button, #payBasic, #payPremium, #saveProfile {
  border-radius: 8px; padding: 11px 14px; background: rgba(80,80,80,.7);
}
.auth-form { display: grid; gap: 13px; }
label { display: grid; gap: 6px; color: var(--muted); }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); outline: 0; color: var(--text);
  background: rgba(70,70,70,.72); border-radius: 8px; padding: 12px 14px;
}
textarea { min-height: 92px; resize: vertical; }
.code-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.subscription-page { display: grid; gap: 16px; }
.subscription-status {
  padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.04); display: grid; gap: 4px;
}
.subscription-status.active { border-color: rgba(120,255,170,.35); background: rgba(80,180,120,.12); }
.subscription-hint { color: var(--muted); margin: 0; }
.plans { display: grid; gap: 12px; }
.plan-card {
  padding: 16px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.plan-card h3 { margin-bottom: 8px; }
.plan-card ul { margin: 10px 0 0; padding-left: 18px; color: var(--muted); }
.plan-card li { margin-bottom: 4px; }
.video-paywall {
  margin: 24px auto; max-width: 520px; padding: 28px; text-align: center;
  border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,.04);
}
.video-paywall h2 { margin-bottom: 10px; }
.video-paywall p { color: var(--muted); margin-bottom: 18px; }
.profile-stories { margin: 0 0 18px; }
.profile-stories-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.profile-stories-head h3 { margin: 0; }
.profile-stories-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px;
}
.profile-story-card {
  display: grid; gap: 6px; justify-items: center; padding: 0; background: transparent; color: var(--text);
}
.profile-story-thumb {
  width: 92px; height: 92px; border-radius: 14px; border: 2px solid #fff;
  background-size: cover; background-position: center; display: grid; place-items: center;
  box-shadow: 0 0 0 2px #000;
}
.profile-story-text {
  padding: 8px; font-size: 11px; line-height: 1.2; text-align: center;
  background: rgba(255,255,255,.08); overflow: hidden;
}
.story-delete-btn {
  margin-top: 14px; width: 100%; border-radius: 10px; padding: 12px;
  background: rgba(255,80,80,.2); color: #ffb3b3;
}
small { color: var(--muted); }
.app { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 64px 1fr; }
.topbar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: 5;
  height: 64px; display: grid; grid-template-columns: 1fr minmax(220px, 520px) 1fr;
  gap: 18px; align-items: center; padding: 0 30px; background: rgba(18,18,18,.9); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; background: transparent; padding: 0; justify-self: start; color: var(--text); }
.brand img { width: 38px; height: 38px; border-radius: 50%; }
.search-wrap {
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: 520px;
  z-index: 40;
}
.search {
  display: flex; align-items: center; gap: 8px;
  background: rgba(75,75,75,.82); border-radius: 12px;
  padding: 0 10px 0 12px; width: 100%;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.search:focus-within {
  background: rgba(90,90,90,.92);
  border-color: rgba(255,255,255,.18);
  box-shadow: 0 0 0 3px rgba(255,255,255,.06);
}
.search-icon { width: 18px; height: 18px; object-fit: contain; flex: 0 0 auto; opacity: .85; }
.search input {
  border: 0; background: transparent; padding: 12px 0;
  flex: 1; min-width: 0; width: 100%;
  font-size: 15px;
}
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.12); color: var(--text);
  border: 0; cursor: pointer; font-size: 18px; line-height: 1; padding: 0;
}
.search-clear:hover { background: rgba(255,255,255,.2); }
.search-clear.hidden { display: none !important; }

.search-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  max-height: min(70vh, 560px);
  overflow: auto;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(18,18,18,.98);
  box-shadow: 0 22px 50px rgba(0,0,0,.55);
  backdrop-filter: blur(16px);
  display: grid; gap: 4px;
  z-index: 50;
}
.search-panel.hidden { display: none !important; }
.search-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 6px 8px;
}
.search-panel-head strong { font-size: 13px; color: var(--muted); font-weight: 600; }
.search-tabs {
  display: flex; gap: 4px; padding: 0 4px 8px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(rgba(18,18,18,.98), rgba(18,18,18,.96));
  padding-top: 2px;
}
.search-tab {
  border: 0; border-radius: 999px; padding: 7px 12px;
  background: rgba(255,255,255,.06); color: var(--muted);
  font-size: 12px; cursor: pointer; white-space: nowrap;
}
.search-tab:hover { background: rgba(255,255,255,.1); color: var(--text); }
.search-tab.active { background: rgba(255,255,255,.16); color: #fff; }
.search-tab .n {
  margin-left: 4px; opacity: .7; font-variant-numeric: tabular-nums;
}
.search-section-title {
  margin: 8px 6px 4px; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
}
.search-item {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
  padding: 4px; border-radius: 12px;
  background: transparent; color: var(--text); border: 0;
}
.search-item-main {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  text-align: left; padding: 8px 10px; border-radius: 10px;
  background: transparent; color: var(--text); border: 0; cursor: pointer;
}
.search-item:hover,
.search-item.active,
.search-item-main:hover,
.search-item-main.active {
  background: rgba(255,255,255,.1);
}
.search-item:hover .search-item-main,
.search-item.active .search-item-main { background: transparent; }
.search-item .search-item-body,
.search-item-main .search-item-body { min-width: 0; flex: 1; }
.search-item strong,
.search-item-main strong { display: block; font-size: 14px; line-height: 1.25; }
.search-item small,
.search-item-main small {
  display: block; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--muted); font-size: 12px; margin-top: 2px;
}
.search-item-tag {
  font-weight: 500; color: var(--muted); font-size: 12px;
}
.search-item mark {
  background: rgba(255,220,100,.28); color: inherit;
  border-radius: 3px; padding: 0 2px;
}
.search-item-meta {
  flex: 0 0 auto; color: var(--muted); font-size: 11px; white-space: nowrap;
}
.search-item-actions {
  display: flex; gap: 4px; flex: 0 0 auto;
}
.search-item-actions button {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.1); color: var(--text);
  border: 0; cursor: pointer; display: grid; place-items: center; font-size: 14px;
}
.search-item-actions button:hover { background: rgba(255,255,255,.18); }
.search-empty {
  color: var(--muted); font-size: 13px; margin: 0; padding: 18px 12px; text-align: center; line-height: 1.45;
}
.search-hint {
  color: var(--muted); font-size: 12px; margin: 0; padding: 8px 10px 4px; line-height: 1.4;
}
.search-recent-title {
  margin: 4px 6px; font-size: 12px; color: var(--muted);
}
.search-recent-row {
  display: flex; align-items: center; gap: 6px;
}
.search-recent-row .search-item { flex: 1; }
.search-recent-del {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
  background: transparent; color: var(--muted); border: 0; cursor: pointer;
}
.search-recent-del:hover { background: rgba(255,255,255,.1); color: #fff; }
.post-highlight {
  outline: 2px solid rgba(255,255,255,.35);
  box-shadow: 0 0 0 6px rgba(255,255,255,.08);
  transition: outline .2s, box-shadow .2s;
}
.top-actions { justify-self: end; display: flex; gap: 10px; align-items: center; }
.top-actions button { width: 38px; height: 38px; border-radius: 50%; }
.logout-btn {
  width: auto;
  min-width: 72px;
  height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255,255,255,.1);
}
.logout-btn:hover { background: rgba(255,255,255,.18); }
.top-menu-wrap { position: relative; }
.top-menu {
  position: absolute; right: 0; top: 46px; z-index: 30;
  width: 220px; padding: 8px; display: grid; gap: 4px;
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(18,18,18,.97); box-shadow: 0 18px 42px rgba(0,0,0,.5);
  backdrop-filter: blur(14px);
}
.top-menu button {
  width: 100%; height: auto; min-height: 40px; border-radius: 8px;
  padding: 10px 12px; text-align: left; background: transparent; color: var(--text);
}
.top-menu button:hover { background: rgba(255,255,255,.12); }
.top-menu .logout-btn { margin-top: 6px; border-top: 1px solid var(--line); color: #ff6b6b; }
.sidebar { display: none; }
.nav { width: 100%; text-align: left; margin-bottom: 9px; }
.nav.active { background: rgba(255,255,255,.18); }
.view { width: min(900px, 100%); margin: 0 auto; padding: 24px 18px 80px; }
.feed-view { position: relative; }
.stories-shell {
  position: sticky; top: 64px; z-index: 3;
  margin-bottom: 18px; padding: 12px 14px 10px;
  border-radius: 20px; border: 1px solid var(--line);
  background: rgba(10,10,10,.82); backdrop-filter: blur(14px);
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
  transition: transform .25s, opacity .25s;
}
.stories-shell.collapsed { transform: translateY(-110px); opacity: 0; pointer-events: none; }
.stories {
  display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 8px;
  transition: transform .25s, opacity .25s;
  align-items: flex-start; scrollbar-width: none;
}
.stories::-webkit-scrollbar { display: none; }
.stories-list { display: contents; }
.story-add { flex-shrink: 0; }

.story {
  min-width: 76px; max-width: 76px; display: grid; justify-items: center; gap: 8px;
  background: transparent; color: var(--text); padding: 0;
}
.story small {
  width: 100%; text-align: center; font-size: 11px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.story-ring {
  display: grid; place-items: center; padding: 3px; border-radius: 50%;
  background: rgba(255,255,255,.18);
}
.story-ring.has-story { background: var(--accent, #ffffff); }
.story-ring .avatar { border: 3px solid rgba(8,8,8,.95); box-shadow: none; }
.story-ring-add { background: rgba(255,255,255,.12); }
.story-add-circle {
  border: 0; background: rgba(255,255,255,.08);
  font-size: 30px; line-height: 1; color: var(--text);
}
.story-add:hover .story-add-circle { background: rgba(255,255,255,.16); transform: scale(1.03); }
.story:hover .story-ring.has-story { filter: brightness(1.08); }
.story .avatar.mid { width: 64px; height: 64px; min-width: 64px; min-height: 64px; font-size: 22px; }
.feed-empty {
  position: relative; overflow: hidden; text-align: center;
  padding: 42px 28px 36px; border-radius: 22px;
  border: 1px solid var(--line); background: rgba(12,12,12,.78);
  backdrop-filter: blur(12px); box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.feed-empty-glow {
  position: absolute; inset: -30% auto auto 50%; width: 280px; height: 280px;
  transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.12), transparent 68%);
  pointer-events: none;
}
.feed-empty-icon {
  position: relative; width: 72px; height: 72px; margin: 0 auto 18px;
  border-radius: 22px; display: grid; place-items: center;
  font-weight: 900; letter-spacing: .08em; font-size: 13px;
  background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.04));
  border: 1px solid rgba(255,255,255,.14);
}
.feed-empty-title { margin: 0 0 10px; font-size: 22px; }
.feed-empty-text { margin: 0 auto 22px; max-width: 420px; color: var(--muted); line-height: 1.55; }
.feed-empty-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.feed-empty-btn {
  min-width: 148px; border-radius: 12px; padding: 12px 16px;
  background: rgba(255,255,255,.1); color: var(--text);
}
.feed-empty-btn.ghost { background: rgba(255,255,255,.06); }
.feed-empty-btn:hover { background: rgba(255,255,255,.18); }
.feed-empty-profile { padding: 28px 22px; }
.avatar {
  display: grid; place-items: center; border-radius: 50%;
  background: #5a5a5a; color: #fff; font-weight: 900;
  overflow: hidden; flex: 0 0 auto; flex-shrink: 0; line-height: 1;
  box-sizing: border-box;
}
.avatar.has-img { background: #1a1a1a; }
.avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 50%; pointer-events: none;
}
.avatar.small { width: 38px; height: 38px; min-width: 38px; min-height: 38px; max-width: 38px; max-height: 38px; font-size: 15px; }
.avatar.mid { width: 52px; height: 52px; min-width: 52px; min-height: 52px; max-width: 52px; max-height: 52px; font-size: 20px; }
.avatar.big { width: 104px; height: 104px; min-width: 104px; min-height: 104px; max-width: 104px; max-height: 104px; font-size: 40px; margin: auto; }
/* Не сбрасывать фон .avatar — только кнопочные стили */
button.avatar.avatar-btn,
.avatar.avatar-btn {
  padding: 0; border: 0; cursor: pointer; color: inherit;
  background: #5a5a5a;
}
button.avatar.avatar-btn.has-img,
.avatar.avatar-btn.has-img { background: #1a1a1a; }
.top-actions .avatar-btn,
.top-actions button.avatar {
  width: 38px; height: 38px; min-width: 38px; min-height: 38px;
  max-width: 38px; max-height: 38px;
}
.story-thumb { background-size: cover; background-position: center; color: transparent; }
.avatar-preview { margin: 4px 0; }
.avatar-preview .avatar { margin: 0; }
.composer, .post, .search-results, .settings-grid article, .music-view .section-head, .player {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(10px);
}

.composer { padding: 14px; display: grid; gap: 10px; margin-bottom: 16px; }
.composer-actions { display: flex; justify-content: flex-end; gap: 10px; }
.composer-actions button { border-radius: 8px; padding: 11px 14px; }
/* Лента как VK / X: сверху вниз, новые выше */
.feed { display: flex; flex-direction: column; gap: 14px; contain: layout style; }
/* Вне экрана — не красим (дешевле скролл ленты) */
.post {
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
}
.feed-view #feed { min-height: 0; }
.feed-load-more {
  align-self: center;
  width: min(100%, 320px);
  margin: 4px 0 8px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 14px;
  cursor: pointer;
}
.feed-load-more:hover { background: rgba(255,255,255,.14); }
.feed-end {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0 4px;
}
.post { padding: 16px 18px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.post img, .avatar img, .story-bg-img { max-width: 100%; height: auto; }
img[loading="lazy"] { content-visibility: auto; }
.post-head {
  display: flex; gap: 12px; align-items: center; margin-bottom: 12px;
  position: relative;
}
/* Только ник/мета — НЕ аватар (у аватара тоже data-profile) */
.post-head > button[data-profile]:not(.avatar) {
  flex: 1; min-width: 0;
  background: transparent; padding: 0; text-align: left; color: var(--text);
  border: 0; cursor: pointer;
}
.post-head > .avatar,
.post-head > button.avatar {
  flex: 0 0 auto;
  width: 52px; height: 52px;
  min-width: 52px; min-height: 52px;
  max-width: 52px; max-height: 52px;
}
.post-more {
  margin-left: auto;
  flex: 0 0 36px;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-size: 20px; line-height: 1;
  cursor: pointer;
  border: 0;
  padding: 0;
}
.post-more:hover { background: rgba(255,255,255,.16); }
.post-menu {
  position: absolute;
  right: 0; top: 42px;
  z-index: 20;
  min-width: 180px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(22,22,22,.98);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
  display: grid; gap: 4px;
}
.post-menu button {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  border: 0;
  cursor: pointer;
  font-size: 14px;
}
.post-menu button:hover { background: rgba(255,255,255,.1); }
.post-menu button.danger { color: #ff6b6b; }
.post-menu button.danger:hover { background: rgba(255,80,80,.15); }
.post-media { margin-top: 12px; border-radius: 16px; overflow: hidden; }
.post-media-open {
  display: block; width: 100%; padding: 0; border: 0; background: transparent;
  cursor: zoom-in; text-align: left; color: inherit;
}
.post-media img,
.post-media video {
  display: block; width: 100%; max-height: 520px; object-fit: cover;
  pointer-events: none;
}
.post-media-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff;
  border: 2px solid rgba(255,255,255,.9);
  display: grid; place-items: center;
  pointer-events: none;
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
}
.post-media-play svg { display: block; }
.post-media-open.has-video { position: relative; }
.post-text { overflow-wrap: anywhere; word-break: break-word; white-space: pre-wrap; }
.post-actions { display: flex; gap: 8px; color: var(--muted); margin-top: 12px; flex-wrap: wrap; }
.post-actions button {
  border-radius: 8px; padding: 8px 10px;
  background: rgba(255,255,255,.08); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.post-actions button:hover { background: rgba(255,255,255,.16); }
.post-actions .like-btn .heart-icon {
  display: block; flex-shrink: 0; width: 18px; height: 18px;
  transition: transform .15s ease;
}
.post-actions .like-btn .heart-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linejoin: round;
  transition: fill .15s ease, stroke .15s ease;
}
.post-actions .like-btn.liked { color: #ff4d7a; }
.post-actions .like-btn.liked .like-count { color: #ff4d7a; }
.post-actions .like-btn.liked .heart-icon path {
  fill: #ff4d7a;
  stroke: #ff4d7a;
}
.post-actions .like-btn:hover .heart-icon { transform: scale(1.1); }
/* legacy unicode heart (если остался) */
.post-actions .like-btn .heart { color: transparent; -webkit-text-stroke: 1.5px currentColor; text-stroke: 1.5px currentColor; }
.post-actions .like-btn.liked .heart { color: #ff4d7a; -webkit-text-stroke: 0; text-stroke: 0; }
.post-time { margin-left: auto; margin-right: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; align-self: center; }
.post-edit-form { display: grid; gap: 10px; margin: 8px 0 4px; }
.post-edit-input {
  width: 100%; min-height: 88px; resize: vertical; padding: 12px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0,0,0,.25); color: var(--text); font: inherit; line-height: 1.45;
}
.post-edit-preview {
  border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  background: rgba(0,0,0,.2); max-height: 220px;
}
.post-edit-preview img, .post-edit-preview video {
  display: block; width: 100%; max-height: 220px; object-fit: cover;
}
.post-edit-preview.muted { padding: 12px; color: var(--muted); font-size: 13px; }
.post-edit-media-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.post-edit-actions { display: flex; justify-content: flex-end; gap: 8px; }
.post-edit-actions button, .comment-edit-actions button, .msg-edit-actions button {
  border-radius: 8px; padding: 8px 12px; background: rgba(255,255,255,.1); color: var(--text); border: 0; cursor: pointer;
}
.post-edit-actions .primary, .comment-edit-actions .primary, .msg-edit-actions .primary {
  background: rgba(255,255,255,.22);
}
.comment-actions { display: flex; gap: 8px; margin-top: 4px; }
.comment-actions button {
  border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 2px 0; cursor: pointer;
}
.comment-actions button:hover { color: var(--text); }
.comment-actions button.danger { color: #ff6b6b; }
.comment-edited { margin-left: 6px; font-size: 11px; color: var(--muted); font-style: italic; }
.comment-edit-input {
  width: 100%; min-height: 56px; resize: vertical; padding: 8px 10px;
  border-radius: 10px; border: 1px solid var(--line);
  background: rgba(0,0,0,.25); color: var(--text); font: inherit;
}
.comment-edit-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.bubble-content {
  display: block; line-height: 1.35; min-width: 48px;
  position: relative;
}
.bubble-content.has-time {
  padding-bottom: 14px; /* место под время в правом нижнем углу */
  padding-right: 2px;
}
.bubble-content-time-only { min-height: 16px; padding-bottom: 14px; }
.bubble-text {
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  display: inline;
}
/* время — правый нижний угол пузыря (как в Telegram) */
.bubble-content .msg-time-wrap {
  position: absolute;
  right: 0;
  bottom: 0;
  float: none;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(255,255,255,.5);
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}
.msg-edited { font-size: 10px; color: rgba(255,255,255,.42); font-style: italic; }
.bubble-main { display: flex; align-items: flex-start; gap: 6px; position: relative; }
/* замочки E2E в пузырях скрыты */
.bubble .e2e-lock { display: none !important; }

/* Staff admin panel (@ilok) */
.staff-users-list { display: grid; gap: 8px; margin-top: 10px; max-height: 60vh; overflow-y: auto; }
.staff-user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
}
.staff-user-meta { min-width: 0; }
.staff-user-meta strong { display: block; }
.staff-user-meta small { color: var(--muted); }
.staff-user-actions { flex-shrink: 0; display: flex; gap: 6px; }
.staff-admin-page .block-hint { margin-bottom: 12px; }
.msg-edit-inline {
  border: 0; background: transparent; color: rgba(255,255,255,.55);
  font-size: 11px; padding: 2px 4px; border-radius: 6px; white-space: nowrap; cursor: pointer; opacity: .75;
}
.msg-edit-inline:hover { opacity: 1; color: #fff; background: rgba(255,255,255,.1); }
.msg-edit-form { display: grid; gap: 8px; min-width: 180px; }
.msg-edit-input {
  width: 100%; min-height: 64px; resize: vertical; padding: 10px;
  border-radius: 10px; border: 1px solid var(--line);
  background: rgba(0,0,0,.25); color: var(--text); font: inherit;
}
.comment-btn { gap: 6px; }
.comment-btn.active { background: rgba(255,255,255,.18); color: var(--text); }
.comment-count { min-width: 1.1em; opacity: .85; font-variant-numeric: tabular-nums; }
.comment-icon, .chat-icon, .video-icon {
  display: block; object-fit: contain; flex-shrink: 0; pointer-events: none;
}
.comment-icon { width: 16px; height: 16px; opacity: .92; }
.chat-icon, .video-icon { width: 20px; height: 20px; opacity: 1; }
.video-icon { color: #fff; flex-shrink: 0; }
/* По умолчанию скрыто; открывается кнопкой «Комментарии» */
.comment-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
}
.comment-panel.hidden { display: none !important; }
.comment-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.comment-form input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.35);
  color: var(--text);
}
.comment-form button {
  border-radius: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,.16);
  color: var(--btn-text);
}
.comments { display: grid; gap: 10px; max-height: 320px; overflow-y: auto; }
.comments-empty { margin: 0; padding: 4px 2px; color: var(--muted); font-size: 13px; }
.comment-item { display: flex; gap: 10px; align-items: flex-start; }
.comment-body { min-width: 0; }
.comment-author { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
.comment-text { margin: 0; color: var(--muted); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }

.profile-hero {
  position: relative; text-align: center;
  padding: 0; min-height: 220px;
  background-color: rgba(20,20,20,.85);
  background-image: url("/backgroundwebvoid.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.profile-hero::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.08), rgba(0,0,0,.55));
  pointer-events: none;
}
.profile-hero-content {
  position: relative; z-index: 1;
  margin: 16px;
  display: grid; gap: 6px; justify-items: center;
}
.profile-avatar-ring {
  display: grid; place-items: center;
  width: 116px; height: 116px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(0,0,0,.35);
  background: rgba(0,0,0,.25);
}
.profile-avatar-ring .avatar.big {
  width: 100px; height: 100px;
  min-width: 100px; min-height: 100px;
  margin: 0;
}
.profile-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.profile-actions button { border-radius: 8px; padding: 11px 14px; }

.chat-layout {
  width: 100%; max-width: none; min-height: calc(100vh - 64px);
  margin: 0; padding: 0;
  display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0;
}
.chat-list, .chat-panel { height: calc(100vh - 64px); min-height: 620px; background: rgba(25,25,25,.78); border: 1px solid var(--line); }
.chat-list { border-radius: 0; padding: 14px; overflow: auto; }
.chat-panel {
  border-left: 0; border-radius: 0;
  display: grid; grid-template-rows: 64px minmax(0, 1fr) 58px;
  background-color: transparent;
  background-size: cover;
  background-position: center;
}
.chat-list-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.chat-list-head strong { font-size: 18px; }
#newRoomBtn { width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 0; }
.room-empty { color: var(--muted); font-size: 13px; padding: 8px 6px; }
.room { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: transparent; color: var(--text); }
.room.active { background: rgba(255,255,255,.13); }
.online { width: 8px; height: 8px; border-radius: 50%; background: #45ff1d; margin-left: auto; }
.chat-head, .message-form { display: flex; align-items: center; gap: 10px; padding: 0 14px; background: rgba(20,20,20,.72); }
.chat-head span { margin-left: auto; color: var(--muted); font-size: 12px; }
.chat-settings-btn {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  background: rgba(255,255,255,.12); color: var(--text);
  margin-left: auto;
}
.chat-settings-btn:hover { background: rgba(255,255,255,.22); }
.chat-head #cryptoState {
  margin-left: 8px;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-head #cryptoState.e2e-on { color: #7dffb3; }
.chat-head #cryptoState.e2e-off { color: var(--muted); }
.chat-head #cryptoState.e2e-warn { color: #ffd27a; }
.bubble .e2e-lock {
  display: inline-block;
  margin-right: 4px;
  font-size: 11px;
  opacity: .75;
  vertical-align: middle;
}
.messages {
  min-height: 0; padding: 18px; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: transparent transparent;
}
.messages::-webkit-scrollbar { width: 3px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb {
  background: transparent; border-radius: 999px;
  transition: background .15s ease;
}
.messages:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); }
.messages:active::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); }
.chat-list {
  scrollbar-width: thin; scrollbar-color: transparent transparent;
}
.chat-list::-webkit-scrollbar { width: 3px; }
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.chat-list:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }
button[type="submit"]:disabled, button.primary:disabled { opacity: .65; cursor: wait; }
.bubble {
  max-width: 66%; padding: 8px 12px 8px 12px; border-radius: 12px;
  background: rgba(80,80,80,.9); display: block; overflow-wrap: anywhere; color: var(--text);
  position: relative;
}
.bubble.me { align-self: flex-end; background: rgba(120,120,120,.88); }
.bubble.system { align-self: center; background: rgba(255,255,255,.08); color: var(--muted); font-size: 12px; max-width: 80%; text-align: center; }
.bubble .msg-author {
  display: block; color: var(--accent); font-weight: 700;
  margin: 0 0 2px; line-height: 1.2; /* ник сверху, без замочка */
}
.bubble-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.bubble.me .bubble-meta { justify-content: flex-end; }
.bubble:not(.me) .bubble-meta { justify-content: flex-start; }
.msg-time { font-size: 11px; color: rgba(255,255,255,.55); white-space: nowrap; }
.bubble audio { width: 240px; max-width: 60vw; height: 36px; }
.bubble-media { display: block; max-width: 100%; border-radius: 8px; margin-top: 2px; }
.bubble-media img, .bubble-media video { display: block; max-width: 260px; max-height: 320px; border-radius: 8px; object-fit: cover; }
.bubble-media img.chat-zoomable { cursor: zoom-in; }
.message-form { gap: 8px; align-items: center; }
.msg-attach-btn { cursor: pointer; margin: 0; }
.msg-attach-btn input { display: none; }
.message-form input { flex: 1; border: 0; background: rgba(55,55,55,.85); padding: 9px 12px; }
.msg-action-btn {
  width: 34px; height: 34px; min-width: 34px; min-height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: inline-grid; place-items: center; align-self: center;
  background: rgba(255,255,255,.12); color: var(--text); padding: 0;
}
.msg-action-btn:hover { background: rgba(255,255,255,.22); }
.msg-icon { width: 18px; height: 18px; display: block; }
.send-btn {
  width: 42px; height: 42px; min-width: 42px; min-height: 42px; flex: 0 0 42px;
  border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: inline-grid; place-items: center; align-self: center;
  background: var(--accent, #2aabee) !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
  transition: transform .15s ease, filter .15s ease, opacity .15s ease;
}
.send-btn:hover:not(:disabled) { filter: brightness(1.08); transform: scale(1.04); }
.send-btn:active:not(:disabled) { transform: scale(.96); }
.send-btn:disabled { opacity: .45; cursor: wait; box-shadow: none; }
.send-plane { width: 20px; height: 20px; display: block; transform: translateX(1px); }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.danger-btn {
  border-radius: 8px; padding: 11px 14px;
  background: rgba(255,70,70,.18); color: #ffb0b0;
}
.danger-btn:hover { background: rgba(255,70,70,.28); }
.danger-btn.active { background: rgba(255,70,70,.32); color: #fff; }
.blocked-list { display: grid; gap: 10px; }
.blocked-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
}
.blocked-item button { border-radius: 8px; padding: 8px 12px; background: rgba(255,255,255,.1); }
.premium-lock-hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
#voiceBtn.recording { background: #ff4444; color: #fff; animation: pulse 1s infinite; }
.play-btn { min-width: 64px; font-size: 13px; font-weight: 700; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.room-form { display: grid; gap: 12px; }
.room-form select, .room-form input { background: rgba(40,40,40,.8); }
.member-list { display: grid; gap: 6px; max-height: 200px; overflow: auto; }
.member-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.member-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.12); font-size: 13px;
}
.member-chip button { width: 18px; height: 18px; border-radius: 50%; padding: 0; font-size: 12px; background: rgba(255,255,255,.2); color: var(--text); }
.add-users-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.12);
}
.add-users-btn img { width: 20px; height: 20px; opacity: .9; }
.add-users-row { display: flex; align-items: center; gap: 10px; }
.security-form { text-align: left; }
.totp-login-hint { margin: 0 0 6px; font-weight: 700; font-size: 16px; text-align: center; }
.totp-login-sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.45; text-align: center; }
.totp-back-btn { width: 100%; margin-top: 8px; }
.tg-login-switch { width: 100%; margin-top: 4px; }
a.tg-open-bot {
  display: block; text-align: center; text-decoration: none;
  padding: 12px 16px; border-radius: 12px; margin-bottom: 4px;
  box-sizing: border-box;
}
.tg-link-box {
  display: grid; gap: 10px; margin-top: 12px; padding: 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
}
.tg-link-box.hidden { display: none; }
.tg-deep-link {
  word-break: break-all; color: #7ec8ff; font-size: 13px; line-height: 1.4;
}
.telegram-settings .danger-btn { border-color: rgba(255,100,100,.35); color: #ffb4b4; }
.telegram-settings .tg-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.totp-card {
  display: grid; gap: 12px; padding: 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
}
.totp-card h3 { margin: 0; font-size: 16px; }
.totp-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.totp-status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px; font-size: 13px; width: fit-content;
}
.totp-status.on { background: rgba(80,220,140,.14); color: #8dffb8; }
.totp-status.off { background: rgba(255,255,255,.08); color: var(--muted); }
.totp-setup { display: grid; gap: 12px; }
.totp-qr-wrap {
  display: grid; place-items: center; gap: 10px;
  padding: 14px; border-radius: 12px;
  background: #fff; color: #111;
}
.totp-qr-wrap canvas, .totp-qr-wrap img { display: block; width: 200px; height: 200px; }
.totp-secret-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .08em; word-break: break-all;
  padding: 12px; border-radius: 10px;
  background: rgba(0,0,0,.35); border: 1px solid var(--line);
  text-align: center; font-size: 15px; user-select: all;
}
.totp-steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.totp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.totp-actions .primary, .totp-actions button { border-radius: 10px; padding: 11px 14px; }
#totpLoginCode, #totpEnableCode, #totpDisableCode {
  font-size: 22px; letter-spacing: .28em; text-align: center;
  font-variant-numeric: tabular-nums;
}
.security-policy { color: var(--muted); font-size: 13px; }
.security-msg { color: var(--accent); min-height: 16px; font-size: 13px; }
.tracks { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.track { padding: 16px; min-height: 130px; border-radius: 8px; background: rgba(42,42,42,.82); border: 1px solid var(--line); display: grid; align-content: end; color: var(--text); }
.player { position: sticky; bottom: 14px; margin-top: 18px; padding: 12px; display: flex; gap: 14px; align-items: center; }
.player button { width: 44px; height: 44px; border-radius: 50%; }
.settings-view { max-width: 560px; }
.settings-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.settings-head h2 { margin: 0; flex: 1; }
.settings-back {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.1); color: var(--text); font-size: 20px;
}
.settings-back:hover { background: rgba(255,255,255,.18); }
.settings-menu { display: grid; gap: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.settings-menu-section { padding: 10px 16px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: rgba(0,0,0,.15); }
.settings-menu-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; text-align: left; background: transparent; color: var(--text);
  border-bottom: 1px solid var(--line);
}
.settings-menu-item:last-child { border-bottom: 0; }
.settings-menu-item:hover { background: rgba(255,255,255,.08); }
.settings-menu-item strong { font-weight: 600; }
.settings-menu-item small { color: var(--muted); display: block; margin-top: 2px; font-size: 13px; }
.settings-menu-chevron { color: var(--muted); font-size: 18px; flex-shrink: 0; }
.settings-page { display: grid; gap: 12px; padding: 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.settings-block { display: grid; gap: 10px; align-content: start; }
.settings-block h3 { margin: 0 0 4px; }
.block-hint { color: var(--muted); font-size: 13px; margin: 0; }
.preview-line { margin: 4px 0; color: var(--muted); }
.ghost-btn { padding: 10px 14px; border-radius: 8px; background: rgba(255,255,255,.06); color: var(--text); }
.ghost-btn:hover { background: rgba(255,255,255,.14); }
.bg-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bg-preset { height: 56px; border-radius: 10px; border: 2px solid transparent; background-size: cover; background-position: center; cursor: pointer; }
.bg-preset:hover, .bg-preset.active { border-color: var(--accent); }
.nick-styled { display: inline-block; }

.color-picker-wrap { display: flex; align-items: center; gap: 14px; }
.color-preview {
  width: 56px; height: 56px; border-radius: 12px;
  border: 2px solid var(--line); cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  transition: transform .15s;
}
.color-preview:hover { transform: scale(1.05); }
.color-picker-fields { display: grid; gap: 8px; flex: 1; }
.color-picker-fields input[type="color"] {
  width: 100%; height: 42px; padding: 2px; cursor: pointer; border-radius: 8px;
}
.color-picker-fields input[type="text"] { font-family: monospace; }
.accent-text-preview { font-size: 16px; font-weight: 600; color: var(--text); }

.story-modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.92);
  display: grid; place-items: center; padding: 20px;
}
.story-modal.story-modal-fullscreen { padding: 0; background: #000; }
#closeStory {
  position: fixed; top: 18px; right: 22px; z-index: 25;
  width: 44px; height: 44px; border-radius: 50%; font-size: 28px;
  background: rgba(255,255,255,.12); color: #fff;
}
#storyContent { width: min(920px, 100%); max-height: 92vh; overflow-y: auto; }
#storyContent.story-content-fit {
  width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh;
  overflow: hidden; display: grid; place-items: center;
}

.story-form { display: grid; gap: 14px; padding: 26px; background: rgba(24,24,24,.98); border-radius: 18px; border: 1px solid var(--line); }
.story-form textarea { min-height: 180px; background: rgba(20,20,20,.78); }

.story-viewer {
  position: relative; width: 100%;
  border-radius: 18px; overflow: hidden;
  background: #111;
  transition: all .35s ease;
}
.story-viewer.no-image {
  min-height: 80vh; max-height: 92vh;
  background: linear-gradient(160deg, #1a1a1a, #0a0a0a);
}
.story-viewer.story-viewer-fit {
  width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh;
  border-radius: 0; background: #000;
}
.story-canvas { position: relative; width: 100%; height: 100%; }
.story-viewer-fit .story-canvas { width: 100vw; height: 100vh; }
.story-viewer-fit .story-bg-img {
  position: absolute; inset: 0; display: block;
  width: 100%; height: 100%; max-width: 100vw; max-height: 100vh;
  object-fit: contain; z-index: 0;
}
.story-viewer.no-image .story-bg-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0;
}
.story-viewer-inner, .story-main { position: relative; z-index: 1; }
.story-viewer-fit .story-viewer-inner {
  position: absolute; inset: 0; min-height: 0; height: 100%; width: 100%;
}
.story-viewer-fit .story-main { min-height: 0; height: 100%; width: 100%; }
.story-empty-hint {
  display: grid; place-items: center; min-height: 80vh;
  color: rgba(255,255,255,.55); font-size: 15px;
}
.story-viewer-inner {
  display: grid; grid-template-columns: 1fr; height: 100%; min-height: 80vh;
  transition: grid-template-columns .35s ease;
}
.story-viewer-fit .story-viewer-inner { min-height: 0; }
.story-viewer.expanded .story-viewer-inner { grid-template-columns: 1fr 1fr; }
.story-main {
  position: relative; display: flex; flex-direction: column;
  justify-content: space-between; min-height: 80vh; padding: 20px;
}
.story-viewer-fit .story-main { min-height: 0; height: 100%; }
.story-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  align-self: start; max-width: 100%;
}
.story-header-info h2 { margin: 0; font-size: 18px; color: #fff; }
.story-header-info p { margin: 2px 0 0; font-size: 13px; color: rgba(255,255,255,.75); }
.story-text-area { align-self: end; width: 100%; }
.story-text-backdrop {
  position: relative;
  background: rgba(0,0,0,.55);
  border-radius: 12px;
  padding: 14px 16px 14px 16px;
  backdrop-filter: blur(4px);
  transition: opacity .3s ease, transform .3s ease;
}
.story-viewer.expanded .story-main .story-text-backdrop {
  opacity: 0; transform: translateY(12px); pointer-events: none;
}
.story-text {
  margin: 0; color: #fff; font-size: 17px; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 3; overflow: hidden;
  transition: -webkit-line-clamp .3s ease;
}
.story-text.expanded-inline {
  -webkit-line-clamp: unset; overflow: visible;
}
.story-expand-btn {
  position: absolute; right: 10px; bottom: 8px;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff;
  display: grid; place-items: center; font-size: 12px;
  transition: transform .25s, background .25s;
}
.story-expand-btn:hover { background: rgba(255,255,255,.3); }
.story-expand-btn.open { transform: rotate(180deg); }
.story-side-panel {
  background: rgba(12,12,12,.95);
  padding: 28px 24px; overflow-y: auto;
  border-left: 1px solid var(--line);
  opacity: 0; transform: translateX(20px);
  transition: opacity .35s ease, transform .35s ease;
}
.story-viewer.expanded .story-side-panel {
  opacity: 1; transform: translateX(0);
}
.story-side-panel p {
  margin: 0; color: #fff; font-size: 17px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
/* legacy class kept if used elsewhere */
.search-results { padding: 12px; margin-bottom: 16px; display: grid; gap: 6px; }
.search-cat { margin: 8px 0 2px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.1);
}
.icon-btn:hover { background: rgba(255,255,255,.2); }


.context-menu {
  position: fixed; z-index: 60; min-width: 168px; padding: 6px;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(18,18,18,.98); box-shadow: 0 14px 40px rgba(0,0,0,.55);
  backdrop-filter: blur(12px);
}
.context-menu-item {
  width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  background: transparent; color: #ff6b6b; font-size: 14px;
}
.context-menu-item:hover { background: rgba(255,80,80,.15); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  z-index: 999; padding: 12px 22px; border-radius: 999px;
  background: rgba(20,20,20,.96); color: #fff; border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(0,0,0,.5); opacity: 0; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); opacity: 0; transition: opacity .2s; }
.drawer.open .drawer-backdrop { opacity: 1; }
.drawer-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; gap: 10px; padding: 18px 18px 26px;
  background: rgba(22,22,22,.99); border-top-left-radius: 20px; border-top-right-radius: 20px;
  border-top: 1px solid var(--line); box-shadow: 0 -18px 50px rgba(0,0,0,.5);
  transform: translateY(100%); transition: transform .22s ease;
  width: min(560px, 100%); margin: 0 auto;
}
.drawer.open .drawer-sheet { transform: translateY(0); }
.drawer-grip { width: 44px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.3); margin: 0 auto 6px; }
.drawer-sheet h3 { text-align: center; margin: 0 0 4px; color: var(--text); }
.drawer-item {
  width: 100%; text-align: left; padding: 16px; border-radius: 12px; font-size: 16px;
  background: rgba(255,255,255,.07); color: var(--text);
}
.drawer-item:hover { background: rgba(255,255,255,.14); }
.drawer-cancel { width: 100%; padding: 14px; border-radius: 12px; background: transparent; color: var(--muted); }

.photo-pick { display: inline-flex; }
.photo-pick span {
  display: inline-block; padding: 10px 14px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,.08); color: var(--text); border: 1px dashed var(--line);
}
.photo-pick.inline { margin: 2px 0; }
.photo-pick span:hover { background: rgba(255,255,255,.16); }
.image-preview { margin-top: 4px; border-radius: 12px; overflow: hidden; }
.image-preview img { display: block; width: 100%; max-height: 320px; object-fit: cover; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text); }
.toggle {
  position: relative; width: 48px; height: 26px; flex-shrink: 0;
  background: rgba(255,255,255,.15); border-radius: 999px;
  transition: background .25s; cursor: pointer;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .25s;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(22px); }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.room-type-picker { display: grid; gap: 8px; width: min(260px, 100%); padding: 26px; background: rgba(24,24,24,.98); border-radius: 18px; border: 1px solid var(--line); }
.room-type-btn { text-align: left; padding: 14px 16px; border-radius: 12px; font-size: 16px; background: rgba(255,255,255,.08); color: var(--text); }
.room-type-btn:hover { background: rgba(255,255,255,.16); }
.room-card { display: grid; gap: 12px; justify-items: stretch; padding: 26px; background: rgba(24,24,24,.98); border-radius: 18px; border: 1px solid var(--line); }
.room-card h2 { text-align: center; margin: 0; color: var(--text); }
.room-photo { justify-self: center; }
.room-photo-circle {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.12); font-size: 14px; cursor: pointer; overflow: hidden; color: var(--muted);
}
.room-photo-circle img { width: 100%; height: 100%; object-fit: cover; }
.room-field { background: rgba(255,255,255,.08); border-radius: 18px; }
.dm-picker { display: grid; gap: 10px; padding: 26px; background: rgba(24,24,24,.98); border-radius: 18px; border: 1px solid var(--line); }
.dm-picker h2 { margin: 0; color: var(--text); }
.dm-search { margin-bottom: 4px; }
.dm-list { display: grid; gap: 6px; max-height: 60vh; overflow-y: auto; }
.dm-pick { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.06); color: var(--text); }
.dm-pick:hover { background: rgba(255,255,255,.14); }

.bg-cropper { display: grid; gap: 14px; padding: 26px; background: rgba(24,24,24,.98); border-radius: 18px; border: 1px solid var(--line); }
.bg-cropper h2 { margin: 0; text-align: center; }
.bg-crop-hint { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.bg-crop-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 5;
  border-radius: 10px; overflow: hidden; border: 2px solid var(--accent);
  background: #111; cursor: grab; touch-action: none; user-select: none;
}
.bg-crop-frame.dragging { cursor: grabbing; }
.bg-crop-frame img {
  position: absolute; top: 50%; left: 50%;
  transform-origin: center center; pointer-events: none;
  max-width: none;
}
.bg-crop-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.user-search-modal { display: grid; gap: 12px; padding: 26px; background: rgba(24,24,24,.98); border-radius: 18px; border: 1px solid var(--line); }
.user-search-modal h3 { margin: 0; color: var(--text); }
.user-search-results { display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; }

.image-lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: #000;
  display: grid; place-items: center; padding: 0;
}
.media-lightbox-body {
  width: 100vw; height: 100vh;
  display: grid; place-items: center;
}
.image-lightbox img,
.image-lightbox video {
  width: 100vw; height: 100vh;
  max-width: 100vw; max-height: 100vh;
  object-fit: contain;
  border-radius: 0;
}
.bubble-media video.chat-zoomable { cursor: zoom-in; }
#closeLightbox {
  position: fixed; top: 18px; right: 22px; z-index: 51;
  width: 44px; height: 44px; border-radius: 50%; font-size: 28px;
  background: rgba(255,255,255,.12); color: #fff;
}
.chat-settings-form { display: grid; gap: 12px; padding: 26px; background: rgba(24,24,24,.98); border-radius: 18px; border: 1px solid var(--line); max-height: 85vh; overflow-y: auto; }
.chat-settings-form h2 { margin: 0; text-align: center; }
.chat-settings-form .admin-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.06); }
.btn-preview-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-preview-sample { border-radius: 8px; padding: 10px 16px; }

.video-view, .shorts-view { width: min(1280px, 100%); max-width: none; }
.video-home-actions {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: flex-end;
}
.video-upload-btn { white-space: nowrap; }
.video-home-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.video-home-head h2 { margin: 0; }
.video-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.video-tab {
  border-radius: 999px; padding: 8px 14px;
  background: rgba(255,255,255,.08); color: var(--text);
}
.video-tab.active { background: var(--btn-bg); font-weight: 800; }
.video-section { margin-bottom: 28px; }
.video-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 10px;
}
.video-section-head h3 { margin: 0; font-size: 18px; }
.video-section-head small { color: var(--muted); }
.shorts-row {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}
.video-card {
  display: grid; gap: 10px; text-align: left; background: transparent;
  color: var(--text); padding: 0; border: 0; width: 100%;
}
.video-card:hover .video-thumb { border-color: rgba(255,255,255,.35); }
.video-thumb {
  position: relative; border-radius: 12px; overflow: hidden;
  background: rgba(20,20,20,.9); border: 1px solid var(--line);
  aspect-ratio: 16 / 9;
}
.video-thumb.vertical { aspect-ratio: 9 / 16; }
.video-thumb img, .video-thumb video {
  display: block; width: 100%; height: 100%; object-fit: cover;
}
.video-thumb .duration {
  position: absolute; right: 8px; bottom: 8px;
  padding: 2px 6px; border-radius: 6px;
  background: rgba(0,0,0,.82); font-size: 12px; font-weight: 700;
}
.video-meta strong {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; font-size: 15px; line-height: 1.35;
}
.video-meta small { color: var(--muted); display: block; margin-top: 4px; }
.video-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px 14px;
}
.shorts-card {
  flex: 0 0 150px; scroll-snap-align: start;
}
.shorts-card .video-thumb { border-radius: 14px; }
.shorts-card .video-meta strong { font-size: 13px; -webkit-line-clamp: 2; }

.video-watch {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start;
}
.video-player-wrap {
  position: relative;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; backdrop-filter: blur(10px);
}
.video-player-wrap.horizontal video {
  display: block; width: 100%; aspect-ratio: 16 / 9; background: #000;
  object-fit: contain;
}
.video-tap-layer {
  position: absolute; inset: 0 0 48px 0; z-index: 2;
  cursor: pointer;
}
.video-sound-btn {
  position: absolute; right: 12px; bottom: 52px; z-index: 3;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.62); color: #fff; border: 1px solid rgba(255,255,255,.2);
  font-size: 18px; cursor: pointer;
}
.video-sound-btn:hover { background: rgba(0,0,0,.82); }
.video-unmute {
  position: absolute; z-index: 4; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 18px; border-radius: 999px;
  background: rgba(0,0,0,.72); color: #fff; border: 1px solid rgba(255,255,255,.25);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.video-unmute:hover { background: rgba(0,0,0,.88); }
.video-player-wrap.vertical { max-width: 420px; margin: 0 auto; }
.video-player-wrap.vertical video { display: block; width: 100%; aspect-ratio: 9 / 16; background: #000; }
.video-watch-info { padding: 14px 0 0; }
.video-watch-info h2 { margin: 0 0 8px; font-size: 20px; line-height: 1.35; }
.video-watch-channel {
  display: flex; align-items: center; gap: 12px; margin: 12px 0;
  padding: 12px; border-radius: 10px; background: rgba(255,255,255,.06);
}
.video-watch-channel button { background: transparent; padding: 0; text-align: left; color: var(--text); }
.video-watch-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.video-watch-actions button {
  border-radius: 999px; padding: 8px 14px;
  background: rgba(255,255,255,.1); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.video-watch-actions button.liked { background: rgba(255,255,255,.22); }
.video-watch-desc {
  padding: 12px 14px; border-radius: 10px;
  background: rgba(255,255,255,.06); color: var(--muted);
  white-space: pre-wrap; line-height: 1.45;
}
.video-comments {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}
.video-comments h3 {
  margin: 0 0 12px; font-size: 16px;
}
.video-comments h3 span { color: var(--muted); font-weight: 600; }
.video-comment-form { margin-bottom: 14px; }
.video-comments-empty {
  margin: 0; padding: 12px 0; color: var(--muted); font-size: 14px;
}
.video-recs { display: grid; gap: 12px; }
.video-recs h3 { margin: 0 0 4px; font-size: 16px; }
.video-rec-item {
  display: grid; grid-template-columns: 168px 1fr; gap: 10px;
  text-align: left; background: transparent; color: var(--text); padding: 0; border: 0;
}
.video-rec-item .video-thumb { border-radius: 10px; }
.video-rec-item .video-meta strong { font-size: 14px; }
.video-back-btn {
  margin-bottom: 14px; border-radius: 8px; padding: 10px 14px;
  background: rgba(255,255,255,.1); color: var(--text);
}

.shorts-view { width: 100%; max-width: none; margin: 0; padding: 0; min-height: calc(100vh - 64px); }
.shorts-player {
  height: calc(100vh - 64px); overflow-y: scroll; scroll-snap-type: y mandatory;
  background: #000;
}
.shorts-slide {
  position: relative; height: calc(100vh - 64px); scroll-snap-align: start;
  display: grid; place-items: center; background: #000;
}
.shorts-slide video {
  width: 100%; max-width: 480px; height: 100%; max-height: calc(100vh - 64px);
  object-fit: contain; background: #000; cursor: pointer;
}
.shorts-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 18px 16px 28px;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  pointer-events: none;
}
.shorts-overlay * { pointer-events: auto; }
.shorts-overlay h3 { margin: 0 0 6px; font-size: 16px; }
.shorts-overlay p { margin: 0; color: rgba(255,255,255,.8); font-size: 13px; }
.shorts-side {
  position: absolute; right: 12px; bottom: 100px; z-index: 3;
  display: grid; gap: 14px; justify-items: center;
}
.shorts-side button {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.14); color: #fff;
  display: grid; place-items: center; font-size: 13px;
}
.shorts-sound-btn { font-size: 18px !important; }
.shorts-unmute {
  position: absolute; z-index: 4; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 18px; border-radius: 999px;
  background: rgba(0,0,0,.72); color: #fff; border: 1px solid rgba(255,255,255,.25);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.shorts-unmute:hover { background: rgba(0,0,0,.88); }
.shorts-close {
  position: fixed; top: 74px; left: 14px; z-index: 10;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 22px;
}
.video-empty {
  padding: 24px; border-radius: 12px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.video-watch-meta {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; color: var(--muted);
}
.video-category, .video-visibility {
  padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.08); font-size: 12px;
}
.video-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.video-tag {
  padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.08);
  color: var(--text); font-size: 13px;
}
.video-studio-form {
  width: min(920px, 100%); display: grid; gap: 18px; padding: 26px;
  background: rgba(24,24,24,.98); border-radius: 18px; border: 1px solid var(--line);
}
.video-studio-head h2 { margin: 0 0 6px; }
.video-studio-head p { margin: 0; color: var(--muted); font-size: 14px; }
.video-studio-grid {
  display: grid; grid-template-columns: minmax(240px, 1fr) minmax(280px, 1.2fr); gap: 18px;
}
.video-studio-panel { display: grid; gap: 14px; align-content: start; }
.video-file-pick { cursor: pointer; }
.video-file-box {
  min-height: 120px; border: 1px dashed rgba(255,255,255,.25); border-radius: 14px;
  display: grid; place-content: center; gap: 4px; padding: 18px; text-align: center;
  background: rgba(255,255,255,.04);
}
.video-preview {
  width: 100%; border-radius: 12px; background: #000; max-height: 220px;
}
.video-thumb-row { display: grid; gap: 10px; }
.video-thumb-preview {
  aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: rgba(255,255,255,.06);
  border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); font-size: 13px;
}
.video-thumb-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.field-hint { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.video-upload-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 24px;
  background: rgba(0,0,0,.78); backdrop-filter: blur(6px);
}
.video-upload-card {
  width: min(360px, 100%); padding: 28px 24px; border-radius: 20px;
  background: rgba(18,18,18,.96); border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
  display: grid; gap: 10px; justify-items: center; text-align: center;
}
.video-upload-card strong { font-size: 18px; }
.video-upload-card p { margin: 0; color: var(--muted); font-size: 14px; min-height: 1.2em; }
.video-upload-card small { color: var(--muted); font-variant-numeric: tabular-nums; }
.video-upload-spinner {
  width: 52px; height: 52px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--btn-bg, #fff);
  animation: videoSpin .85s linear infinite;
}
.video-upload-bar {
  width: 100%; height: 8px; border-radius: 999px;
  background: rgba(255,255,255,.1); overflow: hidden;
}
.video-upload-bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--btn-bg, #c8ff00), #fff);
  border-radius: inherit; transition: width .25s ease;
}
.video-studio-form.is-uploading { pointer-events: none; opacity: .55; }
@keyframes videoSpin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 60px 1fr; }
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 10px; gap: 8px; }
  .brand strong { display: none; }
  .search-wrap { max-width: none; }
  .search-panel {
    position: fixed; left: 8px; right: 8px; top: 58px;
    max-height: calc(100vh - 72px);
  }
  .search input { font-size: 16px; } /* iOS zoom fix */
  .view { padding: 14px 10px 70px; }
  .chat-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: calc(100vh - 60px);
    padding: 0;
  }
  .chat-list { height: auto; min-height: auto; max-height: 180px; border-radius: 0; border-right: 1px solid var(--line); }
  .chat-panel { height: calc(100vh - 240px); min-height: 520px; border-left: 1px solid var(--line); border-radius: 0; }
  .post-media img, .post-media video { max-height: 280px; }
  .story-viewer.expanded .story-viewer-inner { grid-template-columns: 1fr; }
  .story-viewer.expanded .story-main .story-text-backdrop { opacity: 1; transform: none; pointer-events: auto; }
  .story-side-panel { display: none; }
  .story-text.expanded-inline { -webkit-line-clamp: unset; }
  .video-watch { grid-template-columns: 1fr; }
  .video-rec-item { grid-template-columns: 120px 1fr; }
  .shorts-card { flex-basis: 130px; }
  .video-studio-grid { grid-template-columns: 1fr; }
  .video-home-actions { width: 100%; justify-content: space-between; }
}