:root {
  color-scheme: light;
  --bg: #e9edf3;
  --bg-accent: rgba(61, 137, 227, 0.18);
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --panel-alt: #edf4fb;
  --panel-raised: #ffffff;
  --text: #12161d;
  --text-soft: #5d6978;
  --text-faint: #8793a3;
  --border: #c9d3e0;
  --border-strong: #b4c0cf;
  --accent: #257fd9;
  --accent-strong: #1768ba;
  --accent-soft: #e8f2ff;
  --accent-border: #bfd4ef;
  --warn-bg: #fff6d9;
  --warn-border: #e4cf84;
  --warn-text: #5d4902;
  --danger: #d84b58;
  --shadow: 0 18px 42px rgba(20, 38, 63, 0.14);
  --shadow-soft: 0 10px 26px rgba(20, 38, 63, 0.1);
  --message-hover: #f1f7ff;
  --input-bg: #ffffff;
  --chip-bg: #f3f5f8;
  --chip-border: #aab5c4;
  --chip-hover: #e7edf5;
  --lightbox-bg: #0f1319;
  --dm-me: #ebf2ff;
  --dm-me-border: #c9daf8;
  --dm-other: #f4f6f8;
  --dm-other-border: #d4dbe4;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111317;
    --bg-accent: rgba(96, 132, 196, 0.08);
    --panel: #0f1114;
    --panel-soft: #15181d;
    --panel-alt: #181b20;
    --panel-raised: #171a1f;
    --text: #f7f7f7;
    --text-soft: #b1b5bc;
    --text-faint: #7b818b;
    --border: #252a31;
    --border-strong: #2f353e;
    --accent: #7aa2e8;
    --accent-strong: #9dbdff;
    --accent-soft: #1b2432;
    --accent-border: #35507e;
    --warn-bg: #3a3216;
    --warn-border: #655325;
    --warn-text: #efe0a4;
    --danger: #ff5d5d;
    --shadow: 0 20px 48px rgba(0, 0, 0, 0.55);
    --shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.36);
    --message-hover: #11151a;
    --input-bg: #05080c;
    --chip-bg: #161a20;
    --chip-border: #313844;
    --chip-hover: #1b2129;
    --lightbox-bg: #000000;
    --dm-me: #2a3342;
    --dm-me-border: #41546f;
    --dm-other: #2a2d33;
    --dm-other-border: #3b404a;
  }
}

body.theme-light {
  color-scheme: light;
  --bg: #e9edf3;
  --bg-accent: rgba(61, 137, 227, 0.18);
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --panel-alt: #edf4fb;
  --panel-raised: #ffffff;
  --text: #12161d;
  --text-soft: #5d6978;
  --text-faint: #8793a3;
  --border: #c9d3e0;
  --border-strong: #b4c0cf;
  --accent: #257fd9;
  --accent-strong: #1768ba;
  --accent-soft: #e8f2ff;
  --accent-border: #bfd4ef;
  --warn-bg: #fff6d9;
  --warn-border: #e4cf84;
  --warn-text: #5d4902;
  --danger: #d84b58;
  --shadow: 0 18px 42px rgba(20, 38, 63, 0.14);
  --shadow-soft: 0 10px 26px rgba(20, 38, 63, 0.1);
  --message-hover: #f1f7ff;
  --input-bg: #ffffff;
  --chip-bg: #f3f5f8;
  --chip-border: #aab5c4;
  --chip-hover: #e7edf5;
  --lightbox-bg: #0f1319;
  --dm-me: #ebf2ff;
  --dm-me-border: #c9daf8;
  --dm-other: #f4f6f8;
  --dm-other-border: #d4dbe4;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #111317;
  --bg-accent: rgba(96, 132, 196, 0.08);
  --panel: #0f1114;
  --panel-soft: #15181d;
  --panel-alt: #181b20;
  --panel-raised: #171a1f;
  --text: #f7f7f7;
  --text-soft: #b1b5bc;
  --text-faint: #7b818b;
  --border: #252a31;
  --border-strong: #2f353e;
  --accent: #7aa2e8;
  --accent-strong: #9dbdff;
  --accent-soft: #1b2432;
  --accent-border: #35507e;
  --warn-bg: #3a3216;
  --warn-border: #655325;
  --warn-text: #efe0a4;
  --danger: #ff5d5d;
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.36);
  --message-hover: #11151a;
  --input-bg: #05080c;
  --chip-bg: #161a20;
  --chip-border: #313844;
  --chip-hover: #1b2129;
  --lightbox-bg: #000000;
  --dm-me: #2a3342;
  --dm-me-border: #41546f;
  --dm-other: #2a2d33;
  --dm-other-border: #3b404a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Tahoma, Verdana, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  background-image:
    radial-gradient(circle at top left, var(--bg-accent), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  background-attachment: fixed;
  transition: background-color 0.18s ease, color 0.18s ease;
}

body.theme-dark {
  background-image: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea,
a {
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease,
    opacity 0.16s ease,
    transform 0.16s ease;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 8px 14px 14px;
}

.room-title-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.room-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 10px;
  gap: 12px;
}

.room-title {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.04em;
}

.more-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--chip-border) 86%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--chip-bg) 78%, var(--panel)), var(--chip-bg));
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.more-link:hover {
  background: linear-gradient(180deg, color-mix(in srgb, var(--chip-hover) 84%, var(--panel)), var(--chip-hover));
  border-color: color-mix(in srgb, var(--accent-border) 58%, var(--chip-border));
}

.status {
  min-height: 18px;
  margin: 0 0 8px;
  padding-left: 4px;
  font-size: 13px;
  color: var(--text-soft);
}

.status.error {
  color: var(--danger);
}

.room-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--warn-bg) 90%, var(--panel)), var(--warn-bg));
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  padding: 11px 12px;
  margin-bottom: 10px;
  font-size: 14px;
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.room-notice-btn {
  border: 1px solid var(--warn-border);
  background: color-mix(in srgb, var(--warn-bg) 80%, var(--panel));
  color: inherit;
  height: 34px;
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.room-notice-btn:hover {
  background: color-mix(in srgb, var(--warn-bg) 64%, var(--panel));
}

.account-state {
  font-size: 13px;
  color: var(--text-soft);
  margin-left: auto;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.chat-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.chat {
  flex: 1;
  min-height: 560px;
  overflow-y: auto;
}

.user-panel {
  min-height: 560px;
  overflow-y: auto;
}

.chat,
.user-panel {
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-raised) 92%, var(--panel-soft)), var(--panel));
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.user-panel-title {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--panel-soft), color-mix(in srgb, var(--panel-soft) 80%, var(--panel)));
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  z-index: 1;
}

.user-list {
  padding: 8px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid transparent;
  transition:
    background-color 0.14s ease,
    border-color 0.14s ease;
}

.user-row:hover {
  background: var(--message-hover);
  border-color: color-mix(in srgb, var(--accent-border) 72%, var(--border));
}

.user-row-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
  word-break: break-word;
}

.user-row-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.24;
}

.user-avatar,
.avatar,
.profile-avatar,
.dm-avatar,
.dm-msg-avatar,
.people-card-avatar,
.member-avatar {
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-soft) 88%, var(--panel)), var(--panel-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.user-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  font-size: 16px;
  border-radius: 12px;
}

.avatar {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  font-size: 24px;
  border-radius: 15px;
}

.profile-avatar {
  width: 98px;
  height: 98px;
  margin: 4px auto 14px;
  font-size: 44px;
  border-radius: 20px;
}

.dm-avatar {
  width: 46px;
  height: 46px;
  font-size: 22px;
  border-radius: 14px;
}

.dm-msg-avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  font-size: 16px;
  border-radius: 10px;
}

.people-card-avatar,
.member-avatar {
  width: 54px;
  height: 54px;
  font-size: 22px;
  border-radius: 14px;
}

.user-avatar img,
.avatar img,
.profile-avatar img,
.dm-avatar img,
.dm-msg-avatar img,
.people-card-avatar img,
.member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar.clickable,
.username.clickable {
  cursor: pointer;
}

.avatar.clickable:hover,
.username.clickable:hover {
  opacity: 0.85;
}

.message {
  display: flex;
  gap: 12px;
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  transition:
    background-color 0.14s ease,
    transform 0.14s ease;
}

.message:hover {
  background: var(--message-hover);
}

.message-body {
  flex: 1;
  min-width: 0;
}

.meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.meta-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.username {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.12;
}

.time {
  font-size: 13px;
  color: var(--text-faint);
  white-space: nowrap;
  line-height: 1.1;
}

.mod-mini-btn {
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--text-soft);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 999px;
  font-weight: 700;
}

.mod-mini-btn:hover {
  background: var(--chip-hover);
  border-color: color-mix(in srgb, var(--accent-border) 60%, var(--chip-border));
}

.text {
  font-size: 18px;
  line-height: 1.3;
  color: var(--text);
  word-break: break-word;
}

.msg-image {
  display: block;
  max-width: min(320px, 100%);
  margin-top: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.msg-image:hover {
  opacity: 0.92;
}

.msg-audio,
.dm-audio {
  display: block;
  width: min(100%, 320px);
  margin-top: 8px;
  accent-color: var(--accent);
}

.voice-recording {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-soft) 70%, transparent);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.room-identity-panel .field-full textarea {
  min-height: 92px;
}

body.theme-dark .top-bar {
  padding-top: 12px;
}

body.theme-dark .more-link,
body.theme-dark .small-action-btn,
body.theme-dark .tool-btn {
  background: #14181d;
}

body.theme-dark .chat,
body.theme-dark .input-shell,
body.theme-dark .user-panel,
body.theme-dark .room-controls-panel,
body.theme-dark .settings-preview,
body.theme-dark .people-item,
body.theme-dark .members-list,
body.theme-dark .member-row,
body.theme-dark .empty-box,
body.theme-dark .dm-chat {
  background: var(--panel);
}


.input-shell {
  padding: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-raised) 94%, var(--panel-soft)), var(--panel));
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 12px;
}

.reply-label {
  font-size: 13px;
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}

.reply-cancel-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.typing-bar {
  min-height: 18px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-soft);
  padding-left: 2px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  font-size: 20px;
  color: var(--text-soft);
  cursor: pointer;
  padding: 0;
  border-radius: 10px;
  flex-shrink: 0;
}

.tool-btn:hover {
  background: var(--panel-alt);
  border-color: var(--accent-border);
}

#messageInput,
#dmInput,
#membersSearch,
#membersAgeFilter,
#membersGenderFilter,
.field input,
.field select,
.field textarea {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#messageInput:focus,
#dmInput:focus,
#membersSearch:focus,
#membersAgeFilter:focus,
#membersGenderFilter:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-soft) 82%, transparent);
}

#messageInput,
#dmInput {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 8px 12px;
  font-size: 16px;
}

#membersSearch,
#membersAgeFilter,
#membersGenderFilter,
.field input,
.field select {
  height: 40px;
  padding: 8px 10px;
  font-size: 14px;
}

.field textarea {
  padding: 10px 12px;
  font-size: 14px;
  resize: vertical;
}

#sendBtn,
#sendDmBtn,
.modal-btn,
.small-action-btn {
  border: 1px solid var(--chip-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--chip-bg) 76%, var(--panel)), var(--chip-bg));
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  border-radius: 12px;
  font-weight: 700;
}

#sendBtn,
#sendDmBtn,
.modal-btn {
  min-width: 92px;
  height: 40px;
  padding: 0 14px;
}

.small-action-btn {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 999px;
}

#sendBtn:hover,
#sendDmBtn:hover,
.modal-btn:hover,
.small-action-btn:hover {
  background: linear-gradient(180deg, color-mix(in srgb, var(--chip-hover) 82%, var(--panel)), var(--chip-hover));
  border-color: color-mix(in srgb, var(--accent-border) 56%, var(--chip-border));
}

.bottom-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  color: var(--text-soft);
  flex-wrap: wrap;
}

.bottom-icon {
  font-size: 18px;
}

.set-name {
  font-size: 14px;
  cursor: pointer;
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.set-name:hover {
  color: var(--accent);
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.54);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: 999;
}

.modal-card {
  width: 100%;
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-soft) 92%, var(--panel-raised)), var(--panel-soft));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  position: relative;
  color: var(--text);
  border-radius: 16px;
}

.profile-card {
  max-width: 440px;
  padding: 24px 20px 20px;
  text-align: center;
}

.settings-card,
.auth-card {
  max-width: 620px;
  padding: 24px 20px 20px;
}

.settings-card,
.auth-card,
.profile-card,
#roomControlsModal .modal-card {
  overflow: visible;
}

.lightbox-card {
  width: 100%;
  max-width: 920px;
  max-height: calc(100dvh - 28px);
  background: var(--lightbox-bg);
  border: 1px solid var(--border-strong);
  position: relative;
  padding: 42px 12px 12px;
  border-radius: 20px;
}

.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 90px);
  margin: 0 auto;
  object-fit: contain;
  border-radius: 14px;
}

.close-btn {
  position: absolute;
  right: 8px;
  top: 6px;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-soft);
  border-radius: 999px;
}

.close-btn:hover {
  background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
}

.lightbox-card .close-btn {
  color: #ffffff;
}

.profile-name {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.profile-sub {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 4px;
  line-height: 1.35;
}

.profile-facts {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--chip-bg) 82%, var(--panel)), var(--chip-bg));
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.profile-chip-accent {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 86%, var(--panel)), var(--accent-soft));
  border-color: color-mix(in srgb, var(--accent-border) 78%, var(--chip-border));
  color: var(--accent-strong);
}

.profile-chip-success {
  background: linear-gradient(180deg, color-mix(in srgb, #dff8e4 82%, var(--panel)), color-mix(in srgb, #c9f0d3 88%, var(--panel)));
  border-color: color-mix(in srgb, #7cc98f 62%, var(--chip-border));
  color: #267143;
}

.profile-chip-danger {
  background: linear-gradient(180deg, color-mix(in srgb, #ffe8eb 82%, var(--panel)), color-mix(in srgb, #ffdadd 86%, var(--panel)));
  border-color: color-mix(in srgb, #ef9aa6 60%, var(--chip-border));
  color: #a23b48;
}

.profile-chip-muted {
  background: linear-gradient(180deg, color-mix(in srgb, var(--chip-bg) 82%, var(--panel)), var(--chip-bg));
  border-color: color-mix(in srgb, var(--chip-border) 82%, var(--border));
  color: var(--text-soft);
}

.profile-bio {
  margin-top: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--panel) 88%, var(--panel-soft));
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.profile-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.mini-status {
  min-height: 18px;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 10px;
}

.room-controls-overview {
  white-space: pre-wrap;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 78%, var(--panel)), color-mix(in srgb, var(--panel) 88%, var(--panel-soft)));
  border-color: color-mix(in srgb, var(--accent-border) 72%, var(--border));
}

.room-controls-grid,
.room-controls-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.room-controls-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.room-controls-panel {
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 90%, var(--panel-soft)), var(--panel));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.room-controls-actions {
  justify-content: flex-start;
  margin-top: 0;
}

.room-controls-form {
  margin-top: 2px;
}

.auth-note {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 10px;
  line-height: 1.35;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 13px;
  color: var(--text-soft);
}

.field-full {
  grid-column: 1 / -1;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
}

.checkbox-field input {
  width: auto;
  height: auto;
}

.settings-preview-wrap {
  margin-top: 14px;
}

.settings-preview-label {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.settings-preview {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--panel) 85%, var(--panel-soft)));
  padding: 12px;
  border-radius: 14px;
}

.settings-preview-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.settings-preview-text {
  font-size: 18px;
  line-height: 1.25;
}

.settings-push-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel-soft) 74%, transparent);
}

.settings-push-copy {
  min-width: 0;
}

.settings-push-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 3px;
}

.settings-push-card .mini-status {
  min-height: 0;
}

.push-actions {
  margin-top: 0;
  justify-content: flex-end;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
  flex-wrap: wrap;
}

.auth-actions {
  justify-content: flex-start;
}

.dm-card {
  max-width: 680px;
  height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  padding: 16px 16px 14px;
}

.dm-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 34px;
  margin-bottom: 8px;
}

.dm-person {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dm-name {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.dm-sub {
  font-size: 13px;
  color: var(--text-soft);
}

.dm-status {
  min-height: 18px;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.dm-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.dm-chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 92%, var(--panel-soft)), var(--panel));
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 14px;
}

.dm-message {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: flex-start;
}

.dm-message.from-me {
  flex-direction: row-reverse;
}

.dm-bubble-wrap {
  max-width: 78%;
}

.dm-msg-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin: 0 0 4px;
}

.dm-message.from-me .dm-msg-meta {
  text-align: right;
}

.dm-bubble {
  background: var(--dm-other);
  border: 1px solid var(--dm-other-border);
  padding: 9px 11px;
  font-size: 15px;
  line-height: 1.32;
  word-break: break-word;
  border-radius: 14px;
}

.dm-message.from-me .dm-bubble {
  background: var(--dm-me);
  border-color: var(--dm-me-border);
}

.dm-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.people-card {
  max-width: 1020px;
  height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.people-header {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.people-header-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.people-close-btn {
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  border-radius: 999px;
}

.people-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.people-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel-alt), var(--panel-soft));
  overflow-x: auto;
}

.people-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--accent-strong);
  font-size: 18px;
  padding: 11px 14px 12px;
  cursor: pointer;
  border-radius: 12px 12px 0 0;
  white-space: nowrap;
}

.people-tab.active {
  color: var(--text);
  background: var(--panel);
  border-color: var(--border);
  border-bottom-color: var(--panel);
  font-weight: 700;
}

.people-status {
  padding: 8px 14px 0;
  margin-bottom: 0;
}

.people-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
}

.people-panel {
  display: none;
  height: 100%;
  overflow-y: auto;
}

.people-panel.active {
  display: block;
}

.profile-page-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  padding: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 90%, var(--panel-soft)), var(--panel));
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}

.profile-page-avatar {
  width: 96px;
  height: 96px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-soft) 88%, var(--panel)), var(--panel-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 42px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.profile-page-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-page-main {
  min-width: 0;
}

.profile-page-name {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.05;
  word-break: break-word;
}

.profile-page-sub {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-soft);
}

.profile-page-actions {
  justify-content: flex-start;
  margin-top: 10px;
}

.people-section-title {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
}

.people-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.people-item {
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 90%, var(--panel-soft)), var(--panel));
  border: 1px solid var(--border);
  padding: 11px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(20, 38, 63, 0.08);
}

.people-item-unread {
  border-color: color-mix(in srgb, var(--accent-border) 82%, var(--border));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent-border) 46%, transparent),
    0 10px 22px rgba(37, 127, 217, 0.14);
}

.people-card-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.people-card-name {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  word-break: break-word;
}

.people-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.people-chip {
  min-height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

.people-card-meta {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.3;
}

.people-card-preview {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.35;
}

.people-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.members-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 120px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.members-list {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 90%, var(--panel-soft)), var(--panel));
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.member-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition:
    background-color 0.14s ease,
    transform 0.14s ease;
}

.member-row:last-child {
  border-bottom: none;
}

.member-row:hover {
  background: var(--message-hover);
}

.member-main {
  min-width: 0;
}

.member-topline {
  font-size: 18px;
  line-height: 1.15;
  color: var(--text);
  word-break: break-word;
}

.member-name {
  font-weight: 700;
}

.member-state {
  margin-top: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.member-about {
  margin-top: 5px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
}

.member-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-self: center;
}

.empty-box {
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 86%, var(--panel-soft)), var(--panel));
  border: 1px solid var(--border);
  padding: 16px;
  color: var(--text-soft);
  border-radius: 14px;
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .user-panel {
    order: 1;
    min-height: 0;
    max-height: 180px;
  }

  .user-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
    gap: 6px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .app {
    padding-left: 8px;
    padding-right: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  body.theme-dark .app {
    max-width: none;
    padding: 0 0 calc(8px + env(safe-area-inset-bottom));
  }

  .top-bar {
    align-items: flex-start;
    flex-wrap: wrap;
    padding-top: 8px;
    gap: 8px;
  }

  body.theme-dark .top-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #000;
    padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
    margin-bottom: 0;
  }

  body.theme-dark .room-title-stack {
    width: 100%;
    align-items: center;
    text-align: center;
  }

  body.theme-dark .room-kicker {
    display: none;
  }

  body.theme-dark .room-title {
    font-size: 28px;
    letter-spacing: -0.03em;
  }

  body.theme-dark .top-bar > .top-controls-wrap,
  body.theme-dark .top-bar > .more-link {
    display: none !important;
  }

  .room-title {
    font-size: 26px;
  }

  .more-link {
    min-height: 32px;
    padding: 0 11px;
    font-size: 13px;
  }

  .room-notice {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat,
  .user-panel,
  .input-shell {
    border-radius: 16px;
  }

  .chat {
    min-height: 430px;
  }

  body.theme-dark .main-layout {
    display: block;
    padding: 0 8px;
  }

  body.theme-dark .user-panel {
    display: none;
  }

  body.theme-dark .chat-column {
    min-height: calc(100dvh - 108px - env(safe-area-inset-bottom));
  }

  body.theme-dark .chat {
    min-height: calc(100dvh - 210px - env(safe-area-inset-bottom));
    border: none;
    border-radius: 0;
    background: #000;
    padding-bottom: 12px;
  }

  body.theme-dark .message {
    border-bottom: none;
    padding-left: 6px;
    padding-right: 6px;
  }

  body.theme-dark .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1f2328;
  }

  body.theme-dark .message-body {
    max-width: calc(100% - 48px);
  }

  body.theme-dark .meta {
    margin-bottom: 6px;
  }

  body.theme-dark .text {
    background: #2d2d2f;
    border-radius: 22px;
    padding: 14px 16px;
    line-height: 1.18;
  }

  body.theme-dark .reply-bar {
    margin: 0 8px 8px;
    border-radius: 16px;
  }

  body.theme-dark .typing-bar {
    padding-left: 12px;
  }

  .message {
    gap: 10px;
    padding: 11px 9px;
  }

  .avatar {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .username {
    font-size: 18px;
  }

  .text {
    font-size: 16px;
  }

  .bottom-row {
    justify-content: flex-start;
    gap: 10px;
  }

  body.theme-dark .input-shell {
    position: sticky;
    bottom: 0;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    background: #101113;
    padding: 10px 10px calc(8px + env(safe-area-inset-bottom));
    z-index: 25;
  }

  body.theme-dark .input-row {
    gap: 10px;
  }

  body.theme-dark .tool-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 22px;
    background: #1c1f23;
    border-color: #262b31;
  }

  body.theme-dark #messageInput,
  body.theme-dark #dmInput {
    height: 48px;
    border-radius: 24px;
    background: #16181b;
  }

  body.theme-dark #sendBtn,
  body.theme-dark #sendDmBtn {
    min-width: 88px;
    height: 48px;
    border-radius: 24px;
    background: #1c1f23;
  }

  .account-state {
    width: 100%;
    margin-left: 0;
  }

  .dm-card,
  .people-card {
    height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 18px);
    max-width: none;
  }

  body.theme-dark .dm-card,
  body.theme-dark .people-card,
  body.theme-dark .settings-card,
  body.theme-dark .auth-card,
  body.theme-dark .profile-card,
  body.theme-dark #roomControlsModal .modal-card {
    background: #000;
    border: none;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  body.theme-dark .dm-top,
  body.theme-dark .people-header {
    background: #000;
    padding-left: 4px;
    padding-right: 4px;
  }

  body.theme-dark .people-header {
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  body.theme-dark .people-header-title {
    font-size: 22px;
  }

  body.theme-dark .people-tabs {
    background: #000;
    border-bottom-color: #171c20;
  }

  body.theme-dark .people-tab.active {
    color: #fff;
    border-bottom-color: var(--accent);
  }

  body.theme-dark .settings-card .form-grid,
  body.theme-dark .settings-card .settings-preview-wrap,
  body.theme-dark .settings-card .people-section-title,
  body.theme-dark .settings-card .mini-status,
  body.theme-dark .settings-card .row-actions,
  body.theme-dark .room-controls-card > *,
  body.theme-dark .people-body > * {
    max-width: 760px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .profile-card,
  .settings-card,
  .auth-card {
    max-width: none;
  }

  .modal {
    align-items: flex-start;
    padding: calc(env(safe-area-inset-top) + 8px) 8px calc(env(safe-area-inset-bottom) + 12px);
  }

  .modal-card {
    border-radius: 18px;
    max-height: none;
    margin: 0 auto;
  }

  .settings-card,
  .auth-card,
  .profile-card,
  #roomControlsModal .modal-card {
    overflow: visible !important;
  }

  .room-controls-grid,
  .room-controls-columns {
    grid-template-columns: 1fr;
  }

  .room-controls-panel {
    padding: 12px;
  }

  .members-toolbar {
    grid-template-columns: 1fr;
  }

  .member-row {
    grid-template-columns: 54px minmax(0, 1fr);
    padding: 10px;
  }

  .member-topline {
    font-size: 16px;
  }

  .member-state {
    font-size: 10px;
  }

  .member-about {
    font-size: 13px;
  }

  .member-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-left: 54px;
  }

  .people-item {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .people-card-name {
    font-size: 19px;
  }

  .people-card-badges {
    margin-top: 5px;
  }

  .people-card-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .profile-page-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .profile-page-avatar {
    width: 88px;
    height: 88px;
    margin: 0 auto;
  }

  .profile-page-actions {
    justify-content: center;
  }

  .people-header {
    padding: 12px 14px;
  }

  .people-header-title {
    font-size: 24px;
  }

  .people-tab {
    font-size: 16px;
    padding: 10px 12px 11px;
  }

  .profile-facts {
    justify-content: center;
  }

  .lightbox-card {
    padding-left: 8px;
    padding-right: 8px;
  }
}

@media (max-width: 700px) {
  .settings-card > .close-btn,
  .auth-card > .close-btn,
  .profile-card > .close-btn,
  #roomControlsModal .modal-card > .close-btn {
    position: sticky;
    top: 6px;
    left: calc(100% - 34px);
    margin-left: auto;
    background: color-mix(in srgb, var(--panel-soft) 82%, transparent);
    z-index: 8;
  }
}


/* ===== UI refresh batch: Session-like structure with Chatango separation ===== */
.message {
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--border);
}

.message-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-bubble {
  background: color-mix(in srgb, var(--panel-raised) 92%, var(--panel-soft));
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 22px;
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
}

body.theme-dark .message-bubble {
  background: #2d2f35;
  border-color: #3b3f48;
  box-shadow: none;
}

.reply-snippet {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 72%, var(--panel));
  border-radius: 14px;
}

.reply-snippet-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}

.reply-snippet-preview {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.25;
}

.text {
  line-height: 1.28;
}

.msg-image,
.msg-audio {
  margin-top: 10px;
}

.dm-card {
  max-width: 760px;
  border-radius: 28px;
}

.dm-chat {
  padding: 14px 12px;
  border-radius: 22px;
}

.dm-message {
  gap: 10px;
  margin-bottom: 14px;
}

.dm-bubble-wrap {
  max-width: min(78%, 520px);
}

.dm-bubble {
  border-radius: 24px;
  padding: 12px 14px;
}

.dm-actions {
  gap: 10px;
}

#roomControlsModal .modal-card,
.settings-card,
.people-card,
.auth-card,
.profile-card {
  border-radius: 28px;
}

body.theme-dark #roomControlsModal .modal-card,
body.theme-dark .settings-card,
body.theme-dark .people-card,
body.theme-dark .auth-card,
body.theme-dark .profile-card,
body.theme-dark .dm-card {
  background: #0f1114;
}

body.theme-dark .people-header {
  background: #0f1114;
  border-bottom: 1px solid #232831;
}

body.theme-dark .people-tab.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

body.theme-dark .people-item,
body.theme-dark .members-list,
body.theme-dark .member-row,
body.theme-dark .empty-box,
body.theme-dark .settings-preview,
body.theme-dark .room-controls-panel,
body.theme-dark #roomControlsModal .field,
body.theme-dark #roomControlsModal .empty-box {
  background: #17191e;
  border-color: #262b34;
}

body.theme-dark .more-link,
body.theme-dark .small-action-btn,
body.theme-dark .tool-btn,
body.theme-dark #sendBtn,
body.theme-dark #sendDmBtn {
  background: #17191e;
  border-color: #2c3340;
}

body.theme-dark #sendBtn,
body.theme-dark #sendDmBtn {
  color: #fff;
}

body.theme-dark .top-bar {
  background: transparent;
}

@media (max-width: 700px) {
  body.theme-dark .top-bar {
    background: #111317;
  }

  body.theme-dark .chat {
    background: #111317;
    padding-top: 6px;
  }

  body.theme-dark .message {
    padding-left: 10px;
    padding-right: 10px;
    gap: 10px;
  }

  body.theme-dark .avatar {
    width: 34px;
    height: 34px;
  }

  body.theme-dark .message-body {
    max-width: calc(100% - 44px);
  }

  body.theme-dark .meta {
    margin-bottom: 5px;
  }

  body.theme-dark .message-bubble {
    background: #303238;
    border-color: #3d4149;
    border-radius: 24px;
    padding: 12px 14px;
  }

  body.theme-dark .text {
    background: transparent;
    padding: 0;
    border-radius: 0;
    line-height: 1.22;
  }

  body.theme-dark .reply-snippet {
    background: #232730;
    border-left-color: #57d89d;
    border-radius: 16px;
  }

  body.theme-dark .input-shell {
    background: #17191e;
    border-top: 1px solid #242933;
    border-radius: 24px 24px 0 0;
  }

  body.theme-dark .input-row {
    align-items: center;
  }

  body.theme-dark #messageInput,
  body.theme-dark #dmInput {
    background: #0b0d11;
    border-color: #242933;
    height: 50px;
  }

  body.theme-dark .tool-btn {
    background: #0f1217;
    width: 46px;
    height: 46px;
  }

  body.theme-dark .dm-card,
  body.theme-dark .people-card,
  body.theme-dark .settings-card,
  body.theme-dark .auth-card,
  body.theme-dark .profile-card,
  body.theme-dark #roomControlsModal .modal-card {
    background: #111317;
  }

  body.theme-dark .dm-top,
  body.theme-dark .people-header,
  body.theme-dark #roomControlsModal .modal-card > .settings-title {
    background: #111317;
  }

  body.theme-dark .dm-chat {
    background: #111317;
    border: none;
    padding: 10px 6px 18px;
  }

  body.theme-dark .dm-message {
    gap: 8px;
    margin-bottom: 12px;
  }

  body.theme-dark .dm-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }

  body.theme-dark .dm-bubble-wrap {
    max-width: calc(100% - 42px);
  }

  body.theme-dark .dm-bubble {
    background: #2f3136;
    border-color: #3c4149;
    border-radius: 22px;
    padding: 12px 14px;
    font-size: 16px;
    line-height: 1.24;
  }

  body.theme-dark .dm-message.from-me .dm-bubble {
    background: #293342;
    border-color: #41546f;
  }

  body.theme-dark .dm-msg-meta {
    font-size: 12px;
    margin-bottom: 5px;
  }

  body.theme-dark .people-header-title,
  body.theme-dark .settings-title {
    font-size: 26px;
  }

  body.theme-dark .people-card,
  body.theme-dark #roomControlsModal .modal-card,
  body.theme-dark .settings-card {
    padding-left: 14px;
    padding-right: 14px;
  }
}


/* batch v5 overrides */
.settings-upload-row { display:flex; gap:10px; flex-wrap:wrap; margin-top:12px; }
.mention-picker { position:fixed; left:12px; right:12px; bottom:calc(env(safe-area-inset-bottom) + 110px); z-index:1400; max-height:min(260px,42vh); overflow:auto; background:rgba(20,24,30,.98); border:1px solid rgba(255,255,255,.08); border-radius:20px; box-shadow:0 20px 60px rgba(0,0,0,.45); backdrop-filter:blur(10px); }
body.theme-light .mention-picker { background:rgba(255,255,255,.97); border-color:rgba(0,0,0,.08); }
.mention-item { display:flex; align-items:center; gap:12px; padding:12px 14px; border:0; width:100%; background:transparent; color:var(--text); text-align:left; border-bottom:1px solid rgba(255,255,255,.06); cursor:pointer; }
.mention-item:last-child { border-bottom:none; }
.mention-item:hover, .mention-item.active { background:rgba(255,255,255,.06); }
body.theme-light .mention-item:hover, body.theme-light .mention-item.active { background:rgba(0,0,0,.05); }
.mention-item-name { font-weight:700; }
.mention-item-sub { font-size:12px; color:var(--text-soft); }
.message-bubble, .dm-bubble { position:relative; overflow:hidden; }
.message-bubble.has-bg::before, .dm-bubble.has-bg::before { content:""; position:absolute; inset:0; background-image:var(--msg-bg-url); background-size:cover; background-position:center; opacity:.35; pointer-events:none; }
.message-bubble.has-bg::after, .dm-bubble.has-bg::after { content:""; position:absolute; inset:0; background:linear-gradient(180deg, rgba(8,10,14,.18), rgba(8,10,14,.42)); pointer-events:none; }
.message-bubble > *, .dm-bubble > * { position:relative; z-index:1; }
.settings-preview.has-bg { position:relative; overflow:hidden; }
.settings-preview.has-bg::before { content:""; position:absolute; inset:0; background-image:var(--msg-bg-url); background-size:cover; background-position:center; opacity:.28; }
.settings-preview.has-bg > * { position:relative; z-index:1; }
.reaction-strip { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.reaction-chip { border:1px solid rgba(255,255,255,.08); background:rgba(255,255,255,.08); border-radius:999px; padding:3px 8px; font-size:13px; line-height:1; }
body.theme-light .reaction-chip { border-color:rgba(0,0,0,.08); background:rgba(0,0,0,.04); }
.message-action-sheet { position:fixed; inset:0; z-index:1600; }
.message-action-backdrop { position:absolute; inset:0; background:rgba(0,0,0,.42); backdrop-filter:blur(6px); }
.message-action-panel { position:absolute; left:50%; bottom:calc(env(safe-area-inset-bottom) + 20px); transform:translateX(-50%); width:min(94vw,420px); background:rgba(18,20,25,.98); border:1px solid rgba(255,255,255,.08); border-radius:26px; box-shadow:0 24px 70px rgba(0,0,0,.5); overflow:hidden; }
body.theme-light .message-action-panel { background:rgba(255,255,255,.98); border-color:rgba(0,0,0,.08); }
.message-action-preview { padding:14px; border-bottom:1px solid rgba(255,255,255,.06); font-size:14px; color:var(--text-soft); }
.message-reaction-row { display:flex; align-items:center; justify-content:space-between; gap:6px; padding:10px 12px; border-bottom:1px solid rgba(255,255,255,.06); }
.reaction-btn { width:44px; height:44px; border:none; border-radius:999px; background:rgba(255,255,255,.08); font-size:24px; cursor:pointer; }
body.theme-light .reaction-btn { background:rgba(0,0,0,.05); }
.message-action-list { display:flex; flex-direction:column; }
.message-action-btn { border:none; background:transparent; color:var(--text); font-size:17px; text-align:left; padding:16px 18px; cursor:pointer; border-top:1px solid rgba(255,255,255,.06); }
.message-action-btn.danger { color:#ff5d66; }
.message-action-btn:hover { background:rgba(255,255,255,.05); }
body.theme-light .message-action-btn:hover { background:rgba(0,0,0,.04); }
.message-bubble.mentioned { outline:2px solid rgba(88,240,170,.35); outline-offset:6px; border-radius:18px; }
@media (max-width:700px){
  .top-bar { padding-top:18px; align-items:center; }
  .message { padding:8px 10px 10px; align-items:flex-end; }
  .avatar { width:38px; height:38px; font-size:17px; align-self:flex-end; }
  .message-bubble { border-radius:26px; padding:14px 16px; max-width:calc(100vw - 88px); }
  .meta { margin-bottom:8px; }
  .username { font-size:15px; font-weight:700; }
  .time, .mod-mini-btn { display:none; }
  .dm-top { position:sticky; top:0; z-index:4; background:inherit; padding-bottom:10px; }
  .dm-card { padding-top:calc(env(safe-area-inset-top) + 16px); border-radius:0; }
  .dm-chat { background:transparent; border:none; padding:10px 0 120px; }
  .dm-message { gap:10px; margin-bottom:12px; align-items:flex-end; }
  .dm-msg-avatar { width:34px; height:34px; }
  .dm-bubble { border-radius:26px; padding:14px 16px; max-width:min(78vw,430px); }
  .dm-input-row { position:sticky; bottom:0; padding-bottom:calc(env(safe-area-inset-bottom) + 8px); background:inherit; z-index:5; }
  .mention-picker { bottom:calc(env(safe-area-inset-bottom) + 126px); }
}


/* batch v6 session-structure overhaul */
:root {
  --msg-text-on-bg: #f6f8fb;
  --session-shell: #0d0f14;
  --session-panel: #141821;
  --session-panel-2: #1a202b;
  --session-border: rgba(150, 170, 205, 0.22);
  --session-border-strong: rgba(180, 198, 230, 0.34);
}

body.theme-dark {
  color-scheme: dark;
  --bg: #0c0f15;
  --bg-accent: rgba(120, 140, 185, 0.08);
  --panel: #121722;
  --panel-soft: #171d29;
  --panel-alt: #1b2230;
  --panel-raised: #161d29;
  --text: #f5f7fb;
  --text-soft: #b1bbca;
  --text-faint: #7f8b9d;
  --border: rgba(131, 149, 182, 0.26);
  --border-strong: rgba(168, 186, 220, 0.42);
  --accent: #4f8dff;
  --accent-strong: #73a2ff;
  --accent-soft: rgba(79, 141, 255, 0.16);
  --accent-border: rgba(115, 162, 255, 0.32);
  --warn-bg: rgba(182, 126, 43, 0.16);
  --warn-border: rgba(202, 154, 77, 0.34);
  --shadow: 0 20px 44px rgba(0,0,0,0.45);
}

body.theme-dark .app {
  max-width: 1080px;
}

body.theme-dark .top-bar {
  background: transparent;
  border: none;
  padding-bottom: 6px;
}

body.theme-dark .room-title-stack {
  gap: 4px;
}

body.theme-dark .room-kicker {
  letter-spacing: 0.24em;
  color: rgba(223, 230, 242, 0.65);
}

body.theme-dark .room-title {
  color: #fff;
  font-weight: 800;
}

body.theme-dark .chat,
body.theme-dark .user-panel,
body.theme-dark .input-shell,
body.theme-dark .dm-card,
body.theme-dark .people-card,
body.theme-dark .settings-card,
body.theme-dark .auth-card,
body.theme-dark .profile-card,
body.theme-dark #roomControlsModal .modal-card,
body.theme-dark .message-action-panel,
body.theme-dark .mention-picker {
  background: linear-gradient(180deg, rgba(19,24,34,.98), rgba(13,17,25,.98));
  border-color: var(--session-border);
  box-shadow: var(--shadow);
}

body.theme-dark .chat,
body.theme-dark .user-panel {
  border-color: var(--session-border-strong);
}

body.theme-dark .message {
  border-bottom: none;
  gap: 12px;
  padding: 10px 12px 14px;
}

.message-body {
  min-width: 0;
}

.message-bubble {
  border-radius: 26px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 14px 16px;
}

body.theme-dark .message-bubble {
  background: #2b303b;
  border: 1px solid rgba(255,255,255,0.06);
}

.message.from-me {
  justify-content: flex-end;
}

.message.from-me .avatar {
  order: 2;
}

.message.from-me .message-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message.from-me .meta {
  justify-content: flex-end;
}

.message.from-me .meta-right {
  display: none;
}

.message.from-me .username {
  text-align: right;
}

body.theme-dark .message.from-me .message-bubble {
  background: linear-gradient(180deg, #2a3444, #232d3c);
  border-color: rgba(128, 162, 220, 0.28);
}

.text {
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}

.message-bubble.has-bg,
.dm-bubble.has-bg,
.settings-preview.has-bg {
  background: rgba(16, 18, 25, 0.92) !important;
}

.message-bubble.has-bg::before,
.dm-bubble.has-bg::before,
.settings-preview.has-bg::before {
  opacity: .22 !important;
  background-size: cover !important;
  background-position: center center !important;
  filter: saturate(.95) contrast(.9) brightness(.9);
}

.message-bubble.has-bg::after,
.dm-bubble.has-bg::after {
  background: linear-gradient(180deg, rgba(8,10,14,.44), rgba(8,10,14,.62)) !important;
}

.message-bubble.has-bg .text,
.message-bubble.has-bg .reply-snippet,
.message-bubble.has-bg .reply-snippet-user,
.message-bubble.has-bg .reply-snippet-text,
.dm-bubble.has-bg,
.dm-bubble.has-bg .dm-msg-meta,
.dm-bubble.has-bg .text,
.settings-preview.has-bg .settings-preview-name,
.settings-preview.has-bg .settings-preview-text {
  color: var(--msg-text-on-bg) !important;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

.msg-image {
  max-width: min(100%, 320px);
  border-radius: 18px;
  object-fit: cover;
}

body.theme-dark .reply-snippet {
  background: rgba(255,255,255,0.04);
  border-left-color: #62d6a0;
  border-radius: 16px;
}

body.theme-dark .input-shell {
  border-radius: 28px;
  border: 1px solid var(--session-border-strong);
}

body.theme-dark #messageInput,
body.theme-dark #dmInput {
  background: #0a0e16;
  border-color: rgba(255,255,255,0.08);
  color: #fff;
}

body.theme-dark #sendBtn,
body.theme-dark #sendDmBtn,
body.theme-dark .tool-btn,
body.theme-dark .small-action-btn,
body.theme-dark .more-link {
  border-color: var(--session-border-strong);
}

body.theme-dark .user-row,
body.theme-dark .member-row,
body.theme-dark .people-item,
body.theme-dark .empty-box,
body.theme-dark .room-controls-panel,
body.theme-dark .settings-preview,
body.theme-dark .field input,
body.theme-dark .field textarea,
body.theme-dark .field select {
  border-color: var(--session-border) !important;
}

body.theme-dark .field input,
body.theme-dark .field textarea,
body.theme-dark .field select,
body.theme-dark .settings-preview,
body.theme-dark .room-controls-panel,
body.theme-dark .empty-box {
  background: rgba(255,255,255,0.03);
}

body.theme-dark .settings-card .field span,
body.theme-dark .settings-card .mini-status,
body.theme-dark .settings-card .people-section-title,
body.theme-dark .room-controls-panel .people-section-title,
body.theme-dark .room-kicker,
body.theme-dark .time,
body.theme-dark .user-row-sub,
body.theme-dark .member-about,
body.theme-dark .profile-sub,
body.theme-dark .profile-facts,
body.theme-dark .account-state {
  color: var(--text-soft);
}

body.theme-dark .people-header,
body.theme-dark .dm-top {
  background: transparent;
  border-bottom: none;
}

body.theme-dark .people-tab.active {
  background: rgba(255,255,255,0.06);
  border-bottom-color: transparent;
  border-radius: 999px;
}

body.theme-dark .people-tabs {
  gap: 8px;
  padding: 0 10px 12px;
  border-bottom: none;
  background: transparent;
}

body.theme-dark .people-tab {
  border-radius: 999px;
  padding: 10px 16px;
}

body.theme-dark .mention-picker,
body.theme-dark .message-action-panel {
  border-color: var(--session-border-strong);
}

body.theme-dark .reaction-btn {
  background: rgba(255,255,255,0.08);
}

body.theme-dark .message-action-btn:hover,
body.theme-dark .mention-item:hover,
body.theme-dark .mention-item.active {
  background: rgba(255,255,255,0.06);
}

body.theme-dark .mention-item {
  border-bottom-color: rgba(255,255,255,0.05);
}

.message-bubble.mentioned {
  outline: 2px solid rgba(98,214,160,.4);
  outline-offset: 4px;
}

@media (max-width: 900px) {
  .top-controls-wrap { display: none !important; }
  .top-bar {
    justify-content: center;
    text-align: center;
    padding-top: calc(env(safe-area-inset-top) + 10px);
  }
  .top-bar .more-link {
    position: absolute;
    right: 16px;
    top: calc(env(safe-area-inset-top) + 14px);
  }
  .room-title-stack {
    align-items: center;
    width: 100%;
  }
  .room-kicker {
    font-size: 13px;
  }
  .room-title {
    font-size: 34px;
  }
  .main-layout {
    display: block;
  }
  .user-panel {
    display: none;
  }
  .chat-column {
    min-height: calc(100dvh - 150px);
  }
  .chat {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 4px 0 150px;
    min-height: calc(100dvh - 290px);
  }
  .message {
    padding: 8px 14px 14px;
    align-items: flex-end;
  }
  .message .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    align-self: flex-end;
  }
  .message-body {
    max-width: min(100%, calc(100vw - 64px));
  }
  .meta-right,
  .mod-mini-btn,
  .time { display: none !important; }
  .username {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
  }
  .message-bubble {
    border-radius: 28px;
    padding: 14px 16px;
    max-width: calc(100vw - 70px);
  }
  .message.from-me .avatar { display: none; }
  .message.from-me .message-body { max-width: min(86vw, 560px); }
  .message.from-me .message-bubble {
    border-radius: 28px;
    background: linear-gradient(180deg, #3a80ff, #4d93ff);
    color: #fff;
  }
  .message.from-me .username { display: none; }
  .message.from-me .text,
  .message.from-me .reply-snippet,
  .message.from-me .reply-snippet-user,
  .message.from-me .reply-snippet-text { color: #fff !important; }
  .message.from-me .reply-snippet {
    background: rgba(255,255,255,0.12);
    border-left-color: rgba(255,255,255,0.48);
  }
  .input-shell {
    position: sticky;
    bottom: 0;
    z-index: 30;
    padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px);
    margin-top: 8px;
    background: rgba(16,20,28,.92);
    backdrop-filter: blur(20px);
    border-radius: 26px 26px 0 0;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 -12px 36px rgba(0,0,0,0.32);
  }
  .reply-bar { margin-bottom: 8px; }
  .typing-bar { padding-left: 4px; margin-bottom: 8px; }
  .input-row {
    display: grid;
    grid-template-columns: 48px minmax(0,1fr) 48px 88px;
    gap: 10px;
    align-items: center;
  }
  #messageInput,
  #dmInput {
    height: 52px;
    border-radius: 18px;
    font-size: 18px;
  }
  .tool-btn {
    width: 48px;
    height: 48px;
    border-radius: 18px;
  }
  #sendBtn,
  #sendDmBtn {
    width: 100%;
    min-width: 0;
    height: 52px;
    border-radius: 18px;
  }
  .bottom-row {
    justify-content: flex-start;
    gap: 14px;
    padding-top: 10px;
    flex-wrap: wrap;
  }
  .bottom-icon { display:none; }
  .set-name { font-size: 18px; }
  .account-state {
    width: 100%;
    font-size: 16px;
    color: var(--text-soft);
  }
  .mention-picker {
    left: 12px;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom) + 118px);
  }
  .dm-card,
  .people-card,
  .settings-card,
  .auth-card,
  .profile-card,
  #roomControlsModal .modal-card {
    width: 100vw;
    max-width: none;
    min-height: 100dvh;
    height: 100dvh;
    border-radius: 0 !important;
    padding-top: calc(env(safe-area-inset-top) + 16px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 24px);
    overflow-y: auto;
    box-shadow: none !important;
  }
  .dm-card { display: flex; }
  .dm-chat {
    background: transparent !important;
    border: none !important;
    padding: 4px 0 120px;
  }
  .dm-message {
    align-items: flex-end;
    gap: 10px;
  }
  .dm-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }
  .dm-bubble-wrap { max-width: calc(100vw - 80px); }
  .dm-bubble {
    border-radius: 26px;
    padding: 14px 16px;
    background: #2c313b;
  }
  .dm-message.from-me .dm-bubble {
    background: linear-gradient(180deg, #3a80ff, #4d93ff);
    color: #fff;
    border-color: rgba(128, 162, 220, 0.25);
  }
  .dm-input-row {
    position: sticky;
    bottom: 0;
    background: rgba(16,20,28,.94);
    padding: 10px 0 calc(env(safe-area-inset-bottom) + 8px);
  }
}

/* batch v7 polish and room-settings stability */
.reply-snippet {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.reply-snippet-name,
.reply-snippet-user {
  font-weight: 700;
  line-height: 1.15;
}

.reply-snippet-preview,
.reply-snippet-text {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.message-body,
.dm-bubble-wrap {
  min-width: 0;
}

.message-bubble,
.dm-bubble {
  width: fit-content;
  max-width: min(100%, 620px);
  box-sizing: border-box;
}

.message .text,
.dm-bubble .text {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-bubble.has-bg,
.dm-bubble.has-bg,
.settings-preview.has-bg {
  background: color-mix(in srgb, var(--panel) 88%, #000 12%) !important;
}

.message-bubble.has-bg::before,
.dm-bubble.has-bg::before,
.settings-preview.has-bg::before {
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center center !important;
  opacity: .20 !important;
}

.message-bubble.has-bg::after,
.dm-bubble.has-bg::after {
  background: linear-gradient(180deg, rgba(8,10,14,.52), rgba(8,10,14,.70)) !important;
}

body.theme-dark .message-bubble,
body.theme-dark .dm-bubble,
body.theme-dark .input-shell,
body.theme-dark .user-panel,
body.theme-dark .chat,
body.theme-dark .top-bar,
body.theme-dark .room-notice,
body.theme-dark .modal-card,
body.theme-dark .field input,
body.theme-dark .field textarea,
body.theme-dark .field select {
  border-color: rgba(173, 187, 214, 0.22) !important;
}

body.theme-dark .message.from-me .message-bubble {
  background: linear-gradient(180deg, #2f3643, #272d38) !important;
  border-color: rgba(173, 187, 214, 0.24) !important;
}

body.theme-dark .message-action-sheet {
  background: rgba(14, 17, 23, 0.96);
  border: 1px solid rgba(173, 187, 214, 0.20);
  box-shadow: 0 20px 40px rgba(0,0,0,.45);
}

body.theme-dark .reaction-btn {
  background: rgba(255,255,255,0.06);
  border-color: rgba(173, 187, 214, 0.18);
}

body.theme-dark .reaction-btn:hover {
  background: rgba(255,255,255,0.11);
}

body.theme-dark #roomControlsModal .modal-card {
  max-width: 760px;
}

body.theme-dark #roomControlsModal .settings-title {
  letter-spacing: -.02em;
}

@media (max-width: 760px) {
  body.theme-dark {
    background: #080a0f;
  }

  .top-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 18px 18px 8px;
    background: linear-gradient(180deg, rgba(8,10,15,.98), rgba(8,10,15,.92));
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(173, 187, 214, 0.08);
  }

  .room-title-stack {
    width: 100%;
    align-items: center;
    text-align: center;
  }

  .room-kicker {
    display: none;
  }

  .room-title {
    font-size: clamp(30px, 7vw, 42px);
    line-height: 1.04;
    letter-spacing: -.03em;
  }

  .more-link {
    position: absolute;
    left: 16px;
    top: 18px;
    min-width: 56px;
    min-height: 42px;
    border-radius: 999px;
    padding: 0 16px;
  }

  .status,
  .room-notice {
    margin-left: 16px;
    margin-right: 16px;
  }

  .chat {
    padding: 12px 12px 120px;
    border-radius: 22px;
  }

  .message {
    gap: 10px;
    padding: 8px 10px 10px;
    border-bottom: none;
  }

  .avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    font-size: 20px;
  }

  .message-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .meta {
    margin-bottom: 0;
  }

  .meta-right {
    display: none;
  }

  .username {
    font-size: 15px;
    line-height: 1.1;
    font-weight: 700;
  }

  .time {
    font-size: 12px;
  }

  .message-bubble {
    max-width: calc(100vw - 86px);
    border-radius: 26px;
    padding: 14px 16px;
    background: #262b33;
  }

  .message.from-me .message-body {
    align-items: flex-end;
  }

  .message.from-me .message-bubble {
    max-width: min(calc(100vw - 56px), 82vw);
    border-radius: 24px;
  }

  .message.from-me .username {
    display: none;
  }

  .reply-snippet {
    padding: 12px 12px 10px;
    border-radius: 16px;
    margin-bottom: 10px;
  }

  .reply-snippet-preview,
  .reply-snippet-text {
    font-size: 13px;
    line-height: 1.24;
  }

  .input-shell {
    position: sticky;
    bottom: 0;
    z-index: 20;
    border-radius: 28px 28px 0 0;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(11, 14, 20, 0.96), rgba(11, 14, 20, 0.98));
    backdrop-filter: blur(12px);
  }

  .input-row {
    gap: 10px;
  }

  #messageInput,
  #dmInput {
    min-height: 48px;
    border-radius: 999px;
    padding: 0 18px;
  }

  .tool-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
  }

  #sendBtn,
  #sendDmBtn {
    min-width: 94px;
    height: 48px;
    border-radius: 999px;
  }

  .bottom-row {
    padding-top: 8px;
    gap: 12px;
    flex-wrap: wrap;
  }

  .bottom-icon {
    display: none;
  }

  .dm-card {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .dm-top {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(8,10,15,.96);
    padding-bottom: 10px;
  }

  .dm-chat {
    padding-bottom: 120px;
  }

  .dm-message {
    gap: 10px;
    margin-bottom: 12px;
  }

  .dm-bubble {
    border-radius: 24px;
    max-width: calc(100vw - 84px);
    background: #262b33;
    padding: 13px 16px;
  }

  .dm-message.from-me .dm-bubble {
    background: #313846;
  }

  #roomControlsModal .modal-card,
  #settingsModal .modal-card,
  #peopleModal .modal-card,
  #profileModal .modal-card,
  #messageActionSheet .modal-card {
    border-radius: 26px 26px 0 0;
  }
}


/* v8 cleanup overrides */
.voice-preview-card {
  max-width: min(92vw, 520px);
  border-radius: 28px;
}
.voice-preview-player {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0 8px;
}
.voice-play-btn {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
}
.voice-seek {
  width: 100%;
}
.voice-duration {
  min-width: 84px;
  text-align: right;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.voice-pill {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  max-width: min(100%, 360px);
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}
.voice-pill-play {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 0;
  background: #2a2d34;
  color: #fff;
  font-size: 15px;
}
.message.from-me .voice-pill,
.dm-message.from-me .voice-pill {
  background: rgba(88,138,255,.18);
}
.voice-pill-seek {
  width: 100%;
  accent-color: #7aa2ff;
}
.voice-pill-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
  min-width: 42px;
  text-align: right;
}
.reply-snippet,
.reply-block,
.reply-preview {
  max-width: 100%;
  overflow: hidden;
}
.reply-snippet-user,
.reply-snippet-text,
.reply-snippet-preview,
.reply-snippet {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message-bubble,
.dm-bubble {
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.message-bubble.has-bg::before,
.dm-bubble.has-bg::before {
  background-size: cover;
  background-repeat: no-repeat;
}
.message-bubble.has-bg::after,
.dm-bubble.has-bg::after {
  background: linear-gradient(180deg, rgba(5,8,14,.34), rgba(5,8,14,.56));
}
.message-action-panel {
  border-radius: 30px 30px 18px 18px;
  overflow: hidden;
}
.message-action-preview {
  color: var(--text-soft);
}
.message-action-list .message-action-btn {
  min-height: 58px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: 18px;
}
.message-reaction-row {
  padding: 12px 14px;
}
.reaction-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  font-size: 24px;
}
body.theme-dark .message,
body.theme-dark .dm-message {
  border-color: rgba(255,255,255,.04);
}
body.theme-dark .message-bubble,
body.theme-dark .dm-bubble,
body.theme-dark .voice-play-btn,
body.theme-dark .voice-pill,
body.theme-dark .voice-preview-card,
body.theme-dark .message-action-panel {
  border-color: rgba(138,161,255,.16);
}
@media (max-width: 780px) {
  .top-bar {
    padding: 18px 16px 6px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
  }
  .room-title-stack {
    gap: 4px;
  }
  .room-kicker {
    font-size: 11px;
    letter-spacing: .22em;
  }
  .room-title {
    font-size: clamp(34px, 8vw, 52px);
    line-height: .98;
  }
  .chat {
    padding: 10px 10px 14px;
  }
  .message {
    padding: 10px 0;
    gap: 10px;
  }
  .message .avatar {
    width: 42px;
    height: 42px;
  }
  .message-body {
    max-width: calc(100vw - 78px);
  }
  .message.from-me {
    justify-content: flex-end;
  }
  .message.from-me .avatar {
    display: none;
  }
  .message.from-me .message-body {
    max-width: min(84vw, 420px);
    align-items: flex-end;
  }
  .message.from-me .meta {
    display: none;
  }
  .message-bubble {
    max-width: 100%;
    border-radius: 28px;
    padding: 14px 16px;
  }
  .message.from-me .message-bubble {
    background: #5b8fff;
    color: #fff;
    border-radius: 26px;
  }
  .message.from-me .text,
  .message.from-me .voice-pill-time,
  .message.from-me .reply-snippet,
  .message.from-me .reply-snippet-user,
  .message.from-me .reply-snippet-text {
    color: #fff !important;
  }
  .message.from-me .voice-pill {
    background: rgba(255,255,255,.16);
    border-color: rgba(255,255,255,.22);
  }
  .message.from-me .voice-pill-play {
    background: rgba(0,0,0,.25);
  }
  .main-layout {
    display: block;
  }
  .user-panel {
    display: none !important;
  }
  .chat-column {
    width: 100%;
  }
  .input-shell {
    position: sticky;
    bottom: 0;
    border-radius: 28px 28px 0 0;
    padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
    background: rgba(10,12,18,.92);
    backdrop-filter: blur(16px);
  }
  .input-row {
    grid-template-columns: 48px minmax(0,1fr) 48px 90px;
    gap: 10px;
  }
  #messageInput, #dmInput {
    min-width: 0;
    height: 52px;
    border-radius: 26px;
  }
  #sendBtn, #sendDmBtn, .tool-btn {
    height: 52px;
    border-radius: 26px;
  }
  .bottom-row {
    gap: 18px;
    justify-content: flex-start;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 2px;
  }
  .bottom-row::-webkit-scrollbar { display: none; }
  .message-action-panel {
    width: calc(100vw - 20px);
    margin: 0 auto 8px;
    border-radius: 28px 28px 16px 16px;
  }
  .dm-card {
    padding: 0;
    border-radius: 0;
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
  }
  .dm-top {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
    background: rgba(0,0,0,.94);
  }
  .dm-chat {
    padding: 16px 12px 140px;
    background: #000;
  }
  .dm-message {
    align-items: flex-end;
    gap: 10px;
    margin: 0 0 14px;
  }
  .dm-msg-avatar {
    width: 34px;
    height: 34px;
    align-self: flex-end;
  }
  .dm-bubble {
    border-radius: 24px;
    background: #2d2d2f;
    padding: 13px 16px;
    max-width: min(80vw, 420px);
  }
  .dm-message.from-me .dm-bubble {
    background: #38e68d;
    color: #041108;
  }
  .dm-message.from-me .text { color: #041108; }
  .dm-message.from-me .dm-msg-meta {
    text-align: right;
  }
  .voice-preview-card {
    max-height: min(90vh, 460px);
  }
}


/* batch v9 session ui pass */
.icon-nav-btn { appearance:none; border:none; background:transparent; color:var(--text); font-size:46px; line-height:1; width:40px; height:40px; display:flex; align-items:center; justify-content:center; padding:0; }
.room-header-sub { display:none; font-size:14px; color:var(--text-soft); }
.room-header-menu-btn { display:none; position:relative; width:44px; height:44px; border:none; background:transparent; padding:0; }
.mini-header-avatar { position:absolute; width:28px; height:28px; border-radius:999px; overflow:hidden; border:2px solid rgba(255,255,255,.1); background:#232831; color:#fff; display:flex; align-items:center; justify-content:center; font-size:12px; }
.mini-header-avatar img { width:100%; height:100%; object-fit:cover; display:block; }
.mini-header-avatar:first-child { right:12px; top:2px; }
.mini-header-avatar.second { right:0; bottom:2px; }
.search-result-row { width:100%; text-align:left; border:none; background:transparent; color:var(--text); padding:12px 14px; border-top:1px solid var(--border); cursor:pointer; }
.search-result-row:hover { background:rgba(255,255,255,.04); }
.message.flash-hit { animation: flashHit 1.2s ease; }
@keyframes flashHit { 0%{box-shadow:0 0 0 0 rgba(79,141,255,.35)} 40%{box-shadow:0 0 0 10px rgba(79,141,255,.08)} 100%{box-shadow:0 0 0 0 rgba(79,141,255,0)} }

@media (max-width: 820px) {
  .app { padding:0; max-width:none; }
  .top-bar.session-room-header { position:sticky; top:0; z-index:30; padding:calc(env(safe-area-inset-top) + 10px) 14px 10px; min-height:88px; justify-content:center; align-items:center; border:none; background:#000; }
  .top-bar.session-room-header .more-link { display:none; }
  .room-title-stack { align-items:center; text-align:center; width:100%; }
  .room-kicker { display:none; }
  .room-title { font-size:28px; line-height:1.15; letter-spacing:-0.02em; }
  .room-header-sub { display:block; }
  .room-header-menu-btn { display:block; position:absolute; right:14px; top:calc(env(safe-area-inset-top) + 10px); }
  .icon-nav-btn.hidden { display:none !important; }
  .chat-column { min-height:calc(100dvh - 88px); display:flex; flex-direction:column; }
  .chat { flex:1; border:none; background:#000; padding:12px 14px 160px; }
  .message { display:block; padding:0 0 14px; }
  .avatar { width:38px; height:38px; float:left; margin-right:10px; margin-top:44px; }
  .message-body { margin-left:48px; display:block; max-width:none; }
  .meta { margin:0 0 6px; display:flex; gap:8px; align-items:center; }
  .username { font-size:15px; font-weight:700; color:#fff; }
  .time { display:none; }
  .message-bubble { max-width:min(78vw, 600px); border-radius:26px; background:#323338 !important; border:none !important; box-shadow:none; padding:16px 18px; }
  .message.from-me { display:flex; justify-content:flex-end; }
  .message.from-me .avatar, .message.from-me .meta { display:none; }
  .message.from-me .message-body { margin-left:0; display:flex; justify-content:flex-end; width:100%; }
  .message.from-me .message-bubble { background:#54e29a !important; color:#0b130f !important; }
  .message.from-me .text, .message.from-me .voice-pill-time { color:#0b130f !important; }
  .reply-snippet { max-width:100%; overflow:hidden; border-radius:18px; background:rgba(255,255,255,.06); }
  .reply-snippet-name, .reply-snippet-user, .reply-snippet-preview, .reply-snippet-text { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:block; }
  .message-bubble .text { overflow-wrap:anywhere; }
  .message-bubble.has-bg::before { background-size:cover; background-position:center center; opacity:.55; }
  .message-bubble.has-bg::after { background:linear-gradient(180deg, rgba(0,0,0,.26), rgba(0,0,0,.48)); }
  .user-panel { display:none !important; }
  .input-shell { position:sticky; bottom:0; border-radius:0; border:none; background:#111214; padding:12px 14px calc(env(safe-area-inset-bottom) + 10px); box-shadow:none; }
  .input-row { display:grid; grid-template-columns:52px 1fr 52px 96px; gap:10px; align-items:center; }
  .tool-btn, #sendBtn, .dm-send-btn { width:52px; height:52px; border-radius:26px; font-size:28px; padding:0; min-width:52px; }
  #sendBtn { min-width:96px; width:96px; font-size:18px; }
  #messageInput, #dmInput { height:52px; border-radius:26px; padding:0 20px; font-size:17px; }
  .bottom-row { justify-content:flex-start; gap:18px; padding:10px 0 0; overflow:auto; white-space:nowrap; }
  .bottom-row .bottom-icon { display:none; }
  .dm-card { width:100vw; height:100dvh; max-width:none; max-height:none; border:none; border-radius:0; background:#000; padding:0; display:flex; flex-direction:column; }
  .dm-top { position:sticky; top:0; z-index:5; display:grid; grid-template-columns:44px 1fr 44px; align-items:center; padding:calc(env(safe-area-inset-top) + 10px) 14px 10px; background:#000; border:none; }
  .dm-title-wrap { text-align:center; }
  .dm-name { font-size:24px; font-weight:800; line-height:1.1; }
  .dm-sub { margin-top:3px; font-size:14px; color:var(--text-soft); }
  .dm-header-avatar-btn { justify-self:end; width:40px; height:40px; border:none; background:transparent; padding:0; }
  .dm-avatar { width:40px; height:40px; border-radius:999px; overflow:hidden; }
  .session-hidden-actions { display:none; }
  .dm-status { padding:0 14px 8px; color:var(--text-soft); min-height:22px; }
  .dm-chat { flex:1; background:#000; border:none; padding:8px 14px 130px; }
  .dm-message { display:flex; gap:10px; align-items:flex-end; margin-bottom:14px; }
  .dm-msg-avatar { width:34px; height:34px; }
  .dm-bubble-wrap { max-width:min(76vw, 540px); }
  .dm-msg-meta { display:none; }
  .dm-bubble { background:#323338 !important; border:none !important; border-radius:26px; padding:14px 18px; }
  .dm-message.from-me { justify-content:flex-end; }
  .dm-message.from-me .dm-msg-avatar { display:none; }
  .dm-message.from-me .dm-bubble-wrap { max-width:min(72vw, 540px); }
  .dm-message.from-me .dm-bubble { background:#54e29a !important; color:#0b130f !important; }
  .dm-message.from-me .dm-bubble .text { color:#0b130f !important; }
  .dm-attach-menu { position:fixed; left:14px; bottom:calc(env(safe-area-inset-bottom) + 78px); display:flex; flex-direction:column; gap:10px; z-index:8; }
  .dm-attach-item { width:56px; height:56px; border-radius:28px; border:none; background:#1d1f24; color:#fff; box-shadow:0 10px 30px rgba(0,0,0,.45); font-size:14px; }
  .dm-input-row.session-compose-row { position:sticky; bottom:0; display:grid; grid-template-columns:52px 1fr 52px 52px; gap:10px; align-items:center; padding:12px 14px calc(env(safe-area-inset-bottom) + 10px); background:#111214; border-top:1px solid rgba(255,255,255,.08); }
  .dm-send-btn { font-size:24px; display:none; background:#54e29a !important; color:#09120d !important; }
  .dm-send-btn.has-text { display:flex !important; }
  #roomControlsModal .modal-card { width:100vw; height:100dvh; max-width:none; max-height:none; border:none; border-radius:0; background:#000; padding:calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 18px); overflow:auto; }
  #roomControlsModal .settings-title { text-align:center; font-size:28px; font-weight:800; margin-bottom:14px; }
  .room-controls-overview, .room-controls-panel { background:#17181d; border:1px solid rgba(255,255,255,.08); border-radius:28px; }
  .room-controls-panel { padding:18px; }
  .room-controls-grid, .room-controls-columns { display:block; }
  .room-controls-grid > *, .room-controls-columns > *, .room-controls-stack > * { margin-bottom:16px; }
  .room-controls-actions { display:flex; flex-wrap:wrap; gap:10px; }
  .room-controls-actions .modal-btn, .room-controls-actions .small-action-btn { min-height:48px; border-radius:24px; }
}
.message-bubble, .dm-bubble { border-width:1px; }
.reply-snippet { min-width:0; }
.reply-snippet-name, .reply-snippet-user, .reply-snippet-preview, .reply-snippet-text, .text { overflow-wrap:anywhere; }
body.theme-dark .message-bubble.has-bg::before, body.theme-dark .dm-bubble.has-bg::before { background-size:cover; background-position:center; opacity:.42; }
body.theme-dark .message-bubble.has-bg::after, body.theme-dark .dm-bubble.has-bg::after { background:linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,.45)); }


/* batch v10 solid theme + room controls */
body.theme-dark, body.theme-dark .app, body.theme-dark .top-bar, body.theme-dark .chat, body.theme-dark .input-shell, body.theme-dark .dm-card, body.theme-dark .dm-chat, body.theme-dark .people-card, body.theme-dark .settings-card, body.theme-dark .profile-card, body.theme-dark .auth-card, body.theme-dark #roomControlsModal .modal-card, body.theme-dark .message-action-panel, body.theme-dark .mention-picker { background:#000 !important; color:#fff !important; }
body.theme-light, body.theme-light .app, body.theme-light .top-bar, body.theme-light .chat, body.theme-light .input-shell, body.theme-light .dm-card, body.theme-light .dm-chat, body.theme-light .people-card, body.theme-light .settings-card, body.theme-light .profile-card, body.theme-light .auth-card, body.theme-light #roomControlsModal .modal-card, body.theme-light .message-action-panel, body.theme-light .mention-picker { background:#fff !important; color:#000 !important; }
body.theme-dark { --bg:#000; --panel:#000; --panel-soft:#000; --panel-alt:#000; --panel-raised:#000; --input-bg:#000; --border:#2b2b2b; --border-strong:#3b3b3b; --text:#fff; --text-soft:#c9c9c9; --text-faint:#9a9a9a; --accent:#3ae38f; --accent-strong:#3ae38f; --accent-border:#2b2b2b; --accent-soft:#000; }
body.theme-light { --bg:#fff; --panel:#fff; --panel-soft:#fff; --panel-alt:#fff; --panel-raised:#fff; --input-bg:#fff; --border:#d9d9d9; --border-strong:#bdbdbd; --text:#000; --text-soft:#444; --text-faint:#666; --accent:#111; --accent-strong:#000; --accent-border:#d9d9d9; --accent-soft:#fff; }
body.theme-dark .room-title-stack, body.theme-light .room-title-stack { background:transparent !important; }
body.theme-dark .message-bubble.has-bg, body.theme-dark .dm-bubble.has-bg, body.theme-light .message-bubble.has-bg, body.theme-light .dm-bubble.has-bg { background:#111 !important; }
.message-bubble.has-bg::before, .dm-bubble.has-bg::before { opacity:.82 !important; filter:none !important; background-size:cover !important; background-repeat:no-repeat !important; background-position:center center !important; }
.message-bubble.has-bg::after, .dm-bubble.has-bg::after { background:linear-gradient(180deg, rgba(0,0,0,.08), rgba(0,0,0,.18)) !important; }
.message.from-me .message-bubble.has-bg, .dm-message.from-me .dm-bubble.has-bg { background:#111 !important; border-color:rgba(255,255,255,.12) !important; }
.message-bubble.has-bg .text, .message-bubble.has-bg .username, .message-bubble.has-bg .reply-snippet, .dm-bubble.has-bg .text { color:#fff !important; }
body.theme-light .message, body.theme-light .message-bubble, body.theme-light .dm-bubble, body.theme-light .room-controls-panel, body.theme-light .empty-box, body.theme-light .field input, body.theme-light .field textarea, body.theme-light .field select { border-color:#d9d9d9 !important; color:#000 !important; }
body.theme-dark .message, body.theme-dark .message-bubble, body.theme-dark .dm-bubble, body.theme-dark .room-controls-panel, body.theme-dark .empty-box, body.theme-dark .field input, body.theme-dark .field textarea, body.theme-dark .field select { border-color:#2b2b2b !important; color:#fff !important; }
body.theme-dark .message-bubble { background:#2f2f31 !important; border:none !important; }
body.theme-dark .message.from-me .message-bubble, body.theme-dark .dm-message.from-me .dm-bubble { background:#39e58d !important; color:#071109 !important; }
body.theme-dark .message.from-me .message-bubble.has-bg, body.theme-dark .dm-message.from-me .dm-bubble.has-bg { color:#fff !important; }
.room-header-menu-btn { width:52px !important; height:52px !important; }
.mini-header-avatar { width:30px !important; height:30px !important; background:#24262b !important; border:2px solid rgba(255,255,255,.14) !important; }
.room-edit-btn { right:62px; }
.room-controls-card { position:relative; }
.room-controls-card .settings-title { margin-top:10px; }
.room-session-actions .room-controls-actions { display:block; }
.room-session-actions .modal-btn, .room-session-actions .small-action-btn, .room-session-admin-card .room-session-row-btn { width:100%; justify-content:flex-start; text-align:left; min-height:72px; border-radius:28px; padding:0 24px; font-size:20px; margin:0 0 12px; background:#17181d; border:1px solid rgba(255,255,255,.08); color:var(--text); }
.room-session-admin-card .room-session-row-btn { display:flex; flex-direction:column; align-items:flex-start; gap:2px; }
.room-session-admin-card .room-session-row-btn small { color:var(--text-soft); font-size:15px; }
.room-session-admin-card .room-session-row-btn.danger { color:#ff5454; }
.room-attachments-section { margin-top:10px; }
.room-attachments-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.room-attachment-thumb { border:none; background:#111; padding:0; border-radius:16px; overflow:hidden; aspect-ratio:1; }
.room-attachment-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.room-identity-panel.hidden, .room-controls-grid.hidden { display:none !important; }
@media (max-width:820px){
  .top-bar.session-room-header { background:#000 !important; border-bottom:none !important; }
  .chat { background:#000 !important; }
  .input-shell { background:#0e0e10 !important; border-top:1px solid #1f1f23 !important; }
  body.theme-light .top-bar.session-room-header, body.theme-light .chat { background:#fff !important; }
  body.theme-light .input-shell { background:#fff !important; border-top:1px solid #e5e5e5 !important; }
  .room-header-sub { display:block !important; color:var(--text-soft) !important; }
  .message { padding:0 0 18px !important; }
  .message .avatar { margin-top:32px !important; }
  .message-bubble { max-width:min(74vw,540px) !important; border-radius:24px !important; }
  .message.from-me .message-body { align-items:flex-end !important; }
  .message.from-me .message-bubble { max-width:min(72vw,540px) !important; }
  #roomControlsModal .modal-card { background:#000 !important; }
  .room-controls-overview, .room-controls-panel { background:#17181d !important; }
}


/* v11 session polish overrides */
body.theme-dark {
  --bg:#000000 !important;
  --panel:#000000 !important;
  --panel-soft:#000000 !important;
  --panel-alt:#000000 !important;
  --panel-raised:#000000 !important;
  --border:#1e1e1e !important;
  --border-strong:#2a2a2a !important;
  --chip-bg:#000000 !important;
  --chip-border:#2a2a2a !important;
  --chip-hover:#0d0d0d !important;
  --input-bg:#000000 !important;
  --text:#ffffff !important;
  --text-soft:#d1d1d1 !important;
  --text-faint:#9a9a9a !important;
}
body.theme-light {
  --bg:#ffffff !important;
  --panel:#ffffff !important;
  --panel-soft:#ffffff !important;
  --panel-alt:#ffffff !important;
  --panel-raised:#ffffff !important;
  --border:#d8d8d8 !important;
  --border-strong:#c7c7c7 !important;
  --chip-bg:#ffffff !important;
  --chip-border:#d8d8d8 !important;
  --chip-hover:#f5f5f5 !important;
  --input-bg:#ffffff !important;
  --text:#000000 !important;
  --text-soft:#2d2d2d !important;
  --text-faint:#666666 !important;
}
body.theme-dark, body.theme-light { background-image:none !important; }
body.theme-dark .app, body.theme-light .app, body.theme-dark .main-layout, body.theme-light .main-layout,
body.theme-dark .chat-panel, body.theme-light .chat-panel, body.theme-dark .composer-bar, body.theme-light .composer-bar,
body.theme-dark .participants-card, body.theme-light .participants-card, body.theme-dark .dm-shell, body.theme-light .dm-shell,
body.theme-dark .room-controls-panel, body.theme-light .room-controls-panel, body.theme-dark .modal-card, body.theme-light .modal-card {
  background:var(--panel) !important;
  box-shadow:none !important;
}
body.theme-dark .chat-panel, body.theme-dark .composer-bar, body.theme-dark .participants-card, body.theme-dark .modal-card,
body.theme-light .chat-panel, body.theme-light .composer-bar, body.theme-light .participants-card, body.theme-light .modal-card {
  border-color:var(--border) !important;
}
/* message bg: no green wash, full cover */
.message-bubble.has-bg, .dm-bubble.has-bg {
  background:#000 !important;
}
.message-bubble.has-bg::before, .dm-bubble.has-bg::before {
  background-size:100% 100% !important;
  background-position:center center !important;
  background-repeat:no-repeat !important;
  opacity:1 !important;
  filter:none !important;
}
.message-bubble.has-bg::after, .dm-bubble.has-bg::after {
  display:none !important;
  background:none !important;
}
.message-bubble.has-bg .text, .message-bubble.has-bg .username, .message-bubble.has-bg .reply-snippet,
.message-bubble.has-bg .reply-snippet-user, .message-bubble.has-bg .reply-snippet-text,
.dm-bubble.has-bg .text, .dm-bubble.has-bg .dm-msg-meta { 
  text-shadow:0 1px 2px rgba(0,0,0,.65) !important;
  color:#fff !important;
}
/* cleaner session-like room controls */
.room-controls-panel {
  background:var(--panel) !important;
}
.room-controls-panel .room-controls-status {
  margin-bottom:12px;
}
.room-controls-panel .room-control-card {
  background:#17181c !important;
  border:1px solid #24262c !important;
  border-radius:28px !important;
  box-shadow:none !important;
}
body.theme-light .room-controls-panel .room-control-card {
  background:#fff !important;
  border:1px solid #dedede !important;
}
.room-controls-panel .conversation-shortcuts .small-action-btn {
  width:100%;
  justify-content:flex-start;
  min-height:64px;
  border-radius:0 !important;
  border:none !important;
  border-top:1px solid rgba(255,255,255,.08) !important;
  background:transparent !important;
  font-size:18px !important;
  font-weight:600 !important;
  color:var(--text) !important;
  padding:0 24px !important;
}
.room-controls-panel .conversation-shortcuts .small-action-btn:first-child { border-top:none !important; }
body.theme-light .room-controls-panel .conversation-shortcuts .small-action-btn { border-top:1px solid rgba(0,0,0,.08) !important; }
/* top right avatars */
.room-menu-avatar, .room-menu-avatar img {
  object-fit:cover;
}
.room-menu-avatar {
  overflow:hidden;
  background:#2d323b !important;
}
/* mobile room screen like session */
@media (max-width: 760px) {
  .top-bar { padding:0 !important; justify-content:center !important; position:relative; }
  .room-title-stack { align-items:center !important; text-align:center !important; }
  .room-kicker { display:none !important; }
  .room-header-sub { font-size:15px !important; color:var(--text-soft) !important; }
  .room-menu-avatar-stack { position:absolute !important; right:16px !important; top:8px !important; }
  .chat-panel { border:none !important; border-radius:0 !important; min-height:calc(100dvh - 280px) !important; }
  .composer-bar { border:none !important; border-top:1px solid var(--border) !important; border-radius:0 !important; padding:14px 12px calc(14px + env(safe-area-inset-bottom)) !important; }
  .bottom-links { padding-top:8px !important; }
  .message-row { padding:12px 12px !important; border:none !important; }
  .message-avatar { width:42px !important; height:42px !important; }
  .message-bubble { max-width:min(72vw,520px) !important; border-radius:28px !important; background:#35363a !important; }
  .message.from-me .message-bubble { background:#39e58d !important; color:#071109 !important; }
  .message.from-me .message-bubble .text { color:#071109 !important; }
  .username-line { margin-bottom:6px !important; }
  .dm-shell, .dm-header, .dm-composer-wrap { background:#000 !important; }
}


/* v12 overrides */
body.theme-dark, body.theme-dark .app, body.theme-dark .main-layout, body.theme-dark .chat-column, body.theme-dark .chat, body.theme-dark .input-shell, body.theme-dark .top-bar, body.theme-dark .user-panel, body.theme-dark .modal-card, body.theme-dark .dm-card, body.theme-dark .dm-chat, body.theme-dark .room-controls-card { background:#000 !important; color:#fff !important; background-image:none !important; }
body.theme-light, body.theme-light .app, body.theme-light .main-layout, body.theme-light .chat-column, body.theme-light .chat, body.theme-light .input-shell, body.theme-light .top-bar, body.theme-light .user-panel, body.theme-light .modal-card, body.theme-light .dm-card, body.theme-light .dm-chat, body.theme-light .room-controls-card { background:#fff !important; color:#000 !important; background-image:none !important; }
body.theme-dark .top-bar, body.theme-dark .input-shell, body.theme-dark .chat, body.theme-dark .user-panel, body.theme-dark .dm-card, body.theme-dark .room-controls-card { border-color:#1d1d1d !important; box-shadow:none !important; }
body.theme-light .top-bar, body.theme-light .input-shell, body.theme-light .chat, body.theme-light .user-panel, body.theme-light .dm-card, body.theme-light .room-controls-card { border-color:#d8d8d8 !important; box-shadow:none !important; }
#roomNotice, body.theme-dark #roomNotice, body.theme-light #roomNotice { display:none !important; }
.chat { border:none !important; border-radius:0 !important; padding-top:8px !important; }
.input-shell { border-top:none !important; border-left:none !important; border-right:none !important; border-radius:0 !important; }
.user-panel { border:none !important; border-left:1px solid rgba(255,255,255,.08) !important; border-radius:0 !important; }
.chat-attach-menu { position:absolute; left:0; bottom:72px; display:flex; flex-direction:column; gap:10px; z-index:60; }
.chat-attach-menu.hidden { display:none !important; }
.chat-attach-menu .dm-attach-item { width:72px; height:72px; border-radius:999px; }
body.theme-dark .message-bubble.has-bg, body.theme-dark .dm-bubble.has-bg, body.theme-light .message-bubble.has-bg, body.theme-light .dm-bubble.has-bg { background:transparent !important; }
.message-bubble.has-bg::before, .dm-bubble.has-bg::before { opacity:1 !important; background-size:cover !important; background-position:center center !important; background-repeat:no-repeat !important; }
.message-bubble.has-bg::after, .dm-bubble.has-bg::after { background:transparent !important; }
.message-bubble, .dm-bubble { overflow:hidden; }
#roomControlsOverview, .room-controls-grid, #roomAutoModSection { display:none !important; }
.room-session-actions .row-actions { display:flex; flex-direction:column; gap:16px; }
.room-session-actions .modal-btn, .room-session-actions .small-action-btn, .room-session-admin-menu .room-session-row-btn { width:100%; justify-content:flex-start; min-height:76px; border-radius:28px; font-size:18px; padding:0 24px; }
.room-session-admin-menu { display:grid; gap:18px; }
.room-session-admin-card .people-section-title, .room-session-actions .people-section-title { margin-bottom:16px; }
.room-identity-panel.hidden { display:none !important; }
.room-identity-panel { margin-top:18px; }
.reaction-more-btn { font-size:28px !important; }
body.theme-dark .message-action-panel, body.theme-dark .message-action-sheet { background:rgba(0,0,0,.66) !important; }
body.theme-light .message-action-panel, body.theme-light .message-action-sheet { background:rgba(255,255,255,.66) !important; }
body.theme-dark .message-action-btn, body.theme-dark .reaction-btn { background:#1a1a1a !important; color:#fff !important; }
body.theme-light .message-action-btn, body.theme-light .reaction-btn { background:#f4f4f4 !important; color:#000 !important; }
.room-controls-card .room-controls-panel { background:#111319 !important; }
body.theme-light .room-controls-card .room-controls-panel { background:#fff !important; border:1px solid #dcdcdc !important; }
.room-controls-card .people-section-title { letter-spacing:.12em; text-transform:uppercase; }
body.theme-dark .room-controls-card input, body.theme-dark .room-controls-card textarea, body.theme-dark .room-controls-card select { background:#000 !important; color:#fff !important; }
body.theme-light .room-controls-card input, body.theme-light .room-controls-card textarea, body.theme-light .room-controls-card select { background:#fff !important; color:#000 !important; }
@media (max-width: 900px) {
  .app, .main-layout, .chat-column { background:inherit !important; }
  .chat { min-height:0 !important; height:calc(100dvh - 220px) !important; }
  .message { gap:8px; margin:0 0 14px 0 !important; }
  .message-bubble { max-width:72vw !important; }
  .input-shell { padding-bottom:calc(env(safe-area-inset-bottom) + 10px) !important; }
}


/* v13 solid session polish */
body, body.theme-dark, body.theme-light { background-image:none !important; }
.status { min-height: 0 !important; padding: 0 16px 8px !important; background: transparent !important; border: none !important; color: var(--text-soft) !important; }
.status.error { color: #ff6262 !important; }
.app { max-width: none !important; padding: 0 !important; }
.top-bar { padding: calc(env(safe-area-inset-top) + 8px) 16px 10px !important; border: none !important; }
.chat-column, .chat, .input-shell { background: var(--panel) !important; }
.chat { min-height: calc(100dvh - 210px) !important; padding-bottom: 12px !important; }
.input-shell { border-top: none !important; }
.user-panel { display:none !important; }
.room-notice { display:none !important; }
.room-header-menu-btn { background: transparent !important; border: none !important; }
.mini-header-avatar { border-radius: 999px !important; overflow: hidden !important; }
.mini-header-avatar img { width:100%; height:100%; object-fit:cover; display:block; }
/* identical attach menus */
.chat-attach-menu, .dm-attach-menu {
  position: fixed !important;
  left: 12px !important;
  bottom: calc(env(safe-area-inset-bottom) + 92px) !important;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 120;
}
.chat-attach-menu.hidden, .dm-attach-menu.hidden { display:none !important; }
.chat-attach-menu .dm-attach-item, .dm-attach-menu .dm-attach-item {
  width: 74px !important;
  height: 74px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255,255,255,.08) !important;
  background: #1c1f26 !important;
  color: #fff !important;
  font-size: 20px !important;
  box-shadow: none !important;
}
body.theme-light .chat-attach-menu .dm-attach-item, body.theme-light .dm-attach-menu .dm-attach-item {
  background:#fff !important; color:#000 !important; border-color:#d8d8d8 !important;
}
/* GIF picker */
.gif-picker-card {
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  border: none !important;
  border-radius: 0 !important;
  padding: calc(env(safe-area-inset-top) + 10px) 0 calc(env(safe-area-inset-bottom) + 10px) !important;
  background: var(--panel) !important;
  display: flex;
  flex-direction: column;
}
.gif-picker-top { display:grid; grid-template-columns: 88px 1fr 88px; align-items:center; padding: 0 12px 8px; }
.gif-picker-top .settings-title { text-align:center; margin:0; font-size: 30px; }
.gif-picker-cancel { justify-self:start; min-height:40px; border:none !important; background:transparent !important; padding:0 !important; }
.gif-search-row { display:flex; align-items:center; gap:8px; padding: 0 12px 12px; }
.gif-search-icon { font-size: 26px; color: var(--text-soft); }
.gif-search-row input { flex:1; border:none !important; border-radius:0 !important; background:transparent !important; font-size: 22px !important; padding: 8px 0 !important; box-shadow:none !important; }
.gif-picker-grid { display:grid; grid-template-columns: repeat(2, 1fr); gap:0; overflow:auto; flex:1; }
.gif-thumb { border:none; padding:0; background:#000; aspect-ratio:1/1; }
.gif-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.gif-powered { text-align:center; font-size:16px; letter-spacing:.03em; padding:8px 0 0; color:var(--text-soft); }
/* room controls exactly simpler */
.room-controls-card .room-controls-overview, .room-controls-card .room-identity-panel, .room-controls-card #roomAutoModSection, .room-controls-card #roomControlsStaffSection, .room-controls-card #roomControlsModSection, .room-controls-card .room-controls-grid { display:none !important; }
.room-controls-card .room-session-actions, .room-controls-card .room-session-admin-card { background:#15181f !important; border:1px solid rgba(255,255,255,.08) !important; border-radius:28px !important; }
body.theme-light .room-controls-card .room-session-actions, body.theme-light .room-controls-card .room-session-admin-card { background:#fff !important; border-color:#d8d8d8 !important; }
.room-session-actions .room-controls-actions { display:grid !important; gap:18px !important; }
.room-session-actions .modal-btn, .room-session-actions .small-action-btn, .room-session-admin-menu .room-session-row-btn {
  min-height: 82px !important; border-radius: 28px !important; justify-content:flex-start !important; text-align:left !important; padding:0 26px !important; font-size:20px !important; background:#17181d !important; border:1px solid rgba(255,255,255,.08) !important;
}
body.theme-light .room-session-actions .modal-btn, body.theme-light .room-session-actions .small-action-btn, body.theme-light .room-session-admin-menu .room-session-row-btn { background:#fff !important; border-color:#d8d8d8 !important; }
.room-session-admin-menu { display:grid !important; gap:18px !important; }
/* solid black/white message area */
body.theme-dark .top-bar, body.theme-dark .chat, body.theme-dark .input-shell, body.theme-dark .chat-column, body.theme-dark .dm-chat, body.theme-dark .dm-card { background:#000 !important; }
body.theme-light .top-bar, body.theme-light .chat, body.theme-light .input-shell, body.theme-light .chat-column, body.theme-light .dm-chat, body.theme-light .dm-card { background:#fff !important; }
.message { border-bottom:none !important; padding: 10px 14px !important; }
.message:hover { background: transparent !important; }
.message-body { min-width:0; }
.message-bubble { max-width:min(72vw, 540px) !important; border-radius:28px !important; padding:16px 18px !important; background:#35363a !important; }
.message.from-me .message-bubble { background:#39e58d !important; color:#041008 !important; }
.message.from-me .message-bubble .text { color:#041008 !important; }
body.theme-light .message-bubble { background:#f0f0f0 !important; color:#000 !important; }
body.theme-light .message.from-me .message-bubble { background:#39e58d !important; color:#041008 !important; }
/* remove green wash from custom bg */
.message-bubble.has-bg, .dm-bubble.has-bg { background:transparent !important; }
.message-bubble.has-bg::before, .dm-bubble.has-bg::before { opacity:1 !important; background-size:cover !important; background-position:center center !important; }
.message-bubble.has-bg::after, .dm-bubble.has-bg::after { display:none !important; }
/* long press reaction panel polish */
.message-action-panel { border-radius:28px !important; background:#11141a !important; border:1px solid rgba(255,255,255,.08) !important; overflow:hidden; }
.message-action-btn { border-top:1px solid rgba(255,255,255,.08) !important; min-height:60px !important; }
.reaction-btn { width:56px !important; height:56px !important; border-radius:999px !important; }
@media (max-width: 820px) {
  .top-bar { justify-content:center !important; }
  .more-link, .room-kicker { display:none !important; }
  .room-title { font-size: 42px !important; }
  .room-header-sub { font-size: 18px !important; }
  .room-header-menu-btn { position:absolute !important; right:16px; top:8px; }
  .chat { height: calc(100dvh - 230px) !important; min-height: calc(100dvh - 230px) !important; }
  .input-shell { padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px) !important; }
  .bottom-row { display:none !important; }
}


/* V14 solid Session-style cleanup */
.status { display:none !important; }
.room-notice { display:none !important; }
body.theme-dark, body.theme-dark .app, body.theme-dark .main-layout, body.theme-dark .chat-column, body.theme-dark .chat, body.theme-dark .input-shell, body.theme-dark .top-bar, body.theme-dark .user-panel, body.theme-dark .dm-card, body.theme-dark .dm-chat, body.theme-dark .people-card, body.theme-dark .settings-card, body.theme-dark .profile-card, body.theme-dark .auth-card, body.theme-dark .room-controls-card { background:#000 !important; background-image:none !important; color:#fff !important; }
body.theme-light, body.theme-light .app, body.theme-light .main-layout, body.theme-light .chat-column, body.theme-light .chat, body.theme-light .input-shell, body.theme-light .top-bar, body.theme-light .user-panel, body.theme-light .dm-card, body.theme-light .dm-chat, body.theme-light .people-card, body.theme-light .settings-card, body.theme-light .profile-card, body.theme-light .auth-card, body.theme-light .room-controls-card { background:#fff !important; background-image:none !important; color:#000 !important; }
body.theme-dark .top-bar, body.theme-dark .chat, body.theme-dark .input-shell, body.theme-dark .dm-card, body.theme-dark .room-controls-card { border-color:#151515 !important; box-shadow:none !important; }
body.theme-light .top-bar, body.theme-light .chat, body.theme-light .input-shell, body.theme-light .dm-card, body.theme-light .room-controls-card { border-color:#e5e5e5 !important; box-shadow:none !important; }
.top-bar.session-room-header { background:inherit !important; border:none !important; }
.main-layout, .chat-column, .chat { background:inherit !important; }
.chat-column { min-height:calc(100dvh - 112px); }
.chat { flex:1 1 auto; min-height:0; border:none !important; border-radius:0 !important; }
.user-panel { display:none !important; }
.main-layout { display:block !important; }
.input-shell { position:sticky; bottom:0; border-top:1px solid var(--border) !important; border-left:none !important; border-right:none !important; border-bottom:none !important; border-radius:0 !important; box-shadow:none !important; }
.bottom-row { justify-content:flex-start; gap:22px; }

/* identical attach menus for room + dm */
.chat-attach-menu, .dm-attach-menu {
  position:fixed !important;
  left:14px !important;
  bottom:calc(env(safe-area-inset-bottom) + 88px) !important;
  display:flex !important;
  flex-direction:column !important;
  gap:14px !important;
  z-index:90 !important;
}
.chat-attach-menu.hidden, .dm-attach-menu.hidden { display:none !important; }
.chat-attach-menu .dm-attach-item, .dm-attach-menu .dm-attach-item {
  width:78px !important;
  height:78px !important;
  border-radius:999px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  font-size:18px !important;
  background:#1a1d24 !important;
  color:#fff !important;
  border:1px solid rgba(255,255,255,.08) !important;
  box-shadow:0 8px 18px rgba(0,0,0,.28) !important;
}
body.theme-light .chat-attach-menu .dm-attach-item, body.theme-light .dm-attach-menu .dm-attach-item { background:#fff !important; color:#000 !important; border-color:#d9d9d9 !important; }

/* full screen gif picker */
.gif-picker-card {
  width:100vw !important; max-width:none !important; height:100dvh !important; max-height:none !important;
  border:none !important; border-radius:0 !important; padding:calc(env(safe-area-inset-top) + 10px) 12px calc(env(safe-area-inset-bottom) + 12px) !important;
  background:#000 !important; color:#fff !important; display:flex !important; flex-direction:column !important;
}
body.theme-light .gif-picker-card { background:#fff !important; color:#000 !important; }
.gif-picker-top { align-items:center !important; }
.gif-picker-cancel { background:transparent !important; border:none !important; padding:0 !important; min-height:auto !important; }
.gif-search-row { border:none !important; border-radius:0 !important; background:transparent !important; padding:0 0 12px 0 !important; }
.gif-search-row input { border:none !important; background:transparent !important; font-size:22px !important; }
.gif-picker-grid { grid-template-columns:1fr 1fr !important; gap:8px !important; }
.gif-thumb { aspect-ratio:1 / 1 !important; border-radius:0 !important; }
.gif-powered { margin-top:auto !important; padding-top:8px !important; text-align:center !important; font-weight:700 !important; }

/* room controls simplified */
.room-controls-card .room-controls-overview,
.room-controls-card .room-identity-panel,
.room-controls-card #roomAutoModSection,
.room-controls-card #roomControlsStaffSection,
.room-controls-card #roomControlsModSection,
.room-controls-card .room-controls-grid { display:none !important; }
.room-controls-card.editing .room-identity-panel,
.room-controls-card.editing #roomControlsModSection { display:block !important; }
.room-controls-card.editing #roomControlsStaffSection { display:block !important; }
.room-controls-card .settings-title { margin-top:8px !important; }
.room-controls-card { background:inherit !important; }
.room-session-actions, .room-session-admin-card {
  background:#111319 !important;
  border:1px solid rgba(255,255,255,.08) !important;
  border-radius:30px !important;
  padding:18px !important;
}
body.theme-light .room-session-actions, body.theme-light .room-session-admin-card { background:#fff !important; border-color:#e3e3e3 !important; }
.room-session-actions .row-actions, .room-session-admin-menu { display:grid !important; gap:16px !important; }
.room-session-actions .modal-btn, .room-session-actions .small-action-btn, .room-session-admin-menu .room-session-row-btn {
  width:100% !important; min-height:80px !important; border-radius:28px !important; justify-content:flex-start !important; text-align:left !important;
  padding:0 24px !important; background:#171a20 !important; border:1px solid rgba(255,255,255,.08) !important; box-shadow:none !important;
}
body.theme-light .room-session-actions .modal-btn, body.theme-light .room-session-actions .small-action-btn, body.theme-light .room-session-admin-menu .room-session-row-btn { background:#fff !important; color:#000 !important; border-color:#e1e1e1 !important; }
.room-session-admin-menu .room-session-row-btn.danger { color:#ff5f5f !important; }
.room-controls-card .people-section-title { margin-bottom:14px !important; letter-spacing:.14em !important; text-transform:uppercase !important; }
.room-controls-card .close-btn, .room-controls-card .room-edit-btn { width:52px !important; height:52px !important; border-radius:999px !important; }
.room-controls-card .room-edit-btn { right:74px !important; }
.room-attachments-section { margin-top:16px !important; }
.room-attachments-grid { grid-template-columns:repeat(3, minmax(0, 1fr)) !important; }

/* cleaner message action sheet with recent plus */
.message-action-panel { background:#111319 !important; border:1px solid rgba(255,255,255,.08) !important; border-radius:28px !important; }
body.theme-light .message-action-panel { background:#fff !important; border-color:#e1e1e1 !important; }
.reaction-more-btn { font-size:26px !important; }

/* message backgrounds fill full bubble */
.message-bubble, .dm-bubble {
  background-size:cover !important;
  background-position:center center !important;
  background-repeat:no-repeat !important;
}
.message-bubble::before, .dm-bubble::before { background:transparent !important; }
.reply-snippet, .message-reply-preview { max-width:100% !important; overflow:hidden !important; }
.reply-snippet * { max-width:100% !important; }

/* top avatar stack */
.mini-header-avatar { background:#1b1d24 !important; overflow:hidden !important; }
.mini-header-avatar img { width:100% !important; height:100% !important; object-fit:cover !important; display:block !important; }
body.theme-light .mini-header-avatar { background:#efefef !important; }

/* exact mobile solid layout */
@media (max-width: 900px) {
  .top-bar.session-room-header { padding:calc(env(safe-area-inset-top) + 8px) 16px 10px !important; min-height:auto !important; }
  .room-title-stack { gap:2px !important; }
  .room-kicker { display:none !important; }
  .room-title { font-size:34px !important; }
  .room-header-sub { font-size:18px !important; color:var(--text-soft) !important; }
  .chat { padding:0 0 8px 0 !important; }
  .chat-message-row { padding:0 12px 10px !important; }
  .message-row { padding:0 12px 10px !important; }
  .input-row { gap:10px !important; }
  .tool-btn, #sendBtn, #sendDmBtn { height:72px !important; border-radius:999px !important; }
  #messageInput, #dmInput { height:72px !important; border-radius:999px !important; }
  .dm-card { width:100vw !important; height:100dvh !important; border:none !important; border-radius:0 !important; }
}


/* V15 solid session polish */
:root { --session-black: #000; --session-white: #fff; }
body.theme-dark, body.theme-dark .app, body.theme-dark .main-layout, body.theme-dark .chat-column,
body.theme-dark .chat, body.theme-dark .top-bar, body.theme-dark .input-shell, body.theme-dark .chat-panel,
body.theme-dark .composer-bar, body.theme-dark .user-panel, body.theme-dark .modal-card, body.theme-dark .dm-card,
body.theme-dark .dm-chat, body.theme-dark .dm-shell, body.theme-dark .people-card, body.theme-dark .settings-card,
body.theme-dark .profile-card, body.theme-dark .auth-card { background:#000 !important; background-image:none !important; color:#fff !important; }
body.theme-light, body.theme-light .app, body.theme-light .main-layout, body.theme-light .chat-column,
body.theme-light .chat, body.theme-light .top-bar, body.theme-light .input-shell, body.theme-light .chat-panel,
body.theme-light .composer-bar, body.theme-light .user-panel, body.theme-light .modal-card, body.theme-light .dm-card,
body.theme-light .dm-chat, body.theme-light .dm-shell, body.theme-light .people-card, body.theme-light .settings-card,
body.theme-light .profile-card, body.theme-light .auth-card { background:#fff !important; background-image:none !important; color:#000 !important; }
body.theme-dark .top-bar.session-room-header, body.theme-dark .chat-column, body.theme-dark .chat, body.theme-dark .input-shell, body.theme-dark .chat-panel { background:#000 !important; }
body.theme-light .top-bar.session-room-header, body.theme-light .chat-column, body.theme-light .chat, body.theme-light .input-shell, body.theme-light .chat-panel { background:#fff !important; }
.top-bar.session-room-header, .chat-column, .chat, .chat-panel, .input-shell, .composer-bar { box-shadow:none !important; border:none !important; }
.chat-column { min-height: calc(100dvh - 112px) !important; }
.chat { padding-top:0 !important; min-height: calc(100dvh - 220px) !important; }
#roomNotice, .room-notice, #editRoomNoticeBtn { display:none !important; }
#roomControlsOverview, .room-identity-panel, .room-controls-grid { display:none !important; }
#roomAutoModSection.hidden, #roomControlsStaffSection.hidden, #roomControlsModSection.hidden { display:none !important; }
.room-controls-card { background:#000 !important; color:#fff !important; }
body.theme-light .room-controls-card { background:#fff !important; color:#000 !important; }
.room-session-actions, .room-session-admin-card, .room-controls-overview, .room-controls-panel, .room-controls-stack .room-controls-panel {
  background:#111318 !important; border:1px solid rgba(255,255,255,.08) !important; border-radius:28px !important; box-shadow:none !important;
}
body.theme-light .room-session-actions, body.theme-light .room-session-admin-card, body.theme-light .room-controls-overview, body.theme-light .room-controls-panel, body.theme-light .room-controls-stack .room-controls-panel {
  background:#fff !important; border:1px solid #dedede !important; color:#000 !important;
}
.room-session-actions .room-controls-actions { display:grid !important; gap:18px !important; }
.room-session-actions .room-controls-actions > button, .room-session-admin-menu > button {
  width:100% !important; justify-content:flex-start !important; text-align:left !important; min-height:82px !important; padding:0 24px !important; 
  border-radius:28px !important; background:#171a20 !important; border:1px solid rgba(255,255,255,.08) !important; color:#fff !important; box-shadow:none !important;
}
body.theme-light .room-session-actions .room-controls-actions > button, body.theme-light .room-session-admin-menu > button {
  background:#fff !important; color:#000 !important; border:1px solid #e5e5e5 !important;
}
.room-session-admin-menu { display:grid !important; gap:18px !important; }
.room-session-admin-menu .room-session-row-btn.danger { color:#ff6565 !important; }
.chat-attach-menu, .dm-attach-menu {
  position:fixed !important; left:14px !important; bottom:calc(env(safe-area-inset-bottom) + 94px) !important; display:flex !important; flex-direction:column !important; gap:12px !important; z-index:120 !important;
}
.chat-attach-menu.hidden, .dm-attach-menu.hidden { display:none !important; }
.chat-attach-menu .dm-attach-item, .dm-attach-menu .dm-attach-item {
  width:82px !important; height:82px !important; border-radius:999px !important; display:flex !important; align-items:center !important; justify-content:center !important; background:#1a1d23 !important; color:#fff !important; border:1px solid rgba(255,255,255,.08) !important; font-size:18px !important;
}
body.theme-light .chat-attach-menu .dm-attach-item, body.theme-light .dm-attach-menu .dm-attach-item { background:#fff !important; color:#000 !important; border-color:#dedede !important; }
.gif-picker-card {
  position:fixed !important; inset:0 !important; max-width:none !important; max-height:none !important; width:100vw !important; height:100dvh !important; border-radius:0 !important;
  background:#000 !important; color:#fff !important; padding:calc(env(safe-area-inset-top) + 10px) 0 calc(env(safe-area-inset-bottom) + 10px) !important; display:flex !important; flex-direction:column !important;
}
body.theme-light .gif-picker-card { background:#fff !important; color:#000 !important; }
.gif-picker-top { display:grid !important; grid-template-columns:88px 1fr 88px !important; align-items:center !important; padding:0 12px 12px !important; }
.gif-picker-top .settings-title { font-size:34px !important; text-align:center !important; margin:0 !important; }
.gif-picker-cancel { background:transparent !important; border:none !important; padding:0 !important; min-height:auto !important; font-size:20px !important; color:inherit !important; }
.gif-search-row { margin:0 12px 12px !important; border-radius:18px !important; background:#111318 !important; border:1px solid rgba(255,255,255,.08) !important; }
body.theme-light .gif-search-row { background:#fff !important; border-color:#dedede !important; }
.gif-picker-grid { display:grid !important; grid-template-columns:1fr 1fr !important; gap:8px !important; padding:0 10px 12px !important; overflow:auto !important; }
.gif-thumb { aspect-ratio:1 / 1 !important; border-radius:0 !important; overflow:hidden !important; }
.gif-thumb img { width:100% !important; height:100% !important; object-fit:cover !important; display:block !important; }
.gif-powered { padding:6px 0 0 !important; text-align:center !important; color:var(--text-soft) !important; }
.message-bubble.has-bg, .dm-bubble.has-bg, .settings-preview.has-bg { background:transparent !important; overflow:hidden !important; }
.message-bubble.has-bg::before, .dm-bubble.has-bg::before, .settings-preview.has-bg::before {
  opacity:1 !important; background-size:cover !important; background-position:center center !important; background-repeat:no-repeat !important; filter:none !important; inset:0 !important;
}
.message-bubble.has-bg::after, .dm-bubble.has-bg::after, .settings-preview.has-bg::after { display:none !important; background:transparent !important; }
.message-bubble.has-bg .text, .message-bubble.has-bg .username, .message-bubble.has-bg .reply-snippet, .message-bubble.has-bg .reply-snippet-name, .message-bubble.has-bg .reply-snippet-preview,
.dm-bubble.has-bg .text, .dm-bubble.has-bg .dm-msg-meta, .settings-preview.has-bg .settings-preview-name, .settings-preview.has-bg .settings-preview-text {
  color:#fff !important; text-shadow:0 1px 6px rgba(0,0,0,.55) !important;
}
.mini-header-avatar { background:#1a1d23 !important; border:2px solid rgba(255,255,255,.12) !important; }
body.theme-light .mini-header-avatar { background:#efefef !important; border-color:#dadada !important; }
body.theme-dark .message, body.theme-dark .message-body, body.theme-dark .chat { background:#000 !important; }
body.theme-light .message, body.theme-light .message-body, body.theme-light .chat { background:#fff !important; }
body.theme-dark .message-action-panel { background:#111318 !important; border:1px solid rgba(255,255,255,.08) !important; border-radius:28px !important; }
body.theme-light .message-action-panel { background:#fff !important; border:1px solid #dedede !important; border-radius:28px !important; }
.message-action-btn { min-height:60px !important; }
@media (max-width: 900px) {
  .room-header-sub { color:var(--text-soft) !important; }
  .chat-column, .chat, .input-shell, .top-bar.session-room-header, .composer-bar { background:inherit !important; }
}


/* V17 hotfix: portrait footer + solid theme */
@media (max-width: 820px) {
  .bottom-row { display:flex !important; flex-wrap:wrap; row-gap:10px; padding:10px 2px 0 !important; }
  .bottom-row .bottom-icon { display:none !important; }
  .input-shell { padding-bottom:calc(env(safe-area-inset-bottom) + 18px) !important; }
}
body.theme-dark, body.theme-dark .app, body.theme-dark .main-layout, body.theme-dark .chat-column, body.theme-dark .chat, body.theme-dark .top-bar.session-room-header, body.theme-dark .input-shell, body.theme-dark .status { background:#000 !important; background-image:none !important; }
body.theme-light, body.theme-light .app, body.theme-light .main-layout, body.theme-light .chat-column, body.theme-light .chat, body.theme-light .top-bar.session-room-header, body.theme-light .input-shell, body.theme-light .status { background:#fff !important; background-image:none !important; }
.status { background:transparent !important; border:none !important; min-height:0 !important; padding:0 16px 6px !important; }
.status:empty { display:none !important; }
.chat-column, .chat { box-shadow:none !important; }
.room-notice.hidden { display:none !important; }

/* Stabilization: account-only room controls should show the simple Chatango-style panels. */
#roomControlsTitle { letter-spacing:-.03em !important; }
.room-controls-card .room-controls-overview:not(.hidden),
#roomControlsOverview:not(.hidden) {
  display:block !important;
  white-space:pre-wrap !important;
}
.room-controls-card .room-session-actions,
.room-controls-card .room-identity-panel,
.room-controls-card .room-controls-grid,
#roomControlsEditBtn {
  display:none !important;
}
.room-controls-card #roomAutoModSection:not(.hidden),
.room-controls-card #roomControlsStaffSection:not(.hidden),
.room-controls-card #roomControlsModSection:not(.hidden),
.room-controls-card .room-session-admin-card:not(.hidden) {
  display:block !important;
}
.room-controls-card #roomAutoModSection.hidden,
.room-controls-card #roomControlsStaffSection.hidden,
.room-controls-card #roomControlsModSection.hidden,
.room-controls-card .room-session-admin-card.hidden {
  display:none !important;
}

/* Stabilization: custom message backgrounds render as the raw image/GIF, no glaze. */
.message-bubble.has-bg,
.dm-bubble.has-bg,
.settings-preview.has-bg {
  background-color:transparent !important;
  background-image:var(--msg-bg-url) !important;
  background-size:cover !important;
  background-position:center center !important;
  background-repeat:no-repeat !important;
  overflow:hidden !important;
}
.message-bubble.has-bg::before,
.message-bubble.has-bg::after,
.dm-bubble.has-bg::before,
.dm-bubble.has-bg::after,
.settings-preview.has-bg::before,
.settings-preview.has-bg::after {
  content:none !important;
  display:none !important;
  background:none !important;
  opacity:0 !important;
  filter:none !important;
}

/* V18 polish: cleaner mobile flow, modal surfaces, and non-cropped GIF picker. */
html {
  min-height:100%;
  -webkit-text-size-adjust:100%;
}

body {
  min-height:100dvh;
  touch-action:manipulation;
}

button,
input,
textarea,
select {
  font:inherit;
}

button:disabled,
input:disabled {
  cursor:not-allowed !important;
  opacity:.55 !important;
}

.modal {
  backdrop-filter:blur(12px) !important;
  -webkit-backdrop-filter:blur(12px) !important;
}

.modal-card,
.dm-card,
.people-card,
.settings-card,
.auth-card,
.profile-card,
#roomControlsModal .modal-card {
  scrollbar-width:thin;
  overscroll-behavior:contain;
}

.gif-picker-card {
  overflow:hidden !important;
  background:#050608 !important;
  padding:0 !important;
}

body.theme-light .gif-picker-card {
  background:#f8f8f6 !important;
}

.gif-picker-top {
  grid-template-columns:88px minmax(0, 1fr) 88px !important;
  gap:8px !important;
  flex:0 0 auto !important;
  padding:calc(env(safe-area-inset-top) + 8px) 14px 12px !important;
}

.gif-picker-top .settings-title {
  font-size:28px !important;
  line-height:1 !important;
  letter-spacing:-.04em !important;
}

.gif-picker-cancel {
  min-height:44px !important;
  border-radius:999px !important;
  font-weight:800 !important;
  text-align:left !important;
}

.gif-search-row {
  flex:0 0 auto !important;
  display:flex !important;
  align-items:center !important;
  gap:10px !important;
  min-height:50px !important;
  margin:0 14px 10px !important;
  padding:0 14px !important;
  border-radius:999px !important;
  background:#121419 !important;
}

body.theme-light .gif-search-row {
  background:#fff !important;
}

.gif-search-row input {
  width:100% !important;
  min-width:0 !important;
  min-height:48px !important;
  font-size:17px !important;
  outline:none !important;
}

#gifPickerStatus {
  flex:0 0 auto !important;
  min-height:18px !important;
  padding:0 16px 8px !important;
}

.gif-picker-grid {
  flex:1 1 auto !important;
  min-height:0 !important;
  display:grid !important;
  grid-template-columns:repeat(auto-fill, minmax(156px, 1fr)) !important;
  align-content:start !important;
  gap:12px !important;
  padding:0 14px calc(env(safe-area-inset-bottom) + 18px) !important;
  overflow-y:auto !important;
  overscroll-behavior:contain !important;
  -webkit-overflow-scrolling:touch !important;
}

.gif-picker-grid .empty-box {
  grid-column:1 / -1 !important;
}

.gif-thumb {
  aspect-ratio:var(--gif-ratio, 4 / 3) !important;
  width:100% !important;
  min-height:0 !important;
  border:1px solid rgba(255,255,255,.08) !important;
  border-radius:18px !important;
  background:#111318 !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  overflow:hidden !important;
  padding:0 !important;
}

body.theme-light .gif-thumb {
  background:#fff !important;
  border-color:#ddddda !important;
}

.gif-thumb img {
  width:100% !important;
  height:100% !important;
  object-fit:contain !important;
  display:block !important;
}

.gif-powered {
  flex:0 0 auto !important;
  padding:8px 0 max(8px, env(safe-area-inset-bottom)) !important;
  font-size:11px !important;
  letter-spacing:.14em !important;
  text-transform:uppercase !important;
}

.chat-attach-menu,
.dm-attach-menu {
  filter:drop-shadow(0 18px 36px rgba(0,0,0,.28)) !important;
}

.chat-attach-menu .dm-attach-item,
.dm-attach-menu .dm-attach-item {
  font-weight:800 !important;
}

@media (min-width: 860px) {
  .gif-picker-card {
    padding-left:max(18px, env(safe-area-inset-left)) !important;
    padding-right:max(18px, env(safe-area-inset-right)) !important;
  }

  .gif-picker-grid {
    grid-template-columns:repeat(auto-fill, minmax(190px, 1fr)) !important;
  }
}

@media (max-width: 820px) {
  .app {
    width:100% !important;
    min-height:100dvh !important;
    padding:0 !important;
  }

  .top-bar.session-room-header {
    position:sticky !important;
    top:0 !important;
    z-index:50 !important;
    padding:calc(env(safe-area-inset-top) + 10px) 14px 10px !important;
  }

  .room-title {
    font-size:30px !important;
    letter-spacing:-.05em !important;
  }

  .room-header-sub {
    font-size:14px !important;
  }

  .main-layout {
    min-height:calc(100dvh - 86px) !important;
  }

  .chat-column {
    min-height:calc(100dvh - 86px) !important;
  }

  .chat {
    min-height:calc(100dvh - 214px) !important;
    padding:2px 0 8px !important;
  }

  .input-shell {
    position:sticky !important;
    bottom:0 !important;
    z-index:55 !important;
    padding:10px 12px calc(env(safe-area-inset-bottom) + 10px) !important;
    border-radius:22px 22px 0 0 !important;
    border-top:1px solid rgba(255,255,255,.08) !important;
    box-shadow:0 -18px 40px rgba(0,0,0,.22) !important;
  }

  body.theme-light .input-shell {
    border-top-color:#e4e4e0 !important;
    box-shadow:0 -18px 40px rgba(0,0,0,.08) !important;
  }

  .input-row {
    display:grid !important;
    grid-template-columns:52px minmax(0, 1fr) 52px 64px !important;
    gap:8px !important;
    align-items:center !important;
  }

  .tool-btn,
  #sendBtn,
  #sendDmBtn,
  #messageInput,
  #dmInput {
    height:56px !important;
    min-height:56px !important;
    border-radius:999px !important;
  }

  .tool-btn,
  #sendDmBtn {
    width:56px !important;
    min-width:56px !important;
    padding:0 !important;
  }

  #sendBtn {
    min-width:64px !important;
    padding:0 10px !important;
    font-size:14px !important;
    font-weight:900 !important;
  }

  #messageInput,
  #dmInput {
    min-width:0 !important;
    padding:0 16px !important;
    font-size:16px !important;
  }

  .bottom-row {
    display:flex !important;
    flex-wrap:nowrap !important;
    gap:14px !important;
    overflow-x:auto !important;
    white-space:nowrap !important;
    padding:9px 2px 0 !important;
    scrollbar-width:none !important;
  }

  .bottom-row::-webkit-scrollbar {
    display:none !important;
  }

  .set-name,
  .account-state {
    flex:0 0 auto !important;
    font-size:13px !important;
    line-height:1 !important;
  }

  .chat-attach-menu,
  .dm-attach-menu {
    left:12px !important;
    right:12px !important;
    bottom:calc(env(safe-area-inset-bottom) + 82px) !important;
    width:auto !important;
    flex-direction:row !important;
    justify-content:flex-start !important;
    gap:8px !important;
    padding:8px !important;
    border-radius:999px !important;
    background:#101216 !important;
    border:1px solid rgba(255,255,255,.08) !important;
  }

  body.theme-light .chat-attach-menu,
  body.theme-light .dm-attach-menu {
    background:#fff !important;
    border-color:#ddddda !important;
  }

  .chat-attach-menu .dm-attach-item,
  .dm-attach-menu .dm-attach-item {
    width:auto !important;
    min-width:72px !important;
    height:48px !important;
    padding:0 14px !important;
    border-radius:999px !important;
    font-size:14px !important;
  }

  .modal {
    align-items:stretch !important;
    justify-content:flex-start !important;
    padding:0 !important;
  }

  .modal-card:not(.gif-picker-card),
  .dm-card,
  .people-card,
  .settings-card,
  .auth-card,
  .profile-card,
  #roomControlsModal .modal-card {
    width:100vw !important;
    max-width:none !important;
    height:100dvh !important;
    max-height:100dvh !important;
    border:none !important;
    border-radius:0 !important;
    overflow-y:auto !important;
    padding:calc(env(safe-area-inset-top) + 14px) 14px calc(env(safe-area-inset-bottom) + 16px) !important;
  }

  .close-btn {
    min-width:44px !important;
    min-height:44px !important;
  }

  .people-tabs {
    overflow-x:auto !important;
    flex-wrap:nowrap !important;
    scrollbar-width:none !important;
  }

  .people-tabs::-webkit-scrollbar {
    display:none !important;
  }

  .people-tab {
    flex:0 0 auto !important;
  }
}

@media (max-width: 380px) {
  .input-row {
    grid-template-columns:48px minmax(0, 1fr) 48px 58px !important;
  }

  .tool-btn,
  #sendDmBtn {
    width:48px !important;
    min-width:48px !important;
  }

  #sendBtn {
    min-width:58px !important;
  }

  .gif-picker-grid {
    grid-template-columns:repeat(2, minmax(0, 1fr)) !important;
    gap:10px !important;
    padding-left:10px !important;
    padding-right:10px !important;
  }
}

/* V19 room controls: public description card, private mod tools. */
.room-controls-card .room-controls-overview:not(.hidden),
#roomControlsOverview:not(.hidden) {
  display:flex !important;
  flex-direction:column !important;
  gap:10px !important;
  white-space:normal !important;
  padding:18px !important;
}

.room-overview-title {
  font-size:28px !important;
  line-height:1 !important;
  font-weight:900 !important;
  letter-spacing:-.045em !important;
}

.room-overview-label {
  margin-top:4px !important;
  color:var(--text-soft) !important;
  font-size:11px !important;
  font-weight:900 !important;
  letter-spacing:.14em !important;
  text-transform:uppercase !important;
}

.room-overview-description {
  color:var(--text) !important;
  font-size:16px !important;
  line-height:1.45 !important;
  overflow-wrap:anywhere !important;
}

.room-overview-meta,
.room-overview-status {
  color:var(--text-soft) !important;
  font-size:13px !important;
  line-height:1.35 !important;
}

.room-overview-status {
  padding-top:2px !important;
}

@media (max-width: 820px) {
  .room-overview-title {
    font-size:24px !important;
  }

  .room-overview-description {
    font-size:15px !important;
  }
}

/* V20 mobile interaction polish: replies, reactions, native emoji entry, and voice preview. */
html {
  -webkit-text-size-adjust:100%;
}

body {
  overscroll-behavior-y:none;
}

input,
textarea,
select {
  font-size:16px;
}

.reply-bar {
  align-items:center !important;
  gap:10px !important;
  padding:10px 12px !important;
  border-radius:18px !important;
  background:linear-gradient(180deg, rgba(57,229,141,.16), rgba(57,229,141,.08)) !important;
  border:1px solid rgba(57,229,141,.34) !important;
  box-shadow:0 10px 28px rgba(0,0,0,.12) !important;
}

body.theme-light .reply-bar {
  background:linear-gradient(180deg, rgba(15,148,85,.12), rgba(15,148,85,.06)) !important;
  border-color:rgba(15,148,85,.22) !important;
}

.reply-label {
  display:flex !important;
  min-width:0 !important;
  flex:1 1 auto !important;
  flex-direction:column !important;
  gap:2px !important;
  line-height:1.2 !important;
}

.reply-label-kicker {
  color:var(--text-soft) !important;
  font-size:11px !important;
  font-weight:900 !important;
  letter-spacing:.12em !important;
  text-transform:uppercase !important;
}

.reply-label-preview {
  color:var(--text) !important;
  font-size:14px !important;
  font-weight:750 !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
  white-space:nowrap !important;
}

.reply-cancel-btn {
  width:36px !important;
  height:36px !important;
  display:grid !important;
  place-items:center !important;
  border-radius:999px !important;
  background:rgba(255,255,255,.08) !important;
  color:var(--text) !important;
}

body.theme-light .reply-cancel-btn {
  background:rgba(0,0,0,.05) !important;
}

.message:not(.from-me) .message-body {
  display:flex !important;
  flex-direction:column !important;
  align-items:flex-start !important;
}

.message-body > .meta {
  width:100% !important;
}

.message-body > .reaction-strip {
  margin:6px 0 0 4px !important;
  max-width:min(72vw, 540px) !important;
  display:flex !important;
  flex-wrap:wrap !important;
  gap:6px !important;
}

.message.from-me .message-body > .reaction-strip {
  align-self:flex-end !important;
  justify-content:flex-end !important;
  margin:6px 4px 0 0 !important;
  max-width:min(72vw, 540px) !important;
}

.reaction-chip {
  min-height:26px !important;
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:4px !important;
  padding:4px 9px !important;
  border-radius:999px !important;
  background:rgba(255,255,255,.10) !important;
  border:1px solid rgba(255,255,255,.10) !important;
  box-shadow:0 8px 18px rgba(0,0,0,.12) !important;
  font-size:13px !important;
  line-height:1 !important;
}

body.theme-light .reaction-chip {
  background:rgba(0,0,0,.045) !important;
  border-color:rgba(0,0,0,.075) !important;
  box-shadow:none !important;
}

.message-reaction-row.hidden,
.reaction-custom-panel.hidden {
  display:none !important;
}

.message-action-panel {
  border-radius:30px !important;
}

.message-reaction-label {
  padding:12px 14px 0 !important;
  color:var(--text-soft) !important;
  font-size:11px !important;
  font-weight:900 !important;
  letter-spacing:.14em !important;
  text-transform:uppercase !important;
}

.message-reaction-label.hidden {
  display:none !important;
}

.message-reaction-row {
  display:grid !important;
  grid-template-columns:repeat(6, minmax(0, 1fr)) !important;
  gap:8px !important;
  padding:12px !important;
}

.reaction-btn {
  width:100% !important;
  min-width:0 !important;
  height:52px !important;
  border-radius:18px !important;
  background:rgba(255,255,255,.09) !important;
  transform:translateZ(0) !important;
  touch-action:manipulation !important;
}

.reaction-btn:active {
  transform:scale(.96) !important;
}

body.theme-light .reaction-btn {
  background:rgba(0,0,0,.055) !important;
}

.reaction-more-btn {
  font-weight:900 !important;
}

.reaction-custom-panel {
  padding:0 12px 12px !important;
  border-bottom:1px solid rgba(255,255,255,.06) !important;
}

body.theme-light .reaction-custom-panel {
  border-bottom-color:rgba(0,0,0,.06) !important;
}

.reaction-custom-label {
  display:block !important;
  margin:2px 2px 8px !important;
  color:var(--text-soft) !important;
  font-size:11px !important;
  font-weight:900 !important;
  letter-spacing:.14em !important;
  text-transform:uppercase !important;
}

.reaction-custom-row {
  display:grid !important;
  grid-template-columns:minmax(0, 1fr) 90px !important;
  gap:8px !important;
}

#customReactionInput {
  width:100% !important;
  min-width:0 !important;
  min-height:52px !important;
  border:none !important;
  outline:none !important;
  border-radius:18px !important;
  padding:0 14px !important;
  background:rgba(255,255,255,.08) !important;
  color:var(--text) !important;
  font-size:18px !important;
}

body.theme-light #customReactionInput {
  background:rgba(0,0,0,.055) !important;
}

.reaction-custom-send {
  border:none !important;
  border-radius:18px !important;
  background:#39e58d !important;
  color:#041008 !important;
  font-weight:900 !important;
  cursor:pointer !important;
}

.reaction-custom-hint {
  margin:8px 2px 0 !important;
  color:var(--text-soft) !important;
  font-size:12px !important;
  line-height:1.3 !important;
}

.voice-preview-card {
  max-width:min(92vw, 520px) !important;
  padding:26px 22px 20px !important;
  border-radius:32px !important;
  background:linear-gradient(180deg, color-mix(in srgb, var(--panel-raised) 90%, #ffffff), var(--panel)) !important;
  box-shadow:0 28px 80px rgba(0,0,0,.32) !important;
}

body.theme-dark .voice-preview-card {
  background:linear-gradient(180deg, #181c23, #0d0f14) !important;
}

.voice-preview-card .settings-title,
.voice-preview-card .mini-status {
  text-align:center !important;
}

.voice-preview-meter {
  height:52px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:6px !important;
  margin:18px auto 4px !important;
}

.voice-preview-meter span {
  width:7px !important;
  height:18px !important;
  border-radius:999px !important;
  background:linear-gradient(180deg, #39e58d, #7aa2ff) !important;
  opacity:.9 !important;
  animation:voiceMeterPulse 1.25s ease-in-out infinite;
}

.voice-preview-meter span:nth-child(2) { height:34px !important; animation-delay:.08s; }
.voice-preview-meter span:nth-child(3) { height:24px !important; animation-delay:.16s; }
.voice-preview-meter span:nth-child(4) { height:42px !important; animation-delay:.24s; }
.voice-preview-meter span:nth-child(5) { height:28px !important; animation-delay:.32s; }
.voice-preview-meter span:nth-child(6) { height:20px !important; animation-delay:.40s; }

@keyframes voiceMeterPulse {
  0%, 100% { transform:scaleY(.72); opacity:.55; }
  50% { transform:scaleY(1); opacity:1; }
}

.voice-preview-player {
  grid-template-columns:58px minmax(0, 1fr) auto !important;
  gap:12px !important;
  align-items:center !important;
  padding:14px !important;
  margin:10px 0 16px !important;
  border-radius:24px !important;
  background:rgba(255,255,255,.07) !important;
  border:1px solid rgba(255,255,255,.08) !important;
}

body.theme-light .voice-preview-player {
  background:rgba(0,0,0,.045) !important;
  border-color:rgba(0,0,0,.07) !important;
}

.voice-play-btn,
.voice-pill-play {
  background:#39e58d !important;
  color:#041008 !important;
  font-weight:900 !important;
}

.voice-seek,
.voice-pill-seek {
  accent-color:#39e58d !important;
  min-width:0 !important;
}

.voice-duration,
.voice-pill-time {
  font-variant-numeric:tabular-nums !important;
  color:var(--text-soft) !important;
  white-space:nowrap !important;
}

.voice-pill {
  grid-template-columns:42px minmax(86px, 1fr) auto !important;
  max-width:100% !important;
  min-width:min(250px, 100%) !important;
  border-radius:22px !important;
  padding:9px 10px !important;
}

@media (max-width: 820px) {
  .modal,
  .chat,
  .dm-chat,
  .gif-picker-grid,
  .people-body,
  #roomControlsModal .modal-card {
    -webkit-overflow-scrolling:touch !important;
  }

  .message-action-panel {
    left:8px !important;
    right:8px !important;
    bottom:calc(env(safe-area-inset-bottom) + 8px) !important;
    width:auto !important;
    max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px) !important;
    transform:none !important;
    border-radius:28px !important;
  }

  .message-action-preview {
    padding:13px 14px !important;
    font-size:13px !important;
  }

  .message-action-btn {
    min-height:54px !important;
    padding:14px 16px !important;
    font-size:16px !important;
  }

  .reaction-btn {
    height:50px !important;
    border-radius:16px !important;
    font-size:23px !important;
  }

  .reaction-custom-row {
    grid-template-columns:minmax(0, 1fr) 82px !important;
  }

  #customReactionInput {
    min-height:50px !important;
    font-size:18px !important;
  }

  .reply-bar {
    margin-bottom:9px !important;
    border-radius:20px !important;
  }

  .reply-label-preview {
    max-width:calc(100vw - 102px) !important;
  }

  .message-body > .reaction-strip,
  .message.from-me .message-body > .reaction-strip {
    max-width:min(74vw, 520px) !important;
  }

  #voicePreviewModal {
    align-items:flex-end !important;
    justify-content:flex-end !important;
    padding:0 !important;
  }

  #voicePreviewModal .voice-preview-card {
    width:100vw !important;
    max-width:none !important;
    height:auto !important;
    min-height:0 !important;
    max-height:calc(100dvh - 12px) !important;
    border:none !important;
    border-radius:30px 30px 0 0 !important;
    padding:calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 18px) !important;
    overflow-y:auto !important;
  }

  .voice-preview-player {
    grid-template-columns:56px minmax(0, 1fr) auto !important;
    padding:12px !important;
  }

  .voice-duration {
    min-width:64px !important;
    font-size:13px !important;
  }

  .voice-pill {
    min-width:min(230px, 100%) !important;
    grid-template-columns:40px minmax(74px, 1fr) auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .voice-preview-meter span {
    animation:none !important;
  }
}


/* V19 centered custom message background fix */
.message-bubble.has-bg,
.dm-bubble.has-bg,
.settings-preview.has-bg {
  background-color: transparent !important;
  background-image: var(--msg-bg-url) !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-origin: border-box !important;
  background-clip: border-box !important;
}

.message-bubble.has-bg::before,
.message-bubble.has-bg::after,
.dm-bubble.has-bg::before,
.dm-bubble.has-bg::after,
.settings-preview.has-bg::before,
.settings-preview.has-bg::after {
  content: none !important;
  display: none !important;
  background: none !important;
  opacity: 0 !important;
}


/* ===== April 11 mobile + message background hotfix ===== */
html, body {
  overscroll-behavior: none;
}

@supports (-webkit-touch-callout:none) {
  input, textarea, select {
    font-size: 16px !important;
  }
}

.input-shell {
  padding-top: 14px !important;
}

.input-row {
  margin-bottom: 14px !important;
}

.bottom-row {
  margin-top: 0 !important;
  padding-top: 14px !important;
  border-top: 1px solid rgba(255,255,255,.08) !important;
  gap: 16px !important;
}

body.theme-light .bottom-row {
  border-top-color: rgba(0,0,0,.08) !important;
}

#messageInput,
#dmInput {
  -webkit-appearance: none !important;
  appearance: none !important;
}

.message-bubble.has-bg,
.dm-bubble.has-bg,
.settings-preview.has-bg {
  background-color: transparent !important;
  background-image: var(--msg-bg-url) !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
}

.message-bubble.has-bg::before,
.message-bubble.has-bg::after,
.dm-bubble.has-bg::before,
.dm-bubble.has-bg::after,
.settings-preview.has-bg::before,
.settings-preview.has-bg::after {
  content: none !important;
  display: none !important;
  background: none !important;
  opacity: 0 !important;
}

.message-bubble.has-bg .text,
.message-bubble.has-bg .username,
.message-bubble.has-bg .reply-snippet,
.message-bubble.has-bg .reply-snippet-name,
.message-bubble.has-bg .reply-snippet-user,
.message-bubble.has-bg .reply-snippet-preview,
.message-bubble.has-bg .reply-snippet-text,
.dm-bubble.has-bg .text,
.dm-bubble.has-bg .dm-msg-meta,
.settings-preview.has-bg .settings-preview-name,
.settings-preview.has-bg .settings-preview-text,
.message.from-me .message-bubble .text,
.dm-message.from-me .dm-bubble .text {
  color: var(--bubble-text-color, inherit) !important;
}

.message-bubble.has-bg .text,
.message-bubble.has-bg .username,
.message-bubble.has-bg .reply-snippet,
.message-bubble.has-bg .reply-snippet-name,
.message-bubble.has-bg .reply-snippet-user,
.message-bubble.has-bg .reply-snippet-preview,
.message-bubble.has-bg .reply-snippet-text,
.dm-bubble.has-bg .text,
.dm-bubble.has-bg .dm-msg-meta,
.settings-preview.has-bg .settings-preview-name,
.settings-preview.has-bg .settings-preview-text {
  text-shadow: 0 1px 6px rgba(0,0,0,.45) !important;
}

.message-bubble.has-bg .reply-snippet,
.dm-bubble.has-bg .reply-snippet {
  background: rgba(0,0,0,.18) !important;
  border-color: rgba(255,255,255,.18) !important;
}

body.theme-dark .message.from-me .message-bubble:not(.has-bg),
body.theme-light .message.from-me .message-bubble:not(.has-bg),
body.theme-dark .dm-message.from-me .dm-bubble:not(.has-bg),
body.theme-light .dm-message.from-me .dm-bubble:not(.has-bg) {
  background: #39e58d !important;
  color: #041008 !important;
}

body.theme-dark .message.from-me .message-bubble:not(.has-bg) .text,
body.theme-light .message.from-me .message-bubble:not(.has-bg) .text,
body.theme-dark .dm-message.from-me .dm-bubble:not(.has-bg) .text,
body.theme-light .dm-message.from-me .dm-bubble:not(.has-bg) .text {
  color: var(--bubble-text-color, #041008) !important;
}


/* april 11 mobile + custom bubble text hotfix */
html, body {
  overscroll-behavior: none !important;
}

body.keyboard-open .bottom-row {
  display: none !important;
}

body.keyboard-open .input-shell {
  padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
}

body.keyboard-open .input-row {
  margin-bottom: 0 !important;
}

@media (max-width: 900px) {
  .input-shell {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    padding-top: 12px !important;
  }

  .input-row {
    margin-bottom: 0 !important;
  }

  .bottom-row {
    margin-top: 0 !important;
    padding-top: 12px !important;
    border-top: 1px solid rgba(255,255,255,.10) !important;
    row-gap: 10px !important;
  }

  body.theme-light .bottom-row {
    border-top-color: rgba(0,0,0,.10) !important;
  }
}

.message-bubble.has-bg,
.dm-bubble.has-bg,
.settings-preview.has-bg {
  color: var(--bubble-text-color, #ffffff) !important;
}

.message-bubble.has-bg .text,
.message-bubble.has-bg .reply-snippet,
.message-bubble.has-bg .reply-snippet-name,
.message-bubble.has-bg .reply-snippet-user,
.message-bubble.has-bg .reply-snippet-preview,
.message-bubble.has-bg .reply-snippet-text,
.dm-bubble.has-bg .text,
.dm-bubble.has-bg .reply-snippet,
.dm-bubble.has-bg .reply-snippet-name,
.dm-bubble.has-bg .reply-snippet-user,
.dm-bubble.has-bg .reply-snippet-preview,
.dm-bubble.has-bg .reply-snippet-text,
.settings-preview.has-bg .settings-preview-text {
  color: var(--bubble-text-color, #ffffff) !important;
}

.message-bubble.has-bg .reply-snippet,
.dm-bubble.has-bg .reply-snippet {
  background: transparent !important;
}

#messageInput,
#dmInput {
  autocomplete: off;
  -webkit-text-size-adjust: 100%;
}

@media (max-width: 700px) {
  .settings-push-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .push-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .push-actions .small-action-btn {
    width: 100%;
    min-height: 44px;
  }
}

.auth-secondary-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 10px;
}

.link-action-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 0;
  cursor: pointer;
}

.link-action-btn:hover {
  text-decoration: underline;
}

.link-action-btn:disabled {
  cursor: default;
  opacity: .55;
  text-decoration: none;
}

.reset-page {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 34%),
    linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 88%, #000));
}

.reset-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(22px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.reset-card {
  width: min(100%, 480px);
}

.reset-brand {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.reset-actions .reset-login-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
