/* ==============================
   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);
  --toolbar-padding-y: 12px;
  --toolbar-padding-x: 16px;
  --toolbar-gap: 16px;
  --toolbar-logo-size: 40px;
  --toolbar-control-height: 42px;
  --toolbar-button-padding-y: 6px;
  --toolbar-button-padding-x: 12px;
  --toolbar-icon-button-size: 42px;
  --toolbar-button-font-size: 0.95em;
  --toolbar-link-padding-y: 8px;
  --toolbar-link-padding-x: 14px;
  --toolbar-search-gap: 6px;
  --toolbar-search-padding-y: 4px;
  --toolbar-search-padding-x: 6px;
  --toolbar-search-margin-left: 16px;
  --toolbar-search-font-size: 0.85em;
  --toolbar-top-extra: 0px;
  --room-name-font-size: 1.1em;
  --messages-padding-y: 12px;
  --messages-padding-x: 12px;
  --message-gap: 10px;
  --message-padding-y: 12px;
  --message-padding-x: 16px;
  --message-font-size: 1em;
  --message-meta-font-size: 0.75em;
  --scroll-to-latest-bottom: 110px;
  --scroll-to-latest-padding-y: 10px;
  --scroll-to-latest-padding-x: 16px;
  --scroll-to-latest-font-size: 0.9rem;
  --input-padding-y: 10px;
  --input-padding-x: 12px;
  --input-field-height: 36px;
  --input-field-padding-x: 14px;
  --input-font-size: 1em;
  --input-button-gap: 5px;
  --input-button-font-size: 1.3em;
  --input-icon-size: 42px;
  --quick-emoji-gap: 6px;
  --quick-emoji-margin-left: 8px;
  --quick-emoji-size: 36px;
  --sidebar-width: 260px;
  --sidebar-min-width: 220px;
  --sidebar-padding-y: 16px;
  --sidebar-padding-x: 18px;
  --sidebar-gap: 12px;
}

body:not(.dark) {
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-alt: #ffffff;
  --bubble-self: #17a85f;
  --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.compact-mode {
  --toolbar-padding-y: 8px;
  --toolbar-padding-x: 12px;
  --toolbar-gap: 10px;
  --toolbar-logo-size: 32px;
  --toolbar-control-height: 36px;
  --toolbar-button-padding-y: 4px;
  --toolbar-button-padding-x: 10px;
  --toolbar-icon-button-size: 34px;
  --toolbar-button-font-size: 0.9em;
  --toolbar-link-padding-y: 6px;
  --toolbar-link-padding-x: 12px;
  --toolbar-search-gap: 4px;
  --toolbar-search-padding-y: 3px;
  --toolbar-search-padding-x: 4px;
  --toolbar-search-margin-left: 10px;
  --toolbar-search-font-size: 0.8em;
  --room-name-font-size: 1em;
  --messages-padding-y: 8px;
  --messages-padding-x: 8px;
  --message-gap: 6px;
  --message-padding-y: 8px;
  --message-padding-x: 12px;
  --message-font-size: 0.95em;
  --message-meta-font-size: 0.7em;
  --scroll-to-latest-bottom: 84px;
  --scroll-to-latest-padding-y: 8px;
  --scroll-to-latest-padding-x: 14px;
  --scroll-to-latest-font-size: 0.85rem;
  --input-padding-y: 6px;
  --input-padding-x: 10px;
  --input-field-height: 34px;
  --input-field-padding-x: 12px;
  --input-font-size: 0.95em;
  --input-button-gap: 4px;
  --input-button-font-size: 1.15em;
  --input-icon-size: 34px;
  --quick-emoji-gap: 4px;
  --quick-emoji-margin-left: 4px;
  --quick-emoji-size: 32px;
  --sidebar-width: 220px;
  --sidebar-min-width: 200px;
  --sidebar-padding-y: 12px;
  --sidebar-padding-x: 14px;
  --sidebar-gap: 10px;
}

/* ==============================
   Body & Chat Container
   ============================== */
html {
  height: 100%;
}

body {
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text-primary);
}

body.view-landing {
  overflow-y: auto;
}

body.view-chat {
  overflow-y: hidden;
}

body.view-landing #chat-container {
  display: none;
}

body.view-chat #site-landing {
  display: none;
}

@supports (height: 100dvh) {
  body {
    min-height: 100dvh;
    height: 100dvh;
  }

  #chat-container {
    min-height: 100dvh;
    height: 100dvh;
  }
}

@supports (height: 100svh) {
  body {
    min-height: 100svh;
    height: 100svh;
  }

  #chat-container {
    min-height: 100svh;
    height: 100svh;
  }
}

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 1 auto;
  min-height: 100vh;
  height: 100vh;
  width: 100%;
  max-width: 100vw;
  background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  box-sizing: border-box;
}

/* ==============================
   Marketing / Landing Sections
   ============================== */

.site-landing {
  width: 100%;
  background: radial-gradient(circle at top, rgba(37, 211, 102, 0.15), transparent 45%),
    var(--landing-bg);
  color: var(--text-primary);
}

.hero-section {
  padding: 72px clamp(24px, 6vw, 120px) 48px;
  display: flex;
  flex-direction: column;
  gap: 48px;
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.18), rgba(178, 102, 255, 0.12));
  border-bottom: 1px solid var(--border-color);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.site-nav img.logo {
  width: 48px;
  height: 48px;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.85;
}

.nav-links a:hover,
.nav-links a:focus {
  opacity: 1;
}

.nav-links .nav-cta a {
  background: linear-gradient(135deg, var(--accent), #7bffb3);
  color: #0f172a;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(37, 211, 102, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-links .nav-cta a:hover,
.nav-links .nav-cta a:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45);
}

.nav-links .nav-cta a:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 3px;
}

.hero-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 32px;
  align-items: center;
}

.hero-text h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  margin-bottom: 16px;
}

.hero-text p {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.hero-actions {
  margin-top: 24px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-actions a,
.hero-actions button {
  padding: 12px 24px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.hero-primary {
  background: var(--accent);
  color: #000;
}

.hero-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.hero-actions a:hover,
.hero-actions a:focus,
.hero-actions button:hover,
.hero-actions button:focus {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}

.join-link {
  background: linear-gradient(135deg, var(--accent), #9cf7ce);
  color: #0f172a;
  border: none;
  padding: 14px 30px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.join-link::after {
  content: "↗";
  font-size: 1.1em;
}

.section {
  padding: clamp(48px, 8vw, 96px) clamp(24px, 6vw, 120px);
  border-bottom: 1px solid var(--border-color);
  background: var(--landing-bg);
}

.section h2 {
  font-size: 2rem;
  margin-bottom: 12px;
}

.section p.section-lead {
  max-width: 720px;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.6;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.feature-card {
  padding: 24px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.feature-card h3 {
  margin-top: 0;
}

.instruction-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  counter-reset: step;
}

.instruction-step {
  padding: 24px;
  border-radius: 18px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  position: relative;
}

.instruction-step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  top: 18px;
  right: 18px;
  font-weight: 700;
  opacity: 0.25;
  font-size: 2rem;
}

.cta-card {
  padding: 32px;
  background: rgba(178, 102, 255, 0.12);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
}

.site-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

.site-details-card {
  padding: 24px;
  border-radius: 18px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

.site-details-card ul {
  padding-left: 18px;
  margin: 0;
}

.faq {
  display: grid;
  gap: 16px;
}

.faq details {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.35);
}

.site-footer {
  padding: 32px 24px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* spacing for anchor jumps */
section[id] {
  scroll-margin-top: 80px;
}

/* ==============================
   Landing Page
   ============================== */
#username-prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-primary);
  padding: 32px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow);
}

#username-prompt .logo {
  width: 120px;
  height: auto;
  max-height: 80px;
  margin-bottom: 4px;
  object-fit: contain;
}

#username-prompt h1,
#username-prompt h2,
#username-prompt h3 {
  margin: 0;
  color: var(--text-primary);
}




.landing-inputs {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: max(220px);
  gap: 8px;
  margin: 0 auto;
}

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

.landing-inputs input,
.landing-inputs button {
  width: 100%;
}

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

#join-btn {
  margin-top: 4px;
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  width: max(180px)
}

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

#room-list {
  margin-top: 20px;
  width: 100%;
  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:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

#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
   ============================== */
#chat-container > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--toolbar-padding-y) + var(--toolbar-top-extra, 0px))
    var(--toolbar-padding-x) var(--toolbar-padding-y) var(--toolbar-padding-x);
  background: var(--surface);
  background-color: var(--surface);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
  color: var(--text-primary);
  gap: var(--toolbar-gap);
  flex-wrap: wrap;
}
#chat-container > header.toolbar-flash-message {
  animation: toolbarFlashOrange 1.4s ease-in-out 2;
}

#chat-container > 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);
  }
}


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

#chat-container header .logo {
  width: var(--toolbar-logo-size);
  height: var(--toolbar-logo-size);
  max-width: var(--toolbar-logo-size);
  max-height: var(--toolbar-logo-size);
  flex: 0 0 var(--toolbar-logo-size);
  object-fit: contain;
  border-radius: calc(var(--toolbar-logo-size) / 5);
  overflow: hidden;
}

#chat-container header .header-right {
  display: flex;
  align-items: center;
  gap: var(--toolbar-gap);
  padding-left: var(--toolbar-gap);
  margin-left: auto;
  flex-wrap: wrap;
}

.psybin-player {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 4px 6px;
  color: var(--text-primary);
  flex: 0 1 320px;
  min-width: 200px;
}

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

.psybin-player-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.psybin-player-meta {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.78em;
  line-height: 1.4;
  color: var(--text-secondary, rgba(255, 255, 255, 0.72));
  min-height: 1.2em;
  flex: 1 1 auto;
}

.psybin-player-cover {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm, 6px);
  object-fit: cover;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  background: var(--surface, rgba(255, 255, 255, 0.04));
}

.psybin-player-meta[data-state="loading"] .psybin-player-meta-status {
  display: inline-block;
}

.psybin-player-meta-status {
  width: 0.75em;
  height: 0.75em;
  border-radius: 50%;
  border: 2px solid var(--accent, #b266ff);
  border-top-color: transparent;
  display: none;
  animation: psybin-player-spin 0.75s linear infinite;
}

.psybin-player-meta-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.psybin-player-remaining {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary, rgba(255, 255, 255, 0.6));
}

.psybin-player-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.psybin-player-label {
  font-size: 0.8em;
  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: 2px 6px;
  min-height: 26px;
  cursor: pointer;
  font-size: 0.85em;
  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 {
  min-width: 0;
  width: 100%;
  max-width: none;
  flex: 1 1 140px;
  accent-color: var(--accent, #b266ff);
}

@media (max-width: 540px) {
  .psybin-player {
    flex: 1 1 100%;
  }

  .psybin-player-controls {
    gap: 4px;
  }

  .psybin-player-button {
    min-height: 24px;
    padding: 2px 6px;
  }

  .psybin-player-volume {
    flex: 1 1 120px;
  }
}

@keyframes psybin-player-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.stream-modal {
  position: fixed;
  top: 88px;
  left: 20px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  width: min(640px, calc(100vw - 40px));
  height: min(360px, calc(100vh - 180px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  overflow: hidden;
  z-index: 40;
  user-select: none;
}

.stream-modal[hidden] {
  display: none !important;
}

.stream-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-color);
  cursor: grab;
  font-weight: 600;
  letter-spacing: 0.01em;
  touch-action: none;
  flex-wrap: wrap;
}

.stream-modal:active .stream-modal-header,
.stream-modal.dragging .stream-modal-header {
  cursor: grabbing;
}

.stream-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95em;
  flex-wrap: wrap;
  min-width: 0;
}

.stream-modal-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stream-modal-button {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.1em;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease;
}

.stream-modal-button:hover,
.stream-modal-button:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

body:not(.dark) .stream-modal-button:hover,
body:not(.dark) .stream-modal-button:focus-visible {
  background: rgba(0, 0, 0, 0.08);
}

.stream-modal-body {
  position: relative;
  flex: 1;
  background: #000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding-bottom: 24px;
}

.stream-modal-body > * {
  flex: 1 1 auto;
  min-width: 0;
}

#infowars-stream-frame,
#infowars-stream-frame > * {
  width: 100%;
  height: 100%;
}

#infowars-stream-frame .rumble {
  display: flex !important;
  align-items: stretch;
  justify-content: center;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  padding: 0 !important;
  position: relative !important;
}

.stream-modal-body iframe,
#infowars-stream-frame .rumble iframe {
  border: none;
  width: 100% !important;
  height: 100% !important;
  display: block;
  background: #000;
  max-width: none !important;
  max-height: none !important;
}

.stream-resize-handle {
  width: 18px;
  height: 18px;
  background: transparent;
  cursor: nwse-resize;
  border-radius: 4px;
  position: absolute;
  bottom: 6px;
  right: 6px;
  touch-action: none;
}

.stream-resize-handle::before,
.stream-resize-handle::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
}

.stream-resize-handle::before {
  width: 60%;
  height: 2px;
  bottom: 4px;
  right: 2px;
}

.stream-resize-handle::after {
  width: 2px;
  height: 60%;
  bottom: 2px;
  right: 4px;
}

.stream-modal.collapsed {
  height: auto !important;
  min-height: 0;
}

.stream-modal.collapsed .stream-modal-body {
  display: none;
}

.stream-modal.collapsed .stream-modal-header {
  cursor: pointer;
}

#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;
  min-height: 0;
  position: relative;
  background: var(--bg);
}

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

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

#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: var(--room-name-font-size); color: var(--text-primary); }

/* Header buttons */
.header-right button {
  font-size: var(--toolbar-button-font-size);
  margin-left: 0;
  cursor: pointer;
  border-radius: var(--radius);
  padding: var(--toolbar-button-padding-y) var(--toolbar-button-padding-x);
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  background: transparent;
  color: var(--text-primary);
  min-height: var(--toolbar-control-height);
}

.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-density {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--toolbar-button-padding-y);
  min-width: var(--toolbar-icon-button-size);
  width: var(--toolbar-icon-button-size);
  height: var(--toolbar-icon-button-size);
  background: var(--surface-alt);
  border-color: var(--border-color);
}

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

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

.header-right button#toggle-density.is-active {
  background: rgba(187, 134, 252, 0.18);
  border-color: rgba(187, 134, 252, 0.6);
  box-shadow: 0 0 0 1px rgba(187, 134, 252, 0.35);
  color: #f1e7ff;
}

.header-right button#toggle-density.is-active .icon {
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.25));
}

.header-right button#toggle-sounds {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--toolbar-button-padding-y);
  min-width: var(--toolbar-icon-button-size);
  width: var(--toolbar-icon-button-size);
  height: var(--toolbar-icon-button-size);
  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-desktop-notifications[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: var(--toolbar-link-padding-y) var(--toolbar-link-padding-x);
  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;
}

body:not(.dark) .header-right button#toggle-density {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(17, 17, 17, 0.12);
  color: #1f2933;
}

body:not(.dark) .header-right button#toggle-density.is-active {
  background: rgba(123, 47, 247, 0.16);
  border-color: rgba(123, 47, 247, 0.45);
  color: #3b1d75;
}

/* ==============================
   Messages Area
   ============================== */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--messages-padding-y) var(--messages-padding-x);
  padding-bottom: calc(
    var(--messages-padding-y) + var(--input-icon-size) + env(safe-area-inset-bottom)
  );
  display: flex;
  flex-direction: column;
  gap: var(--message-gap);
  scroll-behavior: smooth;
  background: var(--surface-alt);
}

#messages-end-sentinel {
  width: 100%;
  height: 1px;
  flex: 0 0 auto;
  pointer-events: none;
}

.scroll-to-latest[hidden] {
  display: none !important;
}

.scroll-to-latest {
  position: absolute;
  left: 50%;
  bottom: var(--scroll-to-latest-bottom);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--scroll-to-latest-padding-y) var(--scroll-to-latest-padding-x);
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: rgba(17, 17, 17, 0.65);
  color: #fff;
  font-size: var(--scroll-to-latest-font-size);
  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;
}

.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: var(--sidebar-width);
  max-width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border-color);
  padding: var(--sidebar-padding-y) var(--sidebar-padding-x);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--sidebar-gap);
  flex: 0 0 var(--sidebar-width);
  min-width: var(--sidebar-min-width);
}

#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;
}

.sidebar-header-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.user-sidebar-toggle {
  display: none;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-primary);
  font-size: 0.78rem;
  padding: 4px 10px;
  cursor: pointer;
}

#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 .user-filter-toggle {
  border: 1px solid rgba(187, 134, 252, 0.35);
  background: rgba(187, 134, 252, 0.15);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  cursor: pointer;
}

.user-entry .user-filter-toggle.hidden {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.14);
}

.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);
}

.message {
  position: relative;
  max-width: 75%;
  padding: var(--message-padding-y) var(--message-padding-x);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  word-wrap: break-word;
  font-size: var(--message-font-size);
  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(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.22);
}

.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: 8px;
  font-size: var(--message-meta-font-size);
  color: var(--text-muted);
  margin-bottom: 3px;
  padding-right: 30px;
  line-height: 1.15;
}

.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 {
  color: #0f2d1f;
}

body:not(.dark) .message.self .meta {
  color: rgba(15, 45, 31, 0.72);
}

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: 8px;
  margin: 5px 10px 0;
  padding: 7px 10px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--surface-alt) 92%, transparent);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.14);
}

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

#reply-preview .reply-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}

#reply-preview .reply-preview-title {
  font-size: 0.78em;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#reply-preview .reply-preview-text {
  font-size: 0.84em;
  color: var(--text-primary);
  opacity: 0.82;
  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: 1px 0 6px;
  padding: 5px 8px;
  border-left: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.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: 700;
  font-size: 0.78em;
  color: var(--accent);
  line-height: 1.2;
}

.message .reply-context .reply-snippet {
  font-size: 0.84em;
  color: var(--text-primary);
  opacity: 0.82;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.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: 30px;
  right: 6px;
  min-width: 148px;
  max-height: min(280px, calc(100vh - 24px));
  overflow-y: auto;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  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: 7px 10px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  font-size: 0.86em;
  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.has-inline-media {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: min(280px, 100%);
}

.message.has-inline-media .inline-preview {
  width: 100%;
}

.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: 4px;
  padding: 4px;
}

.message.media-only {
  max-width: min(380px, 96%);
}

.message.tenor-only {
  max-width: min(280px, 92%);
}

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

.message.media-only:not(.has-inline-audio) .inline-preview {
  padding: 3px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.message.media-only:not(.has-inline-audio) .inline-preview:hover {
  transform: none;
  box-shadow: none;
}

.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: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.message .reactions .reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 0.78em;
  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: var(--input-padding-y) var(--input-padding-x);
  border-top: 1px solid var(--border-color);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  bottom: 0;
  z-index: 15;
  flex-wrap: wrap;
  gap: 4px;
}

#form.drag-over {
  border-top-color: var(--accent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--surface) 86%, var(--accent) 14%);
}

#quick-emoji-panel {
  display: inline-flex;
  align-items: center;
  gap: var(--quick-emoji-gap);
  margin-left: var(--quick-emoji-margin-left);
  flex-shrink: 0;
}

#quick-emoji-panel:empty {
  display: none;
}

#quick-emoji-panel .quick-emoji-button {
  width: var(--quick-emoji-size);
  height: var(--quick-emoji-size);
  border-radius: var(--radius-sm, 10px);
  border: 1px solid var(--border-color);
  background: var(--surface-alt);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  margin-left: 0;
}

#quick-emoji-panel .quick-emoji-button.quick-emoji-button-image {
  padding: 0;
  font-size: 0;
  overflow: hidden;
}

#quick-emoji-panel .quick-emoji-button.quick-emoji-button-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
  pointer-events: none;
}

body.dark #quick-emoji-panel .quick-emoji-button {
  background: rgba(178, 102, 255, 0.15);
  border-color: rgba(178, 102, 255, 0.35);
  color: #f5f0ff;
}

body:not(.dark) #quick-emoji-panel .quick-emoji-button {
  background: rgba(178, 102, 255, 0.12);
  border-color: rgba(178, 102, 255, 0.3);
  color: #5b21b6;
}

#quick-emoji-panel .quick-emoji-button:hover,
#quick-emoji-panel .quick-emoji-button:focus-visible {
  transform: translateY(-1px) scale(1.05);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(123, 47, 247, 0.18);
}

#quick-emoji-panel .quick-emoji-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#quick-emoji-panel .quick-emoji-button:active {
  transform: scale(0.95);
}

#input {
  flex: 1;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  padding: 0 calc(var(--input-field-padding-x) + 2px);
  box-sizing: border-box;
  height: var(--input-field-height);
  font-size: var(--input-font-size);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
  min-height: var(--input-field-height);
  line-height: 1.2;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

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

#input:focus {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--input-border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

#form button {
  margin-left: 0;
  border: none;
  background: transparent;
  font-size: var(--input-button-font-size);
  cursor: pointer;
  color: var(--text-primary);
  min-width: var(--input-icon-size);
  min-height: var(--input-icon-size);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

#form button:hover {
  transform: scale(1.06);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

#voice-btn {
  position: relative;
  font-size: 1.4em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  min-width: var(--input-icon-size);
}

#voice-btn.recording {
  color: #ff4d6d;
  background: rgba(255, 77, 109, 0.18);
  border-radius: 999px;
  box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.45);
  animation: voice-btn-pulse 1.1s ease-in-out infinite;
}

body:not(.dark) #voice-btn.recording {
  color: #c9184a;
  background: rgba(255, 77, 109, 0.12);
}

#voice-btn.recording:hover,
#voice-btn.recording:focus-visible {
  transform: scale(1.05);
}

#voice-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

#voice-call-btn:not(.call-active) {
  background: #8a2d2d;
  border-color: #d65b5b;
  color: #fff;
}

#voice-call-btn.call-active {
  background: #1f9d55;
  border-color: #43d17a;
  color: #fff;
}

#voice-call-btn.call-muted {
  border-color: #43d17a;
}

#voice-call-btn.call-video-active {
  border-color: #43d17a;
  color: #fff;
}

#jam-session-btn {
  border-color: rgba(250, 204, 21, 0.55);
}

#jam-session-btn:hover,
#jam-session-btn:focus-visible {
  background: rgba(250, 204, 21, 0.18);
}

.voice-call-panel {
  position: fixed;
  right: 14px;
  bottom: 92px;
  z-index: 13000;
  width: min(420px, calc(100vw - 24px));
  background: rgba(18, 22, 28, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
  user-select: none;
}

.voice-call-panel.dragging {
  cursor: grabbing;
  opacity: 0.96;
}

.voice-call-panel[hidden] { display: none !important; }

.voice-call-remote-audio {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  pointer-events: none;
}

.voice-call-header {
  align-items: flex-start;
  cursor: grab;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: -4px -4px 8px;
  padding: 4px;
  touch-action: none;
}

.voice-call-drag-hint {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.75;
  padding: 4px 6px;
}

.voice-call-title { font-weight: 700; font-size: 0.92rem; margin-bottom: 4px; }
.voice-call-status { font-size: 0.84rem; opacity: 0.9; }
.voice-call-music-mode {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.28);
  border-radius: 10px;
  margin-bottom: 8px;
  padding: 8px;
}
.voice-call-music-mode.music-mode-selected {
  border-color: rgba(67, 209, 122, 0.48);
}
.voice-call-music-mode.music-mode-locked {
  opacity: 0.82;
}
.voice-call-music-mode-copy {
  display: grid;
  gap: 3px;
  font-size: 0.78rem;
  line-height: 1.35;
  margin-bottom: 8px;
}
.voice-call-music-mode-copy span { opacity: 0.88; }
.voice-call-music-mode-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.voice-call-music-mode-actions button { flex: 1 1 150px; min-width: 0; }
.voice-call-music-mode-actions button.active {
  background: #1f9d55;
  border-color: #43d17a;
  color: #fff;
}
.voice-call-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.voice-call-controls button { flex: 1 1 42%; min-width: 88px; }
.call-video-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin-top: 10px;
}
.call-video-grid[hidden] { display: none !important; }
.call-video-tile {
  aspect-ratio: 16 / 9;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.call-video-tile-local { border-color: rgba(96, 165, 250, 0.72); }
.call-video-element {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}
.call-video-label {
  background: linear-gradient(90deg, rgba(0,0,0,0.72), rgba(0,0,0,0.08));
  bottom: 0;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 650;
  left: 0;
  overflow: hidden;
  padding: 4px 6px;
  position: absolute;
  right: 0;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}
.voice-call-master-volume { align-items: center; display: flex; gap: 10px; margin-top: 10px; font-size: 0.8rem; }
.voice-call-master-volume span { flex: 0 0 auto; opacity: 0.88; }
.voice-call-master-volume input { flex: 1 1 auto; min-width: 0; }
.voice-call-peers { margin-top: 8px; max-height: 210px; overflow: auto; font-size: 0.8rem; }

.jam-session-panel {
  position: fixed;
  right: 14px;
  bottom: 92px;
  z-index: 13001;
  width: min(560px, calc(100vw - 24px));
  max-height: min(82vh, 760px);
  overflow: auto;
  background: rgba(18, 22, 28, 0.96);
  border: 1px solid rgba(250, 204, 21, 0.32);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
  color: #fff;
  padding: 12px;
}

.jam-session-panel[hidden] { display: none !important; }

.jam-session-header,
.jam-provider-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.jam-session-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.jam-session-status {
  font-size: 0.84rem;
  opacity: 0.9;
}

.jam-session-close {
  flex: 0 0 auto;
  min-width: 34px;
  padding: 5px 8px;
}

.jam-session-providers {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.jam-provider-card {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px;
}

.jam-provider-card.is-unavailable {
  opacity: 0.58;
}

.jam-provider-card button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.jam-provider-head strong { font-size: 0.95rem; }
.jam-provider-head span {
  background: rgba(250, 204, 21, 0.18);
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 999px;
  color: #fde68a;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 7px;
  white-space: nowrap;
}

.jam-provider-card p,
.jam-provider-card li,
.jam-session-output li,
.jam-session-result-meta {
  font-size: 0.82rem;
  line-height: 1.35;
  opacity: 0.9;
}

.jam-provider-card ul,
.jam-session-output ul {
  margin: 8px 0;
  padding-left: 18px;
}

.jam-provider-card button,
.jam-session-open {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  margin-top: 4px;
  text-decoration: none;
}

.jam-session-output {
  background: rgba(250, 204, 21, 0.08);
  border: 1px solid rgba(250, 204, 21, 0.22);
  border-radius: 12px;
  margin-top: 12px;
  padding: 10px;
}

.jam-session-result-title { font-weight: 800; }

.jam-session-code {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 72px 1fr auto;
  margin-top: 8px;
}

.jam-session-code span { font-size: 0.78rem; opacity: 0.8; }
.jam-session-code code {
  background: rgba(0, 0, 0, 0.28);
  border-radius: 8px;
  overflow: hidden;
  padding: 6px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jam-session-command code {
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.jam-session-open {
  background: #facc15;
  border-radius: 9px;
  color: #1f2937;
  font-weight: 800;
  padding: 8px 10px;
}


.jam-session-steps {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.jam-session-step {
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  display: grid;
  gap: 10px;
  grid-template-columns: 30px minmax(0, 1fr);
  padding: 10px;
}

.jam-session-step-number {
  align-items: center;
  background: #facc15;
  border-radius: 50%;
  color: #1f2937;
  display: inline-flex;
  font-size: 0.8rem;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.jam-session-step strong,
.jam-session-credentials > strong,
.jam-session-device-note > strong {
  font-size: 0.88rem;
}

.jam-session-step p,
.jam-session-credentials p,
.jam-session-device-note p,
.jam-session-advanced p {
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 4px 0 7px;
  opacity: 0.84;
}

.jam-session-command-card {
  align-items: stretch;
  display: grid;
  gap: 7px;
  margin-top: 7px;
}

.jam-session-command-card code {
  background: rgba(0, 0, 0, 0.32);
  border-radius: 8px;
  display: block;
  font-size: 0.74rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  padding: 8px;
  white-space: normal;
}

.jam-session-command-card button {
  justify-self: start;
}

.jam-session-credentials,
.jam-session-device-note {
  background: rgba(250, 204, 21, 0.08);
  border: 1px solid rgba(250, 204, 21, 0.18);
  border-radius: 11px;
  margin-top: 12px;
  padding: 10px;
}

.jam-session-advanced {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin-top: 12px;
  padding-top: 10px;
}

.jam-session-advanced summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 750;
  opacity: 0.86;
}

.jam-session-advanced[open] summary {
  margin-bottom: 8px;
}

.jam-session-advanced .jam-session-code {
  grid-template-columns: 78px 1fr auto;
}

.jam-session-advanced .jam-session-command {
  grid-template-columns: 78px minmax(0, 1fr) auto;
}

.voice-peer-empty { opacity: 0.72; padding: 8px 4px 2px; }
.voice-peer-row { padding: 7px 8px; border-radius: 8px; background: rgba(255,255,255,0.06); margin-top: 6px; }
.voice-peer-row-local { background: rgba(124, 77, 255, 0.18); }
.voice-peer-header { align-items: center; display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.voice-peer-name-group { align-items: center; display: flex; gap: 6px; min-width: 0; }
.voice-peer-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-peer-video-badge {
  background: rgba(37, 99, 235, 0.28);
  border: 1px solid rgba(96, 165, 250, 0.58);
  border-radius: 999px;
  color: #dbeafe;
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
}
.voice-peer-level { flex: 0 0 auto; font-variant-numeric: tabular-nums; opacity: 0.78; }
.voice-peer-meter { background: rgba(255, 255, 255, 0.14); border-radius: 999px; height: 7px; overflow: hidden; }
.voice-peer-meter-fill { background: linear-gradient(90deg, #45d483, #ffe066, #ff6b6b); border-radius: inherit; height: 100%; min-width: 0; transition: width 120ms ease; }
.voice-peer-controls { align-items: center; display: flex; gap: 8px; margin-top: 7px; }
.voice-peer-controls button { flex: 0 0 auto; min-width: 74px; padding: 5px 8px; }
.voice-peer-volume { align-items: center; display: flex; flex: 1 1 auto; gap: 6px; min-width: 0; opacity: 0.9; }
.voice-peer-volume input { flex: 1 1 auto; min-width: 0; }

@media (max-width: 480px) {
  .voice-call-panel,
  .jam-session-panel {
    bottom: 76px;
    width: calc(100vw - 20px);
  }
  .call-video-grid {
    grid-template-columns: 1fr;
    max-height: 36vh;
  }
}

@keyframes voice-btn-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.45);
  }
  100% {
    transform: scale(1.08);
    box-shadow: 0 0 0 8px rgba(255, 77, 109, 0);
  }
}

.voice-recording-modal {
  position: absolute;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  width: min(280px, calc(100% - 32px));
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: var(--surface-alt, var(--surface));
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 25;
}

.voice-recording-modal.visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.voice-recording-modal[hidden] {
  display: none;
}

.voice-recording-modal.finishing {
  cursor: progress;
}

.voice-recording-status {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.voice-meter {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

body:not(.dark) .voice-meter {
  background: rgba(0, 0, 0, 0.06);
}

.voice-meter-fill {
  --level: 0;
  height: 100%;
  width: calc(var(--level) * 100%);
  border-radius: inherit;
  background: linear-gradient(90deg, #4fc3f7, #1e88e5);
  transition: width 0.12s ease-out;
}

.voice-recording-timer {
  font-family: "SFMono-Regular", "Roboto Mono", "Fira Code", monospace;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  text-align: center;
}

.voice-recording-controls {
  display: flex;
  gap: 10px;
}

.voice-recording-controls button {
  flex: 1;
  padding: 8px 12px;
  border-radius: 999px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.voice-recording-controls button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.voice-recording-controls button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.voice-recording-modal.finishing .voice-recording-controls button,
.voice-recording-controls button:disabled {
  opacity: 0.6;
  pointer-events: none;
  box-shadow: none;
  transform: none;
}

.voice-recording-finish {
  background: var(--accent);
  color: #fff;
}

body:not(.dark) .voice-recording-finish {
  color: #fff;
}

.voice-recording-cancel {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

#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;
}

#soundboard-btn {
  font-size: 1.05em;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--surface-alt);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

#soundboard-btn .soundboard-icon {
  font-size: 1.2em;
  line-height: 1;
}

body.dark #soundboard-btn {
  background: rgba(187, 134, 252, 0.22);
  border-color: rgba(187, 134, 252, 0.45);
  color: #f5f0ff;
}

body:not(.dark) #soundboard-btn {
  background: rgba(187, 134, 252, 0.12);
  border-color: rgba(187, 134, 252, 0.3);
  color: #5b21b6;
}

#soundboard-btn:hover,
#soundboard-btn:focus-visible {
  background: #b266ff;
  color: #ffffff;
  border-color: #8c3edd;
  box-shadow: 0 0 12px rgba(187, 134, 252, 0.45);
  transform: scale(1.08);
}

#soundboard-btn:focus-visible {
  outline: 2px solid rgba(187, 134, 252, 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(-1px);
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.18);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border-color));
}

.inline-preview.inline-image {
  width: min(360px, 100%);
  padding: 6px;
  gap: 5px;
}

.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;
  max-height: min(480px, 62vh);
  object-fit: contain;
  border-radius: 10px;
}

.inline-preview.tenor-inline {
  width: min(260px, 100%);
  padding: 5px;
  gap: 5px;
}

.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;
  max-height: min(360px, 52vh);
  object-fit: contain;
  border-radius: 10px;
}

.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);
}

/* Compact chat-style audio cards for uploads, voice messages and soundboards. */
.message.has-inline-media.has-inline-audio {
  min-width: 0;
  max-width: min(490px, 96%);
}

.message.media-only.has-inline-video {
  max-width: min(460px, 94%);
}

.message.media-only.has-inline-audio {
  max-width: min(470px, 96%);
}

.message.has-inline-audio .inline-preview.inline-audio {
  width: min(440px, 100%);
  margin-top: 4px;
  padding: 8px 10px;
  gap: 6px;
  border-radius: 18px;
}

.inline-preview.inline-audio:hover {
  transform: none;
}

.inline-preview.inline-audio .preview-media {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-sizing: border-box;
  justify-content: stretch;
  align-items: stretch;
}

@media (hover: hover) and (pointer: fine) {
  .message.has-inline-media.has-inline-audio {
    width: min(410px, 94%);
    max-width: min(430px, 94%);
  }

  .message.media-only.has-inline-audio {
    width: min(410px, 94%);
    max-width: min(430px, 94%);
  }

  .message.has-inline-audio .inline-preview.inline-audio {
    width: 100%;
  }

  .inline-preview.inline-audio .preview-media {
    justify-items: start;
  }

  .inline-preview.inline-audio .preview-media audio {
    width: min(440px, 100%);
  }

  .inline-preview.inline-audio .audio-waveform {
    width: 100%;
    box-sizing: border-box;
  }
}

.inline-preview.inline-audio .preview-media audio {
  display: block;
  width: 100%;
  min-width: 0;
  height: 42px;
}

.audio-waveform {
  --wave-progress: 0%;
  order: -1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 42px;
  padding: 5px 8px;
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--border-color) 74%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.audio-waveform:hover {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--border-color));
}

.audio-waveform:active {
  cursor: grabbing;
}

.audio-waveform:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 82%, white);
  outline-offset: 2px;
}

.audio-waveform-bar {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 1px;
  max-width: 5px;
  height: var(--wave-height, 42%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 72%, transparent);
  opacity: 0.52;
  transform-origin: center;
  transition: height 0.18s ease, background 0.12s ease, opacity 0.12s ease;
  pointer-events: none;
}

.audio-waveform[data-waveform-source="decoded"] .audio-waveform-bar {
  opacity: 0.66;
}

.audio-waveform-bar.is-played {
  background: var(--accent);
  opacity: 1;
}

.audio-waveform-playhead {
  position: absolute;
  z-index: 2;
  top: 4px;
  bottom: 4px;
  left: var(--wave-progress);
  width: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 88%, white);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.24), 0 0 8px color-mix(in srgb, var(--accent) 55%, transparent);
  transform: translateX(-1px);
  pointer-events: none;
  opacity: 0.82;
}

.audio-waveform[data-playing="1"] .audio-waveform-playhead {
  animation: audio-wave-playhead-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes audio-wave-playhead-pulse {
  from { opacity: 0.72; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .audio-waveform[data-playing="1"] .audio-waveform-playhead {
    animation: none;
  }

  .audio-waveform-bar {
    transition: none;
  }
}

.message.has-soundboard-audio .text:not(:empty) {
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
}

.inline-preview.inline-audio .preview-actions {
  margin-top: 0;
  gap: 4px;
  justify-content: flex-end;
}

.inline-preview.inline-audio .preview-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 84px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1;
}

/* Video previews get enough room for native controls without becoming huge. */
.inline-preview.inline-video {
  width: min(440px, 100%);
  padding: 6px;
  gap: 6px;
}

.inline-preview.inline-video .preview-media {
  min-height: 0;
  aspect-ratio: 16 / 9;
  background: #000;
}

.inline-preview.inline-video .preview-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Embedded players need a real desktop width so iframe controls remain usable. */
.message.has-inline-embed {
  width: min(500px, 94%);
  max-width: min(520px, 94%);
}

.message.has-inline-embed .embed-wrap {
  width: min(480px, 100%);
}

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

.embed-iframe {
  display: block;
  width: min(480px, 100%);
  max-width: 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.youtube,
.embed-iframe.rumble,
.embed-iframe.facebook {
  width: 100%;
  max-width: none;
  height: auto;
  aspect-ratio: 16 / 9;
}

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

.link-card {
  background: color-mix(in srgb, var(--surface-alt) 86%, transparent);
  border: 1px solid var(--border-color);
  border-radius: 13px;
  padding: 9px;
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 7px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.link-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-color));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

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

.link-card .link-thumb {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  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: 3px;
  flex: 1;
  min-width: 0;
}

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

.link-card .link-title {
  font-weight: 650;
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-card .link-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.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); } }

/* ==============================
   Mobile Layout
   ============================== */
@media (max-width: 768px) {
  .message.has-inline-embed {
    width: 96%;
    max-width: 96%;
  }

  .message.has-inline-embed .embed-wrap,
  .embed-iframe.youtube,
  .embed-iframe.rumble,
  .embed-iframe.facebook {
    width: 100%;
    max-width: 100%;
  }

  .message.has-inline-audio {
    max-width: 92%;
  }

  :root {
    --toolbar-control-height: 36px;
    --toolbar-button-padding-y: 4px;
    --toolbar-button-padding-x: 10px;
    --toolbar-button-font-size: 0.9em;
    --toolbar-icon-button-size: 34px;
    --toolbar-link-padding-y: 6px;
    --toolbar-link-padding-x: 10px;
  }

  #chat-container {
    padding-left: 10px;
    padding-right: 10px;
  }

  #chat-container > header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: nowrap;
  }

  #chat-container header .header-left {
    width: auto;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
    min-width: 0;
  }

  #chat-container header .header-left #room-name {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 30vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #chat-container header .header-right {
    width: auto;
    display: flex;
    gap: 3px;
    align-items: center;
    margin-left: auto;
    padding-left: 0;
    flex-wrap: nowrap;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  #chat-container header .header-right::-webkit-scrollbar {
    display: none;
  }

  #chat-container .search-bar {
    width: min(30vw, 150px);
    margin-left: 0;
    flex-direction: row;
    align-items: center;
    gap: 3px;
    min-width: 104px;
    flex: 0 1 auto;
  }

  #chat-container .search-bar input,
  #chat-container .search-bar select {
    width: auto;
    min-width: 0;
  }

  #chat-container .header-right button {
    width: auto;
    justify-content: center;
    min-height: var(--toolbar-control-height);
    flex: 0 0 auto;
  }

  #chat-main {
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
  }

  #chat-content {
    order: 0;
  }

  #user-sidebar {
    order: 2;
    width: 100%;
    max-width: none;
    border-left: none;
    border-top: 1px solid var(--border-color);
    min-width: 0;
    flex: 0 0 auto;
    gap: 8px;
  }

  .user-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #user-sidebar #user-list,
  #user-sidebar #user-list-empty {
    display: none;
  }

  #user-sidebar.is-expanded #user-list {
    display: flex;
    max-height: 150px;
  }

  #user-sidebar.is-expanded #user-list-empty {
    display: block;
  }

  #user-sidebar.is-expanded .user-sidebar-toggle {
    background: rgba(178, 102, 255, 0.18);
    border-color: rgba(178, 102, 255, 0.45);
  }

  #form {
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: calc(var(--input-padding-y) + env(safe-area-inset-bottom));
  }

  #form button {
    margin-left: 0;
  }

  #input {
    flex: 1 1 100%;
    min-width: 0;
  }

  #quick-emoji-panel {
    flex: 1 1 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  #emoji-picker {
    position: fixed;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(420px, calc(100% - 20px));
    bottom: calc(90px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  #chat-container {
    padding-left: 8px;
    padding-right: 8px;
  }

  #chat-container > header {
    gap: 8px;
  }

  #chat-container .search-bar {
    width: 104px;
    min-width: 92px;
  }

  #reply-preview {
    margin-left: 6px;
    margin-right: 6px;
  }

  .message.media-only {
    max-width: 96%;
  }

  .inline-preview.inline-image,
  .inline-preview.inline-video,
  .inline-preview.tenor-inline {
    max-width: calc(100vw - 34px);
  }

  #chat-container .header-right #copy-join-link .label {
    display: none;
  }

  #chat-container header .logo {
    width: 32px;
    height: 32px;
  }

  #chat-main {
    gap: 10px;
  }

  #username-prompt {
    padding: 24px 16px;
    gap: 14px;
  }
}

/* ==============================
   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 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: calc(70px + env(safe-area-inset-bottom));
  left: max(10px, env(safe-area-inset-left));
  width: min(340px, calc(100vw - 20px));
  max-height: min(320px, calc(100vh - 120px));
  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 .gif-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
  overflow-x: auto;
}
#gif-picker .gif-tab {
  appearance: none;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  color: rgba(255,255,255,0.78);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 5px 8px;
  white-space: nowrap;
}
#gif-picker .gif-tab.active,
#gif-picker .gif-tab:hover,
#gif-picker .gif-tab:focus-visible {
  background: linear-gradient(135deg, rgba(187,134,252,0.42), rgba(3,218,198,0.2));
  border-color: rgba(187,134,252,0.7);
  color: #fff;
}
#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-loading,
#gif-picker .gif-error {
  grid-column: 1 / -1;
  padding: 9px 10px;
  border: 1px solid rgba(187,134,252,0.24);
  border-radius: 9px;
  background: rgba(187,134,252,0.06);
  color: rgba(255,255,255,0.82);
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: center;
}

#gif-picker .gif-error {
  border-color: rgba(244,67,54,0.38);
  background: rgba(244,67,54,0.08);
  color: #ffbdb6;
}
#gif-picker .gif-tile {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  position: relative;
}
#gif-picker .gif-tile-sticker,
#gif-picker .gif-tile-emoji,
#gif-picker .gif-tile-text {
  background: repeating-conic-gradient(rgba(255,255,255,0.08) 0% 25%, rgba(255,255,255,0.02) 0% 50%) 50% / 14px 14px;
}
#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-tile:hover .gif-thumb,
#gif-picker .gif-tile:focus-visible .gif-thumb {
  transform: translateY(-2px);
  box-shadow: 0 0 8px rgba(187,134,252,0.45);
}
#gif-picker .gif-badge {
  background: rgba(3,218,198,0.9);
  border-radius: 999px;
  bottom: 5px;
  color: #071311;
  font-size: 0.62rem;
  font-weight: 900;
  padding: 2px 6px;
  position: absolute;
  right: 5px;
  text-transform: uppercase;
}
#gif-picker .gif-attribution {
  color: rgba(255,255,255,0.7);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-top: 8px;
  text-align: right;
  text-transform: uppercase;
}

#soundboard-picker {
  position: fixed;
  bottom: 70px;
  left: 10px;
  width: 340px;
  max-height: 320px;
  display: none;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(187,134,252,0.25);
  box-shadow: 0 0 10px rgba(187,134,252,0.3);
  background: rgba(20,20,20,0.95);
  z-index: 1000;
}

.soundboard-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin-bottom: 8px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(187,134,252,0.16);
}

.soundboard-mode-tab {
  flex: 1 1 0;
  border: 0;
  border-radius: 7px;
  padding: 6px 10px;
  background: transparent;
  color: rgba(245,240,255,0.68);
  font-weight: 750;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.soundboard-mode-tab.active {
  background: rgba(123,47,247,0.72);
  color: #fff;
  box-shadow: 0 2px 8px rgba(123,47,247,0.28);
}

.soundboard-mode-tab[hidden] {
  display: none !important;
}

#soundboard-picker .soundboard-search input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #111;
  color: #fff;
  margin-bottom: 8px;
}

#soundboard-picker .soundboard-import {
  margin-bottom: 10px;
  padding: 9px;
  border: 1px solid rgba(187,134,252,0.3);
  border-radius: 10px;
  background: rgba(187,134,252,0.08);
}

#soundboard-picker .soundboard-import[hidden] {
  display: none !important;
}

.soundboard-import-title {
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #d8c1ff;
}

.soundboard-import-row {
  display: flex;
  gap: 6px;
}

#soundboard-import-url {
  min-width: 0;
  flex: 1;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #111;
  color: #fff;
  font-size: 0.78rem;
}

#soundboard-import-btn,
#soundboard-rebuild-btn {
  flex: 0 0 auto;
  border: 1px solid rgba(187,134,252,0.45);
  border-radius: 8px;
  padding: 7px 10px;
  background: rgba(123,47,247,0.7);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.soundboard-import-row--secondary {
  margin-top: 6px;
}

#soundboard-rebuild-btn {
  width: 100%;
  background: rgba(73,46,114,0.78);
}

#soundboard-import-btn:disabled,
#soundboard-rebuild-btn:disabled,
#soundboard-import-url:disabled {
  opacity: 0.55;
  cursor: wait;
}

.soundboard-import-status {
  min-height: 0;
  margin-top: 6px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: rgba(240,240,255,0.82);
}

.soundboard-import-status:empty {
  display: none;
}

.soundboard-import-status[data-tone="complete"] {
  color: #9ee6b8;
}

.soundboard-import-status[data-tone="warn"] {
  color: #ffe9a6;
}

.soundboard-import-status[data-tone="error"] {
  color: #ffbdb6;
}

body:not(.dark) .soundboard-mode-tabs {
  background: rgba(123,47,247,0.06);
  border-color: rgba(123,47,247,0.15);
}

body:not(.dark) .soundboard-mode-tab {
  background: transparent;
  color: #5d4384;
}

body:not(.dark) .soundboard-mode-tab.active {
  background: #fff;
  color: #24104c;
  box-shadow: 0 2px 8px rgba(75,42,126,0.12);
}

body:not(.dark) #soundboard-picker .soundboard-import {
  background: rgba(123,47,247,0.06);
  border-color: rgba(123,47,247,0.2);
}

body:not(.dark) .soundboard-import-title,
body:not(.dark) .soundboard-import-status {
  color: #4a287f;
}

body:not(.dark) #soundboard-import-url {
  background: #fff;
  color: #24104c;
  border-color: rgba(123,47,247,0.25);
}

#soundboard-picker .soundboard-results {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  gap: 6px;
  max-height: 250px;
  overflow-y: auto;
}

.soundboard-web-header,
.soundboard-web-board,
.soundboard-web-clip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.soundboard-web-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 6px;
  background: rgba(20,20,20,0.98);
}

.soundboard-web-heading {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #efe7ff;
  font-size: 0.78rem;
  font-weight: 800;
}

.soundboard-web-board,
.soundboard-web-clip {
  padding: 7px 8px;
  border: 1px solid rgba(187,134,252,0.18);
  border-radius: 10px;
  background: rgba(30,30,30,0.72);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.soundboard-web-board .soundboard-item-content {
  flex: 1 1 auto;
}

.soundboard-web-clip-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f5f0ff;
  font-size: 0.84rem;
}

.soundboard-web-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.soundboard-web-action {
  border: 1px solid rgba(187,134,252,0.35);
  border-radius: 7px;
  padding: 5px 7px;
  background: rgba(73,46,114,0.64);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
  min-width: 32px;
  min-height: 30px;
}

.soundboard-web-action--primary {
  background: rgba(123,47,247,0.75);
}

.soundboard-web-action:disabled {
  opacity: 0.55;
  cursor: wait;
}

.soundboard-web-note {
  padding: 5px 2px;
  color: rgba(240,240,255,0.68);
  font-size: 0.7rem;
}

.soundboard-web-board:hover,
.soundboard-web-clip:hover,
.soundboard-web-clip:focus-visible {
  background: rgba(123,47,247,0.16);
  border-color: rgba(187,134,252,0.42);
}

.soundboard-web-clip:focus-visible {
  outline: 2px solid rgba(178,102,255,0.5);
  outline-offset: 2px;
}

.soundboard-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid rgba(187,134,252,0.2);
  background: rgba(30,30,30,0.78);
  color: #f5f0ff;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.soundboard-item:hover,
.soundboard-item:focus-visible {
  background: rgba(123,47,247,0.28);
  border-color: rgba(187,134,252,0.5);
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  transform: translateY(-1px);
}

.soundboard-item:focus-visible {
  outline: 2px solid rgba(178,102,255,0.55);
  outline-offset: 2px;
}

.soundboard-item-icon {
  font-size: 1.2em;
  line-height: 1;
}

.soundboard-item-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.soundboard-item-title {
  font-weight: 600;
  font-size: 0.95em;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.soundboard-item-meta {
  font-size: 0.75em;
  color: rgba(240, 240, 255, 0.75);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.soundboard-status {
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid rgba(187,134,252,0.24);
  background: rgba(187,134,252,0.06);
  text-align: center;
  font-size: 0.8em;
  line-height: 1.35;
  color: #e0d7ff;
}

.soundboard-status--loading {
  border-style: solid;
  border-color: rgba(187,134,252,0.45);
  background: rgba(187,134,252,0.12);
}

.soundboard-status--error {
  border-color: rgba(244,67,54,0.5);
  color: #ffbdb6;
}

.soundboard-status--warn {
  border-color: rgba(255,193,7,0.55);
  color: #ffe9a6;
}

body:not(.dark) #soundboard-picker {
  background: rgba(248,248,255,0.98);
  border-color: rgba(123,47,247,0.2);
  box-shadow: 0 0 10px rgba(123,47,247,0.2);
}

body:not(.dark) #gif-picker {
  background: rgba(248,248,255,0.98);
  border-color: rgba(123,47,247,0.2);
  box-shadow: 0 8px 24px rgba(57,34,107,0.16);
}

body:not(.dark) #gif-picker input {
  background: #fff;
  color: #24104c;
  border-color: rgba(123,47,247,0.22);
}

body:not(.dark) #gif-picker .gif-tab {
  background: rgba(123,47,247,0.06);
  border-color: rgba(123,47,247,0.14);
  color: #5d4384;
}

body:not(.dark) #gif-picker .gif-tab.active,
body:not(.dark) #gif-picker .gif-tab:hover,
body:not(.dark) #gif-picker .gif-tab:focus-visible {
  background: rgba(123,47,247,0.16);
  border-color: rgba(123,47,247,0.36);
  color: #24104c;
}

body:not(.dark) #gif-picker .gif-loading {
  color: #4a287f;
  background: rgba(123,47,247,0.05);
}

body:not(.dark) #gif-picker .gif-error {
  color: #9f2e27;
  background: rgba(244,67,54,0.06);
}

body:not(.dark) #gif-picker .gif-attribution {
  color: rgba(57,34,107,0.68);
}

body:not(.dark) .soundboard-web-header {
  background: rgba(248,248,255,0.99);
}

body:not(.dark) .soundboard-web-heading,
body:not(.dark) .soundboard-web-clip-title {
  color: #39226b;
}

body:not(.dark) .soundboard-web-board,
body:not(.dark) .soundboard-web-clip {
  background: rgba(247,240,255,0.88);
  border-color: rgba(123,47,247,0.22);
}

body:not(.dark) .soundboard-web-action {
  background: rgba(123,47,247,0.12);
  color: #39226b;
}

body:not(.dark) .soundboard-web-action--primary {
  background: rgba(123,47,247,0.22);
}

body:not(.dark) .soundboard-web-note {
  color: rgba(57,34,107,0.68);
}

body:not(.dark) .soundboard-item {
  background: rgba(247,240,255,0.9);
  color: #39226b;
  border-color: rgba(123,47,247,0.25);
}

body:not(.dark) .soundboard-item-meta {
  color: rgba(57,34,107,0.7);
}

body:not(.dark) .soundboard-item:hover,
body:not(.dark) .soundboard-item:focus-visible {
  background: rgba(123,47,247,0.18);
  color: #24104c;
  box-shadow: 0 0 10px rgba(123,47,247,0.25);
}

body:not(.dark) .soundboard-status {
  color: #39226b;
  border-color: rgba(123,47,247,0.25);
}

body:not(.dark) .soundboard-status--loading {
  background: rgba(123,47,247,0.08);
}

/* 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;
}

/* Watch2Gether watch-party launcher */
.header-right button#watch-party-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--toolbar-link-padding-y) var(--toolbar-link-padding-x);
  background: linear-gradient(120deg, rgba(123, 47, 247, 0.22), rgba(236, 72, 153, 0.18));
  border-color: rgba(187, 134, 252, 0.45);
  color: var(--text-primary);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  line-height: 1.1;
}

.header-right button#watch-party-btn .icon {
  font-size: 1.1em;
  line-height: 1;
}

.header-right button#watch-party-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(236, 72, 153, 0.25);
}

.header-right button#watch-party-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

body:not(.dark) .header-right button#watch-party-btn {
  background: linear-gradient(120deg, rgba(123, 47, 247, 0.12), rgba(236, 72, 153, 0.1));
  border-color: rgba(123, 47, 247, 0.24);
  color: #3b0764;
}

#watch-party-panel {
  position: fixed;
  display: none;
  max-width: calc(100vw - 20px);
  padding: 14px;
  border: 1px solid rgba(187, 134, 252, 0.35);
  border-radius: 16px;
  background: rgba(18, 18, 24, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.35), 0 0 18px rgba(187, 134, 252, 0.24);
  color: #f5f0ff;
  z-index: 1700;
}

.watch-party-panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.watch-party-panel-header strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.watch-party-panel-header p,
.watch-party-help {
  margin: 0;
  color: rgba(245, 240, 255, 0.72);
  font-size: 0.82rem;
  line-height: 1.35;
}

.watch-party-close {
  align-self: flex-start;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 30px;
  height: 30px;
  cursor: pointer;
}

.watch-party-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  color: rgba(245, 240, 255, 0.86);
  font-size: 0.85rem;
  font-weight: 600;
}

.watch-party-field input {
  width: 100%;
  border: 1px solid rgba(187, 134, 252, 0.3);
  border-radius: 10px;
  padding: 9px 10px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  outline: none;
}

.watch-party-field input:focus {
  border-color: rgba(236, 72, 153, 0.8);
  box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.16);
}

.watch-party-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 10px;
}

.watch-party-actions button,
.watch-party-card-actions button,
.watch-party-card-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(187, 134, 252, 0.35);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.watch-party-actions .watch-party-create,
.watch-party-card-actions .watch-party-join {
  background: linear-gradient(120deg, #7b2ff7, #ec4899);
  border-color: transparent;
}

.watch-party-actions button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.watch-party-card {
  margin: 10px 0;
  padding: 14px;
  border: 1px solid rgba(236, 72, 153, 0.32);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(123, 47, 247, 0.18), rgba(236, 72, 153, 0.12));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  color: var(--text-primary);
}

.watch-party-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.watch-party-card-title {
  font-weight: 700;
  margin-bottom: 3px;
}

.watch-party-card-meta,
.watch-party-source {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.watch-party-source {
  display: inline-block;
  margin-top: 6px;
}

.watch-party-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 640px) {
  #chat-container .header-right #watch-party-btn .label {
    display: none;
  }

  .watch-party-actions,
  .watch-party-card-actions {
    flex-direction: column;
  }
}


/* Auth v2 landing */
.auth-v2-landing {
  width: min(720px, calc(100vw - 32px));
  gap: 14px;
}

.auth-choice-heading,
.auth-section-heading {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
}

.auth-choice-heading > div,
.auth-section-heading > div {
  min-width: 0;
}

.auth-choice-heading h2,
.auth-choice-heading p,
.auth-section-heading h2,
.auth-section-heading p {
  margin: 0;
}

.auth-choice-heading p,
.auth-section-heading p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.auth-step-number {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-alt));
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border-color));
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 800;
}

.room-entry-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface-alt);
  box-sizing: border-box;
  transition: opacity 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.room-entry-card.is-locked {
  opacity: 0.48;
  background: color-mix(in srgb, var(--surface-alt) 78%, transparent);
}

.room-entry-card.is-locked input,
.room-entry-card.is-locked button,
.room-entry-card.is-locked .public-room-item {
  cursor: not-allowed;
}

.room-entry-card.is-unlocked {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border-color));
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}

.auth-field > span {
  color: var(--text-primary);
  font-size: 0.76rem;
  font-weight: 700;
}

.auth-field > span small {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.auth-entry-card--primary {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border-color));
}

.auth-entry-card.is-selected {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--border-color));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 10%, transparent);
}

.auth-entry-status {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.room-join-btn {
  width: min(420px, 100%);
  align-self: center;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #07130c;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.room-join-btn:disabled {
  background: color-mix(in srgb, var(--text-muted) 38%, var(--surface));
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 1;
}

.room-join-btn:not(:disabled):hover {
  opacity: 0.9;
}

.room-entry-card #room-list {
  width: 100%;
  margin-top: 2px;
}

.room-entry-card #room-list h3 {
  margin: 0 0 8px;
}

.room-entry-fields {
  display: grid;
  width: min(420px, 100%);
  gap: 8px;
}

.auth-entry-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.auth-entry-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface-alt);
  box-sizing: border-box;
}

.auth-entry-card h2, .auth-entry-card p { margin: 0; }
.auth-entry-card p { color: var(--text-muted); font-size: 0.82rem; line-height: 1.4; }
.auth-entry-card input, .auth-entry-card button, .room-entry-fields input { width: 100%; box-sizing: border-box; }
.auth-entry-card button {
  margin-top: auto;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #07130c;
  font-weight: 700;
  cursor: pointer;
}
.auth-entry-status { min-height: 1.2em; }
.auth-v2-landing [hidden] { display: none !important; }
.auth-entry-grid:has(#guest-login[hidden]) {
  grid-template-columns: 1fr;
  max-width: 420px;
}
#lobby-account-logout-btn {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.account-identity { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

@media (max-width: 720px) {
  .auth-v2-landing { width: min(100%, calc(100vw - 24px)); }
  .auth-entry-grid { grid-template-columns: 1fr; }
  .auth-entry-card,
  .room-entry-card { padding: 12px; }
  .auth-choice-heading,
  .auth-section-heading { gap: 8px; }
}

/* Account-only recent-room shortcuts. Names are text nodes; no passwords are stored. */
.recent-rooms-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--surface-alt);
}
.recent-rooms-panel[hidden] { display: none !important; }
.recent-rooms-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.recent-rooms-heading h3 { margin: 0; font-size: 0.96rem; }
.recent-rooms-panel > p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}
.recent-rooms-clear {
  border: 1px solid var(--border-color);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-primary);
  padding: 7px 10px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.recent-rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.recent-rooms-list li { min-width: 0; }
.recent-room-choice {
  width: 100%;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  text-align: left;
  min-width: 0;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
}
.recent-room-choice:hover,
.recent-rooms-clear:hover { border-color: var(--accent); }
.recent-room-choice:focus-visible,
.recent-rooms-clear:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.recent-room-name {
  overflow-wrap: anywhere;
  font-weight: 700;
}
.recent-room-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
}
