* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f8fa;
  color: #16181d;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 292px;
  overflow: hidden;
}

.sidebar, .people-panel { background: #fbfbfc; }
.sidebar {
  border-right: 1px solid #e8e9ed;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 8px 18px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #15171b;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: -.04em;
}
.brand strong, .brand span { display: block; }
.brand strong {
  font-size: 14px;
  letter-spacing: .08em;
  font-weight: 900;
}
.brand span {
  font-size: 11px;
  color: #8b8e96;
  margin-top: 2px;
}
.section-title, .eyebrow, .modal-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  color: #9da0a8;
}
.section-title { padding: 20px 10px 8px; }

.room-list { display: flex; flex-direction: column; gap: 4px; }
.room-item {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  color: #565a63;
}
.room-item:hover { background: #f1f2f5; }
.room-item.active { background: #15171b; color: #fff; }
.room-icon { font-size: 15px; }
.room-copy strong, .room-copy small { display: block; }
.room-copy strong { font-size: 13px; }
.room-copy small { font-size: 10px; opacity: .65; margin-top: 2px; }
.room-count {
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(127,127,127,.12);
}

.sidebar-footer { margin-top: auto; padding-top: 16px; }
.profile-chip {
  border: 0;
  width: 100%;
  background: transparent;
  border-radius: 12px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
}
.profile-chip:hover { background: #f1f2f5; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e7e9ee;
  color: #4b4f58;
  font-weight: 800;
  font-size: 12px;
  flex: 0 0 auto;
}
.avatar-me { background: #15171b; color: #fff; }
.profile-copy strong, .profile-copy small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-copy strong { font-size: 12px; }
.profile-copy small { font-size: 10px; color: #92959c; margin-top: 2px; }
.admin-entry {
  width: 100%;
  margin-top: 6px;
  border: 1px dashed #d9dbe1;
  background: transparent;
  color: #666b73;
  padding: 10px 12px;
  border-radius: 12px;
  text-align: left;
  font-size: 12px;
}
.admin-entry:hover { background: #f6f7f9; }

.chat-panel {
  min-width: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.chat-header {
  height: 76px;
  border-bottom: 1px solid #eceef1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  flex: 0 0 auto;
}
.room-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
}
.room-heading h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: -.02em;
  font-weight: 850;
}
.room-heading span { font-size: 11px; color: #8b8e95; }
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #28a765;
}
.header-actions { display: flex; gap: 7px; align-items: center; }
.icon-btn {
  border: 1px solid #e3e5e9;
  background: #fff;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  color: #4c5059;
}

.expertise-strip {
  min-height: 51px;
  border-bottom: 1px solid #f0f1f3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  overflow: auto;
  flex: 0 0 auto;
}
.strip-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  color: #9b9ea5;
  white-space: nowrap;
}
.chips { display: flex; gap: 7px; }
.chip {
  border: 1px solid #e5e7ea;
  background: #fff;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 10px;
  color: #555963;
  white-space: nowrap;
}
.chip strong { color: #191b20; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 22px 120px;
  scroll-behavior: smooth;
}
.message {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  padding: 10px 0;
  max-width: 780px;
}
.message:hover .msg-actions { opacity: 1; }
.msg-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.msg-name { font-size: 12px; font-weight: 800; }
.msg-expertise {
  font-size: 9px;
  border: 1px solid #e5e7ea;
  border-radius: 999px;
  padding: 2px 6px;
  color: #747881;
}
.msg-time { font-size: 9px; color: #a2a5ab; }
.msg-body {
  font-size: 13px;
  line-height: 1.55;
  color: #30333a;
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-body.caption { margin-top: 8px; }
.msg-media {
  margin-top: 8px;
  max-width: 360px;
}
.msg-media img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  border: 1px solid #eceef3;
  box-shadow: 0 12px 30px rgba(31,34,41,.05);
}
.msg-sticker {
  margin-top: 6px;
  font-size: 42px;
  line-height: 1;
}
.msg-actions {
  opacity: 0;
  margin-top: 5px;
  display: flex;
  gap: 8px;
  transition: .15s;
}
.msg-actions button {
  border: 0;
  background: transparent;
  color: #9498a0;
  font-size: 10px;
  padding: 0;
}
.msg-actions button:hover { color: #202329; }
.reply-context {
  border-left: 2px solid #d3d5da;
  padding-left: 7px;
  color: #8a8d94;
  font-size: 10px;
  margin: 4px 0 6px;
}
.empty-state {
  text-align: center;
  color: #a0a3aa;
  margin: 18vh auto;
}
.empty-orb {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: #f1f2f5;
  display: grid;
  place-items: center;
  margin: auto;
  font-size: 22px;
}
.empty-state h2 {
  font-size: 14px;
  color: #555963;
  margin: 12px 0 5px;
}
.empty-state p { font-size: 11px; margin: 0; }

.composer-wrap {
  position: sticky;
  bottom: 0;
  z-index: 8;
  background: linear-gradient(to top, rgba(255,255,255,1) 78%, rgba(255,255,255,.92) 92%, rgba(255,255,255,0));
  border-top: 1px solid #eef0f3;
  padding: 10px 20px 16px;
}
.composer {
  border: 1px solid #dfe1e5;
  background: #fff;
  border-radius: 16px;
  display: grid;
  grid-template-columns: 36px 36px 1fr auto;
  align-items: center;
  padding: 5px;
  gap: 4px;
  box-shadow: 0 7px 30px rgba(30,33,40,.05);
}
.composer input[type="text"], .composer input:not([type]) , .composer #messageInput {
  border: 0;
  outline: 0;
  padding: 10px 4px;
  font-size: 13px;
  min-width: 0;
}
.composer-icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: #f3f4f6;
  border-radius: 10px;
  font-size: 15px;
}
.composer-icon-btn:hover { background: #eceef2; }
.send-btn {
  border: 0;
  background: #15171b;
  color: #fff;
  border-radius: 11px;
  padding: 9px 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.composer-help {
  font-size: 9px;
  color: #aaadb3;
  margin: 6px 8px 0;
}
.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f5f6f8;
  border: 1px solid #e9eaed;
  border-radius: 10px;
  padding: 7px 9px;
  margin-bottom: 6px;
  font-size: 10px;
  color: #6d717a;
}
.reply-preview button { border: 0; background: transparent; }

.sticker-popover {
  position: absolute;
  left: 22px;
  bottom: 84px;
  width: min(320px, calc(100% - 44px));
  background: #fff;
  border: 1px solid #e3e5ea;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(23,26,32,.12);
  padding: 12px;
}
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.sticker-btn {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  background: #f4f5f7;
  border-radius: 14px;
  font-size: 28px;
}
.sticker-btn:hover { background: #eceef2; }

.people-panel {
  border-left: 1px solid #e8e9ed;
  padding: 18px 14px;
  overflow-y: auto;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 5px 15px;
}
.panel-header h2 { font-size: 16px; margin: 3px 0 0; }
.people-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 4px 15px;
}
.summary-pill {
  border-radius: 999px;
  background: #f0f1f4;
  padding: 5px 8px;
  font-size: 9px;
  color: #666a73;
}
.people-list { display: flex; flex-direction: column; }
.person {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 8px 5px;
  border-radius: 11px;
}
.person:hover { background: #f4f5f7; }
.presence-wrap { position: relative; }
.presence-wrap:after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 8px;
  height: 8px;
  border: 2px solid #fbfbfc;
  border-radius: 50%;
  background: #28a765;
}
.person-copy { min-width: 0; }
.person-copy strong, .person-copy span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person-copy strong { font-size: 11px; }
.person-copy span { font-size: 9px; color: #92959c; margin-top: 2px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14,16,20,.34);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 20px;
}
.modal {
  background: #fff;
  width: min(390px, 100%);
  border-radius: 22px;
  padding: 25px;
  box-shadow: 0 20px 70px rgba(0,0,0,.18);
}
.modal-wide { width: min(620px, 100%); }
.modal h2 {
  font-size: 22px;
  margin: 6px 0 7px;
}
.modal p {
  font-size: 12px;
  line-height: 1.55;
  color: #777b83;
  margin: 0 0 18px;
}
.modal label { display: block; margin-bottom: 12px; }
.modal label span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #656973;
  margin-bottom: 6px;
}
.modal input, .modal select {
  width: 100%;
  border: 1px solid #dfe1e5;
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  background: #fff;
}
.primary-btn {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: #15171b;
  color: #fff;
  padding: 12px;
  font-weight: 800;
  margin-top: 5px;
}
.text-btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: #92959c;
  padding: 11px;
  font-size: 11px;
}
.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 12px;
}
.admin-form-grid .full { grid-column: 1 / -1; }
.admin-room-list-wrap {
  margin-top: 20px;
  border-top: 1px solid #edf0f3;
  padding-top: 16px;
}
.admin-room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.admin-room-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #f7f8fa;
  border-radius: 14px;
}
.admin-room-row strong, .admin-room-row span {
  display: block;
}
.admin-room-row strong { font-size: 13px; }
.admin-room-row span {
  font-size: 10px;
  color: #838892;
  margin-top: 2px;
}
.admin-status {
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e2e5ea;
  color: #5b616b;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #15171b;
  color: #fff;
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 11px;
  z-index: 50;
}

.sound-wrap { position: relative; }
.sound-popover {
  position: absolute;
  right: 0;
  top: 44px;
  width: 260px;
  background: #fff;
  border: 1px solid #e3e5e9;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 20px 60px rgba(23,26,32,.12);
  z-index: 25;
}
.sound-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.sound-row strong { display: block; font-size: 12px; }
.sound-row small { display: block; font-size: 10px; color: #8a8d95; margin-top: 3px; }
.mini-toggle {
  border: 1px solid #dfe2e7;
  background: #15171b;
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 800;
}
.mini-toggle.off { background: #fff; color: #676b74; }
.sound-slider-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 11px;
  color: #61656d;
}
.sound-slider-row input[type="range"] { width: 100%; }

.mobile-only { display: none; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .people-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 92vw);
    z-index: 20;
    box-shadow: -16px 0 60px rgba(0,0,0,.12);
    transform: translateX(105%);
    transition: .2s;
  }
  .people-panel.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
}

@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 88vw);
    z-index: 25;
    box-shadow: 16px 0 60px rgba(0,0,0,.12);
    transform: translateX(-105%);
    transition: .2s;
  }
  .sidebar.open { transform: translateX(0); }
  .chat-panel { height: 100vh; }
  .chat-header { height: 67px; padding: 0 14px; }
  .expertise-strip { padding: 0 14px; }
  .messages { padding: 10px 14px 112px; }
  .composer-wrap { padding: 8px 10px 12px; }
  .sticker-popover {
    left: 10px;
    bottom: 82px;
    width: min(320px, calc(100% - 20px));
  }
  .sound-popover { right: -8px; width: min(260px, 90vw); }
  .mobile-only { display: inline-grid; place-items: center; }
  .msg-actions { opacity: 1; }
  .room-heading h1 { font-size: 18px; }
  .admin-form-grid { grid-template-columns: 1fr; }
}
