    /* 1) Плеер */
    .live-player {
      position: relative;
      width: 100%;
      aspect-ratio: 16/9;
      border-radius: 12px;
      overflow: hidden;
      background: #0f1116;
      border: 1px solid #2a2f3a;
    }
    .live-player img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    .live-player iframe {
      width: 100%;
      height: 100%;
      border: 0;
      display: block;
    }

    .live-player .overlay {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 12px;
      background: rgba(0,0,0,.25);
    }
    .live-player .overlay .btn {
      display: inline-block;
      padding: 10px 14px;
      border-radius: 10px;
      border: 1px solid #2a2f3a;
      background: #171a21;
      color: #e7eaf0;
      cursor: pointer;
      font-weight: 700;
    }

    /* Кнопки на странице LIVE: нормальный цвет текста */
    .btn {
        color: #baccf1 !important;
    }

    .btn:hover,
    .btn:focus {
        color: #baccf1 !important;
    }

    /* 2) Чат (пока заглушка, но уже с правильным скроллом внутри) */
    .chat-shell {
      border: 1px solid #2a2f3a;
      border-radius: 12px;
      overflow: hidden;
      background: #0f1116;
    }
    .chat-log {
      height: 520px;
      overflow: auto;
      padding: 12px;
      display: flex;
      flex-direction: column-reverse; /* новое сверху */
      gap: 10px;
    }
    .chat-input {
      display: flex;
      gap: 10px;
      padding: 12px;
      border-top: 1px solid #2a2f3a;
      background: #171a21;
    }
    .chat-input input {
      flex: 1;
      border-radius: 10px;
      border: 1px solid #2a2f3a;
      background: #0f1116;
      color: #e7eaf0;
      padding: 10px 12px;
    }
    .chat-input button {
      padding: 10px 14px;
      border-radius: 10px;
      border: 1px solid #2a2f3a;
      background: #0f1116;
      color: #e7eaf0;
      cursor: pointer;
      font-weight: 700;
    }
    .chat-input input:disabled,
    .chat-input button:disabled { opacity: .55; cursor: not-allowed; }

    /* 3) Модалка входа */
    .live-modal {
      position: fixed;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 16px;
      background: rgba(0,0,0,.95);
      z-index: 9999;
    }
    .live-modal.open { display: flex; }
    .live-modal .box {
      width: min(420px, 100%);
      background: #171a21;
      border: 1px solid #2a2f3a;
      border-radius: 12px;
      padding: 14px;
    }
    .live-modal .box h3 { margin: 0 0 10px 0; }
    .live-modal .box .row { display: flex; flex-direction: column; gap: 10px; }
    .live-modal .box input {
      border-radius: 10px;
      border: 1px solid #2a2f3a;
      background: #0f1116;
      color: #e7eaf0;
      padding: 10px 12px;
    }
    .live-modal .box .err { color: #ffb3b3; font-size: 13px; min-height: 16px; margin-top: 8px; }

    /* LOGIN: убрать пустую строку под кнопками, когда ошибки нет */
    #liveModal .box #loginErr:empty{
    display: none !important;
    min-height: 0 !important;
    margin-top: 0 !important;
    }

    .live-me { opacity: .85; font-size: 13px; margin-top: 10px; }


    .chat-wrap {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .chat-meta {
        font-size: 13px;
        opacity: .85;
    }

    .chat-box {
        height: 520px;
        overflow: auto;
        padding: 12px;
        border-radius: 12px;
        border: 1px solid #2a2f3a;
        background: #0f1116;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    /* === CHAT: притемнить скроллбары (чат + закреп) === */
    .chat-box,
    .chat-pin .chat-pin-text{
        scrollbar-width: thin; /* Firefox */
        scrollbar-color: rgba(255,255,255,.22) rgba(255,255,255,.06);
    }

    /* Chromium / WebKit */
    .chat-box::-webkit-scrollbar,
    .chat-pin .chat-pin-text::-webkit-scrollbar{
        width: 10px;
        height: 10px;
    }

    .chat-box::-webkit-scrollbar-track,
    .chat-pin .chat-pin-text::-webkit-scrollbar-track{
        background: rgba(255,255,255,.05);
        border-radius: 10px;
    }

    .chat-box::-webkit-scrollbar-thumb,
    .chat-pin .chat-pin-text::-webkit-scrollbar-thumb{
        background: rgba(255,255,255,.18);
        border-radius: 10px;
        background-clip: padding-box;
        border: 2px solid rgba(0,0,0,0);
    }

    .chat-box::-webkit-scrollbar-thumb:hover,
    .chat-pin .chat-pin-text::-webkit-scrollbar-thumb:hover{
        background: rgba(255,255,255,.28);
    }

    /* === ONLINE: притемнить скроллбар списка онлайна === */
    .online-panel,
    .online-box{
        scrollbar-width: thin; /* Firefox */
        scrollbar-color: rgba(255,255,255,.22) rgba(255,255,255,.06);
    }

    /* Chromium / WebKit */
    .online-panel::-webkit-scrollbar,
    .online-box::-webkit-scrollbar{
        width: 10px;
        height: 10px;
    }

    .online-panel::-webkit-scrollbar-track,
    .online-box::-webkit-scrollbar-track{
        background: rgba(255,255,255,.05);
        border-radius: 10px;
    }

    .online-panel::-webkit-scrollbar-thumb,
    .online-box::-webkit-scrollbar-thumb{
        background: rgba(255,255,255,.18);
        border-radius: 10px;
        background-clip: padding-box;
        border: 2px solid rgba(0,0,0,0);
    }

    .online-panel::-webkit-scrollbar-thumb:hover,
    .online-box::-webkit-scrollbar-thumb:hover{
        background: rgba(255,255,255,.28);
    }

    .msg {
        border: 1px solid #2a2f3a;
        background: #141824;
        border-radius: 12px;
        padding: 10px 12px;
    }

    .msg.msg-me {
        border-color: rgba(17, 79, 138, 0.45);
        box-shadow: 0 0 0 1px rgba(120, 190, 255, .12) inset;
    }

/* === CHAT: stickers popup bigger === */
#chatStickersPop{
  min-width: 460px;
  max-width: 560px;
  max-height: 650px;
}

#chatStickersPop .emoji-grid{
  display: grid;
  grid-template-columns: repeat(2, 220px);
  gap: 14px;
  justify-content: center;
}

#chatStickersPop .emoji-item{
  width: 220px;
  height: 220px;
  border-radius: 22px;
  font-size: 0;
  overflow: hidden;
}

#chatStickersPop .emoji-item img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transform: scale(1.42);      /* было 1.28 */
  transform-origin: center;
}

@media (max-width: 560px) {
  #chatStickersPop{
    min-width: 320px;
    max-width: 94vw;
    max-height: 60vh;
  }

  #chatStickersPop .emoji-grid{
    grid-template-columns: repeat(2, 160px);
    gap: 12px;
  }

  #chatStickersPop .emoji-item{
    width: 160px;
    height: 160px;
    border-radius: 18px;
    overflow: hidden;
  }

  #chatStickersPop .emoji-item img{
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transform: scale(1.42);
    transform-origin: center;
  }
}

    .msg-head {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 6px;
    }

    .msg-nick {
        font-weight: 800;
    }

    .msg-time {
        font-size: 12px;
        opacity: .75;
        margin-left: auto;
    }

    .msg-del {
        font-size: 12px;
        opacity: .85;
        cursor: pointer;
        border: 1px solid #2a2f3a;
        background: #171a21;
        border-radius: 10px;
        padding: 6px 10px;
    }

    .msg-text {
        white-space: pre-wrap;
        line-height: 1.35;
    }

    .msg-img-wrap {
        margin-top: 6px;
    }

    .msg-img {
        max-width: 100%;
        max-height: 360px;   /* ← лимит высоты превью (поменяй на 320/420 если нужно) */
        width: auto;
        height: auto;
        display: block;
        border-radius: 12px;
    }
    @media (max-width: 560px) {
        .msg-img {
            max-height: 55vh; /* на телефоне ограничиваем от высоты экрана */
        }
    }

    /* === CHAT: stickers in feed smaller (75%) === */
    .msg-img[src^="/assets/chat/stickers/"]{
        max-width: 75%;
        max-height: 270px; /* 360 * 0.75 */
    }
    @media (max-width: 560px) {
        .msg-img[src^="/assets/chat/stickers/"]{
            max-width: 75%;
            max-height: 41vh; /* 55vh * 0.75 ≈ 41vh */
        }
    }

    #chatBox.chat-drop-hint {
        outline: 2px dashed rgba(255,255,255,.35);
        outline-offset: -6px;
    }

    .chat-compose {
        display: flex;
        gap: 10px;
        align-items: stretch;
    }

    /* === MOBILE: кнопки под полем ввода === */
    @media (max-width: 560px){
        .chat-compose{
            flex-wrap: wrap;
            gap: 8px;
        }

        #chatText{
            flex: 0 0 100%;
        }

        #chatEmoji,
        #chatAttach{
            flex: 0 0 auto;
        }

        #chatSend{
            flex: 1 1 auto;
            min-width: 0;
        }
    }


#chatText{
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;

    font-size: 17px;          /* ← увеличь тут, например 17px */
    line-height: 1.35;

    color: #e9eef6;
    caret-color: #e9eef6;
    background: rgba(0,0,0,.35);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
}

#chatText::placeholder{
    color: rgba(233,238,246,.55);
}
    #chatText:focus {
        border-color: #3a8cff;
    }

    .chat-hint {
        font-size: 12px;
        opacity: .70;
    }

    /* === LIVE: вертикальная компоновка (трансляция гармошкой сверху, чат снизу) === */
    section.grid {
        display: flex;
        flex-direction: column;
        gap: 18px;
        align-items: stretch;
    }

    section.grid > * {
        min-width: 0; /* критично: иначе чат/ссылки могут распирать и вылезать вправо */
    }

    /* длинные ссылки/текст не должны расширять карточку */
    .msg-text,
    .msg-text a {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Гармошка трансляции */
    .live-acc.card {
        padding: 0;
        overflow: hidden;
    }

    .live-acc-head {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 14px;
        border: 0;
        background: rgba(0,0,0,.10);
        color: #e7eaf0;
        cursor: pointer;
        font-weight: 800;
        text-align: left;
    }

    .live-acc-head:hover {
        background: rgba(0,0,0,.18);
    }

    .live-acc-arrow {
        opacity: .85;
        transition: transform .2s ease;
    }

    .live-acc-head[aria-expanded="true"] .live-acc-arrow {
        transform: rotate(180deg);
    }

    .live-acc-body {
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease;
        border-top: 1px solid #2a2f3a;
    }

    .live-acc-inner {
        padding: 14px;
    }

.msg-rank{
  display:inline-block;
  font-size:12px;
  line-height:1;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.25);
  opacity:.9;
  margin-left:8px;
}

/* ===== LIVE: онлайн-список (кто сейчас на странице) ===== */

.chat-tabs{ display:flex; align-items:center; gap:6px; margin:6px 0 10px 0; }
.chat-tabs-scroll{ display:flex; gap:6px; overflow:auto; padding-bottom:2px; scrollbar-width:thin; }

.chat-tab{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  cursor:pointer;
  user-select:none;
  white-space:nowrap;
}
.chat-tab:hover{ background: rgba(255,255,255,.06); }
.chat-tab.active{ background: rgba(255,255,255,.10); }

.chat-tab .badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:18px;
  height:18px;
  padding:0 6px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.25);
  font-size:12px;
  line-height:1;
  opacity:.95;
}

.chat-layout{ display:flex; gap:12px; align-items:stretch; }

.chat-bottom{ margin-top:10px; }

/* Desktop: 2 колонки сверху, и нижний ряд на всю ширину */
@media (min-width: 769px){
  .chat-layout{
    /* высота верхней зоны (сообщения + онлайн) */
    --chat-top-h: min(640px, 68vh);

    display: grid;
    grid-template-columns: 1fr 220px;
    grid-template-rows: var(--chat-top-h) auto;
    gap: 12px;
    align-items: stretch;
  }

  .chat-main{
    grid-column: 1 / 2;
    grid-row: 1;

    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;
  }

  .chat-box-wrap{
    flex: 1 1 auto;
    min-height: 0;
  }

  .chat-box{
    height: 100% !important;
  }

  .online-panel{
    grid-column: 2 / 3;
    grid-row: 1;

    width: 100%;
    max-width: none;

    display: flex;
    flex-direction: column;

    min-height: 0;
    overflow: hidden;
  }

  .online-box{
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }

  .chat-bottom{
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

.chat-main{ flex:1 1 auto; min-width:0; }

.online-panel{
  flex:0 0 220px;
  max-width:220px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:14px;
  background: rgba(0,0,0,.18);
  padding:10px;
  max-height: 70vh;
  overflow:auto;
}
.online-title{ font-size:12px; opacity:.8; margin-bottom:8px; }
.online-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:6px 6px;
  border-radius:10px;
}
.online-row:hover{ background:rgba(255,255,255,.06); }
.online-nick{
  font-weight:700;
  font-size:13px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.online-rank{
  display:inline-block;
  font-size:11px;
  line-height:1;
  padding:2px 6px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.25);
  opacity:.9;
  flex:0 0 auto;
}

@media (max-width: 900px){
  .online-panel{ flex-basis:180px; max-width:180px; }
}
@media (max-width: 768px){
  .chat-layout{ flex-direction:column; }
  .online-panel{ max-width:none; max-height:180px; }
}


    /* === LIVE: финальные отступы + одинаковые заголовки + 1mm между плашками + без лишней линии === */

    /* расстояние между кнопками и первой плашкой — оставляем как сейчас */
    .wrap > header {
        margin-bottom: 4px !important;
    }

    .head-row {
        margin: 4px 0 4px !important;
    }

    /* между плашками: 1mm (gap = 0, делаем зазор через margin-top у второй карточки) */
    section.grid {
        gap: 0 !important;
        margin-top: 0 !important;
    }

    section.grid > .card {
        margin: 0 !important;
    }

    /* 1mm между "Прямая трансляция" и карточкой чата */
    #liveAcc + .card {
        margin-top: 1mm !important;
        overflow: hidden;             /* чтобы ничего не вылезало за скругления */
        background-clip: padding-box;
    }

    /* Заголовок трансляции по размеру как заголовок чата (h3) */
    .live-acc-head {
        font-size: 1.17em !important;
        line-height: 1.2;
    }

    /* Линия (border) внутри гармошки: нет в свернутом виде, появляется только при раскрытии */
    .live-acc-body {
        border-top: 0 !important;
    }

    .live-acc-head[aria-expanded="true"] + .live-acc-body {
        border-top: 1px solid #2a2f3a !important;
    }

    /* === LIVE: иконки перед заголовками + спокойный жёлто-зелёный цвет === */
    :root {
        --live-head-accent: #e7a456; /* светло жёлто-зелёный, не ядовитый */
        --chat-pin-text-color: rgba(85, 231, 224, 0.92);
        --muster-text-color: rgb(253, 228, 0);
        --muster-text-weight: 600;
        --muster-head-color: rgb(250, 37, 37);
        --muster-head-weight: 800;
    }

    /* Заголовок "Прямая трансляция" (гармошка) */
    .live-acc-head {
        color: var(--live-head-accent) !important;
        justify-content: flex-start !important; /* чтобы иконка+текст были слева */
        gap: 10px !important;
        text-shadow: 0 1px 0 rgba(0,0,0,.35);
    }

    .live-acc-head::before {
        content: "📡";
        opacity: .95;
        transform: translateY(1px);
    }

    .live-acc-arrow {
        margin-left: auto !important; /* стрелка уходит вправо */
        color: var(--live-head-accent) !important;
        opacity: .9;
    }

    /* Заголовок "Чат Клана SVOBODA" */
    .card > div[style*="display:flex"][style*="margin-bottom:8px"] > h3 {
        color: var(--live-head-accent) !important;
        display: inline-flex;
        align-items: center;
        gap: 10px;
        text-shadow: 0 1px 0 rgba(0,0,0,.35);
    }

    .card > div[style*="display:flex"][style*="margin-bottom:8px"] > h3::before {
        content: "💬";
        opacity: .95;
        transform: translateY(1px);
    }

    /* === LIVE: ник в сообщениях чуть меньше === */
    .msg-nick {
        font-size: 14px !important;
        line-height: 1.15;
    }

/* FIX: поле ввода сообщения (темная тема + нормальная ширина) */
.chat-compose{
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.emoji-pop{
  position: fixed;
  z-index: 9999;
  min-width: 260px;
  max-width: 340px;
  max-height: 240px;
  overflow: auto;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #2a2f3a;
  background: #0f1116;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.emoji-title{
  font-size: 12px;
  opacity: .8;
  margin: 6px 0 6px;
}

.emoji-grid{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emoji-item{
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid #2a2f3a;
  background: #141824;
  cursor: pointer;
  user-select: none;
  font-size: 20px;
  line-height: 1;
}

.emoji-item:hover{
  border-color: rgba(120, 190, 255, .35);
  box-shadow: 0 0 0 1px rgba(120, 190, 255, .12) inset;
}


.chat-input{
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;

    color: #e9eef6 !important;
    caret-color: #e9eef6;
    background: rgba(0,0,0,.35);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
}

.chat-input::placeholder{
    color: rgba(233,238,246,.55);
}

.chat-actions{
    flex: 0 0 auto;
}


    /* === LIVE: гармошка "Записи трансляций" === */
    #vodAcc .live-acc-head::before {
        content: "📼";
    }

    /* 1mm между "Записи" и карточкой чата (как сделано для #liveAcc) */
    #vodAcc + .card {
        margin-top: 1mm !important;
        overflow: hidden;
        background-clip: padding-box;
    }

    .vod-list{
        margin-top: 12px;
        border: 1px solid rgba(255,255,255,0.10);
        border-radius: 12px;
        background: rgba(0,0,0,.18);
        padding: 8px;
        max-height: 260px;   /* примерно ~10 строк */
        overflow: auto;
    }

    .vod-item{
        width: 100%;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 10px;
        border-radius: 10px;
        border: 1px solid rgba(255,255,255,0.08);
        background: rgba(255,255,255,0.04);
        color: #e7eaf0;
        cursor: pointer;
        text-align: left;
        font-weight: 700;
        font-size: 13px;
        line-height: 1.25;
        user-select: none;
    }

    .vod-item:hover{
        background: rgba(255,255,255,0.07);
    }

    .vod-item.active{
        border-color: rgba(46,234,120,.55);
        box-shadow: 0 0 10px rgba(46,234,120,.18);
    }

/* === CHAT: кнопка "К новым" (скролл наверх) === */
.chat-main{
    position: relative;
}

.chat-to-top{
    position: absolute;
    right: 12px;
    bottom: 86px;          /* над полем ввода */
    z-index: 5;
    display: none;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    opacity: .92;
}

.chat-to-top:hover{
    opacity: 1;
}

@media (max-width: 560px){
    .chat-to-top{
        right: 10px;
        bottom: 94px;
        padding: 7px 10px;
        font-size: 14px;
    }
}

/* === CHAT: pin + reply (закреп + режим ответа) === */

.chat-pin{
    display:flex;
    align-items:flex-start;
    gap:10px;
    padding:10px 12px;
    margin: 0 0 10px 0;
    border:1px solid rgba(255,255,255,0.10);
    border-radius:12px;
    background: rgba(255,255,255,0.03);
}

.chat-pin .chat-pin-text{
    flex:1 1 auto;
    min-width:0;
    line-height:1.25;
    display:block;
    color: var(--chat-pin-text-color);

    /* сохраняем переносы строк как в исходном тексте */
    white-space: pre-wrap;

    overflow-wrap:anywhere;
    word-break:break-word;

    /* фиксируем высоту примерно на 4 строки, остальное — скролл */
    max-height: calc(4 * 1.25em);
    overflow-y: auto;
    overflow-x: hidden;
}

.chat-pin .chat-pin-actions{
    flex:0 0 auto;
    display:flex;
    gap:8px;
}

.chat-pin .chat-pin-actions .btn{
    padding:6px 10px;
    border-radius:10px;
}

.chat-reply{
    display:flex;
    align-items:flex-start;
    gap:10px;
    padding:8px 10px;
    margin:10px 0;
    border:1px solid rgba(255,255,255,0.08);
    border-left:3px solid rgba(46,234,120,.65);
    border-radius:12px;
    background: rgba(255,255,255,0.03);
}

.chat-reply-text{
    flex:1 1 auto;
    min-width:0;
    font-size:13px;
    line-height:1.25;
    opacity:.92;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.chat-reply-cancel{
    flex:0 0 auto;
    padding:2px 10px;
    font-size:18px;
    line-height:1;
}

/* кнопки действий под сообщением (Ответить / 📌) */
.msg-actions{
    margin-top:8px;
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}

.msg-action{
    padding:5px 10px;
    border-radius:999px;
    border:1px solid rgba(255,255,255,.12);
    background: rgba(0,0,0,.20);
    color: inherit;
    font-size:12px;
    font-weight:700;
    cursor:pointer;
    user-select:none;
}

.msg-action:hover{
    background: rgba(0,0,0,.30);
}

/* цитата (preview ответа) внутри сообщения */
.msg-reply-quote{
    margin-top:8px;
    padding:8px 10px;
    border:1px solid rgba(255,255,255,0.08);
    border-left:3px solid rgba(255,255,255,.18);
    border-radius:10px;
    background: rgba(255,255,255,0.03);
    font-size:13px;
    line-height:1.25;
}

.msg-reply-quote .rq-head{
    font-weight:800;
    margin-bottom:4px;
    opacity:.95;
}

.msg-reply-quote .rq-text{
    opacity:.85;
    overflow-wrap:anywhere;
    word-break:break-word;
}

@media (max-width: 560px) {
    .msg-head{
        flex-wrap: wrap;
    }

    /* кнопка "Ответить" (в заголовке сообщения) уходит на следующую строку и прижимается вправо */
    .msg-action-head{
        margin-left: auto;
    }
}

/* === LOGIN STAGE v2 (независимые “ручки” для каждого объекта) ============ */
#liveModal{
  display: flex !important;
  position: fixed;
  inset: 0;
  z-index: 9999;

  align-items: center;
  justify-content: center;
  padding: 16px;

  background: #000;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility 0s linear .18s;
}

#liveModal.open{
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .18s ease;
}

/* когда модалка открыта — “приезжаем” в финальное положение */
#liveModal.open .tow-group{
  transform: translateX(0%);
}

/* Сцена 16:9 */
#liveModal .login-stage{
  position: relative;
  width: min(1500px, 98vw);
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;

  box-shadow: 0 26px 80px rgba(0,0,0,.55);
  isolation: isolate;

  /* ===================== РУЧКИ (тут крутишь всё) ====================== */
  /* Фон */
  --bg-zoom: 1;                 /* 1 = как есть, 1.05..1.15 = чуть “приблизить” */
  --bg-pos-x: 50%;
  --bg-pos-y: 50%;

  /* Казарма (дом) */
  --barr-x: 50%;
  --barr-y: 50%;
  --barr-w: 92%;                /* ширина дома относительно сцены */
  --barr-scale: 1;

  /* Форма (модалка) ВНУТРИ казармы (в процентах ОТ ДОМА!) */
  --form-x: 50.293%;
  --form-y: 57.032%;
  --form-w: 25.781%;
  --form-scale: 1;

  /* Сдвиг связки (ТАНК + ТРОС) одним движком */
  --rig-shift-x: 57%;
  --rig-shift-y: 0%;

  /* Трос */
  --cable-x: 45%;
  --cable-y: 62%;
  --cable-w: 20%;
  --cable-scale: 1.3;

  /* Танк */
  --tank-x: 88%;
  --tank-y: 60%;
  --tank-w: 65%;
  --tank-scale: 1;

  /* Солдат (проще right/bottom/height) */
  --soldier-right: 10%;
  --soldier-bottom: 0%;
  --soldier-h: 48%;
  --soldier-scale: 1;

  /* === ВЪЕЗД СВЯЗКИ (дом+трос+танк) === */
  --rig-shift-final: 0%;      /* подстройка конечной позиции всей связки: + вправо, - влево */
  --rig-enter-from: -140%;    /* старт: слева за кадром (чем больше по модулю — тем дальше) */
  --rig-x: var(--rig-enter-from);

  --rig-dur: 4s;     /* медленнее (крути как нужно) */
  --rig-delay: 0s;     /* без паузы перед стартом */
  --rig-ease: linear;  /* ровная скорость */

}

#liveModal.open .login-stage{
  --rig-x: 0%;
}

/* Все слои в сцене — абсолютные (каждый сам по себе) */
#liveModal .login-bg,
#liveModal .tow-group,
#liveModal .login-cable,
#liveModal .login-tank,
#liveModal .login-soldier{
  position: absolute;
  display: block;
  user-select: none;
}

/* Фон */
#liveModal .login-bg{
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--bg-pos-x) var(--bg-pos-y);
  transform: scale(var(--bg-zoom));
  filter: saturate(.95) contrast(1.03);
  z-index: 1;
  pointer-events: none;
}

/* Группа: дом + форма внутри него */
#liveModal .tow-group{
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;

  /* двигаем ВСЮ связку разом */
  transform: translate3d(calc(var(--rig-x) + var(--rig-shift-final)), 0, 0);
  transition: transform var(--rig-dur) var(--rig-ease) var(--rig-delay);
  will-change: transform;
}

/* Дом */
#liveModal .barracks-wrap{
  position: absolute;
  left: var(--barr-x);
  top:  var(--barr-y);
  width: var(--barr-w);
  transform: translate(-50%, -50%) scale(var(--barr-scale));
  transform-origin: 50% 50%;
  pointer-events: none;
}

#liveModal .barracks-img{
  position: relative; /* важно: задаёт “габарит” дому */
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

/* Форма ВНУТРИ дома — двигается независимо от дома */
#liveModal .barracks-wrap .box{
  position: absolute;
  left: var(--form-x);
  top:  var(--form-y);
  width: var(--form-w);
  transform: translate(-50%, -50%) scale(var(--form-scale));
  transform-origin: 50% 50%;
  z-index: 6;

  pointer-events: auto; /* чтобы можно было кликать/вводить */
  margin: 0;

  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: none;
  backdrop-filter: blur(2px);
}

/* Трос */
#liveModal .login-cable{
  z-index: 4;
  left: calc(var(--cable-x) + var(--rig-shift-x));
  top:  calc(var(--cable-y) + var(--rig-shift-y));
  width: var(--cable-w);
  transform: translate(-50%, -50%) scale(var(--cable-scale));
  transform-origin: 50% 50%;
  opacity: .95;
  pointer-events: none;
}

/* Танк */
#liveModal .login-tank{
  z-index: 5;
  left: calc(var(--tank-x) + var(--rig-shift-x));
  top:  calc(var(--tank-y) + var(--rig-shift-y));
  width: var(--tank-w);
  transform: translate(-50%, -50%) scale(var(--tank-scale));
  transform-origin: 50% 50%;
  filter: drop-shadow(0 14px 26px rgba(0,0,0,.55));
  pointer-events: none;
}

/* Солдат */
#liveModal .login-soldier{
  z-index: 6;
  right: var(--soldier-right);
  bottom: var(--soldier-bottom);
  height: var(--soldier-h);
  width: auto;
  transform: scale(var(--soldier-scale));
  transform-origin: 100% 100%;
  filter: drop-shadow(0 12px 22px rgba(0,0,0,.55));
  opacity: .95;
  pointer-events: none;
}

/* Мобильная подстройка — только размеры сцены/дома/формы */
@media (max-width: 560px){
  #liveModal .login-stage{
    width: 96vw;
    --barr-w: 98%;
    --form-w: 46%;
  }
}

/* LIVE: отключить sticky у шапки (баннер + меню) */
html body div.wrap > header{
  position: static !important;
  top: auto !important;
  z-index: auto !important;
}

/* === LOGIN: loader + ровная скорость + запуск сцены после preload ========= */

/* 1) Модалка: чуть плавнее затемнение */
#liveModal{
  transition: opacity .32s ease, visibility 0s linear .32s;
}
#liveModal.open{
  transition: opacity .32s ease;
}

/* 2) Пока НЕ scene-ready — показываем только загрузчик, сцену прячем */
#liveModal.open:not(.scene-ready) .login-bg,
#liveModal.open:not(.scene-ready) .tow-group,
#liveModal.open:not(.scene-ready) .login-soldier{
  opacity: 0;
}

/* 3) Экран загрузки поверх сцены */
#liveModal .login-loading{
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 14px;
  z-index: 50;

  background: rgba(0,0,0,.92);
  color: rgba(255,255,255,.88);
  text-align: center;

  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

#liveModal.open:not(.scene-ready) .login-loading{
  opacity: 1;
  pointer-events: auto;
}

#liveModal .login-loading .spinner{
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 4px solid rgba(255,255,255,.18);
  border-top-color: rgba(255,255,255,.78);
  animation: loginSpin 0.9s linear infinite;
}

#liveModal .login-loading .bar{
  width: min(420px, 72vw);
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  overflow: hidden;
}

#liveModal .login-loading .bar > i{
  display: block;
  height: 100%;
  width: 35%;
  background: rgba(255,255,255,.70);
  border-radius: 999px;
  animation: loginBar 1.15s linear infinite;
}

@keyframes loginSpin{ to { transform: rotate(360deg); } }
@keyframes loginBar{
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

/* 4) Въезд связки: РОВНАЯ скорость (linear), старт слева пока грузим */
#liveModal .tow-group{
  transform: translate3d(-120vw, 0, 0);
  transition: transform 3.5s linear;
  will-change: transform;
}

/* EXIT: при успешном логине едем ВПРАВО и не откатываемся назад */
#liveModal.open.leaving .tow-group{
  transform: translate3d(140vw, 0, 0) !important;
  transition: transform 1.2s linear !important;
}

#liveModal.closing .tow-group{
  transform: translate3d(140vw, 0, 0) !important;
  transition: none !important;
}

/* пока НЕ готово — держим слева */
#liveModal.open:not(.scene-ready) .tow-group{
  transform: translate3d(-120vw, 0, 0);
}

/* когда готово — едем в финальную точку */
#liveModal.open.scene-ready .tow-group{
  transform: translate3d(0, 0, 0);
}

/* 5) Слои: трос за домом, танк перед домом */
#liveModal .login-cable{ z-index: 2 !important; }
#liveModal .barracks-wrap{ z-index: 3 !important; }
#liveModal .login-tank{  z-index: 4 !important; }




/* === MOBILE: старый простой логин (без сцены/анимации/звука) ============ */
@media (max-width: 560px){

  /* сама "сцена" превращается в обычный контейнер */
  #liveModal .login-stage{
    width: min(520px, 92vw) !important;
    aspect-ratio: auto !important;
    border-radius: 14px !important;
    overflow: visible !important;
    box-shadow: none !important;
  }

  /* скрываем всю графику сцены */
  #liveModal .login-bg,
  #liveModal .barracks-img,
  #liveModal .login-cable,
  #liveModal .login-tank,
  #liveModal .login-soldier,
  #liveModal .login-loading{
    display: none !important;
  }

  /* выключаем любые движения/анимации сцены */
  #liveModal .tow-group{
    position: static !important;
    inset: auto !important;
    transform: none !important;
    transition: none !important;
  }
  #liveModal .barracks-wrap{
    position: static !important;
    width: auto !important;
    transform: none !important;
  }

  /* форму делаем обычной модалкой по центру */
  #liveModal .barracks-wrap .box{
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;

    width: min(420px, 92vw) !important;
    margin: 0 auto !important;

    pointer-events: auto !important;
    z-index: 2 !important;
  }

  /* если есть классы leaving/closing — на мобиле игнорируем */
  #liveModal.open.leaving .tow-group,
  #liveModal.closing .tow-group{
    transform: none !important;
    transition: none !important;
  }
}

/* === CHAT LAYOUT FIX (убрать большой зазор + порядок на мобиле) === */

@media (min-width: 769px){
  .chat-layout{
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 260px !important;

    /* ВАЖНО: авто-строки, чтобы не было “пустого этажа” между поиском и вводом */
    grid-template-rows: auto auto !important;

    gap: 12px !important;
    align-items: stretch !important;
  }

  .chat-main{
    grid-column: 1 / 2 !important;
    grid-row: 1 !important;

    align-self: stretch !important;
    min-width: 0 !important;
  }

  .online-panel{
    grid-column: 2 / 3 !important;
    grid-row: 1 !important;

    align-self: stretch !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  .online-box{
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: auto !important; /* скролл живой */
  }

  /* Высота верхней зоны задаётся высотой окна сообщений */
  .chat-box{
    height: min(520px, 58vh) !important;
  }

  /* чуть аккуратнее отступы у поиска */
  #chatSearchBar{
    margin: 8px 0 0 0 !important;
  }

  /* убираем лишний отступ, чтобы ввод был ближе к поиску */
  .chat-bottom{
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    margin-top: 0 !important;
  }
}

@media (max-width: 768px){
  .chat-layout{
    display: flex !important;
    flex-direction: column !important;
  }

  .chat-main{ order: 1 !important; }
  .chat-bottom{ order: 2 !important; margin-top: 8px !important; }
  .online-panel{ order: 3 !important; } /* онлайн строго внизу */
}

/* === CHAT WIDTH TUNE: сузить онлайн на ~25% (desktop) === */
@media (min-width: 769px){
  .chat-layout{
    grid-template-columns: minmax(0, 1fr) 240px !important; /* было 320px */
  }

  .online-panel{
    width: 100% !important;
    max-width: none !important;
    justify-self: stretch !important;
  }
}

/* DM modal: список юзеров — чтобы докручивался до самого низа */
.dm-modal .dm-card{
  display: flex !important;
  flex-direction: column !important;
}

.dm-modal .dm-search{
  flex: 0 0 auto !important;
}

.dm-modal .dm-list{
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;   /* перебиваем 52vh */
  overflow: auto !important;
  padding-bottom: 14px !important; /* чтобы последний элемент не прятался у скругления */
}
