* { box-sizing: border-box; }

:root{
  --bg1: #ffd6e7;
  --bg2: #f7b2d9;
  --card: rgba(255,255,255,0.86);
  --stroke: rgba(255, 80, 140, 0.22);
  --text: #2a2a2a;
  --muted: rgba(40, 40, 40, 0.7);
  --accent: #ff3d8d;
  --accent2: #ff6aa9;
  --shadow: 0 12px 30px rgba(0,0,0,0.12);
  --radius: 14px;
}

html, body{ height:100%; }
body{
  margin:0;
  font-family:"Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  overflow:hidden;
}

#app{
  height:100vh;
  display:grid;
  grid-template-columns: 240px 1fr 360px;
  gap:10px;
  padding:10px;
}

/* ===== Sidebar ===== */
#sidebar{
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  display:flex;
  flex-direction:column;
  min-height:0;
}

#meBadge{
  border: 1px solid rgba(255,61,141,0.25);
  background: rgba(255,61,141,0.10);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
}

#rooms strong, #online strong{
  display:block;
  margin-bottom:6px;
  font-size:13px;
  color: var(--muted);
}

#rooms button{
  width:100%;
  border:1px solid var(--stroke);
  background: rgba(255, 61, 141, 0.10);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 10px;
  cursor:pointer;
  font-size: 13px;
  margin:4px 0;
  text-align:left;
  transition: transform .12s ease, background .12s ease;
}
#rooms button:hover{
  transform: translateY(-1px);
  background: rgba(255,61,141,0.16);
}
#rooms button.active{
  background: linear-gradient(135deg, rgba(255,61,141,0.25), rgba(255,106,169,0.18));
  border-color: rgba(255,61,141,0.35);
}

/* ===== Online ===== */
#online{
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0,0,0,0.12);
  flex:1;
  overflow:auto;
  min-height:0;
  font-size:13px;
  line-height:1.18;
}

.online-stats{
  margin: 6px 0 8px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.70);
  font-size: 12px;
  color: rgba(40,40,40,0.75);
}

.online-group{ margin-top: 6px; }
.online-group strong{ font-size:12px; color: rgba(40,40,40,0.75); }

#online a.uLink{
  color: rgba(40,40,40,0.92);
  text-decoration:none;
  display:inline-block;
  padding: 0;
  margin: 0;
  line-height: 1.15;
}
#online a.uLink:hover{
  text-decoration: underline;
  color: var(--accent);
}
#online .empty{ color: rgba(40,40,40,0.45); }

#logout{
  margin-top:10px;
  border:none;
  border-radius:10px;
  padding:8px 10px;
  cursor:pointer;
  font-size:13px;
  color:white;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 10px 20px rgba(255,61,141,0.25);
}

/* ===== Main ===== */
#main{
  background: var(--card);
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
}

.typing{
  min-height:18px;
  padding: 6px 10px 0;
  font-size:12px;
  color: rgba(40,40,40,0.7);
}

#chatContainer{
  flex:1;
  min-height:0;
  overflow:auto;
  padding: 10px 10px 6px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ===== Composer ===== */
#composer{
  position:relative;
  padding:8px;
  border-top: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.7);
  display:grid;
  grid-template-columns: auto 1fr auto;
  gap:8px;
  align-items:center;
}

.composer-left,.composer-right{
  display:flex;
  gap:6px;
  align-items:center;
}

#composer button, #privateComposer button{
  border:1px solid var(--stroke);
  background: rgba(255,61,141,0.10);
  border-radius:10px;
  padding:7px 10px;
  cursor:pointer;
  font-size:13px;
}
#composer button:hover, #privateComposer button:hover{
  background: rgba(255,61,141,0.16);
}
#composer button:disabled, #privateComposer button:disabled{
  opacity:0.5;
  cursor: default;
}

.composer-form{
  display:grid;
  grid-template-columns: 1fr auto;
  gap:8px;
  align-items:center;
}

.composer-form input{
  width:100%;
  border:1px solid rgba(0,0,0,0.12);
  border-radius:12px;
  padding:10px 12px;
  font-size:13px;
  outline:none;
  background: rgba(255,255,255,0.92);
}
.composer-form input:focus{
  border-color: rgba(255,61,141,0.55);
  box-shadow: 0 0 0 3px rgba(255,61,141,0.12);
}

.send-btn{
  border:none !important;
  color:white;
  background: linear-gradient(135deg, var(--accent), var(--accent2)) !important;
  padding: 10px 12px !important;
  border-radius: 12px !important;
  font-size: 13px !important;
  white-space: nowrap;
  box-shadow: 0 10px 20px rgba(255,61,141,0.22);
}

/* ===== Format bar ===== */
.format-bar{
  grid-column: 1 / -1;
  display:flex;
  gap:8px;
  align-items:center;
  padding: 4px 2px 0;
}
.format-bar .fmt{
  display:flex;
  gap:8px;
  align-items:center;
  font-size:12px;
  color: rgba(40,40,40,0.75);
}
.format-bar select{
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.92);
}

/* ===== Emoji panels open UP ===== */
#emojiPanel, #privateEmojiPanel{
  position:absolute;
  right:10px;
  bottom: calc(100% + 8px);
  width: min(520px, 92%);
  max-height: 260px;
  overflow:auto;
  background: rgba(255,255,255,0.95);
  border:1px solid rgba(255,61,141,0.25);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
  padding: 10px;
  z-index: 30;
}

.emoji-tabs{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-bottom:8px;
}
.emoji-tab{
  border:1px solid rgba(0,0,0,0.10);
  background: rgba(255,61,141,0.08);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.emoji-tab.active{
  background: rgba(255,61,141,0.18);
  border-color: rgba(255,61,141,0.35);
}
.emoji-grid{
  display:grid;
  grid-template-columns: repeat(10, 1fr);
  gap:6px;
}
.emoji-btn{
  border:1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.9);
  border-radius:10px;
  padding:6px 0;
  cursor:pointer;
  font-size:18px;
  line-height:1;
}
.emoji-btn:hover{ background: rgba(255,61,141,0.10); }

/* ===== Messages (STACK VERTICALLY) ===== */
.msg{
  position: relative;
  display: block;            /* важно: одно под другим */
  width: fit-content;
  max-width: 94%;
  margin: 4px 0;
  padding: 7px 9px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.92);
  box-shadow: 0 6px 14px rgba(0,0,0,0.06);
  font-size: 13px;
  line-height: 1.22;
  word-break: break-word;
}

.msg.me{
  margin-left:auto;
  background: rgba(255,61,141,0.12);
  border-color: rgba(255,61,141,0.20);
}

.msg.system{
  width:100%;
  max-width:100%;
  background: rgba(255,61,141,0.10);
  border-color: rgba(255,61,141,0.20);
  font-style: italic;
  color: rgba(40,40,40,0.75);
}

.msg-top{
  font-size:12px;
  margin-bottom:3px;
  color: rgba(40,40,40,0.78);
}
.msg-meta{
  color: rgba(40,40,40,0.7);
}

.msg-body{
  font-size:13px;
}

.msg-del{
  position:absolute;
  top:6px;
  right:8px;
  border:none;
  background:transparent;
  cursor:pointer;
  color: rgba(40,40,40,0.45);
  font-size: 12px;
}
.msg-del:hover{ color: rgba(40,40,40,0.8); }

.msg audio{
  width: 260px;
  max-width: 100%;
  margin-top: 6px;
}

/* clickable time/user */
.msg a.msg-link{
  color: rgba(40,40,40,0.88);
  text-decoration: none;
  border-bottom: 1px dotted rgba(40,40,40,0.35);
}
.msg a.msg-link:hover{
  color: var(--accent);
  border-bottom-color: rgba(255,61,141,0.55);
}

/* ===== Private panel ===== */
#privatePanel{
  position: relative;
  background: var(--card);
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
  transition: transform .18s ease, opacity .18s ease;
}

#privateHeader{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap:8px;
  padding:10px;
  border-bottom:1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.7);
}

.private-title{ display:flex; flex-direction:column; gap:2px; }
#privateHeader strong{ font-size: 13px; }
#privateHeader .hint{ font-size:11px; color: rgba(40,40,40,0.6); }

#privateHideBtn{
  border:1px solid rgba(0,0,0,0.10);
  background: rgba(255,61,141,0.08);
  border-radius:10px;
  padding:6px 10px;
  cursor:pointer;
}

.private-header-right{
  margin-left:auto;
  font-size: 18px;
  font-weight: 800;
  color: rgba(40,40,40,0.9);
  padding-left: 6px;
}

/* tabs row */
.private-tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  padding:10px;
  border-bottom: 1px dashed rgba(0,0,0,0.10);
}

.p-tab{
  border:1px solid rgba(255,61,141,0.25);
  background: rgba(255,61,141,0.10);
  border-radius: 999px;
  padding: 7px 10px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:10px;
}
.p-tab.active{
  background: rgba(255,61,141,0.18);
  border-color: rgba(255,61,141,0.45);
}
.p-tab.unread{
  box-shadow: 0 0 0 3px rgba(255,61,141,0.15);
}
.p-tab .tab-label{
  font-size: 13px;
  font-weight: 700;
}
.p-tab .tab-close{
  font-size: 12px;
  opacity: 0.7;
}
.p-tab .tab-close:hover{ opacity: 1; }

#privateChatContainer{
  flex:1;
  min-height:0;
  overflow:auto;
  padding: 10px 10px 6px;
}

.private-thread{
  /* каждый разговор в своем контейнере */
}

/* private composer */
#privateComposer{
  position: relative;
  padding:8px;
  border-top: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.7);
  display:grid;
  grid-template-columns: auto 1fr auto;
  gap:8px;
  align-items:center;
}

/* ===== collapse behavior ===== */
#privatePanel.is-hidden{
  transform: translateX(100%);
  opacity: 1;
}

/* show button when hidden: bottom-right */
#privateShowBtn{
  border: none;
  border-radius: 999px;
  padding: 11px 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(255,61,141,0.26);
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 9999;
}

/* expand main when private collapsed */
#app.private-collapsed{
  grid-template-columns: 240px 1fr 0px;
}

/* Responsive */
@media (max-width: 1100px){
  #app{ grid-template-columns: 220px 1fr 320px; }
  #app.private-collapsed{ grid-template-columns: 220px 1fr 0px; }
}
@media (max-width: 920px){
  #app{
    grid-template-columns: 220px 1fr;
    grid-template-rows: 1fr auto;
  }
  #privatePanel{
    grid-column: 1 / -1;
    height: 38vh;
  }
  #main{ height: 62vh; }
  
  .tab-close {
    display: none !important;
  }
}

/* ===============================
   MOBILE ADAPTATION
   =============================== */
@media (max-width: 768px) {

  html, body {
    height: 100%;
  }

  body {
    margin: 0;
    overflow: hidden;
  }

  .chat, .container, .chat-container {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  #messages, .messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    word-break: break-word;
    padding-bottom: 10px;
  }

  form, .input, .chat-input {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .message {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.4;
  }

  .users, .rooms, .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: min(85vw, 360px);
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    z-index: 1000;
    background: #fff;
    overflow-y: auto;
  }

  body.menu-open .users,
  body.menu-open .rooms,
  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 900;
  }

  body.menu-open .overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ===============================
   MOBILE (exact selectors for current markup)
   =============================== */
@media (max-width: 768px) {

  /* Topbar only on mobile */
  #mobileTopbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 1300;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.08);
  }

  #mobileTopbar .topbar-title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #mobileTopbar button {
    font-size: 18px;
    line-height: 1;
    padding: 8px 10px;
    border-radius: 10px;
  }

  /* App layout */
  #app {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  /* Main should be full-height minus topbar */
  #main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  /* Messages containers scroll */
  #chatContainer {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    word-break: break-word;
    padding-bottom: 10px;
  }

  /* Composer sticks to bottom */
  #composer {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 10;
  }

  /* Sidebar off-canvas (left) */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: min(85vw, 360px);
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    z-index: 1200;
    background: #fff;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.menu-open #sidebar {
    transform: translateX(0);
  }

  /* Private panel off-canvas (right) */
  #privatePanel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: min(90vw, 420px);
    transform: translateX(110%);
    transition: transform 0.2s ease;
    z-index: 1250;
    background: #fff;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  body.private-open #privatePanel {
    transform: translateX(0);
  }

  #privateChatContainer {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    word-break: break-word;
  }

  #privateComposer {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Overlay visible when any panel open */
  #overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1100;
  }
  body.menu-open #overlay,
  body.private-open #overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Desktop: hide mobile topbar */
@media (min-width: 769px) {
  #mobileTopbar { display: none; }
}

/* ===== Gradient theme support ===== */
:root {
  --ui-grad-1: #ffdde1;
  --ui-grad-2: #ee9ca7;
}

body {
  background: linear-gradient(135deg, var(--ui-grad-1), var(--ui-grad-2));
}

/* ===== Apply gradient to Sidebar (rooms/online) and Private panel ===== */
#sidebar,
#privatePanel {
  background: linear-gradient(135deg, var(--ui-grad-1), var(--ui-grad-2));
}

/* Make inner content readable on top of gradient */
#sidebar::before,
#privatePanel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.78); /* light glass layer */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}

/* Ensure content is above the overlay */
#sidebar > *,
#privatePanel > * {
  position: relative;
  z-index: 1;
}

/* Optional: buttons look better on gradient */
#sidebar button,
#privatePanel button {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Prevent weird stacking when panels are fixed on mobile */
#sidebar,
#privatePanel {
  position: relative;
}

/* Keep off-canvas behaviour on mobile */
@media (max-width: 768px) {
  #sidebar, #privatePanel { position: fixed; }
}

/* BEGIN_MOBILE_COMPOSER_LAYOUT_STRAWBERRY */
@media (max-width: 768px) {
  .composer,
  .chat-composer,
  .message-composer {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .composer textarea,
  .chat-composer textarea,
  .message-composer textarea,
  .composer input[type="text"],
  .chat-composer input[type="text"],
  .message-composer input[type="text"] {
    width: 100%;
    max-width: 100%;
  }

  .composer .actions,
  .chat-composer .actions,
  .message-composer .actions {
    display: flex;
    width: 100%;
    gap: 8px;
    align-items: center;
  }

  .composer .actions .send-btn,
  .chat-composer .actions .send-btn,
  .message-composer .actions .send-btn {
    margin-left: auto;
  }
}
/* END_MOBILE_COMPOSER_LAYOUT_STRAWBERRY */

/* BEGIN_TOPBAR_ICONS_STRAWBERRY */
.topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topbar-btn .icon {
  font-size: 20px;
  line-height: 1;
}
/* END_TOPBAR_ICONS_STRAWBERRY */

/* BEGIN_MOBILE_COMPOSER_LAYOUT_V2_STRAWBERRY */
@media (max-width: 768px) {
  /* Любой композер формы (и общий, и приватный) */
  form.composer-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  /* Инпут всегда первой строкой и на всю ширину */
  form.composer-form > input,
  form.composer-form > textarea {
    flex: 1 0 100%;
    width: 100%;
    max-width: 100%;
    order: 1;
  }

  /* Все кнопки формы  второй строкой */
  form.composer-form > button,
  form.composer-form > .btn,
  form.composer-form > .button {
    order: 2;
    flex: 0 0 auto;
  }

  /* Для приватного композера: сначала форма (инпут/отправка), потом кнопки записи */
  #privateComposer {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  #privateComposer > form { order: 1; }
  #privateComposer > button { order: 2; } /* record/stop ниже */
}
/* END_MOBILE_COMPOSER_LAYOUT_V2_STRAWBERRY */

/* BEGIN_TOPBAR_ICONS_V2_STRAWBERRY */
#privateBtn::before {
  content: "";
  font-size: 20px;
  line-height: 1;
}
#menuBtn::before { content: ""; font-size: 20px; line-height: 1; }
/* END_TOPBAR_ICONS_V2_STRAWBERRY */

/* BEGIN_TOPBAR_ICONS_V3_STRAWBERRY */
#menuBtn::before {
  content: "";
  font-size: 20px;
  line-height: 1;
}
#privateBtn::before {
  content: "";
  font-size: 20px;
  line-height: 1;
}

/* небольшая нормализация размеров кнопок в топбаре на мобиле */
@media (max-width: 768px) {
  #menuBtn, #privateBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }
}
/* END_TOPBAR_ICONS_V3_STRAWBERRY */

/* BEGIN_IOS_SAFEAREA_PANELS_STRAWBERRY */
@media (max-width: 768px) {
  /* Сайдбар и приватная панель: высота по экрану iOS, со скроллом */
  #sidebar,
  #privatePanel {
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    box-sizing: border-box;
  }

  /* если есть overlay  пусть тоже не обрезается */
  #overlay {
    height: 100dvh;
  }
}
/* END_IOS_SAFEAREA_PANELS_STRAWBERRY */

/* BEGIN_PRIVATE_COMPOSER_GRID_STRAWBERRY */
@media (max-width: 768px) {
  #privateComposer {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    align-items: center;
  }

  /* Разворачиваем form так, чтобы элементы стали grid-items */
  #privateForm {
    display: contents;
  }

  /* 1) Инпут на всю ширину */
  #privateInput {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
  }

  /* 2) Ряд кнопок:   SEND (и при наличии ) */
  #privateRecordBtn { grid-column: 1 / 2; }
  #privateStopBtn   { grid-column: 2 / 3; }

  /* Кнопка отправки  у вас может быть submit без id, поэтому ловим оба варианта */
  #privateSendBtn,
  #privateForm button[type="submit"] {
    grid-column: 3 / 5;
    justify-self: stretch;
    width: 100%;
  }

  /* если emoji-кнопка есть и ты хочешь её справа  раскомментируй этот блок
  #privateEmojiBtn { grid-column: 4 / 5; }
  #privateSendBtn, #privateForm button[type="submit"] { grid-column: 3 / 4; }
  */

  /* 3) Панели форматирования/цвета  ниже и на всю ширину */
  #privateFormatBar,
  #privateEmojiPanel {
    grid-column: 1 / -1;
  }
}
/* END_PRIVATE_COMPOSER_GRID_STRAWBERRY */

/* BEGIN_GENERAL_COMPOSER_ALIGN_STRAWBERRY */
@media (max-width: 768px) {
  /* общий композер: инпут сверху, ниже один ряд кнопок */
  form.composer-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
  }

  form.composer-form > input,
  form.composer-form > textarea {
    flex: 1 0 100%;
    order: 1;
  }

  form.composer-form > button {
    order: 2;
    align-self: center;
  }

  /* если кнопка send широкая  пусть будет по центру и на одной линии */
  form.composer-form > button[type="submit"],
  form.composer-form > .send-btn {
    align-self: center;
  }
}
/* END_GENERAL_COMPOSER_ALIGN_STRAWBERRY */

/* BEGIN_GENERAL_COMPOSER_GRID_V1_STRAWBERRY */
@media (max-width: 768px) {
  /* Главный композер делаем grid: input сверху, ниже ряд кнопок */
  #composer {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    align-items: center;
  }

  /* Разворачиваем форму, чтобы input/send стали grid-item */
  #form { display: contents; }

  /* INPUT  верхняя строка, на всю ширину */
  #input {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
  }

  /* Нижняя строка     Send */
  .composer-left { display: contents; }
  .composer-right { display: contents; }

  #recordBtn { grid-column: 1 / 2; }
  #stopBtn   { grid-column: 2 / 3; }
  #emojiBtn  { grid-column: 3 / 4; }

  #form button[type="submit"].send-btn {
    grid-column: 4 / 5;
    width: 100%;
    justify-self: stretch;
  }

  /* Чтобы иконки кнопок не уплывали */
  #recordBtn, #stopBtn, #emojiBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }
}
/* END_GENERAL_COMPOSER_GRID_V1_STRAWBERRY */

/* BEGIN_PRIVATE_COMPOSER_GRID_V2_STRAWBERRY */
@media (max-width: 768px) {
  #privateComposer {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    align-items: center;
  }

  #privateForm { display: contents; }

  #privateInput {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
  }

  #privateRecordBtn { grid-column: 1 / 2; }
  #privateStopBtn   { grid-column: 2 / 3; }

  #privateForm button[type="submit"].send-btn {
    grid-column: 3 / -1;
    width: 100%;
    justify-self: stretch;
  }

  #privateRecordBtn, #privateStopBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }

  #privateFormatBar,
  #privateEmojiPanel {
    grid-column: 1 / -1;
  }
}
/* END_PRIVATE_COMPOSER_GRID_V2_STRAWBERRY */

/* BEGIN_PANELS_FIXED_INSET_STRAWBERRY */
@media (max-width: 768px) {
  #sidebar,
  #privatePanel {
    position: fixed;
    top: 0;
    bottom: 0;
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    box-sizing: border-box;
  }
}
/* END_PANELS_FIXED_INSET_STRAWBERRY */

/* BEGIN_PRIVATE_COMPOSER_ORDER_V1_STRAWBERRY */
@media (max-width: 768px) {
  #privateComposer { display: flex !important; flex-direction: column !important; gap: 10px; }

  #privateForm { display: contents !important; }

  #privateInput { order: 1; width: 100% !important; }

  /* ряд кнопок записи ниже input */
  #privateRecordBtn, #privateStopBtn {
    order: 2;
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 18px !important;
  }

  /* send рядом/ниже  делаем отдельной строкой, чтобы не резало */
  #privateForm .send-btn {
    order: 3;
    width: 100% !important;
    padding: 10px 12px !important;
  }

  /* формат/цвет  всегда самый низ */
  #privateFormatBar { order: 4; }
  #privateEmojiPanel { order: 5; }
}
/* END_PRIVATE_COMPOSER_ORDER_V1_STRAWBERRY */


/* BEGIN_PRIVATE_MOBILE_ROW_V1_STRAWBERRY */
@media (max-width: 768px) {
  /* 1) privatePanel: шапка должна быть видна */
  #privatePanel {
    /* если панель фиксированная  уменьшаем видимую высоту */
    top: calc(var(--mobileHeaderH, 64px) + env(safe-area-inset-top, 0px)) !important;
    bottom: env(safe-area-inset-bottom, 0px) !important;
    overflow-y: auto !important;
  }

  #privateHeader {
    position: sticky;
    top: 0;
    z-index: 5;
    /* легкий фон, чтобы текст не терялся на градиенте */
    background: rgba(255,255,255,0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding-top: 6px;
    padding-bottom: 6px;
  }

  /* 2) Приватный композер: input одной строкой */
  #privateInput {
    height: 42px !important;
    line-height: 42px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* 3) Раскладка: input сверху, ниже один ряд кнопок */
  #privateComposer {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
    align-items: center !important;
  }

  #privateForm { display: contents !important; }

  /* Ряд 1: input */
  #privateInput { grid-column: 1 / -1; }

  /* Ряд 2:    Send */
  #privateRecordBtn { grid-column: 1 / 2; }
  #privateStopBtn   { grid-column: 2 / 3; }
  #privateEmojiBtn  { grid-column: 3 / 4; }

  #privateForm .send-btn,
  #privateForm button[type="submit"] {
    grid-column: 4 / 5;
    width: 100% !important;
    padding: 8px 10px !important;
  }

  /* Кнопки поменьше */
  #privateRecordBtn, #privateStopBtn, #privateEmojiBtn {
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 18px !important;
  }

  /* Формат/цвет  ниже */
  #privateFormatBar,
  #privateEmojiPanel {
    grid-column: 1 / -1;
  }
}
/* END_PRIVATE_MOBILE_ROW_V1_STRAWBERRY */



/* BEGIN_PRIVATE_FINAL_TUNE_V1_STRAWBERRY */
@media (max-width: 768px) {
  /* Убираем подрезание снизу (iPhone safe-area + запас) */
  #privatePanel {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 28px) !important;
    box-sizing: border-box;
  }

  #privateComposer {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px) !important;
    box-sizing: border-box;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
    align-items: center !important;
  }

  /* Разворачиваем форму, чтобы input/send стали grid-item */
  #privateForm { display: contents !important; }

  /* Ряд 1: input */
  #privateInput {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 42px !important;
    line-height: 42px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  /* Ряд 2:    Send ( между записью и отправкой) */
  #privateRecordBtn { grid-column: 1 / 2 !important; grid-row: 2 !important; }
  #privateStopBtn   { grid-column: 2 / 3 !important; grid-row: 2 !important; }
  #privateEmojiBtn  { grid-column: 3 / 4 !important; grid-row: 2 !important; }

  #privateForm .send-btn,
  #privateForm button[type="submit"] {
    grid-column: 4 / 5 !important;
    grid-row: 2 !important;
    width: 100% !important;
    padding: 8px 10px !important;
  }

  /* Кнопки поменьше */
  #privateRecordBtn, #privateStopBtn, #privateEmojiBtn {
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 18px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Формат/цвет  ниже, во всю ширину */
  #privateFormatBar,
  #privateEmojiPanel {
    grid-column: 1 / -1 !important;
    grid-row: 3 !important;
  }
}
/* END_PRIVATE_FINAL_TUNE_V1_STRAWBERRY */



/* BEGIN_HIDE_PRIVATE_SHOWBTN_STRAWBERRY */
/* Убираем кнопку "Приват" на вкладке приватных сообщений */
#privateShowBtn {
  display: none !important;
}
/* END_HIDE_PRIVATE_SHOWBTN_STRAWBERRY */



/* BEGIN_PRIVATE_BOTTOM_SPACE_V1_STRAWBERRY */
@media (max-width: 768px) {
  /* Доп. место внизу приватной вкладки под color/style */
  #privateFormatBar {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px) !important;
    margin-bottom: 10px !important;
  }

  /* И небольшой общий запас снизу у композера */
  #privateComposer {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 22px) !important;
  }
}
/* END_PRIVATE_BOTTOM_SPACE_V1_STRAWBERRY */



/* BEGIN_IOS_NO_ZOOM_V1_STRAWBERRY */
html {
  -webkit-text-size-adjust: 100%;
}

/* iOS Safari zoom fix: font-size >= 16px on inputs */
@media (max-width: 768px) {
  input, textarea, select, button {
    font-size: 16px !important;
  }
}
/* END_IOS_NO_ZOOM_V1_STRAWBERRY */



/* BEGIN_GENERAL_FINAL_TUNE_V1_STRAWBERRY */
@media (max-width: 768px) {
  /* запас снизу под iOS safe-area */
  #composer {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px) !important;
    box-sizing: border-box;
  }

  /* Делаем grid: input сверху, ниже ряд кнопок, ниже формат */
  #composer {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
    align-items: center !important;
  }

  /* Разворачиваем form, чтобы input/send стали grid-item */
  #form { display: contents !important; }

  /* Ряд 1: input (одна строка) */
  #input {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 42px !important;
    line-height: 42px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  /* Ряд 2:    Send */
  .composer-left { display: contents !important; }
  .composer-right { display: contents !important; }

  #recordBtn { grid-column: 1 / 2 !important; grid-row: 2 !important; }
  #stopBtn   { grid-column: 2 / 3 !important; grid-row: 2 !important; }
  #emojiBtn  { grid-column: 3 / 4 !important; grid-row: 2 !important; }

  #form .send-btn,
  #form button[type="submit"] {
    grid-column: 4 / 5 !important;
    grid-row: 2 !important;
    width: 100% !important;
    padding: 8px 10px !important;
  }

  /* Кнопки поменьше */
  #recordBtn, #stopBtn, #emojiBtn {
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 18px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Формат/цвет  внизу */
  #formatBar,
  #emojiPanel {
    grid-column: 1 / -1 !important;
    grid-row: 3 !important;
  }

  /* Чтобы лента сообщений не залезала под композер */
  #chatContainer,
  #messages,
  .chat-container,
  .messages {
    padding-bottom: 210px !important;
  }
}
/* END_GENERAL_FINAL_TUNE_V1_STRAWBERRY */



/* BEGIN_SIDEBAR_TOP_OFFSET_V1_STRAWBERRY */
@media (max-width: 768px) {
  /* Подстройка высоты вашей верхней белой шапки (Strawberry Chat) */
  :root { --mobileHeaderH: 72px; }

  #sidebar {
    position: fixed !important;
    top: calc(var(--mobileHeaderH) + env(safe-area-inset-top, 0px)) !important;
    bottom: env(safe-area-inset-bottom, 0px) !important;
    height: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    padding-top: 10px !important;
  }

  /* Чтобы первый элемент списка не "прятался" из-за внешних margin */
  #sidebar > :first-child {
    margin-top: 0 !important;
  }
}
/* END_SIDEBAR_TOP_OFFSET_V1_STRAWBERRY */



/* BEGIN_TOPBAR_GRAY_BUTTON_ICONS_V1_STRAWBERRY */
#menuBtn, #privateBtn {
  color: #111 !important;
  text-indent: 0 !important;
  overflow: visible !important;
}

#menuBtn .icon, #privateBtn .icon {
  display: inline-block;
  font-size: 22px !important;
  line-height: 1 !important;
  color: #111 !important;
}

@media (max-width: 768px) {
  #menuBtn, #privateBtn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}
/* END_TOPBAR_GRAY_BUTTON_ICONS_V1_STRAWBERRY */



/* BEGIN_FORCE_TOPBAR_ICONS_VISIBLE_V1_STRAWBERRY */
/* Убираем конфликтующие псевдоэлементы */
#menuBtn::before, #menuBtn::after,
#privateBtn::before, #privateBtn::after {
  content: none !important;
  display: none !important;
}

/* Гарантируем, что реальные span.icon видимы */
#menuBtn, #privateBtn {
  font-size: 16px !important;   /* на случай font-size:0 */
  color: #111 !important;
  opacity: 1 !important;
}

#menuBtn .icon, #privateBtn .icon {
  display: inline-block !important;
  font-size: 22px !important;
  line-height: 1 !important;
  color: #111 !important;
  opacity: 1 !important;
  visibility: visible !important;
}

@media (max-width: 768px) {
  #menuBtn, #privateBtn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}
/* END_FORCE_TOPBAR_ICONS_VISIBLE_V1_STRAWBERRY */


/* BEGIN_TOPBAR_ICONS_ASCII_SAFE_V1_STRAWBERRY */
#menuBtn::before,
#privateBtn::before,
#menuBtn::after,
#privateBtn::after {
  display: none !important; /* отключаем все старые псевдо-элементы */
  content: none !important;
}

#menuBtn::before {
  display: inline-block !important;
  content: "\2630" !important; /*  */
  font-size: 22px !important;
  line-height: 1 !important;
  color: #111 !important;
}

#privateBtn::before {
  display: inline-block !important;
  content: "\1F4AC" !important; /*  */
  font-size: 22px !important;
  line-height: 1 !important;
  color: #111 !important;
}
/* END_TOPBAR_ICONS_ASCII_SAFE_V1_STRAWBERRY */


/* === Rules banner === */
.rules-banner{
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  font-size: 14px;
}

.rules-banner a{
  text-decoration: underline;
}

/* === Rules page === */
.rules-page{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.rules-wrap{
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.rules-wrap hr{
  margin: 18px 0;
  opacity: .3;
}

.rules-wrap .muted{
  opacity: .7;
  font-size: 13px;
}


/* === Login logo + rules link === */
.logo{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.logo .top-rules{
  font-size: 14px;
}


/* === Rules link on login page (left top) === */
.rules-toplink{
  position: fixed;
  left: 20px;
  top: 20px;
}


/* force rules link to the left on login page */
a.toplink.rules-toplink{
  left: 20px !important;
  right: auto !important;
  position: absolute !important;
  top: 20px !important;
}


/* === Privacy (ignore DMs) UI === */
.privacy-btn{
  margin-top: 8px;
  width: 100%;
}

.privacy-panel{
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
}

.privacy-panel.hidden{ display:none; }

.privacy-row{ margin-bottom: 10px; }
.privacy-row:last-child{ margin-bottom: 0; }

.privacy-check{
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.privacy-add{
  display: flex;
  gap: 10px;
  align-items: center;
}

#ignoreUserIdInput{
  flex: 1;
  min-width: 120px;
}

.privacy-subtitle{
  font-weight: 700;
  margin-bottom: 8px;
}

.ignored-list{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ignored-item{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.10);
}

.ignored-item .ignored-id{
  font-weight: 700;
}

.ignored-item button{
  padding: 6px 10px;
  border-radius: 12px;
}

.privacy-hint{
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.75;
  line-height: 1.35;
}

/* === Ignore search results === */
.privacy-search{
  display:flex;
  gap:10px;
  align-items:center;
}

#ignoreUserSearchInput{ flex:1; }

.ignore-search-results{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin: 6px 0 10px;
}

.search-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.12);
  border: 1px solid rgba(255,255,255,0.10);
}

.search-item .name{
  font-weight:700;
}

.search-item .meta{
  opacity:.75;
  font-size:12px;
  margin-left:8px;
}


:root { --chat-bg-gradient: none; }
body.has-custom-bg { background: var(--chat-bg-gradient) !important; }


/* === Mobile tap targets === */
#privateBtn, #privateShowBtn, #privateHideBtn,
#chatsBtn, #roomsBtn, #conversationsBtn {
  pointer-events: auto;
  touch-action: manipulation;
}
/* === /Mobile tap targets === */


/* === privateBlocked toast (center, light red) === */
#privateBlockedToast{
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  z-index: 99999;
  max-width: min(92vw, 520px);
  padding: 12px 14px;
  border-radius: 12px;
  background: #ffd6d6;
  color: #3b0b0b;
  border: 1px solid #ff9b9b;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  font-weight: 600;
  text-align: center;
}
/* === /privateBlocked toast === */


/* === Gradient vars defaults (chat) === */
:root{
  --ui-grad-1: #ffdde1;
  --ui-grad-2: #ee9ca7;
}
/* === /Gradient vars defaults === */


/* === Mobile tap fix: ensure top buttons clickable === */
#menuBtn, #privateBtn, #privacyBtn, #privateShowBtn, #privateHideBtn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto !important;
}

/* если верхняя панель/кнопки перекрываются  поднимем слой */
#menuBtn, #privateBtn {
  position: relative;
  z-index: 9999;
}
#privacyBtn {
  position: relative;
  z-index: 9999;
}

/* иногда контейнеры получают pointer-events:none на мобилке  страхуем */
header, #topbar, .topbar, .header, .toolbar {
  pointer-events: auto;
}
/* === /Mobile tap fix === */


/* === Mobile tap fix: ensure top buttons clickable === */
#menuBtn, #privateBtn, #privacyBtn, #privateShowBtn, #privateHideBtn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto !important;
}

/* если верхняя панель/кнопки перекрываются  поднимем слой */
#menuBtn, #privateBtn {
  position: relative;
  z-index: 9999;
}
#privacyBtn {
  position: relative;
  z-index: 9999;
}

/* иногда контейнеры получают pointer-events:none на мобилке  страхуем */
header, #topbar, .topbar, .header, .toolbar {
  pointer-events: auto;
}
/* === /Mobile tap fix === */


/* === Mobile: make top buttons reliably tappable === */
header, #topbar, .topbar {
  position: relative;
  z-index: 20000;
  pointer-events: auto;
}

#menuBtn, #privateBtn, #privacyBtn {
  position: relative;
  z-index: 20001;
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* === /Mobile tappable buttons === */


/* === Mobile topbar safety (no overlay override) === */
#mobileTopbar{
  position: sticky;
  top: 0;
  z-index: 30000;
  pointer-events: auto;
}
#menuBtn, #privateBtn{
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* === /Mobile topbar safety (no overlay override) === */


/* === privateBlocked toast (center) === */
#privateBlockedToast {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 210, 210, 0.96); /* light red */
  color: #3a1a1a;
  border: 1px solid rgba(180, 60, 60, 0.25);
  box-shadow: 0 10px 26px rgba(0,0,0,0.18);
  z-index: 4000;
  font-size: 14px;
  line-height: 1.25;
  display: none;
}
/* === /privateBlocked toast (center) === */


/* ===== REMOVE PRIVATE CLOSE BUTTON ON MOBILE ===== */

@media (max-width: 768px) {
    .private-close,
    .private-close-btn,
    .close-private,
    .dm-close {
        display: none !important;
    }
}

/* ===== END MOBILE FIX ===== */

/* ===== HARD MOBILE FIX: REMOVE PRIVATE CLOSE BUTTON ===== */
@media (max-width: 920px) {

  .p-tab .tab-close {
    display: none !important;
  }

  /* дополнительно убираем отступ справа */
  .p-tab {
    padding-right: 8px !important;
  }

}
