/* ==============================
   chat.css — Full Discord/WhatsApp Style (Merged)
   ============================== */

/* Root variables */
:root {
  --bg: #121212;
  --surface: rgba(24, 24, 24, 0.95);
  --surface-alt: #1b1b1b;
  --bubble-self: #056162;
  --bubble-other: #262d31;
  --text-primary: #f5f5f5;
  --text-muted: rgba(255, 255, 255, 0.65);
  --accent: #25d366;
  --border-color: rgba(255, 255, 255, 0.12);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --radius: 16px;
  --input-bg: #1f1f1f;
  --input-border: rgba(255, 255, 255, 0.18);
  --picker-bg: #1e1e1e;
  --picker-border: rgba(255, 255, 255, 0.12);
  --landing-bg: #000000;
  --link-preview-bg: rgba(255, 255, 255, 0.05);
  --link-preview-hover: rgba(255, 255, 255, 0.1);
  --pinned-bg: #2b2b2b;
  --typing-bg: rgba(0, 0, 0, 0.25);
  --preview-bg: rgba(255, 255, 255, 0.08);
  --status-online: #25d366;
  --status-offline: rgba(255, 255, 255, 0.35);
  --status-border: rgba(0, 0, 0, 0.45);
}

body:not(.dark) {
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-alt: #ffffff;
  --bubble-self: #20c373;
  --bubble-other: #e9edf2;
  --text-primary: #1f2933;
  --text-muted: #5f6368;
  --accent: #1fa866;
  --border-color: rgba(17, 17, 17, 0.12);
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  --input-bg: #ffffff;
  --input-border: rgba(17, 17, 17, 0.12);
  --picker-bg: #ffffff;
  --picker-border: rgba(17, 17, 17, 0.12);
  --landing-bg: #fefefe;
  --link-preview-bg: rgba(17, 17, 17, 0.05);
  --link-preview-hover: rgba(17, 17, 17, 0.1);
  --pinned-bg: #ffffff;
  --typing-bg: rgba(17, 17, 17, 0.08);
  --preview-bg: rgba(17, 17, 17, 0.08);
  --status-online: #1fa866;
  --status-offline: rgba(17, 17, 17, 0.28);
  --status-border: rgba(17, 17, 17, 0.08);
}

/* ==============================
   Body & Chat Container
   ============================== */
body {
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
}

body.dark { background: var(--bg); color: var(--text-primary); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100vh;
  background: var(--bg);
}

/* ==============================
   Landing Page
   ============================== */
#username-prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 12px;
  background: var(--landing-bg);
  color: var(--text-primary);
}

#username-prompt .logo { width: 120px; height: auto; margin-bottom: 12px; }

#username-prompt h1 { font-size: 2em; margin: 0 0 12px; color: var(--text-primary); }

.landing-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 260px;
}

.landing-inputs input {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
}

.landing-inputs input::placeholder { color: var(--text-muted); }

#join-btn {
  margin-top: 8px;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

#join-btn:hover { opacity: 0.9; }

#room-list { margin-top: 20px; text-align: center; color: var(--text-primary); }

#public-room-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

#public-room-list li {
  background: var(--surface-alt);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  cursor: default;
  align-items: flex-start;
}

#public-room-list li.clickable {
  cursor: pointer;
}

#public-room-list li.clickable:hover {
  transform: scale(1.05);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 14px rgba(37, 211, 102, 0.32);
}

#public-room-list li.locked {
  border-style: dashed;
  cursor: pointer;
}

#public-room-list li.locked:hover {
  transform: none;
  background: var(--surface-alt);
  color: var(--text-primary);
  box-shadow: none;
}

#public-room-list li.empty {
  width: 100%;
  justify-content: center;
  text-align: center;
  opacity: 0.7;
  border-style: dashed;
  background: transparent;
  color: var(--text-muted);
  cursor: default;
  box-shadow: none;
  pointer-events: none;
  min-width: 0;
}

#public-room-list li .room-name {
  font-weight: 600;
  font-size: 1em;
}

#public-room-list li .room-meta {
  font-size: 0.75em;
  color: var(--text-muted);
}

#public-room-list li.clickable .room-meta {
  color: inherit;
  opacity: 0.85;
}

/* ==============================
   Header
   ============================== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  background-color: var(--surface);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
  color: var(--text-primary);
  gap: 16px;
  flex-wrap: wrap;
}

header.toolbar-flash-message {
  animation: toolbarFlashOrange 1.4s ease-in-out 2;
}

header.toolbar-flash-join {
  animation: toolbarFlashGreen 1.1s ease-in-out 1;
}

@keyframes toolbarFlashOrange {
  0%,
  100% {
    background-color: var(--surface);
    border-bottom-color: var(--border-color);
    box-shadow: none;
  }
  25%,
  75% {
    background-color: #ff9f1c;
    border-bottom-color: #ffb347;
    box-shadow: 0 0 18px rgba(255, 159, 28, 0.45);
  }
  50% {
    background-color: var(--surface);
    border-bottom-color: var(--border-color);
    box-shadow: none;
  }
}

@keyframes toolbarFlashGreen {
  0%,
  100% {
    background-color: var(--surface);
    border-bottom-color: var(--border-color);
    box-shadow: none;
  }
  40% {
    background-color: #2ecc71;
    border-bottom-color: #6de0a0;
    box-shadow: 0 0 14px rgba(46, 204, 113, 0.4);
  }
  70% {
    background-color: #24b862;
    border-bottom-color: #6de0a0;
    box-shadow: 0 0 18px rgba(46, 204, 113, 0.45);
  }
}

header .header-left { display: flex; align-items: center; gap: 10px; }

header .logo { width: 40px; height: auto; }

#chat-container header .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
  margin-left: auto;
}

.psybin-player {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 6px 10px;
  color: var(--text-primary);
  flex: 0 1 320px;
  min-width: 220px;
}

.psybin-player[hidden] {
  display: none !important;
}

.psybin-player-label {
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.psybin-player-button {
  border: none;
  background: var(--surface);
  color: inherit;
  border-radius: var(--radius-sm, 6px);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s ease, color 0.2s ease;
}

.psybin-player-button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.psybin-player-button:not([disabled]):hover,
.psybin-player-button:not([disabled]):focus-visible {
  background: var(--accent-muted, rgba(178, 102, 255, 0.15));
  outline: none;
}

.psybin-player-volume {
  width: 110px;
  accent-color: var(--accent, #b266ff);
}

#chat-main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

#chat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg);
}

#chat-container .search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  margin-left: 16px;
}

#chat-container .search-bar input,
#chat-container .search-bar select {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.85em;
}

#chat-container .search-bar input::placeholder {
  color: var(--text-muted);
}

#chat-container .search-bar select {
  cursor: pointer;
  background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 8px 8px, 8px 8px;
  background-repeat: no-repeat;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 4px 24px 4px 10px;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
}

#chat-container .search-bar select option {
  background: var(--surface-alt);
  color: var(--text-primary);
}

#message-search:focus,
#message-search-filter:focus {
  outline: none;
}

#room-name { font-weight: 600; font-size: 1.1em; color: var(--text-primary); }

/* Header buttons */
.header-right button {
  font-size: 0.95em;
  margin-left: 8px;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 6px 12px;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  background: transparent;
  color: var(--text-primary);
}

.header-right button#leave-btn {
  background: #ff4d4d;
  color: #fff;
  font-weight: 600;
  border-color: transparent;
}

.header-right button#leave-btn:hover {
  background: #ff6666;
  transform: scale(1.05);
}

.header-right button#toggle-theme {
  background: var(--surface-alt);
  border-color: var(--border-color);
}

.header-right button#toggle-theme:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 18px rgba(123, 47, 247, 0.25);
}

.header-right button#toggle-sounds {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  min-width: 42px;
  width: 42px;
  height: 42px;
  background: var(--surface-alt);
  border-color: var(--border-color);
}

.header-right button#toggle-sounds .icon {
  font-size: 1.15em;
  line-height: 1;
}

.header-right button#toggle-sounds:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 18px rgba(123, 47, 247, 0.25);
}

.header-right button#toggle-sounds[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 10px 22px rgba(37, 211, 102, 0.3);
}

.header-right button#toggle-sounds[aria-pressed="true"] .icon {
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.25));
}

.header-right button#copy-join-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface);
  border-color: var(--border-color);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  line-height: 1.1;
}

.header-right button#copy-join-link .icon {
  font-size: 1.1em;
  line-height: 1;
}

.header-right button#copy-join-link .label {
  letter-spacing: 0.02em;
}

.header-right button#copy-join-link:hover {
  background: var(--surface-alt);
  box-shadow: 0 8px 18px rgba(123, 47, 247, 0.25);
  transform: translateY(-1px);
}

.header-right button#copy-join-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body:not(.dark) .header-right button#copy-join-link {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(17, 17, 17, 0.12);
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.05);
  color: #1f2933;
}

body:not(.dark) .header-right button#copy-join-link:hover {
  background: #eef2fb;
}

/* ==============================
   Messages Area
   ============================== */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--surface-alt);
}

.scroll-to-latest {
  position: absolute;
  left: 50%;
  bottom: 110px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: rgba(17, 17, 17, 0.65);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(17, 17, 17, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  transform: translateX(-50%);
  z-index: 5;
}

body:not(.dark) .scroll-to-latest {
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-primary);
  border-color: rgba(17, 17, 17, 0.12);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.18);
}

.scroll-to-latest:hover {
  transform: translate(-50%, -1px);
  box-shadow: 0 16px 30px rgba(17, 17, 17, 0.38);
}

.scroll-to-latest:active {
  transform: translate(-50%, 0);
  box-shadow: 0 10px 20px rgba(17, 17, 17, 0.28);
}

.scroll-to-latest:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.scroll-to-latest .scroll-to-latest-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.8rem;
  line-height: 1.1;
}

.scroll-to-latest.has-new {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 18px 32px rgba(123, 47, 247, 0.35);
}

body:not(.dark) .scroll-to-latest.has-new {
  box-shadow: 0 18px 32px rgba(123, 47, 247, 0.28);
}

.scroll-to-latest.has-new .scroll-to-latest-count {
  background: rgba(255, 255, 255, 0.25);
}

.scroll-to-latest:not(.has-new) .scroll-to-latest-count {
  display: none;
}

@media (max-width: 768px) {
  .scroll-to-latest {
    bottom: 96px;
    font-size: 0.85rem;
    padding: 9px 14px;
  }
}

.day-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 18px 0 8px;
}

.day-separator::before,
.day-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
  opacity: 0.6;
}

#user-sidebar {
  width: 260px;
  max-width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border-color);
  padding: 16px 18px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 260px;
  min-width: 220px;
}

#user-sidebar .sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#user-sidebar .sidebar-header h2 {
  font-size: 1rem;
  margin: 0;
  color: var(--text-primary);
}

#user-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

#user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.user-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.2s ease;
  cursor: default;
}

.user-entry .user-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-entry .user-name .user-crown {
  font-size: 1.05em;
}

.user-entry .user-name .self-pill {
  font-size: 0.75rem;
  background: rgba(187, 134, 252, 0.25);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 999px;
}

.user-entry .user-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-entry .user-status.bad {
  color: #ff6b6b;
}

.user-entry .user-status.warn {
  color: #f6c343;
}

.user-entry.actionable {
  cursor: pointer;
}

.user-entry.actionable:focus-visible {
  outline: 2px solid rgba(187, 134, 252, 0.85);
  outline-offset: 2px;
  border-color: rgba(187, 134, 252, 0.55);
}

.user-entry.actionable:hover {
  transform: translateY(-1px);
  border-color: rgba(187, 134, 252, 0.35);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.user-entry.disabled {
  opacity: 0.65;
}

#user-list-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.user-context-menu {
  position: absolute;
  display: none;
  flex-direction: column;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  padding: 6px;
  z-index: 60;
}

.user-context-menu.open {
  display: flex;
}

.user-context-menu button {
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.user-context-menu button:hover {
  background: rgba(187, 134, 252, 0.18);
  transform: translateY(-1px);
}

.user-context-menu button:focus-visible {
  outline: 2px solid rgba(187, 134, 252, 0.7);
  outline-offset: 2px;
  background: rgba(187, 134, 252, 0.18);
}

.user-context-menu button.danger {
  color: #ff6b6b;
}

.user-context-menu button.danger:hover {
  background: rgba(255, 107, 107, 0.16);
}

@media (max-width: 900px) {
  #chat-main {
    flex-direction: column;
  }

  #user-sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    order: 1;
  }

  #chat-content {
    order: 0;
  }
}

.message {
  position: relative;
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  word-wrap: break-word;
  font-size: 1em;
  animation: fadeIn 0.25s ease-in;
  display: inline-block;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  color: var(--text-primary);
}

.message:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

.message.menu-open {
  z-index: 100;
}

.message.menu-open,
.message.menu-open:hover {
  transform: none;
  box-shadow: var(--shadow);
}

.message.self {
  align-self: flex-end;
  background: var(--bubble-self);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.other {
  align-self: flex-start;
  background: var(--bubble-other);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message[data-deleted="true"] {
  opacity: 0.65;
  background: rgba(128, 128, 128, 0.35);
  box-shadow: none;
}

.message .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.75em;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding-right: 32px;
}

.message .meta .meta-name {
  font-weight: 600;
}

.message .meta .meta-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.message .meta .meta-time {
  opacity: 0.8;
}

.message .meta .meta-status {
  position: relative;
  width: 18px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.95em;
  letter-spacing: -0.02em;
}

.message .meta .meta-status::before,
.message .meta .meta-status::after {
  content: "✓";
  position: absolute;
  font-weight: 700;
  line-height: 1;
  font-size: 0.95em;
}

.message .meta .meta-status::after {
  opacity: 0;
}

.message .meta .meta-status[data-status="sent"]::before {
  color: rgba(255, 255, 255, 0.75);
  right: 0;
}

body:not(.dark) .message.self .meta .meta-status[data-status="sent"]::before {
  color: rgba(0, 0, 0, 0.6);
}

.message .meta .meta-status[data-status="delivered"]::before,
.message .meta .meta-status[data-status="delivered"]::after {
  color: rgba(255, 255, 255, 0.8);
}

body:not(.dark) .message.self .meta .meta-status[data-status="delivered"]::before,
body:not(.dark) .message.self .meta .meta-status[data-status="delivered"]::after {
  color: rgba(0, 0, 0, 0.7);
}

.message .meta .meta-status[data-status="delivered"]::before {
  right: 0;
}

.message .meta .meta-status[data-status="delivered"]::after {
  right: 5px;
  opacity: 1;
}

.message .meta .meta-status[data-status="read"]::before,
.message .meta .meta-status[data-status="read"]::after {
  color: #34b7f1;
}

.message .meta .meta-status[data-status="read"]::before {
  right: 0;
}

.message .meta .meta-status[data-status="read"]::after {
  right: 5px;
  opacity: 1;
}

.message.other .meta .meta-status {
  display: none;
}

.message .message-flags {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.message .message-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.75em;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
}

.message.other .message-flag {
  background: rgba(0, 0, 0, 0.15);
}

.message .message-flag.pinned {
  background: rgba(37, 211, 102, 0.2);
  color: #20c373;
}

.message .message-flag.starred {
  background: rgba(255, 215, 0, 0.25);
  color: #ffd700;
}

.message .message-flag .count {
  font-weight: 600;
}

#reply-preview {
  display: none;
  align-items: center;
  gap: 12px;
  margin: 8px 16px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-alt);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

#reply-preview.show {
  display: flex;
}

#reply-preview .reply-preview-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

#reply-preview .reply-preview-title {
  font-size: 0.85em;
  color: var(--accent);
  font-weight: 600;
}

#reply-preview .reply-preview-text {
  font-size: 0.9em;
  color: var(--text-primary);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#reply-preview .reply-preview-content:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#reply-preview button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1em;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
}

#reply-preview button:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.message .reply-context {
  margin: 2px 0 8px;
  padding: 6px 10px;
  border-left: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message .reply-context:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.message.self .reply-context {
  background: rgba(255, 255, 255, 0.12);
}

.message .reply-context:hover {
  background: var(--link-preview-hover);
}

.message .reply-context .reply-author {
  font-weight: 600;
  font-size: 0.82em;
  color: var(--accent);
}

.message .reply-context .reply-snippet {
  font-size: 0.88em;
  color: var(--text-primary);
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 6px;
}

.message .reply-context.deleted .reply-snippet {
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.7;
}

.message .reply-context .reply-attachment-label {
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.message .text {
  white-space: pre-wrap;
}

.message .text.hidden {
  display: none;
}

.message .deleted-label {
  font-style: italic;
  color: var(--text-muted);
}

.message .message-actions-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1.1em;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.message .message-actions-toggle:hover,
.message .message-actions-toggle[aria-expanded="true"] {
  opacity: 1;
}

.message .message-actions-menu {
  position: absolute;
  top: 28px;
  right: 8px;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
  z-index: 50;
}

.message .message-actions-menu.open {
  display: flex;
}

.message .message-actions-menu button {
  background: transparent;
  border: none;
  padding: 8px 12px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  font-size: 0.9em;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.message .message-actions-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.message .message-actions-menu button.danger {
  color: #ff6b6b;
}

.message.self .message-actions-menu button.danger {
  color: #ffdede;
}

.message .text img.custom-emoji {
  display: inline-block;
  height: 3em;
  width: auto;
  margin: 0 2px;
  vertical-align: middle;
  image-rendering: auto;
}

.message .text img.custom-emoji.custom-emoji-gif {
  display: block;
  width: min(240px, 100%);
  height: auto;
  margin: 6px 0;
  border-radius: 12px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.message.self .text img.custom-emoji.custom-emoji-gif {
  margin-left: auto;
}

.message.other .text img.custom-emoji.custom-emoji-gif {
  margin-right: auto;
}

.message .text.has-emoji-gif {
  display: flex;
  flex-direction: column;
  gap: 8px;
  white-space: pre-wrap;
}

.message.self .text.has-emoji-gif {
  align-items: flex-end;
  text-align: right;
}

.message.other .text.has-emoji-gif {
  align-items: flex-start;
  text-align: left;
}

.message .text.has-emoji-gif.emoji-gif-only {
  gap: 10px;
}

.message.has-emoji-gif {
  max-width: min(260px, 90vw);
  padding: 10px 12px;
}

.message.has-inline-preview {
  padding: 10px 12px;
}

.message.search-hit {
  outline: 2px solid var(--accent);
  box-shadow: 0 0 12px rgba(37, 211, 102, 0.4);
}

.message.has-inline-preview .text:empty {
  display: none;
}

.message.media-only,
.message.tenor-only {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  max-width: min(260px, 100%);
}

.message.media-only .inline-preview,
.message.tenor-only .inline-preview {
  margin-top: 0;
  width: 100%;
  padding: 6px;
}

.message.tenor-only .inline-preview.tenor-inline {
  width: 100%;
}

.message .text img.custom-emoji:first-child {
  margin-left: 0;
}

.message .text img.custom-emoji:last-child {
  margin-right: 0;
}

/* Pin & Star Buttons */
.message .pin-btn,
.message .star-btn {
  position: absolute;
  top: 8px;
  font-size: 1.3em;
  cursor: pointer;
  opacity: 0.8;
  border: none;
  background: none;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.message .pin-btn { right: 32px; }
.message .star-btn { right: 6px; }
.message .pin-btn:hover,
.message .star-btn:hover { transform: scale(1.4); opacity: 1; }

/* Reactions */
.message .reactions {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.message .reactions .reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 3px 8px;
  font-size: 0.85em;
  color: inherit;
  cursor: default;
  transition: transform 0.15s ease, background 0.2s ease, border 0.2s ease;
}

.message .reactions .reaction-chip.own {
  cursor: pointer;
}

.message .reactions .reaction-chip.own:hover,
.message .reactions .reaction-chip.own:focus-visible {
  transform: translateY(-1px) scale(1.05);
  background: rgba(187,134,252,0.28);
  border-color: rgba(187,134,252,0.6);
  outline: none;
}

.message .reactions .reaction-chip .reaction-emoji,
.message .reactions .reaction-chip .reaction-count {
  line-height: 1;
}

.message .reactions .reaction-chip .reaction-count {
  font-size: 0.75em;
  opacity: 0.85;
}

.message .reactions .reaction-chip img {
  width: 1.2em;
  height: 1.2em;
  object-fit: contain;
  border-radius: 8px;
}

.message .reactions .reaction-chip.own {
  background: rgba(187,134,252,0.35);
  border-color: rgba(187,134,252,0.75);
  box-shadow: 0 0 8px rgba(187,134,252,0.35);
}

body.light .message .reactions .reaction-chip {
  border-color: rgba(0,0,0,0.12);
  background: rgba(0,0,0,0.05);
}

body.light .message .reactions .reaction-chip.own:hover,
body.light .message .reactions .reaction-chip.own:focus-visible {
  background: rgba(187,134,252,0.25);
  border-color: rgba(187,134,252,0.55);
}

body.light .message .reactions .reaction-chip.own {
  background: rgba(187,134,252,0.32);
  border-color: rgba(187,134,252,0.7);
}

/* ==============================
   Input Bar
   ============================== */
#form {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  background: var(--surface);
  backdrop-filter: blur(8px);
}

#input {
  flex: 1;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 1em;
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
}

#input::placeholder { color: var(--text-muted); }

#form button {
  margin-left: 6px;
  border: none;
  background: none;
  font-size: 1.3em;
  cursor: pointer;
  color: var(--text-primary);
  transition: transform 0.15s ease;
}

#form button:hover { transform: scale(1.2); }

#gif-btn {
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--surface-alt);
  color: var(--text-primary);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

#gif-btn span[aria-hidden="true"] {
  pointer-events: none;
}

body.dark #gif-btn {
  background: rgba(123, 47, 247, 0.22);
  border-color: rgba(123, 47, 247, 0.45);
  color: #f5f0ff;
}

body:not(.dark) #gif-btn {
  background: rgba(123, 47, 247, 0.12);
  border-color: rgba(123, 47, 247, 0.35);
  color: #5b21b6;
}

#gif-btn:hover,
#gif-btn:focus-visible {
  background: #7b2ff7;
  color: #ffffff;
  border-color: #6820d7;
  box-shadow: 0 0 12px rgba(123, 47, 247, 0.45);
  transform: scale(1.1);
}

#gif-btn:focus-visible {
  outline: 2px solid rgba(123, 47, 247, 0.6);
  outline-offset: 2px;
}

/* ==============================
   Emoji Picker
   ============================== */
#emoji-picker {
  position: absolute;
  bottom: 60px;
  right: 20px;
  width: 320px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--picker-bg);
  border: 1px solid var(--picker-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
  z-index: 500;
  padding: 8px;
  color: var(--text-primary);
}

#emoji-picker.show {
  display: block;
}

#quick-emojis {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

#quick-emojis button {
  font-size: 1.5em;
  cursor: pointer;
  border: none;
  background: none;
  transition: transform 0.15s ease;
}

#quick-emojis button.pop { transform: scale(1.5); }

#emoji-search {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.9em;
  outline: none;
}

#emoji-search::placeholder { color: var(--text-muted); }

#emoji-catalog {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.emoji-category-title {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: transform 0.12s ease, border 0.12s ease, background 0.12s ease;
  color: var(--text-primary);
}

.emoji-item.emoji-item-image {
  height: 72px;
  padding: 4px;
  background: var(--surface-alt);
  border-color: var(--border-color);
  grid-column: span 2;
}

.emoji-item img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  pointer-events: none;
}

.emoji-item.emoji-item-image img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.emoji-item:hover {
  transform: translateY(-1px) scale(1.05);
  border-color: var(--border-color);
  background: var(--surface-alt);
}

.emoji-empty {
  text-align: center;
  padding: 12px 0;
  font-size: 0.85em;
  color: var(--text-muted);
}

/* ==============================
   Pinned Messages
   ============================== */
#pinned-messages {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--pinned-bg);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius);
  margin: 8px;
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid rgba(37, 211, 102, 0.35);
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

#pinned-messages .pinned-entry {
  list-style: none;
  padding: 6px 8px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  font-size: 0.9em;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

#pinned-messages .pinned-entry:hover {
  background: var(--link-preview-hover);
  transform: translateY(-1px);
}

#pinned-messages .pinned-entry .pinned-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#pinned-messages .pinned-entry .pinned-meta {
  font-size: 0.75em;
  color: var(--text-muted);
}

/* ==============================
   Search Results Overlay
   ============================== */
#search-results {
  margin: 0 16px 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: none;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

#search-results.show {
  display: flex;
}

#search-results .search-result-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

#search-results .search-result-item:hover {
  background: var(--link-preview-hover);
}

#search-results .search-result-meta {
  font-size: 0.75em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

#search-results .search-result-text {
  font-size: 0.85em;
  color: var(--text-primary);
}

/* ==============================
   Typing Bubble
   ============================== */
#typing-bubble {
  position: sticky;
  bottom: 60px;
  z-index: 10;
  background: var(--typing-bg);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.95em;
  color: var(--text-primary);
  text-align: center;
  align-self: center;
  max-width: 60%;
  word-wrap: break-word;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.2s ease;
  visibility: hidden;
  pointer-events: none;
}

#typing-bubble.show {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

#typing-bubble.hide {
  opacity: 0;
  transform: translateY(10px);
  visibility: hidden;
  pointer-events: none;
}

/* ==============================
   File & Link Previews
   ============================== */
.file-preview { margin-top: 6px; max-width: 240px; border-radius: var(--radius); overflow: hidden; }

.inline-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(240px, 100%);
  border-radius: 16px;
  margin-top: 8px;
  background: var(--preview-bg);
  border: 1px solid var(--border-color);
  padding: 10px;
  box-sizing: border-box;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.inline-preview .embed-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.inline-preview .embed-links a {
  color: var(--accent);
  font-size: 0.8em;
  text-decoration: underline;
  word-break: break-all;
}

.inline-preview:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
  border-color: rgba(123, 47, 247, 0.45);
}

.inline-preview.inline-image {
  padding: 8px;
  gap: 6px;
}

.inline-preview.inline-image .preview-media {
  min-height: 0;
  padding: 0;
  background: transparent;
}

.preview-media {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80px;
}

.preview-media img,
.preview-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.inline-preview.inline-image .preview-media img {
  height: auto;
  object-fit: contain;
}

.inline-preview.tenor-inline {
  width: min(220px, 100%);
  padding: 8px;
  gap: 6px;
}

.inline-preview.tenor-inline .preview-media {
  min-height: 0;
  background: transparent;
}

.inline-preview.tenor-inline .preview-media img,
.inline-preview.tenor-inline .preview-media video {
  height: auto;
  border-radius: 12px;
}

.inline-preview.tenor-inline .preview-actions {
  justify-content: space-between;
}

.preview-media video {
  background: #000;
}

.preview-media audio {
  width: 100%;
}

.soundcloud-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8em;
  color: var(--text-primary);
}

.soundcloud-controls button {
  border: none;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.soundcloud-controls button:hover {
  background: rgba(0, 0, 0, 0.35);
}

.soundcloud-controls input[type="range"] {
  flex: 1;
}

.inline-preview.inline-audio .preview-media,
.inline-preview.inline-pdf .preview-media,
.inline-preview.inline-file .preview-media {
  background: var(--surface-alt);
  border: 1px dashed var(--border-color);
  padding: 20px 12px;
}

.inline-preview .preview-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  text-transform: uppercase;
  text-align: center;
}

.inline-preview .preview-label a {
  color: inherit;
  text-decoration: underline;
  word-break: break-word;
}

.inline-preview .preview-label a:hover,
.inline-preview .preview-label a:focus {
  color: var(--accent);
}

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

.preview-actions .preview-open,
.preview-actions .preview-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(187, 134, 252, 0.4);
  background: rgba(187, 134, 252, 0.15);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.preview-actions .preview-open:hover,
.preview-actions .preview-download:hover {
  background: rgba(187, 134, 252, 0.3);
  transform: translateY(-1px);
}

.preview-actions .preview-open {
  border-color: rgba(37, 211, 102, 0.35);
  background: rgba(37, 211, 102, 0.16);
}

.preview-actions .preview-open:hover {
  background: rgba(37, 211, 102, 0.28);
}

.preview-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  word-break: break-word;
}

.embed-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.embed-iframe {
  width: min(340px, 100%);
  height: 190px;
  border: none;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.embed-iframe.spotify { height: 152px; }
.embed-iframe.soundcloud { height: 166px; background: transparent; }

.link-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(187, 134, 252, 0.25);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-top: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.link-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(187, 134, 252, 0.3);
}

.link-card:focus {
  outline: 2px solid rgba(187, 134, 252, 0.8);
  outline-offset: 2px;
}

.link-card .link-thumb {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
}

.link-card .link-thumb.link-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  background: linear-gradient(135deg, rgba(187, 134, 252, 0.35), rgba(37, 211, 102, 0.3));
}

.link-card .link-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.link-card .link-domain {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.link-card .link-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.link-card .link-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.link-card .link-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.4));
}

#media-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 4000;
}

#media-lightbox.show {
  display: flex;
}

#media-lightbox .media-frame {
  background: rgba(15, 15, 15, 0.92);
  border-radius: 18px;
  padding: 20px;
  max-width: min(90vw, 960px);
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.media-frame .media-close {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.media-frame .media-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox-media {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.media-frame .media-caption {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
}

.link-preview {
  display: flex; align-items: center; gap: 8px; background: var(--link-preview-bg);
  border-radius: var(--radius); padding: 6px; margin-top: 6px; cursor: pointer; transition: background 0.2s ease, box-shadow 0.2s ease;
}
.link-preview:hover { background: var(--link-preview-hover); box-shadow: 0 6px 14px rgba(0,0,0,0.18); }
.link-preview img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }

/* ==============================
   Animations
   ============================== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ==============================
   Responsive Adjustments
   ============================== */
@media (max-width: 640px) {
  #emoji-picker { bottom: 60px; width: 90%; right: 5%; }
  #pinned-messages { max-height: 100px; margin: 4px; font-size: 0.85em; }
  #typing-bubble { bottom: 70px; font-size: 0.85em; max-width: 80%; }
  .message { max-width: 90%; font-size: 0.95em; padding: 10px 12px; }
  .link-preview img { width: 40px; height: 40px; }
  #input { font-size: 0.95em; }
  .header-right button { font-size: 0.85em; padding: 5px 10px; }
  .inline-preview { width: min(200px, 100%); }
}

@media (max-width: 480px) {
  #username-prompt { padding: 20px 16px; gap: 12px; }
  #username-prompt .logo { width: 100px; }
  #username-prompt h1 { font-size: 1.4em; }
  .landing-inputs { width: 100%; max-width: 260px; flex-direction: column; gap: 8px; }
  .landing-inputs input { width: 100%; padding: 10px 12px; font-size: 0.95em; }
  #join-btn { width: 100%; padding: 10px; font-size: 1em; }
  #room-list h3 { font-size: 1em; }
  #public-room-list { gap: 6px; }
  #public-room-list li { font-size: 0.85em; padding: 5px 8px; }
  .inline-preview { width: min(180px, 100%); }
}

/* ==============================
   Scrollbar Styling
   ============================== */
#messages::-webkit-scrollbar,
#pinned-messages::-webkit-scrollbar,
#emoji-picker::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-thumb,
#pinned-messages::-webkit-scrollbar-thumb,
#emoji-picker::-webkit-scrollbar-thumb { background: #444; border-radius: 6px; }
#messages::-webkit-scrollbar-track,
#pinned-messages::-webkit-scrollbar-track,
#emoji-picker::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); }

/* ==============================
   DIZY PURPLE PATCH
   ============================== */
.upload-progress {
  width: 100%;
  max-width: 360px;
  height: 6px;
  border-radius: 999px;
  background: rgba(123, 47, 247, 0.15);
  margin: 8px auto;
  overflow: hidden;
}

.upload-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #7B2FF7;
  box-shadow: 0 0 12px rgba(123, 47, 247, 0.6) inset;
  transition: width .12s linear;
}

.inline-video,
.inline-audio,
.inline-pdf,
.inline-text {
  margin-top: 6px;
  border-radius: 12px;
  max-width: 100%;
  background: rgba(255,255,255,0.05);
}

#file-attach:hover,
#emoji-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 8px rgba(123,47,247,0.4);
}
/* DIZY PURPLE PATCH (Upload Progress + Media + Embeds) */
#upload-progress {
  width: 100%;
  height: 4px;
  background: #222;
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0 0;
  display: none;
}
#upload-progress::-webkit-progress-value { background: #bb86fc; }
#upload-progress::-moz-progress-bar { background: #bb86fc; }

.inline-image,
.file-preview {
  border-radius: 12px;
}

.embed-card {
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(187,134,252,0.2);
}
.embed-card iframe {
  display: block;
  width: 100%;
  max-width: 420px;
  height: 240px;
  border: 0;
}
.link-preview-lite {
  display: inline-block;
  margin-top: 6px;
  max-width: 420px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: #bb86fc;
  text-decoration: none;
  word-break: break-word;
}

#file-attach:hover,
#emoji-btn:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 0 6px rgba(187,134,252,0.45));
}
/* ==============================
   DIZY FUSION SUPERNOVA PATCH 💜
   ============================== */

/* Upload progress overlay */
.upload-progress {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  width: 260px;
  height: 8px;
  background: rgba(187,134,252,0.15);
  border-radius: 999px;
  overflow: hidden;
  z-index: 1000;
  text-align: center;
  color: #fff;
  font-size: 0.75em;
}
.upload-progress .bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg,#b266ff,#7B2FF7);
  box-shadow: 0 0 8px rgba(187,134,252,0.4);
  transition: width 0.25s ease;
}

/* GIF picker */
#gif-picker {
  position: fixed;
  bottom: 70px;
  left: 10px;
  width: 340px;
  max-height: 320px;
  overflow-y: auto;
  background: rgba(20,20,20,0.95);
  border: 1px solid rgba(187,134,252,0.25);
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(123,47,247,0.3);
  display: none;
  padding: 10px;
  z-index: 1000;
}
#gif-picker input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #111;
  color: #fff;
  margin-bottom: 8px;
}
#gif-picker .gif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  grid-auto-rows: 72px;
}
#gif-picker .gif-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#gif-picker .gif-thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 8px rgba(187,134,252,0.45);
}

/* Admin badge and system messages */
.admin-badge {
  margin-left: 8px;
  padding: 2px 6px;
  background: rgba(187,134,252,0.2);
  border-radius: 8px;
  font-size: 0.8em;
  color: #bb86fc;
}
.system-bubble {
  text-align: center;
  background: rgba(187,134,252,0.1);
  border-left: 3px solid #bb86fc;
  border-radius: 10px;
  padding: 6px 10px;
  margin: 6px 0;
  font-size: 0.9em;
  color: #d1b9ff;
}

/* ==============================
   Dialogs
   ============================== */
.confirm-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
}

.confirm-dialog {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  width: min(320px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
}

.confirm-dialog h3 {
  margin: 0;
  font-size: 1.1em;
}

.confirm-dialog .confirm-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.confirm-dialog .confirm-dialog-actions button {
  flex: 1;
  border-radius: 10px;
  border: none;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
}

.confirm-dialog .confirm-dialog-actions button.primary {
  background: var(--accent);
  color: #fff;
}

.confirm-dialog .confirm-dialog-actions button.danger {
  background: #ff4d4d;
  color: #fff;
}

.confirm-dialog .confirm-dialog-actions button.neutral {
  background: var(--surface-alt);
  color: var(--text-primary);
}
/* ==============================
   DIZY TOAST NOTIFICATIONS 💜
   ============================== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 200px;
  max-width: 280px;
  background: rgba(20, 20, 20, 0.9);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 0 8px rgba(187, 134, 252, 0.4);
  font-size: 0.9em;
  opacity: 0;
  transform: translateX(20px);
  animation: toastSlide 0.4s ease forwards;
}

.toast.success { border-left: 4px solid #7B2FF7; }
.toast.error { border-left: 4px solid #ff4d4d; }
.toast.info { border-left: 4px solid #25d366; }

@keyframes toastSlide {
  to { opacity: 1; transform: translateX(0); }
}

.toast.hide {
  animation: toastHide 0.3s ease forwards;
}
@keyframes toastHide {
  to { opacity: 0; transform: translateX(30px); }
}
/* ==============================
   DIZY PURPLE GLOW PATCH 🌌
   ============================== */

/* Toasts — bottom-left, glowing, fade + slide stack */
.toast-container {
  position: fixed;
  bottom: 76px;
  left: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: rgba(20, 20, 20, 0.9);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9em;
  min-width: 200px;
  max-width: 320px;
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  font-weight: 500;
  animation: toastPop 0.25s ease forwards;
}

/* Success, Error, and Info Toasts */
.toast.success {
  border-left: 4px solid #2ecc71;
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.45);
}

.toast.error {
  border-left: 4px solid #e74c3c;
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

.toast.info {
  border-left: 4px solid #bb86fc;
  box-shadow: 0 0 10px rgba(187, 134, 252, 0.55);
}

/* Embed / Link Card Glow */
.embed-iframe,
.embed-image,
.embed-media,
.embed-audio {
  border-radius: 10px;
  box-shadow: 0 0 8px rgba(187, 134, 252, 0.25);
}

/* Toast Slide Up & Fade Animation */
@keyframes toastPop {
  0% { opacity: 0; transform: translateX(-12px) translateY(10px); }
  100% { opacity: 1; transform: translateX(0) translateY(0); }
}

/* Toast container auto-stack animation */
.toast-container .toast:nth-child(1) {
  animation-delay: 0s;
}

.toast-container .toast:nth-child(2) {
  animation-delay: 0.15s;
}

.toast-container .toast:nth-child(3) {
  animation-delay: 0.3s;
}

.toast-container .toast:nth-child(4) {
  animation-delay: 0.45s;
}

.toast-container .toast:nth-child(5) {
  animation-delay: 0.6s;
}
