:root {
  --bg-dark: #090a0f;
  --bg-panel: #121420;
  --bg-card: #181b2c;
  --bg-card-hover: #20243a;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --accent: #e11d48;
  --accent-hover: #f43f5e;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

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

html, body {
  height: 100%;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 0.94rem;
}

.hidden {
  display: none !important;
}

/* Top Navigation Bar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(18, 20, 32, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 800;
  font-size: 1.2rem;
  cursor: pointer;
  letter-spacing: -0.02em;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-purple));
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-link {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  background: transparent;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  background: var(--bg-card);
  border-color: var(--border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.05rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #be123c);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  transform: translateY(-1px);
}

.btn-purple {
  background: linear-gradient(135deg, var(--accent-purple), #6d28d9);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-success {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.45);
  color: #34d399;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: #f87171;
}

.btn-sm {
  padding: 0.32rem 0.65rem;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 0.78rem 1.45rem;
  font-size: 1.02rem;
  border-radius: var(--radius);
}

/* Containers & Public Pages */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.2rem 1.5rem 4rem;
}

.hero {
  text-align: center;
  padding: 2.8rem 1.5rem;
  background: radial-gradient(circle at 50% 0%, rgba(225, 29, 72, 0.2), rgba(139, 92, 246, 0.08) 55%, transparent 80%);
  border: 1px solid var(--border);
  border-radius: 20px;
  margin-bottom: 2.5rem;
}

.hero-tag {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  background: rgba(225, 29, 72, 0.16);
  border: 1px solid rgba(225, 29, 72, 0.4);
  color: #fda4af;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(1.9rem, 4vw, 3.1rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

.hero p {
  max-width: 740px;
  margin: 0 auto 1.75rem;
  color: var(--text-muted);
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.2rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card p {
  color: var(--text-muted);
  font-size: 0.93rem;
}

.feature-icon {
  font-size: 1.5rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.input, .select {
  width: 100%;
  padding: 0.62rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s;
}

.input:focus, .select:focus {
  border-color: var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* Room Directory Cards */
.directory-toolbar {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.directory-toolbar .input {
  flex: 1;
  min-width: 180px;
}

.directory-toolbar .select {
  width: 165px;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 460px;
  overflow-y: auto;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.room-item:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.room-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.28rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.badge-lang {
  background: rgba(6, 182, 212, 0.18);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.35);
  text-transform: uppercase;
}

.badge-live {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.5);
  animation: pulseLive 1.8s infinite;
}

@keyframes pulseLive {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Cinema Watch Room Layout */
.cinema-layout {
  display: grid;
  grid-template-columns: 1fr 370px;
  height: calc(100vh - 57px);
  overflow: hidden;
}

.cinema-layout.sidebar-collapsed {
  grid-template-columns: 1fr 0px;
}

.cinema-main {
  display: flex;
  flex-direction: column;
  background: #05060a;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* Host Source Toolbar */
.room-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.room-title-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.host-source-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  background: rgba(24, 27, 44, 0.85);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

/* Video Stage (Supports Fullscreen with Floating Popups & Subtitles Inside) */
.cinema-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
  user-select: none;
}

.cinema-stage:fullscreen {
  width: 100vw;
  height: 100vh;
}

.video-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#local-Or-Remote-Video {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
}

#youtube-container {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

#youtube-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* Freeze-frame Canvas for Camera / Screen Pause */
#freeze-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  z-index: 6;
}

/* Synchronized Subtitle Overlay */
.subtitle-overlay {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 82%;
  text-align: center;
  z-index: 20;
  pointer-events: none;
}

.subtitle-text {
  display: inline-block;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: clamp(1rem, 2.2vw, 1.55rem);
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  border-radius: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
  white-space: pre-line;
}

/* Floating Popups ("Вспивашки") Inside Video Stage & Fullscreen */
.floating-toasts {
  position: absolute;
  top: 18px;
  right: 18px;
  width: min(360px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  z-index: 35;
  pointer-events: none;
}

.toast-bubble {
  pointer-events: auto;
  background: rgba(15, 17, 28, 0.86);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
  animation: toastSlideIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.toast-bubble.fading-out {
  opacity: 0;
  transform: translateX(20px);
}

.toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.toast-body {
  font-size: 0.9rem;
  word-break: break-word;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Fullscreen Quick Chat Input Overlay */
.fullscreen-quick-chat {
  position: absolute;
  bottom: 78px;
  left: 20px;
  width: min(420px, 85vw);
  z-index: 35;
  display: flex;
  gap: 0.45rem;
  background: rgba(15, 17, 28, 0.88);
  backdrop-filter: blur(12px);
  padding: 0.45rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
}

/* Unified Synchronized Player Control Bar */
.player-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.7rem 1.1rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.55) 70%, transparent);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  z-index: 30;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.seek-slider {
  flex: 1;
  height: 6px;
  accent-color: var(--accent);
  cursor: pointer;
}

.time-label {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: #e5e7eb;
  min-width: 95px;
  text-align: right;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

/* Sidebar: Participants Mixer & Chat */
.cinema-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  height: 100%;
  overflow: hidden;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.sidebar-tab {
  padding: 0.7rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
}

.sidebar-tab.active {
  color: var(--text-main);
  border-bottom-color: var(--accent);
  background: rgba(225, 29, 72, 0.08);
}

.sidebar-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Voice Bar & Audio Settings */
.voice-toolbar {
  padding: 0.75rem 0.9rem;
  background: rgba(24, 27, 44, 0.7);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.voice-buttons {
  display: flex;
  gap: 0.45rem;
}

.voice-buttons .btn {
  flex: 1;
}

/* Participants List & Per-User 0-200% Volume Sliders */
.participants-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.participant-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.participant-card.speaking {
  border-color: var(--success);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.participant-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.participant-identity {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.avatar-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.participant-volume-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.participant-volume-row input[type="range"] {
  flex: 1;
  height: 5px;
  accent-color: var(--accent-cyan);
}

.host-mod-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* Chat Messages & Clickable Seek Markers */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.89rem;
}

.chat-item.system {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 0.81rem;
  border-style: dashed;
}

.chat-item.seek-event {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.38);
}

.seek-return-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.35rem;
  padding: 0.24rem 0.6rem;
  border-radius: 6px;
  background: rgba(225, 29, 72, 0.22);
  border: 1px solid rgba(225, 29, 72, 0.55);
  color: #fda4af;
  font-weight: 700;
  font-size: 0.79rem;
  cursor: pointer;
  transition: all 0.15s;
}

.seek-return-btn:hover {
  background: var(--accent);
  color: #fff;
}

.chat-input-box {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin: 1rem auto;
  width: fit-content;
}

@media (max-width: 920px) {
  .cinema-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 56vh 1fr;
  }
  .cinema-sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
