* {
  box-sizing: border-box;
}

:root {
  --bg: #36393f;
  --sidebar: #2f3136;
  --sidebar-dark: #292b2f;
  --input: #40444b;
  --hover: #34373c;
  --selected: #3a3d43;
  --border: #202225;
  --text: #dcddde;
  --bright: #ffffff;
  --muted: #b9bbbe;
  --faint: #72767d;
  --accent: #5865f2;
  --danger: #ed4245;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Helvetica Neue", sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* AUTH */

.auth-page {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #36393f;
}

.auth-box {
  width: 360px;
  padding: 24px;
  background: #2f3136;
  border: 1px solid #26282c;
  border-radius: 4px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, .25);
}

.auth-home-box {
  padding-top: 28px;
  padding-bottom: 28px;
}

.loading-box {
  text-align: center;
}

.loading-box h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.loading-box p {
  margin: 0;
  color: var(--muted);
}

.auth-logo {
  margin: 0 0 6px;
  text-align: center;
  font-size: 27px;
}

.auth-subtitle {
  margin: 0 0 22px;
  text-align: center;
  color: var(--muted);
}

.auth-description {
  margin: -4px 0 20px;
  color: var(--muted);
}

.auth-box h1 {
  margin: 6px 0 8px;
  color: white;
  font-size: 22px;
}

.auth-box label {
  display: block;
  margin-top: 15px;
  color: var(--muted);
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}

.auth-box input {
  width: 100%;
  height: 38px;
  margin-top: 7px;
  padding: 0 10px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  background: #202225;
  color: var(--text);
}

.auth-box input:focus {
  border-color: #7289da;
}

.auth-box small {
  display: block;
  margin-top: 5px;
  color: var(--faint);
}

.handle-input {
  position: relative;
}

.handle-input span {
  position: absolute;
  left: 10px;
  top: 17px;
  color: var(--faint);
}

.handle-input input {
  padding-left: 25px;
}

.button {
  width: 100%;
  height: 38px;
  margin-top: 10px;
  border: none;
  border-radius: 3px;
  font-weight: bold;
}

.button.primary {
  background: var(--accent);
  color: white;
}

.button.primary:hover {
  background: #4752c4;
}

.button.secondary {
  background: #40444b;
  color: var(--text);
}

.button.secondary:hover {
  background: #474c54;
}

.back-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
}

.back-button:hover {
  color: white;
}

.form-error {
  min-height: 16px;
  margin: 10px 0 0;
  color: #f47b7e;
  font-size: 12px;
}

/* APP */

.wirebox {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
}

.sidebar-top {
  padding: 13px 10px 8px;
  border-bottom: 1px solid var(--border);
}

.wordmark {
  height: 28px;
  display: flex;
  align-items: center;
  padding-left: 2px;
  margin-bottom: 8px;
  color: white;
  font-size: 18px;
  font-weight: bold;
}

#search-form input {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  background: #202225;
  color: var(--text);
}

#search-form input:focus {
  border-color: #4f545c;
}

.search-message {
  min-height: 14px;
  padding: 5px 2px 0;
  color: #f47b7e;
  font-size: 11px;
}

.sidebar-section-title {
  padding: 10px 12px 5px;
  color: var(--faint);
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
}

.recent-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 6px;
}

.empty-recents {
  padding: 8px 6px;
  color: var(--faint);
  font-size: 12px;
}

.contact {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 7px;
  margin-bottom: 1px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.contact:hover {
  background: var(--hover);
  color: var(--text);
}

.contact.active {
  background: var(--selected);
  color: white;
}

.contact-text {
  min-width: 0;
  flex: 1;
}

.contact-text strong {
  display: block;
  overflow: hidden;
  color: inherit;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.contact-text span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.contact-close {
  width: 22px;
  height: 22px;
  flex: none;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: #96989d;
  font-size: 17px;
  line-height: 1;
}

.contact:hover .contact-close {
  display: flex;
}

.contact-close:hover {
  background: #292b2f;
  color: white;
}


/* UNREAD BADGES */

.unread-badge {
  min-width: 18px;
  height: 18px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-radius: 999px;
  background: #ed4245;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.unread-badge.hidden {
  display: none !important;
}

/* AVATARS */

.avatar {
  width: 34px;
  height: 34px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #747f8d;
  color: white;
  font-size: 13px;
  font-weight: bold;
  user-select: none;
}

/* USER BAR */

.user-bar {
  height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  padding: 6px;
  background: var(--sidebar-dark);
}

.user-info {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.user-info:hover {
  background: #32353a;
}

.user-copy {
  min-width: 0;
}

.user-copy strong {
  display: block;
  overflow: hidden;
  color: white;
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-copy span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.settings-button {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
}

.settings-button:hover {
  background: #3a3d42;
  color: white;
}

.settings-button svg {
  width: 18px;
  height: 18px;
  display: block;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* CHAT */

.chat {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

.empty-chat {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  text-align: center;
}

.empty-chat strong {
  color: var(--muted);
  font-size: 15px;
}

.empty-chat p {
  margin: 5px 0;
}

.active-chat {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-header {
  height: 49px;
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid #2b2e32;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .1);
}

.chat-profile-button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: white;
}

.chat-profile-button:hover {
  background: #3a3d42;
}

.chat-header .avatar {
  width: 30px;
  height: 30px;
}

/* MESSAGES */

.messages {
  min-height: 0;
  height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 15px 16px 6px;
}

.message {
  display: flex;
  gap: 10px;
  padding: 4px 0 8px;
}

.message .avatar {
  width: 36px;
  height: 36px;
  cursor: pointer;
}

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

.message-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 2px;
}

.message-head strong {
  color: white;
  font-size: 13px;
  cursor: pointer;
}

.message-time {
  color: var(--faint);
  font-size: 10px;
}

.message-text {
  color: var(--text);
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* COMPOSER */

.message-form {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px 16px 14px;
}

.message-form input {
  min-width: 0;
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 4px;
  outline: none;
  background: var(--input);
  color: var(--text);
}

.message-form button {
  padding: 0 15px;
  border: none;
  border-radius: 3px;
  background: #4f545c;
  color: white;
}

.message-form button:hover {
  background: #5c626b;
}

.message-form button:disabled,
.message-form input:disabled {
  opacity: .55;
  cursor: default;
}

/* PROFILE CARD */
/* Fixed positioning is intentional: JS anchors this next to the pfp clicked. */

.profile-card {
  position: fixed;
  z-index: 120;
  top: 0;
  left: 0;
  width: 280px;
  padding: 15px;
  border: 1px solid #202225;
  border-radius: 4px;
  background: #2f3136;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

.profile-card-close {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: #b9bbbe;
  font-size: 21px;
}

.profile-card-close:hover {
  color: white;
}

.profile-card-avatar {
  width: 64px;
  height: 64px;
  margin-bottom: 10px;
  font-size: 23px;
}

.profile-card-name {
  display: block;
  color: white;
  font-size: 16px;
}

.profile-card-handle {
  display: block;
  margin-top: 2px;
  color: #b9bbbe;
  font-size: 12px;
}

.profile-card-section {
  margin-top: 15px;
  padding-top: 11px;
  border-top: 1px solid #202225;
}

.profile-card-section label {
  display: block;
  margin-bottom: 5px;
  color: #8e9297;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
}

.profile-card-section p {
  margin: 0;
  color: #dcddde;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* RIGHT-CLICK MENU */

.context-menu {
  position: fixed;
  z-index: 180;
  min-width: 170px;
  padding: 5px;
  border: 1px solid #202225;
  border-radius: 4px;
  background: #18191c;
  box-shadow: 0 7px 20px rgba(0, 0, 0, .35);
}

.context-menu button {
  width: 100%;
  padding: 7px 9px;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: #dcddde;
  text-align: left;
}

.context-menu button:hover {
  background: #4752c4;
  color: white;
}

.context-menu .context-danger {
  color: #f47b7e;
}

.context-menu .context-danger:hover {
  background: #9c3436;
  color: white;
}

.context-divider {
  height: 1px;
  margin: 4px;
  background: #2f3136;
}

/* SETTINGS */

dialog {
  width: 430px;
  max-width: calc(100% - 30px);
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid #202225;
  border-radius: 4px;
  background: var(--sidebar);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, .55);
}

.settings {
  max-height: calc(100vh - 42px);
  overflow-y: auto;
  padding: 20px;
}

.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-heading h2 {
  margin: 0;
  color: white;
  font-size: 20px;
}

.settings-heading button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
}

.settings-group {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #202225;
}

.first-settings-group {
  margin-top: 16px;
}

.settings-group h3 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.settings-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.large-avatar {
  width: 44px;
  height: 44px;
}

.settings-user strong,
.settings-user span {
  display: block;
}

.settings-user strong {
  color: white;
}

.settings-user span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.settings-group p {
  color: var(--muted);
  line-height: 1.4;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
}

.settings-field {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
}

.settings-field input,
.settings-field textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px 9px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  resize: vertical;
  background: #202225;
  color: var(--text);
  text-transform: none;
}

.settings-field input {
  height: 36px;
}

.settings-field input:focus,
.settings-field textarea:focus {
  border-color: #4f545c;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-row label {
  color: #dcddde;
}

.settings-row select {
  min-width: 110px;
  padding: 7px 8px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  background: #202225;
  color: #dcddde;
}

.settings-normal-button {
  margin-top: 12px;
  padding: 8px 11px;
  border: none;
  border-radius: 3px;
  background: #4f545c;
  color: white;
}

.account-actions .settings-normal-button {
  margin-top: 0;
}

.settings-normal-button:hover {
  background: #5d6269;
}

.settings-normal-button:disabled {
  opacity: .5;
  cursor: default;
}

.settings-small-message {
  min-height: 14px;
  margin: 7px 0 0 !important;
  color: #b9bbbe !important;
  font-size: 11px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.toggle-row div {
  min-width: 0;
}

.toggle-row strong {
  display: block;
  color: #dcddde;
  font-size: 13px;
}

.toggle-row span {
  display: block;
  margin-top: 3px;
  color: #8e9297;
  font-size: 11px;
  line-height: 1.35;
}

.toggle-row input {
  width: 17px;
  height: 17px;
  flex: none;
}

/* BLOCKED LIST */

.blocked-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.blocked-person {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 5px;
  border-radius: 3px;
  background: #292b2f;
}

.blocked-person-copy {
  min-width: 0;
  flex: 1;
}

.blocked-person-copy strong,
.blocked-person-copy span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.blocked-person-copy strong {
  color: white;
  font-size: 12px;
}

.blocked-person-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.unblock-button {
  padding: 6px 8px;
  border: 1px solid #4f545c;
  border-radius: 3px;
  background: transparent;
  color: #dcddde;
}

.unblock-button:hover {
  background: #4f545c;
  color: white;
}

.muted-line {
  margin: 0 !important;
  color: var(--faint) !important;
  font-size: 12px;
}

.logout-button {
  padding: 8px 12px;
  border: 1px solid #9c3436;
  border-radius: 3px;
  background: transparent;
  color: #f47b7e;
}

.logout-button:hover {
  background: #9c3436;
  color: white;
}

.delete-account-button {
  margin-left: 8px;
  padding: 8px 12px;
  border: 1px solid #9c3436;
  border-radius: 3px;
  background: #9c3436;
  color: white;
}

.delete-account-button:hover {
  background: #b13c3f;
}

/* ACCOUNT POPUPS */

.small-dialog {
  width: 390px;
}

.account-popup {
  padding: 20px;
}

.dialog-copy {
  margin: 7px 0 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.dialog-handle-input span {
  top: 16px;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 5px;
}

.compact-button {
  width: auto;
  min-width: 100px;
  padding: 0 12px;
}

.account-popup-message {
  margin-top: 9px;
}

/* SMALL WINDOWS */

@media (max-width: 680px) {
  .wirebox {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .profile-card {
    width: 250px;
  }
}

/* =======================================
   PHASE 2 - MESSAGE CONTROLS + SEND QUEUE
======================================= */

.message-segment,
.pending-messages {
  width: 100%;
}

.message-edited {
  color: var(--faint);
  font-size: 10px;
}

.message.pending {
  opacity: .48;
}

.message.pending .message-text {
  color: #c6c8ca;
}

.pending-state {
  margin-left: 6px;
  color: #8e9297;
  font-size: 10px;
  font-weight: normal;
}

.pending-state.failed {
  color: #f47b7e;
}

.inline-message-editor {
  width: min(620px, calc(100vw - 360px));
  min-width: 240px;
}

.inline-message-editor textarea {
  width: 100%;
  min-height: 68px;
  padding: 8px 9px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  resize: vertical;
  background: #202225;
  color: var(--text);
  font: inherit;
  line-height: 1.35;
}

.inline-message-editor textarea:focus {
  border-color: #4f545c;
}

.inline-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.inline-edit-actions button {
  padding: 5px 9px;
  border: none;
  border-radius: 3px;
  background: #4f545c;
  color: white;
  font-size: 11px;
}

.inline-edit-actions button:hover {
  background: #5c626b;
}

.inline-edit-actions .edit-cancel {
  background: transparent;
  color: var(--muted);
}

.inline-edit-actions .edit-cancel:hover {
  background: #3a3d42;
  color: white;
}

.composer-status {
  flex: none;
  min-height: 18px;
  margin: -7px 18px 8px;
  color: #b9bbbe;
  font-size: 11px;
}

.composer-status.penalty {
  color: #f0b36d;
}

.context-menu button + button {
  margin-top: 1px;
}

@media (max-width: 680px) {
  .inline-message-editor {
    width: min(430px, calc(100vw - 250px));
    min-width: 180px;
  }
}

/* =======================================
   PHASE 3 — GROUPCHATS
======================================= */

.sidebar-action-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  margin-top: 6px;
}

.sidebar-icon-button {
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: #aeb1b7;
}

.sidebar-icon-button:hover {
  border-color: #202225;
  background: #40444b;
  color: white;
}

.sidebar-icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  pointer-events: none;
}

.group-list {
  max-height: 170px;
  overflow-y: auto;
  padding: 0 6px 5px;
}

.group-item {
  width: 100%;
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 7px;
  margin-bottom: 1px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.group-item:hover {
  background: var(--hover);
  color: white;
}

.group-item.active {
  background: var(--selected);
  color: white;
}

.group-item-copy {
  min-width: 0;
  flex: 1;
}

.group-item-copy strong,
.group-item-copy span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.group-item-copy strong {
  color: inherit;
  font-size: 12px;
}

.group-item-copy span {
  margin-top: 2px;
  color: var(--faint);
  font-size: 10px;
}

.group-avatar {
  width: 34px;
  height: 34px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: white;
  font-weight: bold;
  user-select: none;
}

.conversation-layout {
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
}

.conversation-main {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.group-members-panel {
  width: 210px;
  flex: none;
  overflow-y: auto;
  padding: 11px 8px;
  border-left: 1px solid #2b2e32;
  background: #303238;
}

.members-heading {
  padding: 0 5px 8px;
  color: var(--faint);
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
}

.group-member-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 5px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.group-member-row:hover {
  background: #383b41;
  color: white;
}

.group-member-copy {
  min-width: 0;
  flex: 1;
}

.group-member-copy strong,
.group-member-copy span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.group-member-copy strong {
  color: inherit;
  font-size: 12px;
}

.group-member-copy span {
  margin-top: 2px;
  color: var(--faint);
  font-size: 10px;
}

.owner-crown {
  display: inline-flex !important;
  width: 13px;
  height: 13px;
  margin-left: 5px;
  color: white;
  line-height: 1;
  vertical-align: -2px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.owner-crown svg {
  width: 13px;
  height: 13px;
  display: block;
  fill: currentColor;
}

.group-dialog {
  width: 470px;
}

.group-dialog-body {
  padding: 20px;
}

.group-dialog-section {
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid #202225;
}

.group-dialog-section h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.group-invite-picker {
  max-height: 190px;
  overflow-y: auto;
  margin-top: 9px;
  border: 1px solid #202225;
  border-radius: 3px;
  background: #292b2f;
}

.group-picker-person {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 5px 8px;
  border-bottom: 1px solid #303238;
}

.group-picker-person:last-child {
  border-bottom: none;
}

.group-picker-person label {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #dcddde;
  cursor: pointer;
}

.group-picker-person input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex: none;
}

.join-code-row {
  display: flex;
  gap: 7px;
  margin-top: 8px;
}

.join-code-row input {
  min-width: 0;
  flex: 1;
  height: 36px;
  padding: 0 9px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  background: #202225;
  color: var(--text);
}

.join-code-row .settings-normal-button {
  margin-top: 0;
}

/* Group invite cards: one compact row, no blank card area. */
.group-invite-embed {
  width: min(420px, 100%);
  min-height: 40px;
  display: grid !important;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  margin-top: 4px;
  padding: 5px 6px;
  overflow: hidden;
  border: 1px solid #282b30;
  border-radius: 3px;
  background: #2f3136;
}

.group-invite-embed .group-avatar {
  width: 30px;
  height: 30px;
  min-width: 30px;
  font-size: 12px;
}

.group-invite-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.group-invite-name,
.group-invite-meta {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.group-invite-name {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
}

.group-invite-meta {
  margin-top: 1px;
  color: #a7abb1;
  font-size: 10px;
  line-height: 12px;
}

.group-invite-join {
  height: 28px;
  min-height: 28px;
  padding: 0 10px;
  border: none;
  border-radius: 3px;
  background: #4f545c;
  color: white;
  white-space: nowrap;
}

.group-invite-join:hover:not(:disabled) {
  background: #5c626b;
}

.group-invite-join:disabled {
  opacity: .62;
  cursor: default;
}

/* Group icon color picker */
.group-color-editor {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #202225;
}

.compact-color-editor {
  margin-top: 11px;
  padding-top: 10px;
}

.group-color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.group-color-swatch {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #202225;
}

.group-color-swatch:hover {
  transform: translateY(-1px);
}

.group-color-swatch.selected {
  border-color: white;
  box-shadow: 0 0 0 1px #202225, 0 0 0 3px #4f545c;
}

@media (max-width: 820px) {
  .group-members-panel {
    width: 170px;
  }
}

.blocked-message-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #8e9297;
  font-size: 12px;
}

.blocked-message-placeholder button {
  padding: 2px 6px;
  border: 1px solid #4f545c;
  border-radius: 3px;
  background: transparent;
  color: #b9bbbe;
  font-size: 11px;
}

.blocked-message-placeholder button:hover {
  background: #4f545c;
  color: white;
}

.privacy-second-row {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid #202225;
}

.danger-confirm {
  background: #a23b3e !important;
}

.danger-confirm:hover {
  background: #b4474a !important;
}


/* PHASE 4 — verification + moderation */
.profile-card-identity {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}


.verification-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid #202225;
  border-radius: 3px;
  background: #292b2f;
}

.verification-row > div:first-child { min-width: 0; flex: 1; }
.verification-row strong, .verification-row span { display: block; }
.verification-row strong { color: #fff; font-size: 12px; }
.verification-row span { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.35; overflow-wrap: anywhere; }
.verification-actions { display: flex; gap: 6px; flex: none; }
.verification-actions .settings-normal-button { margin-top: 0; }

.moderation-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 12px;
  max-height: 360px;
  overflow-y: auto;
}

.moderation-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 5px;
  border-radius: 3px;
  background: #292b2f;
}

.moderation-row-copy { min-width: 0; flex: 1; }
.moderation-row-copy strong, .moderation-row-copy span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.moderation-row-copy strong { color: #fff; font-size: 12px; }
.moderation-row-copy span { margin-top: 2px; color: var(--muted); font-size: 10px; }

/* =======================================
   PHASE 4.3 - KLIPY GIF PICKER
======================================= */

.conversation-main {
  position: relative;
}

.composer-tool-button {
  flex: none;
  width: 42px;
  padding: 0 !important;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
}

.gif-picker {
  position: absolute;
  z-index: 90;
  left: 16px;
  bottom: 62px;
  width: min(390px, calc(100% - 32px));
  max-height: min(430px, calc(100% - 84px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #202225;
  border-radius: 4px;
  background: #2f3136;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .38);
}

.gif-picker-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid #202225;
}

.gif-picker-top input {
  min-width: 0;
  flex: 1;
  height: 34px;
  padding: 0 9px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  background: #202225;
  color: var(--text);
}

.gif-picker-top input:focus {
  border-color: #4f545c;
}

.gif-picker-top button {
  width: 32px;
  height: 32px;
  flex: none;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.gif-picker-top button:hover {
  background: #40444b;
  color: white;
}

.gif-picker-message {
  flex: none;
  padding: 13px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.gif-results {
  min-height: 170px;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 92px;
  gap: 4px;
  padding: 6px;
}

.gif-result {
  min-width: 0;
  min-height: 0;
  position: relative;
  padding: 0;
  overflow: hidden;
  border: none;
  border-radius: 3px;
  background: #202225;
}

.gif-result img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.gif-result:hover::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .7);
  pointer-events: none;
}

.gif-attribution {
  flex: none;
  padding: 5px 8px 7px;
  border-top: 1px solid #202225;
  color: #8e9297;
  font-size: 9px;
  text-align: right;
}

.message-gif {
  display: block;
  width: auto;
  max-width: min(360px, 100%);
  max-height: 320px;
  margin-top: 3px;
  border-radius: 4px;
  object-fit: contain;
  background: #202225;
}

.message.pending .message-gif {
  opacity: .62;
}

.settings-note {
  margin: 0 0 8px !important;
  color: var(--muted) !important;
  font-size: 11px;
  line-height: 1.4;
}

.settings-inline-actions {
  display: flex;
  gap: 7px;
}

.settings-inline-actions .settings-normal-button {
  margin-top: 10px;
}

.secondary-settings-button {
  background: #36393f;
}

.secondary-settings-button:hover {
  background: #40444b;
}

@media (max-width: 680px) {
  .gif-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* =======================================
   PHASE 4.3 - VERIFICATION OPT-OUT
======================================= */


.verification-copy {
  min-width: 0;
}

.verification-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
}

.verification-remove {
  width: 22px;
  height: 22px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #4f545c;
  border-radius: 3px;
  background: transparent;
  color: #b9bbbe;
  font-size: 15px;
  line-height: 1;
}

.verification-remove:hover {
  border-color: #9c3436;
  background: #9c3436;
  color: white;
}

.danger-compact {
  height: 38px;
  margin-top: 10px;
  padding: 0 12px;
  border: 1px solid #9c3436;
  border-radius: 3px;
  background: #9c3436;
  color: white;
  font-weight: bold;
}

.danger-compact:hover {
  background: #b13c3f;
}

.danger-compact:disabled {
  opacity: .55;
  cursor: default;
}

/* =======================================
   PHASE 5 — DISCOVERY / NOTIFICATIONS
======================================= */

.notification-icon-button {
  position: relative;
}

.toolbar-badge {
  position: absolute;
  top: -3px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #2f3136;
  border-radius: 8px;
  background: #d83c3e;
  color: white;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.settings-select {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  background: #202225;
  color: var(--text);
}

.settings-select:focus {
  border-color: #4f545c;
}

.feature-dialog-body {
  padding: 18px;
}

.discovery-dialog {
  width: min(760px, calc(100vw - 32px));
  max-width: 760px;
}

.discovery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: min(540px, calc(100vh - 180px));
  margin-top: 12px;
  padding-right: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.discovery-room {
  min-width: 0;
  height: 88px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #202225;
  border-radius: 4px;
  background: #292b2f;
}

.discovery-room:hover {
  background: #303238;
}

.discovery-room .group-avatar {
  width: 48px;
  height: 48px;
  font-size: 17px;
}

.discovery-room-copy {
  min-width: 0;
}

.discovery-room-copy strong,
.discovery-room-copy span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.discovery-room-copy strong {
  color: white;
  font-size: 13px;
}

.discovery-room-copy span {
  margin-top: 4px;
  color: #a7abb1;
  font-size: 10px;
}

.discovery-room-join {
  min-width: 58px;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 3px;
  background: #4f545c;
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.discovery-room-join:hover:not(:disabled) {
  background: #5c626b;
}

.discovery-room-join:disabled {
  opacity: .65;
  cursor: default;
}

.notification-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 390px;
  margin-top: 12px;
  overflow-y: auto;
}

.notification-item {
  padding: 9px 10px;
  border: 1px solid #202225;
  border-radius: 3px;
  background: #292b2f;
}

.notification-item strong,
.notification-item span {
  display: block;
}

.notification-item strong {
  color: white;
  font-size: 12px;
}

.notification-item span {
  margin-top: 4px;
  color: #a7abb1;
  font-size: 10px;
  line-height: 1.4;
}

.notification-empty,
.discovery-empty {
  padding: 18px 10px;
  color: #8e9297;
  font-size: 12px;
  text-align: center;
}

/* GIF link / copy-link affordance. */
.message-gif-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin-top: 3px;
}

.message-gif-wrap .message-gif {
  margin-top: 0;
}


.klipy-link-source {
  display: block;
  max-width: 420px;
  margin-top: 3px;
  color: #8ea1e1;
  font-size: 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (max-width: 720px) {
  .discovery-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Phase 5.0.1: KLIPY share-page resolving */
.klipy-embed-loading {
  margin-top: 6px;
  min-height: 18px;
  font-size: 12px;
  color: #9aa0a8;
}

/* ======================================================
   Phase 5.0.3 — link styling + official site embeds
   ====================================================== */

.message-text a,
.message-text .message-link,
.klipy-embed-fallback a {
  color: #00a8fc;
  text-decoration: none;
}

.message-text a:hover,
.message-text .message-link:hover,
.klipy-embed-fallback a:hover {
  text-decoration: underline;
}

.site-embed-frame,
.site-embed-image-wrap,
.site-embed-loading {
  display: block;
  margin-top: 7px;
}

.site-embed-frame {
  width: min(480px, 100%);
  border: 0;
  border-radius: 4px;
  background: #18191c;
}

.site-embed-video {
  aspect-ratio: 16 / 9;
  height: auto;
  min-height: 200px;
}

.site-embed-twitch {
  width: min(480px, 100%);
  height: 300px;
}

.site-embed-tiktok {
  width: min(325px, 100%);
  height: 578px;
}

.site-embed-spotify {
  width: min(480px, 100%);
  height: 352px;
}

.site-embed-spotify.compact {
  height: 152px;
}

.site-embed-soundcloud {
  width: min(480px, 100%);
  height: 166px;
}

.site-embed-image-wrap {
  max-width: 420px;
}

.site-embed-image {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 4px;
  object-fit: contain;
}

.site-embed-loading {
  color: #9aa0a8;
  font-size: 12px;
}

@media (max-width: 520px) {
  .site-embed-video,
  .site-embed-twitch {
    min-height: 200px;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .site-embed-tiktok {
    height: 520px;
  }
}

/* Phase 5.1 */
.discovery-search {
  width: 100%;
  height: 34px;
  margin: 2px 0 10px;
  padding: 0 10px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  background: #202225;
  color: var(--text);
}
.discovery-search:focus { border-color: #4f545c; }
.compact-toggle-row { margin: 8px 0 12px; }
.member-timeout-label { color: #f0b36b !important; font-size: 10px !important; }
.notification-alert-item {
  position: relative;
  width: 100%;
  text-align: left;
  border: 0;
  color: inherit;
  cursor: pointer;
}
.notification-alert-item:hover { background: #393c42; }
.notification-dismiss {
  position: absolute;
  right: 8px;
  top: 7px;
  display: none;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  color: var(--muted);
  font-size: 18px;
  line-height: 20px;
}
.notification-alert-item:hover .notification-dismiss { display: flex; }
.notification-dismiss:hover { background: #202225; color: white; }

/* PHASE 5.2 — unread boundary */
.unread-divider {
  position: relative;
  display: flex;
  align-items: center;
  height: 18px;
  margin: 3px 0 5px;
  color: #f23f42;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.unread-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: #f23f42;
}

.unread-divider span {
  position: relative;
  margin-left: auto;
  padding-left: 7px;
  background: #313338;
}


/* Attachment hover controls + fullscreen viewer */
.attachment-hover-actions {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .08s linear;
  z-index: 2;
}

.message-gif-wrap:hover .attachment-hover-actions,
.attachment-hover-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
}

.attachment-hover-action {
  height: 24px;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 3px;
  background: rgba(32, 34, 37, .92);
  color: white;
  font: inherit;
  font-size: 9px;
  cursor: pointer;
  white-space: nowrap;
}

.attachment-hover-action:hover,
.attachment-hover-action:focus-visible,
.attachment-viewer-action:hover,
.attachment-viewer-action:focus-visible,
.attachment-viewer-close:hover,
.attachment-viewer-close:focus-visible {
  background: rgba(54, 57, 63, .98);
  outline: none;
}

.message-gif-wrap .message-gif {
  cursor: zoom-in;
}

body.attachment-viewer-open {
  overflow: hidden;
}

.attachment-viewer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
}

.attachment-viewer.hidden {
  display: none !important;
}

.attachment-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .86);
}

.attachment-viewer-shell {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.attachment-viewer-toolbar {
  flex: none;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 10px;
  pointer-events: auto;
}

.attachment-viewer-action,
.attachment-viewer-close {
  height: 30px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 3px;
  background: rgba(32, 34, 37, .9);
  color: #fff;
  cursor: pointer;
}

.attachment-viewer-action {
  padding: 0 10px;
  font-size: 11px;
}

.attachment-viewer-close {
  width: 32px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.attachment-viewer-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px 22px 22px;
  pointer-events: none;
}

.attachment-viewer-image {
  display: block;
  max-width: min(96vw, 1600px);
  max-height: calc(100vh - 82px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  background: #111;
  box-shadow: 0 8px 34px rgba(0, 0, 0, .45);
  pointer-events: auto;
}

@media (max-width: 600px) {
  .attachment-hover-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .attachment-hover-action {
    font-size: 8px;
    padding: 0 5px;
  }

  .attachment-viewer-stage {
    padding: 4px 8px 12px;
  }

  .attachment-viewer-image {
    max-width: 98vw;
    max-height: calc(100vh - 70px);
  }
}


/* ======================================================
   PHASE 6.0 — GROUP VOICE CALLS
   ====================================================== */
.group-call-button{margin-left:auto;height:30px;padding:0 9px;border:0;border-radius:3px;background:#3a3d42;color:#dbdee1;display:flex;gap:6px;align-items:center;font:inherit;font-size:11px;cursor:pointer}.group-call-button.hidden{display:none}.group-call-button:hover{background:#45494f;color:#fff}.group-call-button.in-call{background:#248046;color:#fff}.group-call-button svg{width:15px;height:15px}.call-panel{flex:none;border-bottom:1px solid #202225;background:#292b2f;padding:9px 12px 11px;max-height:245px;overflow:auto}.call-panel.hidden{display:none}.call-panel-top{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}.call-panel-top>div{min-width:0;display:flex;align-items:baseline;gap:8px}.call-panel-top strong{font-size:12px;color:#f2f3f5}.call-panel-top span{font-size:10px;color:#949ba4}.call-panel-join{height:28px;padding:0 10px;border:0;border-radius:3px;background:#248046;color:white;font:inherit;font-size:10px;font-weight:700;cursor:pointer}.call-panel-join:hover{background:#1f6f3d}.call-panel-join.leave{background:#da373c}.call-panel-join.leave:hover{background:#b92f34}.call-participants{display:flex;flex-wrap:wrap;gap:13px;align-items:flex-start}.call-participant{width:76px;display:flex;flex-direction:column;align-items:center;gap:5px;position:relative;user-select:none}.call-participant-avatar-wrap{width:62px;height:62px;border-radius:50%;padding:3px;border:3px solid transparent;transition:border-color .08s linear,box-shadow .08s linear;position:relative}.call-participant.speaking .call-participant-avatar-wrap{border-color:#23a55a;box-shadow:0 0 0 2px rgba(35,165,90,.18)}.call-participant-avatar{width:100%;height:100%;border-radius:50%;display:grid;place-items:center;font-size:20px;font-weight:700;color:#fff}.call-participant-name{max-width:76px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#dbdee1;font-size:10px;text-align:center}.call-participant-muted{position:absolute;right:-2px;bottom:-2px;width:20px;height:20px;border-radius:50%;background:#da373c;border:3px solid #292b2f;color:#fff;display:grid;place-items:center;font-size:10px}.call-participant-muted.hidden{display:none}.call-participant-self .call-participant-name::after{content:' (you)';color:#949ba4}.context-volume-row{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:7px;padding:7px 9px;color:#b5bac1;font-size:10px}.context-volume-row.hidden{display:none}.context-volume-row input{width:96px;accent-color:#5865f2}.context-volume-row span:last-child{width:30px;text-align:right;color:#949ba4}.group-member-context-menu{min-width:180px}.call-remote-audio{display:none}


/* Phase 6.1 — persistent DM/group calls */
.call-panel {
  flex: none;
  border-bottom: 1px solid #202225;
  background: #292b2f;
  padding: 9px 12px 11px;
  max-height: 360px;
  overflow: auto;
}

.call-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.call-panel-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.call-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.call-live-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.call-live-controls.hidden,
.call-panel-join.hidden,
.call-screen-shares.hidden {
  display: none !important;
}

.call-control-button {
  width: 31px;
  height: 29px;
  border: 0;
  border-radius: 3px;
  background: #3a3d42;
  color: #dbdee1;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 6px;
}

.call-control-button:hover {
  background: #45494f;
  color: #fff;
}

.call-control-button.active {
  background: #5865f2;
  color: #fff;
}

.call-control-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.call-control-leave {
  background: #da373c;
  color: #fff;
}

.call-control-leave:hover {
  background: #b92f34;
}

.call-control-leave svg {
  fill: currentColor;
  stroke: none;
}

.call-screen-shares {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 7px;
  margin: 2px 0 10px;
}

.call-screen-share-card {
  min-width: 0;
  border: 1px solid #202225;
  background: #1e1f22;
  border-radius: 4px;
  overflow: hidden;
}

.call-screen-share-label {
  height: 25px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: #b5bac1;
  font-size: 10px;
  border-bottom: 1px solid #202225;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-screen-share-video {
  display: block;
  width: 100%;
  max-height: 220px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #111214;
}

.call-participant-sharing {
  position: absolute;
  left: -2px;
  bottom: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #5865f2;
  border: 3px solid #292b2f;
  color: #fff;
  display: grid;
  place-items: center;
}

.call-participant-sharing.hidden {
  display: none;
}

.call-participant-sharing svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.microphone-volume-field input[type="range"] {
  width: 100%;
}

.microphone-volume-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.microphone-volume-heading strong {
  color: #949ba4;
  font-size: 10px;
  font-weight: 600;
}

#microphone-device-select {
  width: 100%;
  min-height: 34px;
  border: 1px solid #202225;
  border-radius: 3px;
  background: #1e1f22;
  color: #dbdee1;
  padding: 0 8px;
}

@media (max-width: 700px) {
  .call-panel-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .call-panel-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .call-screen-shares {
    grid-template-columns: 1fr;
  }
}


/* Phase 7 uploads */
.composer-upload-button {
  display: grid;
  place-items: center;
  padding: 0 7px;
}
.composer-upload-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.composer-media-tip {
  flex: none;
  padding: 2px 12px 5px;
  color: #858b94;
  font-size: 9px;
  background: #36393f;
}
.upload-quota-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0 5px;
  font-size: 11px;
  color: #b5bac1;
}
.upload-quota-track {
  height: 7px;
  overflow: hidden;
  border-radius: 3px;
  background: #1e1f22;
  margin-bottom: 9px;
}
.upload-quota-track span {
  display: block;
  width: 0;
  height: 100%;
  background: #5865f2;
  transition: width .15s linear;
}
.message-video-wrap,
.message-audio-wrap {
  margin-top: 4px;
  max-width: 560px;
}
.message-video {
  display: block;
  width: min(100%, 560px);
  max-height: 420px;
  background: #111214;
  border-radius: 4px;
}
.attachment-media-meta,
.attachment-audio-title {
  margin-top: 4px;
  color: #949ba4;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-audio-wrap {
  width: min(100%, 430px);
  padding: 7px 9px;
  background: #2b2d31;
  border: 1px solid #202225;
  border-radius: 4px;
}
.message-audio {
  width: 100%;
  height: 34px;
  margin-top: 5px;
}
.message-file-card {
  min-height: 44px;
  max-width: 500px;
  margin-top: 4px;
  padding: 5px 6px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  background: #2b2d31;
  border: 1px solid #202225;
  border-radius: 4px;
}
.message-file-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: #1e1f22;
  color: #b5bac1;
  font-size: 8px;
  font-weight: 700;
  border-radius: 3px;
}
.message-file-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.message-file-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #dbdee1;
  font-size: 11px;
}
.message-file-copy span {
  color: #949ba4;
  font-size: 9px;
}
.message-file-actions {
  display: flex;
  gap: 4px;
}
.message-file-actions button {
  height: 25px;
  border: 0;
  border-radius: 3px;
  padding: 0 7px;
  background: #3a3d42;
  color: #dbdee1;
  font-size: 9px;
  cursor: pointer;
}
.message-file-actions button:hover {
  background: #45494f;
  color: #fff;
}

.message-input.upload-ready,
#message-input.upload-ready {
  color: #b5bac1;
  font-style: italic;
}
.attachment-expired {
  display: inline-block;
  margin-top: 4px;
  color: #f0f0f0;
  font-weight: 700;
}


/* ======================================================
   PHASE 7.2 — MOBILE WEB
   ====================================================== */

.mobile-chat-back,
.mobile-members-button,
.mobile-members-close,
.mobile-members-backdrop {
  display: none;
}

@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overscroll-behavior: none;
  }

  body {
    min-height: 100dvh;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
  }

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

  .wirebox {
    position: relative;
    display: block;
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--sidebar);
  }

  /* Conversation list is the mobile home screen. */
  .sidebar {
    position: absolute;
    inset: env(safe-area-inset-top, 0px) 0 0;
    width: 100%;
    height: calc(100dvh - env(safe-area-inset-top, 0px));
    min-width: 0;
    display: flex;
    z-index: 10;
  }

  .wirebox.mobile-chat-open .sidebar {
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-18px);
  }

  .sidebar-top {
    padding: 11px 12px 8px;
  }

  .wordmark {
    height: 31px;
    margin-bottom: 7px;
    font-size: 20px;
  }

  #search-form input {
    height: 38px;
    font-size: 16px;
  }

  .sidebar-action-bar {
    gap: 4px;
    margin-top: 4px;
  }

  .sidebar-icon-button {
    width: 42px;
    height: 38px;
  }

  .sidebar-icon-button svg {
    width: 19px;
    height: 19px;
  }

  .sidebar-section-title {
    padding: 10px 14px 5px;
    font-size: 11px;
  }

  .group-list,
  .recent-list {
    padding-inline: 7px;
  }

  .group-item,
  .recent-item {
    min-height: 52px;
    padding-block: 5px;
    border-radius: 4px;
  }

  .group-avatar,
  .recent-item .avatar {
    width: 40px;
    height: 40px;
  }

  .group-item-copy strong,
  .recent-copy strong {
    font-size: 14px;
  }

  .group-item-copy span,
  .recent-copy span {
    font-size: 11px;
  }

  .user-bar {
    min-height: 58px;
    padding: 7px 9px calc(7px + env(safe-area-inset-bottom, 0px));
  }

  .user-info {
    min-width: 0;
  }

  .user-info .avatar {
    width: 38px;
    height: 38px;
  }

  .settings-button {
    width: 42px;
    height: 42px;
  }

  /* Chat becomes a separate full-screen view. */
  .chat {
    position: absolute;
    inset: env(safe-area-inset-top, 0px) 0 0;
    width: 100%;
    height: calc(100dvh - env(safe-area-inset-top, 0px));
    min-width: 0;
    display: none;
    z-index: 20;
    background: var(--bg);
  }

  .wirebox.mobile-chat-open .chat {
    display: flex;
    flex-direction: column;
  }

  .empty-chat {
    display: none !important;
  }

  .active-chat {
    width: 100%;
    height: 100%;
  }

  .chat-header {
    height: 52px;
    min-height: 52px;
    padding: 0 7px;
    gap: 3px;
    background: #36393f;
  }

  .mobile-chat-back,
  .mobile-members-button {
    flex: none;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: #b5bac1;
    padding: 8px;
  }

  .mobile-chat-back {
    display: grid;
    place-items: center;
  }

  .mobile-members-button:not(.hidden) {
    display: grid;
    place-items: center;
    margin-left: auto;
  }

  .mobile-chat-back:active,
  .mobile-members-button:active {
    background: #40444b;
    color: #fff;
  }

  .mobile-chat-back svg,
  .mobile-members-button svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-members-button svg {
    fill: currentColor;
    stroke: none;
  }

  .chat-profile-button {
    min-width: 0;
    flex: 1 1 auto;
    gap: 7px;
    overflow: hidden;
  }

  .chat-profile-button strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }

  .chat-header .avatar {
    width: 32px;
    height: 32px;
  }

  .group-call-button {
    flex: none;
    max-width: 112px;
    margin-left: 2px;
    padding: 0 7px;
  }

  #group-call-button-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .conversation-layout,
  .conversation-main {
    width: 100%;
    min-width: 0;
  }

  .messages {
    padding: 11px 10px 5px;
    scroll-padding-bottom: 74px;
  }

  .message {
    gap: 8px;
    padding: 3px 0 8px;
  }

  .message .avatar {
    width: 34px;
    height: 34px;
  }

  .message-head {
    gap: 5px;
  }

  .message-head strong {
    font-size: 13px;
  }

  .message-text {
    font-size: 14px;
    line-height: 1.38;
  }

  /* Fixed-feeling mobile composer that remains inside the 100dvh layout. */
  .message-form {
    flex: none;
    gap: 5px;
    padding: 7px 8px 7px;
    background: #36393f;
    border-top: 1px solid #2b2e32;
  }

  .message-form input {
    height: 42px;
    padding-inline: 10px;
    font-size: 16px;
  }

  .message-form button {
    height: 42px;
    min-width: 42px;
    padding-inline: 10px;
  }

  .composer-tool-button {
    width: 42px;
  }

  #send-button {
    min-width: 58px;
  }

  .composer-media-tip {
    padding: 3px 9px calc(5px + env(safe-area-inset-bottom, 0px));
    font-size: 9px;
    line-height: 1.3;
  }

  .composer-status {
    padding-inline: 9px;
  }

  /* GIF picker becomes a bottom sheet and owns its scrolling. */
  .gif-picker {
    position: fixed !important;
    z-index: 350;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: none;
    height: min(72dvh, 620px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 14px);
    border: 0;
    border-top: 1px solid #202225;
    border-radius: 8px 8px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -12px 36px rgba(0, 0, 0, .42);
  }

  .gif-picker::before {
    content: "";
    width: 36px;
    height: 4px;
    flex: none;
    align-self: center;
    margin-top: 7px;
    border-radius: 4px;
    background: #5b6068;
  }

  .gif-picker-top {
    padding: 7px 9px;
  }

  .gif-picker-top input {
    height: 40px;
    font-size: 16px;
  }

  .gif-results {
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 126px;
    gap: 5px;
    padding: 6px 8px 10px;
    -webkit-overflow-scrolling: touch;
  }

  /* Members become a slide-in drawer instead of stealing chat width. */
  .group-members-panel {
    position: fixed;
    z-index: 420;
    top: env(safe-area-inset-top, 0px);
    right: 0;
    bottom: 0;
    width: min(84vw, 330px) !important;
    height: calc(100dvh - env(safe-area-inset-top, 0px));
    padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px));
    border-left: 1px solid #202225;
    background: #303238;
    transform: translateX(105%);
    transition: transform .16s ease-out;
    box-shadow: -12px 0 32px rgba(0, 0, 0, .35);
  }

  .wirebox.mobile-members-open .group-members-panel:not(.hidden) {
    transform: translateX(0);
  }

  .mobile-members-backdrop {
    position: fixed;
    z-index: 410;
    inset: 0;
    border: 0;
    background: rgba(0, 0, 0, .48);
  }

  .mobile-members-backdrop:not(.hidden) {
    display: block;
  }

  .mobile-members-drawer-head {
    min-height: 48px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #202225;
    margin: 0 -8px 5px;
    padding: 0 7px 0 12px;
  }

  .mobile-members-drawer-head .members-heading {
    flex: 1;
    padding: 0;
    font-size: 11px;
  }

  .mobile-members-close {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    color: #b5bac1;
    font-size: 25px;
  }

  .group-member-row {
    min-height: 48px;
    padding: 5px 7px;
  }

  /* Profile / context menus become touch-friendly bottom sheets. */
  .profile-card {
    position: fixed !important;
    z-index: 500;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-height: min(72dvh, 560px);
    overflow-y: auto;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-top: 1px solid #202225;
    border-radius: 9px 9px 0 0;
  }

  .profile-card-avatar {
    width: 68px;
    height: 68px;
  }

  .context-menu,
  .group-member-context-menu {
    position: fixed !important;
    z-index: 520 !important;
    left: 8px !important;
    right: 8px !important;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    width: auto !important;
    max-height: 70dvh;
    overflow-y: auto;
    border-radius: 7px;
    padding: 6px;
  }

  .context-menu button {
    min-height: 43px;
    padding: 9px 10px;
    font-size: 14px;
    text-align: left;
  }

  .context-volume-row {
    min-height: 48px;
  }

  /* Calls stay compact enough to leave room for chat. */
  .call-panel {
    max-height: 42dvh;
    padding: 8px 9px 9px;
  }

  .call-panel-top {
    gap: 6px;
  }

  .call-panel-heading {
    min-width: 0;
  }

  .call-panel-actions {
    flex: none;
  }

  .call-control-button {
    width: 36px;
    height: 34px;
  }

  .call-participants {
    gap: 9px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
    -webkit-overflow-scrolling: touch;
  }

  .call-participant {
    flex: 0 0 68px;
    width: 68px;
  }

  .call-participant-avatar-wrap {
    width: 56px;
    height: 56px;
  }

  .call-screen-shares {
    grid-template-columns: 1fr;
  }

  .call-screen-share-video {
    max-height: 31dvh;
  }

  /* Attachments fit phone width. */
  .message-gif-wrap,
  .message-video-wrap,
  .message-audio-wrap,
  .message-file-card {
    max-width: calc(100vw - 66px);
  }

  .message-gif {
    max-width: min(78vw, 380px);
    max-height: 45dvh;
  }

  .message-video {
    width: min(78vw, 520px);
    max-height: 42dvh;
  }

  .message-file-card {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .message-file-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  /* Dialogs become full-screen mobile pages. */
  dialog,
  .small-dialog,
  .feature-dialog,
  .discovery-dialog {
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    inset: 0 !important;
    background: #2f3136;
  }

  dialog::backdrop {
    background: #2f3136;
  }

  dialog > form,
  dialog > .dialog-body,
  dialog > .settings-content,
  dialog > div {
    max-width: none;
  }

  .dialog-header,
  .settings-header {
    min-height: 52px;
    position: sticky;
    top: 0;
    z-index: 2;
    background: #2f3136;
  }

  .settings-layout {
    min-height: 0;
    height: calc(100dvh - env(safe-area-inset-top, 0px));
  }

  .settings-body,
  .settings-content,
  .dialog-content {
    max-height: none !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }

  /* Discovery: one column on narrow phones, two on wider phones. */
  .discovery-grid {
    grid-template-columns: 1fr;
    padding: 8px 10px calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .discovery-card {
    min-height: 88px;
  }

  .auth-page {
    min-height: 100dvh;
    height: 100dvh;
    padding: max(14px, env(safe-area-inset-top, 0px)) 12px max(14px, env(safe-area-inset-bottom, 0px));
    align-items: center;
  }

  .auth-box {
    width: min(100%, 410px);
    max-height: 92dvh;
    overflow-y: auto;
    padding: 20px 17px;
  }
}

@media (min-width: 540px) and (max-width: 760px) {
  .discovery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  #group-call-button-label {
    display: none;
  }

  .group-call-button {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  #send-button {
    min-width: 50px;
    padding-inline: 7px;
  }

  .composer-media-tip {
    font-size: 8px;
  }
}


/* ======================================================
   PHASE 7.3 — CAMERA CALLS
   ====================================================== */

.call-cameras {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 7px;
  margin-top: 7px;
}

.call-camera-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid #202225;
  border-radius: 4px;
  background: #111214;
}

.call-camera-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111214;
}

.call-camera-video.mirrored {
  transform: scaleX(-1);
}

.call-camera-label {
  position: absolute;
  left: 5px;
  bottom: 5px;
  max-width: calc(100% - 10px);
  padding: 2px 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 3px;
  background: rgba(17, 18, 20, .78);
  color: #f2f3f5;
  font-size: 10px;
}

.call-participant-camera {
  position: absolute;
  right: 16px;
  bottom: -1px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #23a55a;
  color: #fff;
}

.call-participant-camera svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.camera-device-field {
  margin-top: 12px;
}

.call-flip-camera {
  display: none;
}

@media (max-width: 760px) {
  .call-cameras {
    display: flex;
    overflow-x: auto;
    grid-template-columns: none;
    gap: 7px;
    padding-bottom: 3px;
    -webkit-overflow-scrolling: touch;
  }

  .call-cameras.hidden {
    display: none;
  }

  .call-camera-card {
    flex: 0 0 min(76vw, 300px);
  }

  .call-flip-camera:not(.hidden) {
    display: grid;
  }

  .call-panel {
    max-height: 58dvh;
    overflow-y: auto;
  }
}


/* ======================================================
   PHASE 7.4 — TYPING INDICATORS
   ====================================================== */

.typing-indicator {
  flex: none;
  min-height: 19px;
  padding: 3px 12px 3px 62px;
  background: #36393f;
  color: #dbdee1;
  font-size: 11px;
  line-height: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-indicator::before {
  content: "•••";
  margin-right: 6px;
  color: #949ba4;
  letter-spacing: 1px;
}

.typing-indicator-empty {
  display: none;
}

.typing-indicator-empty::before {
  content: "";
}

@media (max-width: 760px) {
  .typing-indicator {
    min-height: 20px;
    padding: 3px 9px 4px;
    font-size: 11px;
  }
}


/* PHASE 7.4.4 — ACCOUNT-WIDE EMAIL LOGIN PREFERENCE */
.account-login-preference-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #292b2f;
}

.account-login-preference-row input:disabled {
  cursor: not-allowed;
  opacity: .45;
}


/* PHASE 7.4.5 — PASTE IMAGE SUPPORT */
.message-form input::placeholder {
  text-overflow: ellipsis;
}


/* PHASE 8.1 — NOTIFICATION SOUND CONTROLS */
#context-toggle-dm-sound,
#context-toggle-group-sound {
  white-space: nowrap;
}


/* ======================================================
   PHASE 8.2 — NEWEST / CUSTOM SIDEBAR ORDER
   ====================================================== */

.sidebar-section-title-with-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-sort-mode {
  width: auto;
  min-width: 72px;
  height: 22px;
  padding: 0 4px;
  border: 1px solid #202225;
  border-radius: 3px;
  outline: none;
  background: #202225;
  color: #b9bbbe;
  font-size: 10px;
  font-weight: normal;
  text-transform: none;
}

.sidebar-sort-mode:focus {
  border-color: #4f545c;
}

.contact,
.group-item {
  position: relative;
}

.sidebar-item-dragging {
  opacity: .48;
}

.sidebar-drop-before::before,
.sidebar-drop-after::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  height: 2px;
  z-index: 2;
  background: #5865f2;
  border-radius: 2px;
  pointer-events: none;
}

.sidebar-drop-before::before {
  top: -1px;
}

.sidebar-drop-after::after {
  bottom: -1px;
}

@media (max-width: 760px) {
  .sidebar-sort-mode {
    min-width: 78px;
    height: 28px;
    font-size: 11px;
  }
}
