:root{ 
  --bg:245 248 255; 
  --text:24 28 35; 
  --muted:108 116 128; 
  --like:230 40 70; 
  --shadow:0 24px 80px rgba(16,24,40,.18);
  
  /* تنظیمات فاصله استوری‌ها */
  --stories-top-spacing: 80px;     /* فاصله بالای استوری‌ها (50% کم شده) */
  --stories-bottom-spacing: -50px;  /* فاصله پایین استوری‌ها (خیلی منفی برای نزدیک شدن به لوگو) */
  --stories-transform-y: 60px;   /* جابجایی عمودی رینگ‌ها (50% کم شده) */
}

/* Loading state */
.mlm-stories-loading {
  text-align: center;
  padding: 20px;
  color: #666;
  font-size: 14px;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Skeleton loading */
.mlm-story-ring.skeleton {
  opacity: 1;
}

.skeleton-border {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%) !important;
  background-size: 200% 100% !important;
  animation: skeleton-loading 1.5s infinite !important;
}

.skeleton-thumb {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%) !important;
  background-size: 200% 100% !important;
  animation: skeleton-loading 1.5s infinite !important;
}

.skeleton-title {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%) !important;
  background-size: 200% 100% !important;
  animation: skeleton-loading 1.5s infinite !important;
  height: 1.2em !important;
  border-radius: 4px !important;
  margin-top: 8px !important;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

/* Tray */
#mlm-stories {
  position: relative !important;
  z-index: 100 !important;
  margin-top: 20px !important;
  padding-top: var(--stories-top-spacing) !important;
  margin-bottom: var(--stories-bottom-spacing) !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

/* Move stories higher in default demo only */
body:not(.zhaket-demo) #mlm-stories {
  margin-top: -80px !important;
  padding-top: 40px !important;
  padding-bottom: 20px !important;
  margin-bottom: 20px !important;
}

#mlm-stories .mlm-stories-wrap {
  max-width: 1280px;
  margin: 0 auto !important;
  padding: 0 50px !important;
  padding-top: 0 !important;
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  -ms-overflow-style: none;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
  position: relative !important;
  top: 0 !important;
  transform: translateY(var(--stories-transform-y)) !important;
}

#mlm-stories .mlm-stories-wrap.grabbing {
  cursor: grabbing;
}

#mlm-stories .mlm-stories-wrap::-webkit-scrollbar {
  display: none;
}

#mlm-stories .mlm-stories-head {
  display: none; /* Hide title and arrows */
}

#mlm-stories .mlm-stories-inner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  overflow: visible;
  width: 100%;
}

/* Story chip */
.mlm-story-ring {
  flex: 0 0 auto;
  width: 82px;
  text-align: center;
}

.mlm-story-ring .ring-btn {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  margin: 0;
}

/* Ring */
.mlm-story-ring .ring-border {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 999px;
  padding: 3px;
  position: relative;
  transition: all 0.3s ease;
}

.mlm-story-ring .ring-thumb {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #fff center/cover;
  border: none;
  object-fit: cover;
}

.mlm-story-ring .ring-title {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: bold;
  line-height: 1.2;
  height: 2.4em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Unseen ring */
.mlm-story-ring:not(.seen) .ring-border {
  background: conic-gradient(#ff2f4e, #ff8aa0);
}

.mlm-story-ring:not(.seen) .ring-border::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(255, 47, 78, 0.35);
  animation: pulse 1.6s infinite ease-out;
}

@keyframes pulse {
  0% { opacity: 0.9; transform: scale(0.96); }
  100% { opacity: 0; transform: scale(1.1); }
}

/* Seen ring */
.mlm-story-ring.seen .ring-border {
  background: conic-gradient(#cfd6e4, #e7ebf4);
}

/* Overlay */
.mlm-story-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 998;
  pointer-events: none;
}

.mlm-story-overlay[style*="flex"] {
  pointer-events: auto;
}

.mlm-story-viewer {
  width: min(350px, 90vw);
  height: min(84vh, 720px);
  border-radius: 24px;
  background: transparent;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  touch-action: none;
  max-width: 1920px;
  max-height: 1080px;
}

.mlm-story-media {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.mlm-story-media img,
.mlm-story-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  width: auto;
  height: auto;
}

/* Header */
.mlm-story-top {
  position: absolute;
  top: 20px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 4;
}

.mlm-story-vendor-ava {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  background: #ccc center/cover;
}

/* Vendor name and time display */
.mlm-story-vendor-name {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.mlm-story-vendor-time {
  color: #fff;
  font-size: 12px;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.mlm-story-vendor {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.mlm-story-vendor small {
  opacity: 0.9;
}

.mlm-story-spacer {
  flex: 1;
}

.mlm-story-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  cursor: pointer;
}

/* Side actions */
.mlm-story-side {
  position: absolute;
  inset-inline-start: 14px;
  bottom: 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  z-index: 4;
}

.mlm-story-side .act {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  border: none;
  font-size: 18px;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.mlm-story-side .act:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.05);
}

.mlm-story-side .act i {
  font-size: 18px;
  line-height: 1;
}

.mlm-story-side .count {
  color: #fff;
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.mlm-story-side .hearted {
  background: rgba(255, 0, 0, 0.2) !important;
}

.mlm-story-side .hearted i {
  color: #ff0000 !important;
}

/* Product hint bubble */
.mlm-story-prod-tip {
  position: absolute;
  inset-inline-start: 68px;
  bottom: 168px;
  background: #fff;
  color: #111;
  padding: 6px 10px;
  border: 1px solid rgba(16, 24, 40, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 5;
}

.mlm-story-prod-tip.show {
    opacity: 1;
    transform: translateY(0);
}

/* Muted badge */
.mlm-story-muted-badge {
    position: absolute;
    top: 14px;
    inset-inline-start: 14px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    display: none;
    z-index: 4;
}

/* Progress bars for slides */
.mlm-story-progress-bars {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(5px);
  padding: 4px 8px;
  border-radius: 8px;
  flex-direction: row-reverse;
}

.mlm-story-progress-segment {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    overflow: hidden;
}

.mlm-story-progress-fill {
    width: 0%;
    height: 100%;
    background: #fff;
    border-radius: inherit;
    transition: width 0.08s linear;
    float: left;
}

/* Caption */
.mlm-story-caption {
  position: absolute;
  bottom: 42px;
  left: 3px;
  right: 3px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  font-weight: 600;
  z-index: 4;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  padding: 8px 12px;
  border-radius: 12px 12px 0 0;
}

/* Scrub */
.mlm-story-scrub {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 0px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 4;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  padding: 8px 12px;
  border-radius: 0 0 12px 12px;
  flex-direction: row-reverse;
}

.mlm-story-elapsed {
  color: #fff;
  font-size: 12px;
  opacity: 0.95;
  min-width: 44px;
}

.mlm-story-seek {
  -webkit-appearance: none;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  outline: none;
  direction: ltr;
}

.mlm-story-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
    border-radius: 50%;
  background: #fff;
  border: none;
  margin-top: 0px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.mlm-story-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
    border-radius: 50%;
  background: #fff;
  border: none;
}

/* Tap zones */
.mlm-story-tap-left,
.mlm-story-tap-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 2;
}

.mlm-story-tap-left {
  left: 0;
}

.mlm-story-tap-right {
  right: 0;
}

.mlm-story-muted-badge {
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  display: none;
  z-index: 4;
}

/* Comments panel */
.mlm-story-comments-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
  transform: translateY(110%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 6;
  display: flex;
  flex-direction: column;
  max-height: 65%;
  backdrop-filter: blur(10px);
}

.mlm-story-comments-panel.open {
  transform: translateY(0);
}


.mlm-story-cp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(16, 24, 40, 0.12);
  background: #fff;
  font-weight: 600;
  color: #1a202c;
}

.mlm-story-cp-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 300px;
  background: #fafbfc;
}

.mlm-story-cp-item {
  background: #f6f7fb;
  border: 1px solid rgba(16, 24, 40, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 8px;
}

.mlm-story-cp-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.mlm-story-cp-avatar {
  width: 24px !important;
  height: 24px !important;
  border-radius: 50% !important;
  object-fit: cover;
  border: 1px solid rgba(16, 24, 40, 0.1);
  flex-shrink: 0;
}

.mlm-story-cp-name {
  font-weight: 600;
  color: #1a202c;
  font-size: 12px;
}

.mlm-story-cp-content {
  color: #4a5568;
  line-height: 1.4;
  margin-right: 32px;
  word-wrap: break-word;
}

.mlm-story-cp-empty {
  text-align: center;
  color: #a0aec0;
  font-style: italic;
  padding: 20px;
}

.mlm-story-cp-input {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(16, 24, 40, 0.12);
  background: #fff;
}

.mlm-story-cp-input input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid rgba(16, 24, 40, 0.15);
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease;
}

.mlm-story-cp-input input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.mlm-story-cp-input button {
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  min-width: 60px;
}

.mlm-story-cp-input button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.mlm-story-cp-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #718096;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mlm-story-cp-close:hover {
  background: rgba(113, 128, 150, 0.1);
  color: #4a5568;
}

/* پاسخ‌ها */
.mlm-story-cp-replies {
  margin-top: 12px;
  padding-right: 20px;
  border-right: 2px solid #e0e0e0;
}

.mlm-story-cp-reply {
  margin-bottom: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.mlm-story-cp-reply:last-child {
  border-bottom: none;
}

.mlm-story-cp-reply .mlm-story-cp-avatar {
  width: 20px !important;
  height: 20px !important;
}

.mlm-story-cp-reply .mlm-story-cp-name {
  font-size: 11px;
  color: #666;
}

.mlm-story-cp-reply .mlm-story-cp-content {
  font-size: 12px;
  color: #555;
  margin-right: 28px;
  line-height: 1.4;
}

/* Heart effect */
.mlm-story-heart-fx {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 96px;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35));
}

@keyframes heartPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(0.95); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}

/* Force stories to be positioned lower */
body #mlm-stories {
  margin-top: 20px !important;
  padding-top: var(--stories-top-spacing) !important;
  margin-bottom: var(--stories-bottom-spacing) !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

/* Override any conflicting styles */
html body #mlm-stories {
  margin-top: 20px !important;
  padding-top: var(--stories-top-spacing) !important;
  margin-bottom: var(--stories-bottom-spacing) !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

/* Ultra high specificity override */
html body div#mlm-stories {
  margin-top: 20px !important;
  padding-top: var(--stories-top-spacing) !important;
  margin-bottom: var(--stories-bottom-spacing) !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

/* Force positioning with transform as backup */
#mlm-stories {
  transform: translateY(0) !important;
}

/* Emergency override - add this to your theme's style.css if needed */
#mlm-stories {
  margin-top: 20px !important;
  padding-top: var(--stories-top-spacing) !important;
  margin-bottom: var(--stories-bottom-spacing) !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

/* Large screens */
@media (min-width: 1200px) {
  :root {
    --stories-top-spacing: 90px;
    --stories-transform-y: 70px;
  }
}

/* Medium screens */
@media (min-width: 769px) and (max-width: 1199px) {
  :root {
    --stories-top-spacing: 80px;
    --stories-transform-y: 60px;
  }
}

/* Tablet responsive */
@media (max-width: 768px) and (min-width: 561px) {
  :root {
    --stories-top-spacing: 70px;
    --stories-transform-y: 50px;
  }
  
  #mlm-stories .mlm-stories-wrap {
    padding: 0 30px !important;
  }
}

/* Mobile responsive */
@media (max-width: 560px) {
  :root {
    --stories-top-spacing: 60px;
    --stories-transform-y: 40px;
  }
  
  /* تنظیم موقعیت رینگ‌ها در گوشی دمو دوم */
  body.zhaket-demo #mlm-stories {
    margin-top: 40px !important; /* فاصله از بالای صفحه */
    padding-top: 20px !important; /* فاصله داخلی */
  }
  
  body.zhaket-demo #mlm-stories .mlm-stories-wrap {
    transform: translateY(60px) !important; /* جابجایی عمودی رینگ‌ها */
  }
  
  /* تنظیمات اضافی برای دمو دوم در گوشی */
  body.zhaket-demo #mlm-stories {
    /* فاصله از پایین */
    margin-bottom: -30px !important;
    
    /* ارتفاع */
    min-height: 120px !important;
  }
  
  #mlm-stories .mlm-stories-wrap {
    padding: 0 20px !important;
  }
  
  .mlm-story-viewer {
    height: 100vh;
    width: 100vw;
    border-radius: 0;
    box-shadow: none;
    max-width: 100vw;
    max-height: 100vh;
    /* قاب ویدیو در گوشی - می‌توانید این مقادیر را تغییر دهید */
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.1);
  }
  
  .mlm-story-media img,
  .mlm-story-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* گوشه‌های گرد برای ویدیو در گوشی */
    border-radius: 0;
  }
  
  .mlm-story-side {
    bottom: 140px;
  }
  
  :root {
    --stories-top-spacing: 60px;
    --stories-transform-y: 40px;
  }
  
  #mlm-stories .mlm-stories-wrap {
    padding: 0 20px !important;
    padding-top: 0 !important;
  }
  
  /* Mobile comments styling */
  .mlm-story-comments-panel {
    max-height: 70%;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
  }
  
  .mlm-story-cp-item {
    padding: 10px 12px;
  }
  
  .mlm-story-cp-avatar {
    width: 20px !important;
    height: 20px !important;
  }
  
  .mlm-story-cp-name {
    font-size: 11px;
  }
  
  .mlm-story-cp-content {
    font-size: 12px;
    margin-right: 28px;
  }
  
  .mlm-story-cp-input {
    padding: 10px 12px;
  }
  
  .mlm-story-cp-input input {
    padding: 8px 10px;
    font-size: 12px;
  }
  
  .mlm-story-cp-input button {
    padding: 8px 12px;
    font-size: 12px;
    min-width: 50px;
  }
}

/* تنظیمات قاب ویدیو در گوشی - قابل تغییر */
@media (max-width: 560px) {
  /* قاب اصلی ویدیو */
  .mlm-story-viewer {
    /* اندازه قاب */
    border: 3px solid rgba(255, 255, 255, 0.3);
    
    /* گوشه‌های گرد */
    border-radius: 20px;
    
    /* سایه */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    /* پس‌زمینه */
    background: rgba(0, 0, 0, 0.1);
    
    /* فاصله از لبه‌ها */
    margin: 10px;
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
  }
  
  /* ویدیو داخل قاب */
  .mlm-story-media video {
    /* گوشه‌های گرد برای ویدیو */
    border-radius: 17px;
    
    /* فاصله از قاب */
    margin: 3px;
    width: calc(100% - 6px);
    height: calc(100% - 6px);
  }
  
  /* تصاویر داخل قاب */
  .mlm-story-media img {
    /* گوشه‌های گرد برای تصاویر */
    border-radius: 17px;
    
    /* فاصله از قاب */
    margin: 3px;
    width: calc(100% - 6px);
    height: calc(100% - 6px);
  }
  
  /* تنظیم موقعیت المان‌های بالای ویدیو در گوشی */
  .mlm-story-top {
    /* فاصله از بالای صفحه - می‌توانید این مقدار را تغییر دهید */
    top: 60px;
    
    /* فاصله از لبه‌ها */
    left: 20px;
    right: 20px;
  }
  
  /* تنظیم موقعیت نوار پیشرفت در گوشی */
  .mlm-story-progress-bars {
    /* فاصله از بالای صفحه - می‌توانید این مقدار را تغییر دهید */
    top: 40px;
    
    /* فاصله از لبه‌ها */
    left: 20px;
    right: 20px;
    
    /* سایه بیشتر برای وضوح بهتر */
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 12px;
  }
}