* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overflow-y: auto;
  font-family: Arial, sans-serif;
  color: #ffffff;
}

body {
  margin: 0;
  padding: 0;
  background-image: url("../bilder/saturn.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.app-shell {
  max-width: none;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 10px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.header-panel {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
  border-radius: 16px;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.rsp-chat-header-player {
  width: 70% !important;
  min-width: 280px;
  max-width: 900px;
  flex: 1 1 70% !important;
  display: flex;
  align-items: center;
}

.toggle-online-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.main-layout {
  display: flex;
  gap: 15px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.online-panel {
  width: 260px;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 15px;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.online-panel.collapsed {
  width: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
}

.online-title {
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #333;
}

.online-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.online-item {
  padding: 8px 10px;
  border-radius: 8px;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  display: inline-block;
}

.chat-panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-window {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.message-row {
  display: flex;
}

.message-row.self {
  justify-content: flex-end;
}

.message-row.other {
  justify-content: flex-start;
}

.message-bubble {
  flex: 1 1 auto;
  width: 100%;
  max-width: none !important;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255,255,255,0.1);
  color: #ffffff;
  display: block;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.message-meta {
  display: flex;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 0.75rem;
  color: #aaa;
}

.message-text {
  word-wrap: break-word;
  line-height: 1.4;
}

.system-note {
  text-align: center;
  color: #aaa;
  font-size: 0.8rem;
  padding: 10px;
}

.input-panel {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
  border-radius: 16px;
  padding: 15px;
}

.message-form {
  align-items: flex-end;
}

#messageInput {
  flex: 1;
  background: rgba(0,0,0,0.5);
  border: 1px solid #333;
  color: #fff;
  font-family: inherit;
  resize: vertical;
}

#messageInput:focus {
  outline: none;
  border-color: #2d6cdf;
}

.icon-btn {
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.icon-btn:hover {
  transform: translateY(-1px);
}

.send-icon-btn {
  background: #2d6cdf;
  border-color: transparent;
}

.send-icon-btn:hover {
  background: #3f7ae4;
}

.emoji-picker {
  position: fixed;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  backdrop-filter: blur(10px);
}

.emoji-option {
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-size: 1.2rem;
  cursor: pointer;
}

.emoji-option:hover {
  background: rgba(255,255,255,0.2);
}

.notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
  border-radius: 10px;
  padding: 10px 18px;
  transform: translateX(400px);
  transition: transform 0.3s;
  z-index: 2000;
}

.notification.show {
  transform: translateX(0);
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #333;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #2d6cdf;
  border-radius: 3px;
}

@media (max-width: 768px) {
    .app-shell {
  padding: 10px;
}

    .main-layout {
  flex-direction: column;
}

    .online-panel {
  width: 100%;
  order: 2;
}

    .message-form {
  flex-direction: column;
}

    .form-actions {
  justify-content: space-between;
}

    .message-bubble {
  max-width: 85%;
}

}

@media (min-width: 1200px) {
    .message-bubble {
  max-width: 60%;
}

}

.message-form {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px;
  width: 100%;
}

#messageInput {
  width: 100% !important;
  min-height: 30px;
  max-height: 30px;
  height: 80px;
  font-size: 1rem;
  padding: 2px;
  border-radius: 12px;
}

.form-actions {
  width: 100%;
}

.send-main-btn {
  flex: 1;
  background: #2d6cdf;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: bold;
  cursor: pointer;
}

.send-main-btn:hover {
  background: #3f7ae4;
}

.icon-btn, .admin-link-btn {
  padding: 6px 10px;
  font-size: 0.9rem;
  border-radius: 8px;
  min-height: 32px;
}

.send-main-btn {
  padding: 8px 12px;
  font-size: 0.95rem;
  min-height: 34px;
}

.primary-btn, .send-main-btn, .admin-link-btn, .icon-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

body.modal-open {
  overflow: hidden;
}

.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
}

.gallery-dialog {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  background: #111827;
  border: 1px solid #334155;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
  overflow: hidden;
}

.gallery-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #334155;
  background: #0f172a;
}

.gallery-dialog-header h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.gallery-dialog-header p {
  margin: 0;
  color: #94a3b8;
  font-size: .92rem;
}

.gallery-close-btn {
  min-width: 38px;
}

.gallery-modal-body {
  padding: 16px;
  overflow: auto;
}

.gallery-modal-status {
  color: #cbd5e1;
  padding: 12px 0;
}

.gallery-upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 220px) auto;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}

.gallery-upload-form input[type="text"], .gallery-upload-form input[type="file"] {
  width: 100%;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px;
}

.gallery-upload-form input[type="file"] {
  padding: 8px 10px;
}

.gallery-upload-btn {
  white-space: nowrap;
}

.gallery-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.gallery-picker-card {
  border: 1px solid #334155;
  background: #1e293b !important;
  border-radius: 16px;
  color: #e5e7eb;
  text-align: left;
  padding: 10px;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
  position: relative;
}

.gallery-picker-card:hover {
  transform: translateY(-1px);
  border-color: #3b82f6;
  background: #243247;
}

.gallery-picker-card.is-sending {
  opacity: .7;
  pointer-events: none;
}

.gallery-picker-image {
  display: block;
  width: 100%;
  margin-bottom: 35px;
}

.gallery-picker-title {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.gallery-picker-date {
  display: block;
  color: #94a3b8;
  font-size: .82rem;
}

.chat-gallery-preview {
  display: grid;
  gap: 8px;
}

.chat-gallery-link {
  display: inline-block;
}

.chat-gallery-image {
  display: block;
  width: 100%;
  max-width: 350px;
  height: 200px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #334155;
  background: #0f172a;
}

.chat-gallery-caption {
  font-weight: 700;
  color: #e5e7eb;
}

.message-text.is-gallery-text {
  color: #cbd5e1;
}

@media (max-width: 700px) {
  .gallery-dialog {
  width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
}

  .gallery-modal-body {
  padding: 12px;
}

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

  .gallery-modal-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

  .gallery-picker-image {
  height: 150px;
}

}

.chat-gallery-caption {
  display: none;
}

.online-panel {
  background: rgba(0, 0, 0, 0.5) !important;
}

.online-item {
  background: rgba(255, 255, 255, 0.08) !important;
}

.online-item span, .online-item div {
  color: #ffffff !important;
  font-weight: 500;
}

.online-title {
  color: #ffffff !important;
}

.message-row {
  align-items: flex-end;
  gap: 10px;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.22);
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  background: rgba(255,255,255,0.08);
}

.chat-avatar.is-fallback {
  background: linear-gradient(135deg, #2d6cdf, rgba(255,255,255,0.18));
}

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

.message-row.self {
  flex-direction: row-reverse;
}

.message-row.self .message-meta {
  justify-content: flex-end;
}

.online-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-actions {
  display: flex !important;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.left-icons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.icon-btn {
  min-width: 42px !important;
  min-height: 38px !important;
  padding: 8px 12px !important;
  font-size: 18px !important;
  line-height: 1 !important;
  color: #ffffff !important;
  background: rgba(255,255,255,0.14) !important;
  border: 1px solid rgba(255,255,255,0.22) !important;
  position: relative;
  z-index: 20;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.24) !important;
}

.smiley-btn, #emojiBtn, button[title*="Emoji"], button[title*="Smiley"], button[aria-label*="Emoji"], button[aria-label*="Smiley"] {
  min-width: 46px !important;
  min-height: 40px !important;
  padding: 8px 12px !important;
  border-radius: 10px !important;
  border: 1px solid rgba(0,0,0,0.15) !important;
  background: #ffcc00 !important;
  color: #000000 !important;
  font-size: 22px !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  box-shadow: 0 6px 16px rgba(0,0,0,0.28) !important;
  position: relative;
  z-index: 30 !important;
}

.smiley-btn:hover, #emojiBtn:hover, button[title*="Emoji"]:hover, button[title*="Smiley"]:hover, button[aria-label*="Emoji"]:hover, button[aria-label*="Smiley"]:hover {
  background: #ffd84d !important;
  transform: translateY(-1px);
}

.emoji-picker {
  z-index: 9999 !important;
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
}

.smiley-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.smiley-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.smiley-picker-dialog {
  position: relative;
  z-index: 1;
  width: 980px;
  height: 560px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(12, 16, 26, 0.96);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}

.smiley-picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  background: linear-gradient(135deg, rgba(57, 77, 120, 0.55), rgba(18, 24, 38, 0.95));
}

.smiley-picker-header h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  color: #fff;
}

.smiley-picker-header p {
  margin: 0;
  color: #cbd5e1;
  font-size: .92rem;
}

.smiley-picker-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
  flex: 1;
}

.smiley-picker-sidebar {
  background: rgba(255,255,255,0.04);
  border-right: 1px solid rgba(255,255,255,0.1);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.smiley-category-tab {
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(45,108,223,.82), rgba(98, 76, 182, .82));
  box-shadow: 0 8px 16px rgba(0,0,0,.18);
}

.smiley-category-tab:nth-child(2n) {
  background: linear-gradient(135deg, rgba(2,132,199,.84), rgba(14,165,233,.74));
}

.smiley-category-tab:nth-child(3n) {
  background: linear-gradient(135deg, rgba(16,185,129,.84), rgba(34,197,94,.74));
}

.smiley-category-tab:nth-child(4n) {
  background: linear-gradient(135deg, rgba(245,158,11,.86), rgba(249,115,22,.76));
}

.smiley-category-tab:nth-child(5n) {
  background: linear-gradient(135deg, rgba(236,72,153,.86), rgba(168,85,247,.76));
}

.smiley-category-tab.active {
  outline: 2px solid rgba(255,255,255,0.92);
  transform: translateX(4px);
}

.smiley-picker-content {
  min-width: 0;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
}

.smiley-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.smiley-picker-item-card {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  border-radius: 14px;
  padding: 8px 6px;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.smiley-picker-item-card:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.smiley-picker-item-image {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
}

.smiley-picker-item-code {
  display: none;
}

.inline-smiley {
  width: auto !important;
  height: auto !important;
  max-width: 40px !important;
  max-height: 40px !important;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 2px;
}

.message-text {
  word-break: break-word;
}

@media (max-width: 1100px) {
  .smiley-picker-dialog {
  width: 900px;
}

  .smiley-picker-grid {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

}

@media (max-width: 820px) {
  .smiley-picker-dialog {
  width: calc(100vw - 16px);
  height: calc(100vh - 16px);
}

  .smiley-picker-layout {
  grid-template-columns: 170px 1fr;
}

  .smiley-picker-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

}

@media (max-width: 620px) {
  .smiley-picker-layout {
  grid-template-columns: 1fr;
}

  .smiley-picker-sidebar {
  flex-direction: row;
  flex-wrap: wrap;
  border-right: none;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

  .smiley-category-tab.active {
  transform: none;
}

  .smiley-picker-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

}

.chat-window .message-row, .chat-window .message-row.self, .chat-window .message-row.other, .chat-window .message-row.system-message {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  margin: 0 !important;
  padding: 3px 0 !important;
  text-align: left !important;
}

.chat-window .chat-avatar, .chat-window .message-row > .chat-avatar {
  margin: 0 !important;
}

.chat-window .message-content {
  order: 2 !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 7px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.chat-window .message-line {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 7px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  flex-wrap: wrap !important;
}

.chat-window .message-header {
  justify-content: flex-start !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.chat-window .message-username, .chat-window .username {
  order: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  flex: 0 0 auto !important;
  width: auto !important;
  white-space: nowrap !important;
  font-weight: 800 !important;
  line-height: 1.2 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.chat-window .message-time {
  order: 2 !important;
  display: inline-flex !important;
  align-items: center !important;
  flex: 0 0 auto !important;
  width: auto !important;
  white-space: nowrap !important;
  opacity: .65 !important;
  font-size: 11px !important;
  line-height: 1.2 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.chat-window .message-meta {
  display: none !important;
}

.chat-window .message-bubble, .chat-window .message-content .message-bubble, .chat-window .message-line .message-bubble {
  all: unset !important;
  order: 2 !important;
  display: contents !important;
}

.chat-window .message-text, .chat-window .message-bubble .message-text {
  order: 3 !important;
  display: inline-block !important;
  width: auto !important;
  max-width: min(72vw, 900px) !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 4px 8px !important;
  border-radius: 7px !important;
  background: rgba(0, 0, 0, 0.4) !important;
  color: #ffffff !important;
  line-height: 1.35 !important;
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
}

.chat-window .message-text:hover {
  background: rgba(0, 0, 0, 0.55) !important;
}

.chat-window .message-row.self {
  flex-direction: row !important;
  justify-content: flex-start !important;
}

.chat-window .system-message .message-text {
  font-size: 1rem !important;
  font-weight: 600 !important;
}

.chat-window .chat-gallery-preview {
  display: inline-grid !important;
  gap: 6px !important;
  max-width: 350px !important;
}

.chat-window .chat-gallery-image {
  max-width: 350px !important;
  height: auto !important;
  border-radius: 10px !important;
}

.chat-window .dice-number-color {
  font-weight: 900 !important;
}

@media (max-width: 768px) {
  .chat-window .message-row, .chat-window .message-row.self, .chat-window .message-row.other, .chat-window .message-row.system-message {
  gap: 6px !important;
  align-items: center !important;
}

  .chat-window .chat-avatar, .chat-window .message-row > .chat-avatar {
  flex-basis: 34px !important;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
}

  .chat-window .message-content, .chat-window .message-line {
  gap: 5px !important;
}

  .chat-window .message-text {
  max-width: calc(100vw - 130px) !important;
  padding: 3px 7px !important;
  font-size: 13px !important;
}

  .chat-window .message-time {
  font-size: 10px !important;
}

}

.chat-window .message-row, .chat-window .message-row.self, .chat-window .message-row.other {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
}

.chat-window .chat-avatar, .chat-window .message-row > .chat-avatar {
  order: 1 !important;
  flex: 0 0 38px !important;
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  max-width: 38px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
}

.chat-window .chat-avatar img, .chat-window .message-row > .chat-avatar img {
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  border-radius: 50% !important;
  display: block !important;
}

.chat-window .message-content, .chat-window .message-line {
  order: 2 !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 7px !important;
  flex-wrap: wrap !important;
}

.chat-window .message-header {
  order: 1 !important;
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 5px !important;
  flex: 0 0 auto !important;
}

.chat-window .message-username, .chat-window .username, .chat-window .message-time {
  display: inline-flex !important;
  width: auto !important;
  white-space: nowrap !important;
}

.chat-window .message-text {
  order: 2 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: wrap !important;
  width: auto !important;
  max-width: none !important;
}

.chat-window .message-content > a:not(.username), .chat-window .message-content > img, .chat-window .message-line > a:not(.username), .chat-window .message-line > img, .chat-window .chat-gallery-preview, .chat-window .chat-gallery-link {
  order: 2 !important;
}

.chat-window .message-content img:not(.inline-smiley), .chat-window .message-line img:not(.inline-smiley), .chat-window .message-text img:not(.inline-smiley), .chat-window .chat-gallery-image {
  max-width: 180px !important;
  max-height: 180px !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  border-radius: 8px !important;
}

.chat-window .inline-smiley {
  max-width: 350px !important;
  max-height: 240px !important;
  width: auto !important;
  height: auto !important;
}

@media (max-width: 768px) {
  .chat-window .message-content img:not(.inline-smiley), .chat-window .message-line img:not(.inline-smiley), .chat-window .message-text img:not(.inline-smiley), .chat-window .chat-gallery-image {
  max-width: 110px !important;
  max-height: 110px !important;
}

}

.chat-panel, .chat-window {
  width: 100% !important;
  min-width: 0 !important;
}

.chat-window .message-row, .chat-window .message-row.self, .chat-window .message-row.other, .chat-window .message-row.system-message {
  width: 100% !important;
  max-width: 100% !important;
}

.chat-window .message-content, .chat-window .message-line {
  flex: 1 1 auto !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

.chat-window .message-text:not(.is-gallery-text) {
  flex: 1 1 auto !important;
  width: auto !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

.chat-window .chat-gallery-preview, .chat-window .chat-gallery-link, .chat-window .message-text.is-gallery-text {
  flex: 0 1 auto !important;
  width: auto !important;
  max-width: 350px !important;
}

@media (max-width: 768px) {
  .chat-window .message-content, .chat-window .message-line {
  width: 100% !important;
  max-width: 100% !important;
}

  .chat-window .message-text:not(.is-gallery-text) {
  max-width: 100% !important;
  font-size: 13px !important;
}

}

.rsp-chat-header-player {
  position: relative;
  overflow: hidden;
}

.rsp-chat-header-player * {
  white-space: nowrap;
}

.rsp-chat-header-player span, .rsp-chat-header-player .track-title, .rsp-chat-header-player .marquee, .rsp-chat-header-player .nowplaying {
  display: inline-block;
  padding-left: 100%;
  animation: playerScroll 15s linear infinite;
}

@keyframes playerScroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

.online-item {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
}

.online-name-text {
  color: #fff !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
}

.online-avatar {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.online-avatar img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  border-radius: 50% !important;
}

.online-avatar.is-fallback {
  background: linear-gradient(135deg,#2d6cdf,rgba(255,255,255,.18)) !important;
  color: #fff !important;
  font-weight: 800 !important;
}

.profile-modal.hidden {
  display: none !important;
}

.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,.60);
}

.profile-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
}

.profile-dialog {
  position: relative;
  z-index: 1;
  width: min(720px, 96vw);
  height: min(760px, 92vh);
  border: 1px solid #334155;
  border-radius: 22px;
  background: #0f172a;
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.profile-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid #334155;
  background: #111827;
}

.profile-dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.profile-dialog-header p {
  margin: 4px 0 0;
  opacity: .72;
  font-size: 13px;
}

.profile-modal-body {
  flex: 1;
  min-height: 0;
  background: #0f172a;
}

.profile-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #0f172a;
}

@media (max-width: 720px) {
  .profile-modal {
  padding: 8px;
  align-items: stretch;
}

  .profile-dialog {
  width: 100%;
  height: 100%;
  border-radius: 16px;
}

}

.online-user-trigger {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 12px;
  padding: 7px 8px;
}

.online-user-trigger:hover, .online-user-trigger:focus-visible {
  background: rgba(96,165,250,.16) !important;
  outline: 1px solid rgba(96,165,250,.35);
}

.online-user-menu {
  position: absolute;
  z-index: 10050;
  min-width: 230px;
  padding: 8px;
  border: 1px solid rgba(148,163,184,.35);
  border-radius: 14px;
  background: rgba(15,23,42,.98);
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  backdrop-filter: blur(10px);
}

.online-user-menu-action {
  width: 100%;
  display: block;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: #f8fafc;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
}

.online-user-menu-action:hover:not(:disabled) {
  background: rgba(96,165,250,.20);
}

.online-user-menu-action:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.private-chat-window {
  position: fixed;
  z-index: 10040;
  height: min(520px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(148,163,184,.36);
  border-radius: 18px;
  overflow: hidden;
  background: #0f172a;
  color: #f8fafc;
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
}

.private-chat-window.minimized {
  height: auto;
}

.private-chat-window.minimized .private-chat-messages, .private-chat-window.minimized .private-chat-form {
  display: none;
}

.private-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(37,99,235,.35), rgba(14,165,233,.16));
  border-bottom: 1px solid rgba(148,163,184,.22);
}

.private-chat-header span {
  display: block;
  font-size: 12px;
  opacity: .72;
  margin-top: 2px;
}

.private-chat-actions {
  display: flex;
  gap: 6px;
}

.private-chat-actions .private-clear {
  font-size: 15px;
}

.private-empty {
  opacity: .75;
  text-align: center;
  padding: 18px 8px;
  font-size: 13px;
}

.private-chat-actions button {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  background: rgba(15,23,42,.65);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.private-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  background: rgba(2,6,23,.55);
}

.private-message-row {
  margin: 0 0 10px;
  display: flex;
  flex-direction: column;
}

.private-message-row.self {
  align-items: flex-end;
}

.private-message-row.other {
  align-items: flex-start;
}

.private-message-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 0 4px 3px;
  font-size: 12px;
  opacity: .78;
}

.private-message-bubble {
  max-width: 86%;
  border-radius: 15px;
  padding: 9px 11px;
  line-height: 1.35;
  background: rgba(30,41,59,.96);
  border: 1px solid rgba(148,163,184,.20);
  overflow-wrap: anywhere;
}

.private-message-row.self .private-message-bubble {
  background: rgba(37,99,235,.90);
}

.private-chat-form {
  padding: 10px;
  border-top: 1px solid rgba(148,163,184,.22);
  background: #111827;
}

.private-chat-form textarea {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  border: 1px solid rgba(148,163,184,.30);
  border-radius: 12px;
  padding: 9px 10px;
  background: #020617;
  color: #f8fafc;
}

.private-chat-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.private-chat-toolbar button {
  border: 0;
  border-radius: 11px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 800;
}

.private-smiley-toggle {
  background: rgba(148,163,184,.18);
  color: #f8fafc;
}

.private-chat-toolbar button[type="submit"] {
  background: #2563eb;
  color: #fff;
}

.private-smiley-panel.hidden {
  display: none;
}

.private-smiley-panel {
  margin-top: 9px;
  padding: 8px;
  border: 1px solid rgba(148,163,184,.25);
  border-radius: 12px;
  background: rgba(15,23,42,.98);
  max-height: 210px;
  overflow: auto;
}

.private-smiley-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 8px;
}

.private-smiley-tab {
  flex: 0 0 auto;
  border: 1px solid rgba(148,163,184,.22);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(30,41,59,.8);
  color: #f8fafc;
  cursor: pointer;
  font-size: 12px;
}

.private-smiley-tab.active {
  background: #2563eb;
}

.private-smiley-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 7px;
}

.private-smiley-item {
  border: 1px solid rgba(148,163,184,.20);
  border-radius: 10px;
  padding: 6px;
  background: rgba(2,6,23,.55);
  color: #f8fafc;
  cursor: pointer;
  min-height: 58px;
}

.private-smiley-item:hover {
  background: rgba(96,165,250,.20);
}

.private-smiley-item img {
  max-width: 30px;
  max-height: 30px;
  display: block;
  margin: 0 auto 3px;
}

.private-smiley-item span {
  display: block;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.private-smiley-empty {
  font-size: 13px;
  opacity: .75;
}

@media (max-width: 640px) {
  .private-chat-window {
  left: 8px !important;
  right: 8px !important;
  bottom: 8px !important;
  width: auto;
  height: min(520px, calc(100vh - 16px));
}

}

.online-item.online-self {
  cursor: default;
  opacity: 0.86;
}

.online-item.online-self small {
  font-size: 0.72em;
  opacity: 0.75;
  font-weight: 700;
}

.private-chat-window.has-new-private-message {
  animation: privateMessagePulse 0.6s ease-in-out 0s 2;
}

@keyframes privateMessagePulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.online-item.has-private-attention {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}

.private-attention-label {
  font-size: 0.78em;
  font-weight: 800;
  color: #3b82f6;
  margin-left: 3px;
}

.private-attention-label[hidden] {
  display: none !important;
}

.private-chat-window {
  width: min(320px, calc(100vw - 24px));
}

.private-chat-window.minimized .private-typing-indicator {
  display: none;
}

.private-typing-indicator {
  min-height: 20px;
  padding: 0 12px 8px;
  background: rgba(2,6,23,.55);
  color: #93c5fd;
  font-size: 12px;
  font-style: italic;
}

.private-typing-indicator:not(.active) {
  display: none;
}

@media (max-width: 760px) {
  .private-chat-window {
  width: calc(100vw - 24px);
  right: 12px !important;
}

}


/* === CHAT TOOLBOX CLOSE FIX === */
/* Chat Toolbox: Header-Button + schließbares Overlay */
.chat-toolbox{
    position:relative;
    z-index:9990;
    font-family:Arial, Helvetica, sans-serif;
    flex:0 0 auto;
}
.chat-toolbox-header{display:flex;align-items:center;}
.toolbox-main-btn{
    height:44px;
    min-width:118px;
    padding:0 14px;
    border-radius:14px;
    border:1px solid rgba(255,255,255,.22);
    background:linear-gradient(145deg, rgba(16,16,24,.96), rgba(45,45,60,.94));
    color:#fff;
    font-weight:700;
    font-size:14px;
    cursor:pointer;
    box-shadow:0 0 14px rgba(0,0,0,.45), 0 0 16px color-mix(in srgb, var(--chat-toolbox-accent,#00d4ff) 35%, transparent);
    transition:.2s ease;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    white-space:nowrap;
}
.toolbox-main-btn:hover{transform:translateY(-1px);color:var(--chat-toolbox-accent,#00d4ff);}
.toolbox-menu{
    position:absolute;
    right:0;
    top:52px;
    width:190px;
    padding:10px;
    display:none;
    gap:8px;
    flex-direction:column;
    border-radius:16px;
    background:rgba(10,10,14,.95);
    border:1px solid rgba(255,255,255,.14);
    box-shadow:0 10px 30px rgba(0,0,0,.58);
    backdrop-filter:blur(10px);
}
.chat-toolbox.open .toolbox-menu{display:flex;animation:toolboxPop .16s ease-out;}
.toolbox-menu button{
    display:flex;
    align-items:center;
    gap:10px;
    width:100%;
    padding:11px 12px;
    border:0;
    border-radius:12px;
    color:#fff;
    background:rgba(255,255,255,.08);
    cursor:pointer;
    text-align:left;
    font-size:14px;
}
.toolbox-menu button:hover{background:var(--chat-toolbox-accent,#00d4ff);color:#111;}

/* WICHTIGER FIX: Overlay ist immer ZU, bis JS .is-open setzt */
.toolbox-overlay,
.toolbox-overlay[hidden]{
    display:none !important;
}
.toolbox-overlay.is-open{
    position:fixed;
    inset:0;
    z-index:99999;
    display:grid !important;
    place-items:center;
    background:rgba(0,0,0,.62);
    backdrop-filter:blur(5px);
}
body.toolbox-modal-open{overflow:hidden;}
.toolbox-window{
    width:min(820px,94vw);
    height:min(700px,88vh);
    overflow:hidden;
    border-radius:20px;
    border:1px solid rgba(255,255,255,.16);
    background:#111;
    box-shadow:0 25px 70px rgba(0,0,0,.75), 0 0 26px color-mix(in srgb, var(--chat-toolbox-accent,#00d4ff) 28%, transparent);
}
.toolbox-header{
    height:48px;
    padding:0 14px 0 18px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    background:linear-gradient(90deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
    color:#fff;
    border-bottom:1px solid rgba(255,255,255,.12);
}
.toolbox-header strong{color:var(--chat-toolbox-accent,#00d4ff);}
.toolbox-actions{display:flex;gap:8px;}
.toolbox-actions button{
    width:34px;
    height:34px;
    border-radius:10px;
    border:0;
    background:rgba(255,255,255,.1);
    color:#fff;
    cursor:pointer;
    font-size:19px;
    line-height:1;
}
.toolbox-actions button:hover{background:var(--chat-toolbox-accent,#00d4ff);color:#111;}
#toolboxFrame{width:100%;height:calc(100% - 48px);border:0;background:#181818;display:block;}
@keyframes toolboxPop{from{opacity:0;transform:translateY(-8px) scale(.96)}to{opacity:1;transform:none}}
@media(max-width:900px){
    .header-left{flex-wrap:wrap;}
    .chat-toolbox{order:3;width:100%;}
    .toolbox-main-btn{width:100%;}
    .toolbox-menu{left:0;right:auto;width:100%;top:50px;}
}
@media(max-width:600px){
    .toolbox-window{width:100vw;height:100vh;border-radius:0;}
    .toolbox-overlay.is-open{place-items:stretch;}
}

/* Jonny: Emoji/Bild nur im Avatar, Name ohne Emoji größer anzeigen */
.online-jonny .jonny-avatar {
  box-shadow: 0 0 10px rgba(0,255,200,0.55) !important;
}

.online-jonny .jonny-avatar.is-fallback {
  font-size: 20px !important;
  background: linear-gradient(135deg, rgba(0,255,200,.35), rgba(45,108,223,.55)) !important;
}

.online-jonny .jonny-name {
  font-size: 16px !important;
  font-weight: 800 !important;
  color: #00ffcc !important;
  text-shadow: 0 0 8px rgba(0,255,200,0.45) !important;
}


/* Chat-Schriftfarbe Final-Fix: Inline-Farben aus dem Profil dürfen nicht von weißem Theme-CSS überschrieben werden */
.chat-window .message-text[style],
.chat-window .message-bubble .message-text[style],
.chat-window .message-content .message-text[style] {
  color: revert-layer;
}
