:root {
  --bg: #0c0e13;
  --panel: #12161eef;
  --panel-2: #161b26;
  --text: #e7e9f0;
  --muted: #9aa6bc;
  --accent: #a564fb;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.35);
  --danger: #f15b6c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #131a29, var(--bg));
  min-height: 100vh;
}

body.embed {
  overflow: hidden;
  background: transparent;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ========== DASHBOARD СТИЛИ ========== */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.floating-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #44ff44, #22aa22);
  border: none;
  color: white;
  font-size: 30px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.2s;
  z-index: 1000;
}

.floating-btn:hover {
  transform: scale(1.1);
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--panel);
  border-radius: 20px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  border: 1px solid var(--border);
}

.modal-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.modal-tab {
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 10px 10px 0 0;
}

.modal-tab.active {
  background: var(--accent);
  color: #0d1533;
}

.modal-tab-content {
  display: none;
}

.modal-tab-content.active {
  display: block;
}

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.room-card {
  background: var(--panel-2);
  border-radius: 12px;
  padding: 15px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-info h3 {
  margin: 0 0 5px 0;
}

.room-info p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.room-actions {
  display: flex;
  gap: 10px;
}

.room-actions .btn-small {
  padding: 5px 10px;
}

.btn-danger {
  background: rgba(241, 91, 108, 0.2);
  color: var(--danger);
}

.btn-join {
  background: rgba(68, 255, 68, 0.2);
  color: #44ff44;
}

.status-online {
  color: #44ff44;
  font-size: 10px;
}

.status-offline {
  color: #ff4444;
  font-size: 10px;
}

.empty-state {
  text-align: center;
  padding: 60px;
}

.role-badge {
  display: inline-block;
  background: rgba(122, 162, 255, 0.2);
  color: var(--accent);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-top: 4px;
}

/* ========== ОБЩИЕ СТИЛИ ========== */
.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 26px 18px 46px;
}

.header {
  padding: 16px 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0));
  border: 1px solid var(--border);
}

.header h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

/* ========== AUTH PAGE ========== */
.auth-container {
  width: min(420px, calc(100% - 32px));
  margin: 60px auto;
  padding: 32px;
  background: rgba(15, 19, 28, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px;
  border-radius: 18px;
}

.auth-tab {
  flex: 1;
  padding: 12px 14px;
  text-align: center;
  cursor: pointer;
  border-radius: 14px;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}

.auth-tab.active {
  background: rgba(122, 162, 255, 0.18);
  color: #ffffff;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form h2 {
  margin: 0 0 18px;
  font-size: 22px;
  color: #ffffff;
}

.auth-form label,
.modal-content form label {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
}

.auth-form input,
.modal-content form input,
.auth-form textarea,
.modal-content form textarea,
.auth-form select,
.modal-content form select {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 22, 31, 0.92);
  color: var(--text);
  font-size: 14px;
}

.auth-form button,
.modal-content form button {
  width: 100%;
  margin-top: 10px;
}

.auth-form .error {
  margin-top: 12px;
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
}

/* ========== MODAL FORM IMPROVEMENTS ========== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 20, 0.78);
  backdrop-filter: blur(10px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: rgba(15, 19, 28, 0.98);
  border-radius: 24px;
  padding: 32px;
  max-width: 520px;
  width: 92%;
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

.modal-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  padding: 8px;
}

.modal-tab {
  flex: 1;
  padding: 12px 16px;
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.modal-tab:hover {
  background: rgba(255, 255, 255, 0.06);
}

.modal-tab.active {
  background: rgba(122, 162, 255, 0.18);
  color: #ffffff;
}

.modal-content h3 {
  margin: 0 0 20px;
  font-size: 22px;
  color: #ffffff;
}

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

.card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(16, 19, 27, 0.9);
  border: 1px solid var(--border);
}

.form label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.form input[type='text'],
.form input[type='url'],
.form input[type='file'],
.form textarea,
.form select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(16, 19, 27, 0.8);
  color: var(--text);
  font-size: 14px;
}

.form textarea {
  resize: vertical;
}

.checkbox-group {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent), rgba(122, 162, 255, 0.75));
  color: #0d1533;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:active {
  transform: scale(0.98);
}

.hidden {
  display: none !important;
}

.result-row {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.result-row label {
  font-size: 13px;
  color: var(--muted);
}

.result-row input {
  font-family: monospace;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.footer {
  margin-top: 30px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ========== ROOM UI ========== */
.room {
  max-width: 1400px;
  margin: 0 auto;
  padding: 22px 40px 42px;
}

/* Полноэкранный режим для медиа-оверлея */
.room .tab-panel[data-panel="media"] {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  z-index: 2000;
}

.room .tab-panel[data-panel="media"]:not(.hidden) ~ .room__header,
.room .tab-panel[data-panel="media"]:not(.hidden) ~ .tabs {
  display: none;
}

.room__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 18px;
  background: rgba(16, 19, 27, 0.9);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.room__header h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

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

.room__links {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.room__links small {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.room__links a {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(22, 27, 38, 0.85);
  color: var(--text);
  font-size: 13px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.room__links a:hover {
  background: rgba(122, 162, 255, 0.2);
  border-color: rgba(122, 162, 255, 0.3);
  transform: translateY(-1px);
}

.tabs {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.tab {
  flex: 1;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 22, 31, 0.75);
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: rgba(113, 145, 255, 0.12);
  border-color: rgba(122, 162, 255, 0.4);
  color: var(--text);
}

.tab-panels {
  margin-top: 18px;
}

.tab-panel {
  padding: 18px;
  border-radius: 18px;
  background: rgba(16, 19, 27, 0.9);
  border: 1px solid var(--border);
}

.form-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.media-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.media-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(20, 25, 35, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.media-item button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.overlay-preview {
  margin-top: 16px;
  width: 100%;
  max-width: 100%;
  height: auto;
  position: relative;
  overflow: hidden;
  background: rgba(9, 12, 18, 0.65);
  border-radius: 8px;
  min-height: 320px;
}


.safe-zone {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  border: 2px dashed #ff4444;
  border-radius: 4px;
  background: rgba(255, 68, 68, 0.1);
  overflow: hidden;
}

.obs-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px solid rgba(68, 255, 68, 0.35);
  border-radius: 4px;
  background: rgba(68, 255, 68, 0.05);
  z-index: 0;
}

.overlay-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.25);
  font-size: 14px;
  pointer-events: none;
}

.embed {
  height: 100vh;
  margin: 0;
  background: transparent;
  overflow: hidden;
}

.embed__wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  background: transparent;
}

.embed__overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* ========== МЕДИА-ОБЪЕКТЫ ========== */
.media-object {
  position: absolute;
  cursor: move;
  user-select: none;
  box-sizing: border-box;
  transition: left 0.12s ease, top 0.12s ease, width 0.12s ease, height 0.12s ease, transform 0.12s ease;
  will-change: left, top, width, height, transform;
  border: none;
  background: transparent;
}

.media-object .media-content {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  background: transparent;
}

.media-object.active {
  /* Border styling handled by in-workzone/out-of-workzone classes */
}

.media-object.in-workzone {
  border: 2px solid #44ff44 !important;
  box-shadow: 0 0 0 2px rgba(68, 255, 68, 0.3) !important;
}

.media-object.out-of-workzone {
  border: 2px solid #ff9800 !important;
  box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.3) !important;
}

.media-object.media-hidden {
  opacity: 0.5;
  filter: grayscale(50%);
}

.media-object.media-hidden::after {
  content: 'Скрыто';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
}

.embed .media-object {
  border: none;
  box-shadow: none;
}

.media-object.media-hidden {
  display: block;
  filter: grayscale(80%);
}

.media-object.media-hidden::after {
  content: 'Скрыто';
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 6px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border-radius: 10px;
  pointer-events: none;
}

.media-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: rgba(122, 162, 255, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: auto;
  touch-action: none;
  display: none;
}

.media-object.active .media-handle {
  display: block;
  opacity: 1;
}

.media-delete-btn {
  position: absolute;
  width: 24px;
  height: 24px;
  top: -18px;
  right: -18px;
  background: #f15b6c;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: white;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: auto;
  padding: 0;
  line-height: 1;
}

.media-visibility-btn {
  position: absolute;
  width: 24px;
  height: 24px;
  top: -18px;
  right: -46px;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: rgba(0, 0, 0, 0.7);
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  pointer-events: auto;
  padding: 0;
  line-height: 1;
}

.media-visibility-btn.hidden {
  background: #f15b6c;
  color: white;
}

.media-object.active .media-delete-btn,
.media-object.active .media-visibility-btn {
  display: flex;
  opacity: 1;
}

/* Позиции ручек */
.handle-tl { top: -8px; left: -8px; cursor: nwse-resize; }
.handle-tm { top: -8px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle-tr { top: -8px; right: -8px; cursor: nesw-resize; }
.handle-ml { top: 50%; left: -8px; transform: translateY(-50%); cursor: ew-resize; }
.handle-mr { top: 50%; right: -8px; transform: translateY(-50%); cursor: ew-resize; }
.handle-bl { bottom: -8px; left: -8px; cursor: nesw-resize; }
.handle-bm { bottom: -8px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle-br { bottom: -8px; right: -8px; cursor: nwse-resize; }
.handle-center {
  top: -26px;
  left: 50%;
  width: 14px;
  height: 14px;
  background: rgba(255, 100, 100, 0.8);
  transform: translateX(-50%);
  cursor: grab;
}

.handle-center:active {
  cursor: grabbing;
}

/* ========== ГЛОБАЛЬНЫЙ СКРОЛЛБАР ========== */
:root {
  --scrollbar-width: 6px;        /* толщина ползунка */
  --scrollbar-height: 30px;
  --scrollbar-color: #a564fb;    /* цвет ползунка */
  --scrollbar-hover-color: #8249cc; /* цвет при наведении */
  --scrollbar-min-height: 10px;
  --scrollbar-max-height: 30px;
}

/* WebKit (Chrome, Edge, Safari) */
::-webkit-scrollbar {
  width: var(--scrollbar-width);
  height: var(--scrollbar-height);
  height: var(--scrollbar-width);  /* для горизонтальных скроллбаров тоже */
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-color);
  border-radius: calc(var(--scrollbar-width) / 2);
  min-height: var(--scrollbar-min-height);
  max-height: var(--scrollbar-max-height);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-hover-color);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-color) transparent;
}

/* ========== ЧАТ ========== */
.chat-log {
  margin-top: 14px;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(17, 22, 31, 0.75);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px;
  font-size: 13px;
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(113, 145, 255, 0.18);
  border: 1px solid rgba(122, 162, 255, 0.3);
  color: var(--text);
  font-size: 13px;
}

.tag button {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
}

/* Toast notification */
#notification {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.2s ease;
}

#notification.hidden {
  opacity: 0;
  visibility: hidden;
}

#notification:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.chat-messages-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* Кнопка сброса чата в самый низ */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: #a564fb;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
  opacity: 0.9;
  transition: opacity 0.2s;
  white-space: nowrap;
  display: none;          
}

.scroll-to-bottom-btn:hover {
  opacity: 1;
}

/* Стили для списка пользователей */
.users-list {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  max-height: 400px;
  overflow-y: auto;
}

.user-card {
  background: rgba(20, 25, 35, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
}

.user-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.user-card__header strong {
  color: var(--accent);
  font-size: 16px;
}

.user-card__details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.user-card__details span {
  display: block;
}

.btn-small {
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  background: rgba(122, 162, 255, 0.2);
  color: var(--text);
  cursor: pointer;
}

.btn-small.remove-user {
  background: rgba(241, 91, 108, 0.2);
  color: var(--danger);
}

.btn-small:hover {
  filter: brightness(1.1);
}

/* Twitch чат */
.twitch-settings {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.chat-visibility-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(122, 162, 255, 0.1);
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid rgba(122, 162, 255, 0.2);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #4a4e6b;
  transition: 0.3s;
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--accent), rgba(122, 162, 255, 0.75));
}

input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.toggle-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* Окно чата */
.twitch-chat-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 350px;
  height: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  overflow: hidden;
  transition: box-shadow 0.2s;
  position: relative; 
}

.twitch-chat-window:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* Заголовок окна чата */
.twitch-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-weight: bold;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.twitch-chat-header span {
  font-size: 14px;
  color: var(--text);
}

.twitch-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Кнопки в заголовке чата */
.twitch-chat-header-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 14px;
  padding: 0;
}

.twitch-chat-header-btn:hover {
  background: rgba(122, 162, 255, 0.25);
  border-color: rgba(122, 162, 255, 0.4);
  transform: scale(1.05);
}

.twitch-chat-header-btn:active {
  transform: scale(0.95);
}

/* Кнопка пользователей чата */
#chatUsersSettingsBtn {
  font-size: 16px;
}

#chatUsersSettingsBtn:hover {
  background: rgba(122, 162, 255, 0.35);
  border-color: rgba(122, 162, 255, 0.5);
}

/* Кнопка закрытия */
#closeChatWindow {
  font-size: 16px;
}

#closeChatWindow:hover {
  background: rgba(241, 91, 108, 0.5);
  border-color: rgba(241, 91, 108, 0.6);
}

/* Сообщения чата */
.twitch-chat-messages {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  font-size: 12px;
}

.twitch-chat-message {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  word-wrap: break-word;
}

.twitch-chat-message strong {
  color: var(--accent);
}

.twitch-chat-status {
  text-align: center;
  color: var(--muted);
  padding: 20px;
  font-size: 12px;
}

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

.twitch-chat-status.connected {
  color: #6b6b6b;
}

/* Информация о Twitch канале */
.twitch-channel-info {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: rgba(122, 162, 255, 0.1);
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid rgba(122, 162, 255, 0.2);
  transition: all 0.3s ease;
}

.twitch-channel-info:hover {
  background: rgba(122, 162, 255, 0.15);
  border-color: rgba(122, 162, 255, 0.4);
}

.channel-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--panel-2);
  flex-shrink: 0;
}

.channel-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.channel-details {
  flex: 1;
  min-width: 0;
}

.channel-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.channel-name span:first-child {
  font-weight: bold;
  font-size: 18px;
}

.channel-login {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 12px;
}

.live-status {
  font-size: 11px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(0,0,0,0.5);
}

.live-status.online {
  color: #44ff44;
  background: rgba(68, 255, 68, 0.2);
}

.live-status.offline {
  color: #ff4444;
  background: rgba(255, 68, 68, 0.2);
}

.stream-title {
  font-size: 14px;
  color: var(--text);
  margin-top: 6px;
  font-weight: 500;
  word-break: break-word;
}

.channel-game {
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
}

.channel-viewers {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.media-object.active {
  border-color: rgba(122, 162, 255, 1);
  box-shadow: 0 0 10px rgba(122, 162, 255, 0.5);
}

.media-hidden {
  opacity: 0.3;
}

.media-object:hover .media-delete-btn,
.media-object:hover .media-visibility-btn {
  opacity: 1;
}

.media-item:last-child {
  border-bottom: none;
}

.media-item label {
  flex: 1;
  font-size: 14px;
  word-break: break-all;
}

/* Copy notification popup */
.copy-notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  opacity: 0;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  transition: all 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

.copy-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ========== MEDIA OVERLAY СТИЛИ (MIRO-LIKE) ========== */

.media-overlay-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  z-index: 2000;
}

/* Кнопка меню слева */
.media-menu-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  background: rgba(122, 162, 255, 0.9);
  border: 2px solid white;
  border-radius: 10px;
  color: white;
  font-size: 24px;
  cursor: pointer;
  z-index: 3001;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.media-menu-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(122, 162, 255, 0.4);
}

/* Боковое меню навигации */
.media-side-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 3000;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.3);
}

.media-side-menu.active {
  transform: translateX(0);
}

.media-side-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.media-side-menu-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.media-side-menu-close {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-side-menu-close:hover {
  background: rgba(241, 91, 108, 0.3);
  border-color: var(--danger);
  color: var(--danger);
}

.media-side-menu-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  overflow-y: auto;
}

.media-side-menu-item {
  padding: 12px 16px;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  text-align: left;
  border: none;
}

.media-side-menu-item:hover {
  background: rgba(122, 162, 255, 0.15);
  border-color: rgba(122, 162, 255, 0.3);
}

.media-side-menu-item.active {
  background: rgba(122, 162, 255, 0.25);
  border-color: var(--accent);
  color: var(--accent);
}

.media-side-menu-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.media-side-menu-footer .btn-small {
  width: 100%;
  display: block;
  text-align: center;
}

/* Полотно MIRO-like */
.media-canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(45deg, rgba(122, 162, 255, 0.05) 1px, transparent 1px),
              linear-gradient(-45deg, rgba(122, 162, 255, 0.05) 1px, transparent 1px);
  background-size: 50px 50px;
  background-position: 0 0, 25px 25px;
  width: 100%;
  height: 100%;
}

/* ═══ МЕДИА КОНТРОЛЫ ═══ */
.media-controls {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2998;
  background: rgba(18, 22, 31, 0.9);
  border: 1px solid rgba(122, 162, 255, 0.3);
  border-radius: 12px;
  padding: 12px 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  gap: 12px;
  align-items: center;
}

.media-controls-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.media-control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 50px;
  height: 50px;
  background: rgba(122, 162, 255, 0.15);
  border: 2px solid rgba(122, 162, 255, 0.3);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.media-control-btn span {
  display: block;
  line-height: 1;
}

.media-control-btn small {
  font-size: 9px;
  color: rgba(122, 162, 255, 0.7);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.media-control-btn:hover {
  background: rgba(122, 162, 255, 0.3);
  border-color: rgba(122, 162, 255, 0.6);
  box-shadow: 0 0 12px rgba(122, 162, 255, 0.3);
  transform: translateY(-2px);
}

.media-control-btn:active {
  transform: translateY(0);
}

.media-zoom-display {
  background: rgba(122, 162, 255, 0.1);
  border: 1px solid rgba(122, 162, 255, 0.2);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  color: rgba(122, 162, 255, 0.8);
  font-weight: 600;
  min-width: 50px;
  text-align: center;
  font-family: 'Courier New', monospace;
}

/* ═══ УПРАВЛЕНИЕ ФОНОМ ═══ */
.media-bg-opacity-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(122, 162, 255, 0.1);
  border: 1px solid rgba(122, 162, 255, 0.2);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: rgba(122, 162, 255, 0.8);
}

.media-bg-opacity-control .opacity-label {
  white-space: nowrap;
  font-weight: 600;
}

.opacity-slider {
  width: 80px;
  height: 4px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(to right, #7aa2ff 0%, #7aa2ff 100%);
  border-radius: 2px;
  outline: none;
}

.opacity-slider:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  background: linear-gradient(to right, #555 0%, #555 100%);
}

.opacity-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: white;
  border: 2px solid #7aa2ff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.opacity-slider:disabled::-webkit-slider-thumb {
  background: #aaa;
  border-color: #666;
  cursor: not-allowed;
}

.opacity-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: white;
  border: 2px solid #7aa2ff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.opacity-slider:disabled::-moz-range-thumb {
  background: #aaa;
  border-color: #666;
  cursor: not-allowed;
}

.opacity-value {
  min-width: 35px;
  text-align: right;
  font-weight: 600;
}

/* ═══ MODAL ДЛЯ ФОНОВ ═══ */
#bgAddModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 3000;
  overflow-y: auto;
}

#bgAddModal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

.bg-name-section label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.bg-name-section input {
  padding: 8px 12px;
  border: 1px solid rgba(122, 162, 255, 0.3);
  border-radius: 4px;
  background: rgba(30, 35, 50, 0.6);
  color: var(--text);
  font-size: 14px;
}

.bg-source-tabs {
  display: flex;
  gap: 12px;
  margin: 12px 0;
  padding: 12px 0;
  border-top: 1px solid rgba(122, 162, 255, 0.2);
  border-bottom: 1px solid rgba(122, 162, 255, 0.2);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.radio-label:hover {
  background: rgba(122, 162, 255, 0.1);
}

.radio-label input[type="radio"] {
  cursor: pointer;
}

.bg-source-content {
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bg-preview-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: rgba(122, 162, 255, 0.05);
  border: 1px solid rgba(122, 162, 255, 0.2);
  border-radius: 4px;
}

.bg-presets-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(122, 162, 255, 0.2);
}

.bg-presets-section h4 {
  margin-bottom: 12px;
  color: rgba(122, 162, 255, 0.8);
}

.bg-presets-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.bg-preset-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: rgba(122, 162, 255, 0.1);
  border: 2px solid rgba(122, 162, 255, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bg-preset-item:hover {
  background: rgba(122, 162, 255, 0.2);
  border-color: rgba(122, 162, 255, 0.6);
  transform: translateY(-2px);
}

.bg-preset-item:hover .bg-preset-delete {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bg-preset-thumbnail {
  width: 60px;
  height: 60px;
  border-radius: 4px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.3);
}

.bg-preset-name {
  font-size: 11px;
  text-align: center;
  color: rgba(122, 162, 255, 0.8);
  word-break: break-word;
  max-width: 100%;
  line-height: 1.2;
}

.bg-preset-delete {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: rgba(255, 76, 76, 0.8);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: all 0.2s ease;
}

.bg-preset-delete:hover {
  background: rgba(255, 76, 76, 1);
  transform: scale(1.1);
}

.media-canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  z-index: 1;
}

.media-canvas-content {
  position: absolute;
  width: 5000px;
  height: 5000px;
  overflow: visible;
  transform-origin: 0 0;
  transition: transform 0.1s ease-out;
  pointer-events: auto;
}

.media-safe-zone {
  position: relative;
  width: 5000px;
  height: 5000px;
  cursor: grab;
  z-index: 10;
  /* ═══ СЕТКА ═══ */
  background-color: #0a0d12;
  background-image: 
    /* Основная сетка 100×100px (еле заметная) */
    linear-gradient(0deg, rgba(122, 162, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 162, 255, 0.08) 1px, transparent 1px),
    /* Вторичная сетка 500×500px (более видимая) */
    linear-gradient(0deg, rgba(122, 162, 255, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 162, 255, 0.15) 1px, transparent 1px);
  background-size: 
    100px 100px,
    100px 100px,
    500px 500px,
    500px 500px;
  background-position: 0 0, 0 0, 0 0, 0 0;
}

.media-safe-zone::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Маркеры координат каждые 1000px + красная центральная линия */
  background-image: 
    linear-gradient(90deg, rgba(76, 175, 80, 0.2) 2px, transparent 2px),
    linear-gradient(0deg, rgba(76, 175, 80, 0.2) 2px, transparent 2px),
    /* Центральные оси (красные) */
    linear-gradient(90deg, rgba(255, 100, 100, 0.3) 3px, transparent 3px);
  background-size: 1000px 100%, 100% 1000px, 100% 100%;
  background-position: 0 0, 0 0, 2500px 2500px;
  background-repeat: repeat, repeat, no-repeat;
  pointer-events: none;
  z-index: 0;
}

.media-safe-zone::after {
  content: "SAFEZONE (5000×5000) — Сетка 500px · Маркеры 1000px · Центр: красный крест";
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 12px;
  color: rgba(122, 162, 255, 0.7);
  font-weight: 600;
  pointer-events: none;
  z-index: 1;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid rgba(122, 162, 255, 0.3);
  line-height: 1.5;
  letter-spacing: 0.3px;
}

.media-safe-zone.dragging {
  cursor: grabbing;
}

.media-work-zone {
  position: absolute;
  top: 1960px;
  left: 1540px;
  background: rgba(122, 162, 255, 0);
  border: 3px solid rgba(122, 162, 255, 0.5);
  box-shadow: 
    0 0 20px rgba(122, 162, 255, 0.2) inset,
    0 0 0 1px rgba(122, 162, 255, 0.3);
  width: 1920px;
  height: 1080px;
  pointer-events: none;
  --bg-opacity: 1;
}

.media-work-zone::before {
  content: "WORKZONE (1920×1080) - Видимая в OBS embed";
  position: absolute;
  top: 15px;
  left: 15px;
  font-size: 13px;
  color: rgba(122, 162, 255, 0.7);
  font-weight: 600;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 10px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.media-work-zone::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(122, 162, 255, 0.3);
  pointer-events: none;
  border-radius: 2px;
}

.media-item-element {
  position: absolute;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: move;
  box-sizing: border-box;
  user-select: none;
  transition: outline 0.2s ease, border-color 0.2s ease;
  outline: none;
  z-index: 10;
}

/* ✅ Медиа видна в OBS embed (находится в workzone) */
.media-item-element.in-workzone {
}

/* ⚠️ Медиа НЕ видна в OBS embed (вне workzone) */
.media-item-element.out-of-workzone {
}

.media-item-element.out-of-workzone::after {
  content: "⚠️ Вне workzone";
  position: absolute;
  top: -24px;
  left: 0;
  font-size: 10px;
  background: rgba(255, 152, 0, 0.2);
  color: rgba(255, 152, 0, 0.8);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(255, 152, 0, 0.4);
  white-space: nowrap;
  pointer-events: none;
}

.media-item-element.active {
  outline: none;
  z-index: 100;
}

/* Показываем рамку только когда выделено или перемещается */
.media-item-element.active,
.media-item-element.dragging {
  border: 2px solid rgba(122, 162, 255, 0.6);
}

/* Зеленая рамка если в workzone и выделено */
.media-item-element.active.in-workzone,
.media-item-element.dragging.in-workzone {
  border-color: rgba(76, 175, 80, 0.8);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.3) inset;
}

/* Оранжевая рамка если вне workzone и выделено */
.media-item-element.active.out-of-workzone,
.media-item-element.dragging.out-of-workzone {
  border-color: rgba(255, 152, 0, 0.8);
  box-shadow: 0 0 8px rgba(255, 152, 0, 0.3) inset;
}

.media-item-element.disabled {
  filter: grayscale(100%) brightness(0.75);
  border: none;
}

.media-item-element-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(82, 81, 81, 0);
}

.media-item-element-content img,
.media-item-element-content video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.media-item-element > .media-item-handles {
  position: absolute;
  inset: -10px;
  pointer-events: none;
  z-index: 50;
  display: none;
}

/* Показываем ручки только когда выделено или перемещается */
.media-item-element.active > .media-item-handles,
.media-item-element.dragging > .media-item-handles {
  display: block;
  pointer-events: auto;
}

.media-resize-handle {
  position: absolute;
  pointer-events: auto;
  background: rgba(122, 162, 255, 0.9);
  border: 2px solid white;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  z-index: 200;
}

.media-resize-handle:hover {
  transform: scale(1.3);
  box-shadow: 0 2px 8px rgba(122, 162, 255, 0.6);
}

/* Угловые ручки */
.media-resize-handle.corner {
  background: rgba(122, 162, 255, 0.95);
  width: 14px;
  height: 14px;
}

.media-resize-handle.nw {
  top: -10px;
  left: -10px;
  cursor: nwse-resize;
}

.media-resize-handle.ne {
  top: -10px;
  right: -10px;
  cursor: nesw-resize;
}

.media-resize-handle.sw {
  bottom: -10px;
  left: -10px;
  cursor: nesw-resize;
}

.media-resize-handle.se {
  bottom: -10px;
  right: -10px;
  cursor: nwse-resize;
}

/* Грани */
.media-resize-handle.n {
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
  width: 20px;
  height: 10px;
}

.media-resize-handle.s {
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
  width: 20px;
  height: 10px;
}

.media-resize-handle.e {
  top: 50%;
  right: -8px;
  transform: translateY(-50%);
  cursor: ew-resize;
  width: 10px;
  height: 20px;
}

.media-resize-handle.w {
  top: 50%;
  left: -8px;
  transform: translateY(-50%);
  cursor: ew-resize;
  width: 10px;
  height: 20px;
}

/* Ручка поворота */
.media-rotate-handle {
  position: absolute;
  top: -35px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 24px;
  background: rgba(76, 175, 80, 0.9);
  border: 2px solid white;
  border-radius: 50%;
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M1 4v6h6M23 20v-6h-6" stroke="white" stroke-width="2"/></svg>') 12 12, grab;
  z-index: 200;
  pointer-events: auto;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

/* Показываем ручку поворота только когда выделено */
.media-item-element.active > .media-rotate-handle,
.media-item-element.dragging > .media-rotate-handle {
  display: flex;
}

.media-rotate-handle:hover {
  transform: translateX(-50%) scale(1.2);
  box-shadow: 0 3px 12px rgba(76, 175, 80, 0.6);
}

.media-rotate-handle::after {
  content: "↻";
  font-size: 14px;
  font-weight: bold;
}

/* Соединительная линия для ручки поворота */
.media-item-element.active::before,
.media-item-element.dragging::before {
  content: "";
  position: absolute;
  top: -35px;
  left: 50%;
  width: 2px;
  height: 35px;
  background: rgba(76, 175, 80, 0.5);
  transform: translateX(-50%);
  z-index: 49;
}

/* Язычок для панели слоев */
.media-layers-tab {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2999;
}

.media-layers-tab button {
  width: 44px;
  height: 44px;
  background: rgba(122, 162, 255, 0.9);
  border: 2px solid white;
  border-radius: 10px;
  cursor: pointer;
  color: white;
  font-size: 20px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.media-layers-tab button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(122, 162, 255, 0.4);
}

/* Правая панель слоев */
.media-layers-panel {
  width: 280px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2998;
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  box-shadow: -2px 0 16px rgba(0, 0, 0, 0.3);
}

.media-layers-panel.collapsed {
  transform: translateX(100%);
}

.media-layers-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.media-layers-header h3 {
  margin: 0;
  font-size: 16px;
}

.media-layers-collapse-btn {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-layers-collapse-btn:hover {
  background: rgba(122, 162, 255, 0.2);
  border-color: var(--accent);
}

.media-layers-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.media-layers-list.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.media-layer-item {
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: move;
  transition: all 0.2s ease;
  display: flex;
  gap: 8px;
  align-items: center;
}

.media-layer-item:hover {
  background: rgba(122, 162, 255, 0.1);
  border-color: rgba(122, 162, 255, 0.3);
}

.media-layer-item.active {
  background: rgba(122, 162, 255, 0.2);
  border-color: var(--accent);
}

.media-layer-item.drag-over {
  background: rgba(122, 162, 255, 0.3);
  border-color: var(--accent);
  transform: scaleY(1.05);
}

.media-layer-thumbnail {
  width: 32px;
  height: 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.media-layer-thumbnail img,
.media-layer-thumbnail video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-layer-info {
  flex: 1;
  min-width: 0;
}

.media-layer-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.media-layer-size {
  font-size: 11px;
  color: var(--muted);
}

.media-layer-visible-btn {
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.media-layer-visible-btn:hover {
  background: rgba(122, 162, 255, 0.3);
}

.media-layer-teleport-btn {
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.media-layer-teleport-btn:hover {
  background: rgba(76, 175, 80, 0.3);
  color: rgba(76, 175, 80, 0.9);
}

.media-layer-delete-btn {
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.media-layer-delete-btn:hover {
  background: rgba(241, 91, 108, 0.3);
  color: var(--danger);
}

.media-layers-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.media-layers-footer .hint {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Модальное окно добавления медиа */
.media-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.media-modal.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.media-modal-content {
  background: var(--panel);
  border-radius: 16px;
  padding: 0;
  max-width: 500px;
  width: 90%;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.media-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.media-modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.media-modal-close-btn {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 20px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-modal-close-btn:hover {
  background: rgba(241, 91, 108, 0.3);
  border-color: var(--danger);
  color: var(--danger);
}

.media-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.media-modal-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.media-modal-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.media-modal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.media-modal-tab-content {
  display: none;
}

.media-modal-tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.1);
}

.media-preview-container {
  margin-top: 20px;
  padding: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.media-preview {
  margin-bottom: 20px;
  text-align: center;
}

.media-settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

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

.size-input-group input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  transition: all 0.2s ease;
}

.size-input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.size-input-group span {
  color: var(--muted);
  font-weight: 500;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.toggle-switch-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-switch-group #mediaVisibleLabel {
  font-size: 13px;
  color: var(--muted);
  min-width: 60px;
}

/* Контекстное меню */
.media-context-menu {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  min-width: 160px;
  animation: fadeIn 0.15s ease;
}

.media-context-menu-item {
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.media-context-menu-item:hover {
  background: rgba(122, 162, 255, 0.2);
  color: var(--accent);
}

.media-context-menu-item.danger:hover {
  background: rgba(241, 91, 108, 0.2);
  color: var(--danger);
}

/* Контроли управления */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
}

.control-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

/* ========== BG CONFIRM MODAL ========== */
.bg-confirm-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bg-confirm-modal.active {
  opacity: 1;
}

.bg-confirm-content {
  background: rgba(18, 22, 30, 0.98);
  border: 1px solid rgba(122, 162, 255, 0.3);
  border-radius: 16px;
  padding: 0;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bg-confirm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(122, 162, 255, 0.15);
}

.bg-confirm-header h3 {
  margin: 0;
  font-size: 18px;
  color: #e7e9f0;
}

.bg-confirm-close {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  color: #9aa6bc;
  font-size: 18px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bg-confirm-close:hover {
  background: rgba(241, 91, 108, 0.2);
  border-color: rgba(241, 91, 108, 0.4);
  color: #f15b6c;
}

.bg-confirm-body {
  padding: 24px;
}

.bg-confirm-body p {
  margin: 0 0 12px;
  font-size: 15px;
  color: #e7e9f0;
  line-height: 1.5;
}

.bg-confirm-body p:last-child {
  margin-bottom: 0;
}

.bg-confirm-body strong {
  color: #f15b6c;
}

.bg-confirm-hint {
  font-size: 13px !important;
  color: #9aa6bc !important;
  font-style: italic;
}

.bg-confirm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid rgba(122, 162, 255, 0.15);
}

.bg-confirm-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.bg-confirm-cancel {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #e7e9f0;
}

.bg-confirm-cancel:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.bg-confirm-delete {
  background: rgba(241, 91, 108, 0.2);
  border-color: rgba(241, 91, 108, 0.4);
  color: #f15b6c;
}

.bg-confirm-delete:hover {
  background: rgba(241, 91, 108, 0.35);
  border-color: rgba(241, 91, 108, 0.6);
  box-shadow: 0 0 12px rgba(241, 91, 108, 0.3);
}

/* ========== NICK COLOR PICKER ========== */
.nick-color-picker-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nick-color-picker-modal.active {
  opacity: 1;
}

.nick-color-picker-content {
  background: rgba(22, 27, 38, 0.98);
  border: 1px solid rgba(122, 162, 255, 0.3);
  border-radius: 16px;
  padding: 0;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nick-color-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(122, 162, 255, 0.15);
}

.nick-color-picker-header h3 {
  margin: 0;
  font-size: 18px;
  color: #e7e9f0;
}

.nick-color-picker-close {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  color: #9aa6bc;
  font-size: 18px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nick-color-picker-close:hover {
  background: rgba(241, 91, 108, 0.2);
  border-color: rgba(241, 91, 108, 0.4);
  color: #f15b6c;
}

.nick-color-picker-body {
  padding: 24px;
}

.color-presets {
  margin-bottom: 24px;
}

.color-presets label {
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
  color: #9aa6bc;
}

.color-presets-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.color-preset-item {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: rgba(0, 0, 0, 0.5);
  font-weight: bold;
}

.color-preset-item:hover {
  transform: scale(1.1);
  border-color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.color-preset-item.selected {
  border-color: white;
  box-shadow: 0 0 0 2px rgba(122, 162, 255, 0.5);
}

.color-custom {
  margin-bottom: 8px;
}

.color-custom label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: #9aa6bc;
}

.color-custom-input {
  display: flex;
  gap: 8px;
}

.color-custom-input input {
  flex: 1;
  padding: 8px 12px;
  background: rgba(16, 19, 27, 0.8);
  border: 1px solid rgba(122, 162, 255, 0.3);
  border-radius: 6px;
  color: #e7e9f0;
  font-size: 14px;
  font-family: monospace;
}

.color-custom-input input:focus {
  outline: none;
  border-color: rgba(122, 162, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.1);
}

.color-custom-input .btn-small {
  padding: 8px 16px;
  white-space: nowrap;
}

.nick-color-picker-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(122, 162, 255, 0.15);
  display: flex;
  justify-content: flex-end;
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e7e9f0;
  border-radius: 8px;
  padding: 8px 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Стиль для ника с возможностью клика */
.nick-name {
  transition: opacity 0.2s ease;
  border-bottom: 1px dashed transparent;
}

.nick-name:hover {
  opacity: 0.8;
  border-bottom-color: currentColor;
}

/* ========== CHAT USERS PANEL ========== */
.chat-users-settings {
  margin-bottom: 20px;
}

.chat-users-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  background: rgba(122, 162, 255, 0.15);
  border: 1px solid rgba(122, 162, 255, 0.3);
  border-radius: 12px;
  padding: 12px 20px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-users-btn:hover {
  background: rgba(122, 162, 255, 0.25);
  border-color: rgba(122, 162, 255, 0.5);
  transform: translateY(-1px);
}

.chat-users-btn-icon {
  font-size: 20px;
}

/* Панель пользователей */
/* ========== CHAT USERS PANEL ========== */

/* Панель пользователей */
.chat-users-panel {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  background: rgba(18, 22, 30, 0.98);
  border: 1px solid rgba(122, 162, 255, 0.2);
  border-radius: 20px;
  display: none;
  flex-direction: column;
  z-index: 10001;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Заголовок панели */
.chat-users-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 20px;
  border-bottom: 1px solid rgba(122, 162, 255, 0.1);
  flex-shrink: 0;
  gap: 16px;
}

.chat-users-panel-header h3 {
  margin: 0;
  font-size: 20px;
  color: #e7e9f0;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Контролы в заголовке */
.chat-users-panel-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Поиск */
.chat-users-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 19, 27, 0.6);
  border: 1px solid rgba(122, 162, 255, 0.2);
  border-radius: 10px;
  padding: 6px 10px;
  transition: border-color 0.2s ease;
}

.chat-users-search:focus-within {
  border-color: rgba(122, 162, 255, 0.5);
}

.chat-users-search input {
  background: transparent;
  border: none;
  color: #e7e9f0;
  font-size: 13px;
  outline: none;
  width: 140px;
  padding: 0;
}

.chat-users-search input::placeholder {
  color: rgba(154, 166, 188, 0.5);
  font-style: italic;
}

.chat-users-search .btn-small {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 11px;
  color: #9aa6bc;
  cursor: pointer;
  transition: all 0.2s ease;
  display: none;
}

.chat-users-search .btn-small:hover {
  background: rgba(241, 91, 108, 0.2);
  border-color: rgba(241, 91, 108, 0.3);
  color: #f15b6c;
}

/* Кнопка закрытия */
.chat-users-panel-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  color: #9aa6bc;
  font-size: 16px;
  transition: all 0.2s ease;
}

.chat-users-panel-close:hover {
  background: rgba(241, 91, 108, 0.15);
  border-color: rgba(241, 91, 108, 0.3);
  color: #f15b6c;
}

/* Тело панели */
.chat-users-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 24px;
}

/* Группы */
.chat-users-groups {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Заголовок группы */
.chat-users-group {
  background: rgba(16, 19, 27, 0.4);
  border: 1px solid rgba(122, 162, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
}

.chat-users-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(122, 162, 255, 0.08);
}

.chat-users-group-icon {
  font-size: 16px;
}

.chat-users-group-title {
  font-size: 13px;
  font-weight: 600;
  color: #e7e9f0;
  flex: 1;
  letter-spacing: 0.3px;
}

.chat-users-group-count {
  font-size: 11px;
  color: #9aa6bc;
  background: rgba(122, 162, 255, 0.1);
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 500;
}

/* Список пользователей */
.chat-users-group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Карточка пользователя */
.chat-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(122, 162, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.chat-user-item:hover {
  background: rgba(122, 162, 255, 0.08);
  border-color: rgba(122, 162, 255, 0.15);
}

/* Имя пользователя */
.chat-user-name {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
  letter-spacing: 0.2px;
}

.chat-user-name:hover {
  background-color: rgba(122, 162, 255, 0.12);
}

/* Кнопки действий */
.chat-user-actions {
  display: flex;
  gap: 4px;
}

.chat-user-color-btn {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chat-user-color-btn:hover {
  background: rgba(122, 162, 255, 0.2);
  border-color: rgba(122, 162, 255, 0.4);
  transform: scale(1.05);
}

/* Пустое состояние */
.chat-users-empty {
  text-align: center;
  padding: 40px 20px;
  color: #9aa6bc;
  font-size: 14px;
}

.chat-users-empty p {
  margin: 0;
  font-style: italic;
}

.chat-users-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chat-users-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(122, 162, 255, 0.1);
}

.chat-users-group-icon {
  font-size: 16px;
}

.chat-users-group-title {
  font-size: 14px;
  font-weight: 600;
  color: #e7e9f0;
  flex: 1;
}

.chat-users-group-count {
  font-size: 12px;
  color: #9aa6bc;
  background: rgba(122, 162, 255, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
}

.chat-users-group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(122, 162, 255, 0.05);
  border-radius: 6px;
  transition: background 0.2s ease;
}

.chat-user-item:hover {
  background: rgba(122, 162, 255, 0.1);
}

.chat-user-name {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.chat-user-name:hover {
  background-color: rgba(122, 162, 255, 0.15);
}

.chat-user-actions {
  display: flex;
  gap: 4px;
}

.chat-user-color-btn {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chat-user-color-btn:hover {
  background: rgba(122, 162, 255, 0.2);
  border-color: rgba(122, 162, 255, 0.4);
}

.chat-users-empty {
  text-align: center;
  padding: 40px;
  color: #9aa6bc;
  font-size: 14px;
}

/* SOUNDPAD */
/* Саундпад панель */
.tab-panel[data-panel="soundpad"] {
  max-width: 1200px;
  margin: 0 auto;
}

.soundpad-container { padding: 20px; }
.soundpad-header { margin-bottom: 20px; }
.soundpad-grid {
  display: grid;
  grid-template-columns: repeat(6, 150px);
  gap: 15px;
  justify-content: center;
}

.soundpad-tile {
  width: 150px;
  background: var(--panel-2);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

.tile-icon {
  position: relative;
  width: 100%;
  height: 100px;
  background: #2a2f3a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile-icon-placeholder {
  font-size: 40px;
  color: var(--muted);
}

.tile-indicator {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #555;
}
.tile-indicator.local { background: #ff0; }
.tile-indicator.streaming { background: #0f0; }

.tile-name {
  font-size: 13px;
  margin: 8px 0;
  text-align: center;
  word-break: break-word;
}

.tile-actions button {
  background: var(--accent);
  border: none;
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  margin: 0 2px;
}

/* Плеер */
.audio-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  z-index: 9999;
}
.player-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
}
.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.status-indicator.stopped { background: red; }
.status-indicator.local { background: yellow; }
.status-indicator.streaming { background: lime; }

/* Очередь */
.stream-queue-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 10000;
  padding: 20px;
  overflow-y: auto;
}
.floating-queue-btn {
  position: fixed;
  bottom: 80px;
  right: 30px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  z-index: 10001;
}
