.container { max-width: 1200px; margin: 20px auto; padding: 0 16px; }

/* ensure the grid can use the full container width */
.wardrobe-grid {
  width: 100%;
  box-sizing: border-box;
  display: grid;
  /* limit track width to 350px so items stay close together when few in number */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 350px));
  gap: 32px;
  padding: 30px 0;
  justify-content: center;
}

/* allow items to shrink and images to fill their cell */
.wardrobe-item {
  min-width: 0;              /* important inside flex/grid cells */
  width: 100%;               /* force item to fill the grid track width */
  max-width: 350px;          /* restricted width as requested */
  background: linear-gradient(25deg, #189de4, #ffffff);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  box-shadow: 1px -1px 4px #002e4763;
  margin: 0 auto;            /* center in grid cell if it becomes smaller than 1fr */
  box-sizing: border-box;
}

.wardrobe-item img {
  width: 100%;
  height: auto;
  display: block;            /* avoid inline spacing issues */
  border-radius: 8px;
  background: #f1f1f1;
}

.image-wrapper {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  container-type: inline-size;
}

.favorite-ribbon {
  position: absolute;
  /* Fallback for browsers without cqi support */
  bottom: 20px;
  right: -35px;
  width: 140px;
  font-size: 13px;
  padding: 8px 0;
  
  /* Scalable values */
  width: 50cqi;
  right: -10cqi;
  bottom: 11cqi;
  font-size: 4.5cqi;
  padding: 2cqi 0;
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  color: #222;
  font-weight: 800;
  text-align: center;
  transform: rotate(-45deg);
  box-shadow: 0 3px 6px rgba(0,0,0,0.25);
  z-index: 5;
  pointer-events: none;
  letter-spacing: 0.05em;
  line-height: 1;
}

.menu-btn {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 10;
  transition: background 0.2s ease, transform 0.2s ease;
}

.menu-btn:hover {
  background: #fff;
  transform: scale(1.05);
}

.menu-btn svg {
  display: block;
  color: #555;
}

.submenu {
  position: absolute;
  bottom: 45px;
  left: 8px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 15;
  min-width: 160px;
}

.submenu.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.submenu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9em;
  color: #333;
  transition: background 0.15s ease;
}

.submenu-item:hover {
  background: #f5f5f5;
}

.submenu-item svg {
  flex-shrink: 0;
}

.submenu-item.favorite-option svg {
  color: #ffd700;
}

.submenu-item.delete-option svg {
  color: #d45c3a;
}

.submenu-item.donate-option svg {
  color: #3ea198;
}

.reason-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.reason-overlay.visible { opacity: 1; pointer-events: auto; }

.reason-content { width: 100%; max-height: 100%; overflow-y: auto; text-align: center;}

.reason-content h3 { margin-top: 0; margin-bottom: 8px; font-size: 1.1em; color:#fff597}

.reason-text { margin: 10px 0; line-height: 1.2; color: #fff; padding: 10px 5px;font-weight: 600;font-size:1.1em}

.overlay-close {
  background: #3ea198;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
}

.overlay-close:hover { background: #32867f; }

.card-info {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
  gap: 8px;
}

#emptyMsg { text-align: center; margin: 40px 0; color: var(--muted, #9aa); }

/* Ensure upload icon appears to the left of the label */
.menu-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  flex-direction: row;
}

.menu-box svg { order: 0; flex: none; }

.menu-box .menu-label { order: 1; display: inline-block; }
