.chat-header { min-height: 67px; padding: 0 24px 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); box-shadow: 0 2px 7px rgba(31,44,61,.035); position: relative; z-index: 2; }
.chat-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-title-wrap > div { min-width: 0; }
.chat-title-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-title-line h1 { margin: 0; max-width: min(54vw, 650px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; line-height: 1.1; letter-spacing: .3px; text-transform: uppercase; }
.chat-title-wrap p { margin: 3px 0 0; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 560px; }
.room-count { min-width: 27px; height: 20px; padding: 0 7px; border-radius: 12px; display: grid; place-items: center; background: #b9bdc4; color: #fff; font-size: 11px; }
.chevron { color: #a3a8af; font-size: 11px; }
.chat-actions { display: flex; align-items: center; gap: 4px; }
.mode-button { width: 35px; height: 35px; border-radius: 10px; background: transparent; color: #a5abb3; font-size: 17px; }
.mode-button:hover { background: var(--surface-hover); color: var(--blue); }
.mode-button.active { background: #eef3ff; color: var(--blue); }

.presence-strip { min-height: 46px; padding: 5px 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #eef0f2; background: #fbfbfc; }
.presence-label { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; }
#people { min-width: 0; display: flex; align-items: center; flex: 1; padding-left: 4px; }
#people .character-portrait { width: 31px; height: 31px; margin-left: -7px; border: 2px solid #fff; box-shadow: 0 1px 4px #0001; }
#people .character-portrait:first-child { margin-left: 0; }
.presence-more { background: transparent; color: var(--blue); font-size: 11px; }

#messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 18px clamp(18px, 9vw, 110px) 24px; background-color: #fbfcfd; background-image: radial-gradient(circle at 2px 2px, rgba(91,111,134,.055) 1px, transparent 0); background-size: 22px 22px; scroll-behavior: smooth; }
.empty { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; text-align: center; color: var(--muted); font-size: 12px; }
.empty span { font-size: 26px; opacity: .55; }
.empty b { color: #68717b; font-size: 13px; }
.msg { max-width: 76%; display: flex; align-items: flex-end; gap: 9px; margin: 0 auto 12px 0; overflow-wrap: anywhere; }
.msg.self { margin-left: auto; margin-right: 0; flex-direction: row-reverse; }
.msg > .character-portrait { width: 37px; height: 37px; border: 2px solid #fff; box-shadow: 0 1px 5px rgba(40,55,70,.12); }
.msg-main { min-width: 0; }
.msg-meta { margin: 0 7px 3px; display: flex; gap: 8px; align-items: center; color: #788493; font-size: 11px; }
.msg.self .msg-meta { justify-content: flex-end; }
.msg-meta b { color: #607aa1; }
.msg.self .msg-meta b { color: #5b80c4; }
.msg-meta time { color: #adb3bb; font-size: 10px; }
.msg p { margin: 0; display: inline-block; max-width: 100%; padding: 9px 12px; border-radius: 5px 14px 14px 14px; background: #fff; border: 1px solid #edf0f3; box-shadow: 0 2px 6px rgba(34,48,64,.045); color: #222b34; font-size: 13px; line-height: 1.42; white-space: pre-wrap; }
.msg.self .msg-main { text-align: right; }
.msg.self p { text-align: left; background: #dcecff; border-color: #d3e6fb; border-radius: 14px 5px 14px 14px; }

.composer { min-height: 64px; padding: 9px clamp(18px, 7vw, 100px); display: grid; grid-template-columns: 36px minmax(0,1fr) 42px; gap: 8px; align-items: center; border-top: 1px solid var(--line); background: #fff; }
.composer input { min-width: 0; height: 43px; border: 0; background: transparent; color: var(--text); font-size: 14px; padding: 0 8px; }
.composer input::placeholder { color: #a4a9af; }
.composer-tool { width: 36px; height: 36px; border-radius: 50%; background: transparent; color: #9ba1a8; font-size: 23px; }
.composer-tool:hover { background: var(--surface-hover); color: #69717b; }
.send-button { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: transparent; color: var(--green); font-size: 25px; transform: rotate(-5deg); }
.send-button:hover { background: var(--green-soft); }


/* v17 — меню мира возле названия в верхней шапке */
.room-native-menu {
  position: relative;
  flex: 0 0 auto;
  z-index: 60;
}

.room-native-menu > summary {
  list-style: none;
}

.room-native-menu > summary::-webkit-details-marker {
  display: none;
}

.room-native-trigger {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
}

.room-native-trigger:hover {
  background: #f2f4f7;
}

.room-native-menu[open] .room-native-trigger {
  background: #f2f4f7;
}

.room-native-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 252px;
  max-height: calc(100dvh - 86px);
  padding: 8px;
  border-radius: 7px;
  background: #343a49;
  box-shadow: 0 14px 34px rgba(24,30,42,.28);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.28) transparent;
  z-index: 500;
}

.room-native-popup::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: 12px;
  top: -6px;
  background: #343a49;
  transform: rotate(45deg);
}

.room-native-item {
  width: 100%;
  min-height: 46px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #f4f6fb;
  display: grid;
  grid-template-columns: 34px minmax(0,1fr);
  align-items: center;
  gap: 7px;
  text-align: left;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.room-native-item:hover {
  background: rgba(255,255,255,.08);
}

.room-native-icon {
  color: #d9f64d;
  font-size: 19px;
  text-align: center;
}


/* v18 — список миров внутри «Сменить мир» */
.room-native-item.room-world-switch-toggle {
  grid-template-columns: 34px minmax(0,1fr) 22px;
}

.room-native-arrow {
  color: #aeb4c1;
  font-size: 22px;
  text-align: center;
  transition: transform .15s ease;
}

.room-world-switch-toggle[aria-expanded="true"] .room-native-arrow {
  transform: rotate(90deg);
}

.room-world-switcher[hidden] {
  display: none !important;
}

.room-world-switcher {
  margin: 3px 0 7px;
  padding: 5px;
  border-radius: 8px;
  background: rgba(15,19,28,.28);
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.room-world-option {
  width: 100%;
  min-height: 54px;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #eef1f6;
  display: grid;
  grid-template-columns: 30px minmax(0,1fr) auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}

.room-world-option:hover {
  background: rgba(255,255,255,.075);
}

.room-world-option.active {
  background: rgba(217,246,77,.09);
}

.room-world-option:disabled {
  opacity: .55;
  cursor: wait;
}

.room-world-option-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  display: grid;
  place-items: center;
  color: #d9f64d;
  font-size: 14px;
}

.room-world-option-content {
  min-width: 0;
}

.room-world-option-content b {
  display: block;
  color: #f6f7fa;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-world-option-content small {
  display: block;
  margin-top: 2px;
  color: #9fa6b4;
  font-size: 9px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-world-option-side {
  display: flex;
  align-items: center;
  gap: 5px;
}

.room-world-count {
  color: #aeb5c1;
  font-size: 9px;
  white-space: nowrap;
}

.room-world-check {
  width: 18px;
  color: #d9f64d;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}


/* v19 — категории миров в стиле списка, как на присланном скрине */
.room-world-switcher[hidden] { display: none !important; }

.room-world-switcher {
  margin: 3px 0 7px;
  border-radius: 8px;
  background: rgba(15,19,28,.18);
  overflow: hidden;
}

.room-world-categories,
.room-world-list-view {
  padding: 4px 0;
}

.room-world-category,
.room-world-back {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: #f4f6fb;
  display: grid;
  grid-template-columns: 24px minmax(0,1fr);
  align-items: center;
  gap: 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.room-world-category:hover,
.room-world-back:hover {
  background: rgba(255,255,255,.08);
}

.room-world-category-icon {
  color: #d9f64d;
  font-size: 18px;
  text-align: center;
  line-height: 1;
}

.room-world-list-title {
  padding: 6px 14px 8px;
  color: #aeb5c1;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.room-world-realms {
  padding: 0 5px 5px;
  max-height: 255px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.room-native-item.room-world-switch-toggle {
  grid-template-columns: 34px minmax(0,1fr) 22px;
}

.room-native-arrow {
  color: #aeb4c1;
  font-size: 22px;
  text-align: center;
  transition: transform .15s ease;
}

.room-world-switch-toggle[aria-expanded='true'] .room-native-arrow {
  transform: rotate(90deg);
}


.room-native-popup::-webkit-scrollbar {
  width: 6px;
}

.room-native-popup::-webkit-scrollbar-track {
  background: transparent;
}

.room-native-popup::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.25);
  border-radius: 999px;
}

.room-native-popup::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.38);
}

/* Вложенный список не создаёт второй большой скролл.
   Скроллится само меню целиком — так на маленьких экранах ничего не обрезается. */
.room-world-switcher,
.room-world-realms {
  max-height: none;
}

.room-world-realms {
  overflow: visible;
}


/* v21: меню категорий больше не рисует список миров внутри dropdown. */
.room-world-list-view,
.room-world-realms,
.room-world-back,
.room-world-list-title {
  display: none !important;
}

.room-world-category {
  min-height: 42px;
}

.chat-header {
  min-height: 64px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #ebeff4;
  box-shadow: none;
  background: #fff;
}

.chat-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.chat-title-line-compact {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.chat-title-line-compact .ui-icon {
  width: 27px;
  height: 27px;
  color: #3c4757;
}

.chat-title-line-compact h2 {
  margin: 0;
  color: #263140;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.chat-presence-inline {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #637083;
}

.chat-presence-label {
  color: #5f6d80;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

#people {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

#people .location-person-link + .location-person-link {
  margin-left: -8px;
}

#people .character-portrait {
  width: 34px;
  height: 34px;
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,.08);
}

#messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 22px 12px;
  background: linear-gradient(180deg, #fbfcfe 0%, #f8fafc 100%);
  scrollbar-gutter: stable;
}

.empty {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  color: #7d8896;
  font-size: 12px;
}

.empty span { font-size: 25px; opacity: .6; }
.empty b { color: #596678; font-size: 14px; }

.msg {
  max-width: min(560px, 78%);
  gap: 10px;
  margin: 0 auto 12px 0;
}

.msg > .character-portrait {
  width: 40px;
  height: 40px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(29,44,66,.1);
}

.msg-meta {
  margin: 0 7px 4px;
  gap: 7px;
  color: #7c8896;
  font-size: 12px;
}

.msg-meta b {
  color: #233247;
}

.msg-meta time {
  color: #94a0af;
  font-size: 11px;
}

.msg p {
  padding: 10px 14px;
  border-radius: 0 16px 16px 16px;
  background: #eef2f7;
  border: 1px solid #e4ebf3;
  box-shadow: none;
  color: #223043;
  font-size: 14px;
  line-height: 1.42;
}

.msg.self p {
  background: #dff7ea;
  border-color: #cdeedc;
  border-radius: 16px 0 16px 16px;
}

.composer {
  min-height: 76px;
  padding: 12px 18px 14px;
  display: grid;
  grid-template-columns: 44px minmax(0,1fr) 72px;
  gap: 10px;
  align-items: center;
  border-top: 1px solid #ebeff4;
  background: #fff;
}

.composer-tool {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #dce4ec;
  color: #738093;
  font-size: 24px;
}

.composer-tool:hover {
  background: #f4f7fa;
  color: #5f6e80;
}

.composer input {
  min-width: 0;
  height: 46px;
  padding: 0 18px;
  border: 1px solid #dde6ee;
  border-radius: 17px;
  background: #fbfcfe;
  color: #223043;
  font-size: 14px;
}

.send-button {
  width: 64px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #43d77a 0%, #31c967 100%);
  color: #fff;
  font-size: 26px;
  transform: none;
  box-shadow: 0 12px 24px rgba(63, 204, 112, .22);
}

.send-button:hover {
  background: linear-gradient(180deg, #4ce27f 0%, #36d06c 100%);
}

/* v156 — социальные действия между персонажами в общей комнате. */
.msg.interaction p {
  background: #f7f4ff;
  border-color: #e8e0ff;
  color: #4e4960;
  font-weight: 650;
}
.msg.interaction.self p {
  background: #eef4ff;
  border-color: #dce7fb;
}


/* v164 — gift messages render the actual gift image */
.msg.gift-message .msg-main { max-width: min(280px, 72vw); }
.msg-gift {
  display: inline-flex;
  flex-direction: column;
  gap: 7px;
  align-items: flex-start;
  padding: 9px;
  border: 1px solid #edf0f3;
  border-radius: 5px 16px 16px 16px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(34,48,64,.06);
}
.msg.self .msg-gift {
  align-items: flex-end;
  border-color: #d3e6fb;
  border-radius: 16px 5px 16px 16px;
  background: #eef6ff;
}
.msg-gift img {
  width: 112px;
  height: 112px;
  object-fit: contain;
  display: block;
  border-radius: 14px;
  background: linear-gradient(145deg,#fff7fb,#f6f1ff);
}
.msg-gift p,
.msg.self .msg-gift p {
  max-width: 230px;
  padding: 0 3px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #4b5563;
  font-size: 11px;
  line-height: 1.35;
}
@media (max-width: 640px) {
  .msg-gift img { width: 96px; height: 96px; border-radius: 12px; }
  .msg.gift-message .msg-main { max-width: 70vw; }
}
